From 1833020caf9bc68216fb4c87fc2ed2fd61b74269 Mon Sep 17 00:00:00 2001 From: Christ Date: Thu, 13 Aug 2026 20:04:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=89=88=E6=9C=AC=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=B5=81=E7=A8=8B=E5=B9=B6=E5=A4=84=E7=90=86=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=A4=B1=E6=95=88=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/desktop-cd.yml | 103 ++++------- .github/workflows/docker-publish.yml | 43 +++-- .github/workflows/release.yml | 149 ++++++++++++++++ Dockerfile.debian13 | 7 +- README.md | 24 +-- cmd/server/main.go | 16 +- cmd/tray/main.go | 2 + docs/slider-captcha-frozen-spec.md | 10 ++ frontend/components/AccountList.tsx | 10 +- frontend/components/Sidebar.tsx | 98 ++++++++--- frontend/services/api.ts | 5 +- internal/account/manager.go | 9 + internal/adapter/adapter.go | 6 +- internal/automation/account_tasks.go | 87 +++++++++- internal/automation/account_tasks_test.go | 75 ++++++++ internal/automation/center.go | 3 + internal/browser/token_captcha.go | 103 ++++++++++- internal/browser/token_captcha_fallback.go | 4 + ...token_captcha_fallback_integration_test.go | 38 ++++ .../token_captcha_orchestrator_test.go | 44 +++++ internal/browser/token_captcha_test.go | 17 ++ internal/engine/account.go | 14 +- internal/renewal/scheduler.go | 12 ++ internal/renewal/scheduler_test.go | 20 +++ internal/server/chat_handlers.go | 16 ++ internal/server/cookie_handlers.go | 1 + internal/server/item_handlers.go | 25 ++- .../server/item_publish_batch_handlers.go | 10 +- internal/server/order_handlers.go | 23 +++ internal/server/qrlogin_handlers.go | 22 ++- internal/server/qrlogin_keyword_test.go | 21 ++- internal/server/server.go | 24 ++- internal/server/server_test.go | 3 + internal/version/version.go | 22 +++ internal/version/version_test.go | 13 ++ ...r-DF3hof7q.js => icons-vendor-BpMgNNfy.js} | 163 +++++++++--------- .../webui/static/assets/index-BNFvzMjk.css | 1 - .../webui/static/assets/index-DVSGe2YH.css | 1 + .../webui/static/assets/index-DhAArJzx.js | 19 -- .../webui/static/assets/index-Nsmvj8uh.js | 19 ++ internal/webui/static/index.html | 6 +- internal/xianyu/mtop/account_tasks.go | 6 + internal/xianyu/mtop/account_tasks_test.go | 19 ++ internal/xianyu/mtop/client.go | 44 ++++- internal/xianyu/mtop/client_test.go | 16 +- internal/xianyu/mtop/consign.go | 3 + internal/xianyu/mtop/item_detail.go | 3 + internal/xianyu/mtop/items.go | 3 + internal/xianyu/mtop/order_detail.go | 3 + internal/xianyu/mtop/sold_orders.go | 3 + internal/xianyu/mtop/token.go | 3 + internal/xianyu/mtop/user_profile.go | 3 + 52 files changed, 1129 insertions(+), 265 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 internal/version/version.go create mode 100644 internal/version/version_test.go rename internal/webui/static/assets/{icons-vendor-DF3hof7q.js => icons-vendor-BpMgNNfy.js} (74%) delete mode 100644 internal/webui/static/assets/index-BNFvzMjk.css create mode 100644 internal/webui/static/assets/index-DVSGe2YH.css delete mode 100644 internal/webui/static/assets/index-DhAArJzx.js create mode 100644 internal/webui/static/assets/index-Nsmvj8uh.js diff --git a/.github/workflows/desktop-cd.yml b/.github/workflows/desktop-cd.yml index 0b13d93..248e360 100644 --- a/.github/workflows/desktop-cd.yml +++ b/.github/workflows/desktop-cd.yml @@ -5,10 +5,13 @@ on: branches: - main - dev - - codex/desktop-packaging - tags: - - 'v*.*.*' workflow_dispatch: + workflow_call: + inputs: + app_version: + description: 正式发布版本号(不含 v) + required: true + type: string permissions: contents: read @@ -23,22 +26,28 @@ jobs: runs-on: ubuntu-24.04 outputs: app_version: ${{ steps.version.outputs.app_version }} + build_version: ${{ steps.version.outputs.build_version }} + build_time: ${{ steps.version.outputs.build_time }} steps: - name: 解析并校验版本号 id: version shell: bash run: | set -Eeuo pipefail - if [[ "$GITHUB_REF" == refs/tags/* ]]; then - if [[ ! "$GITHUB_REF_NAME" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then - echo "版本标签必须符合 v1.2.3 格式:$GITHUB_REF_NAME" >&2 - exit 1 - fi - app_version="${GITHUB_REF_NAME#v}" + if [ -n "${{ inputs.app_version }}" ]; then + app_version="${{ inputs.app_version }}" + build_version="$app_version" else - app_version="0.0.0-${GITHUB_RUN_NUMBER}" + app_version="0.0.${GITHUB_RUN_NUMBER}" + build_version="${GITHUB_REF_NAME}-${GITHUB_SHA::12}" + fi + if [[ ! "$app_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "安装包版本必须符合 1.2.3 格式:$app_version" >&2 + exit 1 fi echo "app_version=$app_version" >> "$GITHUB_OUTPUT" + echo "build_version=$build_version" >> "$GITHUB_OUTPUT" + echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT" linux: name: Linux 安装包 (${{ matrix.arch }}) @@ -46,6 +55,8 @@ jobs: runs-on: ${{ matrix.runner }} env: APP_VERSION: ${{ needs.prepare.outputs.app_version }} + BUILD_VERSION: ${{ needs.prepare.outputs.build_version }} + BUILD_TIME: ${{ needs.prepare.outputs.build_time }} strategy: fail-fast: false matrix: @@ -84,7 +95,8 @@ jobs: run: | package_dir="dist/ydisks-xianyu-helper-linux-${GOARCH}" mkdir -p "$package_dir" - go build -trimpath -ldflags='-s -w' -o "$package_dir/xianyu-server" ./cmd/server + version_ldflags="-s -w -X xianyu-go/internal/version.Version=$BUILD_VERSION -X xianyu-go/internal/version.Commit=$GITHUB_SHA -X xianyu-go/internal/version.BuildTime=$BUILD_TIME" + go build -trimpath -ldflags="$version_ldflags" -o "$package_dir/xianyu-server" ./cmd/server go build -trimpath -ldflags='-s -w' -o "$package_dir/browser-install" ./cmd/browser-install - name: 恢复 Linux Chromium runtime 缓存 @@ -175,6 +187,8 @@ jobs: runs-on: windows-latest env: APP_VERSION: ${{ needs.prepare.outputs.app_version }} + BUILD_VERSION: ${{ needs.prepare.outputs.build_version }} + BUILD_TIME: ${{ needs.prepare.outputs.build_time }} steps: - name: 检出代码 uses: actions/checkout@v6 @@ -225,7 +239,8 @@ jobs: run: | & packaging/windows/build-resources.ps1 New-Item -ItemType Directory -Force -Path dist/windows | Out-Null - go build -trimpath -ldflags "-s -w" -o dist/windows/xianyu-server.exe ./cmd/server + $versionLdflags = "-s -w -X xianyu-go/internal/version.Version=$env:BUILD_VERSION -X xianyu-go/internal/version.Commit=$env:GITHUB_SHA -X xianyu-go/internal/version.BuildTime=$env:BUILD_TIME" + go build -trimpath -ldflags $versionLdflags -o dist/windows/xianyu-server.exe ./cmd/server go build -trimpath -ldflags "-s -w" -o dist/windows/browser-install.exe ./cmd/browser-install go build -trimpath -ldflags "-s -w -H=windowsgui" -o dist/windows/xianyu-tray.exe ./cmd/tray @@ -584,6 +599,8 @@ jobs: runs-on: macos-14 env: APP_VERSION: ${{ needs.prepare.outputs.app_version }} + BUILD_VERSION: ${{ needs.prepare.outputs.build_version }} + BUILD_TIME: ${{ needs.prepare.outputs.build_time }} steps: - name: 检出代码 uses: actions/checkout@v6 @@ -610,8 +627,9 @@ jobs: - name: 编译 macOS 桌面程序 run: | mkdir -p dist/macos/arm64 dist/macos/amd64 + version_ldflags="-s -w -X xianyu-go/internal/version.Version=$BUILD_VERSION -X xianyu-go/internal/version.Commit=$GITHUB_SHA -X xianyu-go/internal/version.BuildTime=$BUILD_TIME" for arch in arm64 amd64; do - GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags='-s -w' -o "dist/macos/$arch/xianyu-server" ./cmd/server + GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags="$version_ldflags" -o "dist/macos/$arch/xianyu-server" ./cmd/server GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags='-s -w' -o "dist/macos/$arch/browser-install" ./cmd/browser-install GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags='-s -w' -o "dist/macos/$arch/xianyu-tray" ./cmd/tray done @@ -736,62 +754,3 @@ jobs: name: ydisks-xianyu-helper-macos-amd64-${{ env.APP_VERSION }} path: dist/macos/Ydisks-Xianyu-Helper-${{ env.APP_VERSION }}-amd64.pkg if-no-files-found: error - - release: - name: 发布 GitHub Release - if: startsWith(github.ref, 'refs/tags/v') - needs: - - prepare - - linux - - windows - - macos - runs-on: ubuntu-24.04 - permissions: - contents: write - steps: - - name: 下载全部平台安装包 - uses: actions/download-artifact@v8 - with: - pattern: ydisks-xianyu-helper-* - path: dist/release - merge-multiple: true - - - name: 校验 Release 文件 - shell: bash - run: | - set -Eeuo pipefail - test -f "dist/release/ydisks-xianyu-helper-linux-amd64-${{ needs.prepare.outputs.app_version }}.tar.gz" - test -f "dist/release/ydisks-xianyu-helper-linux-arm64-${{ needs.prepare.outputs.app_version }}.tar.gz" - test -f "dist/release/Ydisks-Xianyu-Helper-Setup.exe" - test -f "dist/release/Ydisks-Xianyu-Helper-${{ needs.prepare.outputs.app_version }}-arm64.pkg" - test -f "dist/release/Ydisks-Xianyu-Helper-${{ needs.prepare.outputs.app_version }}-amd64.pkg" - test "$(find dist/release -maxdepth 1 -type f | wc -l)" -eq 5 - test -z "$(find dist/release -maxdepth 1 -type f -name '*.zip' -print -quit)" - ( - cd dist/release - sha256sum * > SHA256SUMS - ) - - - name: 创建或更新 GitHub Release - shell: bash - env: - GH_TOKEN: ${{ github.token }} - RELEASE_VERSION: ${{ needs.prepare.outputs.app_version }} - run: | - set -Eeuo pipefail - mapfile -t release_files < <(find dist/release -maxdepth 1 -type f -print | sort) - if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then - while IFS= read -r asset_name; do - case "$asset_name" in - Ydisks-Xianyu-Helper-*-binaries.zip) - gh release delete-asset "$GITHUB_REF_NAME" "$asset_name" --yes - ;; - esac - done < <(gh release view "$GITHUB_REF_NAME" --json assets --jq '.assets[].name') - gh release upload "$GITHUB_REF_NAME" "${release_files[@]}" --clobber - else - gh release create "$GITHUB_REF_NAME" "${release_files[@]}" \ - --verify-tag \ - --generate-notes \ - --title "Ydisks 闲鱼助手 $RELEASE_VERSION" - fi diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a08dab2..a0bb835 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -4,10 +4,14 @@ on: push: branches: - main - - codex/desktop-packaging - tags: - - 'v*.*.*' + - dev workflow_dispatch: + workflow_call: + inputs: + app_version: + description: 正式发布版本号(不含 v) + required: true + type: string permissions: contents: read @@ -21,17 +25,26 @@ jobs: verify: name: Docker 发布测试门禁 runs-on: ubuntu-24.04 + outputs: + app_version: ${{ steps.version.outputs.app_version }} + build_time: ${{ steps.version.outputs.build_time }} steps: - - name: 校验版本标签 - if: startsWith(github.ref, 'refs/tags/') + - name: 准备构建版本 + id: version shell: bash run: | set -Eeuo pipefail - if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "版本标签必须符合 v1.2.3 格式:$GITHUB_REF_NAME" >&2 + if [ -n "${{ inputs.app_version }}" ]; then + app_version="${{ inputs.app_version }}" + else + app_version="${GITHUB_REF_NAME}-${GITHUB_SHA::12}" + fi + if [ -n "${{ inputs.app_version }}" ] && [[ ! "$app_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "正式版本必须符合 1.2.3 格式:$app_version" >&2 exit 1 fi - + echo "app_version=$app_version" >> "$GITHUB_OUTPUT" + echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT" - name: 检出代码 uses: actions/checkout@v6 @@ -178,6 +191,10 @@ jobs: context: . file: Dockerfile.debian13 platforms: ${{ matrix.platform }} + build-args: | + APP_VERSION=${{ needs.verify.outputs.app_version }} + VCS_REF=${{ github.sha }} + BUILD_TIME=${{ needs.verify.outputs.build_time }} outputs: type=image,name=${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=true cache-from: type=gha,scope=ydisks-docker-${{ matrix.arch }} cache-to: type=gha,mode=max,scope=ydisks-docker-${{ matrix.arch }} @@ -241,10 +258,11 @@ jobs: name: ydisks-docker-digest-${{ matrix.arch }} path: dist/digests/* if-no-files-found: error - retention-days: 1 + retention-days: 30 publish: name: 合并多架构镜像 + if: inputs.app_version == '' needs: build runs-on: ubuntu-24.04 steps: @@ -276,14 +294,9 @@ jobs: with: images: ${{ steps.image.outputs.name }} tags: | - type=ref,event=tag - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} type=sha,format=long type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} - type=raw,value=desktop-packaging,enable=${{ github.ref == 'refs/heads/codex/desktop-packaging' }} - type=raw,value=alpha,enable=${{ github.ref == 'refs/heads/codex/desktop-packaging' }} + type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} - name: 创建并推送多架构 manifest shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..863e76f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,149 @@ +name: 发布正式版本 + +on: + push: + tags: + - 'v*.*.*' + +permissions: + contents: write + packages: write + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +jobs: + prepare: + name: 校验正式版本 + runs-on: ubuntu-24.04 + outputs: + app_version: ${{ steps.version.outputs.app_version }} + steps: + - name: 检出完整 Git 历史 + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: 校验标签、来源与版本顺序 + id: version + shell: bash + run: | + set -Eeuo pipefail + if [[ ! "$GITHUB_REF_NAME" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + echo "正式版本标签必须符合 v1.2.3 格式:$GITHUB_REF_NAME" >&2 + exit 1 + fi + git fetch origin main --no-tags + if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then + echo "正式版本标签必须指向 main 已包含的提交。" >&2 + exit 1 + fi + newest_tag="$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)" + if [ "$newest_tag" != "$GITHUB_REF_NAME" ]; then + echo "拒绝用旧版本 $GITHUB_REF_NAME 覆盖 latest;当前最高版本是 $newest_tag。" >&2 + exit 1 + fi + echo "app_version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + + desktop: + name: 构建桌面端安装包 + needs: prepare + uses: ./.github/workflows/desktop-cd.yml + with: + app_version: ${{ needs.prepare.outputs.app_version }} + secrets: inherit + + docker: + name: 构建 Docker 镜像 + needs: prepare + uses: ./.github/workflows/docker-publish.yml + with: + app_version: ${{ needs.prepare.outputs.app_version }} + secrets: inherit + + publish: + name: 审批并发布正式版本 + needs: + - prepare + - desktop + - docker + runs-on: ubuntu-24.04 + environment: + name: production-release + steps: + - name: 下载全部构建产物 + uses: actions/download-artifact@v8 + with: + pattern: ydisks-* + path: dist/artifacts + merge-multiple: true + + - name: 校验桌面产物并生成校验和 + shell: bash + env: + APP_VERSION: ${{ needs.prepare.outputs.app_version }} + run: | + set -Eeuo pipefail + mkdir -p dist/release dist/digests + find dist/artifacts -maxdepth 1 -type f -name '*.tar.gz' -exec cp {} dist/release/ \; + find dist/artifacts -maxdepth 1 -type f -name '*.exe' -exec cp {} dist/release/ \; + find dist/artifacts -maxdepth 1 -type f -name '*.pkg' -exec cp {} dist/release/ \; + find dist/artifacts -maxdepth 1 -type f -regex '.*/[0-9a-f]\{64\}' -exec cp {} dist/digests/ \; + test -f "dist/release/ydisks-xianyu-helper-linux-amd64-$APP_VERSION.tar.gz" + test -f "dist/release/ydisks-xianyu-helper-linux-arm64-$APP_VERSION.tar.gz" + test -f "dist/release/Ydisks-Xianyu-Helper-Setup.exe" + test -f "dist/release/Ydisks-Xianyu-Helper-$APP_VERSION-arm64.pkg" + test -f "dist/release/Ydisks-Xianyu-Helper-$APP_VERSION-amd64.pkg" + test "$(find dist/release -maxdepth 1 -type f | wc -l)" -eq 5 + test "$(find dist/digests -maxdepth 1 -type f | wc -l)" -eq 2 + (cd dist/release && sha256sum * > SHA256SUMS) + + - name: 配置 Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: 登录 GitHub Container Registry + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: 发布正式 Docker manifest + shell: bash + env: + APP_VERSION: ${{ needs.prepare.outputs.app_version }} + run: | + set -Eeuo pipefail + image_name="ghcr.io/${GITHUB_REPOSITORY,,}" + minor_version="${APP_VERSION%.*}" + digest_args=() + while IFS= read -r digest_file; do + digest_args+=("$image_name@sha256:$(basename "$digest_file")") + done < <(find dist/digests -maxdepth 1 -type f -print | sort) + docker buildx imagetools create \ + --tag "$image_name:$GITHUB_REF_NAME" \ + --tag "$image_name:$APP_VERSION" \ + --tag "$image_name:$minor_version" \ + --tag "$image_name:latest" \ + --tag "$image_name:sha-$GITHUB_SHA" \ + "${digest_args[@]}" + docker buildx imagetools inspect "$image_name:$GITHUB_REF_NAME" + docker buildx imagetools inspect "$image_name:latest" + + - name: 创建或更新 GitHub Release + shell: bash + env: + GH_TOKEN: ${{ github.token }} + APP_VERSION: ${{ needs.prepare.outputs.app_version }} + run: | + set -Eeuo pipefail + mapfile -t release_files < <(find dist/release -maxdepth 1 -type f -print | sort) + if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then + gh release upload "$GITHUB_REF_NAME" "${release_files[@]}" --clobber + else + gh release create "$GITHUB_REF_NAME" "${release_files[@]}" \ + --verify-tag \ + --generate-notes \ + --title "Ydisks 闲鱼助手 $APP_VERSION" + fi diff --git a/Dockerfile.debian13 b/Dockerfile.debian13 index b83d168..d3ca40b 100644 --- a/Dockerfile.debian13 +++ b/Dockerfile.debian13 @@ -10,12 +10,17 @@ RUN npm run build FROM --platform=$BUILDPLATFORM golang:1.26-trixie AS backend ARG TARGETOS ARG TARGETARCH +ARG APP_VERSION=dev +ARG VCS_REF=unknown +ARG BUILD_TIME=unknown WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . COPY --from=frontend /src/internal/webui/static ./internal/webui/static -RUN CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath -ldflags="-s -w" -o /out/xianyu-server ./cmd/server \ +RUN CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath \ + -ldflags="-s -w -X xianyu-go/internal/version.Version=$APP_VERSION -X xianyu-go/internal/version.Commit=$VCS_REF -X xianyu-go/internal/version.BuildTime=$BUILD_TIME" \ + -o /out/xianyu-server ./cmd/server \ && CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath -ldflags="-s -w" -o /out/xianyu-dbseed ./cmd/dbseed \ && CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" go build -trimpath -ldflags="-s -w" -o /out/xianyu-dbverify ./cmd/dbverify diff --git a/README.md b/README.md index 931f88e..6219552 100644 --- a/README.md +++ b/README.md @@ -208,10 +208,11 @@ Windows 和 macOS 托盘启动时会自动启动后台服务,并显示检查 `/var/log/ydisks-xianyu-helper/server.log`,也可以使用 `journalctl -u ydisks-xianyu-helper.service` 查看。 -桌面端安装包由 GitHub Actions 工作流在 `main`、`codex/desktop-packaging` 分支以及 `v1.2.3` -格式的版本标签上构建:Linux 上传 amd64/arm64 tar 包,Windows 上传安装器,macOS 分别上传 -arm64 和 amd64 安装包。版本标签构建全部成功后,会自动创建 GitHub Release,上传各平台安装包 -及 `SHA256SUMS`。Windows +桌面端安装包由 GitHub Actions 工作流在 `dev`、`main` 分支以及 `v1.2.3` 格式的版本标签上构建: +Linux 上传 amd64/arm64 tar 包,Windows 上传安装器,macOS 分别上传 arm64 和 amd64 安装包。 +分支构建只保留非正式 Actions artifacts;版本标签必须指向 `main` 中的提交,全部桌面端和 Docker +构建验证成功后等待 `production-release` Environment 人工审批,审批通过才创建 GitHub Release、 +上传各平台安装包及 `SHA256SUMS`,并发布正式 Docker 标签。Windows 和 macOS 安装包使用工作流中配置的固定签名证书签名;未配置对应 GitHub Secrets 时,签名 步骤会失败,不会生成可分发的安装包。 @@ -411,15 +412,14 @@ ARM64 Linux 拉取 arm64,不需要手动设置 `platform`。 | Git 引用 | 镜像标签 | | --- | --- | -| `main` 分支 | `main`、`latest`、`sha-<完整提交号>` | -| `codex/desktop-packaging` 分支 | `alpha`、`desktop-packaging`、`sha-<完整提交号>` | -| `v1.2.3` 标签 | `v1.2.3`、`1.2.3`、`1.2`、`sha-<完整提交号>` | +| `dev` 分支 | `dev`、`sha-<完整提交号>` | +| `main` 分支 | `main`、`sha-<完整提交号>` | +| `v1.2.3` 标签 | `v1.2.3`、`1.2.3`、`1.2`、`latest`、`sha-<完整提交号>` | -当前 Docker 发布工作流会在 `main` 分支发布 `main` 和 `latest` 正式镜像,并在 -`codex/desktop-packaging` 分支发布 `desktop-packaging` 和 `alpha` 标签用于验收;其他开发分支 -不会自动生成 GHCR 标签。推送 `v1.2.3` 格式的 Git 标签会同时触发版本 Docker 镜像和 GitHub -Release。所有 Docker 发布都必须先通过 Go/前端测试,再对每个原生架构镜像实际启动 Chromium -和服务并通过 `/health` 检查,之后才会生成 `latest`、分支或版本 manifest。 +`dev` 是日常调试通道,`main` 是稳定候选通道,两者都不会更新 `latest` 或创建 Release。推送 +`v1.2.3` 格式的 Git 标签会触发统一正式发布流程。所有 Docker 发布都必须先通过 Go/前端测试, +再对每个原生架构镜像实际启动 Chromium 和服务并通过 `/health` 检查;正式版还必须等全部桌面 +安装包构建成功并通过人工审批,之后才生成版本 manifest、更新 `latest` 并创建 GitHub Release。 生产环境建议使用明确的版本标签或 SHA 标签,避免上游更新导致未经验证的自动升级。 diff --git a/cmd/server/main.go b/cmd/server/main.go index 58b6466..73bff44 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -29,6 +29,7 @@ import ( "xianyu-go/internal/notify" "xianyu-go/internal/renewal" "xianyu-go/internal/server" + appversion "xianyu-go/internal/version" ) type serverOptions struct { @@ -51,6 +52,7 @@ type serverOptions struct { adminEmail string adminPassword string service bool + showVersion bool } const ( @@ -61,6 +63,10 @@ const ( func main() { opts := parseOptions() + if opts.showVersion { + fmt.Printf("Ydisks Xianyu Helper %s (commit %s, built %s)\n", appversion.Version, appversion.ShortCommit(), appversion.BuildTime) + return + } if opts.workDir != "" { if err := os.Chdir(opts.workDir); err != nil { fmt.Fprintf(os.Stderr, "切换工作目录失败: %v\n", err) @@ -106,6 +112,7 @@ func parseOptions() serverOptions { flag.StringVar(&opts.adminEmail, "admin-email", "admin@example.com", "初始化 admin 的邮箱") flag.StringVar(&opts.adminPassword, "admin-password", "", "初始化/重置 admin 密码;也可用 XIANYU_ADMIN_PASSWORD 环境变量") flag.BoolVar(&opts.service, "service", false, "以 Windows Service 模式运行") + flag.BoolVar(&opts.showVersion, "version", false, "显示版本和构建信息后退出") flag.Parse() return opts } @@ -118,6 +125,7 @@ func runServer(parent context.Context, opts serverOptions) error { if err != nil { return err } + packagedPlaywrightRuntime := strings.TrimSpace(opts.playwrightRuntimeRoot) != "" applyPlaywrightRuntimeRoot(&opts) if dataDir != "" { if err := os.MkdirAll(dataDir, 0o700); err != nil { @@ -126,10 +134,14 @@ func runServer(parent context.Context, opts serverOptions) error { if opts.dataKeyFile == "" { opts.dataKeyFile = filepath.Join(dataDir, defaultDataKeyName) } - if opts.playwrightDriverDir == "" { + // 只有安装包显式提供 runtime root 时,才把 Playwright runtime + // 放进应用数据目录。普通本地开发应沿用 Playwright 的用户缓存; + // 空的应用目录会让 playwright-go 误以为 driver 已配置,随后尝试 + // 执行不存在的 /playwright-driver/node。 + if packagedPlaywrightRuntime && opts.playwrightDriverDir == "" { opts.playwrightDriverDir = filepath.Join(dataDir, "playwright-driver") } - if opts.playwrightBrowserDir == "" { + if packagedPlaywrightRuntime && opts.playwrightBrowserDir == "" { opts.playwrightBrowserDir = filepath.Join(dataDir, "playwright-browsers") } } diff --git a/cmd/tray/main.go b/cmd/tray/main.go index a65312d..31f8a7f 100644 --- a/cmd/tray/main.go +++ b/cmd/tray/main.go @@ -24,6 +24,8 @@ import ( type healthResponse struct { Status string `json:"status"` Database string `json:"database"` + Version string `json:"version"` + Commit string `json:"commit"` } var serviceURL = strings.TrimRight(envOr("XIANYU_SERVICE_URL", "http://127.0.0.1:59188"), "/") diff --git a/docs/slider-captcha-frozen-spec.md b/docs/slider-captcha-frozen-spec.md index 911f375..9659969 100644 --- a/docs/slider-captcha-frozen-spec.md +++ b/docs/slider-captcha-frozen-spec.md @@ -96,6 +96,9 @@ distance = track.width - button.width - 页面加载后随机等待 `0.3–0.8s`,移动鼠标到 `(640, 360)`,滚动 `200–500px`,并保留现有短暂停顿。 - 页面包含“抱歉,页面访问出现了问题”时,判定验证链接过期。 - 页面包含 `STATUS_BREAKPOINT` 或“崩溃”时,判定验证页崩溃。 +- 页面准备完成后、首次滑动前必须先判定页面类型:只有同一 frame 内存在可见的滑块按钮和轨道时才进入滑动逻辑。 +- 如果没有可见滑块,并且任一 frame 的可见正文直接显示“验证失败”“安全验证未通过”“请求/加载失败”“系统繁忙”“服务/网络/页面异常”“请稍后重试”或对应英文错误提示,则判定为无可验证滑块的直接错误页,立即停止自动验证。 +- 直接错误页不得通过点击错误框、reload 或备用引擎强行转成滑块尝试;只有已经实际拖动过滑块后出现的 `.errloading` 才继续按第 5 节恢复。 - 拖动前必须保存所有域上的旧 `x5sec` 值,供严格成功判定使用。 ### 3.2 距离计算 @@ -199,6 +202,7 @@ Playwright 主引擎 - 获取新验证链接的 provider 不得在主引擎持有同账号持久化 profile 锁时调用,避免同账号锁死。 - 过期链接最多触发现有的 2 次链接刷新;最终仍过期时直接失败,不把过期 URL 交给备用引擎重放。 +- 主引擎判定为“没有可见滑块的直接错误页”时立即失败,不刷新链接,也不进入直接 Chromium/CDP 备用引擎。 - 进入备用引擎前可再获取一次新链接和更新后的 Cookie。 - `CAPTCHA_REAL_MOUSE=true` 在当前 Go/Docker 实现中只记录物理鼠标不可用,并继续备用逻辑;不得假装已启用物理鼠标。 - `CAPTCHA_DRISSIONPAGE_FALLBACK_ENABLED` 默认为启用。 @@ -242,6 +246,7 @@ Playwright 主引擎 - 最终 `left`、最终 class 或最终 X 偏移。 - 失败时的按钮 style/class、轨道 class、可见重试选择器和重试文本。 - 恢复方式是 `click` 还是 `reload`、所用选择器以及是否重新归位。 +- 自动滑块最终失败时,错误文本和 `token 风控滑块处理失败` 日志的 `verification_url` 字段必须包含最后实际使用的完整验证地址(包括 query),供用户复制到本机浏览器手动验证。此字段是仅在最终失败时提供的人工接管信息;常规页面/frame 诊断日志仍必须去掉 query 与 fragment。 页面可能被浏览器扩展注入大量无关 DOM。当前仅把下列注入作为诊断信息记录,不允许它们改变滑块定位、距离或成功判定: @@ -268,6 +273,7 @@ go vet ./internal/browser ./internal/engine ./internal/account ./internal/server - 主引擎首次滑动成功。 - 主引擎首次失败并隐藏滑块,点击 `.errloading` 恢复后第二次成功。 - 直接 Chromium/CDP 备用引擎使用同一恢复流程后成功。 +- 没有可见滑块、只显示直接错误提示的真实 Chromium 页面必须被识别,并且不得进入滑动或备用引擎。 - 标准 `300px` 轨道与 `42px` 按钮得到精确 `258px`。 - 旧 `x5sec` 不得判成功,新 `x5sec` 才能判成功。 @@ -275,6 +281,10 @@ go vet ./internal/browser ./internal/engine ./internal/account ./internal/server ## 10. 唯一变更流程 +### 2026-08-13 当前授权变更 + +用户明确要求改变“未找到滑块时仍执行失败恢复/备用引擎”和“最终失败日志只保留脱敏页面地址”的既有契约。原因是风控页有时只显示平台错误信息而没有可操作滑块,继续 reload、拖动或切换引擎没有验证意义且会增加风控;而真实滑块自动处理失败时,用户需要完整地址在本机浏览器中接管验证。本规范第 3.1、6、8、9 节已同步纳入新的页面分类、编排、日志和集成验证要求。 + 只有用户在当前任务中明确点名要求修改滑块认证时,才允许触碰冻结范围。获得授权后也必须在同一个变更中: 1. 说明要改变本文哪一条冻结契约及原因。 diff --git a/frontend/components/AccountList.tsx b/frontend/components/AccountList.tsx index 81b435f..7719c14 100644 --- a/frontend/components/AccountList.tsx +++ b/frontend/components/AccountList.tsx @@ -50,6 +50,7 @@ const AccountList: React.FC = () => { const [showQRModal, setShowQRModal] = useState(false); const [qrCodeUrl, setQrCodeUrl] = useState(''); const [qrStatus, setQrStatus] = useState('pending'); + const [qrErrorMessage, setQrErrorMessage] = useState(''); const [verificationScreenshot, setVerificationScreenshot] = useState(''); const [faceQrUrl, setFaceQrUrl] = useState(''); const [qrReauthTarget, setQrReauthTarget] = useState(null); @@ -624,12 +625,16 @@ const AccountList: React.FC = () => { setQrReauthTarget(targetAccount); setShowQRModal(true); setQrStatus('loading'); + setQrErrorMessage(''); setQrCodeUrl(''); setVerificationScreenshot(''); setFaceQrUrl(''); try { const res = await generateQRLogin({ signal: controller.signal }); if (!qrRequestGateRef.current?.isCurrent(requestGeneration)) return; + if (!res.success || !res.qr_code_url || !res.session_id) { + throw new Error(res.message || '闲鱼未返回可用的登录二维码'); + } if (res.success && res.qr_code_url && res.session_id) { const generatedSessionID = res.session_id; setQrCodeUrl(res.qr_code_url); @@ -674,7 +679,10 @@ const AccountList: React.FC = () => { } } catch (e) { if (!qrRequestGateRef.current?.isCurrent(requestGeneration)) return; + setQrErrorMessage(e instanceof Error ? e.message : '二维码获取失败,请稍后重试'); setQrStatus('error'); + } finally { + if (qrGenerateAbortRef.current === controller) qrGenerateAbortRef.current = null; } }; @@ -1029,7 +1037,7 @@ const AccountList: React.FC = () => { {qrStatus === 'error' && (
二维码获取失败 - 请关闭窗口后重新发起扫码登录。 + {qrErrorMessage || '请关闭窗口后重新发起扫码登录。'}
)} {qrStatus === 'verification' && ( diff --git a/frontend/components/Sidebar.tsx b/frontend/components/Sidebar.tsx index 71319d3..1e65f4e 100644 --- a/frontend/components/Sidebar.tsx +++ b/frontend/components/Sidebar.tsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { Bell, Box, ChevronLeft, ChevronRight, CreditCard, LayoutDashboard, - LogOut, MessageCircleMore, Settings, ShoppingBag, Users, Zap, + GitCommitHorizontal, LogOut, MessageCircleMore, Settings, ShoppingBag, Users, Zap, } from 'lucide-react'; import { YdisksBrandIcon } from './YdisksLogo'; @@ -14,9 +14,30 @@ interface SidebarProps { onLogout: () => void; } +interface BuildInfo { + version: string; + commit: string; +} + const Sidebar: React.FC = ({ activeTab, isAdmin = false, collapsed, onToggleCollapsed, onNavigate, onLogout, }) => { + const [buildInfo, setBuildInfo] = useState({ version: 'dev', commit: 'unknown' }); + + useEffect(() => { + const controller = new AbortController(); + fetch('/health', { signal: controller.signal }) + .then(response => response.ok ? response.json() : Promise.reject(new Error('health request failed'))) + .then(data => setBuildInfo({ + version: String(data.version || 'dev'), + commit: String(data.commit || 'unknown'), + })) + .catch(error => { + if (error instanceof DOMException && error.name === 'AbortError') return; + }); + return () => controller.abort(); + }, []); + const menuItems = [ { id: 'dashboard', icon: LayoutDashboard, label: '仪表盘' }, { id: 'accounts', icon: Users, label: '账号管理' }, @@ -28,6 +49,9 @@ const Sidebar: React.FC = ({ { id: 'notifications', icon: Bell, label: '通知设置' }, ...(isAdmin ? [{ id: 'settings', icon: Settings, label: '系统与AI' }] : []), ]; + const displayVersion = /^\d+\.\d+\.\d+$/.test(buildInfo.version) + ? `v${buildInfo.version}` + : buildInfo.version; return ( ); diff --git a/frontend/services/api.ts b/frontend/services/api.ts index 7733d1a..fe3186d 100644 --- a/frontend/services/api.ts +++ b/frontend/services/api.ts @@ -163,8 +163,9 @@ export const getAccountRuntimeStatuses = async (options?: RequestControlOptions) return get('/cookies/runtime-status', undefined, options); }; -export const generateQRLogin = async (options?: RequestControlOptions): Promise<{ success: boolean; session_id?: string; qr_code_url?: string }> => { - return post('/qr-login/generate', undefined, options); +export const generateQRLogin = async (options?: RequestControlOptions): Promise<{ success: boolean; session_id?: string; qr_code_url?: string; message?: string }> => { + // 风控后匿名 token 接口可能超过通用的 30 秒请求窗口;后端总生成窗口为 2 分钟。 + return post('/qr-login/generate', undefined, { ...options, timeoutMs: options?.timeoutMs ?? 130_000 }); }; export const checkQRLoginStatus = async (sessionId: string, signal?: AbortSignal): Promise => { diff --git a/internal/account/manager.go b/internal/account/manager.go index 319d4c5..2dc2ca2 100644 --- a/internal/account/manager.go +++ b/internal/account/manager.go @@ -159,6 +159,15 @@ func (m *Manager) Sender(cookieID string) (automation.MessageSender, bool) { return m.GetInstance(cookieID) } +// RecoverExpiredCredential 把任意上层 MTOP API 检测到的 Session 失效统一 +// 转交给账号 Handler 的协议续期流程。调用方必须先释放账号凭证锁。 +func (m *Manager) RecoverExpiredCredential(ctx context.Context, cookieID string) bool { + if m == nil || m.handler == nil { + return false + } + return m.handler.OnPasswordLoginRefresh(ctx, cookieID) +} + // RuntimeStatuses 返回所有已启动账号的实时状态快照。 func (m *Manager) RuntimeStatuses() map[string]engine.RuntimeStatus { m.mu.Lock() diff --git a/internal/adapter/adapter.go b/internal/adapter/adapter.go index 5715b11..5e6f8e2 100644 --- a/internal/adapter/adapter.go +++ b/internal/adapter/adapter.go @@ -276,7 +276,11 @@ func (a *Adapter) OnTokenCaptchaVerification(ctx context.Context, cookieID, cook } } if err != nil { - a.logger.Warn("token 风控滑块处理失败", "account", cookieID, "err", err) + manualURL := browser.TokenCaptchaManualVerificationURL(err) + if strings.TrimSpace(manualURL) == "" { + manualURL = verificationURL + } + a.logger.Warn("token 风控滑块处理失败", "account", cookieID, "err", err, "verification_url", manualURL) if a.store != nil && a.store.RiskLogs != nil { _ = a.store.RiskLogs.Update(ctx, logID, db.RiskControlLog{ ProcessingStatus: "failed", diff --git a/internal/automation/account_tasks.go b/internal/automation/account_tasks.go index 27d43a6..cb8ea6a 100644 --- a/internal/automation/account_tasks.go +++ b/internal/automation/account_tasks.go @@ -2,6 +2,7 @@ package automation import ( "context" + "crypto/sha256" "fmt" "strings" "time" @@ -45,14 +46,32 @@ func (c *Center) RunAccountTask(ctx context.Context, accountID, taskType string) if err != nil { return AccountTaskSummary{TaskType: taskType}, err } + return c.runConfiguredAccountTask(ctx, settings, taskType) +} + +func (c *Center) runConfiguredAccountTask(ctx context.Context, settings db.AccountTaskSettings, taskType string) (AccountTaskSummary, error) { + if blocked, err := c.accountTaskSessionBlocked(ctx, settings.CookieID); err != nil { + return AccountTaskSummary{TaskType: taskType}, err + } else if blocked { + return AccountTaskSummary{TaskType: taskType, Skipped: 1, Message: "Session 已失效,等待续期或重新登录"}, + fmt.Errorf("账号 Session 已失效,已停止自动化 API 请求,等待续期或重新登录") + } + var ( + summary AccountTaskSummary + err error + ) switch taskType { case TaskAutoRate: - return c.runAutoRate(ctx, settings) + summary, err = c.runAutoRate(ctx, settings) case TaskAutoPolish: - return c.runAutoPolish(ctx, settings, beijingNow(), true) + summary, err = c.runAutoPolish(ctx, settings, beijingNow(), true) default: return AccountTaskSummary{TaskType: taskType}, fmt.Errorf("不支持的账号任务: %s", taskType) } + if err != nil && mtop.IsSessionExpiredErr(err) { + err = c.recoverAccountTaskSession(ctx, settings.CookieID, err) + } + return summary, err } func (c *Center) scanAccountTasks(ctx context.Context) { @@ -70,19 +89,70 @@ func (c *Center) scanAccountTasks(ctx context.Context) { if err != nil || !allowed { continue } + if blocked, blockErr := c.accountTaskSessionBlocked(ctx, setting.CookieID); blockErr != nil || blocked { + continue + } if setting.AutoRateEnabled { - if _, err := c.runAutoRate(ctx, setting); err != nil { + if _, err := c.runConfiguredAccountTask(ctx, setting, TaskAutoRate); err != nil { c.logger.Warn("自动评价扫描失败", "account", setting.CookieID, "err", err) } } if setting.AutoPolishEnabled && polishDue(setting, now) { - if _, err := c.runAutoPolish(ctx, setting, now, false); err != nil { - c.logger.Warn("每日擦亮失败", "account", setting.CookieID, "err", err) + if blocked, _ := c.accountTaskSessionBlocked(ctx, setting.CookieID); blocked { + continue + } + _, taskErr := c.runAutoPolish(ctx, setting, now, false) + if taskErr != nil && mtop.IsSessionExpiredErr(taskErr) { + taskErr = c.recoverAccountTaskSession(ctx, setting.CookieID, taskErr) + } + if taskErr != nil { + c.logger.Warn("每日擦亮失败", "account", setting.CookieID, "err", taskErr) } } } } +func (c *Center) recoverAccountTaskSession(ctx context.Context, accountID string, sessionErr error) error { + fingerprint, fingerprintErr := c.accountCredentialFingerprint(ctx, accountID) + if fingerprintErr == nil { + c.sessionExpired.Store(accountID, fingerprint) + } + c.logger.Warn("自动化 API 检测到 Session 过期,停止后续请求并开始即时续期", "account", accountID, "err", sessionErr) + if c.recoverer != nil && c.recoverer.RecoverExpiredCredential(ctx, accountID) { + c.sessionExpired.Delete(accountID) + return fmt.Errorf("%w;Session 续期成功,本次自动化已停止,下一轮将使用新凭证", sessionErr) + } + return fmt.Errorf("%w;已停止该账号自动化 API 请求,等待续期或重新登录", sessionErr) +} + +func (c *Center) accountTaskSessionBlocked(ctx context.Context, accountID string) (bool, error) { + blockedFingerprint, ok := c.sessionExpired.Load(accountID) + if !ok { + return false, nil + } + current, err := c.accountCredentialFingerprint(ctx, accountID) + if err != nil { + return true, err + } + if current != blockedFingerprint.(string) { + c.sessionExpired.Delete(accountID) + return false, nil + } + return true, nil +} + +func (c *Center) accountCredentialFingerprint(ctx context.Context, accountID string) (string, error) { + detail, err := c.store.Cookies.GetDetails(ctx, accountID) + if err != nil { + return "", err + } + if detail == nil { + return "", db.ErrNotFound + } + sum := sha256.Sum256([]byte(detail.Value + "\x00" + detail.MetadataJSON)) + return fmt.Sprintf("%x", sum[:]), nil +} + func (c *Center) runAutoRate(ctx context.Context, settings db.AccountTaskSettings) (AccountTaskSummary, error) { summary := AccountTaskSummary{TaskType: TaskAutoRate} if c.accountTasks == nil { @@ -125,6 +195,9 @@ func (c *Center) runAutoRate(ctx context.Context, settings db.AccountTaskSetting } _ = c.store.AccountTasks.FinishRun(ctx, runKey, "failed", 0, 1, message, time.Now().UTC().Add(10*time.Minute).Unix()) summary.Failed++ + if mtop.IsSessionExpiredErr(rateErr) { + return summary, rateErr + } continue } current = c.persistTaskCookies(ctx, settings.CookieID, current, result.UpdatedCookies) @@ -178,6 +251,10 @@ func (c *Center) runAutoPolish(ctx context.Context, settings db.AccountTaskSetti if result != nil && result.Message != "" { lastError = result.Message } + if mtop.IsSessionExpiredErr(polishErr) { + _ = c.store.AccountTasks.FinishRun(ctx, runKey, "failed", summary.Success, summary.Failed, lastError, 0) + return summary, polishErr + } continue } current = c.persistTaskCookies(ctx, settings.CookieID, current, result.UpdatedCookies) diff --git a/internal/automation/account_tasks_test.go b/internal/automation/account_tasks_test.go index 9743666..8742d7a 100644 --- a/internal/automation/account_tasks_test.go +++ b/internal/automation/account_tasks_test.go @@ -3,6 +3,7 @@ package automation import ( "context" "errors" + "strings" "testing" "time" @@ -15,6 +16,8 @@ type fakeAccountTaskClient struct { rateCalls int polishCalls int pending []mtop.PendingRateOrder + pendingErr error + rateErr error items []mtop.ItemListItem fetchItemsErr error fetchPageSize int @@ -24,11 +27,17 @@ type fakeAccountTaskClient struct { func (f *fakeAccountTaskClient) FetchPendingRateOrders(context.Context, string, int, int) (*mtop.PendingRateResult, error) { f.pendingCalls++ + if f.pendingErr != nil { + return nil, f.pendingErr + } return &mtop.PendingRateResult{Orders: f.pending}, nil } func (f *fakeAccountTaskClient) RateBuyer(context.Context, string, string, string) (*mtop.AccountTaskResult, error) { f.rateCalls++ + if f.rateErr != nil { + return nil, f.rateErr + } return &mtop.AccountTaskResult{Success: true, Message: "ok"}, nil } @@ -69,6 +78,72 @@ func TestAccountTaskRateIsOrderIdempotent(t *testing.T) { } } +func TestAccountTaskSessionExpiredRecoversOnceAndBlocksFurtherAPIRequests(t *testing.T) { + store, cleanup := newAutomationTestStore(t) + defer cleanup() + ctx := context.Background() + sessionErr := &mtop.SessionExpiredError{API: "自动评价接口", Ret: []string{"FAIL_SYS_SESSION_EXPIRED::Session过期"}} + client := &fakeAccountTaskClient{pendingErr: sessionErr} + recoverer := &fakeCredentialRecoverer{store: store, fail: true} + center := New(store, testSenderProvider{sender: &testSender{}}, nil) + center.SetAccountTaskClient(client) + center.SetOrderDetailFetcher(recoverer) + if err := store.AccountTasks.Upsert(ctx, db.AccountTaskSettings{CookieID: "cid", AutoRateEnabled: true, + RateContent: "交易愉快", PolishTime: "03:00"}); err != nil { + t.Fatal(err) + } + + if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err == nil || !mtop.IsSessionExpiredErr(err) { + t.Fatalf("首次 session 失效应触发续期并返回原始分类错误: %v", err) + } + if client.pendingCalls != 1 || recoverer.calls != 1 { + t.Fatalf("first calls: api=%d recover=%d want 1/1", client.pendingCalls, recoverer.calls) + } + if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err == nil || !strings.Contains(err.Error(), "已停止自动化 API 请求") { + t.Fatalf("未更新凭证时应保持阻断: %v", err) + } + if client.pendingCalls != 1 || recoverer.calls != 1 { + t.Fatalf("blocked run must not call API/recovery again: api=%d recover=%d", client.pendingCalls, recoverer.calls) + } + + if err := store.Cookies.UpdateValueExisting(ctx, "cid", "unb=1; _m_h5_tk=fresh_1; renewed=1"); err != nil { + t.Fatal(err) + } + client.pendingErr = nil + if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err != nil { + t.Fatalf("凭证变化后应自动解除阻断: %v", err) + } + if client.pendingCalls != 2 { + t.Fatalf("api calls after credential update=%d want 2", client.pendingCalls) + } +} + +func TestAccountTaskStopsRemainingOrdersOnSessionExpired(t *testing.T) { + store, cleanup := newAutomationTestStore(t) + defer cleanup() + ctx := context.Background() + sessionErr := &mtop.SessionExpiredError{API: "评价接口", Ret: []string{"FAIL_SYS_SESSION_EXPIRED::Session过期"}} + client := &fakeAccountTaskClient{ + pending: []mtop.PendingRateOrder{{TradeID: "order-1"}, {TradeID: "order-2"}}, + rateErr: sessionErr, + } + recoverer := &fakeCredentialRecoverer{store: store, fail: true} + center := New(store, testSenderProvider{sender: &testSender{}}, nil) + center.SetAccountTaskClient(client) + center.SetOrderDetailFetcher(recoverer) + if err := store.AccountTasks.Upsert(ctx, db.AccountTaskSettings{CookieID: "cid", AutoRateEnabled: true, + RateContent: "交易愉快", PolishTime: "03:00"}); err != nil { + t.Fatal(err) + } + + if _, err := center.RunAccountTask(ctx, "cid", TaskAutoRate); err == nil { + t.Fatal("session expiry must be returned") + } + if client.rateCalls != 1 || recoverer.calls != 1 { + t.Fatalf("remaining orders must stop immediately: rate=%d recover=%d", client.rateCalls, recoverer.calls) + } +} + func TestAccountTaskPolishRunsOncePerBeijingDay(t *testing.T) { store, cleanup := newAutomationTestStore(t) defer cleanup() diff --git a/internal/automation/center.go b/internal/automation/center.go index 586cf04..c44bee0 100644 --- a/internal/automation/center.go +++ b/internal/automation/center.go @@ -96,6 +96,9 @@ type Center struct { logger *slog.Logger cookieSrc func(context.Context, string) (string, error) cardLocks sync.Map + // sessionExpired 保存检测到 Session 失效时的凭证指纹。在凭证续期或 + // 重新登录真正改变之前,账号任务不得再次调用任何 MTOP 业务接口。 + sessionExpired sync.Map } // New 构造自动化中心。 diff --git a/internal/browser/token_captcha.go b/internal/browser/token_captcha.go index 4a5d223..ccba55a 100644 --- a/internal/browser/token_captcha.go +++ b/internal/browser/token_captcha.go @@ -30,6 +30,53 @@ type TokenCaptchaURLProvider func(ctx context.Context, currentCookies string) (u type tokenCaptchaEngineFunc func(ctx context.Context, cookieID, cookieStr, verificationURL string, headless bool, provider TokenCaptchaURLProvider) (string, error) var errTokenCaptchaURLExpired = errors.New("token 风控验证链接已过期") +var errTokenCaptchaDirectPageError = errors.New("token 风控页面直接显示错误且没有可验证滑块") + +// TokenCaptchaFailureError 保留自动验证失败时最后实际使用的完整验证地址, +// 便于用户复制到本机浏览器中手动完成验证。 +type TokenCaptchaFailureError struct { + VerificationURL string + Cause error +} + +func (e *TokenCaptchaFailureError) Error() string { + if e == nil { + return "" + } + if e.Cause == nil { + if strings.TrimSpace(e.VerificationURL) == "" { + return "token 风控自动验证失败" + } + return fmt.Sprintf("token 风控自动验证失败;手动验证地址: %s", e.VerificationURL) + } + if strings.TrimSpace(e.VerificationURL) == "" { + return e.Cause.Error() + } + return fmt.Sprintf("%v;手动验证地址: %s", e.Cause, e.VerificationURL) +} + +func (e *TokenCaptchaFailureError) Unwrap() error { + if e == nil { + return nil + } + return e.Cause +} + +// TokenCaptchaManualVerificationURL 从自动验证失败中提取可供用户手动打开的完整地址。 +func TokenCaptchaManualVerificationURL(err error) string { + var failure *TokenCaptchaFailureError + if errors.As(err, &failure) { + return failure.VerificationURL + } + return "" +} + +func tokenCaptchaFailure(err error, verificationURL string) error { + if err == nil { + return nil + } + return &TokenCaptchaFailureError{VerificationURL: strings.TrimSpace(verificationURL), Cause: err} +} // TokenCaptchaRecover solves a token-refresh captcha and returns cookies with x5sec merged in. func (m *Manager) TokenCaptchaRecover(ctx context.Context, cookieID, cookieStr, verificationURL string, headless bool, provider TokenCaptchaURLProvider) (string, error) { @@ -77,8 +124,8 @@ func (m *Manager) TokenCaptchaRecoverWithEngine(ctx context.Context, cookieID, c primaryURL = freshURL } // An expired URL cannot be repaired by replaying it through the fallback. - if errors.Is(primaryErr, errTokenCaptchaURLExpired) { - return "", "", primaryErr + if errors.Is(primaryErr, errTokenCaptchaURLExpired) || errors.Is(primaryErr, errTokenCaptchaDirectPageError) { + return "", "", tokenCaptchaFailure(primaryErr, primaryURL) } if realMouseRequested() { @@ -87,7 +134,7 @@ func (m *Manager) TokenCaptchaRecoverWithEngine(ctx context.Context, cookieID, c m.logger.Error("CAPTCHA_REAL_MOUSE 已开启但物理鼠标引擎不可用,回退备用滑块逻辑", "goos", runtime.GOOS) } if !drissionFallbackEnabled() { - return "", "playwright", primaryErr + return "", "playwright", tokenCaptchaFailure(primaryErr, primaryURL) } fallbackURL := verificationURL @@ -121,7 +168,10 @@ func (m *Manager) TokenCaptchaRecoverWithEngine(ctx context.Context, cookieID, c if fallbackErr == nil { fallbackErr = fmt.Errorf("备用滑块引擎未获取到新的 x5sec Cookie") } - return "", "", fmt.Errorf("Playwright 主引擎失败: %v;备用滑块引擎失败: %w", primaryErr, fallbackErr) + return "", "", tokenCaptchaFailure( + fmt.Errorf("Playwright 主引擎失败: %v;备用滑块引擎失败: %w", primaryErr, fallbackErr), + fallbackURL, + ) } func (m *Manager) tokenCaptchaPlaywrightRecover(ctx context.Context, cookieID, cookieStr, verificationURL string, headless bool, _ TokenCaptchaURLProvider) (string, error) { @@ -176,6 +226,10 @@ func (m *Manager) tokenCaptchaPlaywrightRecover(ctx context.Context, cookieID, c if strings.Contains(content, "STATUS_BREAKPOINT") || strings.Contains(content, "崩溃") { return "", fmt.Errorf("token 风控验证页面崩溃") } + if pageErr := tokenCaptchaDirectPageError(page); pageErr != nil { + m.logger.Warn("token 风控页面没有可验证滑块,停止自动验证", "cookieID", cookieID, "err", pageErr) + return "", pageErr + } scratch := isScratchCaptcha(content) if err := solveSliderStrict(page, scratch, m.logger, previousX5SecValues, browserDeadline); err != nil { @@ -255,6 +309,47 @@ func captchaURLExpired(content string) bool { return strings.Contains(content, "抱歉,页面访问出现了问题") } +func tokenCaptchaDirectPageError(page playwright.Page) error { + if page == nil { + return nil + } + if _, _, _, err := findSliderElements(page); err == nil { + return nil + } + frames := append([]playwright.Frame{page.MainFrame()}, page.Frames()...) + for _, frame := range frames { + body, err := frame.QuerySelector("body") + if err != nil || body == nil { + continue + } + text, err := body.InnerText() + if err != nil { + continue + } + if tokenCaptchaDirectErrorText(text) { + return fmt.Errorf("%w: %s", errTokenCaptchaDirectPageError, truncateSliderText(text)) + } + } + return nil +} + +func tokenCaptchaDirectErrorText(text string) bool { + normalized := strings.ToLower(strings.Join(strings.Fields(text), " ")) + if normalized == "" { + return false + } + for _, marker := range []string{ + "验证失败", "安全验证未通过", "请求失败", "加载失败", "系统繁忙", "服务异常", "网络异常", + "页面异常", "页面出错", "发生错误", "请稍后重试", "something's wrong", "something went wrong", + "please refresh and try again", "try again later", + } { + if strings.Contains(normalized, marker) { + return true + } + } + return false +} + func waitForFreshX5SecCookie(ctx context.Context, reader browserCookieReader, previousValues map[string]struct{}, timeout, pollInterval time.Duration) (map[string]string, error) { if timeout <= 0 || pollInterval <= 0 { return nil, fmt.Errorf("等待 x5sec Cookie 的超时和轮询间隔必须大于 0") diff --git a/internal/browser/token_captcha_fallback.go b/internal/browser/token_captcha_fallback.go index a5d6508..fc1ed11 100644 --- a/internal/browser/token_captcha_fallback.go +++ b/internal/browser/token_captcha_fallback.go @@ -112,6 +112,10 @@ func (m *Manager) tokenCaptchaCDPFallback(ctx context.Context, cookieID, cookieS if err := sleepUntil(ctx, deadline, secondsDuration(randomFloat(1, 3))); err != nil { return "", err } + if pageErr := tokenCaptchaDirectPageError(page); pageErr != nil { + m.logger.Warn("备用滑块引擎页面没有可验证滑块,停止自动验证", "cookieID", cookieID, "err", pageErr) + return "", pageErr + } for attempt := 0; attempt < 3; attempt++ { if err := contextDeadlineError(ctx, deadline); err != nil { diff --git a/internal/browser/token_captcha_fallback_integration_test.go b/internal/browser/token_captcha_fallback_integration_test.go index 15f6982..8931cad 100644 --- a/internal/browser/token_captcha_fallback_integration_test.go +++ b/internal/browser/token_captcha_fallback_integration_test.go @@ -2,6 +2,7 @@ package browser import ( "context" + "errors" "fmt" "io" "net/http" @@ -169,6 +170,43 @@ document.addEventListener('click', event => { } } +func TestTokenCaptchaDirectErrorPageBrowserIntegration(t *testing.T) { + if os.Getenv("RUN_BROWSER_INTEGRATION") != "1" { + t.Skip("set RUN_BROWSER_INTEGRATION=1 to exercise direct-error page classification") + } + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "text/html; charset=utf-8") + _, _ = io.WriteString(w, `验证码拦截 +
Oops... something's wrong. Please refresh and try again.(error:6T0DWd)
+`) + })) + defer server.Close() + + m := NewManager(nil) + defer m.Close() + if err := m.init(); err != nil { + t.Fatal(err) + } + browser, err := m.pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{ + Headless: playwright.Bool(true), + Args: chromiumLaunchArgs(), + }) + if err != nil { + t.Fatal(err) + } + defer func() { _ = browser.Close() }() + page, err := browser.NewPage() + if err != nil { + t.Fatal(err) + } + if _, err := page.Goto(server.URL+"/punish", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}); err != nil { + t.Fatal(err) + } + if err := tokenCaptchaDirectPageError(page); !errors.Is(err, errTokenCaptchaDirectPageError) { + t.Fatalf("无滑块错误页应停止自动验证: %v", err) + } +} + func TestTokenCaptchaCDPFallbackBrowserIntegration(t *testing.T) { if os.Getenv("RUN_BROWSER_INTEGRATION") != "1" { t.Skip("set RUN_BROWSER_INTEGRATION=1 to exercise the direct-CDP Chromium fallback") diff --git a/internal/browser/token_captcha_orchestrator_test.go b/internal/browser/token_captcha_orchestrator_test.go index 98109e7..0c7c903 100644 --- a/internal/browser/token_captcha_orchestrator_test.go +++ b/internal/browser/token_captcha_orchestrator_test.go @@ -3,6 +3,7 @@ package browser import ( "context" "errors" + "fmt" "log/slog" "os" "path/filepath" @@ -77,6 +78,49 @@ func TestTokenCaptchaExpiredURLSkipsFallback(t *testing.T) { } } +func TestTokenCaptchaDirectErrorPageSkipsFallbackAndKeepsManualURL(t *testing.T) { + fallbackCalls := 0 + verificationURL := "https://h5api.m.goofish.com/punish?x5secdata=full-sensitive-value&action=captcha" + m := &Manager{ + logger: slog.Default(), + tokenCaptchaPrimaryFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) { + return "", fmt.Errorf("%w: Oops... something's wrong", errTokenCaptchaDirectPageError) + }, + tokenCaptchaFallbackFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) { + fallbackCalls++ + return "", errors.New("must not run") + }, + } + _, engine, err := m.TokenCaptchaRecoverWithEngine(context.Background(), "cid", "unb=1", verificationURL, true, nil) + if !errors.Is(err, errTokenCaptchaDirectPageError) || engine != "" || fallbackCalls != 0 { + t.Fatalf("engine=%q fallback=%d err=%v", engine, fallbackCalls, err) + } + if got := TokenCaptchaManualVerificationURL(err); got != verificationURL || !strings.Contains(err.Error(), verificationURL) { + t.Fatalf("manual URL=%q err=%v", got, err) + } +} + +func TestTokenCaptchaSliderFailureReportsLatestFallbackURL(t *testing.T) { + t.Setenv("CAPTCHA_DRISSIONPAGE_FALLBACK_ENABLED", "true") + freshURL := "https://h5api.m.goofish.com/punish?x5secdata=latest-full-value&action=captcha" + m := &Manager{ + logger: slog.Default(), + tokenCaptchaPrimaryFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) { + return "", errors.New("slider failed three times") + }, + tokenCaptchaFallbackFn: func(context.Context, string, string, string, bool, TokenCaptchaURLProvider) (string, error) { + return "", errors.New("fallback slider failed three times") + }, + } + provider := func(context.Context, string) (string, bool, string, error) { + return freshURL, false, "unb=1; _m_h5_tk=fresh", nil + } + _, _, err := m.TokenCaptchaRecoverWithEngine(context.Background(), "cid", "unb=1", "https://old.example/punish", true, provider) + if err == nil || TokenCaptchaManualVerificationURL(err) != freshURL || !strings.Contains(err.Error(), freshURL) { + t.Fatalf("err=%v manual=%q", err, TokenCaptchaManualVerificationURL(err)) + } +} + func TestTokenCaptchaExpiredURLRefreshesAfterPrimaryCloses(t *testing.T) { primaryCalls := 0 providerCalls := 0 diff --git a/internal/browser/token_captcha_test.go b/internal/browser/token_captcha_test.go index b5f0703..1082070 100644 --- a/internal/browser/token_captcha_test.go +++ b/internal/browser/token_captcha_test.go @@ -140,3 +140,20 @@ func TestX5SecValuesCollectsAllDomains(t *testing.T) { t.Fatal("缺少 two") } } + +func TestTokenCaptchaDirectErrorTextRequiresAnErrorPrompt(t *testing.T) { + for _, text := range []string{ + "验证失败,点击框体重试(error:YzRQd)", + "Oops... something's wrong. Please refresh and try again.(error:6T0DWd)", + "系统繁忙,请稍后重试", + } { + if !tokenCaptchaDirectErrorText(text) { + t.Fatalf("应识别无滑块错误提示 %q", text) + } + } + for _, text := range []string{"请按住滑块,拖动到最右边", "验证码加载中,请稍候", "验证码拦截"} { + if tokenCaptchaDirectErrorText(text) { + t.Fatalf("正常滑块提示不应识别为错误页 %q", text) + } + } +} diff --git a/internal/engine/account.go b/internal/engine/account.go index 8ee4a3f..a8053d1 100644 --- a/internal/engine/account.go +++ b/internal/engine/account.go @@ -443,9 +443,19 @@ func (a *Account) Run(parent context.Context) error { return err } if mtop.IsSessionExpiredErr(err) { - reason := "登录凭证已失效,请重新登录" - a.logger.Warn("session 已失效,停止消息登录", "err", err) + reason := "登录凭证已失效,正在立即续期" + a.logger.Warn("token API 检测到 Session 过期,停止重试并开始即时续期", "err", err) a.clearTokenCache(ctx) + a.setRuntimeState(RuntimeReconnecting, reason) + a.notifyOffline(ctx, reason+":"+errString(err)) + if a.handler != nil && a.handler.OnPasswordLoginRefresh(ctx, a.CookieID) { + a.reloadCookieFromDB(ctx) + a.clearCurrentToken() + a.resetFailures() + a.setRuntimeState(RuntimeConnecting, "Session 续期成功,正在重新连接") + continue + } + reason = "登录凭证已失效,自动续期失败,请重新扫码登录" a.setRuntimeState(RuntimeAuthExpired, reason) a.notifyOffline(ctx, reason+":"+errString(err)) return err diff --git a/internal/renewal/scheduler.go b/internal/renewal/scheduler.go index 4416927..50b1699 100644 --- a/internal/renewal/scheduler.go +++ b/internal/renewal/scheduler.go @@ -188,8 +188,17 @@ func (s *Scheduler) executeLoginRenew(ctx context.Context) { func (s *Scheduler) loginRenewOne(ctx context.Context, batchID string, account db.RenewalAccount) { credentialUnlock := s.store.LockAccountCredentials(account.ID) credentialUpdated := false + sessionExpired := false defer func() { credentialUnlock() + if sessionExpired { + s.logger.Warn("loginuser.get 检测到 Session 过期,开始即时续期", "account", account.ID) + if s.refresher != nil && s.refresher.OnPasswordLoginRefresh(ctx, account.ID) { + s.wakeCredentialBlockedAutomation(ctx, account.ID) + s.restartAfterCredentialUpdate(ctx, account.ID, account.Enabled, "Session 即时续期") + } + return + } if credentialUpdated { s.wakeCredentialBlockedAutomation(ctx, account.ID) s.restartAfterCredentialUpdate(ctx, account.ID, account.Enabled, "登录态续期") @@ -267,6 +276,9 @@ func (s *Scheduler) loginRenewOne(ctx context.Context, batchID string, account d if res.Status == mtop.LoginStatusSessionExpired || res.Status == mtop.LoginStatusTokenEmpty { s.markSessionExpired(account.ID) } + if res.Status == mtop.LoginStatusSessionExpired { + sessionExpired = true + } } func (s *Scheduler) executeAPICookieRenew(ctx context.Context) { diff --git a/internal/renewal/scheduler_test.go b/internal/renewal/scheduler_test.go index 512f8b0..b38a511 100644 --- a/internal/renewal/scheduler_test.go +++ b/internal/renewal/scheduler_test.go @@ -400,6 +400,26 @@ func TestLoginRenewPreservesValidTokenCache(t *testing.T) { } } +func TestLoginRenewSessionExpiredStartsImmediateRecovery(t *testing.T) { + store, cleanup := newSchedulerTestStore(t) + defer cleanup() + ctx := context.Background() + account := createSchedulerAccount(t, store, "cid-login-session-expired", "unb=1; _m_h5_tk=old_1") + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(`{"ret":["FAIL_SYS_SESSION_EXPIRED::Session过期"],"data":{}}`)) + })) + defer srv.Close() + refresher := &schedulerFakePasswordRefresher{} + s := NewScheduler(store, nil, refresher, nil) + s.mtop = &mtop.ClientImpl{HTTPClient: srv.Client(), LoginUserURL: srv.URL} + + s.loginRenewOne(ctx, "batch-login-session-expired", account) + + if got := refresher.calls.Load(); got != 1 { + t.Fatalf("session 过期应在登录态检查返回后立即触发一次续期,calls=%d", got) + } +} + func TestLoginRenewPersistsAuthoritativeSessionBeforeParseError(t *testing.T) { store, cleanup := newSchedulerTestStore(t) defer cleanup() diff --git a/internal/server/chat_handlers.go b/internal/server/chat_handlers.go index a397580..7068be7 100644 --- a/internal/server/chat_handlers.go +++ b/internal/server/chat_handlers.go @@ -58,6 +58,8 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) { return } hasMore, nextCursor = page.HasMore, page.NextCursor + } else { + s.recoverExpiredMTOPSession(r.Context(), accountID, fetchErr) } } } @@ -80,6 +82,8 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) { defer resolveCancel() jobs := make(chan int) var workers sync.WaitGroup + var sessionOnce sync.Once + var sessionErr error for worker := 0; worker < 8; worker++ { workers.Add(1) go func() { @@ -88,6 +92,13 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) { infoCtx, cancel := context.WithTimeout(resolveCtx, 3*time.Second) info, infoErr := client.FetchChatUserInfo(infoCtx, cookieValue, rows[index].ChatID) cancel() + if mtop.IsSessionExpiredErr(infoErr) { + sessionOnce.Do(func() { + sessionErr = infoErr + resolveCancel() + }) + continue + } if infoErr != nil || info == nil { continue } @@ -115,6 +126,9 @@ func (s *Server) listChatSessions(w http.ResponseWriter, r *http.Request) { } close(jobs) workers.Wait() + if sessionErr != nil { + s.recoverExpiredMTOPSession(r.Context(), accountID, sessionErr) + } } } writeJSON(w, http.StatusOK, map[string]any{"sessions": rows, "has_more": hasMore, "next_cursor": nextCursor}) @@ -283,6 +297,8 @@ func (s *Server) resolveSelectedChatIdentity(ctx context.Context, accountID stri if info.AvatarURL != "" { session.BuyerAvatar = info.AvatarURL } + } else if err != nil { + s.recoverExpiredMTOPSession(ctx, accountID, err) } } } diff --git a/internal/server/cookie_handlers.go b/internal/server/cookie_handlers.go index ecad810..724a08e 100644 --- a/internal/server/cookie_handlers.go +++ b/internal/server/cookie_handlers.go @@ -839,6 +839,7 @@ func (s *Server) refreshAccountProfile(ctx context.Context, d *db.CookieDetail) s.updateRunningCookie(ctx, d.ID, runtimeCookie) } if callErr != nil { + s.recoverExpiredMTOPSession(ctx, d.ID, callErr) if s.Logger != nil { s.Logger.Warn("刷新账号资料失败", "account", d.ID, "err", callErr) } diff --git a/internal/server/item_handlers.go b/internal/server/item_handlers.go index 5dbe03c..5105626 100644 --- a/internal/server/item_handlers.go +++ b/internal/server/item_handlers.go @@ -151,6 +151,7 @@ func (s *Server) publishItem(w http.ResponseWriter, r *http.Request) { if responseCookieErr != nil { callErr = errors.Join(callErr, fmt.Errorf("保存发布响应 Cookie: %w", responseCookieErr)) } + s.recoverExpiredMTOPSession(r.Context(), cookieID, callErr) var perr *mtop.PublishError if errors.As(callErr, &perr) { status := http.StatusBadGateway @@ -382,6 +383,7 @@ func (s *Server) syncItemsFromAccount(w http.ResponseWriter, r *http.Request) { } else if valueChanged { s.updateRunningCookie(r.Context(), req.CookieID, value) } + s.recoverExpiredMTOPSession(r.Context(), req.CookieID, callErr) writeErr(w, http.StatusBadGateway, callErr.Error()) return } @@ -389,7 +391,7 @@ func (s *Server) syncItemsFromAccount(w http.ResponseWriter, r *http.Request) { if res.UpdatedCookies != "" { detailCookies = res.UpdatedCookies } - s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items) + detailErr := s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items) runtimeCookie := "" runtimeCookieChanged := false value, valueChanged, handled, persistErr := s.persistMTopCookieSessionLocked(r.Context(), latest, cookieSession) @@ -418,6 +420,11 @@ func (s *Server) syncItemsFromAccount(w http.ResponseWriter, r *http.Request) { if runtimeCookieChanged { s.updateRunningCookie(r.Context(), req.CookieID, runtimeCookie) } + if detailErr != nil { + s.recoverExpiredMTOPSession(r.Context(), req.CookieID, detailErr) + writeErr(w, http.StatusBadGateway, detailErr.Error()) + return + } syncResult, syncErr := s.syncSyncedItems(r.Context(), req.CookieID, res.Items) if syncErr != nil { if s.Logger != nil { @@ -476,6 +483,7 @@ func (s *Server) syncItemsPageFromAccount(w http.ResponseWriter, r *http.Request } else if valueChanged { s.updateRunningCookie(r.Context(), req.CookieID, value) } + s.recoverExpiredMTOPSession(r.Context(), req.CookieID, callErr) writeErr(w, http.StatusBadGateway, callErr.Error()) return } @@ -483,7 +491,7 @@ func (s *Server) syncItemsPageFromAccount(w http.ResponseWriter, r *http.Request if res.UpdatedCookies != "" { detailCookies = res.UpdatedCookies } - s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items) + detailErr := s.enrichSyncedItemMultiSpec(mtopCtx, client, detailCookies, req.CookieID, res.Items) runtimeCookie := "" runtimeCookieChanged := false value, valueChanged, handled, persistErr := s.persistMTopCookieSessionLocked(r.Context(), latest, cookieSession) @@ -512,6 +520,11 @@ func (s *Server) syncItemsPageFromAccount(w http.ResponseWriter, r *http.Request if runtimeCookieChanged { s.updateRunningCookie(r.Context(), req.CookieID, runtimeCookie) } + if detailErr != nil { + s.recoverExpiredMTOPSession(r.Context(), req.CookieID, detailErr) + writeErr(w, http.StatusBadGateway, detailErr.Error()) + return + } saved := s.saveSyncedItems(r.Context(), req.CookieID, res.Items) writeJSON(w, http.StatusOK, map[string]any{ "success": true, @@ -592,10 +605,10 @@ func (s *Server) syncSyncedItems(ctx context.Context, cookieID string, items []m return s.Store.Items.SyncFromRemote(ctx, cookieID, rows) } -func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Client, cookies, cookieID string, items []mtop.ItemListItem) { +func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Client, cookies, cookieID string, items []mtop.ItemListItem) error { fetcher, ok := client.(mtop.ItemDetailFetcher) if !ok { - return + return nil } for index := range items { if items[index].IsMultiSpec || s.Store.Items.IsMultiSpec(ctx, cookieID, items[index].ID) { @@ -604,6 +617,9 @@ func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Clie } isMultiSpec, err := fetcher.DetectItemMultiSpec(ctx, cookies, items[index].ID) if err != nil { + if mtop.IsSessionExpiredErr(err) { + return err + } if s.Logger != nil { s.Logger.Warn("识别商品多规格状态失败", "cookie_id", cookieID, "item_id", items[index].ID, "err", err) } @@ -611,6 +627,7 @@ func (s *Server) enrichSyncedItemMultiSpec(ctx context.Context, client mtop.Clie } items[index].IsMultiSpec = isMultiSpec } + return nil } func (s *Server) listItemsByCookie(w http.ResponseWriter, r *http.Request) { diff --git a/internal/server/item_publish_batch_handlers.go b/internal/server/item_publish_batch_handlers.go index a855738..b7fbcf8 100644 --- a/internal/server/item_publish_batch_handlers.go +++ b/internal/server/item_publish_batch_handlers.go @@ -705,11 +705,12 @@ func (s *Server) runItemPublishBatch(ctx context.Context, userID int64, batchID, if !claimed { continue } - if err := s.publishBatchRow(ctx, userID, client, row, workerToken); err != nil { + if rowErr := s.publishBatchRow(ctx, userID, client, row, workerToken); rowErr != nil { + sessionExpired := mtop.IsSessionExpiredErr(rowErr) statusCtx, statusCancel := context.WithTimeout(context.Background(), 5*time.Second) status, _ := s.Store.PublishBatches.BatchStatus(statusCtx, batchID) statusCancel() - message, failureKind := publishBatchFailure(err, status) + message, failureKind := publishBatchFailure(rowErr, status) wctx, cancel := publishStatusContext(ctx) marked, markErr := s.Store.PublishBatches.MarkClaimedRowFailed(wctx, row.ID, workerToken, message, failureKind) cancel() @@ -719,6 +720,10 @@ func (s *Server) runItemPublishBatch(ctx context.Context, userID int64, batchID, } return } + if sessionExpired { + s.finishInterruptedPublishBatch(ctx, userID, batchID, workerToken) + return + } } wctx, cancel = publishStatusContext(ctx) if err := s.Store.PublishBatches.Recount(wctx, batchID); err != nil && s.Logger != nil { @@ -977,6 +982,7 @@ func (s *Server) publishBatchRow(ctx context.Context, userID int64, client mtop. s.updateRunningCookie(ctx, row.CookieID, runtimeCookie) } if err != nil { + s.recoverExpiredMTOPSession(ctx, row.CookieID, err) if ctx.Err() != nil { return &uncertainRemotePublishError{err: fmt.Errorf("取消时远端发布结果未知: %w", err)} } diff --git a/internal/server/order_handlers.go b/internal/server/order_handlers.go index 5a62582..1040ca1 100644 --- a/internal/server/order_handlers.go +++ b/internal/server/order_handlers.go @@ -190,6 +190,7 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) { discovered, listUpdated, softDeleted, failed := 0, 0, 0, 0 results := []map[string]any{} newOrderIDs := make(map[string]struct{}) + sessionExpiredAccounts := make(map[string]struct{}) if fetcher, ok := s.mtopClient().(mtop.SoldOrderFetcher); ok { for cid := range all { credentialUnlock := s.Store.LockAccountCredentials(cid) @@ -218,6 +219,10 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) { if persistErr == nil && valueChanged { s.updateRunningCookie(r.Context(), cid, value) } + if mtop.IsSessionExpiredErr(discoveryErr) { + sessionExpiredAccounts[cid] = struct{}{} + s.recoverExpiredMTOPSession(r.Context(), cid, discoveryErr) + } discovered += accountDiscovered listUpdated += accountUpdated for orderID := range accountNewIDs { @@ -250,6 +255,9 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) { ordersByCookie := map[string][]refreshTarget{} for cid := range all { + if _, blocked := sessionExpiredAccounts[cid]; blocked { + continue + } for offset := 0; ; offset += 500 { rows, err := s.Store.Orders.ByCookiePage(r.Context(), cid, 500, offset) if err != nil { @@ -312,6 +320,7 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) { updated, noChange := 0, 0 for cid, targets := range ordersByCookie { + accountSessionExpired := false for _, chunk := range chunkRefreshTargets(targets, refreshOrderChunkSize) { credentialUnlock := s.Store.LockAccountCredentials(cid) latest, latestErr := s.Store.Cookies.GetDetails(r.Context(), cid) @@ -323,6 +332,7 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) { } ctx, cancel := context.WithTimeout(r.Context(), 3*time.Minute) mtopCtx, cookieSession := withMTopCookieSnapshot(ctx, latest) + var sessionErr error for _, target := range chunk { detail, fetchErr := detailFetcher.FetchOrderDetail(mtopCtx, latest.Value, target.OrderID) if fetchErr != nil || detail == nil { @@ -336,6 +346,10 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) { "success": false, "error": message, }) + if mtop.IsSessionExpiredErr(fetchErr) { + sessionErr = fetchErr + break + } continue } newStatus := db.NormalizeOrderStatus(detail.OrderStatus) @@ -377,6 +391,14 @@ func (s *Server) refreshOrders(w http.ResponseWriter, r *http.Request) { } else if valueChanged { s.updateRunningCookie(r.Context(), cid, value) } + if sessionErr != nil { + s.recoverExpiredMTOPSession(r.Context(), cid, sessionErr) + accountSessionExpired = true + break + } + } + if accountSessionExpired { + continue } } writeJSON(w, http.StatusOK, map[string]any{ @@ -544,6 +566,7 @@ func (s *Server) refreshSingleOrder(w http.ResponseWriter, r *http.Request) { s.updateRunningCookie(r.Context(), cookieID, runtimeCookie) } if callErr != nil { + s.recoverExpiredMTOPSession(r.Context(), cookieID, callErr) writeErr(w, http.StatusBadGateway, callErr.Error()) return } diff --git a/internal/server/qrlogin_handlers.go b/internal/server/qrlogin_handlers.go index 8340006..c858a8b 100644 --- a/internal/server/qrlogin_handlers.go +++ b/internal/server/qrlogin_handlers.go @@ -16,6 +16,8 @@ import ( "xianyu-go/internal/xianyu/protocol" ) +const qrLoginGenerateTimeout = 2 * time.Minute + // mountQRLoginReal 扫码登录端点(纯 HTTP,不需要浏览器)。 func (s *Server) mountQRLoginReal(r chi.Router) { r.Post("/qr-login/generate", s.generateQRLogin) @@ -32,12 +34,26 @@ func (s *Server) generateQRLogin(w http.ResponseWriter, r *http.Request) { return } s.cleanupQRLoginSessions() - sessionID, qrCodeURL, err := s.QRLogin.GenerateQRCode(r.Context()) + // 风控后的闲鱼匿名 token 接口偶尔会明显变慢。二维码生成需要连续完成 + // token、登录参数和二维码请求,不能沿用前端通用接口的短超时。 + generateCtx, cancel := context.WithTimeout(r.Context(), qrLoginGenerateTimeout) + defer cancel() + sessionID, qrCodeURL, err := s.QRLogin.GenerateQRCode(generateCtx) if err != nil { - s.Logger.Error("生成二维码失败", "err", err) + message := "生成二维码失败: " + err.Error() + switch { + case errors.Is(err, context.Canceled): + s.Logger.Info("二维码生成请求已取消") + message = "二维码生成请求已取消,请重新获取" + case errors.Is(err, context.DeadlineExceeded): + s.Logger.Error("生成二维码超时", "err", err) + message = "闲鱼二维码接口响应超时,请稍后重新获取" + default: + s.Logger.Error("生成二维码失败", "err", err) + } writeJSON(w, http.StatusOK, map[string]any{ "success": false, - "message": "生成二维码失败: " + err.Error(), + "message": message, }) return } diff --git a/internal/server/qrlogin_keyword_test.go b/internal/server/qrlogin_keyword_test.go index 6585910..4de5575 100644 --- a/internal/server/qrlogin_keyword_test.go +++ b/internal/server/qrlogin_keyword_test.go @@ -15,14 +15,16 @@ import ( ) type fakeQRLoginService struct { - status map[string]any - generateErr error - completeCookies string - completeUNB string - completeErr error + status map[string]any + generateErr error + generateDeadline time.Time + completeCookies string + completeUNB string + completeErr error } -func (f *fakeQRLoginService) GenerateQRCode(context.Context) (string, string, error) { +func (f *fakeQRLoginService) GenerateQRCode(ctx context.Context) (string, string, error) { + f.generateDeadline, _ = ctx.Deadline() if f.generateErr != nil { return "", "", f.generateErr } @@ -54,7 +56,8 @@ func (f *fakeQRLoginService) CompleteVerification(context.Context, string) (stri func TestGenerateQRLogin(t *testing.T) { srv, _, cleanup := newTestServer(t) defer cleanup() - srv.QRLogin = &fakeQRLoginService{} + qr := &fakeQRLoginService{} + srv.QRLogin = qr h := srv.Router() cookie := loginHelper(t, h) @@ -70,6 +73,10 @@ func TestGenerateQRLogin(t *testing.T) { if res["success"] != true || res["session_id"] == nil || res["session_id"] == "" { t.Fatalf("生成二维码响应异常: %+v", res) } + remaining := time.Until(qr.generateDeadline) + if remaining < qrLoginGenerateTimeout-time.Second || remaining > qrLoginGenerateTimeout { + t.Fatalf("二维码生成超时窗口=%v want≈%v", remaining, qrLoginGenerateTimeout) + } } func TestQRLoginSessionCannotBeReadByAnotherUser(t *testing.T) { diff --git a/internal/server/server.go b/internal/server/server.go index b235a0b..7533845 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -24,6 +24,7 @@ import ( "xianyu-go/internal/chat" "xianyu-go/internal/db" "xianyu-go/internal/notify" + appversion "xianyu-go/internal/version" "xianyu-go/internal/webui" "xianyu-go/internal/xianyu/mtop" "xianyu-go/internal/xianyu/qrlogin" @@ -128,6 +129,21 @@ func (s *Server) mtopClient() mtop.Client { return mtop.NewClient() } +// recoverExpiredMTOPSession 是 HTTP/API 入口的统一 Session 失效出口。 +// 各调用点必须先保存响应 Cookie 并释放账号凭证锁,再进入续期,避免锁反转。 +func (s *Server) recoverExpiredMTOPSession(ctx context.Context, cookieID string, err error) bool { + if !mtop.IsSessionExpiredErr(err) { + return false + } + if s.Logger != nil { + s.Logger.Warn("MTOP API 检测到 Session 过期,停止业务请求并开始即时续期", "account", cookieID, "err", err) + } + if s.Manager == nil { + return false + } + return s.Manager.RecoverExpiredCredential(ctx, cookieID) +} + // Router 构建完整路由树。 func (s *Server) Router() http.Handler { r := chi.NewRouter() @@ -349,7 +365,13 @@ func (s *Server) health(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusServiceUnavailable, map[string]any{"status": "degraded", "database": "unavailable"}) return } - writeJSON(w, http.StatusOK, map[string]any{"status": "ok", "database": "ok"}) + writeJSON(w, http.StatusOK, map[string]any{ + "status": "ok", + "database": "ok", + "version": appversion.Version, + "commit": appversion.ShortCommit(), + "build_time": appversion.BuildTime, + }) } // 各分组 mount*Real 方法在 handlers 文件中实现;为避免单文件过大,按业务域分文件。 diff --git a/internal/server/server_test.go b/internal/server/server_test.go index d39f979..e7704f3 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -390,6 +390,9 @@ func TestHealth(t *testing.T) { if rec.Code != 200 { t.Fatalf("health status=%d", rec.Code) } + if !strings.Contains(rec.Body.String(), `"version":"dev"`) { + t.Fatalf("health response missing build version: %s", rec.Body.String()) + } } func TestHealthReportsUnavailableDatabase(t *testing.T) { diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..ccd4fee --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,22 @@ +// Package version exposes build metadata injected by release builds. +package version + +import "strings" + +var ( + Version = "dev" + Commit = "unknown" + BuildTime = "unknown" +) + +// ShortCommit returns a compact commit identifier suitable for UI display. +func ShortCommit() string { + commit := strings.TrimSpace(Commit) + if len(commit) > 12 { + return commit[:12] + } + if commit == "" { + return "unknown" + } + return commit +} diff --git a/internal/version/version_test.go b/internal/version/version_test.go new file mode 100644 index 0000000..67f5ea7 --- /dev/null +++ b/internal/version/version_test.go @@ -0,0 +1,13 @@ +package version + +import "testing" + +func TestShortCommit(t *testing.T) { + original := Commit + t.Cleanup(func() { Commit = original }) + + Commit = "0123456789abcdef" + if got := ShortCommit(); got != "0123456789ab" { + t.Fatalf("ShortCommit() = %q", got) + } +} diff --git a/internal/webui/static/assets/icons-vendor-DF3hof7q.js b/internal/webui/static/assets/icons-vendor-BpMgNNfy.js similarity index 74% rename from internal/webui/static/assets/icons-vendor-DF3hof7q.js rename to internal/webui/static/assets/icons-vendor-BpMgNNfy.js index 9119e85..e8f3d53 100644 --- a/internal/webui/static/assets/icons-vendor-DF3hof7q.js +++ b/internal/webui/static/assets/icons-vendor-BpMgNNfy.js @@ -1,4 +1,4 @@ -import{r as y}from"./react-vendor-C_od1ZSF.js";/** +import{r as h}from"./react-vendor-C_od1ZSF.js";/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -13,32 +13,32 @@ import{r as y}from"./react-vendor-C_od1ZSF.js";/** * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const m=y.forwardRef(({color:t="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:s="",children:h,iconNode:i,...d},p)=>y.createElement("svg",{ref:p,...v,width:a,height:a,stroke:t,strokeWidth:o?Number(c)*24/Number(a):c,className:k("lucide",s),...!h&&!x(d)&&{"aria-hidden":"true"},...d},[...i.map(([r,l])=>y.createElement(r,l)),...Array.isArray(h)?h:[h]]));/** + */const m=h.forwardRef(({color:t="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:s="",children:y,iconNode:i,...d},p)=>h.createElement("svg",{ref:p,...v,width:a,height:a,stroke:t,strokeWidth:o?Number(c)*24/Number(a):c,className:k("lucide",s),...!y&&!x(d)&&{"aria-hidden":"true"},...d},[...i.map(([r,l])=>h.createElement(r,l)),...Array.isArray(y)?y:[y]]));/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const e=(t,a)=>{const c=y.forwardRef(({className:o,...s},h)=>y.createElement(m,{ref:h,iconNode:a,className:k(`lucide-${M(n(t))}`,`lucide-${t}`,o),...s}));return c.displayName=n(t),c};/** + */const e=(t,a)=>{const c=h.forwardRef(({className:o,...s},y)=>h.createElement(m,{ref:y,iconNode:a,className:k(`lucide-${M(n(t))}`,`lucide-${t}`,o),...s}));return c.displayName=n(t),c};/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const g=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],I1=e("activity",g);/** + */const g=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],O1=e("activity",g);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],O1=e("arrow-right",u);/** + */const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Z1=e("arrow-right",u);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const $=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Z1=e("bell",$);/** + */const $=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],K1=e("bell",$);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const N=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],K1=e("bot",N);/** + */const N=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],G1=e("bot",N);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -48,47 +48,47 @@ import{r as y}from"./react-vendor-C_od1ZSF.js";/** * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const w=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],G1=e("calendar-clock",w);/** + */const w=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],J1=e("calendar-clock",w);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const b=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],J1=e("check-check",b);/** + */const z=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],X1=e("check-check",z);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const z=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],X1=e("check",z);/** + */const b=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Y1=e("check",b);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const q=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Y1=e("chevron-down",q);/** + */const q=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],e2=e("chevron-down",q);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],e2=e("chevron-left",C);/** + */const C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],a2=e("chevron-left",C);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const j=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],a2=e("chevron-right",j);/** + */const j=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],t2=e("chevron-right",j);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],t2=e("circle-alert",A);/** + */const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],c2=e("circle-alert",A);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const H=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],c2=e("circle-check",H);/** + */const H=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],o2=e("circle-check",H);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const V=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],o2=e("circle-dashed",V);/** + */const V=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],y2=e("circle-dashed",V);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -98,314 +98,319 @@ import{r as y}from"./react-vendor-C_od1ZSF.js";/** * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const P=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],y2=e("clock",P);/** + */const P=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],s2=e("clock",P);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const S=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],s2=e("cloud-upload",S);/** + */const S=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],d2=e("cloud-upload",S);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const U=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],d2=e("code",U);/** + */const U=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],n2=e("code",U);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const E=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],n2=e("copy",E);/** + */const E=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],k2=e("copy",E);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const B=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],k2=e("credit-card",B);/** + */const B=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],i2=e("credit-card",B);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const D=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],i2=e("database",D);/** + */const D=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],p2=e("database",D);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const R=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],p2=e("dollar-sign",R);/** + */const R=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],r2=e("dollar-sign",R);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const T=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],r2=e("external-link",T);/** + */const T=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],l2=e("external-link",T);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const W=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],l2=e("eye-off",W);/** + */const W=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],M2=e("eye-off",W);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const F=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],M2=e("eye",F);/** + */const F=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_2=e("eye",F);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const I=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],_2=e("file-down",I);/** + */const I=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],x2=e("file-down",I);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const O=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],x2=e("file-text",O);/** + */const O=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],v2=e("file-text",O);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Z=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],v2=e("funnel",Z);/** + */const Z=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],m2=e("funnel",Z);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const K=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],m2=e("gift",K);/** + */const K=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],g2=e("gift",K);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Q=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],g2=e("image-plus",Q);/** + */const G=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],u2=e("git-commit-horizontal",G);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const G=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],u2=e("image",G);/** + */const Q=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],$2=e("image-plus",Q);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const J=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],$2=e("key",J);/** + */const J=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],N2=e("image",J);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const X=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],N2=e("layers",X);/** + */const X=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],f2=e("key",X);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Y=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],f2=e("layout-dashboard",Y);/** + */const Y=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],w2=e("layers",Y);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const e1=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],w2=e("link-2",e1);/** + */const e1=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],z2=e("layout-dashboard",e1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const a1=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],b2=e("list-plus",a1);/** + */const a1=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],b2=e("link-2",a1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const t1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],z2=e("loader-circle",t1);/** + */const t1=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],q2=e("list-plus",t1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const c1=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],q2=e("locate-fixed",c1);/** + */const c1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],C2=e("loader-circle",c1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const o1=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],C2=e("lock-keyhole",o1);/** + */const o1=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],j2=e("locate-fixed",o1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const h1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],j2=e("lock",h1);/** + */const y1=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],A2=e("lock-keyhole",y1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const y1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],A2=e("log-out",y1);/** + */const h1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],H2=e("lock",h1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const s1=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],H2=e("mail",s1);/** + */const s1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],V2=e("log-out",s1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const d1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]],V2=e("message-circle-more",d1);/** + */const d1=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],L2=e("mail",d1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const n1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],L2=e("message-circle",n1);/** + */const n1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]],P2=e("message-circle-more",n1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const k1=[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]],P2=e("message-square-quote",k1);/** + */const k1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],S2=e("message-circle",k1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const i1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],S2=e("package-check",i1);/** + */const i1=[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]],U2=e("message-square-quote",i1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const p1=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],U2=e("package-plus",p1);/** + */const p1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],E2=e("package-check",p1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const r1=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],E2=e("package",r1);/** + */const r1=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],B2=e("package-plus",r1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const l1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],B2=e("pen",l1);/** + */const l1=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],D2=e("package",l1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const M1=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],D2=e("play",M1);/** + */const M1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],R2=e("pen",M1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const _1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],R2=e("plus",_1);/** + */const _1=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],T2=e("play",_1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const x1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],T2=e("power",x1);/** + */const x1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],W2=e("plus",x1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const v1=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],W2=e("qr-code",v1);/** + */const v1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],F2=e("power",v1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const m1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],F2=e("refresh-cw",m1);/** + */const m1=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],I2=e("qr-code",m1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const g1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],I2=e("save",g1);/** + */const g1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],O2=e("refresh-cw",g1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const u1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],O2=e("search",u1);/** + */const u1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Z2=e("save",u1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const $1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Z2=e("send",$1);/** + */const $1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],K2=e("search",$1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const N1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],K2=e("settings",N1);/** + */const N1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],G2=e("send",N1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const f1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Q2=e("shield-check",f1);/** + */const f1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Q2=e("settings",f1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const w1=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],G2=e("shopping-bag",w1);/** + */const w1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],J2=e("shield-check",w1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const b1=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],J2=e("shopping-cart",b1);/** + */const z1=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],X2=e("shopping-bag",z1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const z1=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],X2=e("sliders-horizontal",z1);/** + */const b1=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],Y2=e("shopping-cart",b1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const q1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],Y2=e("smile",q1);/** + */const q1=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],e0=e("sliders-horizontal",q1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const C1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],e0=e("sparkles",C1);/** + */const C1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],a0=e("smile",C1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const j1=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],a0=e("square-pen",j1);/** + */const j1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],t0=e("sparkles",j1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const A1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],t0=e("trash-2",A1);/** + */const A1=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],c0=e("square-pen",A1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const H1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],c0=e("trending-up",H1);/** + */const H1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],o0=e("trash-2",H1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const V1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],o0=e("triangle-alert",V1);/** + */const V1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],y0=e("trending-up",V1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const L1=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],h0=e("truck",L1);/** + */const L1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],h0=e("triangle-alert",L1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const P1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],y0=e("upload",P1);/** + */const P1=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],s0=e("truck",P1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const S1=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],s0=e("user-round",S1);/** + */const S1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],d0=e("upload",S1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const U1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],d0=e("user",U1);/** + */const U1=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],n0=e("user-round",U1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const E1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],n0=e("users",E1);/** + */const E1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],k0=e("user",E1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const B1=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],k0=e("webhook",B1);/** + */const B1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],i0=e("users",B1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const D1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],i0=e("wifi-off",D1);/** + */const D1=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],p0=e("webhook",D1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const R1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],p0=e("wifi",R1);/** + */const R1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],r0=e("wifi-off",R1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const T1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],r0=e("x",T1);/** + */const T1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],l0=e("wifi",T1);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const W1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],l0=e("zap",W1);export{v2 as $,I1 as A,Q1 as B,k2 as C,p2 as D,r2 as E,h0 as F,O2 as G,a0 as H,y0 as I,X2 as J,$2 as K,f2 as L,V2 as M,n2 as N,x2 as O,E2 as P,W2 as Q,F2 as R,G2 as S,c0 as T,n0 as U,u2 as V,b2 as W,r0 as X,_2 as Y,l0 as Z,d2 as _,Z1 as a,U2 as a0,s2 as a1,c2 as a2,o2 as a3,w2 as a4,O1 as a5,q2 as a6,i2 as a7,Y1 as a8,Q2 as a9,C2 as aa,s0 as ab,h2 as ac,m2 as ad,N2 as ae,Z2 as af,H2 as ag,k0 as ah,p0 as ai,i0 as aj,J1 as ak,Y2 as al,g2 as am,j2 as an,K2 as b,a2 as c,e2 as d,A2 as e,t2 as f,J2 as g,S2 as h,o0 as i,z2 as j,P2 as k,D2 as l,e0 as m,G1 as n,I2 as o,d0 as p,X1 as q,K1 as r,L2 as s,y2 as t,B2 as u,T2 as v,t0 as w,l2 as x,M2 as y,R2 as z}; + */const W1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],M0=e("x",W1);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const F1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],_0=e("zap",F1);export{n2 as $,O1 as A,Q1 as B,i2 as C,r2 as D,l2 as E,s0 as F,u2 as G,K2 as H,c0 as I,d0 as J,f2 as K,z2 as L,P2 as M,e0 as N,k2 as O,D2 as P,I2 as Q,O2 as R,X2 as S,y0 as T,i0 as U,v2 as V,N2 as W,M0 as X,q2 as Y,_0 as Z,x2 as _,K1 as a,m2 as a0,B2 as a1,d2 as a2,o2 as a3,y2 as a4,b2 as a5,Z1 as a6,j2 as a7,p2 as a8,e2 as a9,J2 as aa,A2 as ab,n0 as ac,h2 as ad,g2 as ae,w2 as af,G2 as ag,L2 as ah,p0 as ai,l0 as aj,r0 as ak,X1 as al,a0 as am,$2 as an,H2 as ao,Q2 as b,t2 as c,a2 as d,V2 as e,c2 as f,Y2 as g,E2 as h,h0 as i,C2 as j,U2 as k,T2 as l,t0 as m,J1 as n,Z2 as o,k0 as p,Y1 as q,G1 as r,S2 as s,s2 as t,R2 as u,F2 as v,o0 as w,M2 as x,_2 as y,W2 as z}; diff --git a/internal/webui/static/assets/index-BNFvzMjk.css b/internal/webui/static/assets/index-BNFvzMjk.css deleted file mode 100644 index 6c6f84c..0000000 --- a/internal/webui/static/assets/index-BNFvzMjk.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--color-neutral-200) / 1)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-1{top:-.25rem;right:-.25rem;bottom:-.25rem;left:-.25rem}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-12{right:-3rem}.-right-6{right:-1.5rem}.-top-16{top:-4rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-11{bottom:2.75rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-0\.5{left:.125rem}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[-10\%\]{left:-10%}.right-0{right:0}.right-10{right:2.5rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-\[-10\%\]{right:-10%}.top-0{top:0}.top-0\.5{top:.125rem}.top-1{top:.25rem}.top-1\.5{top:.375rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-4{top:1rem}.top-\[-10\%\]{top:-10%}.top-\[calc\(100\%\+6px\)\]{top:calc(100% + 6px)}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-\[10000\]{z-index:10000}.col-span-2{grid-column:span 2 / span 2}.col-span-full{grid-column:1 / -1}.m-2{margin:.5rem}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-10{margin-bottom:2.5rem}.mb-2{margin-bottom:.5rem}.mb-2\.5{margin-bottom:.625rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-16{margin-left:4rem}.ml-64{margin-left:16rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-28{height:7rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-32{height:8rem}.h-36{height:9rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[19px\]{height:19px}.h-\[280px\]{height:280px}.h-\[300px\]{height:300px}.h-\[350px\]{height:350px}.h-\[48px\]{height:48px}.h-\[60\%\]{height:60%}.h-\[800px\]{height:800px}.h-\[calc\(100vh-4rem\)\]{height:calc(100vh - 4rem)}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-80{max-height:20rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[min\(64vh\,28rem\)\]{max-height:min(64vh,28rem)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-36{min-height:9rem}.min-h-56{min-height:14rem}.min-h-64{min-height:16rem}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-\[42px\]{min-height:42px}.min-h-\[46px\]{min-height:46px}.min-h-\[560px\]{min-height:560px}.min-h-screen{min-height:100vh}.w-1\.5{width:.375rem}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[19\%\]{width:19%}.w-\[19px\]{width:19px}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[360px\]{width:360px}.w-\[60\%\]{width:60%}.w-\[7\%\]{width:7%}.w-\[8\%\]{width:8%}.w-\[800px\]{width:800px}.w-\[9\%\]{width:9%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-5{min-width:1.25rem}.min-w-9{min-width:2.25rem}.min-w-\[150px\]{min-width:150px}.min-w-\[200px\]{min-width:200px}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.min-w-\[760px\]{min-width:760px}.max-w-36{max-width:9rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[12rem\]{max-width:12rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[15rem\]{max-width:15rem}.max-w-\[1680px\]{max-width:1680px}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[400px\]{max-width:400px}.max-w-\[72\%\]{max-width:72%}.max-w-\[80px\]{max-width:80px}.max-w-\[82\%\]{max-width:82%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-5{--tw-translate-x: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-7{--tw-translate-x: 1.75rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}@keyframes spin{to{transform:rotate(360deg)}}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.grid-cols-\[320px_minmax\(0\,1fr\)\]{grid-template-columns:320px minmax(0,1fr)}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-100>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-divide-opacity, 1))}.divide-gray-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overscroll-contain{overscroll-behavior:contain}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:6px}.rounded-2xl,.rounded-3xl{border-radius:10px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:7px}.rounded-md{border-radius:6px}.rounded-xl{border-radius:8px}.rounded-bl-md{border-bottom-left-radius:6px}.rounded-br-md{border-bottom-right-radius:6px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-100) / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-200) / var(--tw-border-opacity, 1))}.border-amber-500{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-500) / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-600) / var(--tw-border-opacity, 1))}.border-brand{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(var(--color-success-100) / var(--tw-border-opacity, 1))}.border-emerald-500{--tw-border-opacity: 1;border-color:rgb(var(--color-success-500) / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-200) / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(var(--color-success-200) / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(var(--color-accent-100) / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-100) / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-200) / var(--tw-border-opacity, 1))}.border-sky-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-sky-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-sky-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-slate-100{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-100) / var(--tw-border-opacity, 1))}.border-slate-200{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-200) / var(--tw-border-opacity, 1))}.border-slate-200\/80{border-color:rgb(var(--color-slate-200) / .8)}.border-transparent{border-color:var(--color-transparent)}.border-white{--tw-border-opacity: 1;border-color:rgb(var(--color-white) / var(--tw-border-opacity, 1))}.border-white\/10{border-color:rgb(var(--color-white) / .1)}.border-white\/80{border-color:rgb(var(--color-white) / .8)}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:rgb(var(--color-warning-100) / .7)}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-50) / var(--tw-bg-opacity, 1))}.bg-amber-50\/60{background-color:rgb(var(--color-warning-50) / .6)}.bg-amber-50\/70{background-color:rgb(var(--color-warning-50) / .7)}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:rgb(var(--color-black) / .5)}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-blue-100\/70{background-color:rgb(var(--color-brand-100) / .7)}.bg-blue-200\/30{background-color:rgb(var(--color-brand-200) / .3)}.bg-blue-200\/40{background-color:rgb(var(--color-brand-200) / .4)}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-400) / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-blue-50\/40{background-color:rgb(var(--color-brand-50) / .4)}.bg-blue-50\/50{background-color:rgb(var(--color-brand-50) / .5)}.bg-blue-50\/60{background-color:rgb(var(--color-brand-50) / .6)}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:rgb(var(--color-brand-500) / .2)}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.bg-brand{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.bg-canvas{--tw-bg-opacity: 1;background-color:rgb(var(--color-canvas) / var(--tw-bg-opacity, 1))}.bg-danger-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-emerald-50\/60{background-color:rgb(var(--color-success-50) / .6)}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:rgb(var(--color-neutral-100) / .5)}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.bg-gray-200\/50{background-color:rgb(var(--color-neutral-200) / .5)}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-300) / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-400) / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:rgb(var(--color-neutral-50) / .7)}.bg-gray-50\/80{background-color:rgb(var(--color-neutral-50) / .8)}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-900) / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:rgb(var(--color-accent-50) / .5)}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-500) / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-600) / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:rgb(var(--color-danger-200) / .35)}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-600) / var(--tw-bg-opacity, 1))}.bg-sky-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-sky-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-200) / var(--tw-bg-opacity, 1))}.bg-slate-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-50) / var(--tw-bg-opacity, 1))}.bg-slate-50\/40{background-color:rgb(var(--color-slate-50) / .4)}.bg-slate-50\/70{background-color:rgb(var(--color-slate-50) / .7)}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-900) / var(--tw-bg-opacity, 1))}.bg-success-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-surface{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface) / var(--tw-bg-opacity, 1))}.bg-surface-muted{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-muted) / var(--tw-bg-opacity, 1))}.bg-surface-subtle{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-subtle) / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:var(--color-transparent)}.bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:rgb(var(--color-white) / .05)}.bg-white\/80{background-color:rgb(var(--color-white) / .8)}.bg-white\/90{background-color:rgb(var(--color-white) / .9)}.bg-white\/95{background-color:rgb(var(--color-white) / .95)}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: rgb(var(--color-brand-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-brand-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: rgb(var(--color-danger-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-danger-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(var(--color-white) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), rgb(var(--color-white) / 1) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: rgb(var(--color-warning-50) / 1) var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: var(--color-transparent) var(--tw-gradient-to-position)}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-12{padding:3rem}.p-16{padding:4rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-20{padding:5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-20{padding-top:5rem;padding-bottom:5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-0{padding-bottom:0}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pb-9{padding-bottom:2.25rem}.pl-10{padding-left:2.5rem}.pl-11{padding-left:2.75rem}.pl-14{padding-left:3.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pl-6{padding-left:1.5rem}.pl-9{padding-left:2.25rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pr-9{padding-right:2.25rem}.pt-1{padding-top:.25rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-black{font-weight:900}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-\[0\.22em\]{letter-spacing:.22em}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-amber-600{--tw-text-opacity: 1;color:rgb(var(--color-warning-600) / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(var(--color-warning-800) / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:rgb(var(--color-warning-800) / .8)}.text-amber-900{--tw-text-opacity: 1;color:rgb(var(--color-warning-900) / var(--tw-text-opacity, 1))}.text-amber-900\/90{color:rgb(var(--color-warning-900) / .9)}.text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(var(--color-brand-950) / var(--tw-text-opacity, 1))}.text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(var(--color-neutral-100) / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(var(--color-neutral-300) / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(var(--color-neutral-400) / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(var(--color-neutral-500) / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(var(--color-neutral-800) / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(var(--color-neutral-950) / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(var(--color-success-500) / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-ink{--tw-text-opacity: 1;color:rgb(var(--color-ink) / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(var(--color-accent-500) / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(var(--color-accent-700) / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(var(--color-danger-700) / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(var(--color-danger-800) / var(--tw-text-opacity, 1))}.text-red-900{--tw-text-opacity: 1;color:rgb(var(--color-danger-900) / var(--tw-text-opacity, 1))}.text-sky-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-sky-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-sky-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-sky-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-sky-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-slate-300{--tw-text-opacity: 1;color:rgb(var(--color-slate-300) / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(var(--color-slate-500) / var(--tw-text-opacity, 1))}.text-slate-600{--tw-text-opacity: 1;color:rgb(var(--color-slate-600) / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.text-slate-800{--tw-text-opacity: 1;color:rgb(var(--color-slate-800) / var(--tw-text-opacity, 1))}.text-slate-900{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(var(--color-slate-950) / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.accent-brand{accent-color:rgb(var(--color-brand) / 1)}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: var(--shadow-2xl);--tw-shadow-colored: var(--shadow-2xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-brand-active{--tw-shadow: var(--shadow-brand-active);--tw-shadow-colored: var(--shadow-brand-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat{--tw-shadow: var(--shadow-chat);--tw-shadow-colored: var(--shadow-chat);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-active{--tw-shadow: var(--shadow-chat-active);--tw-shadow-colored: var(--shadow-chat-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-input{--tw-shadow: var(--shadow-chat-input);--tw-shadow-colored: var(--shadow-chat-input);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: var(--shadow-inner);--tw-shadow-colored: var(--shadow-inner);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: var(--shadow-md);--tw-shadow-colored: var(--shadow-md);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-modal{--tw-shadow: var(--shadow-modal);--tw-shadow-colored: var(--shadow-modal);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-panel{--tw-shadow: var(--shadow-panel);--tw-shadow-colored: var(--shadow-panel);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sidebar{--tw-shadow: var(--shadow-sidebar);--tw-shadow-colored: var(--shadow-sidebar);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: var(--shadow-sm);--tw-shadow-colored: var(--shadow-sm);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: var(--shadow-xl);--tw-shadow-colored: var(--shadow-xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-blue-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: rgb(var(--color-brand-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: rgb(var(--color-success-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: rgb(var(--color-neutral-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(var(--color-neutral-200) / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: rgb(var(--color-danger-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-sky-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-neutral-200) / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-white) / var(--tw-ring-opacity, 1))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-2xl{--tw-blur: blur(40px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-\[120px\]{--tw-blur: blur(120px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur: blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-3xl{--tw-backdrop-blur: blur(64px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-xl{--tw-backdrop-blur: blur(24px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}:root{--color-transparent: transparent;--color-black: 0 0 0;--color-white: 255 255 255;--color-brand: 0 148 247;--color-brand-highlight: 0 113 227;--color-brand-light: 40 126 254;--color-ink: 29 29 31;--color-muted: 134 134 139;--color-line: 210 210 215;--color-canvas: 244 245 247;--color-surface: 255 255 255;--color-surface-subtle: 247 248 250;--color-surface-muted: 250 250 250;--color-neutral-50: 249 250 251;--color-neutral-100: 243 244 246;--color-neutral-200: 229 231 235;--color-neutral-300: 209 213 219;--color-neutral-400: 156 163 175;--color-neutral-500: 107 114 128;--color-neutral-600: 75 85 99;--color-neutral-700: 55 65 81;--color-neutral-800: 31 41 55;--color-neutral-900: 17 24 39;--color-neutral-950: 3 7 18;--color-slate-50: 248 250 252;--color-slate-100: 241 245 249;--color-slate-200: 226 232 240;--color-slate-300: 203 213 225;--color-slate-400: 148 163 184;--color-slate-500: 100 116 139;--color-slate-600: 71 85 105;--color-slate-700: 51 65 85;--color-slate-800: 30 41 59;--color-slate-900: 15 23 42;--color-slate-950: 2 6 23;--color-brand-50: 239 248 255;--color-brand-100: 223 241 255;--color-brand-200: 191 229 255;--color-brand-300: 143 210 255;--color-brand-400: 83 184 251;--color-brand-500: 0 148 247;--color-brand-600: 0 148 247;--color-brand-700: 0 113 227;--color-brand-800: 0 91 181;--color-brand-900: 0 75 147;--color-brand-950: 0 53 107;--color-success-50: 236 253 245;--color-success-100: 209 250 229;--color-success-200: 167 243 208;--color-success-300: 110 231 183;--color-success-400: 52 211 153;--color-success-500: 16 185 129;--color-success-600: 5 150 105;--color-success-700: 4 120 87;--color-success-800: 6 95 70;--color-success-900: 6 78 59;--color-success-950: 2 44 34;--color-warning-50: 255 251 235;--color-warning-100: 254 243 199;--color-warning-200: 253 230 138;--color-warning-300: 252 211 77;--color-warning-400: 251 191 36;--color-warning-500: 245 158 11;--color-warning-600: 217 119 6;--color-warning-700: 180 83 9;--color-warning-800: 146 64 14;--color-warning-900: 120 53 15;--color-warning-950: 69 26 3;--color-danger-50: 254 242 242;--color-danger-100: 254 226 226;--color-danger-200: 254 202 202;--color-danger-300: 252 165 165;--color-danger-400: 248 113 113;--color-danger-500: 239 68 68;--color-danger-600: 220 38 38;--color-danger-700: 185 28 28;--color-danger-800: 153 27 27;--color-danger-900: 127 29 29;--color-danger-950: 69 10 10;--color-info-50: 239 246 255;--color-info-100: 219 234 254;--color-info-200: 191 219 254;--color-info-300: 147 197 253;--color-info-400: 96 165 250;--color-info-500: 59 130 246;--color-info-600: 37 99 235;--color-info-700: 29 78 216;--color-info-800: 30 64 175;--color-info-900: 30 58 138;--color-info-950: 23 37 84;--color-accent-50: 250 245 255;--color-accent-100: 243 232 255;--color-accent-200: 233 213 255;--color-accent-300: 216 180 254;--color-accent-400: 192 132 252;--color-accent-500: 168 85 247;--color-accent-600: 147 51 234;--color-accent-700: 126 34 206;--color-accent-800: 107 33 168;--color-accent-900: 88 28 135;--color-accent-950: 59 7 100;--shadow-none: 0 0 0 var(--color-transparent);--shadow-default: 0 1px 3px 0 rgb(var(--color-black) / .1), 0 1px 2px -1px rgb(var(--color-black) / .1);--shadow-sm: 0 1px 2px 0 rgb(var(--color-black) / .05);--shadow-md: 0 4px 6px -1px rgb(var(--color-black) / .1), 0 2px 4px -2px rgb(var(--color-black) / .1);--shadow-lg: 0 10px 15px -3px rgb(var(--color-black) / .1), 0 4px 6px -4px rgb(var(--color-black) / .1);--shadow-xl: 0 20px 25px -5px rgb(var(--color-black) / .1), 0 8px 10px -6px rgb(var(--color-black) / .1);--shadow-2xl: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-inner: inset 0 2px 4px 0 rgb(var(--color-black) / .05);--shadow-card: 0 8px 24px rgb(var(--color-black) / .04);--shadow-panel: 0 20px 60px -15px rgb(var(--color-black) / .05);--shadow-modal: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-sidebar: 4px 0 24px rgb(var(--color-slate-900) / .035);--shadow-chat: 0 16px 45px rgb(var(--color-slate-900) / .06);--shadow-chat-input: 0 -8px 24px rgb(var(--color-slate-900) / .04);--shadow-chat-active: inset 3px 0 0 rgb(var(--color-brand));--shadow-brand-soft: 0 2px 8px rgb(var(--color-brand) / .2);--shadow-brand-active: 0 8px 18px rgb(var(--color-brand) / .2);--shadow-brand-strong: 0 8px 20px rgb(var(--color-brand) / .3)}*,:before,:after{--tw-ring-offset-color: rgb(var(--color-white));--tw-ring-color: rgb(var(--color-brand-400) / .5);--tw-ring-offset-shadow: 0 0 0 var(--color-transparent);--tw-ring-shadow: 0 0 0 var(--color-transparent);--tw-shadow: 0 0 0 var(--color-transparent);--tw-shadow-colored: 0 0 0 var(--color-transparent)}.squircle{-webkit-mask-image:url(/static/assets/squircle-rb6SKa34.svg);mask-image:url(/static/assets/squircle-rb6SKa34.svg);-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;border-radius:0}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;background-color:rgb(var(--color-canvas));color:rgb(var(--color-ink));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:rgb(var(--color-surface));border-radius:8px;border:1px solid rgb(var(--color-black) / .02);box-shadow:var(--shadow-card);transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px rgb(var(--color-black) / .06)}.dashboard-pie-chart .recharts-surface:focus,.dashboard-pie-chart .recharts-pie:focus,.dashboard-pie-chart .recharts-pie-sector:focus,.dashboard-pie-chart .recharts-sector:focus{outline:none}.dashboard-revenue-chart .recharts-surface:focus,.dashboard-revenue-chart .recharts-bar-rectangle:focus,.dashboard-revenue-chart .recharts-rectangle:focus,.dashboard-revenue-chart .recharts-curve:focus,.dashboard-revenue-chart .recharts-dot:focus,.dashboard-revenue-chart [class*=recharts-zIndex-layer_]:focus{outline:none!important}.dashboard-revenue-chart .recharts-bar-rectangle,.dashboard-revenue-chart .recharts-rectangle{stroke:none!important}.ios-input{background:rgb(var(--color-surface-subtle));border:1px solid var(--color-transparent);transition:all .3s cubic-bezier(.25,.8,.25,1);color:rgb(var(--color-ink));font-weight:500}.ios-input:focus{background:rgb(var(--color-surface));border-color:rgb(var(--color-brand));box-shadow:0 0 0 4px rgb(var(--color-brand) / .3);outline:none}.ios-input::-moz-placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-input::placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-btn-primary{background:rgb(var(--color-brand));color:rgb(var(--color-white));font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:rgb(var(--color-brand-highlight));transform:translateY(-1px);box-shadow:var(--shadow-brand-strong)}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:var(--shadow-brand-soft)}.ios-btn-primary:disabled{background:rgb(var(--color-neutral-100));color:rgb(var(--color-neutral-400));box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:rgb(var(--color-surface-subtle));color:rgb(var(--color-ink));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:rgb(var(--color-neutral-200));border-color:rgb(var(--color-neutral-300))}.ios-btn-danger{background:rgb(var(--color-danger-100));color:rgb(var(--color-danger-600));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:rgb(var(--color-danger-200));border-color:rgb(var(--color-danger-300))}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--color-transparent)}::-webkit-scrollbar-thumb{background:rgb(var(--color-black) / .1);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:rgb(var(--color-black) / .2)}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-in{animation:fadeIn .5s cubic-bezier(.16,1,.3,1) forwards}@keyframes slideUp{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.animate-slide-up{animation:slideUp .3s cubic-bezier(.16,1,.3,1) forwards}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}::-moz-selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}::selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}.text-brand{color:rgb(var(--color-brand))}.bg-brand{background-color:rgb(var(--color-brand))}.border-brand{border-color:rgb(var(--color-brand))}.status-badge{display:inline-flex;align-items:center;padding:4px 12px;border-radius:9999px;font-size:12px;font-weight:600}.status-badge-success{background-color:rgb(var(--color-success-100));color:rgb(var(--color-success-800))}.status-badge-warning{background-color:rgb(var(--color-warning-100));color:rgb(var(--color-warning-800))}.status-badge-error{background-color:rgb(var(--color-danger-100));color:rgb(var(--color-danger-800))}.status-badge-info{background-color:rgb(var(--color-info-100));color:rgb(var(--color-info-800))}.loading-skeleton{background:linear-gradient(90deg,rgb(var(--color-neutral-100)),rgb(var(--color-neutral-200)),rgb(var(--color-neutral-100)));background-size:200% 100%;animation:loading 1.5s ease-in-out infinite}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background-color:rgb(var(--color-black) / .4);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto;display:flex;flex-direction:column;background-color:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));z-index:10}.modal-body{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:2rem}.modal-footer{flex-shrink:0;padding:1.5rem 2rem 2rem;border-top:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));z-index:10}.modal-container-lg{max-width:64rem}.modal-overlay-centered{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;justify-content:center;background-color:rgb(var(--color-black) / .4);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-overlay-centered .modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto 0;display:flex;flex-direction:column;background-color:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}@media(max-width:768px){.ios-card{border-radius:6px}.ios-input{font-size:16px}.modal-container{max-width:calc(100% - 2rem);max-height:90vh;border-radius:8px}.modal-header,.modal-body,.modal-footer{padding-left:1.5rem;padding-right:1.5rem}}.placeholder\:text-slate-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.placeholder\:text-slate-400::placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.focus-within\:border-sky-400:focus-within{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus-within\:ring-2:focus-within{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-within\:ring-sky-100:focus-within{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.hover\:translate-y-\[-4px\]:hover{--tw-translate-y: -4px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-amber-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-300) / var(--tw-border-opacity, 1))}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-300) / var(--tw-border-opacity, 1))}.hover\:border-brand:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-success-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-400) / var(--tw-border-opacity, 1))}.hover\:border-sky-200:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-700) / var(--tw-bg-opacity, 1))}.hover\:bg-brand:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.hover\:bg-brand-highlight:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-highlight) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:rgb(var(--color-success-50) / .5)}.hover\:bg-emerald-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-700) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-800) / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-700) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.hover\:bg-warning-50\/50:hover{background-color:rgb(var(--color-warning-50) / .5)}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:rgb(var(--color-white) / .1)}.hover\:bg-white\/80:hover{background-color:rgb(var(--color-white) / .8)}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-brand:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.hover\:text-sky-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-slate-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.hover\:text-slate-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:border-sky-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-brand:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand) / var(--tw-ring-opacity, 1))}.focus\:ring-sky-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.active\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:bg-red-400:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-400) / var(--tw-bg-opacity, 1))}.disabled\:bg-slate-300:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.disabled\:opacity-25:disabled{opacity:.25}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.disabled\:opacity-70:disabled{opacity:.7}.disabled\:shadow-none:disabled{--tw-shadow: var(--shadow-none);--tw-shadow-colored: var(--shadow-none);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.group:focus-within .group-focus-within\:text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.group:hover .group-hover\:translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-105{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-48{width:12rem}.sm\:w-56{width:14rem}.sm\:w-64{width:16rem}.sm\:w-72{width:18rem}.sm\:max-w-sm{max-width:24rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:grid-cols-\[1fr_180px\]{grid-template-columns:1fr 180px}.sm\:flex-row{flex-direction:row}.sm\:flex-wrap{flex-wrap:wrap}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:col-span-3{grid-column:span 3 / span 3}.md\:col-span-full{grid-column:1 / -1}.md\:w-auto{width:auto}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1\.4fr_110px_40px\]{grid-template-columns:1.4fr 110px 40px}.md\:grid-cols-\[180px_1fr\]{grid-template-columns:180px 1fr}.md\:grid-cols-\[1fr_1fr_1\.4fr_110px_40px\]{grid-template-columns:1fr 1fr 1.4fr 110px 40px}.md\:flex-row{flex-direction:row}.md\:items-end{align-items:flex-end}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:border-l{border-left-width:1px}.md\:border-t-0{border-top-width:0px}.md\:p-12{padding:3rem}.md\:p-6{padding:1.5rem}.md\:pl-6{padding-left:1.5rem}.md\:pt-0{padding-top:0}}@media(min-width:1024px){.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[320px_1fr\]{grid-template-columns:320px 1fr}.lg\:flex-row{flex-direction:row}.lg\:items-center{align-items:center}}@media(min-width:1280px){.xl\:w-36{width:9rem}.xl\:w-52{width:13rem}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-\[minmax\(270px\,0\.72fr\)_minmax\(0\,1\.28fr\)\]{grid-template-columns:minmax(270px,.72fr) minmax(0,1.28fr)}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:items-center{align-items:center}.xl\:justify-between{justify-content:space-between}}@media(min-width:1536px){.\32xl\:grid-cols-\[360px_1fr\]{grid-template-columns:360px 1fr}} diff --git a/internal/webui/static/assets/index-DVSGe2YH.css b/internal/webui/static/assets/index-DVSGe2YH.css new file mode 100644 index 0000000..767c006 --- /dev/null +++ b/internal/webui/static/assets/index-DVSGe2YH.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--color-neutral-200) / 1)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-1{top:-.25rem;right:-.25rem;bottom:-.25rem;left:-.25rem}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.-bottom-1{bottom:-.25rem}.-right-1{right:-.25rem}.-right-12{right:-3rem}.-right-6{right:-1.5rem}.-top-16{top:-4rem}.-top-6{top:-1.5rem}.bottom-10{bottom:2.5rem}.bottom-11{bottom:2.75rem}.bottom-8{bottom:2rem}.bottom-\[-10\%\]{bottom:-10%}.left-0{left:0}.left-0\.5{left:.125rem}.left-1{left:.25rem}.left-1\.5{left:.375rem}.left-1\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[-10\%\]{left:-10%}.right-0{right:0}.right-10{right:2.5rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-\[-10\%\]{right:-10%}.top-0{top:0}.top-0\.5{top:.125rem}.top-1{top:.25rem}.top-1\.5{top:.375rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-4{top:1rem}.top-\[-10\%\]{top:-10%}.top-\[calc\(100\%\+6px\)\]{top:calc(100% + 6px)}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-\[10000\]{z-index:10000}.col-span-2{grid-column:span 2 / span 2}.col-span-full{grid-column:1 / -1}.m-2{margin:.5rem}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-10{margin-bottom:2.5rem}.mb-2{margin-bottom:.5rem}.mb-2\.5{margin-bottom:.625rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-16{margin-left:4rem}.ml-64{margin-left:16rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-28{height:7rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-32{height:8rem}.h-36{height:9rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-9{height:2.25rem}.h-\[18px\]{height:18px}.h-\[19px\]{height:19px}.h-\[280px\]{height:280px}.h-\[300px\]{height:300px}.h-\[350px\]{height:350px}.h-\[48px\]{height:48px}.h-\[60\%\]{height:60%}.h-\[800px\]{height:800px}.h-\[calc\(100vh-4rem\)\]{height:calc(100vh - 4rem)}.h-auto{height:auto}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-44{max-height:11rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-80{max-height:20rem}.max-h-\[380px\]{max-height:380px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[min\(64vh\,28rem\)\]{max-height:min(64vh,28rem)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-36{min-height:9rem}.min-h-56{min-height:14rem}.min-h-64{min-height:16rem}.min-h-\[120px\]{min-height:120px}.min-h-\[150px\]{min-height:150px}.min-h-\[400px\]{min-height:400px}.min-h-\[42px\]{min-height:42px}.min-h-\[46px\]{min-height:46px}.min-h-\[560px\]{min-height:560px}.min-h-screen{min-height:100vh}.w-1\.5{width:.375rem}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[18px\]{width:18px}.w-\[19\%\]{width:19%}.w-\[19px\]{width:19px}.w-\[23\%\]{width:23%}.w-\[27\%\]{width:27%}.w-\[360px\]{width:360px}.w-\[60\%\]{width:60%}.w-\[7\%\]{width:7%}.w-\[8\%\]{width:8%}.w-\[800px\]{width:800px}.w-\[9\%\]{width:9%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-5{min-width:1.25rem}.min-w-9{min-width:2.25rem}.min-w-\[150px\]{min-width:150px}.min-w-\[200px\]{min-width:200px}.min-w-\[210px\]{min-width:210px}.min-w-\[260px\]{min-width:260px}.min-w-\[760px\]{min-width:760px}.max-w-36{max-width:9rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[12rem\]{max-width:12rem}.max-w-\[1400px\]{max-width:1400px}.max-w-\[15rem\]{max-width:15rem}.max-w-\[1680px\]{max-width:1680px}.max-w-\[240px\]{max-width:240px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[400px\]{max-width:400px}.max-w-\[72\%\]{max-width:72%}.max-w-\[80px\]{max-width:80px}.max-w-\[82\%\]{max-width:82%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-5{--tw-translate-x: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-7{--tw-translate-x: 1.75rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}@keyframes spin{to{transform:rotate(360deg)}}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.grid-cols-\[320px_minmax\(0\,1fr\)\]{grid-template-columns:320px minmax(0,1fr)}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-100>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-divide-opacity, 1))}.divide-gray-50>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-divide-opacity, 1))}.self-start{align-self:flex-start}.self-center{align-self:center}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overscroll-contain{overscroll-behavior:contain}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:6px}.rounded-2xl,.rounded-3xl{border-radius:10px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:7px}.rounded-md{border-radius:6px}.rounded-xl{border-radius:8px}.rounded-bl-md{border-bottom-left-radius:6px}.rounded-br-md{border-bottom-right-radius:6px}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-4{border-width:4px}.border-y{border-top-width:1px;border-bottom-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-100) / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-200) / var(--tw-border-opacity, 1))}.border-amber-500{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-500) / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-600) / var(--tw-border-opacity, 1))}.border-brand{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.border-emerald-100{--tw-border-opacity: 1;border-color:rgb(var(--color-success-100) / var(--tw-border-opacity, 1))}.border-emerald-500{--tw-border-opacity: 1;border-color:rgb(var(--color-success-500) / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-100) / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-200) / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.border-gray-50{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-50) / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(var(--color-success-200) / var(--tw-border-opacity, 1))}.border-purple-100{--tw-border-opacity: 1;border-color:rgb(var(--color-accent-100) / var(--tw-border-opacity, 1))}.border-red-100{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-100) / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(var(--color-danger-200) / var(--tw-border-opacity, 1))}.border-sky-100{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-100) / var(--tw-border-opacity, 1))}.border-sky-200{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.border-sky-500{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-500) / var(--tw-border-opacity, 1))}.border-slate-100{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-100) / var(--tw-border-opacity, 1))}.border-slate-200{--tw-border-opacity: 1;border-color:rgb(var(--color-slate-200) / var(--tw-border-opacity, 1))}.border-slate-200\/80{border-color:rgb(var(--color-slate-200) / .8)}.border-transparent{border-color:var(--color-transparent)}.border-white{--tw-border-opacity: 1;border-color:rgb(var(--color-white) / var(--tw-border-opacity, 1))}.border-white\/10{border-color:rgb(var(--color-white) / .1)}.border-white\/80{border-color:rgb(var(--color-white) / .8)}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-amber-100\/70{background-color:rgb(var(--color-warning-100) / .7)}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-50) / var(--tw-bg-opacity, 1))}.bg-amber-50\/60{background-color:rgb(var(--color-warning-50) / .6)}.bg-amber-50\/70{background-color:rgb(var(--color-warning-50) / .7)}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:rgb(var(--color-black) / .5)}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-blue-100\/70{background-color:rgb(var(--color-brand-100) / .7)}.bg-blue-200\/30{background-color:rgb(var(--color-brand-200) / .3)}.bg-blue-200\/40{background-color:rgb(var(--color-brand-200) / .4)}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-400) / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-blue-50\/40{background-color:rgb(var(--color-brand-50) / .4)}.bg-blue-50\/50{background-color:rgb(var(--color-brand-50) / .5)}.bg-blue-50\/60{background-color:rgb(var(--color-brand-50) / .6)}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-blue-500\/20{background-color:rgb(var(--color-brand-500) / .2)}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.bg-brand{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.bg-canvas{--tw-bg-opacity: 1;background-color:rgb(var(--color-canvas) / var(--tw-bg-opacity, 1))}.bg-danger-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-emerald-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-emerald-50\/60{background-color:rgb(var(--color-success-50) / .6)}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.bg-gray-100\/50{background-color:rgb(var(--color-neutral-100) / .5)}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.bg-gray-200\/50{background-color:rgb(var(--color-neutral-200) / .5)}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-300) / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-400) / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.bg-gray-50\/70{background-color:rgb(var(--color-neutral-50) / .7)}.bg-gray-50\/80{background-color:rgb(var(--color-neutral-50) / .8)}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-900) / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-500) / var(--tw-bg-opacity, 1))}.bg-pink-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-50) / var(--tw-bg-opacity, 1))}.bg-purple-50\/50{background-color:rgb(var(--color-accent-50) / .5)}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-500) / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-600) / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.bg-red-200\/35{background-color:rgb(var(--color-danger-200) / .35)}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-500) / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-600) / var(--tw-bg-opacity, 1))}.bg-sky-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.bg-sky-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-500) / var(--tw-bg-opacity, 1))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-200) / var(--tw-bg-opacity, 1))}.bg-slate-300{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-50) / var(--tw-bg-opacity, 1))}.bg-slate-50\/40{background-color:rgb(var(--color-slate-50) / .4)}.bg-slate-50\/70{background-color:rgb(var(--color-slate-50) / .7)}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-900) / var(--tw-bg-opacity, 1))}.bg-success-500{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-500) / var(--tw-bg-opacity, 1))}.bg-surface{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface) / var(--tw-bg-opacity, 1))}.bg-surface-muted{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-muted) / var(--tw-bg-opacity, 1))}.bg-surface-subtle{--tw-bg-opacity: 1;background-color:rgb(var(--color-surface-subtle) / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:var(--color-transparent)}.bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.bg-white\/5{background-color:rgb(var(--color-white) / .05)}.bg-white\/80{background-color:rgb(var(--color-white) / .8)}.bg-white\/90{background-color:rgb(var(--color-white) / .9)}.bg-white\/95{background-color:rgb(var(--color-white) / .95)}.bg-opacity-10{--tw-bg-opacity: .1}.bg-gradient-to-bl{background-image:linear-gradient(to bottom left,var(--tw-gradient-stops))}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from: rgb(var(--color-brand-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-brand-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-50{--tw-gradient-from: rgb(var(--color-danger-50) / 1) var(--tw-gradient-from-position);--tw-gradient-to: rgb(var(--color-danger-50) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-white{--tw-gradient-to: rgb(var(--color-white) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), rgb(var(--color-white) / 1) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-orange-50{--tw-gradient-to: rgb(var(--color-warning-50) / 1) var(--tw-gradient-to-position)}.to-transparent{--tw-gradient-to: var(--color-transparent) var(--tw-gradient-to-position)}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-12{padding:3rem}.p-16{padding:4rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-20{padding:5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-20{padding-top:5rem;padding-bottom:5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-0{padding-bottom:0}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-24{padding-bottom:6rem}.pb-9{padding-bottom:2.25rem}.pl-10{padding-left:2.5rem}.pl-11{padding-left:2.75rem}.pl-14{padding-left:3.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pl-6{padding-left:1.5rem}.pl-9{padding-left:2.25rem}.pr-10{padding-right:2.5rem}.pr-11{padding-right:2.75rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-6{padding-right:1.5rem}.pr-9{padding-right:2.25rem}.pt-1{padding-top:.25rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-black{font-weight:900}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-\[0\.22em\]{letter-spacing:.22em}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-amber-600{--tw-text-opacity: 1;color:rgb(var(--color-warning-600) / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(var(--color-warning-800) / var(--tw-text-opacity, 1))}.text-amber-800\/80{color:rgb(var(--color-warning-800) / .8)}.text-amber-900{--tw-text-opacity: 1;color:rgb(var(--color-warning-900) / var(--tw-text-opacity, 1))}.text-amber-900\/90{color:rgb(var(--color-warning-900) / .9)}.text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-blue-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-blue-950{--tw-text-opacity: 1;color:rgb(var(--color-brand-950) / var(--tw-text-opacity, 1))}.text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-gray-100{--tw-text-opacity: 1;color:rgb(var(--color-neutral-100) / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(var(--color-neutral-300) / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(var(--color-neutral-400) / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(var(--color-neutral-500) / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(var(--color-neutral-800) / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.text-gray-950{--tw-text-opacity: 1;color:rgb(var(--color-neutral-950) / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(var(--color-success-500) / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(var(--color-success-700) / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(var(--color-success-800) / var(--tw-text-opacity, 1))}.text-ink{--tw-text-opacity: 1;color:rgb(var(--color-ink) / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(var(--color-warning-700) / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(var(--color-accent-500) / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(var(--color-accent-600) / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(var(--color-accent-700) / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(var(--color-danger-700) / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(var(--color-danger-800) / var(--tw-text-opacity, 1))}.text-red-900{--tw-text-opacity: 1;color:rgb(var(--color-danger-900) / var(--tw-text-opacity, 1))}.text-sky-500{--tw-text-opacity: 1;color:rgb(var(--color-brand-500) / var(--tw-text-opacity, 1))}.text-sky-600{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.text-sky-700{--tw-text-opacity: 1;color:rgb(var(--color-brand-700) / var(--tw-text-opacity, 1))}.text-sky-800{--tw-text-opacity: 1;color:rgb(var(--color-brand-800) / var(--tw-text-opacity, 1))}.text-sky-900{--tw-text-opacity: 1;color:rgb(var(--color-brand-900) / var(--tw-text-opacity, 1))}.text-slate-300{--tw-text-opacity: 1;color:rgb(var(--color-slate-300) / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(var(--color-slate-500) / var(--tw-text-opacity, 1))}.text-slate-600{--tw-text-opacity: 1;color:rgb(var(--color-slate-600) / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.text-slate-800{--tw-text-opacity: 1;color:rgb(var(--color-slate-800) / var(--tw-text-opacity, 1))}.text-slate-900{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.text-slate-950{--tw-text-opacity: 1;color:rgb(var(--color-slate-950) / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.accent-brand{accent-color:rgb(var(--color-brand) / 1)}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow: var(--shadow-2xl);--tw-shadow-colored: var(--shadow-2xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-brand-active{--tw-shadow: var(--shadow-brand-active);--tw-shadow-colored: var(--shadow-brand-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat{--tw-shadow: var(--shadow-chat);--tw-shadow-colored: var(--shadow-chat);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-active{--tw-shadow: var(--shadow-chat-active);--tw-shadow-colored: var(--shadow-chat-active);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-chat-input{--tw-shadow: var(--shadow-chat-input);--tw-shadow-colored: var(--shadow-chat-input);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-inner{--tw-shadow: var(--shadow-inner);--tw-shadow-colored: var(--shadow-inner);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: var(--shadow-md);--tw-shadow-colored: var(--shadow-md);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-modal{--tw-shadow: var(--shadow-modal);--tw-shadow-colored: var(--shadow-modal);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-panel{--tw-shadow: var(--shadow-panel);--tw-shadow-colored: var(--shadow-panel);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sidebar{--tw-shadow: var(--shadow-sidebar);--tw-shadow-colored: var(--shadow-sidebar);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: var(--shadow-sm);--tw-shadow-colored: var(--shadow-sm);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: var(--shadow-xl);--tw-shadow-colored: var(--shadow-xl);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-blue-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-blue-200{--tw-shadow-color: rgb(var(--color-brand-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-100{--tw-shadow-color: rgb(var(--color-success-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200{--tw-shadow-color: rgb(var(--color-neutral-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-gray-200\/70{--tw-shadow-color: rgb(var(--color-neutral-200) / .7);--tw-shadow: var(--tw-shadow-colored)}.shadow-red-200{--tw-shadow-color: rgb(var(--color-danger-200) / 1);--tw-shadow: var(--tw-shadow-colored)}.shadow-sky-100{--tw-shadow-color: rgb(var(--color-brand-100) / 1);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-neutral-200) / var(--tw-ring-opacity, 1))}.ring-white{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-white) / var(--tw-ring-opacity, 1))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-2xl{--tw-blur: blur(40px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.blur-\[120px\]{--tw-blur: blur(120px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur: blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-3xl{--tw-backdrop-blur: blur(64px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-md{--tw-backdrop-blur: blur(12px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-xl{--tw-backdrop-blur: blur(24px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}:root{--color-transparent: transparent;--color-black: 0 0 0;--color-white: 255 255 255;--color-brand: 0 148 247;--color-brand-highlight: 0 113 227;--color-brand-light: 40 126 254;--color-ink: 29 29 31;--color-muted: 134 134 139;--color-line: 210 210 215;--color-canvas: 244 245 247;--color-surface: 255 255 255;--color-surface-subtle: 247 248 250;--color-surface-muted: 250 250 250;--color-neutral-50: 249 250 251;--color-neutral-100: 243 244 246;--color-neutral-200: 229 231 235;--color-neutral-300: 209 213 219;--color-neutral-400: 156 163 175;--color-neutral-500: 107 114 128;--color-neutral-600: 75 85 99;--color-neutral-700: 55 65 81;--color-neutral-800: 31 41 55;--color-neutral-900: 17 24 39;--color-neutral-950: 3 7 18;--color-slate-50: 248 250 252;--color-slate-100: 241 245 249;--color-slate-200: 226 232 240;--color-slate-300: 203 213 225;--color-slate-400: 148 163 184;--color-slate-500: 100 116 139;--color-slate-600: 71 85 105;--color-slate-700: 51 65 85;--color-slate-800: 30 41 59;--color-slate-900: 15 23 42;--color-slate-950: 2 6 23;--color-brand-50: 239 248 255;--color-brand-100: 223 241 255;--color-brand-200: 191 229 255;--color-brand-300: 143 210 255;--color-brand-400: 83 184 251;--color-brand-500: 0 148 247;--color-brand-600: 0 148 247;--color-brand-700: 0 113 227;--color-brand-800: 0 91 181;--color-brand-900: 0 75 147;--color-brand-950: 0 53 107;--color-success-50: 236 253 245;--color-success-100: 209 250 229;--color-success-200: 167 243 208;--color-success-300: 110 231 183;--color-success-400: 52 211 153;--color-success-500: 16 185 129;--color-success-600: 5 150 105;--color-success-700: 4 120 87;--color-success-800: 6 95 70;--color-success-900: 6 78 59;--color-success-950: 2 44 34;--color-warning-50: 255 251 235;--color-warning-100: 254 243 199;--color-warning-200: 253 230 138;--color-warning-300: 252 211 77;--color-warning-400: 251 191 36;--color-warning-500: 245 158 11;--color-warning-600: 217 119 6;--color-warning-700: 180 83 9;--color-warning-800: 146 64 14;--color-warning-900: 120 53 15;--color-warning-950: 69 26 3;--color-danger-50: 254 242 242;--color-danger-100: 254 226 226;--color-danger-200: 254 202 202;--color-danger-300: 252 165 165;--color-danger-400: 248 113 113;--color-danger-500: 239 68 68;--color-danger-600: 220 38 38;--color-danger-700: 185 28 28;--color-danger-800: 153 27 27;--color-danger-900: 127 29 29;--color-danger-950: 69 10 10;--color-info-50: 239 246 255;--color-info-100: 219 234 254;--color-info-200: 191 219 254;--color-info-300: 147 197 253;--color-info-400: 96 165 250;--color-info-500: 59 130 246;--color-info-600: 37 99 235;--color-info-700: 29 78 216;--color-info-800: 30 64 175;--color-info-900: 30 58 138;--color-info-950: 23 37 84;--color-accent-50: 250 245 255;--color-accent-100: 243 232 255;--color-accent-200: 233 213 255;--color-accent-300: 216 180 254;--color-accent-400: 192 132 252;--color-accent-500: 168 85 247;--color-accent-600: 147 51 234;--color-accent-700: 126 34 206;--color-accent-800: 107 33 168;--color-accent-900: 88 28 135;--color-accent-950: 59 7 100;--shadow-none: 0 0 0 var(--color-transparent);--shadow-default: 0 1px 3px 0 rgb(var(--color-black) / .1), 0 1px 2px -1px rgb(var(--color-black) / .1);--shadow-sm: 0 1px 2px 0 rgb(var(--color-black) / .05);--shadow-md: 0 4px 6px -1px rgb(var(--color-black) / .1), 0 2px 4px -2px rgb(var(--color-black) / .1);--shadow-lg: 0 10px 15px -3px rgb(var(--color-black) / .1), 0 4px 6px -4px rgb(var(--color-black) / .1);--shadow-xl: 0 20px 25px -5px rgb(var(--color-black) / .1), 0 8px 10px -6px rgb(var(--color-black) / .1);--shadow-2xl: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-inner: inset 0 2px 4px 0 rgb(var(--color-black) / .05);--shadow-card: 0 8px 24px rgb(var(--color-black) / .04);--shadow-panel: 0 20px 60px -15px rgb(var(--color-black) / .05);--shadow-modal: 0 25px 50px -12px rgb(var(--color-black) / .25);--shadow-sidebar: 4px 0 24px rgb(var(--color-slate-900) / .035);--shadow-chat: 0 16px 45px rgb(var(--color-slate-900) / .06);--shadow-chat-input: 0 -8px 24px rgb(var(--color-slate-900) / .04);--shadow-chat-active: inset 3px 0 0 rgb(var(--color-brand));--shadow-brand-soft: 0 2px 8px rgb(var(--color-brand) / .2);--shadow-brand-active: 0 8px 18px rgb(var(--color-brand) / .2);--shadow-brand-strong: 0 8px 20px rgb(var(--color-brand) / .3)}*,:before,:after{--tw-ring-offset-color: rgb(var(--color-white));--tw-ring-color: rgb(var(--color-brand-400) / .5);--tw-ring-offset-shadow: 0 0 0 var(--color-transparent);--tw-ring-shadow: 0 0 0 var(--color-transparent);--tw-shadow: 0 0 0 var(--color-transparent);--tw-shadow-colored: 0 0 0 var(--color-transparent)}.squircle{-webkit-mask-image:url(/static/assets/squircle-rb6SKa34.svg);mask-image:url(/static/assets/squircle-rb6SKa34.svg);-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;border-radius:0}*{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;background-color:rgb(var(--color-canvas));color:rgb(var(--color-ink));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ios-card{background:rgb(var(--color-surface));border-radius:8px;border:1px solid rgb(var(--color-black) / .02);box-shadow:var(--shadow-card);transition:transform .2s ease,box-shadow .2s ease}.ios-card:hover{box-shadow:0 12px 32px rgb(var(--color-black) / .06)}.dashboard-pie-chart .recharts-surface:focus,.dashboard-pie-chart .recharts-pie:focus,.dashboard-pie-chart .recharts-pie-sector:focus,.dashboard-pie-chart .recharts-sector:focus{outline:none}.dashboard-revenue-chart .recharts-surface:focus,.dashboard-revenue-chart .recharts-bar-rectangle:focus,.dashboard-revenue-chart .recharts-rectangle:focus,.dashboard-revenue-chart .recharts-curve:focus,.dashboard-revenue-chart .recharts-dot:focus,.dashboard-revenue-chart [class*=recharts-zIndex-layer_]:focus{outline:none!important}.dashboard-revenue-chart .recharts-bar-rectangle,.dashboard-revenue-chart .recharts-rectangle{stroke:none!important}.ios-input{background:rgb(var(--color-surface-subtle));border:1px solid var(--color-transparent);transition:all .3s cubic-bezier(.25,.8,.25,1);color:rgb(var(--color-ink));font-weight:500}.ios-input:focus{background:rgb(var(--color-surface));border-color:rgb(var(--color-brand));box-shadow:0 0 0 4px rgb(var(--color-brand) / .3);outline:none}.ios-input::-moz-placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-input::placeholder{color:rgb(var(--color-neutral-400));font-weight:400}.ios-btn-primary{background:rgb(var(--color-brand));color:rgb(var(--color-white));font-weight:700;border:none;transition:all .2s cubic-bezier(.25,.8,.25,1);cursor:pointer}.ios-btn-primary:hover:not(:disabled){background:rgb(var(--color-brand-highlight));transform:translateY(-1px);box-shadow:var(--shadow-brand-strong)}.ios-btn-primary:active:not(:disabled){transform:translateY(1px);box-shadow:var(--shadow-brand-soft)}.ios-btn-primary:disabled{background:rgb(var(--color-neutral-100));color:rgb(var(--color-neutral-400));box-shadow:none;transform:none;cursor:not-allowed}.ios-btn-secondary{background:rgb(var(--color-surface-subtle));color:rgb(var(--color-ink));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-secondary:hover{background:rgb(var(--color-neutral-200));border-color:rgb(var(--color-neutral-300))}.ios-btn-danger{background:rgb(var(--color-danger-100));color:rgb(var(--color-danger-600));font-weight:600;border:1px solid var(--color-transparent);transition:all .2s ease;cursor:pointer}.ios-btn-danger:hover{background:rgb(var(--color-danger-200));border-color:rgb(var(--color-danger-300))}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:var(--color-transparent)}::-webkit-scrollbar-thumb{background:rgb(var(--color-black) / .1);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:rgb(var(--color-black) / .2)}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-in{animation:fadeIn .5s cubic-bezier(.16,1,.3,1) forwards}@keyframes slideUp{0%{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.animate-slide-up{animation:slideUp .3s cubic-bezier(.16,1,.3,1) forwards}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}::-moz-selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}::selection{background:rgb(var(--color-brand));color:rgb(var(--color-white))}.text-brand{color:rgb(var(--color-brand))}.bg-brand{background-color:rgb(var(--color-brand))}.border-brand{border-color:rgb(var(--color-brand))}.status-badge{display:inline-flex;align-items:center;padding:4px 12px;border-radius:9999px;font-size:12px;font-weight:600}.status-badge-success{background-color:rgb(var(--color-success-100));color:rgb(var(--color-success-800))}.status-badge-warning{background-color:rgb(var(--color-warning-100));color:rgb(var(--color-warning-800))}.status-badge-error{background-color:rgb(var(--color-danger-100));color:rgb(var(--color-danger-800))}.status-badge-info{background-color:rgb(var(--color-info-100));color:rgb(var(--color-info-800))}.loading-skeleton{background:linear-gradient(90deg,rgb(var(--color-neutral-100)),rgb(var(--color-neutral-200)),rgb(var(--color-neutral-100)));background-size:200% 100%;animation:loading 1.5s ease-in-out infinite}@keyframes loading{0%{background-position:200% 0}to{background-position:-200% 0}}.modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background-color:rgb(var(--color-black) / .4);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto;display:flex;flex-direction:column;background-color:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}.modal-header{flex-shrink:0;padding:2rem 2rem 1.5rem;border-bottom:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));z-index:10}.modal-body{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;padding:2rem}.modal-footer{flex-shrink:0;padding:1.5rem 2rem 2rem;border-top:1px solid rgb(var(--color-neutral-100));background-color:rgb(var(--color-white));z-index:10}.modal-container-lg{max-width:64rem}.modal-overlay-centered{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;justify-content:center;background-color:rgb(var(--color-black) / .4);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);padding:1rem;overflow-y:auto}.modal-overlay-centered .modal-container{position:relative;width:100%;max-width:42rem;max-height:85vh;margin:auto 0;display:flex;flex-direction:column;background-color:rgb(var(--color-white));border-radius:10px;box-shadow:var(--shadow-modal);overflow:hidden}@media(max-width:768px){.ios-card{border-radius:6px}.ios-input{font-size:16px}.modal-container{max-width:calc(100% - 2rem);max-height:90vh;border-radius:8px}.modal-header,.modal-body,.modal-footer{padding-left:1.5rem;padding-right:1.5rem}}.placeholder\:text-slate-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.placeholder\:text-slate-400::placeholder{--tw-text-opacity: 1;color:rgb(var(--color-slate-400) / var(--tw-text-opacity, 1))}.focus-within\:border-sky-400:focus-within{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus-within\:ring-2:focus-within{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-within\:ring-sky-100:focus-within{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.hover\:translate-y-\[-4px\]:hover{--tw-translate-y: -4px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-amber-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-warning-300) / var(--tw-border-opacity, 1))}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-300) / var(--tw-border-opacity, 1))}.hover\:border-brand:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand) / var(--tw-border-opacity, 1))}.hover\:border-emerald-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-success-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-300) / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-neutral-400) / var(--tw-border-opacity, 1))}.hover\:border-sky-200:hover{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-200) / var(--tw-border-opacity, 1))}.hover\:bg-amber-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-warning-100) / var(--tw-bg-opacity, 1))}.hover\:bg-black:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-black) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-100) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-700) / var(--tw-bg-opacity, 1))}.hover\:bg-brand:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand) / var(--tw-bg-opacity, 1))}.hover\:bg-brand-highlight:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-highlight) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-50\/50:hover{background-color:rgb(var(--color-success-50) / .5)}.hover\:bg-emerald-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-600) / var(--tw-bg-opacity, 1))}.hover\:bg-emerald-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-700) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-100) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-200) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-50) / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-neutral-800) / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-100) / var(--tw-bg-opacity, 1))}.hover\:bg-green-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-success-50) / var(--tw-bg-opacity, 1))}.hover\:bg-purple-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-accent-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-100) / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-50) / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-700) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-50:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-50) / var(--tw-bg-opacity, 1))}.hover\:bg-sky-600:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-brand-600) / var(--tw-bg-opacity, 1))}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-100) / var(--tw-bg-opacity, 1))}.hover\:bg-warning-50\/50:hover{background-color:rgb(var(--color-warning-50) / .5)}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.hover\:bg-white\/10:hover{background-color:rgb(var(--color-white) / .1)}.hover\:bg-white\/80:hover{background-color:rgb(var(--color-white) / .8)}.hover\:text-black:hover{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-brand:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-600) / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-700) / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-neutral-900) / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-success-600) / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-500) / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-danger-600) / var(--tw-text-opacity, 1))}.hover\:text-sky-600:hover{--tw-text-opacity: 1;color:rgb(var(--color-brand-600) / var(--tw-text-opacity, 1))}.hover\:text-slate-700:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.hover\:text-slate-900:hover{--tw-text-opacity: 1;color:rgb(var(--color-slate-900) / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(var(--color-white) / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: var(--shadow-lg);--tw-shadow-colored: var(--shadow-lg);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:border-sky-400:focus{--tw-border-opacity: 1;border-color:rgb(var(--color-brand-400) / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-brand:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand) / var(--tw-ring-opacity, 1))}.focus\:ring-sky-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(var(--color-brand-100) / var(--tw-ring-opacity, 1))}.active\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:bg-red-400:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-danger-400) / var(--tw-bg-opacity, 1))}.disabled\:bg-slate-300:disabled{--tw-bg-opacity: 1;background-color:rgb(var(--color-slate-300) / var(--tw-bg-opacity, 1))}.disabled\:opacity-25:disabled{opacity:.25}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.disabled\:opacity-70:disabled{opacity:.7}.disabled\:shadow-none:disabled{--tw-shadow: var(--shadow-none);--tw-shadow-colored: var(--shadow-none);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.group:focus-within .group-focus-within\:text-black{--tw-text-opacity: 1;color:rgb(var(--color-black) / var(--tw-text-opacity, 1))}.group:focus-within .group-focus-within\:text-brand{--tw-text-opacity: 1;color:rgb(var(--color-brand) / var(--tw-text-opacity, 1))}.group:hover .group-hover\:translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-105{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:bg-white{--tw-bg-opacity: 1;background-color:rgb(var(--color-white) / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-slate-700{--tw-text-opacity: 1;color:rgb(var(--color-slate-700) / var(--tw-text-opacity, 1))}.group:hover .group-hover\:opacity-100{opacity:1}@media(min-width:640px){.sm\:w-48{width:12rem}.sm\:w-56{width:14rem}.sm\:w-64{width:16rem}.sm\:w-72{width:18rem}.sm\:max-w-sm{max-width:24rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:grid-cols-\[1fr_180px\]{grid-template-columns:1fr 180px}.sm\:flex-row{flex-direction:row}.sm\:flex-wrap{flex-wrap:wrap}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-8{gap:2rem}}@media(min-width:768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:col-span-3{grid-column:span 3 / span 3}.md\:col-span-full{grid-column:1 / -1}.md\:w-auto{width:auto}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1\.4fr_110px_40px\]{grid-template-columns:1.4fr 110px 40px}.md\:grid-cols-\[180px_1fr\]{grid-template-columns:180px 1fr}.md\:grid-cols-\[1fr_1fr_1\.4fr_110px_40px\]{grid-template-columns:1fr 1fr 1.4fr 110px 40px}.md\:flex-row{flex-direction:row}.md\:items-end{align-items:flex-end}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:border-l{border-left-width:1px}.md\:border-t-0{border-top-width:0px}.md\:p-12{padding:3rem}.md\:p-6{padding:1.5rem}.md\:pl-6{padding-left:1.5rem}.md\:pt-0{padding-top:0}}@media(min-width:1024px){.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[320px_1fr\]{grid-template-columns:320px 1fr}.lg\:flex-row{flex-direction:row}.lg\:items-center{align-items:center}}@media(min-width:1280px){.xl\:w-36{width:9rem}.xl\:w-52{width:13rem}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-\[minmax\(270px\,0\.72fr\)_minmax\(0\,1\.28fr\)\]{grid-template-columns:minmax(270px,.72fr) minmax(0,1.28fr)}.xl\:flex-row{flex-direction:row}.xl\:items-end{align-items:flex-end}.xl\:items-center{align-items:center}.xl\:justify-between{justify-content:space-between}}@media(min-width:1536px){.\32xl\:grid-cols-\[360px_1fr\]{grid-template-columns:360px 1fr}} diff --git a/internal/webui/static/assets/index-DhAArJzx.js b/internal/webui/static/assets/index-DhAArJzx.js deleted file mode 100644 index b9314ee..0000000 --- a/internal/webui/static/assets/index-DhAArJzx.js +++ /dev/null @@ -1,19 +0,0 @@ -import{j as e,r,b as Me,c as xa,d as Fa}from"./react-vendor-C_od1ZSF.js";import{L as Ba,U as ma,M as rs,C as ns,B as pa,S as ua,Z as is,a as jt,b as bs,c as fs,d as ys,e as za,f as at,A as Ls,D as Ua,g as Os,P as ha,h as Tt,E as ga,T as Wa,i as Ja,j as Ee,X as Te,k as Va,l as Qa,m as js,n as ba,o as Ge,Q as Zt,p as xt,q as Qe,r as yt,s as Et,t as Is,R as Be,u as fa,v as Ga,w as Je,K as Ka,x as dt,y as st,z as Ye,F as As,G as Nt,H as _t,I as $t,J as ya,N as Ha,O as Rs,V as Ps,W as Za,Y as Ya,_ as Xa,$ as el,a0 as Yt,a1 as qt,a2 as os,a3 as tl,a4 as sl,a5 as cs,a6 as $s,a7 as al,a8 as ll,a9 as Dt,aa as Es,ab as Vt,ac as ja,ad as rl,ae as nl,af as Kt,ag as _a,ah as il,ai as ol,aj as cl,ak as dl,al as xl,am as ml,an as Ds}from"./icons-vendor-DF3hof7q.js";import{R as Ft,B as pl,X as Ts,Y as Ms,T as Bt,a as ul,C as Xt,A as hl,b as gl,c as bl,P as qs,d as Fs,L as fl}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))o(x);new MutationObserver(x=>{for(const v of x)if(v.type==="childList")for(const k of v.addedNodes)k.tagName==="LINK"&&k.rel==="modulepreload"&&o(k)}).observe(document,{childList:!0,subtree:!0});function l(x){const v={};return x.integrity&&(v.integrity=x.integrity),x.referrerPolicy&&(v.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?v.credentials="include":x.crossOrigin==="anonymous"?v.credentials="omit":v.credentials="same-origin",v}function o(x){if(x.ep)return;x.ep=!0;const v=l(x);fetch(x.href,v)}})();const yl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ds=({sizeClass:t="w-12 h-12",logoClassName:s="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),e.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:e.jsx(yl,{className:s})})]})]}),jl=({activeTab:t,isAdmin:s=!1,collapsed:l,onToggleCollapsed:o,onNavigate:x,onLogout:v})=>{const k=[{id:"dashboard",icon:Ba,label:"仪表盘"},{id:"accounts",icon:ma,label:"账号管理"},{id:"chat",icon:rs,label:"在线聊天"},{id:"cards",icon:ns,label:"卡密库存"},{id:"items",icon:pa,label:"商品列表"},{id:"orders",icon:ua,label:"订单管理"},{id:"rules",icon:is,label:"自动化规则"},{id:"notifications",icon:jt,label:"通知设置"},...s?[{id:"settings",icon:bs,label:"系统与AI"}]:[]];return e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${l?"w-16":"w-64"}`,children:[e.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${l?"justify-center px-2":"gap-3 px-5"}`,children:[e.jsx(ds,{sizeClass:"h-10 w-10"}),!l&&e.jsxs("div",{className:"min-w-0 leading-tight",children:[e.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),e.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),e.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto py-5 ${l?"px-2":"px-3"}`,"aria-label":"主导航",children:k.map(A=>{const b=A.icon,O=t===A.id;return e.jsxs("button",{type:"button",title:l?A.label:void 0,"aria-label":A.label,"aria-current":O?"page":void 0,onClick:()=>x(A.id),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${l?"justify-center":"gap-3 px-3.5"} ${O?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[e.jsx(b,{className:`h-[19px] w-[19px] shrink-0 ${O?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),!l&&e.jsx("span",{className:"truncate text-sm font-bold",children:A.label}),O&&!l&&e.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]},A.id)})}),e.jsxs("div",{className:`space-y-2 border-t border-slate-100 p-2 ${l?"":"p-3"}`,children:[e.jsxs("button",{type:"button",onClick:o,title:l?"展开侧边栏":"收起侧边栏","aria-label":l?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${l?"justify-center":"gap-3 px-3"}`,children:[l?e.jsx(fs,{className:"h-5 w-5"}):e.jsx(ys,{className:"h-5 w-5"}),!l&&e.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),e.jsxs("button",{type:"button",onClick:v,title:l?"退出登录":void 0,"aria-label":"退出登录",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${l?"justify-center":"gap-3 px-3"}`,children:[e.jsx(za,{className:"h-5 w-5"}),!l&&e.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})},_l=3e4,Nl=10*6e4;let es=!1;const Na=()=>{es||typeof window>"u"||(es=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{es=!1}))},vl=t=>{if(!t)return"";const s=new URLSearchParams;for(const[o,x]of Object.entries(t))x!=null&&s.set(o,String(x));const l=s.toString();return l?`?${l}`:""},Ht=async(t,s,l={})=>{var O;const o=vl(l.params),x=`${s}${o}`,v=va(l.signal,l.timeoutMs??_l);let k;try{k=await fetch(x,{method:t,credentials:"include",signal:v.signal,headers:{...l.body===void 0?{}:{"Content-Type":"application/json"}},body:l.body===void 0?void 0:JSON.stringify(l.body)})}catch(j){throw v.signal.aborted?new Error((O=l.signal)!=null&&O.aborted?"请求已取消":"请求超时,请稍后重试"):j}finally{v.cleanup()}const b=(k.headers.get("content-type")||"").includes("application/json");if(!k.ok){k.status===401&&!l.skipAuthLogout&&Na();const j=b?await k.json().catch(()=>{}):await k.text().catch(()=>{}),V=typeof j=="string"?j:(j==null?void 0:j.detail)||(j==null?void 0:j.message)||(j==null?void 0:j.msg);throw new Error(V||`请求失败: ${k.status}`)}return b?await k.json():await k.text()},Ie=async(t,s,l)=>Ht("GET",t,{params:s,...l}),Oe=async(t,s,l)=>Ht("POST",t,{body:s,...l}),Fe=async(t,s,l)=>Ht("PUT",t,{body:s,...l}),Ke=async(t,s,l)=>Ht("DELETE",t,{params:s,...l}),wt=async(t,s,l={})=>{var b;const o=va(l.signal,l.timeoutMs??Nl);let x;try{x=await fetch(t,{method:"POST",credentials:"include",signal:o.signal,body:s})}catch(O){throw o.signal.aborted?new Error((b=l.signal)!=null&&b.aborted?"请求已取消":"上传超时,请稍后重试"):O}finally{o.cleanup()}const A=(x.headers.get("content-type")||"").includes("application/json")?await x.json().catch(()=>{}):await x.text().catch(()=>{});if(!x.ok){x.status===401&&Na();const O=typeof A=="string"?A:(A==null?void 0:A.detail)||(A==null?void 0:A.message)||(A==null?void 0:A.msg),j=new Error(O||"请求失败: "+x.status);throw j.payload=A,j}return A},va=(t,s)=>{const l=new AbortController,o=()=>l.abort(t==null?void 0:t.reason);t!=null&&t.aborted?o():t==null||t.addEventListener("abort",o,{once:!0});const x=globalThis.setTimeout(()=>l.abort(new DOMException("timeout","TimeoutError")),Math.max(1,s));return{signal:l.signal,cleanup:()=>{globalThis.clearTimeout(x),t==null||t.removeEventListener("abort",o)}}},Qt=t=>{const s=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${s}-${l}-${o}`},_s=(t,s)=>{const l=new Date(t);return l.setHours(12,0,0,0),l.setDate(l.getDate()+s),l},xs=(t,s)=>({startDate:Qt(_s(t,-(s-1))),endDate:Qt(t)}),Bs=(t,s=new Date,l="",o="")=>{if(t==="custom"&&l&&o){if(l>o)throw new Error("开始日期不能晚于结束日期");return{startDate:l,endDate:o}}return t==="yesterday"?xs(_s(s,-1),1):xs(s,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},wl=t=>{const s=new Date(`${t.startDate}T12:00:00`),l=new Date(`${t.endDate}T12:00:00`),o=Math.round((l.getTime()-s.getTime())/864e5)+1,x=_s(s,-1);return xs(x,o)},kl=t=>{const s={...t};if("renewal_log_retention_days"in s){const l=Number(s.renewal_log_retention_days);s.renewal_log_retention_days=Number.isFinite(l)?l:10}return s},Cl=async t=>Oe("/login",t,{skipAuthLogout:!0}),Sl=async t=>Oe("/initialize",{password:t},{skipAuthLogout:!0}),wa=async()=>Ie("/verify"),Ll=async()=>Oe("/logout",{}),Ol=async t=>Fe("/account/credentials",t),Il=(t,s)=>{const l=t.avatar_url||"";if(!l)return"";try{const o=new URL(l,window.location.origin);return o.hostname.endsWith("alicdn.com")&&o.searchParams.set("_v",s),o.toString()}catch{return l}},Mt=async t=>{const s=await Ie("/cookies/details",void 0,t),l=Date.now().toString();return s.map(o=>({id:o.id,value:"",cookie:"",enabled:o.enabled,auto_confirm:o.auto_confirm,remark:o.remark,note:o.remark,pause_duration:o.pause_duration,paused_until:Number(o.paused_until||0),paused:o.paused===!0,username:o.username||"",login_password:"",show_browser:o.show_browser===!0||o.show_browser===1||o.show_browser==="1"||o.show_browser==="true",nickname:o.nickname||o.remark||`账号 ${o.id.substring(0,6)}`,avatar_url:Il(o,l),profile_error:o.profile_error||"",ai_enabled:!1,auto_rate_enabled:o.auto_rate_enabled===!0||o.auto_rate_enabled===1,rate_content:o.rate_content||"不错的买家,交易愉快",auto_polish_enabled:o.auto_polish_enabled===!0||o.auto_polish_enabled===1,polish_time:o.polish_time||"03:00",last_rate_scan_at:Number(o.last_rate_scan_at||0),last_polish_date:o.last_polish_date||"",last_polish_at:Number(o.last_polish_at||0)}))},Al=async t=>Ie(`/api/account-tasks/${t}`),zs=async(t,s)=>Fe(`/api/account-tasks/${t}`,s),Rl=async(t,s)=>Oe(`/api/account-tasks/${t}/run`,{task_type:s},{timeoutMs:12e4}),ts=async(t,s,l,o=!1)=>{const x=await Ie("/api/chat/sessions",{account_id:t,cursor:s,refresh:o?1:void 0},o?{timeoutMs:6e4,...l}:l);return{sessions:x.sessions||[],has_more:x.has_more===!0,next_cursor:x.next_cursor}},ms=async(t,s,l,o,x)=>{const v=await Ie("/api/chat/messages",{account_id:t,chat_id:s,cursor:l,before_id:o},x);return{messages:v.messages||[],has_more:v.has_more===!0,next_cursor:v.next_cursor,session:v.session}},Pl=async(t,s,l,o)=>(await ms(t,s,void 0,l,o)).messages,$l=async t=>Oe("/api/chat/messages",t),El=async t=>{const s=new FormData;return Object.entries(t).forEach(([l,o])=>s.append(l,o)),wt("/api/chat/images",s,{timeoutMs:12e4})},Us=async(t,s)=>Oe("/api/chat/read",{account_id:t,chat_id:s}),ps=async t=>Ie("/cookies/runtime-status",void 0,t),Dl=async t=>Oe("/qr-login/generate",void 0,t),Tl=async(t,s)=>Ie(`/qr-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),Ml=async(t,s)=>Oe(`/qr-login/complete-verification/${t}`,{target_account_id:s||""}),ql=async(t,s)=>Fe(`/cookies/${t}/status`,{enabled:s}),Fl=async t=>Ke(`/cookies/${t}`),Bl=async(t,s)=>Fe(`/cookies/${t}/pause-duration`,{pause_duration:s}),zl=async(t,s)=>Fe(`/cookies/${t}/settings`,s),Ul=async t=>Ie(`/cookies/${t}/long-login`),Wl=async(t,s)=>Fe(`/cookies/${t}/long-login`,{enabled:s}),Jl=async t=>Oe("/password-login",t),Vl=async(t,s)=>Ie(`/password-login/check/${t}`,void 0,{signal:s,timeoutMs:1e4}),Ql=async t=>Ke(`/password-login/cancel/${t}`),Gl=async t=>Oe(`/cookies/${t}/refresh-profile`,{}),Kl=async t=>Ie("/ai-reply-settings",void 0,t),ka=t=>{const s=String(t||"");return s==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(s)?s:"unknown"},Hl=async(t,s,l=1,o=20,x)=>{const v={page:l,page_size:o};t&&(v.cookie_id=t),s&&s!=="all"&&(v.status=s),x!=null&&x.trim()&&(v.search=x.trim());const k=await Ie("/api/orders",v),b=(k.orders||k.data||[]).map(O=>({...O,id:O.id||O.order_id,status:ka(O.status||O.order_status),quantity:Number(O.quantity||1)}));return{success:!0,data:b,total:k.total||b.length,page:k.page||l,page_size:k.page_size||o,total_pages:k.total_pages||1}},Zl=async(t,s)=>Fe(`/api/orders/${t}`,s),Yl=async t=>Ke(`/api/orders/${t}`),Xl=async(t,s)=>{const l=new FormData;return t&&l.append("cookie_id",t),s&&l.append("status",s),wt("/api/orders/refresh",l)},er=async t=>Oe(`/api/orders/${t}/refresh`),tr=async(t,s)=>Oe("/api/orders/manual-ship",{order_ids:t,ship_mode:s}),sr=async t=>t instanceof FormData?wt("/api/orders/import",t):Oe("/api/orders/import",t),ar=async()=>Ie("/dashboard/stats"),Ws=async(t=7)=>{let s;if(typeof t=="number"){const l=new Date,o=new Date;o.setDate(o.getDate()-t),s={start_date:Qt(o),end_date:Qt(l)}}else s=t;return Ie("/analytics/orders",{...s,timezone_offset_minutes:-new Date().getTimezoneOffset()})},lr=async t=>{const s=await Ie("/analytics/orders/valid",{start_date:t.start_date,end_date:t.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()}),o=(Array.isArray(s)?s:s.orders||[]).map(x=>({...x,id:x.id||x.order_id,status:ka(x.status||x.order_status),quantity:Number(x.quantity||1)}));return{orders:o,total:Array.isArray(s)?o.length:Number(s.total??o.length),truncated:Array.isArray(s)?!1:s.truncated===!0}},rr=t=>{let s=t.api_config;if(typeof s=="string"&&s.trim())try{s=JSON.parse(s)}catch{s=void 0}return{...t,api_config:s||void 0}},Ca=t=>({...t,api_config:t.api_config?JSON.stringify(t.api_config):""}),Ze=async()=>{const t=await Ie("/cards");return(Array.isArray(t)?t:t.cards||[]).map(rr)},nr=async t=>Oe("/cards",Ca(t)),Js=async(t,s)=>Fe(`/cards/${t}`,Ca(s)),ir=async t=>Ke(`/cards/${t}`),or=async t=>{const s=new FormData;return s.append("file",t),wt("/cards/batch",s)},cr=async(t,s)=>Oe(`/cards/${t}/append-data`,{content:s}),ss=t=>t===!0||t===1||t==="1",vt=async t=>{const s=await Ie("/items",void 0);return(Array.isArray(s)?s:s.items||[]).map(o=>({...o,id:o.id||`${o.cookie_id}-${o.item_id}`,is_multi_spec:ss(o.is_multi_spec),is_multi_qty_ship:ss(o.is_multi_qty_ship??o.multi_quantity_delivery),multi_quantity_delivery:ss(o.multi_quantity_delivery??o.is_multi_qty_ship)}))},dr=async t=>Oe("/items/get-all-from-account",{cookie_id:t}),xr=async(t,s)=>Ke(`/items/${t}/${s}`),mr=async(t,s)=>Oe(`/items/${t}`,s),pr=async t=>{const s=new FormData;s.set("cookie_id",t.cookie_id),s.set("title",t.title),s.set("description",t.description),s.set("price",t.price),s.set("original_price",t.original_price||""),s.set("quantity",String(t.quantity)),s.set("postage_mode",t.postage_mode),s.set("postage",t.postage||""),t.location&&s.set("location",JSON.stringify(t.location));for(const l of t.images)s.append("images",l);return wt("/items/publish",s)},ur=async(t,s)=>Oe("/items/publish-categories/recommend",{cookie_id:t,keyword:s}),hr=async t=>{const s=new FormData;return s.set("file",t.file),t.imagesZip&&s.set("images_zip",t.imagesZip),t.defaultCookieId&&s.set("default_cookie_id",t.defaultCookieId),s.set("fallback_category_id",t.fallbackCategory.catId),s.set("fallback_category_name",t.fallbackCategory.catName),s.set("fallback_channel_category_id",t.fallbackCategory.channelCatId||""),s.set("fallback_tb_category_id",t.fallbackCategory.tbCatId||""),t.location&&s.set("location",JSON.stringify(t.location)),wt("/items/publish-batches/preview",s)},gr=async t=>Oe("/items/publish-batches",{preview_id:t}),bt=async t=>Ie(`/items/publish-batches/${t}`),Vs=async(t=20)=>{const s=await Ie("/items/publish-batches",{limit:t});return Array.isArray(s)?s:s.batches||[]},br=async t=>Ke(`/items/publish-batches/${t}`),fr=async t=>Oe(`/items/publish-batches/${t}/cancel`,{}),yr=async t=>Oe(`/items/publish-batches/${t}/retry-failed`,{}),jr=async(t,s,l)=>Fe(`/items/${t}/${s}`,l),Sa=t=>t.map(s=>{var l,o;return{id:String(s.id),name:s.name||"",trigger_type:s.trigger_type||"order_paid",item_keyword:s.item_title||s.item_id||"",cookie_id:s.cookie_id||"",item_id:s.item_id||"",item_title:s.item_title||"",card_group_id:Number(((l=(s.actions||[]).find(x=>x.action_type==="send_card"))==null?void 0:l.card_id)||0),card_group_name:((o=(s.actions||[]).find(x=>x.action_type==="send_card"))==null?void 0:o.card_name)||"",priority:s.priority||100,enabled:s.enabled||!1,config_json:s.config_json||"{}",actions:(s.actions||[]).map(x=>({id:x.id?String(x.id):void 0,action_type:x.action_type,card_id:Number(x.card_id||0),card_name:x.card_name||"",delivery_count:Number(x.delivery_count||1),message_template:x.message_template||"",delay_seconds:Number(x.delay_seconds||0),config_json:x.config_json||"{}",enabled:x.enabled!==!1,sort_order:Number(x.sort_order||0)})),variants:(s.actions||[]).filter(x=>x.action_type==="send_card").map(x=>{let v={};try{v=JSON.parse(x.config_json||"{}")}catch{}return{id:x.id?String(x.id):void 0,spec_name:v.spec_name||"",spec_value:v.spec_value||"",card_id:Number(x.card_id||0),card_name:x.card_name||"",delivery_count:Number(x.delivery_count||1),enabled:x.enabled!==!1,delay_override:v.delay_override===!0,delay_seconds:Number(x.delay_seconds||0),config_json:x.config_json||"{}"}})}}),us=async()=>{const t=await Ie("/automation-rules"),s=Array.isArray(t)?t:t.data||t.rules||[];return Sa(s)},_r=async({cookieId:t,triggerType:s,enabled:l,search:o,page:x=1,pageSize:v=10}={})=>{const k=await Ie("/automation-rules",{page:x,page_size:v,cookie_id:t||void 0,trigger_type:s||void 0,enabled:l,search:(o==null?void 0:o.trim())||void 0}),A=Sa(Array.isArray(k)?k:k.data||k.rules||[]);return{success:!0,data:A,total:Number(k.total??A.length),page:Number(k.page??x),page_size:Number(k.page_size??v),total_pages:Number(k.total_pages??(A.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(k.trigger_counts||{}).map(([b,O])=>[b,Number(O)]))}},Nr=(t,s)=>{if(t!=="order_paid")return s.map((x,v)=>({...x,sort_order:x.sort_order||v+1}));const l=s.filter(x=>x.action_type==="send_card").map((x,v)=>({...x,sort_order:v+1})),o=s.filter(x=>x.action_type!=="send_card"&&x.action_type!=="confirm_shipment");return[...l,...o.map((x,v)=>({...x,sort_order:l.length+v+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:l.length+o.length+1}]},Qs=async t=>{const s=t.trigger_type||"order_paid",o=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[s]||"自动化规则",t.item_title||t.item_id||t.cookie_id||""].filter(Boolean).join(" - "),x=(t.actions||[]).filter(b=>b.action_type!=="send_card"&&b.action_type!=="confirm_shipment"),v=t.variants&&t.variants.length>0?[...t.variants.map((b,O)=>({action_type:"send_card",card_id:b.card_id,delivery_count:b.delivery_count||1,enabled:b.enabled!==!1,sort_order:O+1,delay_seconds:b.delay_seconds||0,config_json:JSON.stringify({spec_name:b.spec_name||"",spec_value:b.spec_value||"",delay_override:b.delay_override===!0})})),...x]:t.actions&&t.actions.length>0?t.actions:[{action_type:"send_card",card_id:t.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],k=Nr(s,v),A={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||o||"自动化规则",trigger_type:s,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:k.map((b,O)=>({action_type:b.action_type,card_id:b.card_id||0,delivery_count:b.delivery_count||1,message_template:b.message_template||"",delay_seconds:b.delay_seconds||0,config_json:b.config_json||"{}",enabled:b.enabled!==!1,sort_order:b.sort_order||O+1}))};return t.id?Fe(`/automation-rules/${t.id}`,A):Oe("/automation-rules",A)},vr=async t=>Ke(`/automation-rules/${t}`),wr=async()=>{const t=await Ie("/automation-issues");return{runs:Array.isArray(t==null?void 0:t.runs)?t.runs:[],pending_tasks:Array.isArray(t==null?void 0:t.pending_tasks)?t.pending_tasks:[]}},kr=async(t,s)=>Oe(`/automation-runs/${t}/resolve`,{resolution:s}),Cr=async(t,s)=>Oe(`/automation-pending-tasks/${t}/resolve`,{resolution:s}),Sr=t=>({id:String((t==null?void 0:t.id)||""),keyword:(t==null?void 0:t.keyword)||"",reply:(t==null?void 0:t.reply)||"",item_id:(t==null?void 0:t.item_id)||"",type:(t==null?void 0:t.type)==="image"?"image":"text",image_url:(t==null?void 0:t.image_url)||""}),Lr=async t=>{const s=await Ie(`/keywords-with-type/${t}`);return Array.isArray(s)?s.map(Sr):[]},Or=async t=>t?(await Lr(t)).map(l=>({id:l.id,keyword:l.keyword||"",reply_content:l.reply||"",match_type:"fuzzy",enabled:!0,item_id:l.item_id||"",type:l.type==="image"?"image":"text",image_url:l.image_url||""})):[],Ir=async(t,s)=>{const l=t.type||"text",o={keyword:t.keyword||"",reply:l==="text"&&t.reply_content||"",item_id:t.item_id||"",type:l,image_url:l==="image"&&t.image_url||""};return t.id?Fe(`/keywords-with-type/${s}/${t.id}`,o):Oe(`/keywords-with-item-id/${s}`,o)},Ar=async(t,s)=>Ke(`/keywords-with-type/${s}/${t}`),La=async()=>{const t=await Ie("/system-settings");return kl(t.data||t)},Oa=async t=>{const s=Object.fromEntries(Object.entries(t).filter(([,l])=>l!=null));return Fe("/system-settings",s)},Rr=async(t,s)=>Ie(`/ai-reply-settings/${t}`,void 0,s),Pr=async(t,s)=>{const l={ai_enabled:s.ai_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return Fe(`/ai-reply-settings/${t}`,l)},$r=async(t,s="")=>(await Oe("/ai-models",{base_url:t,api_key:s})).models||[],Er=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const s=JSON.parse(t);if(Array.isArray(s))return s.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},Ia=t=>{const s=Array.from(new Set((t||[]).filter(Boolean)));return s.length>0?JSON.stringify(s):""},Aa=async t=>({success:!0,data:(await Ie("/notification-channels",void 0,t)||[]).map(o=>{let x;try{x=typeof o.config=="string"?JSON.parse(o.config):o.config}catch{x={}}return{id:String(o.id),name:o.name,type:o.type==="ding_talk"?"dingtalk":o.type==="lark"?"feishu":o.type,config:x,event_types:Er(o.event_types),enabled:o.enabled,created_at:o.created_at,updated_at:o.updated_at}})}),Dr=async t=>Oe("/notification-channels",{...t,config:JSON.stringify(t.config),event_types:Ia(t.event_types)}),Gs=async(t,s)=>{const l={...s};return"config"in s&&(l.config=JSON.stringify(s.config)),"event_types"in s&&(l.event_types=Ia(s.event_types)),Fe(`/notification-channels/${t}`,l)},Tr=async t=>Ke(`/notification-channels/${t}`),Mr=async(t,s)=>{const l=await Ie(`/message-notifications/${t}`,void 0,s);return(l==null?void 0:l.channel_ids)||[]},qr=async t=>Oe(`/notification-channels/${t}/test`,{}),Ks=async()=>Ie("/api/default-replies"),Fr=async t=>{const s=await Ie(`/api/default-reply/${t}`);return{cookie_id:t,enabled:s.enabled||!1,reply_content:s.reply_content||"",reply_once:s.reply_once||!1,reply_image_url:s.reply_image_url||""}},Br=async(t,s)=>Fe(`/api/default-reply/${t}`,{enabled:s.enabled??!1,reply_content:s.reply_content||"",reply_once:s.reply_once??!1,reply_image_url:s.reply_image_url||""}),zr=async t=>Ke(`/api/default-reply/${t}`),Ur=async t=>Oe(`/api/default-reply/${t}/clear-records`,{}),Ot=t=>String(t).padStart(2,"0"),hs=t=>{if(t==null||t==="")return"-";const s=t instanceof Date?t:new Date(t);return Number.isNaN(s.getTime())?"-":[s.getFullYear(),Ot(s.getMonth()+1),Ot(s.getDate())].join("-")+" "+[Ot(s.getHours()),Ot(s.getMinutes()),Ot(s.getSeconds())].join(":")},_e=(t,s)=>s===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${s})`,Wr=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`inline-flex items-center justify-center whitespace-nowrap px-3 py-1.5 rounded-lg text-xs leading-none font-bold ${s[t]||s.cancelled}`,children:l[t]||t})},zt=({title:t,value:s,icon:l,colorClass:o,trend:x})=>e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col justify-between hover:translate-y-[-4px] transition-all duration-300 h-full relative overflow-hidden group border-0",children:[e.jsx("div",{className:`absolute -right-6 -top-6 w-32 h-32 ${o} opacity-10 rounded-full group-hover:scale-125 transition-transform duration-500 blur-2xl`}),e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsx("div",{className:`p-4 rounded-2xl ${o} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(l,{className:`w-6 h-6 ${o.replace("bg-","text-")}`})}),x&&e.jsxs("span",{className:"text-xs font-bold text-white bg-brand px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(Wa,{className:"w-3 h-3"})," ",x]})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h3",{className:"text-3xl font-extrabold text-gray-900 tracking-tight font-feature-settings-tnum",children:s}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),as=()=>{var S,Q;const[t,s]=r.useState(null),[l,o]=r.useState(null),[x,v]=r.useState(""),[k,A]=r.useState("7days"),[b,O]=r.useState(""),[j,V]=r.useState(""),[Y,pe]=r.useState(null),[ce,w]=r.useState(""),[M,de]=r.useState([]),[G,X]=r.useState(0),[U,fe]=r.useState(!1),[ge,L]=r.useState(!1),[K,ae]=r.useState([]),[Z,me]=r.useState({}),R=r.useRef(0),E=[_e("brand"),_e("brand-highlight"),_e("success-500"),_e("warning-500"),_e("accent-500")],ee=u=>`¥${Number(u||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`,T=async u=>{let d;try{d=Bs(u,new Date,b,j)}catch(Re){v(Re instanceof Error?Re.message:"日期范围无效");return}const{startDate:F,endDate:I}=d,H={start_date:F,end_date:I},P=wl(d),Ce=++R.current;L(!0),v("");try{const[Re,xe,Pe]=await Promise.all([Ws(H),Ws({start_date:P.startDate,end_date:P.endDate}),lr(H)]);if(Ce!==R.current)return;o(Re),pe(xe),de(Pe.orders),X(Pe.total),fe(Pe.truncated)}catch(Re){Ce===R.current&&v(Re instanceof Error?Re.message:"经营数据加载失败")}finally{Ce===R.current&&L(!1)}},se=()=>{if(!l||!Y)return null;const u=l.revenue_stats.total_amount,d=Y.revenue_stats.total_amount;if(d===0)return u>0?"+100%":"0%";const F=(u-d)/d*100;return`${F>=0?"+":""}${F.toFixed(1)}%`};if(r.useEffect(()=>{let u=!1;return Promise.all([ar(),vt()]).then(([d,F])=>{if(u)return;s(d),ae(F);const I={};F.forEach(H=>{I[H.item_id]=H.item_title||H.item_id}),me(I)}).catch(d=>{u||v(d instanceof Error?d.message:"概览加载失败")}),()=>{u=!0}},[]),r.useEffect(()=>{k!=="custom"&&T(k)},[k]),x&&(!t||!l))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(at,{className:"w-8 h-8"}),e.jsx("span",{children:x}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:()=>window.location.reload(),children:"重新加载"})]});if(!t||!l)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx(Ls,{className:"w-8 h-8 animate-spin text-brand"})});const ke=((S=l.daily_stats)==null?void 0:S.map(u=>({name:u.date.slice(5),amount:u.amount,orders:u.order_count,avgAmount:u.order_count>0?(u.amount/u.order_count).toFixed(2):0})))||[],ye=l.item_stats||[],z=l.revenue_stats.total_orders||0,m=l.revenue_stats.total_amount||0,f=ye.length>0?ye.map(u=>({name:(Z[u.item_id]||u.item_id).length>12?(Z[u.item_id]||u.item_id).substring(0,12)+"...":Z[u.item_id]||u.item_id,sales:u.order_count})).sort((u,d)=>d.sales-u.sales).slice(0,10):[],W=Math.max(...f.map(u=>u.sales),1),q=ye.length>0?ye.map(u=>({name:(Z[u.item_id]||u.item_id).length>10?(Z[u.item_id]||u.item_id).substring(0,10)+"...":Z[u.item_id]||u.item_id,value:u.order_count,percent:z>0?u.order_count/z*100:0})).sort((u,d)=>d.value-u.value).slice(0,6).map((u,d)=>({...u,color:E[d%E.length]})):[],ne=ye.length>0?ye.map(u=>({name:(Z[u.item_id]||u.item_id).length>12?(Z[u.item_id]||u.item_id).substring(0,12)+"...":Z[u.item_id]||u.item_id,value:u.total_amount,orderCount:u.order_count,percentage:m>0?u.total_amount/m*100:0})).sort((u,d)=>d.value-u.value).slice(0,5).map((u,d)=>({...u,color:E[d%E.length],percentage:u.percentage.toFixed(1)})):[],be=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],ve=((Q=be.find(u=>u.key===k))==null?void 0:Q.label)||"所选范围";let De;try{De=Bs(k,new Date,b,j)}catch{De={startDate:b,endDate:j}}const Ne=ce.trim().toLowerCase(),c=M.filter(u=>{var d,F,I,H;return((d=u.order_id)==null?void 0:d.toLowerCase().includes(Ne))||((F=u.item_id)==null?void 0:F.toLowerCase().includes(Ne))||((I=u.item_title)==null?void 0:I.toLowerCase().includes(Ne))||((H=u.buyer_id)==null?void 0:H.toLowerCase().includes(Ne))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"运营概览"}),e.jsx("p",{className:"text-gray-500 mt-2 text-base",children:"欢迎回来,以下是闲鱼店铺的实时经营数据。"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-sm font-bold text-gray-700 bg-white px-5 py-2.5 rounded-full shadow-sm border border-gray-100 flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-green-500 rounded-full animate-pulse"}),"系统正常运行"]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[be.map(u=>e.jsx("button",{onClick:()=>A(u.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${k===u.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:u.label},u.key)),k==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:b,onChange:u=>O(u.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:j,onChange:u=>V(u.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("button",{onClick:()=>{try{v(""),T("custom")}catch(u){v(u instanceof Error?u.message:"日期范围无效")}},className:"px-4 py-2 rounded-xl text-sm font-bold bg-black text-white hover:bg-gray-800 transition-colors",children:"应用"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsx(zt,{title:"累计营收 (CNY)",value:`¥${l.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:Ua,colorClass:"bg-blue-400",trend:se()||void 0}),e.jsx(zt,{title:"活跃账号 / 总数",value:`${t.active_cookies} / ${t.total_cookies}`,icon:ma,colorClass:"bg-blue-500"}),e.jsx(zt,{title:"订单数",value:l.revenue_stats.total_orders.toLocaleString(),icon:Os,colorClass:"bg-blue-500"}),e.jsx(zt,{title:"库存卡密余量",value:t.available_card_stock,icon:ha,colorClass:"bg-purple-500"})]}),e.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[ve,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:ke.length===0||l.revenue_stats.total_amount===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(Os,{className:"w-16 h-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),e.jsx("p",{className:"text-sm mt-2",children:"所选时间范围内暂无订单记录"})]}):ke.length<=2?e.jsx(Ft,{width:"100%",height:"100%",children:e.jsxs(pl,{data:ke,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(Ts,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:_e("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(Ms,{axisLine:!1,tickLine:!1,tick:{fill:_e("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:u=>`¥${u}`}),e.jsx(Bt,{contentStyle:{backgroundColor:_e("white"),borderRadius:"8px",border:`1px solid ${_e("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:_e("neutral-500"),fontWeight:500},itemStyle:{color:_e("brand"),fontWeight:600},cursor:{fill:_e("brand",.08)},formatter:u=>[`¥${Number(u).toFixed(2)}`,"营收"]}),e.jsx(ul,{dataKey:"amount",fill:_e("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:ke.map((u,d)=>e.jsx(Xt,{fill:_e("brand"),stroke:"none",strokeWidth:0},`cell-${d}`))})]})}):e.jsx(Ft,{width:"100%",height:"100%",children:e.jsxs(hl,{data:ke,margin:{top:10,right:10,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:_e("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:_e("brand"),stopOpacity:0})]})}),e.jsx(Ts,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:_e("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(Ms,{axisLine:!1,tickLine:!1,tick:{fill:_e("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(gl,{vertical:!1,stroke:_e("neutral-100"),strokeDasharray:"3 3"}),e.jsx(Bt,{contentStyle:{backgroundColor:_e("white"),borderRadius:"8px",border:`1px solid ${_e("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:_e("neutral-500"),fontWeight:500},itemStyle:{color:_e("brand"),fontWeight:600},cursor:{stroke:_e("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(bl,{type:"monotone",dataKey:"amount",stroke:_e("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:_e("white"),stroke:_e("brand"),strokeWidth:2}})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品销量排行"}),e.jsx("div",{className:"h-[280px]",children:f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx("div",{className:"h-full space-y-4 overflow-y-auto pr-2",children:f.map((u,d)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${d<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:d+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:u.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[u.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,u.sales/W*100)}%`}})})]},`${u.name}-${d}`))})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),e.jsx("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${z} 单`,children:q.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(Ft,{width:"100%",height:"100%",children:e.jsxs(qs,{accessibilityLayer:!1,children:[e.jsx(Fs,{data:q,cx:"50%",cy:"45%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:96,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:q.map((u,d)=>e.jsx(Xt,{fill:u.color},`cell-${d}`))}),e.jsx(Bt,{formatter:u=>`${Number(u||0)} 单`,wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:_e("white"),border:`1px solid ${_e("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(fl,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:u=>e.jsx("span",{style:{color:_e("neutral-500"),fontWeight:500},children:u})})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center pb-9",children:[e.jsx("span",{className:"text-2xl font-extrabold text-gray-900 tabular-nums",children:z}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总订单"})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 ios-card p-0 rounded-xl border-0 bg-white overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b border-gray-50 flex justify-between items-center bg-surface-muted",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),U&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",M.length," / ",G," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:ce,onChange:u=>w(u.target.value),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),e.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:ge?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx(Ls,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:e.jsx(Tt,{className:"w-7 h-7 text-gray-300"})}),Ne?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"没有匹配的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-md",children:["当前共有 ",M.length," 单参与统计,但没有订单号、商品、买家匹配“",ce,"”。"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"当前范围内没有参与统计的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-lg leading-6",children:["日期范围:",De.startDate," 至 ",De.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",l.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full min-w-[760px] text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-4",children:"订单信息"}),e.jsx("th",{className:"px-6 py-4",children:"买家信息"}),e.jsx("th",{className:"px-6 py-4",children:"金额"}),e.jsx("th",{className:"px-6 py-4 whitespace-nowrap",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:c.map(u=>e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:e.jsx(Tt,{className:"w-full h-full text-gray-300 p-2"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:u.item_title||u.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:u.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",u.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:u.buyer_id}),u.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:hs(u.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",u.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(Wr,{status:u.status||u.order_status||"unknown"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${u.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(ga,{className:"w-4 h-4"})})})]},u.order_id))})]})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),ne.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品金额分析,总金额 ${ee(m)}`,children:[e.jsx(Ft,{width:"100%",height:"100%",children:e.jsxs(qs,{accessibilityLayer:!1,children:[e.jsx(Fs,{data:ne,cx:"50%",cy:"50%",innerRadius:60,outerRadius:92,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:98,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:ne.map((u,d)=>e.jsx(Xt,{fill:u.color||E[d%E.length]},`cell-${d}`))}),e.jsx(Bt,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:_e("white"),border:`1px solid ${_e("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:u=>`¥${Number(u||0).toLocaleString()}`})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-lg font-extrabold text-gray-900 tabular-nums",children:ee(m)}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总金额"})]})]}),e.jsx("div",{className:"space-y-3 mt-4",children:ne.map(u=>e.jsxs("div",{className:"flex justify-between items-center gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:u.color||E[ne.indexOf(u)%E.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:u.name,children:u.name})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 whitespace-nowrap",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",u.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[u.percentage,"%"]})]})]},u.name))})]})]})]})]})},Jr=(t,s)=>{const l=s.pause_duration||0;return t!==l},Vr=(t,s)=>{const l=s.username!==(t.username||""),o=s.show_browser!==(t.show_browser||!1),x=s.login_password!=="",v=s.clear_password===!0;if(!l&&!o&&!x&&!v)return null;const k={username:s.username,show_browser:s.show_browser};return v?k.clear_password=!0:x&&(k.login_password=s.login_password),k},Qr=(t,s)=>t&&s,Gr=(t,s)=>{if(!t||!s)return!1;const l=Date.parse(t),o=Date.parse(s);return Number.isFinite(l)&&Number.isFinite(o)&&ot.map(l=>{const o=s[l.id];return!o||Gr(l.runtime_updated_at,o.updated_at)?l:{...l,runtime_state:o.state,runtime_message:o.message||"",runtime_connected:o.connected,runtime_updated_at:o.updated_at}}),Hr=new Set(["expired","cancelled","error","not_found"]),Ut=()=>{let t=0;return{next:()=>(t+=1,t),cancel:()=>{t+=1},isCurrent:s=>s===t}},Zr=(t={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let s=null,l=null,o=-1,x=0;const v=()=>{x+=1,l==null||l.abort(),l=null,s!==null&&(t.clearInterval(s),s=null)};return{start:(A,b,O,j=2e3)=>{v();const V=x;l=new AbortController;const Y=l.signal;s=t.setInterval(()=>{o===V||V!==x||(o=V,(async()=>{var pe,ce;try{const w=await b(A,Y);if(w.status==="success"){v(),await O.onSuccess(w);return}if(w.status==="scanned"){(pe=O.onScanned)==null||pe.call(O,w);return}if(w.status==="verification_required"){(ce=O.onVerificationRequired)==null||ce.call(O,w);return}w.status&&Hr.has(w.status)&&(v(),O.onTerminalError(w))}catch(w){if(Y.aborted||V!==x)return;v(),O.onPollError(w)}finally{o===V&&(o=-1)}})())},j)},stop:v,isActive:()=>s!==null}},Yr=({faceQrUrl:t,verificationScreenshot:s})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(Ja,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:t?e.jsx("img",{src:t,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):s?e.jsx("img",{src:s,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx(Ee,{className:"h-6 w-6 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-bold",children:"正在准备风控二维码…"})]})}),e.jsx("p",{className:"mx-auto mt-2 max-w-[15rem] break-words text-[11px] leading-4 text-gray-500",children:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),Hs=({src:t,alt:s,className:l=""})=>e.jsx("img",{src:t,alt:s,className:`block aspect-square h-auto w-full object-contain ${l}`.trim()}),Zs=({checked:t,onChange:s,label:l})=>e.jsx("button",{type:"button","aria-label":l,"aria-pressed":t,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),Xr=({account:t,onClose:s,onSaved:l})=>{const[o,x]=r.useState({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),[v,k]=r.useState(!1),[A,b]=r.useState(""),[O,j]=r.useState(""),[V,Y]=r.useState(null),pe=async()=>{k(!0),j("");try{const w=await zs(t.id,o);x(w),l(w)}catch(w){j(w instanceof Error?w.message:"保存失败")}finally{k(!1)}},ce=async w=>{b(w),j(""),Y(null);try{await zs(t.id,o);const M=await Rl(t.id,w),de=await Al(t.id);Y(M.summary),x(de),l(de)}catch(M){j(M instanceof Error?M.message:"任务执行失败")}finally{b("")}};return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(Te,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(Va,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(Zs,{checked:o.auto_rate_enabled,onChange:()=>x(w=>({...w,auto_rate_enabled:!w.auto_rate_enabled})),label:"自动评价"})]}),e.jsx("label",{className:"mt-4 block text-xs font-extrabold text-slate-600",children:"统一好评文案"}),e.jsx("textarea",{"aria-label":"统一好评文案",value:o.rate_content,maxLength:500,onChange:w=>x(M=>({...M,rate_content:w.target.value})),className:"mt-2 h-24 w-full resize-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm leading-6 text-slate-800 placeholder:text-slate-400 outline-none focus:border-sky-400 focus:ring-2 focus:ring-sky-100"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:["最近扫描:",o.last_rate_scan_at?new Date(o.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:A!==""||!t.enabled,onClick:()=>void ce("auto_rate"),className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-extrabold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50",children:[A==="auto_rate"?e.jsx(Ee,{className:"h-4 w-4 animate-spin"}):e.jsx(Qa,{className:"h-4 w-4"}),"立即评价"]})]})]})]})}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-50 text-amber-600",children:e.jsx(js,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"每日自动擦亮"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"每个账号每天最多执行一次,按北京时间判断。"})]}),e.jsx(Zs,{checked:o.auto_polish_enabled,onChange:()=>x(w=>({...w,auto_polish_enabled:!w.auto_polish_enabled})),label:"每日自动擦亮"})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-extrabold text-slate-600",children:"每日执行时间"}),e.jsx("input",{type:"time",value:o.polish_time,onChange:w=>x(M=>({...M,polish_time:w.target.value})),className:"mt-2 block rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-bold text-slate-800 outline-none focus:border-sky-400"})]}),e.jsxs("button",{type:"button",disabled:A!==""||!t.enabled,onClick:()=>void ce("auto_polish"),className:"flex items-center gap-2 rounded-xl bg-amber-50 px-3 py-2 text-xs font-extrabold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:[A==="auto_polish"?e.jsx(Ee,{className:"h-4 w-4 animate-spin"}):e.jsx(ba,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",o.last_polish_at?new Date(o.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),V&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",V.found," 项,成功 ",V.success,",失败 ",V.failed,",跳过 ",V.skipped,"。",V.message||""]}),O&&e.jsx("div",{className:"rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:O})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:s,disabled:v||A!=="",className:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-bold text-gray-700 transition-colors hover:bg-gray-200 disabled:opacity-50",children:"关闭"}),e.jsxs("button",{type:"button",onClick:()=>void pe(),disabled:v||A!==""||o.auto_rate_enabled&&!o.rate_content.trim(),className:"ios-btn-primary flex flex-1 items-center justify-center gap-2 rounded-xl px-6 py-3 font-bold disabled:opacity-50",children:[v?e.jsx(Ee,{className:"h-4 w-4 animate-spin"}):e.jsx(Ge,{className:"h-4 w-4"}),"保存"]})]})})]})})},en=()=>{const[t,s]=r.useState([]),[l,o]=r.useState(!0),[x,v]=r.useState(""),[k,A]=r.useState(""),[b,O]=r.useState(""),[j,V]=r.useState(null),[Y,pe]=r.useState(""),[ce,w]=r.useState(!1),[M,de]=r.useState(""),[G,X]=r.useState("pending"),[U,fe]=r.useState(""),[ge,L]=r.useState(""),[K,ae]=r.useState(null),[Z,me]=r.useState(null),[R,E]=r.useState(null),[ee,T]=r.useState(null),[se,ke]=r.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[ye,z]=r.useState([]),[m,f]=r.useState([]),[W,q]=r.useState(!1),[ne,be]=r.useState(!1),[ve,De]=r.useState(!1),[Ne,c]=r.useState(""),[S,Q]=r.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),[u,d]=r.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[F,I]=r.useState(!1),[H,P]=r.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),Ce=r.useRef(null),Re=r.useRef(null),xe=r.useRef(null),Pe=r.useRef(null),le=r.useRef(null),g=r.useRef(null),y=r.useRef(null),D=r.useRef(null),J=r.useRef(null),Se=r.useRef(null),$e=r.useRef(null),Le=r.useRef(null),Ae=r.useRef(0);Ce.current===null&&(Ce.current=Zr()),Re.current===null&&(Re.current=Ut()),xe.current===null&&(xe.current=Ut()),Pe.current===null&&(Pe.current=Ut()),le.current===null&&(le.current=Ut());const te=()=>{$e.current!==null&&(window.clearTimeout($e.current),$e.current=null)},je=()=>{Le.current!==null&&(window.clearTimeout(Le.current),Le.current=null)},p=()=>{var i;(i=Ce.current)==null||i.stop()},$=()=>{var i,N;(i=J.current)==null||i.abort(),(N=Re.current)==null||N.cancel(),p(),te(),w(!1)},ie=()=>{te(),$e.current=window.setTimeout(()=>{$e.current=null,w(!1),re()},1e3)},re=async()=>{var a,h,_,B,oe;const i=xe.current.next();(a=g.current)==null||a.abort();const N=new AbortController;g.current=N,o(!0);try{const ue={signal:N.signal},[he,qe]=await Promise.allSettled([Mt(ue),Kl(ue)]);if(!((h=xe.current)!=null&&h.isCurrent(i)))return;if(he.status==="rejected")throw he.reason;const we=he.value,ot=qe.status==="fulfilled"?qe.value:{};qe.status==="rejected"&&console.error("Failed to load AI settings:",qe.reason);const qa=we.map(gt=>{var vs,ws,ks,Cs,Ss;return{...gt,ai_enabled:((vs=ot[gt.id])==null?void 0:vs.ai_enabled)??!1,max_discount_percent:((ws=ot[gt.id])==null?void 0:ws.max_discount_percent)??10,max_discount_amount:((ks=ot[gt.id])==null?void 0:ks.max_discount_amount)??100,max_bargain_rounds:((Cs=ot[gt.id])==null?void 0:Cs.max_bargain_rounds)??3,custom_prompts:((Ss=ot[gt.id])==null?void 0:Ss.custom_prompts)??""}});(_=xe.current)!=null&&_.isCurrent(i)&&s(qa)}catch(ue){(B=xe.current)!=null&&B.isCurrent(i)&&!N.signal.aborted&&console.error("Failed to load accounts:",ue)}finally{(oe=xe.current)!=null&&oe.isCurrent(i)&&o(!1)}};r.useEffect(()=>{let i=!1,N=null;const a=new AbortController,h=async()=>{try{const _=await ps({signal:a.signal,timeoutMs:1e4});i||s(B=>Kr(B,_))}catch(_){i||console.error("Failed to load account runtime statuses:",_)}finally{i||(N=window.setTimeout(()=>void h(),2e3))}};return re().finally(()=>{i||h()}),()=>{i=!0,a.abort(),N!==null&&window.clearTimeout(N)}},[]),r.useEffect(()=>()=>{var i,N,a,h,_,B,oe,ue,he;p(),(i=Re.current)==null||i.cancel(),(N=xe.current)==null||N.cancel(),(a=Pe.current)==null||a.cancel(),(h=le.current)==null||h.cancel(),(_=g.current)==null||_.abort(),(B=y.current)==null||B.abort(),(oe=D.current)==null||oe.abort(),(ue=J.current)==null||ue.abort(),(he=Se.current)==null||he.abort(),te(),Ae.current+=1,je()},[]);const ze=i=>{if(!i.enabled||i.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(i.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},He=async(i,N)=>{await ql(i,!N),re()},Xe=i=>{b||(pe(""),V(i))},mt=()=>{b||(pe(""),V(null))},Ue=async()=>{const i=j;if(!(!i||b)){O(i.id),pe("");try{await Fl(i.id),s(N=>N.filter(a=>a.id!==i.id)),V(null)}catch(N){console.error("删除账号失败:",N),pe((N==null?void 0:N.message)||"删除账号失败,请稍后重试")}finally{O("")}}},We=async i=>{A(i.id);try{const N=await Gl(i.id);N!=null&&N.profile_error&&alert("资料刷新失败:"+N.profile_error),await re()}catch(N){console.error("刷新账号资料失败:",N),alert((N==null?void 0:N.message)||"刷新账号资料失败,请先重新授权该账号")}finally{A("")}},pt=async i=>{var B,oe;const N=Pe.current.next();(B=y.current)==null||B.abort();const a=new AbortController;y.current=a,be(!0),q(!1),De(!1),c("");const[h,_]=await Promise.allSettled([Aa({signal:a.signal}),Mr(i,{signal:a.signal})]);(oe=Pe.current)!=null&&oe.isCurrent(N)&&(h.status==="fulfilled"?z(h.value.data||[]):(z([]),c("通知渠道列表加载失败,请重试")),_.status==="fulfilled"?(f(_.value||[]),q(!0)):(f([]),c("通知绑定加载失败;本次保存不会修改现有绑定")),be(!1))},kt=async i=>{var a;Ae.current+=1,(a=Se.current)==null||a.abort(),je(),P({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),E(i),Q({remark:i.remark||i.note||"",cookie:i.cookie||i.value||"",auto_confirm:i.auto_confirm||!1,pause_duration:i.pause_duration||0,username:i.username||"",login_password:i.login_password||"",show_browser:i.show_browser||!1,showLoginPassword:!1,clear_password:!1}),me("edit"),ke({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,N]=await Promise.allSettled([pt(i.id),Ul(i.id)]);N.status==="fulfilled"?ke({loading:!1,saving:!1,canOpen:N.value.can_open_long_login,enabled:N.value.enabled,error:""}):ke({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"})},Ct=async()=>{if(!R||se.loading||se.saving||!se.canOpen)return;const i=!se.enabled;ke(N=>({...N,saving:!0,error:""}));try{const N=await Wl(R.id,i);ke({loading:!1,saving:!1,canOpen:N.can_open_long_login,enabled:N.enabled,error:""})}catch(N){ke(a=>({...a,saving:!1,error:N instanceof Error?N.message:"保存登录信息设置失败"}))}},St=async i=>{var h,_,B,oe;const N=le.current.next();(h=D.current)==null||h.abort();const a=new AbortController;D.current=a,E(i),me("ai-settings"),I(!0);try{const ue=await Rr(i.id,{signal:a.signal});if(!((_=le.current)!=null&&_.isCurrent(N)))return;d({ai_enabled:ue.ai_enabled??!1,max_discount_percent:ue.max_discount_percent??10,max_discount_amount:ue.max_discount_amount??100,max_bargain_rounds:ue.max_bargain_rounds??3,custom_prompts:ue.custom_prompts??""})}catch(ue){(B=le.current)!=null&&B.isCurrent(N)&&console.error("Failed to load AI settings:",ue)}finally{(oe=le.current)!=null&&oe.isCurrent(N)&&I(!1)}},lt=async()=>{if(R){I(!0);try{const i={};S.remark!==(R.remark||R.note||"")&&(i.remark=S.remark),S.cookie&&S.cookie!==(R.cookie||R.value||"")&&(i.cookie=S.cookie),S.auto_confirm!==R.auto_confirm&&(i.auto_confirm=S.auto_confirm),Jr(S.pause_duration,R)&&(i.pause_duration=S.pause_duration);const N=Vr(R,S);N&&Object.assign(i,N),Qr(W,ve)&&(i.channel_ids=m),Object.keys(i).length>0&&await zl(R.id,i),me(null),re()}catch(i){console.error("更新账号失败:",i),alert("更新失败,请重试")}finally{I(!1)}}},rt=async()=>{if(!(!R||S.pause_duration<=0)){I(!0);try{const i=await Bl(R.id,S.pause_duration);E({...R,pause_duration:S.pause_duration,paused:(i==null?void 0:i.paused)===!0,paused_until:Number((i==null?void 0:i.paused_until)||0)}),await re()}catch(i){alert(i instanceof Error?i.message:"重新暂停失败")}finally{I(!1)}}},Lt=async()=>{if(R){I(!0);try{await Pr(R.id,u),me(null),re()}catch(i){console.error("更新AI设置失败:",i),alert("更新失败,请重试")}finally{I(!1)}}},nt=async(i,N)=>{var h;(h=Se.current)==null||h.abort();const a=new AbortController;Se.current=a;try{const _=await Vl(i,a.signal);if(N!==Ae.current)return;if(_.status==="success"){je(),P({sessionId:i,status:"success",message:_.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}),Q(B=>({...B,login_password:"",showLoginPassword:!1})),await re();return}if(_.status==="processing"||_.status==="verification_required"){P({sessionId:i,status:_.status,message:_.message||(_.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:_.qr_code_url||""}),je(),Le.current=window.setTimeout(()=>void nt(i,N),1500);return}je(),P({sessionId:i,status:"failed",message:_.error||_.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""})}catch(_){if(N!==Ae.current)return;je(),P({sessionId:i,status:"failed",message:_ instanceof Error?_.message:"查询密码登录状态失败",qrCodeUrl:""})}},ut=async()=>{var a;if(!R)return;const i=S.username.trim();if(!i||!S.login_password){alert("请先填写登录账号和本次登录密码");return}je(),(a=Se.current)==null||a.abort();const N=++Ae.current;P({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const h=await Jl({account_id:R.id,account:i,password:S.login_password,show_browser:S.show_browser});if(N!==Ae.current)return;if(!h.success||!h.session_id)throw new Error(h.message||"无法启动密码登录");P({sessionId:h.session_id,status:"processing",message:h.message||"登录处理中",qrCodeUrl:""}),await nt(h.session_id,N)}catch(h){if(N!==Ae.current)return;P({sessionId:"",status:"failed",message:h instanceof Error?h.message:"启动密码登录失败",qrCodeUrl:""})}},et=async()=>{var N;const i=H.sessionId;if(Ae.current+=1,(N=Se.current)==null||N.abort(),je(),i)try{await Ql(i)}catch(a){console.error("取消密码登录失败",a)}P({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},it=async()=>{var i,N;(i=Pe.current)==null||i.cancel(),(N=y.current)==null||N.abort(),(H.status==="processing"||H.status==="verification_required")&&await et(),me(null)},Ve=()=>{var i,N;(i=le.current)==null||i.cancel(),(N=D.current)==null||N.abort(),me(null)},ht=async(i,N)=>{const a=await Ml(i,N==null?void 0:N.id);if(!a.success||!a.account_id)throw new Error(a.message||"保存扫码授权失败");return a.account_id},n=async i=>{var _,B,oe,ue;p(),(_=J.current)==null||_.abort();const N=new AbortController;J.current=N;const a=Re.current.next();te();const h=i||null;ae(h),w(!0),X("loading"),de(""),fe(""),L("");try{const he=await Dl({signal:N.signal});if(!((B=Re.current)!=null&&B.isCurrent(a)))return;if(he.success&&he.qr_code_url&&he.session_id){const qe=he.session_id;de(he.qr_code_url),X("waiting"),(oe=Ce.current)==null||oe.start(qe,Tl,{onSuccess:async()=>{try{if(!await ht(qe,h)){X("error");return}}catch(we){console.error("保存扫码授权失败",we),X("error");return}X("success"),ie()},onScanned:()=>{X("waiting")},onTerminalError:()=>{X("error")},onPollError:we=>{console.error("轮询扫码状态失败",we),X("error")},onVerificationRequired:we=>{X("verification"),we.face_qr_url&&L(we.face_qr_url),we.verification_screenshot&&fe(we.verification_screenshot)}})}}catch{if(!((ue=Re.current)!=null&&ue.isCurrent(a)))return;X("error")}};if(l)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(Ee,{className:"w-8 h-8 text-brand animate-spin"})});const C=t.filter(i=>{const N=x.trim().toLowerCase();return N?[i.id,i.nickname,i.remark,i.note,i.username,i.runtime_message].some(a=>(a||"").toLowerCase().includes(N)):!0});return e.jsxs("div",{className:"space-y-8 animate-fade-in relative",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"账号管理"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("input",{value:x,onChange:i=>v(i.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>n(),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(Zt,{className:"w-5 h-5"}),"扫码添加新账号"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 px-5 py-4 text-sm text-blue-900 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[e.jsxs("div",{className:"font-bold",children:["当前显示 ",C.length," / ",t.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[C.map(i=>{const N=ze(i),a=i.runtime_state==="auth_expired"||i.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:e.jsx(xt,{className:"w-9 h-9"})}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${N.dot}`,children:i.runtime_state==="online"&&e.jsx(Qe,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:i.nickname||i.remark||`账号 ${i.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${N.badge}`,children:N.label}),i.ai_enabled&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[e.jsx(yt,{className:"w-3 h-3"})," AI"]}),i.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx(Et,{className:"h-3 w-3"})," 自动评价"]}),i.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(js,{className:"h-3 w-3"})," 每日擦亮"]}),i.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(Qe,{className:"h-3 w-3"})," 自动确认发货"]}),i.profile_error&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:i.profile_error,children:[e.jsx(at,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-500",children:[e.jsx("p",{children:i.remark||i.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",i.id]})]}),i.runtime_message&&i.runtime_state!=="online"&&i.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${a?"text-red-700":"text-amber-700"}`,children:[e.jsx(at,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:i.runtime_message}),a&&e.jsxs("button",{type:"button",onClick:()=>n(i),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(Zt,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),i.paused&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700",children:[e.jsx(Is,{className:"h-3 w-3"})," 暂停处理中"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>We(i),disabled:k===i.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(Be,{className:`w-5 h-5 ${k===i.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>n(i),className:`p-3 rounded-xl transition-colors ${a?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(Zt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>kt(i),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(fa,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>St(i),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(yt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>T(i),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(ba,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>He(i.id,i.enabled),className:`p-3 rounded-xl transition-colors ${i.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:i.enabled?"停用账号":"启用账号",children:e.jsx(Ga,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Xe(i),disabled:b!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:b===i.id?"删除中…":`删除账号 ${i.nickname||i.remark||i.id}`,children:b===i.id?e.jsx(Ee,{className:"w-5 h-5 animate-spin"}):e.jsx(Je,{className:"w-5 h-5"})})]})]})]})]})},i.id)}),t.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(xt,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),t.length>0&&C.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"没有匹配的账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"换一个关键词搜索昵称、备注或账号ID。"})]})]}),ee&&Me.createPortal(e.jsx(Xr,{account:ee,onClose:()=>T(null),onSaved:i=>{s(N=>N.map(a=>a.id===ee.id?{...a,auto_rate_enabled:i.auto_rate_enabled,rate_content:i.rate_content,auto_polish_enabled:i.auto_polish_enabled,polish_time:i.polish_time,last_rate_scan_at:i.last_rate_scan_at,last_polish_date:i.last_polish_date,last_polish_at:i.last_polish_at}:a))}}),document.body),j&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",role:"presentation",children:e.jsxs("div",{className:"h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-modal",role:"dialog","aria-modal":"true","aria-labelledby":"delete-account-title","aria-describedby":"delete-account-description",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5",children:[e.jsx("div",{className:"absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl"}),e.jsxs("div",{className:"relative flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200",children:e.jsx(Je,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{id:"delete-account-title",className:"text-lg font-extrabold tracking-tight text-gray-950",children:"删除这个账号?"}),e.jsx("p",{id:"delete-account-description",className:"mt-1 text-xs leading-5 text-gray-600",children:"删除后,该账号的关联配置也会一并清理,此操作无法撤销。"})]}),e.jsx("button",{type:"button",onClick:mt,disabled:b!=="",className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"关闭删除确认",children:e.jsx(Te,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:j.nickname||j.remark||"未命名账号"}),j.remark&&j.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",j.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",j.id]})]}),b===j.id&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3",role:"progressbar","aria-label":"正在删除账号",children:[e.jsx(Ee,{className:"h-5 w-5 flex-shrink-0 animate-spin text-brand"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-blue-950",children:"正在删除账号"}),e.jsx("div",{className:"mt-0.5 text-xs text-blue-700",children:"正在清理关联数据,请保持页面打开…"})]})]}),Y&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3",role:"alert",children:[e.jsx(at,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-red-800",children:"删除失败"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-red-700",children:Y})]})]})]}),e.jsxs("div",{className:"flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4",children:[e.jsx("button",{type:"button",onClick:mt,disabled:b!=="",className:"flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:"取消"}),e.jsx("button",{type:"button",onClick:()=>void Ue(),disabled:b!=="",className:"flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400",children:b===j.id?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),ce&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:$,className:"absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:K?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:K?`请用闲鱼APP扫码,为「${K.nickname||K.remark||K.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${G==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[G==="loading"&&e.jsx(Ee,{className:"w-10 h-10 text-brand animate-spin"}),G==="waiting"&&e.jsx(Hs,{src:M,alt:"闲鱼登录二维码",className:"p-2"}),G==="success"&&e.jsxs("div",{className:"absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(Qe,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),G==="error"&&e.jsxs("div",{className:"px-5 text-center",children:[e.jsx("span",{className:"block text-red-600 font-bold",children:"二维码获取失败"}),e.jsx("span",{className:"mt-2 block text-xs leading-5 text-gray-500",children:"请关闭窗口后重新发起扫码登录。"})]}),G==="verification"&&e.jsx(Yr,{faceQrUrl:ge,verificationScreenshot:U})]}),G!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),Z==="edit"&&R&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑账号"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:R.nickname||R.remark||R.id})]}),e.jsx("button",{onClick:()=>void it(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"账号ID"}),e.jsx("input",{type:"text",value:R.id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注"}),e.jsx("input",{type:"text",value:S.remark,onChange:i=>Q({...S,remark:i.target.value}),placeholder:"为账号添加备注",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"Cookie"}),e.jsx("textarea",{value:S.cookie,onChange:i=>Q({...S,cookie:i.target.value}),placeholder:"更新账号Cookie",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none font-mono text-xs"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["当前Cookie长度: ",S.cookie.length," 字符"]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:()=>Q({...S,auto_confirm:!S.auto_confirm}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${S.auto_confirm?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${S.auto_confirm?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2 flex items-center gap-2",children:[e.jsx(Is,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:S.pause_duration,onChange:i=>Q({...S,pause_duration:parseInt(i.target.value)||0}),placeholder:"0",min:"0",max:"1440",className:"w-full ios-input px-4 py-3 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),S.pause_duration>0&&!R.paused&&S.pause_duration===(R.pause_duration||0)&&e.jsx("button",{type:"button",disabled:F,onClick:()=>void rt(),className:"mt-3 px-4 py-2 rounded-xl bg-amber-50 text-amber-700 hover:bg-amber-100 text-sm font-bold disabled:opacity-50",children:"立即按当前时长重新暂停"})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(Ka,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"保存登录信息"}),e.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"状态直接读取并修改闲鱼官方长登录设置"}),se.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:se.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:se.loading||se.saving||!se.canOpen,onClick:()=>void Ct(),className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${se.enabled?"bg-brand":"bg-gray-300"} disabled:cursor-not-allowed disabled:opacity-50`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${se.enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"用户名"}),e.jsx("input",{type:"text",value:S.username,onChange:i=>Q({...S,username:i.target.value}),placeholder:"闲鱼账号/手机号",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"登录密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:S.showLoginPassword?"text":"password",value:S.login_password,onChange:i=>Q({...S,login_password:i.target.value,clear_password:!1}),placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:()=>Q({...S,showLoginPassword:!S.showLoginPassword}),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:S.showLoginPassword?e.jsx(dt,{className:"w-5 h-5"}):e.jsx(st,{className:"w-5 h-5"})})]}),e.jsxs("label",{className:"mt-3 flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:S.clear_password,onChange:i=>Q({...S,clear_password:i.target.checked,login_password:i.target.checked?"":S.login_password}),className:"w-4 h-4 accent-brand"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:"清空已保存密码"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"登录时显示浏览器"}),e.jsx("div",{className:"text-xs text-gray-500",children:"调试时可开启查看登录过程"})]}),e.jsx("button",{type:"button",onClick:()=>Q({...S,show_browser:!S.show_browser}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${S.show_browser?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${S.show_browser?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-blue-950",children:"立即执行账号密码登录"}),e.jsx("div",{className:"text-xs text-blue-700 mt-1",children:"需要在上方重新输入本次登录密码;成功后后端会更新 Cookie 和保存的登录信息。"})]}),H.status==="processing"||H.status==="verification_required"?e.jsx("button",{type:"button",onClick:et,className:"px-4 py-2 rounded-xl bg-white text-red-600 font-bold text-sm border border-red-100",children:"取消登录"}):e.jsx("button",{type:"button",onClick:ut,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),H.message&&e.jsx("div",{className:`text-sm font-medium ${H.status==="failed"?"text-red-700":H.status==="success"?"text-green-700":"text-blue-800"}`,children:H.message}),H.status==="verification_required"&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsx("div",{className:"font-extrabold",children:"账号已触发平台风控,需要完成人脸识别"}),e.jsx("div",{className:"text-xs mt-1 leading-5",children:"请在闲鱼 App 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),H.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(Hs,{src:H.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(ye.length>0||ne||Ne)&&e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-1 flex items-center gap-2",children:[e.jsx(jt,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),ne&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Ee,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),Ne&&!ne&&e.jsxs("div",{className:"mb-3 rounded-xl bg-amber-50 p-3 text-sm text-amber-800 flex items-center justify-between gap-3",children:[e.jsx("span",{children:Ne}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:()=>pt(R.id),children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:ye.map(i=>{const N=m.includes(Number(i.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:()=>{W&&(f(a=>N?a.filter(h=>h!==Number(i.id)):[...a,Number(i.id)]),De(!0))},disabled:!W,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${N?"bg-brand border-brand":"bg-white border-gray-300"}`,children:N&&e.jsx(Qe,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:i.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[i.type,i.enabled?"":" · 已停用"]})]})]},i.id)})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>void it(),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:F,children:"取消"}),e.jsxs("button",{onClick:lt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:F,children:[F?e.jsx(Ee,{className:"w-4 h-4 animate-spin"}):e.jsx(Ge,{className:"w-4 h-4"}),F?"保存中...":"保存"]})]})})]})}),document.body),Z==="ai-settings"&&R&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-2xl font-extrabold text-gray-900 flex items-center gap-2",children:[e.jsx(yt,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:R.nickname||R.remark||R.id})]}),e.jsx("button",{onClick:Ve,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-purple-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(yt,{className:"w-4 h-4 text-purple-500"}),"启用AI自动回复"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"AI将自动处理买家的砍价消息"})]}),e.jsx("button",{type:"button",onClick:()=>d({...u,ai_enabled:!u.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${u.ai_enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${u.ai_enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"砍价策略"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣比例 (%)"}),e.jsx("input",{type:"number",value:u.max_discount_percent,onChange:i=>d({...u,max_discount_percent:parseInt(i.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"100"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:10 表示最多降价 10%;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣金额 (元)"}),e.jsx("input",{type:"number",value:u.max_discount_amount,onChange:i=>d({...u,max_discount_amount:parseInt(i.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:100 表示最多降价 100 元;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大砍价轮次"}),e.jsx("input",{type:"number",value:u.max_bargain_rounds,onChange:i=>d({...u,max_bargain_rounds:parseInt(i.target.value)||1}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"10"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"买家最多可以砍价的次数"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"自定义提示词(可选)"}),e.jsx("textarea",{value:u.custom_prompts,onChange:i=>d({...u,custom_prompts:i.target.value}),placeholder:`输入自定义的AI回复规则或风格指引... - -例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(bs,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Ve,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:F,children:"取消"}),e.jsxs("button",{onClick:Lt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:F,children:[F?e.jsx(Ee,{className:"w-4 h-4 animate-spin"}):e.jsx(Ge,{className:"w-4 h-4"}),F?"保存中...":"保存"]})]})})]})}),document.body)]})},tn=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(s=>({order_id:String((s==null?void 0:s.order_id)||"unknown"),success:(s==null?void 0:s.success)===!0,message:String((s==null?void 0:s.message)||"")})):[]}),sn=t=>(t==null?void 0:t.results.filter(s=>!s.success))||[],Ys=({status:t})=>{const s={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${s[t]||s.cancelled}`,children:l[t]||t})},an=()=>{const[t,s]=r.useState([]),[l,o]=r.useState([]),[x,v]=r.useState([]),[k,A]=r.useState({}),[b,O]=r.useState("all"),[j,V]=r.useState(""),[Y,pe]=r.useState(""),[ce,w]=r.useState(""),M=r.useRef(0),[de,G]=r.useState(1),[X,U]=r.useState(1),[fe,ge]=r.useState(!1),[L,K]=r.useState(!1),[ae,Z]=r.useState(!1),[me,R]=r.useState(!1),[E,ee]=r.useState(null),[T,se]=r.useState(null),[ke,ye]=r.useState({}),[z,m]=r.useState(!1),[f,W]=r.useState(""),[q,ne]=r.useState(!1),[be,ve]=r.useState(null),[De,Ne]=r.useState(null),[c,S]=r.useState(null),[Q,u]=r.useState(!1),[d,F]=r.useState(null),[I,H]=r.useState(null),P=async()=>{const p=++M.current;ge(!0);try{const $=await Hl(j||void 0,b,de,20,ce);if(p!==M.current)return;s($.data),U($.total_pages)}catch($){console.error("加载订单失败:",$)}finally{p===M.current&&ge(!1)}},Ce=(p,$,ie)=>{if(ie&&ie.trim())return ie;if(k[`${p}:${$}`])return k[`${p}:${$}`];const re=l.find(ze=>{if(ie&&ze.item_title){const He=ie.toLowerCase(),Xe=ze.item_title.toLowerCase();return Xe.includes(He)||He.includes(Xe)}return!1});return re!=null&&re.item_title?re.item_title:"未知商品"},Re=p=>{const $={};p.forEach(ie=>{ie.item_id&&($[`${ie.cookie_id}:${ie.item_id}`]=ie.item_title||ie.item_id)}),A($)};r.useEffect(()=>{const p=window.setTimeout(()=>{G(1),w(Y.trim())},300);return()=>window.clearTimeout(p)},[Y]),r.useEffect(()=>{P()},[j,b,de,ce]),r.useEffect(()=>{Promise.all([Mt(),vt()]).then(([p,$])=>{v(p),o($),Re($)}).catch(p=>{console.error("加载商品列表失败:",p)})},[]);const xe=r.useMemo(()=>new Map(x.map(p=>[p.id,p])),[x]),Pe=p=>{const $=xe.get(p),ie=($==null?void 0:$.remark)||($==null?void 0:$.nickname);return ie?`${ie} · ${p.slice(0,6)}`:`账号 ${p.slice(0,8)}`},le=p=>{const $=xe.get(p);return($==null?void 0:$.remark)||($==null?void 0:$.nickname)||"未命名账号"},g=async()=>{ge(!0);try{const p=await Xl(j||void 0,b);await P(),p!=null&&p.message&&alert(p.message)}catch(p){console.error("同步订单失败:",p),alert((p==null?void 0:p.message)||"同步失败,请重试")}finally{ge(!1)}},y=p=>{W(p),ve(null),m(!0)},D=async p=>{var $;ne(!0),ve(null);try{const ie=await tr([f],p),re=($=ie==null?void 0:ie.results)==null?void 0:$[0];re!=null&&re.success?(ve({success:!0,message:re.message}),P()):ve({success:!1,message:(re==null?void 0:re.message)||"发货失败"})}catch(ie){ve({success:!1,message:(ie==null?void 0:ie.message)||"请求失败"})}finally{ne(!1)}},J=p=>{ee(p),K(!0)},Se=p=>{se({...p}),Z(!0)},$e=async()=>{if(!(!T||!T.order_id))try{const p={};T.status!==void 0&&(p.order_status=T.status),T.buyer_id!==void 0&&(p.buyer_id=T.buyer_id),T.amount!==void 0&&(p.amount=T.amount),T.receiver_name!==void 0&&(p.receiver_name=T.receiver_name),T.receiver_phone!==void 0&&(p.receiver_phone=T.receiver_phone),T.receiver_address!==void 0&&(p.receiver_address=T.receiver_address),T.item_id!==void 0&&(p.item_id=T.item_id),T.quantity!==void 0&&(p.quantity=T.quantity),T.item_title!==void 0&&(p.item_title=T.item_title),await Zl(T.order_id,p),Z(!1),se(null),P()}catch(p){console.error("更新订单失败:",p),alert("更新失败,请重试")}},Le=async()=>{if(De){u(!0);try{const p=new FormData;p.append("file",De);const $=tn(await sr(p));S($),Ne(null),await P(),$.failed_count===0&&(R(!1),S(null),alert(`订单导入成功,共 ${$.success_count} 条`))}catch(p){alert((p==null?void 0:p.message)||"导入失败,请检查文件格式")}finally{u(!1)}}},Ae=()=>{Q||(R(!1),Ne(null),S(null))},te=async p=>{F(p);try{const $=await er(p);$.success?await P():alert($.message||"同步失败")}catch($){console.error("同步订单失败:",$),alert(($==null?void 0:$.message)||"同步失败,请重试")}finally{F(null)}},je=async p=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){H(p);try{await Yl(p),t.length===1&&de>1?G($=>$-1):await P()}catch($){console.error("删除订单失败:",$),alert(($==null?void 0:$.message)||"删除失败,请重试"),await P()}finally{H(null)}}};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:P,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:e.jsx(Be,{className:`w-5 h-5 ${fe?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{S(null),R(!0)},className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[e.jsx(Ye,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:g,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[e.jsx(As,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:[{k:"all",v:"全部"},{k:"processing",v:"处理中"},{k:"shipped",v:"已发货"},{k:"pending_ship",v:"待发货"},{k:"completed",v:"已完成"},{k:"cancelled",v:"已取消"},{k:"refunding",v:"退款中"}].map(p=>e.jsx("button",{onClick:()=>{O(p.k),G(1),pe("")},className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${b===p.k?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:p.v},p.k))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:j,onChange:p=>{V(p.target.value),G(1)},className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),x.map(p=>e.jsx("option",{value:p.id,children:Pe(p.id)},p.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Nt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:Y,onChange:p=>{pe(p.target.value),G(1)},className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]}),e.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),e.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),e.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.map(p=>e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:p.item_image?e.jsx("img",{src:p.item_image,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(Tt,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:Ce(p.cookie_id,p.item_id,p.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:le(p.cookie_id),children:[e.jsx(xt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:le(p.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",p.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",p.quantity," • ",hs(p.created_at)]})]})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),e.jsx("div",{className:"text-sm font-bold text-gray-800",children:p.buyer_id}),p.receiver_name&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),e.jsx("div",{className:"text-xs text-gray-600",children:p.receiver_name})]}),p.receiver_phone&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),e.jsx("div",{className:"text-xs text-gray-600 font-mono",children:p.receiver_phone})]}),p.receiver_address&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),e.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:p.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:p.amount?`¥${p.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(Ys,{status:p.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[p.status==="pending_ship"&&e.jsx("button",{onClick:()=>y(p.order_id),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${p.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(ga,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(p),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(st,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Se(p),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(_t,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(p.order_id),disabled:d===p.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:e.jsx(Be,{className:`w-4 h-4 ${d===p.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>je(p.order_id),disabled:I===p.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:e.jsx(Je,{className:"w-4 h-4"})})]})]},p.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",de," 页 / 共 ",X," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:de<=1,onClick:()=>G(p=>p-1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(ys,{className:"w-5 h-5"})}),e.jsx("button",{disabled:de>=X,onClick:()=>G(p=>p+1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(fs,{className:"w-5 h-5"})})]})]})]}),L&&E&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),e.jsx("button",{onClick:()=>K(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),e.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:E.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:le(E.cookie_id),children:le(E.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(Ys,{status:E.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),e.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:E.amount?`¥${E.amount}`:"待获取"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),e.jsx("div",{className:"font-bold text-gray-900",children:E.quantity})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),e.jsx("div",{className:"text-sm font-medium text-gray-700",children:hs(E.created_at)})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[E.item_image&&e.jsx("img",{src:E.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-bold text-gray-900 mb-1",children:Ce(E.cookie_id,E.item_id,E.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",E.item_id]}),E.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",E.item_price]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),e.jsx("div",{className:"font-bold text-gray-900",children:E.buyer_id})]}),E.receiver_name&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),e.jsx("div",{className:"font-medium text-gray-700",children:E.receiver_name})]}),E.receiver_phone&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),e.jsx("div",{className:"font-mono text-sm text-gray-700",children:E.receiver_phone})]}),E.receiver_address&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),e.jsx("div",{className:"text-sm text-gray-700",children:E.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>K(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),E.status==="pending_ship"&&e.jsx("button",{onClick:()=>{K(!1),y(E.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),me&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:Ae,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:p=>{var $;return Ne((($=p.target.files)==null?void 0:$[0])||null)},className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),De&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($t,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:De.name})]})}),c&&c.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",c.success_count," 条,失败 ",c.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:sn(c).map((p,$)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:p.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:p.message||"导入失败"})]},`${p.order_id}-${$}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Ae,disabled:Q,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),e.jsx("button",{onClick:Le,disabled:!De||Q,className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:Q?"正在导入…":"导入订单"})]})})]})}),document.body),z&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),e.jsx("button",{onClick:()=>{m(!1),ve(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),e.jsx("button",{onClick:()=>D("status_only"),disabled:q,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(As,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),e.jsx("button",{onClick:()=>D("full_delivery"),disabled:q,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Tt,{className:"w-5 h-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),q&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(Be,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),be&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${be.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[be.success?"✓ ":"✗ ",be.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{m(!1),ve(null)},className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:be!=null&&be.success?"完成":"取消"})})]})}),document.body),ae&&T&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),e.jsx("button",{onClick:()=>Z(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),e.jsx("input",{type:"text",value:T.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),e.jsxs("select",{value:T.status,onChange:p=>se({...T,status:p.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"processing",children:"处理中"}),e.jsx("option",{value:"pending_ship",children:"待发货"}),e.jsx("option",{value:"shipped",children:"已发货"}),e.jsx("option",{value:"completed",children:"已完成"}),e.jsx("option",{value:"cancelled",children:"已取消"}),e.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),e.jsx("input",{type:"text",value:T.buyer_id,onChange:p=>se({...T,buyer_id:p.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),e.jsx("input",{type:"number",value:T.amount,onChange:p=>se({...T,amount:p.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),e.jsx("input",{type:"text",value:T.receiver_name||"",onChange:p=>se({...T,receiver_name:p.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),e.jsx("input",{type:"text",value:T.receiver_phone||"",onChange:p=>se({...T,receiver_phone:p.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),e.jsx("textarea",{value:T.receiver_address||"",onChange:p=>se({...T,receiver_address:p.target.value}),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),e.jsx("input",{type:"text",value:T.item_title||"",onChange:p=>se({...T,item_title:p.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>Z(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:$e,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},ln=(t,s,l)=>{const o=l.trim().toLocaleLowerCase();return t.filter(x=>(!s||x.type===s)&&(!o||x.name.toLocaleLowerCase().includes(o)))},Xs=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),rn=()=>{const[t,s]=r.useState([]),[l,o]=r.useState(!1),[x,v]=r.useState(!1),[k,A]=r.useState(null),[b,O]=r.useState({}),[j,V]=r.useState(Xs),[Y,pe]=r.useState(!1),[ce,w]=r.useState("create"),[M,de]=r.useState(null),[G,X]=r.useState(null),[U,fe]=r.useState(!1),[ge,L]=r.useState(""),[K,ae]=r.useState(""),[Z,me]=r.useState(null),[R,E]=r.useState(""),[ee,T]=r.useState("");r.useEffect(()=>{Ze().then(s)},[]);const se=({type:c})=>{switch(c){case"text":return e.jsx(Rs,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Ps,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(Xa,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(ns,{className:"w-5 h-5 text-gray-500"})}},ke=c=>{var S,Q,u,d,F;A(c),O({id:c.id,name:c.name||"",type:c.type||"text",api_url:((S=c.api_config)==null?void 0:S.url)||"",api_method:((Q=c.api_config)==null?void 0:Q.method)||"GET",api_timeout:((u=c.api_config)==null?void 0:u.timeout)||10,api_headers:((d=c.api_config)==null?void 0:d.headers)||"",api_params:((F=c.api_config)==null?void 0:F.params)||"",text_content:c.text_content||"",data_content:c.data_content||"",image_url:c.image_url||"",delay_seconds:c.delay_seconds||0,description:c.description||"",enabled:c.enabled}),o(!0)},ye=async()=>{var c,S,Q,u,d,F,I,H;if(k){if(!((c=b.name)!=null&&c.trim())){alert("请输入卡密名称");return}if(!b.type){alert("请选择卡密类型");return}try{const P={name:b.name.trim(),type:b.type,description:(S=b.description)==null?void 0:S.trim(),delay_seconds:b.delay_seconds||0,enabled:b.enabled??!0};b.type==="api"?P.api_config={url:((Q=b.api_url)==null?void 0:Q.trim())||"",method:b.api_method,timeout:b.api_timeout||10,headers:((u=b.api_headers)==null?void 0:u.trim())||void 0,params:((d=b.api_params)==null?void 0:d.trim())||void 0}:b.type==="text"?P.text_content=((F=b.text_content)==null?void 0:F.trim())||"":b.type==="data"?P.data_content=((I=b.data_content)==null?void 0:I.trim())||"":b.type==="image"&&(P.image_url=((H=b.image_url)==null?void 0:H.trim())||""),await Js(k.id,P),o(!1),Ze().then(s)}catch(P){console.error("更新卡密失败:",P),alert("更新失败,请重试")}}},z=async c=>{if(confirm("确认删除该卡密吗?"))try{await ir(c),Ze().then(s)}catch(S){console.error("删除卡密失败:",S),alert("删除失败,请重试")}},m=async()=>{if(!j.name.trim()){alert("请输入卡密名称");return}if(!j.content.trim()){alert(j.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const c={name:j.name.trim(),type:j.type,description:j.description.trim(),enabled:j.enabled,delay_seconds:j.delay_seconds};j.type==="text"&&(c.text_content=j.content.trim()),j.type==="data"&&(c.data_content=j.content.trim()),j.type==="image"&&(c.image_url=j.content.trim()),j.type==="api"&&(c.api_config={url:j.content.trim(),method:j.api_method,timeout:j.api_timeout,headers:j.api_headers.trim()||void 0,params:j.api_params.trim()||void 0}),await nr(c),v(!1),V(Xs()),Ze().then(s)}catch(c){console.error("添加卡密失败:",c),alert("添加失败,请重试")}},f=async c=>{try{await Js(c.id,{...c,enabled:!c.enabled}),Ze().then(s)}catch(S){console.error("切换状态失败:",S)}},W=async c=>{try{await navigator.clipboard.writeText(String(c)),alert(`已复制卡密组ID:${c}`)}catch{prompt("复制卡密组ID",String(c))}},q=t.filter(c=>c.type==="data"),ne=r.useMemo(()=>ln(t,R,ee),[t,ee,R]),be=()=>{const Q=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 -VIP-MONTH-002 -VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(I=>I.map(H=>`"${String(H).replace(/"/g,'""')}"`).join(",")).join(` -`),u=new Blob(["\uFEFF"+Q],{type:"text/csv;charset=utf-8"}),d=URL.createObjectURL(u),F=document.createElement("a");F.href=d,F.download="卡密组批量导入模板.csv",document.body.appendChild(F),F.click(),F.remove(),URL.revokeObjectURL(d)},ve=async()=>{if(M){fe(!0),X(null);try{const c=await or(M);if(X(c),c.created>0){const S=await Ze();s(S)}}catch(c){X({error:(c==null?void 0:c.message)||"上传失败"})}finally{fe(!1)}}},De=async()=>{if(!(!ge||!K.trim())){fe(!0),me(null);try{const c=await cr(ge,K);me({added:c.added}),ae("");const S=await Ze();s(S)}catch(c){alert("追加失败:"+((c==null?void 0:c.message)||"未知错误"))}finally{fe(!1)}}},Ne=()=>{var c;w("create"),de(null),X(null),L((c=q[0])!=null&&c.id?String(q[0].id):""),ae(""),me(null),pe(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:Ne,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx($t,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>v(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(Ye,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(ya,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:R,onChange:c=>E(c.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(Nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:ee,onChange:c=>T(c.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",ne.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:ne.map(c=>{let S="";return c.type==="data"&&c.data_content?S=`库存: ${c.data_content.split(` -`).filter(u=>u.trim()).length} 条`:c.type==="text"&&c.text_content?S=c.text_content:c.type==="api"&&c.api_config?S=c.api_config.url:c.type==="image"&&c.image_url&&(S="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(se,{type:c.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:c.name,children:c.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>W(c.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:c.id}),e.jsx(Ha,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${c.type==="text"?"bg-blue-50 text-blue-600":c.type==="data"?"bg-purple-50 text-purple-600":c.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:c.type==="text"?"文本":c.type==="data"?"批量":c.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:S,children:S})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:c.description||"-",children:c.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>f(c),className:`w-12 h-8 rounded-full relative transition-colors ${c.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${c.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>ke(c),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(_t,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>z(c.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Je,{className:"h-4 w-4"})})]})})]},c.id)})})]})}),ne.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(ha,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),l&&k&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>o(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:b.name||"",onChange:c=>O({...b,name:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:b.type||"text",onChange:c=>O({...b,type:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(k==null?void 0:k.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),b.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:b.api_url||"",onChange:c=>O({...b,api_url:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求方法"}),e.jsxs("select",{value:b.api_method||"GET",onChange:c=>O({...b,api_method:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"超时时间(秒)"}),e.jsx("input",{type:"number",value:b.api_timeout||10,onChange:c=>O({...b,api_timeout:parseInt(c.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"60"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求头(JSON 格式)"}),e.jsx("textarea",{value:b.api_headers||"",onChange:c=>O({...b,api_headers:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"Authorization": "Bearer token"}'})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求参数(JSON 格式)"}),e.jsx("textarea",{value:b.api_params||"",onChange:c=>O({...b,api_params:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"type": "card", "count": 1}'})]})]}),b.type==="text"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"固定文字配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"文字内容"}),e.jsx("textarea",{value:b.text_content||"",onChange:c=>O({...b,text_content:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),b.type==="data"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"批量数据配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"数据内容(一行一个)"}),e.jsx("textarea",{value:b.data_content||"",onChange:c=>O({...b,data_content:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-80 resize-none font-mono text-sm",placeholder:`请输入数据,每行一个: -卡号1:密码1 -卡号2:密码2 -或者 -兑换码1 -兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:b.data_content?b.data_content.split(` -`).filter(c=>c.trim()).length:0})," 条"]})]})]}),b.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:b.image_url||"",onChange:c=>O({...b,image_url:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),b.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:b.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:c=>{c.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:b.delay_seconds||0,onChange:c=>O({...b,delay_seconds:parseInt(c.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:b.description||"",onChange:c=>O({...b,description:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>O({...b,enabled:!b.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${b.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${b.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>o(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:ye,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),x&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>v(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:j.name,onChange:c=>V({...j,name:c.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>V({...j,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(ns,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>V({...j,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Rs,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>V({...j,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Ps,{className:"w-5 h-5 mx-auto mb-1"}),"图片"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:j.type==="data"?"库存内容(一行一个)":j.type==="text"?"固定回复内容":j.type==="image"?"图片 URL":"API 地址"}),j.type==="api"?e.jsx("input",{type:"url",value:j.content,onChange:c=>V({...j,content:c.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):j.type==="image"?e.jsx("input",{type:"url",value:j.content,onChange:c=>V({...j,content:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:j.content,onChange:c=>V({...j,content:c.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${j.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:j.type==="data"?`CODE-123456 -CODE-789012 -...`:"请输入每次发货时发送的固定文字"}),j.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:j.content.split(` -`).filter(c=>c.trim()).length})," 条"]})]}),j.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:j.api_method,onChange:c=>V({...j,api_method:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:j.api_timeout,onChange:c=>V({...j,api_timeout:parseInt(c.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:j.api_headers,onChange:c=>V({...j,api_headers:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:j.api_params,onChange:c=>V({...j,api_params:c.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:j.description,onChange:c=>V({...j,description:c.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:j.delay_seconds,onChange:c=>V({...j,delay_seconds:parseInt(c.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>v(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:m,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),Y&&Me.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>pe(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>w("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ce==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Za,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>w("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ce==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx($t,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),ce==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:be,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[e.jsx(Ya,{className:"w-4 h-4"}),"下载模板"]}),e.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[e.jsx($t,{className:"w-4 h-4"}),M?M.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:c=>{var S;return de(((S=c.target.files)==null?void 0:S[0])||null)}})]})]}),G&&!G.error&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[e.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",G.total," 行 · 成功 ",G.created," · 失败 ",G.failed]}),G.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:G.rows.filter(c=>!c.success).map(c=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",c.row_no," 行「",c.name,"」:",c.error]},c.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:q.length===0?e.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),e.jsx("select",{value:ge,onChange:c=>L(c.target.value),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:q.map(c=>e.jsxs("option",{value:String(c.id),children:[c.name,"(ID: ",c.id,")"]},c.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),e.jsx("textarea",{value:K,onChange:c=>ae(c.target.value),placeholder:`VIP-001 -VIP-002 -VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),Z&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",Z.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>pe(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),ce==="create"?e.jsxs("button",{onClick:ve,disabled:!M||U,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[U?e.jsx(Ee,{className:"w-4 h-4 animate-spin"}):e.jsx($t,{className:"w-4 h-4"}),U?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:De,disabled:!ge||!K.trim()||U||q.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[U?e.jsx(Ee,{className:"w-4 h-4 animate-spin"}):e.jsx(Ye,{className:"w-4 h-4"}),U?"处理中...":"追加卡密"]})]})]})}),document.body)]})},nn=t=>t.find(s=>s.status==="running"||s.status==="canceling"),ea="ydisks-amap-js-api",on="c9b68d4ce9a2a97f22a4a439404488ca";let It=null;const cn=()=>on,dn=()=>window.AMap?Promise.resolve(window.AMap):It||(It=new Promise((t,s)=>{const l=document.getElementById(ea),o=l||document.createElement("script"),x=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(k)},v=()=>{window.AMap?(x(),t(window.AMap)):(x(),s(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},k=window.setTimeout(()=>{x(),s(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=v,o.id=ea,o.async=!0,o.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(cn())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,o.onerror=()=>{x(),s(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},l||document.head.appendChild(o)}).catch(t=>{throw It=null,t}),It),Gt=t=>Number.isFinite(t)&&t!==0,xn=t=>{var x,v;const s=Number((x=t.location)==null?void 0:x.lng),l=Number((v=t.location)==null?void 0:v.lat),o={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:s,latitude:l,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!o.division_id||!o.province||!o.city||!o.poi_id||!o.poi_name||!Gt(s)||!Gt(l)||s<-180||s>180||l<-90||l>90?null:o},mn=async(t,s)=>{if(!Gt(t)||!Gt(s)||t<-180||t>180||s<-90||s>90)throw new Error("经纬度无效");const l=await dn();return new Promise((o,x)=>{new l.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,s],1e3,(k,A)=>{var O;if(k!=="complete"){if(k==="no_data"){o([]);return}x(new Error("高德地图附近地址查询失败,请稍后重试"));return}const b=(((O=A==null?void 0:A.poiList)==null?void 0:O.pois)||[]).map(xn).filter(j=>j!==null);o(b)})})},pn=t=>{const s=String(t||"").trim();return s?/^[¥¥]/.test(s)?s:`¥${s}`:"-"},un=({onConfigureDelivery:t})=>{const[s,l]=r.useState([]),[o,x]=r.useState([]),[v,k]=r.useState([]),[A,b]=r.useState(""),[O,j]=r.useState(""),[V,Y]=r.useState(!1),[pe,ce]=r.useState(!1),[w,M]=r.useState(!1),[de,G]=r.useState(!1),[X,U]=r.useState(!1),[fe,ge]=r.useState(!1),[L,K]=r.useState(!1),[ae,Z]=r.useState("upload"),[me,R]=r.useState(null),[E,ee]=r.useState(null),[T,se]=r.useState(""),[ke,ye]=r.useState(!1),[z,m]=r.useState(!1),[f,W]=r.useState([]),[q,ne]=r.useState(null),[be,ve]=r.useState([]),[De,Ne]=r.useState(null),[c,S]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[Q,u]=r.useState(null),[d,F]=r.useState(null),[I,H]=r.useState(null),P=r.useRef(!1),[Ce,Re]=r.useState(null),[xe,Pe]=r.useState({}),[le,g]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[y,D]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[J,Se]=r.useState([]);r.useEffect(()=>{if(!fe||y.images.length===0){Se([]);return}const n=y.images.map((C,i)=>({key:C.name+i,url:URL.createObjectURL(C)}));return Se(n),()=>{n.forEach(C=>URL.revokeObjectURL(C.url))}},[fe,y.images]);const $e=async()=>{const n=await vt();l(n)},Le=async()=>{x(await us())};r.useEffect(()=>{Promise.all([Mt(),vt(),us(),Vs(20)]).then(([n,C,i,N])=>{k(n),l(C),x(i);const a=N.find(h=>["running","canceling"].includes(h.status))||N.find(h=>h.status!=="preview");H(a||null)}).catch(n=>console.error("加载商品配置失败:",n))},[]),r.useEffect(()=>{if(!L||!(d!=null&&d.id)||!["running","canceling"].includes(d.status))return;const n=window.setInterval(async()=>{if(!P.current){P.current=!0;try{const C=await bt(d.id);F(C),H(C),["running","canceling"].includes(C.status)||(Z("done"),await $e(),await Le())}catch(C){console.error("刷新批量铺货进度失败:",C)}finally{P.current=!1}}},3e3);return()=>{window.clearInterval(n)}},[L,d==null?void 0:d.id,d==null?void 0:d.status]);const Ae=async()=>{if(!A)return alert("请先选择账号");Y(!0);try{const n=await dr(A);await $e(),alert((n==null?void 0:n.message)||"商品同步完成")}catch(n){console.error("同步商品失败:",n),alert((n==null?void 0:n.message)||"同步失败,请重试")}finally{Y(!1)}},te=n=>{Re(n),Pe({...n}),G(!0)},je=async()=>{if(Ce)try{await jr(Ce.cookie_id,Ce.item_id,{item_title:xe.item_title||"",item_description:xe.item_description||"",item_category:xe.item_category||"",item_price:xe.item_price||"",item_detail:xe.item_detail||Ce.item_detail||""}),await $e(),await Le(),G(!1),Re(null)}catch(n){console.error("更新商品失败:",n),alert("更新失败,请重试")}},p=async n=>{if(confirm(`确认删除商品"${n.item_title}"吗?`))try{await xr(n.cookie_id,n.item_id),l(C=>C.filter(i=>!(i.cookie_id===n.cookie_id&&i.item_id===n.item_id)))}catch(C){console.error("删除商品失败:",C),alert("删除失败,请重试")}},$=async()=>{try{if(!le.cookie_id||!le.item_id){alert("请选择账号并填写商品ID");return}await mr(le.cookie_id,{item_id:le.item_id,item_title:le.item_title,item_price:le.item_price,item_detail:le.item_image?JSON.stringify({item_image:le.item_image}):""}),await $e(),U(!1),g({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(n){console.error("添加商品失败:",n),alert("添加失败,请重试")}},ie=async()=>{if(!y.cookie_id)return alert("请选择发布账号");if(!y.title.trim())return alert("请填写商品标题");if(!y.price.trim())return alert("请填写商品价格");if(!y.quantity||Number(y.quantity)<=0)return alert("库存数量必须大于 0");if(y.images.length===0)return alert("至少上传 1 张商品图片");if(y.postage_mode==="fixed"&&!y.postage.trim())return alert("请填写一口价邮费");ce(!0);try{const n=await pr({...y,location:q||void 0});if(await $e(),ge(!1),D({cookie_id:A||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),W([]),ne(null),n!=null&&n.item_id){const C={id:n.item_id,cookie_id:y.cookie_id,item_id:n.item_id,item_title:n.item_title||y.title,item_price:n.item_price||y.price,item_image:n.item_image};t(C),alert("商品发布成功,ID: "+n.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(n){console.error("发布商品失败:",n);const C=n==null?void 0:n.payload;if((C==null?void 0:C.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((n==null?void 0:n.message)||"发布失败,请重试")}finally{ce(!1)}},re=async()=>{Z("upload"),u(null),F(null),R(null),ee(null),se(""),S({catId:"",catName:"",channelCatId:"",tbCatId:""}),ve([]),Ne(null),K(!0),M(!0);try{const n=await Vs(20),C=nn(n);if(C!=null&&C.id){const i=await bt(C.id);H(i),F(i),Z(["running","canceling"].includes(i.status)?"running":"done")}}catch(n){console.error("恢复最近批量铺货任务失败:",n)}finally{M(!1)}},ze=async()=>{const n=T.trim();if(!A)return alert("请先选择默认发布账号");if(!n)return alert("请输入类目关键词");ye(!0);try{const i=(await ur(A,n)).category;S({catId:i.cat_id,catName:i.cat_name,channelCatId:i.channel_cat_id,tbCatId:i.tb_cat_id||""})}catch(C){console.error("获取推荐类目失败:",C),alert((C==null?void 0:C.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{ye(!1)}},He=async()=>{if(I!=null&&I.id){M(!0),K(!0);try{const n=await bt(I.id);F(n),Z(["running","canceling"].includes(n.status)?"running":"done")}catch(n){console.error("加载最近批量铺货结果失败:",n)}finally{M(!1)}}},Xe=async()=>{if(!me)return alert("请先上传商品表格");if(!A)return alert("请先选择默认发布账号");M(!0);try{const n=await hr({file:me,imagesZip:E,defaultCookieId:A,fallbackCategory:c,location:De||void 0});u(n),F(null),Z("preview")}catch(n){console.error("批量铺货预检失败:",n),alert((n==null?void 0:n.message)||"预检失败,请检查表格和图片 zip")}finally{M(!1)}},mt=async()=>{if(Q!=null&&Q.preview_id){if(Q.valid<=0)return alert("没有可发布的商品行");M(!0);try{const n=await gr(Q.preview_id),C=await bt(n.batch_id||Q.preview_id);F(C),H(C),Z(C.status==="running"?"running":"done")}catch(n){console.error("启动批量铺货失败:",n),alert((n==null?void 0:n.message)||"启动发布任务失败")}finally{M(!1)}}},Ue=async()=>{if(d!=null&&d.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){M(!0);try{const n=await fr(d.id),C=await bt(d.id);F(C),Z((n==null?void 0:n.status)==="canceling"||C.status==="canceling"?"running":"done")}catch(n){alert((n==null?void 0:n.message)||"取消失败")}finally{M(!1)}}},We=async()=>{const n=Q==null?void 0:Q.preview_id;if(n&&ae==="preview")try{await br(n)}catch(C){console.error("清理批量铺货预检失败:",C)}u(null),Z("upload")},pt=async()=>{await We(),K(!1)},kt=async()=>{if(d!=null&&d.id){M(!0);try{await yr(d.id),F(await bt(d.id)),Z("running")}catch(n){alert((n==null?void 0:n.message)||"重试失败")}finally{M(!1)}}},Ct=()=>{const i=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","类目ID","类目名称","频道类目ID","淘宝类目ID","付款发货启用","付款发货内容","评价赠品启用","评价赠品内容","求评价启用","求评价等待小时","求评价文案","求评价最多次数"],...[["","会员组合包自动发货","下单后发送主卡和附赠卡。","19.90","29.90","10","free","","images/bundle-1.jpg;images/bundle-2.jpg","","","","","是","101:1;102:1","是","201:1;202:2","是","72","亲,满意的话麻烦给个评价,谢谢~","1"],["","普通商品","仅发布商品,不创建自动化规则。","49.90","","10","fixed","8.00","https://example.com/product.jpg","","","","","否","","否","","否","","",""]]].map(_=>_.map(B=>`"${String(B).replace(/"/g,'""')}"`).join(",")).join(` -`),N=new Blob(["\uFEFF"+i],{type:"text/csv;charset=utf-8"}),a=URL.createObjectURL(N),h=document.createElement("a");h.href=a,h.download="批量铺货模板.csv",document.body.appendChild(h),h.click(),h.remove(),URL.revokeObjectURL(a)},St=()=>{g(n=>({...n,cookie_id:A||n.cookie_id})),U(!0)},lt=()=>{D(n=>({...n,cookie_id:A||n.cookie_id})),ge(!0)},rt=async n=>{if(!(n?A:y.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");m(!0),navigator.geolocation.getCurrentPosition(async i=>{try{const N=await mn(i.coords.longitude,i.coords.latitude);if(!N.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");n?(ve(N),Ne(N[0])):(W(N),ne(N[0]))}catch(N){alert((N==null?void 0:N.message)||"获取发货地失败")}finally{m(!1)}},i=>{m(!1),alert(i.code===i.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},Lt=n=>o.filter(C=>C.cookie_id===n.cookie_id&&C.item_id===n.item_id).length>0?o.filter(C=>C.cookie_id===n.cookie_id&&C.item_id===n.item_id):o.filter(C=>C.cookie_id===n.cookie_id&&!C.item_id),nt=n=>{switch(n){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return n||"-"}},ut=n=>{switch(n){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},et=r.useMemo(()=>new Map(v.map(n=>[n.id,n])),[v]),it=r.useMemo(()=>O?s.filter(n=>n.cookie_id===O):s,[O,s]),Ve=n=>{const C=et.get(n),i=(C==null?void 0:C.remark)||(C==null?void 0:C.nickname);return i?`${i} · ${n.slice(0,6)}`:`账号 ${n.slice(0,8)}`},ht=n=>{const C=et.get(n);return(C==null?void 0:C.remark)||(C==null?void 0:C.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(el,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:O,onChange:n=>j(n.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ve(n.id)},n.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(xt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:A,onChange:n=>b(n.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ve(n.id)},n.id))]})]})]}),e.jsxs("button",{onClick:Ae,disabled:V||!A,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Be,{className:`w-4 h-4 ${V?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:St,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(Ye,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:lt,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Yt,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void re(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(qt,{className:"w-4 h-4"}),I&&["running","canceling"].includes(I.status)?"继续批量任务":"批量铺货"]}),I&&!["running","canceling"].includes(I.status)&&e.jsx("button",{onClick:()=>void He(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[it.map(n=>{const C=Lt(n),i=C.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:[e.jsx("button",{onClick:()=>te(n),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors",title:"编辑",children:e.jsx(_t,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>p(n),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md hover:bg-red-100 text-red-500 transition-colors",title:"删除",children:e.jsx(Je,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"aspect-square bg-gray-100 rounded-xl mb-2.5 overflow-hidden relative",children:[n.item_image?e.jsx("img",{src:n.item_image,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(pa,{className:"w-8 h-8"})}),e.jsx("div",{className:"absolute top-1.5 left-1.5 bg-black/50 backdrop-blur-md text-white text-[10px] font-bold px-1.5 py-0.5 rounded-md",children:pn(n.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:n.item_title}),e.jsxs("div",{className:"mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:ht(n.cookie_id),children:[e.jsx(xt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:ht(n.cookie_id)})]}),e.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500 mb-2",children:[e.jsxs("span",{className:"bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]",children:["ID: ",n.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${i?"text-emerald-600":"text-amber-600"}`,children:[i?e.jsx(os,{className:"w-3 h-3"}):e.jsx(tl,{className:"w-3 h-3"}),i?`${C.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>t(n),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${i?"bg-gray-900 text-white hover:bg-black":"bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(sl,{className:"w-3.5 h-3.5"}),i?"查看发货规则":"关联发货规则"]}),e.jsx(cs,{className:"w-3.5 h-3.5"})]})})]},`${n.cookie_id}-${n.item_id}`)}),it.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(ua,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),O?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),de&&Ce&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"560px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"编辑商品"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",Ce.item_id]})]}),e.jsx("button",{onClick:()=>G(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"商品标题",value:xe.item_title||"",onChange:n=>Pe({...xe,item_title:n.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:xe.item_price||"",onChange:n=>Pe({...xe,item_price:n.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:xe.item_category||"",onChange:n=>Pe({...xe,item_category:n.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:xe.item_description||"",onChange:n=>Pe({...xe,item_description:n.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:je,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),X&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"720px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"添加商品"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"手动建立商品与自动发货规则的关联"})]}),e.jsx("button",{onClick:()=>U(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"所属账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:le.cookie_id,onChange:n=>g({...le,cookie_id:n.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ve(n.id)},n.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品 ID"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入闲鱼商品 ID",value:le.item_id,onChange:n=>g({...le,item_id:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品价格"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 99.00",value:le.item_price,onChange:n=>g({...le,item_price:n.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入商品标题",value:le.item_title,onChange:n=>g({...le,item_title:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"图片 URL"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://...",value:le.item_image,onChange:n=>g({...le,item_image:n.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:$,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),fe&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:()=>ge(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800 leading-6",children:"发布时必须填写库存。若账号没有库存发布能力,后端会返回明确的“库存权限不足”错误,不会误报为普通发布失败。"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:y.cookie_id,onChange:n=>{D({...y,cookie_id:n.target.value}),W([]),ne(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ve(n.id)},n.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:会员月卡自动发货",value:y.title,onChange:n=>D({...y,title:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"库存数量"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",type:"number",min:"1",placeholder:"必须大于 0",value:y.quantity,onChange:n=>D({...y,quantity:n.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品描述"}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述会用于自动识别类目;留空时使用标题",value:y.description,onChange:n=>D({...y,description:n.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"售价"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"99.00",value:y.price,onChange:n=>D({...y,price:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"原价(可选)"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"129.00",value:y.original_price,onChange:n=>D({...y,original_price:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"运费方式"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:y.postage_mode,onChange:n=>D({...y,postage_mode:n.target.value}),children:[e.jsx("option",{value:"free",children:"包邮"}),e.jsx("option",{value:"distance",children:"按距离计费"}),e.jsx("option",{value:"fixed",children:"一口价邮费"}),e.jsx("option",{value:"none",children:"无需邮寄"})]})]})]}),y.postage_mode==="fixed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"一口价邮费"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 8.00",value:y.postage,onChange:n=>D({...y,postage:n.target.value})})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。"})]}),e.jsxs("button",{type:"button",disabled:z||!y.cookie_id,onClick:()=>void rt(!1),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx($s,{className:"h-4 w-4"}),z?"定位中...":"获取当前位置"]})]}),f.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,f.indexOf(q))),onChange:n=>ne(f[Number(n.target.value)]||null),children:f.map((n,C)=>e.jsx("option",{value:String(C),children:[n.province,n.city,n.area,n.poi_name].filter(Boolean).join(" ")},`${n.division_id}-${n.poi_id}-${C}`))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品图片(1-9 张)"}),e.jsxs("label",{className:"flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors",children:[e.jsx(qt,{className:"w-8 h-8 text-emerald-600 mb-2"}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"选择图片"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:y.images.length?"已选择 "+y.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:n=>D({...y,images:Array.from(n.target.files||[]).slice(0,9)})})]}),J.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:J.map(n=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:n.url,alt:"",className:"w-full h-full object-cover"})},n.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:pe,onClick:ie,className:"w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Yt,{className:"w-4 h-4"}),pe?"正在发布...":"发布到闲鱼"]})})]})}),document.body),L&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"980px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量铺货"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"上传商品表格和图片 zip,先预检,再逐条发布到闲鱼。"})]}),e.jsx("button",{onClick:()=>void pt(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Te,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]].map(([n,C])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${ae===n?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:C},n))}),ae==="upload"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-sm text-blue-900 leading-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:"先下载模板,再按字段填写。"}),e.jsxs("div",{children:["图片字段写 zip 内相对路径,多个图片用英文分号分隔,例如 ",e.jsx("span",{className:"font-mono font-bold",children:"images/a.jpg;images/b.jpg"}),"。也支持直接填写图片 URL。"]})]}),e.jsx("button",{type:"button",onClick:Ct,className:"shrink-0 rounded-xl bg-blue-600 px-4 py-2 text-sm font-extrabold text-white hover:bg-blue-700",children:"下载CSV模板"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"默认发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:A,onChange:n=>{b(n.target.value),ve([]),Ne(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),v.map(n=>e.jsx("option",{value:n.id,children:Ve(n.id)},n.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/70 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-extrabold text-gray-900",children:["默认类目 ",e.jsx("span",{className:"font-medium text-gray-500",children:"(可为空)"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-800",children:"填写后优先使用该类目;留空时由闲鱼根据每件商品自动识别。仍无法识别时,系统最终使用“电子资料”兜底。"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("label",{className:"relative flex-1",children:[e.jsx("span",{className:"sr-only",children:"类目关键词"}),e.jsx(Nt,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{className:"w-full ios-input rounded-xl bg-white py-2.5 pl-10 pr-3",placeholder:"输入关键词,例如:课程资料、设计素材",value:T,onChange:n=>se(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),ze())}})]}),e.jsxs("button",{type:"button",disabled:!A||!T.trim()||ke,onClick:()=>void ze(),className:"ios-btn-primary flex min-h-[42px] items-center justify-center gap-2 rounded-xl px-4 text-sm font-bold disabled:opacity-50",children:[e.jsx(Nt,{className:"h-4 w-4"}),ke?"匹配中...":"获取类目"]})]}),c.catId?e.jsxs("div",{className:"flex min-h-[46px] items-center justify-between gap-3 border-t border-amber-200 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-900",children:[e.jsx(os,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:c.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",c.catId," · 频道 ",c.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:()=>S({catId:"",catName:"",channelCatId:"",tbCatId:""}),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",children:e.jsx(Te,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"批次发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。"})]}),e.jsxs("button",{type:"button",disabled:z||!A,onClick:()=>void rt(!0),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx($s,{className:"h-4 w-4"}),z?"定位中...":"获取当前位置"]})]}),be.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,be.indexOf(De))),onChange:n=>Ne(be[Number(n.target.value)]||null),children:be.map((n,C)=>e.jsx("option",{value:String(C),children:[n.province,n.city,n.area,n.poi_name].filter(Boolean).join(" ")},`${n.division_id}-${n.poi_id}-${C}`))})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors",children:[e.jsx(qt,{className:"w-9 h-9 text-blue-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传商品表格"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:me?me.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:n=>{var C;return R(((C=n.target.files)==null?void 0:C[0])||null)}})]}),e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50 transition-colors",children:[e.jsx(qt,{className:"w-9 h-9 text-emerald-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传图片 zip(可选)"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:E?E.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:n=>{var C;return ee(((C=n.target.files)==null?void 0:C[0])||null)}})]})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 border border-gray-100 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"字段说明"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"照着下面的“什么时候填写”处理即可。预检发现问题时,会指出具体哪一行需要修改。"})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 text-xs text-blue-950",children:[e.jsx("div",{className:"text-sm font-extrabold",children:"“付款后发送的卡密”怎么填"}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101"}),e.jsx("p",{className:"mt-1 leading-5",children:"从卡密组 101 立即发送 1 份。卡密组 ID 可以在“卡密库存”页面查看。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:2"}),e.jsx("p",{className:"mt-1 leading-5",children:"每购买 1 件,就从卡密组 101 发送 2 份。买家购买 3 件时会发送 6 份。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:1:0;102:2:3"}),e.jsx("p",{className:"mt-1 leading-5",children:"先立即发送卡密组 101 的 1 份,再等待 3 秒发送卡密组 102 的 2 份。"})]})]}),e.jsxs("p",{className:"mt-3 leading-5 text-blue-800",children:["每一组依次写“卡密组 ID : 每件发送几份 : 等待几秒”。份数不写时按 1 份处理,等待时间不写时立即发送。需要发送多种卡密时,用英文分号 ",e.jsx("code",{className:"font-bold",children:";"})," 隔开。"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"字段"}),e.jsx("th",{className:"px-3 py-2",children:"什么时候填写"}),e.jsx("th",{className:"px-3 py-2",children:"填写方法"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 text-gray-700",children:[["账号ID","需要覆盖默认账号时填写","上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["类目ID","需要指定当前行默认类目时填写","必须和“类目名称、频道类目ID”同时填写;优先于自动识别"],["类目名称","填写了“类目ID”时必填","填写该 ID 对应的准确类目名称"],["频道类目ID","覆盖类目时必填","必须填写闲鱼返回的准确频道类目 ID"],["淘宝类目ID","按闲鱼返回填写","“电子资料”无淘宝类目 ID,保持为空"],["付款发货启用","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款发货内容","“付款发货启用”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价赠品启用","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价赠品内容","“评价赠品启用”填“是”时填写","格式和付款发货内容相同,也可以同时发送多个卡密组"],["求评价启用","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["求评价等待小时","“求评价启用”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["求评价文案","“求评价启用”填“是”时填写","填写要发送给买家的求评价消息"],["求评价最多次数","可以留空","留空只提醒 1 次"]].map(([n,C,i])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:n}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${C==="每个商品都要填"?"text-red-600":C==="可以留空"?"text-gray-500":"text-amber-700"}`,children:C}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:i})]},n))})]})})]})]}),ae==="preview"&&Q&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总行数"}),e.jsx("div",{className:"text-2xl font-extrabold text-gray-900 mt-1",children:Q.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"可发布"}),e.jsx("div",{className:"text-2xl font-extrabold text-emerald-700 mt-1",children:Q.valid})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"有问题"}),e.jsx("div",{className:"text-2xl font-extrabold text-red-700 mt-1",children:Q.invalid})]})]}),e.jsx("div",{className:"max-h-[380px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"价格/库存"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"图片"}),e.jsx("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:Q.rows.map(n=>{var C,i,N,a;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:n.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${n.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:n.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:n.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",n.price||"-"," / ",n.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((C=n.category)==null?void 0:C.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((i=n.category)==null?void 0:i.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((N=n.images)==null?void 0:N.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((a=n.errors)==null?void 0:a.join(";"))||"-"})]},n.row_no)})})]})})]}),(ae==="running"||ae==="done")&&d&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("div",{className:`rounded-2xl p-4 border ${ut(d.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:nt(d.status)})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总数"}),e.jsx("div",{className:"text-xl font-extrabold text-gray-900 mt-1",children:d.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"成功"}),e.jsx("div",{className:"text-xl font-extrabold text-emerald-700 mt-1",children:d.success})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"失败"}),e.jsx("div",{className:"text-xl font-extrabold text-red-700 mt-1",children:d.failed})]}),e.jsxs("div",{className:"rounded-2xl bg-blue-50 p-4 border border-blue-100",children:[e.jsx("div",{className:"text-xs font-bold text-blue-700",children:"等待"}),e.jsx("div",{className:"text-xl font-extrabold text-blue-700 mt-1",children:d.pending})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"商品ID"}),e.jsx("th",{className:"px-4 py-3",children:"错误原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:d.rows.map(n=>{var C,i;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:n.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${ut(n.status)}`,children:nt(n.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:n.title}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((C=n.category)==null?void 0:C.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((i=n.category)==null?void 0:i.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:n.item_url?e.jsx("a",{href:n.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:n.item_id}):n.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:n.error_message||"-"})]},n.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[ae==="upload"&&e.jsxs("button",{disabled:w||!me||!A,onClick:Xe,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(Be,{className:`w-4 h-4 ${w?"animate-spin":""}`}),w?"正在预检...":"开始预检"]}),ae==="preview"&&Q&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:w,onClick:()=>void We(),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"返回修改"}),e.jsxs("button",{disabled:w||Q.valid<=0,onClick:mt,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(Yt,{className:"w-4 h-4"}),w?"启动中...":`确认发布 ${Q.valid} 个商品`]})]}),(ae==="running"||ae==="done")&&d&&e.jsxs("div",{className:"flex gap-3 w-full",children:[d.status==="running"?e.jsx("button",{disabled:w,onClick:Ue,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):d.status==="canceling"?e.jsx("button",{disabled:!0,className:"flex-1 px-6 py-3.5 rounded-xl bg-amber-100 text-amber-800 font-bold",children:"正在保存远端结果并安全取消…"}):e.jsx("button",{onClick:()=>window.open(`/items/publish-batches/${d.id}/result.csv`,"_blank"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"下载结果"}),d.retryable>0&&!["running","canceling"].includes(d.status)&&e.jsxs("button",{disabled:w,onClick:kt,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Be,{className:`w-4 h-4 ${w?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(d.status)&&e.jsx("button",{onClick:()=>{K(!1),$e(),Le()},className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"完成"})]})]})]})}),document.body)]})},ta="https://dashscope.aliyuncs.com/compatible-mode/v1",hn=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],gn=new Set(["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),bn=()=>{const[t,s]=r.useState(null),[l,o]=r.useState(!1),[x,v]=r.useState(""),[k,A]=r.useState(!1),[b,O]=r.useState([]),[j,V]=r.useState(!1),[Y,pe]=r.useState(""),[ce,w]=r.useState(!1),M=r.useRef(null),[de,G]=r.useState(!1),[X,U]=r.useState(!1),[fe,ge]=r.useState(!1),[L,K]=r.useState(!1),[ae,Z]=r.useState(!1),[me,R]=r.useState(null),[E,ee]=r.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});r.useEffect(()=>{se(),wa().then(f=>{f.username&&ee(W=>({...W,new_username:f.username||""}))}).catch(()=>{})},[]),r.useEffect(()=>{const f=W=>{var q;(q=M.current)!=null&&q.contains(W.target)||w(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const T=async(f,W=!1)=>{const q=f||t,ne=(q==null?void 0:q.ai_api_url)||(q==null?void 0:q.ai_base_url)||ta;V(!0),pe("");try{const be=await $r(ne,(q==null?void 0:q.ai_api_key)||"");O(be),w(W&&be.length>0),!(q!=null&&q.ai_model)&&be.length>0&&s(ve=>ve&&{...ve,ai_model:be[0]})}catch(be){O([]),w(!1),pe(be.message||"读取模型失败")}finally{V(!1)}},se=()=>{o(!0),v(""),La().then(f=>{s(f),T(f)}).catch(f=>{s(null),v(f.message||"加载配置失败")}).finally(()=>o(!1))},ke=async()=>{if(t){A(!0);try{const f=Object.fromEntries(Object.entries(t).filter(([W,q])=>!gn.has(W)&&q!==void 0&&q!==null));await Oa(f),alert("系统配置已保存")}catch(f){alert("保存失败:"+f.message)}finally{A(!1)}}},ye=async f=>{f.preventDefault(),R(null);const W=E.new_username.trim();if(W.length<3){R({type:"error",text:"用户名至少需要 3 个字符"});return}if(!E.current_password){R({type:"error",text:"请输入当前密码确认身份"});return}if(E.new_password&&E.new_password.length<8){R({type:"error",text:"新密码至少需要 8 个字符"});return}if(E.new_password!==E.confirm_password){R({type:"error",text:"两次输入的新密码不一致"});return}Z(!0);try{const q=await Ol({current_password:E.current_password,new_username:W,new_password:E.new_password||void 0});if(!q.success){R({type:"error",text:q.message||"登录凭据更新失败"});return}R({type:"success",text:q.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(q){R({type:"error",text:q.message||"登录凭据更新失败"})}finally{Z(!1)}};if(!t)return e.jsx("div",{className:"p-8 text-center text-gray-400",children:x||(l?"加载配置中...":"暂无配置")});const z=t.ai_model||"",m=b;return e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-fade-in pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-2xl flex items-center justify-center",children:e.jsx(bs,{className:"w-6 h-6 text-gray-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900",children:"系统设置"}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm font-medium",children:"配置全局自动化规则与系统参数"})]})]}),e.jsxs("button",{onClick:se,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Be,{className:"w-4 h-4"}),"刷新"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-100 text-gray-600",children:e.jsx(al,{className:"w-4 h-4"})}),"基础设置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:t.log_level||"info",onChange:f=>s({...t,log_level:f.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:hn.map(f=>e.jsx("option",{value:f.value,children:f.label},f.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:t.log_format||"text",onChange:f=>s({...t,log_format:f.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:t.renewal_log_retention_days??10,onChange:f=>s({...t,renewal_log_retention_days:parseInt(f.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"365"}),e.jsx("p",{className:"text-xs text-gray-500",children:"0 表示不自动清理续期日志"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-brand text-white",children:e.jsx(js,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),e.jsx("input",{type:"text",value:t.ai_api_url||ta,onChange:f=>s({...t,ai_api_url:f.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://api.openai.com/v1"}),e.jsx("p",{className:"text-xs text-gray-500",children:"无需补全 /chat/completions"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:de?"text":"password",value:t.ai_api_key||"",onChange:f=>s({...t,ai_api_key:f.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:"sk-..."}),e.jsx("button",{type:"button",onClick:()=>G(!de),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:de?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"模型"}),e.jsxs("div",{ref:M,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:z,onFocus:()=>b.length>0&&w(!0),onChange:f=>{s({...t,ai_model:f.target.value}),b.length>0&&w(!0)},onKeyDown:f=>{f.key==="Escape"&&w(!1),f.key==="ArrowDown"&&b.length>0&&w(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>b.length>0&&w(f=>!f),disabled:b.length===0,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 disabled:opacity-30","aria-label":"展开模型列表",children:e.jsx(ll,{className:`w-4 h-4 transition-transform ${ce?"rotate-180":""}`})}),ce&&e.jsx("div",{className:"absolute left-0 right-0 top-[calc(100%+6px)] z-40 max-h-64 overflow-y-auto rounded-xl border border-gray-200 bg-white shadow-xl shadow-gray-200/70 py-1",children:m.length>0?m.map(f=>e.jsxs("button",{type:"button",onClick:()=>{s({...t,ai_model:f}),w(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-brand flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:f}),f===z&&e.jsx(Qe,{className:"w-4 h-4 shrink-0 text-brand"})]},f)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>T(void 0,!0),disabled:j,className:"px-4 py-3 rounded-xl bg-gray-100 text-gray-700 hover:bg-gray-200 disabled:opacity-60 font-bold flex items-center justify-center gap-2 whitespace-nowrap",children:[e.jsx(Be,{className:`w-4 h-4 ${j?"animate-spin":""}`}),"读取模型"]})]}),Y?e.jsx("p",{className:"text-xs text-red-500",children:Y}):e.jsx("p",{className:"text-xs text-gray-500",children:b.length>0?`已从当前 API 地址读取到 ${b.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),e.jsxs("div",{className:"p-3 bg-blue-50 rounded-xl text-xs text-blue-700",children:[e.jsx("strong",{children:"常见 AI 服务:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-0.5",children:[e.jsx("li",{children:"阿里云通义千问: https://dashscope.aliyuncs.com/compatible-mode/v1"}),e.jsx("li",{children:"OpenAI: https://api.openai.com/v1"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-amber-500 text-white",children:e.jsx(Dt,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务地址"}),e.jsx("input",{type:"url",value:t["captcha.remote_service_url"]||"",onChange:f=>s({...t,"captcha.remote_service_url":f.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://example.com/internal/captcha/solve"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务秘钥"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:X?"text":"password",value:t["captcha.remote_secret_key"]||"",onChange:f=>s({...t,"captcha.remote_secret_key":f.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off"}),e.jsx("button",{type:"button",onClick:()=>U(!X),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:X?"隐藏秘钥":"显示秘钥",children:X?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(t["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:f=>s({...t,"captcha.remote_pass_cookies":f.target.checked}),className:"mt-0.5 w-4 h-4 rounded border-gray-300"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-bold text-amber-900",children:"允许向远程服务传递账号 Cookie"}),e.jsx("span",{className:"block mt-1 text-xs text-amber-700",children:"默认关闭。仅在信任远程服务且需要由其自动重取过期验证链接时开启。"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"配置地址和秘钥后优先调用远程服务;只有网络不可用或超时才回退本机引擎,远程明确返回失败时不会重复触发本机验证。"})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-900 text-white",children:e.jsx(Es,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:ye,className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"登录用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:E.new_username,onChange:f=>ee({...E,new_username:f.target.value}),className:"w-full ios-input pl-11 pr-4 py-3 rounded-xl text-sm",autoComplete:"username"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"当前密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:fe?"text":"password",value:E.current_password,onChange:f=>ee({...E,current_password:f.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm",placeholder:"用于确认当前身份",autoComplete:"current-password"}),e.jsx("button",{type:"button",onClick:()=>ge(!fe),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:fe?"隐藏密码":"显示密码",children:fe?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"新密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:L?"text":"password",value:E.new_password,onChange:f=>ee({...E,new_password:f.target.value}),className:"w-full ios-input px-4 py-3 pr-11 rounded-xl text-sm",placeholder:"不修改则留空",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>K(!L),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:L?"隐藏密码":"显示密码",children:L?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"确认新密码"}),e.jsx("input",{type:L?"text":"password",value:E.confirm_password,onChange:f=>ee({...E,confirm_password:f.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),me&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${me.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(Dt,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:me.text})]}),e.jsxs("button",{type:"submit",disabled:ae||!E.new_username||!E.current_password,className:"w-full bg-gray-900 hover:bg-black text-white px-5 py-3 rounded-xl font-bold text-sm flex items-center justify-center gap-2 transition-colors disabled:opacity-40",children:[e.jsx(Es,{className:"w-4 h-4"}),ae?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:ke,disabled:k,className:"ios-btn-primary px-10 py-5 rounded-xl text-lg shadow-2xl shadow-blue-200 flex items-center gap-3 transform hover:scale-105 active:scale-95 transition-all disabled:opacity-70",children:[e.jsx(Ge,{className:"w-6 h-6"}),k?"保存中...":"保存所有配置"]})})]})},ls=(t,s)=>t.allowed_resolutions.includes(s),fn=(t,s)=>({runs:t.runs.filter(l=>!s||l.cookie_id===s),pending_tasks:t.pending_tasks.filter(l=>!s||l.cookie_id===s)}),yn=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",jn=(t,s,l,o,x,v)=>t!==s||l!==o?!1:(v(x),!0),tt={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:Tt},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:rl},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:ja}},Wt=["order_paid","buyer_reviewed","review_missing_timeout"],_n="亲,商品使用满意的话,麻烦给个评价,谢谢~",At=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),Ra=t=>{if(!t)return{};try{const s=JSON.parse(t);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}},ct=(t,s={})=>{const l=Ra(t);return JSON.stringify({after_shipped_hours:Number(l.after_shipped_hours||72),repeat_interval_hours:Number(l.repeat_interval_hours||24),max_attempts:Number(l.max_attempts||1),...s})},Rt=(t,s)=>{var o;const l=((o=tt[t])==null?void 0:o.label)||"自动化规则";return s?`${l} - ${s}`:l},sa=t=>{const s=(t||"").trim();return s?Object.values(tt).some(l=>s===l.label||s.startsWith(`${l.label} -`)):!0},Pt=(t,s=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:_n,enabled:!0,sort_order:1}];const l={action_type:"send_card",card_id:s,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[l,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[l]},Nn=t=>{var l,o;if(t.trigger_type==="review_missing_timeout")return((o=(l=t.actions)==null?void 0:l.find(x=>x.action_type==="send_text"))==null?void 0:o.message_template)||"发送求评价文案";const s=(t.actions||[]).filter(x=>x.action_type==="send_card");return s.length?s.map(x=>x.card_name||`卡密 ${x.card_id}`).join(" / "):"未配置卡密库存"},aa=(t,s=!1)=>{const l={blue:s?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:s?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:s?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return l[t]||l.blue},vn=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Jt=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",wn=t=>t===!0||t===1||t==="1",kn=({initialDeliveryTarget:t,onDeliveryTargetHandled:s})=>{var C,i,N;const[l,o]=r.useState("automation"),[x,v]=r.useState([]),[k,A]=r.useState({runs:[],pending_tasks:[]}),[b,O]=r.useState([]),[j,V]=r.useState({}),[Y,pe]=r.useState([]),[ce,w]=r.useState([]),[M,de]=r.useState([]),[G,X]=r.useState(!1),[U,fe]=r.useState(""),[ge,L]=r.useState(""),[K,ae]=r.useState(""),[Z,me]=r.useState(""),[R,E]=r.useState("all"),[ee,T]=r.useState(1),[se,ke]=r.useState(10),[ye,z]=r.useState(0),[m,f]=r.useState(0),[W,q]=r.useState({}),ne=r.useRef(0),be=r.useRef(0),ve=r.useRef("");ve.current=U;const[De,Ne]=r.useState(!1),[c,S]=r.useState(!1),[Q,u]=r.useState(!1),[d,F]=r.useState(null),[I,H]=r.useState(null),[P,Ce]=r.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});Y.find(a=>a.id===U);const Re=r.useCallback(async()=>{const[a,h,_,B]=await Promise.all([Mt(),Ze(),vt(),Ks()]);pe(a),w(h),de(_),V(B),fe(oe=>{var ue;return oe||((ue=a[0])==null?void 0:ue.id)||""})},[]),xe=r.useCallback(async()=>{const a=++ne.current,h=wr().catch(oe=>(console.warn("加载自动化异常列表失败,不阻断规则展示",oe),null)),_=await _r({cookieId:U||void 0,triggerType:Z,enabled:R==="all"?void 0:R==="enabled",search:K,page:ee,pageSize:se});if(a!==ne.current)return;v(_.data),z(_.total),f(_.total_pages),q(_.trigger_counts||{}),_.page!==ee&&T(_.page);const B=await h;a===ne.current&&B&&A(B)},[ee,se,R,Z,K,U]),Pe=r.useCallback(async()=>{const a=U;if(a!==ve.current)return;const h=++be.current;if(O([]),!a)return;const _=await Or(a);jn(h,be.current,a,ve.current,_,O)},[U]),le=r.useCallback(async()=>{V(await Ks())},[]),g=r.useCallback(async()=>{X(!0);try{l==="automation"?await xe():l==="reply"?await Pe():await le()}finally{X(!1)}},[l,xe,le,Pe]);r.useEffect(()=>{const a=window.setTimeout(()=>{T(1),ae(ge.trim())},300);return()=>window.clearTimeout(a)},[ge]),r.useEffect(()=>{Re().catch(a=>console.error("加载规则参考数据失败",a))},[Re]),r.useEffect(()=>{g().catch(a=>console.error("刷新规则页面失败",a))},[g]);const y=r.useMemo(()=>x.filter(a=>!U||a.cookie_id===U),[x,U]),D=r.useMemo(()=>fn(k,U),[k,U]),J=r.useMemo(()=>Y.filter(a=>!U||a.id===U),[Y,U]),Se=r.useMemo(()=>{if(m<=1)return[];const a=Math.max(1,Math.min(ee-2,m-4)),h=Math.min(m,a+4);return Array.from({length:h-a+1},(_,B)=>a+B)},[ee,m]),$e=!!(ge.trim()||Z||R!=="all"),Le=()=>{L(""),ae(""),me(""),E("all"),T(1)},Ae=r.useMemo(()=>{const a=(d==null?void 0:d.cookie_id)||U;return M.filter(h=>h.cookie_id===a)},[d==null?void 0:d.cookie_id,M,U]),te=r.useMemo(()=>{if(!(!(d!=null&&d.cookie_id)||!(d!=null&&d.item_id)))return M.find(a=>a.cookie_id===d.cookie_id&&a.item_id===d.item_id)},[d==null?void 0:d.cookie_id,d==null?void 0:d.item_id,M]),je=wn(te==null?void 0:te.is_multi_spec),p=(d==null?void 0:d.trigger_type)||"order_paid",$=tt[p],ie=Ra(d==null?void 0:d.config_json),re=r.useCallback((a="order_paid",h=U,_="")=>{const B=M.find(ue=>ue.cookie_id===h&&ue.item_id===_),oe=(B==null?void 0:B.item_title)||_;return{name:Rt(a,oe),trigger_type:a,cookie_id:h,item_id:_,item_title:(B==null?void 0:B.item_title)||"",item_keyword:oe,card_group_id:0,priority:100,enabled:!0,config_json:a==="review_missing_timeout"?ct():"{}",actions:Pt(a),variants:a==="review_missing_timeout"?[]:[At()]}},[M,U]),ze=r.useCallback(a=>{var _,B;const h=a.trigger_type||"order_paid";F({...a,trigger_type:h,config_json:h==="review_missing_timeout"?ct(a.config_json):a.config_json||"{}",actions:(_=a.actions)!=null&&_.length?a.actions.map(oe=>({...oe})):Pt(h,a.card_group_id),variants:(B=a.variants)!=null&&B.length?a.variants.map(oe=>({...oe})):h==="review_missing_timeout"?[]:[At()]}),Ne(!0)},[]);r.useEffect(()=>{if(!t)return;let a=!1;return(async()=>{o("automation"),fe(t.cookieId),X(!0);try{const[_,B,oe]=await Promise.all([us(),vt(),Ze().catch(he=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",he),[]))]);if(a)return;v(_),de(B),w(oe);const ue=_.find(he=>he.cookie_id===t.cookieId&&he.item_id===t.itemId&&he.trigger_type==="order_paid");if(ue)ze(ue);else{const he=B.find(qe=>qe.cookie_id===t.cookieId&&qe.item_id===t.itemId);F({...re("order_paid",t.cookieId,t.itemId),item_title:(he==null?void 0:he.item_title)||"",item_keyword:(he==null?void 0:he.item_title)||t.itemId,name:Rt("order_paid",(he==null?void 0:he.item_title)||t.itemId)}),Ne(!0)}}catch(_){console.error("打开商品自动化规则失败",_),alert("无法加载该商品的自动化规则")}finally{a||(X(!1),s==null||s())}})(),()=>{a=!0}},[re,t,s,ze]);const He=(a="order_paid")=>{if(!U){alert("请先选择账号");return}F(re(a)),Ne(!0)},Xe=a=>{var B,oe,ue,he,qe;if(!d)return;const h=((oe=(B=d.variants)==null?void 0:B.find(we=>we.card_id))==null?void 0:oe.card_id)||((he=(ue=d.actions)==null?void 0:ue.find(we=>we.action_type==="send_card"))==null?void 0:he.card_id)||d.card_group_id||0,_=(te==null?void 0:te.item_title)||d.item_title||d.item_id||"";F({...d,trigger_type:a,name:sa(d.name)?Rt(a,_):d.name,card_group_id:h,config_json:a==="review_missing_timeout"?ct(d.config_json):"{}",actions:Pt(a,h),variants:a==="review_missing_timeout"?[]:(qe=d.variants)!=null&&qe.length?d.variants:[{...At(),card_id:h}]})},mt=a=>{if(!d)return;const h=M.find(B=>B.cookie_id===(d.cookie_id||U)&&B.item_id===a),_=(h==null?void 0:h.item_title)||a;F({...d,item_id:a,item_title:(h==null?void 0:h.item_title)||"",item_keyword:_,name:sa(d.name)?Rt(p,_):d.name})},Ue=(C=d==null?void 0:d.variants)!=null&&C.length?d.variants:[At()],We=(a,h)=>{var B;if(!d)return;const _=Ue.map((oe,ue)=>ue===a?{...oe,...h}:oe);F({...d,variants:_,card_group_id:((B=_[0])==null?void 0:B.card_id)||0})},pt=()=>{if(!d)return;const a=Ue[Ue.length-1];F({...d,variants:[...Ue,{...At(),spec_name:je&&(a==null?void 0:a.spec_name)||"",spec_value:je&&(a==null?void 0:a.spec_value)||""}]})},kt=async()=>{var B,oe,ue,he,qe;if(!d)return;const a=d.trigger_type||"order_paid";if(!d.cookie_id){alert("请选择账号");return}const h=(B=d.variants)!=null&&B.length?d.variants:[];if(a!=="review_missing_timeout"){if(!h.length||h.some(we=>!we.card_id)){alert(a==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(je&&h.some(we=>!we.spec_name.trim()||!we.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(a==="review_missing_timeout"&&!(((ue=(oe=d.actions)==null?void 0:oe.find(ot=>ot.action_type==="send_text"))==null?void 0:ue.message_template)||"").trim()){alert("请填写求评价文案");return}const _=a==="review_missing_timeout"?[]:h.map(we=>({...we,spec_name:je?we.spec_name.trim():"",spec_value:je?we.spec_value.trim():"",delivery_count:Math.max(1,Number(we.delivery_count)||1),enabled:we.enabled!==!1}));try{await Qs({...d,trigger_type:a,name:(d.name||"").trim()||Rt(a,(te==null?void 0:te.item_title)||d.item_id||""),config_json:a==="review_missing_timeout"?ct(d.config_json):d.config_json||"{}",actions:(he=d.actions)!=null&&he.length?d.actions:Pt(a,((qe=_[0])==null?void 0:qe.card_id)||d.card_group_id||0),variants:_}),Ne(!1),await Promise.all([xe(),Re()]),alert("保存成功")}catch(we){console.error("保存自动化规则失败:",we),alert("保存失败:"+we.message)}},Ct=async a=>{if(confirm("确定删除该自动化规则吗?"))try{await vr(a),await xe(),alert("删除成功")}catch(h){alert("删除失败:"+h.message)}},St=async a=>{try{await Qs({...a,enabled:!a.enabled}),await xe()}catch(h){alert("操作失败:"+h.message)}},lt=async(a,h)=>{if(confirm(h==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":h==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await kr(a,h),await xe()}catch(B){alert("处理失败:"+B.message)}},rt=async(a,h)=>{if(confirm(h==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Cr(a,h),await xe()}catch(_){alert("处理失败:"+_.message)}},Lt=()=>{if(!U){alert("请先选择账号");return}H({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),S(!0)},nt=async()=>{var h,_,B;if(!I||!U)return;const a=I.type==="image"?!!((h=I.image_url)!=null&&h.trim()):!!((_=I.reply_content)!=null&&_.trim());if(!((B=I.keyword)!=null&&B.trim())||!a){alert("请填写关键词和回复内容");return}try{await Ir({...I,match_type:"fuzzy",enabled:!0},U),S(!1),await Pe(),alert("保存成功")}catch(oe){alert("保存失败:"+oe.message)}},ut=async a=>{if(!(!U||!confirm("确定删除该回复规则吗?")))try{await Ar(a,U),await Pe(),alert("删除成功")}catch(h){alert("删除失败:"+h.message)}},et=async(a=U)=>{if(!a){alert("请先选择账号");return}try{const h=await Fr(a);Ce({cookie_id:a,enabled:h.enabled,reply_content:h.reply_content,reply_once:h.reply_once,reply_image_url:h.reply_image_url||""})}catch{Ce({cookie_id:a,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}u(!0)},it=async()=>{if(!P.cookie_id){alert("请先选择账号");return}if(P.enabled&&!P.reply_content.trim()&&!P.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}try{await Br(P.cookie_id,{enabled:P.enabled,reply_content:P.reply_content,reply_once:P.reply_once,reply_image_url:P.reply_image_url}),u(!1),await le(),alert("保存成功")}catch(a){alert("保存失败:"+a.message)}},Ve=async a=>{if(confirm("确定删除该账号默认回复吗?"))try{await zr(a),await le(),alert("删除成功")}catch(h){alert("删除失败:"+h.message)}},ht=async a=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await Ur(a),alert("清空成功")}catch(h){alert("清空失败:"+h.message)}},n=l==="automation"?"新建自动化":l==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"min-w-0 space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap gap-3",children:[e.jsxs("select",{value:U,onChange:a=>{fe(a.target.value),T(1)},className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),Y.map(a=>e.jsx("option",{value:a.id,children:Jt(a)},a.id))]}),e.jsxs("button",{onClick:g,className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 hover:bg-gray-200 text-gray-700 flex items-center justify-center gap-2 whitespace-nowrap transition-colors",children:[e.jsx(Be,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:l==="automation"?()=>He("order_paid"):l==="reply"?Lt:()=>void et(),disabled:!U,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 whitespace-nowrap disabled:opacity-50",children:[e.jsx(Ye,{className:"w-4 h-4"}),n]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:is},{id:"reply",label:"关键词回复",icon:Et},{id:"default",label:"账号默认回复",icon:yt}].map(a=>{const h=a.icon;return e.jsxs("button",{onClick:()=>o(a.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${l===a.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(h,{className:"w-4 h-4"}),a.label]},a.id)})}),l==="automation"&&(D.runs.length>0||D.pending_tasks.length>0)&&e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(at,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[D.runs.map(a=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",a.cookie_id," · 订单 ",a.order_id||"-"," · 已记录发送 ",a.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:yn(a.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:a.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[ls(a,"continue")&&e.jsx("button",{onClick:()=>void lt(a.id,"continue"),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),ls(a,"retry")&&e.jsx("button",{onClick:()=>void lt(a.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),ls(a,"cancel")&&e.jsx("button",{onClick:()=>void lt(a.id,"cancel"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${a.id}`)),D.pending_tasks.map(a=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",a.cookie_id," · 延迟任务重试已达 ",a.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:a.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>void rt(a.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:()=>void rt(a.id,"dismiss"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${a.id}`))]})]}),l==="automation"&&e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-6 xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]",children:[e.jsxs("aside",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsx("h3",{className:"font-black text-gray-900 mb-1",children:"新建规则"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"先选自动化类型,再配置对应动作。"}),e.jsx("div",{className:"space-y-3",children:Wt.map(a=>{const h=tt[a],_=h.icon;return e.jsx("button",{type:"button",onClick:()=>He(a),className:`w-full text-left rounded-2xl border p-4 transition-colors ${aa(h.accent)}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/80 flex items-center justify-center shrink-0",children:e.jsx(_,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:h.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:h.description})]})]})},a)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"font-black text-gray-900",children:"筛选结果构成"}),e.jsxs("span",{className:"text-xs font-bold text-gray-400",children:["共 ",ye," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Wt.map(a=>{const h=tt[a],_=h.icon;return e.jsxs("div",{className:"flex items-center justify-between rounded-2xl bg-gray-50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:h.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:W[a]||0})]},a)})})]})]}),e.jsxs("section",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-surface-muted p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(Nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"搜索自动化规则",placeholder:"搜索规则名、商品名或商品 ID...",value:ge,onChange:a=>{L(a.target.value),T(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]}),e.jsxs("div",{className:"relative xl:w-52",children:[e.jsx(ya,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按自动化类型筛选",value:Z,onChange:a=>{me(a.target.value),T(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部自动化类型"}),Wt.map(a=>e.jsx("option",{value:a,children:tt[a].shortLabel},a))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:R,onChange:a=>{E(a.target.value),T(1)},className:"ios-input rounded-xl border-none bg-white px-4 py-2.5 text-sm shadow-sm xl:w-36",children:[e.jsx("option",{value:"all",children:"全部状态"}),e.jsx("option",{value:"enabled",children:"已启用"}),e.jsx("option",{value:"disabled",children:"已禁用"})]}),$e&&e.jsx("button",{type:"button",onClick:Le,className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white text-gray-500 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900",title:"清除筛选","aria-label":"清除筛选",children:e.jsx(Te,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs font-bold text-gray-400",children:[e.jsxs("span",{children:["找到 ",ye," 条规则"]}),G&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Be,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),G&&y.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(Be,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):y.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(is,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:$e?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:$e?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):y.map(a=>{const h=tt[a.trigger_type],_=h.icon;return e.jsx("article",{className:"bg-white rounded-xl border border-gray-100 p-5 shadow-sm hover:shadow-lg transition-all",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center shrink-0 ${aa(h.accent,!0)}`,children:e.jsx(_,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-lg font-black text-gray-900 truncate",children:a.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${vn(a.enabled)}`,children:a.enabled?"已启用":"已禁用"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-bold",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:h.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:a.item_title||a.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:Nn(a)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>ze(a),className:"px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-bold flex items-center gap-2",children:[e.jsx(_t,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>St(a),className:`px-4 py-2 rounded-xl text-sm font-bold ${a.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:a.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>Ct(a.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Je,{className:"w-4 h-4"})})]})]})},a.id)}),ye>0&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-gray-500",children:[e.jsxs("span",{children:["第 ",ee," / ",Math.max(m,1)," 页"]}),e.jsx("span",{className:"h-4 w-px bg-gray-200"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"sr-only",children:"每页显示数量"}),e.jsx("select",{value:se,onChange:a=>{ke(Number(a.target.value)),T(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(a=>e.jsxs("option",{value:a,children:[a," 条/页"]},a))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:ee<=1||G,onClick:()=>T(a=>Math.max(1,a-1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"上一页",title:"上一页",children:e.jsx(ys,{className:"h-4 w-4"})}),Se.map(a=>e.jsx("button",{type:"button",disabled:G,onClick:()=>T(a),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${a===ee?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${a} 页`,"aria-current":a===ee?"page":void 0,children:a},a)),e.jsx("button",{type:"button",disabled:ee>=m||G,onClick:()=>T(a=>Math.min(m,a+1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"下一页",title:"下一页",children:e.jsx(fs,{className:"h-4 w-4"})})]})]})]})]}),l==="reply"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(at,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[b.map(a=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-surface-subtle hover:bg-white hover:shadow-lg transition-all gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"px-3 py-1 bg-black text-white rounded-lg text-xs font-bold",children:"包含匹配"}),e.jsxs("h3",{className:"font-bold text-gray-900",children:["“",a.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:a.type==="image"&&a.image_url?a.image_url:a.reply_content})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>{H({...a}),S(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(_t,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ut(a.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Je,{className:"w-5 h-5"})})]})]},a.id)),b.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),l==="default"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(at,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[J.map(a=>{const h=j[a.id],_=!!(h!=null&&h.enabled);return e.jsxs("div",{className:`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${_?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-surface-subtle hover:bg-white hover:shadow-lg"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center ${_?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(yt,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg truncate",children:Jt(a)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${_?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:_?"已启用":"未启用"}),(h==null?void 0:h.reply_once)&&e.jsx("span",{className:"px-2 py-0.5 rounded-lg text-xs font-bold bg-purple-100 text-purple-700",children:"只回复一次"})]}),e.jsx("div",{className:"text-sm text-gray-600 line-clamp-2",children:_?h.reply_content||h.reply_image_url||"已配置默认回复":"未配置默认回复"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>void et(a.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(_t,{className:"w-4 h-4"})}),_&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void ht(a.id),className:"px-3 py-2 text-xs font-bold text-blue-600 hover:bg-blue-50 rounded-xl transition-colors",children:"清空记录"}),e.jsx("button",{onClick:()=>void Ve(a.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Je,{className:"w-5 h-5"})})]})]})]},a.id)}),J.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),De&&d&&Me.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"72rem",maxHeight:"92vh"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-black text-gray-900",children:d.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:$.description})]}),e.jsx("button",{onClick:()=>Ne(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] min-h-0",children:[e.jsxs("aside",{className:"bg-slate-900 text-white p-5 overflow-y-auto",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"选择自动化类型"}),e.jsx("div",{className:"space-y-3",children:Wt.map(a=>{const h=tt[a],_=h.icon,B=p===a;return e.jsx("button",{type:"button",onClick:()=>Xe(a),className:`w-full rounded-2xl p-4 text-left border transition-all ${B?"bg-white text-slate-950 border-white":"bg-white/5 text-white border-white/10 hover:bg-white/10"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{className:`w-5 h-5 mt-0.5 ${B?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:h.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${B?"text-gray-500":"text-gray-400"}`,children:h.description})]})]})},a)})}),e.jsxs("div",{className:"mt-6 rounded-2xl bg-white/5 border border-white/10 p-4",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"执行流程"}),e.jsx("div",{className:"space-y-3",children:$.flow.map((a,h)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white text-slate-950 text-xs font-black flex items-center justify-center",children:h+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:a})]},a))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-surface-subtle",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(os,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:"生效范围"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"规则名称"}),e.jsx("input",{type:"text",value:d.name||"",onChange:a=>F({...d,name:a.target.value}),placeholder:"不填时按类型和商品自动生成",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:d.cookie_id||"",onChange:a=>F({...d,cookie_id:a.target.value,item_id:"",item_title:"",item_keyword:""}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),Y.map(a=>e.jsx("option",{value:a.id,children:Jt(a)},a.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:d.item_id||"",onChange:a=>mt(a.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),Ae.map(a=>e.jsx("option",{value:a.item_id,children:a.item_title||a.item_id},`${a.cookie_id}-${a.item_id}`))]})]})]}),te&&p!=="review_missing_timeout"&&e.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:te.item_title||te.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${je?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:je?"多规格商品":"普通商品"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),p!=="review_missing_timeout"?e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nl,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:p==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:je?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:pt,className:"px-3 py-2 rounded-xl bg-gray-900 text-white text-xs font-bold hover:bg-black flex items-center gap-1.5",children:[e.jsx(Ye,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:Ue.map((a,h)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${je?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[je&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格名称"}),e.jsx("input",{value:a.spec_name,onChange:_=>We(h,{spec_name:_.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:套餐"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格值"}),e.jsx("input",{value:a.spec_value,onChange:_=>We(h,{spec_value:_.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:30天"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"卡密库存"}),e.jsxs("select",{value:a.card_id||"",onChange:_=>We(h,{card_id:Number(_.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),ce.filter(_=>_.enabled&&_.type!=="api").map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"每件份数"}),e.jsx("input",{type:"number",min:"1",max:"100",value:a.delivery_count,onChange:_=>We(h,{delivery_count:Math.max(1,Number(_.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),e.jsxs("div",{className:"md:col-span-full flex flex-wrap items-center gap-3 rounded-xl bg-gray-50 px-3 py-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-bold text-gray-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a.delay_override===!0,onChange:_=>We(h,{delay_override:_.target.checked}),className:"accent-brand"}),"覆盖卡密默认延时"]}),a.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:a.delay_seconds||0,onChange:_=>We(h,{delay_seconds:Math.max(0,Number(_.target.value)||0)}),className:"w-28 ios-input px-2 py-1.5 rounded-lg text-xs","aria-label":"动作延时秒数"}),e.jsx("span",{className:"text-xs text-gray-500",children:a.delay_override?`本动作延时 ${a.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:Ue.length===1,onClick:()=>F({...d,variants:Ue.filter((_,B)=>B!==h)}),className:"w-10 h-10 flex items-center justify-center rounded-lg text-red-500 hover:bg-red-50 disabled:opacity-25",title:"删除发货内容",children:e.jsx(Je,{className:"w-4 h-4"})})]},a.id||h))})]}):e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(ja,{className:"w-5 h-5 text-amber-600"}),e.jsx("h4",{className:"font-black text-gray-900",children:"求评价计划"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"发货后等待小时"}),e.jsx("input",{type:"number",min:"1",value:Number(ie.after_shipped_hours||72),onChange:a=>F({...d,config_json:ct(d.config_json,{after_shipped_hours:Math.max(1,Number(a.target.value)||72)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"再次求评间隔小时"}),e.jsx("input",{type:"number",min:"1",value:Number(ie.repeat_interval_hours||24),onChange:a=>F({...d,config_json:ct(d.config_json,{repeat_interval_hours:Math.max(1,Number(a.target.value)||24)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最多求评次数"}),e.jsx("input",{type:"number",min:"1",value:Number(ie.max_attempts||1),onChange:a=>F({...d,config_json:ct(d.config_json,{max_attempts:Math.max(1,Number(a.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),e.jsx("textarea",{value:((N=(i=d.actions)==null?void 0:i.find(a=>a.action_type==="send_text"))==null?void 0:N.message_template)||"",onChange:a=>{var h;return F({...d,actions:((h=d.actions)!=null&&h.length?d.actions:Pt("review_missing_timeout")).map(_=>_.action_type==="send_text"?{..._,message_template:a.target.value}:_)})},className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none"})]})]})]}),e.jsx("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[180px_1fr] gap-4 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"优先级"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"数字越小优先级越高;同一账号、商品和触发条件只执行优先级最高的一条规则。"}),e.jsx("input",{type:"number",value:d.priority||100,onChange:a=>F({...d,priority:Number(a.target.value)||100}),min:"1",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"h-[48px] flex items-center gap-3 px-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsx("input",{type:"checkbox",checked:d.enabled!==!1,onChange:a=>F({...d,enabled:a.target.checked}),className:"w-4 h-4 rounded"}),"启用规则"]})]})})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 bg-white flex gap-3",children:[e.jsx("button",{onClick:()=>Ne(!1),className:"flex-1 px-6 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200",children:"取消"}),e.jsxs("button",{onClick:kt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),c&&I&&Me.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:I.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>S(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:I.item_id||"",onChange:a=>H({...I,item_id:a.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),M.filter(a=>!U||a.cookie_id===U).map(a=>e.jsx("option",{value:a.item_id,children:a.item_title||a.item_id},`${a.cookie_id}-${a.item_id}`))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复类型"}),e.jsxs("select",{value:I.type||"text",onChange:a=>{const h=a.target.value;H({...I,type:h,reply_content:h==="text"?I.reply_content:"",image_url:h==="image"?I.image_url:""})},className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"文字"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关键词"}),e.jsx("input",{type:"text",value:I.keyword||"",onChange:a=>H({...I,keyword:a.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),I.type==="image"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{value:I.image_url||"",onChange:a=>H({...I,image_url:a.target.value}),placeholder:"https://...",className:"w-full ios-input px-4 py-3 rounded-xl"})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:I.reply_content||"",onChange:a=>H({...I,reply_content:a.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>S(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:nt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Kt,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),Q&&Me.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"账号默认回复"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"关键词和 AI 都未处理时,才会使用默认回复。"})]}),e.jsx("button",{onClick:()=>u(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:P.cookie_id,onChange:a=>Ce({...P,cookie_id:a.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),Y.map(a=>e.jsx("option",{value:a.id,children:Jt(a)},a.id))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"启用默认回复"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"启用后,未命中关键词时自动发送"})]}),e.jsx("button",{type:"button",onClick:()=>Ce({...P,enabled:!P.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${P.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${P.enabled?"translate-x-7":"translate-x-1"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:P.reply_content,onChange:a=>Ce({...P,reply_content:a.target.value}),placeholder:"输入默认回复内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复图片 URL(可选)"}),e.jsx("input",{type:"text",value:P.reply_image_url,onChange:a=>Ce({...P,reply_image_url:a.target.value}),placeholder:"https://example.com/image.jpg",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsxs("span",{children:["只回复一次",e.jsx("span",{className:"block text-xs text-gray-500 font-medium mt-1",children:"同一会话只发送一次默认回复"})]}),e.jsx("input",{type:"checkbox",checked:P.reply_once,onChange:a=>Ce({...P,reply_once:a.target.checked}),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>u(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:it,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Ge,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},Cn=t=>{const s=String(t.smtp_from||"").trim(),l=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);return{...t,smtp_from_name:t.smtp_from_name||(l?"":s),smtp_from_address:t.smtp_from_address||(l?s:t.smtp_user||""),smtp_use_tls:la(t.smtp_use_tls,!0),smtp_use_ssl:la(t.smtp_use_ssl,!1)}},la=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},Ns=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],gs=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return s},Pa=t=>{const s=Object.prototype.hasOwnProperty.call(t,"use_custom_smtp"),l=Ns.some(o=>String(t[o]??"").trim()!=="");return{...t,use_custom_smtp:s?gs(t.use_custom_smtp,!1):l}},ra=(t,s)=>{const l={...t,use_custom_smtp:!0};for(const o of Ns)String(l[o]??"").trim()===""&&s[o]!==void 0&&(l[o]=s[o]);return l.smtp_port||(l.smtp_port=587),l.smtp_from_address||(l.smtp_from_address=l.smtp_user||""),l.smtp_use_tls=gs(l.smtp_use_tls,!0),l.smtp_use_ssl=gs(l.smtp_use_ssl,!1),l},Sn=t=>{const s=Pa(t),l={to_email:String(s.to_email??"").trim(),use_custom_smtp:s.use_custom_smtp===!0};if(l.use_custom_smtp)for(const o of Ns)l[o]=s[o];return l},ft={bark:{label:"Bark",icon:jt,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"Ydisks闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app//这是测试推送内容","URL 路径里 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:Et,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:Et,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:Et,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:il,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:Kt,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的用户 ID",required:!0}],guide:{steps:["在 Telegram 搜索 @BotFather,发送 /newbot,按提示创建机器人,拿到 Bot Token","把你的 Bot 拉进一个群,或私聊它发一条消息","浏览器访问 https://api.telegram.org/bot<你的Token>/getUpdates",'从返回 JSON 里找 "chat":{"id":xxx},xxx 就是 Chat ID(群是负数,私聊是正数)'],urlFormat:"Bot Token: 123456:ABC-DEF... Chat ID: -1001234567890",note:"群聊需先把 Bot 设为管理员才能发消息。"}},email:{label:"邮件",icon:_a,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},$a=[{value:"account_offline",label:"掉线通知",description:"账号过期、断线或登录态失效"},{value:"account_recovered",label:"恢复通知",description:"自动恢复成功并重新在线"},{value:"account_disabled",label:"禁用通知",description:"连续失败、账密错误等导致账号停用"},{value:"security_verification",label:"风控验证",description:"滑块、人脸、扫码验证等安全校验"},{value:"delivery_result",label:"交易通知",description:"订单发货、卡密发送等交易结果"},{value:"token_renewal",label:"续期通知",description:"Cookie/token 续期和自动恢复过程"},{value:"system_error",label:"系统错误",description:"后台任务或系统级异常"}],Ln=t=>!t||t.length===0?"全部事件":t.map(l=>{var o;return((o=$a.find(x=>x.value===l))==null?void 0:o.label)||l}).join("、"),On=({isAdmin:t=!1})=>{const[s,l]=r.useState([]),[o,x]=r.useState(!0),[v,k]=r.useState(!1),[A,b]=r.useState(null),[O,j]=r.useState(!1),[V,Y]=r.useState(""),[pe,ce]=r.useState(null),[w,M]=r.useState({}),[de,G]=r.useState(!1),[X,U]=r.useState(!1),[fe,ge]=r.useState(!1),[L,K]=r.useState({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),ae=async()=>{x(!0);try{const m=await Aa();l(m.data||[])}catch(m){console.error("加载通知渠道失败",m)}finally{x(!1)}},Z=async()=>{try{const m=await La();M(Cn(m||{}))}catch(m){console.error("加载 SMTP 配置失败",m)}},me=async()=>{G(!0);try{await Oa({smtp_server:w.smtp_server||"",smtp_port:w.smtp_port||587,smtp_user:w.smtp_user||"",smtp_password:w.smtp_password||"",smtp_from_name:w.smtp_from_name||"",smtp_from_address:w.smtp_from_address||w.smtp_user||"",smtp_use_tls:w.smtp_use_tls!==!1,smtp_use_ssl:w.smtp_use_ssl===!0}),R("success","SMTP 配置已保存")}catch(m){R("error",(m==null?void 0:m.message)||"保存失败")}finally{G(!1)}};r.useEffect(()=>{ae(),t?Z():M({})},[t]);const R=(m,f)=>{ce({type:m,text:f}),window.setTimeout(()=>ce(null),3e3)},E=()=>{b(null),K({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),ge(!1),k(!0)},ee=m=>{b(m);const f=m.type==="email"?Pa({...m.config||{}}):null,W=f?f.use_custom_smtp===!0?ra(f,w):f:{...m.config||{}};K({name:m.name,type:m.type,enabled:m.enabled,config:W,event_types:m.event_types||[]}),ge(!1),k(!0)},T=async()=>{const m=ft[L.type];for(const W of m.fields)if(W.required&&!String(L.config[W.key]||"").trim()){R("error",`请填写 ${W.label}`);return}if(!L.name.trim()){R("error","请填写渠道名称");return}let f=L.config;if(L.type==="email"&&(f=Sn(L.config),f.use_custom_smtp)){const q=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([ne])=>!String(f[ne]||"").trim());if(q){R("error",`请填写 ${q[1]}`);return}}j(!0);try{const W={name:L.name.trim(),type:L.type,config:f,event_types:L.event_types,enabled:L.enabled};A?await Gs(A.id,W):await Dr(W),k(!1),await ae(),R("success",A?"已更新":"已创建")}catch(W){console.error("保存失败",W),R("error",(W==null?void 0:W.message)||"保存失败")}finally{j(!1)}},se=async m=>{if(confirm(`确认删除渠道「${m.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await Tr(m.id),await ae(),R("success","已删除")}catch(f){R("error",(f==null?void 0:f.message)||"删除失败")}},ke=async m=>{try{await Gs(m.id,{enabled:!m.enabled}),l(f=>f.map(W=>W.id===m.id?{...W,enabled:!W.enabled}:W))}catch(f){R("error",(f==null?void 0:f.message)||"切换失败")}},ye=async m=>{Y(m.id);try{await qr(m.id),R("success","测试通知已发送,请检查对应渠道")}catch(f){R("error",(f==null?void 0:f.message)||"发送失败")}finally{Y("")}},z=ft[L.type];return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"通知设置"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"配置通知渠道,账号异常时主动推送告警"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:ae,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Be,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:E,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"新建渠道"]})]})]}),e.jsx("div",{className:"ios-card rounded-xl p-5 bg-blue-50/50 border border-blue-100",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(jt,{className:"w-5 h-5 text-brand mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-gray-700 leading-6",children:["配置通知渠道并在「账号管理 → 编辑」里绑定后,以下事件会主动推送到该账号绑定的渠道:",e.jsxs("ul",{className:"mt-2 space-y-1 text-gray-600",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"账号 session 失效"}),":系统正在尝试自动恢复(警告)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"自动恢复失败"}),":账号已停止,需人工处理(严重)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),o?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(Ee,{className:"w-8 h-8 text-brand animate-spin"})}):s.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(jt,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"还没有配置任何通知渠道"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"点击右上角「新建渠道」开始配置"})]}):e.jsx("div",{className:"space-y-3",children:s.map(m=>{const f=ft[m.type]||ft.webhook,W=f.icon;return e.jsxs("div",{className:"ios-card rounded-xl p-5 bg-white flex items-center gap-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-gray-100 flex items-center justify-center flex-shrink-0",children:e.jsx(W,{className:"w-5 h-5 text-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-gray-900 truncate",children:m.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:f.label}),!m.enabled&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-400 font-medium",children:"已停用"})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 truncate",children:f.fields.map(q=>{var ne;return(ne=m.config)==null?void 0:ne[q.key]}).filter(Boolean).map((q,ne)=>e.jsx("span",{className:"mr-3",children:String(q).length>40?String(q).slice(0,40)+"…":String(q)},ne))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",Ln(m.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ke(m),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${m.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:m.enabled?"启用中":"已停用"}),e.jsxs("button",{onClick:()=>ye(m),disabled:V===m.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-brand hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[V===m.id?e.jsx(Ee,{className:"w-3 h-3 animate-spin"}):e.jsx(Kt,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{onClick:()=>ee(m),className:"w-8 h-8 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors",title:"编辑",children:e.jsx(fa,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>se(m),className:"w-8 h-8 rounded-lg bg-red-50 hover:bg-red-100 flex items-center justify-center text-red-500 transition-colors",title:"删除",children:e.jsx(Je,{className:"w-4 h-4"})})]})]},m.id)})}),t&&e.jsxs("section",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-extrabold text-gray-800",children:"SMTP 邮件配置"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"系统级邮件发送服务,供邮件通知渠道复用"})]}),e.jsx("div",{className:"p-2 rounded-xl bg-blue-50 text-blue-600",children:e.jsx(_a,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 服务器"}),e.jsx("input",{type:"text",value:w.smtp_server||"",onChange:m=>M({...w,smtp_server:m.target.value}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 端口"}),e.jsx("input",{type:"number",value:w.smtp_port||587,onChange:m=>M({...w,smtp_port:parseInt(m.target.value)||587}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱"}),e.jsx("input",{type:"email",value:w.smtp_user||"",onChange:m=>M({...w,smtp_user:m.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"邮箱密码 / 授权码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:X?"text":"password",value:w.smtp_password||"",onChange:m=>M({...w,smtp_password:m.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>U(!X),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:X?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:w.smtp_from_name||"",onChange:m=>M({...w,smtp_from_name:m.target.value}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱地址"}),e.jsx("input",{type:"email",value:w.smtp_from_address||w.smtp_user||"",onChange:m=>M({...w,smtp_from_address:m.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:w.smtp_use_tls!==!1,onChange:m=>M({...w,smtp_use_tls:m.target.checked,smtp_use_ssl:m.target.checked?!1:w.smtp_use_ssl})}),"STARTTLS(常用于 587 端口)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:w.smtp_use_ssl===!0,onChange:m=>M({...w,smtp_use_ssl:m.target.checked,smtp_use_tls:m.target.checked?!1:w.smtp_use_tls})}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:me,disabled:de,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[de?e.jsx(Ee,{className:"w-4 h-4 animate-spin"}):e.jsx(Ge,{className:"w-4 h-4"}),de?"保存中...":"保存 SMTP 配置"]})]}),v&&Me.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"36rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:A?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:()=>k(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Te,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道名称"}),e.jsx("input",{type:"text",value:L.name,onChange:m=>K({...L,name:m.target.value}),placeholder:"例如:我的 Bark",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道类型"}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:Object.keys(ft).map(m=>{const f=ft[m],W=f.icon,q=L.type===m;return e.jsxs("button",{type:"button",onClick:()=>K({...L,type:m,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${q?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(W,{className:`w-5 h-5 ${q?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${q?"text-brand":"text-gray-600"}`,children:f.label})]},m)})})]}),e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jt,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",z.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:z.guide.steps.map((m,f)=>e.jsx("li",{children:m},f))}),z.guide.urlFormat&&e.jsxs("div",{className:"text-xs text-amber-900/90",children:[e.jsx("span",{className:"font-bold",children:"格式示例:"}),e.jsx("code",{className:"mt-1 block bg-amber-100/70 px-2.5 py-1.5 rounded-lg break-all font-mono text-[11px]",children:z.guide.urlFormat})]}),z.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",z.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:z.fields.map(m=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[m.label,m.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{type:m.type==="password"?"password":m.type==="number"?"number":"text",value:String(L.config[m.key]||""),onChange:f=>K({...L,config:{...L.config,[m.key]:f.target.value}}),placeholder:m.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),m.help&&e.jsx("p",{className:"text-xs text-gray-500",children:m.help})]},m.key))}),L.type==="email"&&e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-blue-100 bg-blue-50/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"SMTP 来源"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-gray-500",children:L.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:()=>{const m=L.config.use_custom_smtp===!0;K({...L,config:m?{...L.config,use_custom_smtp:!1}:ra(L.config,w)})},className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${L.config.use_custom_smtp===!0?"bg-brand":"bg-gray-300"}`,"aria-label":"使用独立 SMTP",children:e.jsx("span",{className:`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${L.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),L.config.use_custom_smtp===!0&&e.jsxs("div",{className:"space-y-4 border-t border-blue-100 bg-white/80 p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 服务器 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:String(L.config.smtp_server||""),onChange:m=>K({...L,config:{...L.config,smtp_server:m.target.value}}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 端口 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",value:String(L.config.smtp_port||587),onChange:m=>K({...L,config:{...L.config,smtp_port:m.target.value}}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["登录邮箱 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(L.config.smtp_user||""),onChange:m=>K({...L,config:{...L.config,smtp_user:m.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["密码 / 授权码 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:fe?"text":"password",value:String(L.config.smtp_password||""),onChange:m=>K({...L,config:{...L.config,smtp_password:m.target.value}}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>ge(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:fe?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:String(L.config.smtp_from_name||""),onChange:m=>K({...L,config:{...L.config,smtp_from_name:m.target.value}}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["发件邮箱地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(L.config.smtp_from_address||""),onChange:m=>K({...L,config:{...L.config,smtp_from_address:m.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:L.config.smtp_use_tls!==!1,onChange:m=>K({...L,config:{...L.config,smtp_use_tls:m.target.checked,smtp_use_ssl:m.target.checked?!1:L.config.smtp_use_ssl}})}),"STARTTLS(常用于 587)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:L.config.smtp_use_ssl===!0,onChange:m=>K({...L,config:{...L.config,smtp_use_ssl:m.target.checked,smtp_use_tls:m.target.checked?!1:L.config.smtp_use_tls}})}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"通知内容"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"不选择表示接收全部通知;选择后仅接收勾选类型。"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:$a.map(m=>{const f=L.event_types.includes(m.value);return e.jsxs("button",{type:"button",onClick:()=>{const W=f?L.event_types.filter(q=>q!==m.value):[...L.event_types,m.value];K({...L,event_types:W})},className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${f?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center ${f?"bg-brand border-brand":"border-gray-300"}`,children:f&&e.jsx(Qe,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${f?"text-brand":"text-gray-800"}`,children:m.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:m.description})]},m.value)})})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>K({...L,enabled:!L.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${L.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform ${L.enabled?"translate-x-5":""}`})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>k(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"取消"}),e.jsxs("button",{onClick:T,disabled:O,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[O?e.jsx(Ee,{className:"w-4 h-4 animate-spin"}):e.jsx(Qe,{className:"w-4 h-4"}),O?"保存中...":"保存"]})]})]})}),document.body),pe&&e.jsxs("div",{className:`fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in text-white ${pe.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[pe.type==="success"?e.jsx(Qe,{className:"w-4 h-4"}):e.jsx(Te,{className:"w-4 h-4"}),pe.text]})]})},Ea=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["流汗","https://img.alicdn.com/imgextra/i4/O1CN01BU3NZ21gdcSjkqnST_!!6000000004165-2-tps-980-980.png_110x10000.jpg_.webp"],["憨笑","https://img.alicdn.com/imgextra/i2/O1CN01Pee9Ql1SJ661eH9By_!!6000000002225-2-tps-980-980.png_110x10000.jpg_.webp"],["耶","https://img.alicdn.com/imgextra/i2/O1CN01pFicsL1ipBhIqzcgs_!!6000000004461-2-tps-980-980.png_110x10000.jpg_.webp"],["奋斗","https://img.alicdn.com/imgextra/i3/O1CN01ZhQ4AV25xBmTK3CnF_!!6000000007592-2-tps-980-980.png_110x10000.jpg_.webp"],["咒骂","https://img.alicdn.com/imgextra/i3/O1CN01r1Zh9927QKb4pnf7k_!!6000000007791-2-tps-980-980.png_110x10000.jpg_.webp"],["疑问","https://img.alicdn.com/imgextra/i4/O1CN01UZqbzt29MmlNctCQS_!!6000000008054-2-tps-980-980.png_110x10000.jpg_.webp"],["嘘","https://img.alicdn.com/imgextra/i1/O1CN01qBlYkM1ojaYF75On5_!!6000000005261-2-tps-980-980.png_110x10000.jpg_.webp"],["晕","https://img.alicdn.com/imgextra/i2/O1CN014zhM2h1wPuSUFoMwV_!!6000000006301-2-tps-980-980.png_110x10000.jpg_.webp"],["开心到模糊","https://img.alicdn.com/imgextra/i1/O1CN01T1Dy271j6akZWo7Vr_!!6000000004499-2-tps-980-980.png_110x10000.jpg_.webp"],["衰","https://img.alicdn.com/imgextra/i1/O1CN01aOXsNr1LmgMvtyzOO_!!6000000001342-2-tps-980-980.png_110x10000.jpg_.webp"],["委屈","https://img.alicdn.com/imgextra/i2/O1CN013J0bMk1QNYih3UFTk_!!6000000001964-2-tps-980-980.png_110x10000.jpg_.webp"],["再见","https://img.alicdn.com/imgextra/i2/O1CN01IHKsQx1UdpFgeTHcA_!!6000000002541-2-tps-980-980.png_110x10000.jpg_.webp"],["鼓掌","https://img.alicdn.com/imgextra/i4/O1CN01DHxB5s1G1RRBxekIu_!!6000000000562-2-tps-980-980.png_110x10000.jpg_.webp"],["吐","https://img.alicdn.com/imgextra/i1/O1CN01xyVxH21LNUaMgW4hh_!!6000000001287-2-tps-980-980.png_110x10000.jpg_.webp"],["坏笑","https://img.alicdn.com/imgextra/i1/O1CN01zV7opv1bIU6iI8OhM_!!6000000003442-2-tps-980-980.png_110x10000.jpg_.webp"],["抠鼻","https://img.alicdn.com/imgextra/i1/O1CN01QOanju1sNqCrtYstu_!!6000000005755-2-tps-980-980.png_110x10000.jpg_.webp"],["叹气","https://img.alicdn.com/imgextra/i3/O1CN01RElx7R1QD1c8ZN07f_!!6000000001941-2-tps-980-980.png_110x10000.jpg_.webp"],["无聊","https://img.alicdn.com/imgextra/i2/O1CN01d91LnZ1UJDQjKCouC_!!6000000002496-2-tps-980-980.png_110x10000.jpg_.webp"],["思考","https://img.alicdn.com/imgextra/i2/O1CN01wQjg2f1tO84ZWitn9_!!6000000005891-2-tps-980-980.png_110x10000.jpg_.webp"],["呆","https://img.alicdn.com/imgextra/i1/O1CN01GLqBWC1DGbhqmpD2L_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["哇哦","https://img.alicdn.com/imgextra/i2/O1CN01MtLpS21qRO2bnAA5k_!!6000000005492-2-tps-980-980.png_110x10000.jpg_.webp"],["飞吻","https://img.alicdn.com/imgextra/i4/O1CN01q1WpFE25ljsNKjvHX_!!6000000007567-2-tps-980-980.png_110x10000.jpg_.webp"],["好喜欢","https://img.alicdn.com/imgextra/i2/O1CN01mD4iQM1O57XyQ5SHD_!!6000000001653-2-tps-980-980.png_110x10000.jpg_.webp"],["拜托","https://img.alicdn.com/imgextra/i4/O1CN01SQgrTH1dzCH3pIyRN_!!6000000003806-2-tps-980-980.png_110x10000.jpg_.webp"],["真棒","https://img.alicdn.com/imgextra/i2/O1CN017fcAmd1SCgYCj9Upk_!!6000000002211-2-tps-980-980.png_110x10000.jpg_.webp"],["流鼻血","https://img.alicdn.com/imgextra/i3/O1CN0139JscY1rC6RS9GR4j_!!6000000005594-2-tps-980-980.png_110x10000.jpg_.webp"],["费解","https://img.alicdn.com/imgextra/i1/O1CN01FqAVvR1tyJMPj13ie_!!6000000005970-2-tps-980-980.png_110x10000.jpg_.webp"],["秃头","https://img.alicdn.com/imgextra/i4/O1CN01ZF4bV11thMhqm2Z1h_!!6000000005933-2-tps-980-980.png_110x10000.jpg_.webp"],["嘿哈","https://img.alicdn.com/imgextra/i4/O1CN01ObcOw61FOVlvQg7Mw_!!6000000000477-2-tps-980-980.png_110x10000.jpg_.webp"],["吃土","https://img.alicdn.com/imgextra/i3/O1CN01Z6nJ1b1ZYr22YseHN_!!6000000003207-2-tps-980-980.png_110x10000.jpg_.webp"],["机智","https://img.alicdn.com/imgextra/i1/O1CN01rfKY351zDUZJlBiir_!!6000000006680-2-tps-980-980.png_110x10000.jpg_.webp"],["举杯","https://img.alicdn.com/imgextra/i4/O1CN01R2tn4F1mn8NuEIE8J_!!6000000004998-2-tps-980-980.png_110x10000.jpg_.webp"],["握手","https://img.alicdn.com/imgextra/i4/O1CN01NDcA251JDkvuFhSDb_!!6000000000995-2-tps-980-980.png_110x10000.jpg_.webp"],["挥手","https://img.alicdn.com/imgextra/i4/O1CN01iVN0ht1TmEuSwauGt_!!6000000002424-2-tps-980-980.png_110x10000.jpg_.webp"],["yeah","https://img.alicdn.com/imgextra/i3/O1CN01opt7hh27Wk8omjR4t_!!6000000007805-2-tps-980-980.png_110x10000.jpg_.webp"],["666","https://img.alicdn.com/imgextra/i3/O1CN01YRWDPF1OjQOpXeuTC_!!6000000001741-2-tps-980-980.png_110x10000.jpg_.webp"],["棒","https://img.alicdn.com/imgextra/i3/O1CN01agprvs1HU7rPRxOnB_!!6000000000760-2-tps-980-980.png_110x10000.jpg_.webp"],["爱你","https://img.alicdn.com/imgextra/i1/O1CN01SzxgcH1GSSo6Lwmwk_!!6000000000621-2-tps-980-980.png_110x10000.jpg_.webp"],["比心","https://img.alicdn.com/imgextra/i1/O1CN01YHZ39t1DeQIeb0TWQ_!!6000000000241-2-tps-980-980.png_110x10000.jpg_.webp"],["感谢","https://img.alicdn.com/imgextra/i3/O1CN01ywacF81baLYNeyK1n_!!6000000003481-2-tps-980-980.png_110x10000.jpg_.webp"],["拍手","https://img.alicdn.com/imgextra/i4/O1CN01wbj4wv1K7ArD9AU44_!!6000000001116-2-tps-980-980.png_110x10000.jpg_.webp"],["拉钩","https://img.alicdn.com/imgextra/i1/O1CN01dePkKH1HOd6ivAcu8_!!6000000000748-2-tps-980-980.png_110x10000.jpg_.webp"],["没钱","https://img.alicdn.com/imgextra/i3/O1CN01qhxGjp1zD2AfqmWx5_!!6000000006679-2-tps-980-980.png_110x10000.jpg_.webp"],["小刀","https://img.alicdn.com/imgextra/i3/O1CN01tFVx5Y1T2thPjhR6b_!!6000000002325-2-tps-980-980.png_110x10000.jpg_.webp"],["不刀","https://img.alicdn.com/imgextra/i4/O1CN01zTxff61clcvOcTS3n_!!6000000003641-2-tps-980-980.png_110x10000.jpg_.webp"],["同出","https://img.alicdn.com/imgextra/i3/O1CN01URKas6249R8ozS98O_!!6000000007348-2-tps-980-980.png_110x10000.jpg_.webp"],["递钱","https://img.alicdn.com/imgextra/i4/O1CN01PzhgV51FLlOaZHZ6n_!!6000000000471-2-tps-980-980.png_110x10000.jpg_.webp"],["数钱","https://img.alicdn.com/imgextra/i3/O1CN01CzXXvp23khkljToQH_!!6000000007294-2-tps-980-980.png_110x10000.jpg_.webp"],["打call","https://img.alicdn.com/imgextra/i1/O1CN01X7VUVm1il48IYv8Qw_!!6000000004452-2-tps-980-980.png_110x10000.jpg_.webp"],["号外","https://img.alicdn.com/imgextra/i2/O1CN01vg6xSM1Vxo9EKyfjR_!!6000000002720-2-tps-980-980.png_110x10000.jpg_.webp"],["包邮","https://img.alicdn.com/imgextra/i3/O1CN01yVS7ys24jA22oVZ2T_!!6000000007426-2-tps-980-980.png_110x10000.jpg_.webp"],["求赞","https://img.alicdn.com/imgextra/i1/O1CN01Xwqi5A1giCQMRcX6N_!!6000000004175-2-tps-980-980.png_110x10000.jpg_.webp"],["非主流","https://img.alicdn.com/imgextra/i1/O1CN013wyI1j1hlEfDUoATI_!!6000000004317-2-tps-980-980.png_110x10000.jpg_.webp"],["吃瓜","https://img.alicdn.com/imgextra/i1/O1CN01LLOFsh1UUCw0deZba_!!6000000002520-2-tps-980-980.png_110x10000.jpg_.webp"],["种草","https://img.alicdn.com/imgextra/i2/O1CN01ooeRC81hA8a4x9S3q_!!6000000004236-2-tps-980-980.png_110x10000.jpg_.webp"],["佛系","https://img.alicdn.com/imgextra/i4/O1CN01BYXEe321GMHMZ9w66_!!6000000006957-2-tps-980-980.png_110x10000.jpg_.webp"],["超便宜","https://img.alicdn.com/imgextra/i4/O1CN01mqgSZi1Er4rOIDiP7_!!6000000000404-2-tps-980-980.png_110x10000.jpg_.webp"],["拥抱","https://img.alicdn.com/imgextra/i1/O1CN01yuGD9c1hJkttfKHAm_!!6000000004257-2-tps-980-980.png_110x10000.jpg_.webp"],["摊手","https://img.alicdn.com/imgextra/i2/O1CN014AiIqE1o9repE6STR_!!6000000005183-2-tps-980-980.png_110x10000.jpg_.webp"],["举手","https://img.alicdn.com/imgextra/i1/O1CN01xizuHZ1WPkJCogbuj_!!6000000002781-2-tps-980-980.png_110x10000.jpg_.webp"],["蹲","https://img.alicdn.com/imgextra/i3/O1CN01Midjjn1FrMj2CWer6_!!6000000000540-2-tps-980-980.png_110x10000.jpg_.webp"],["跪了","https://img.alicdn.com/imgextra/i3/O1CN01F2y52j24E16L6RIjF_!!6000000007358-2-tps-980-980.png_110x10000.jpg_.webp"],["拜","https://img.alicdn.com/imgextra/i4/O1CN01Jldd1G1oXDrEHH2qr_!!6000000005234-2-tps-980-980.png_110x10000.jpg_.webp"],["排","https://img.alicdn.com/imgextra/i3/O1CN01uSUmYD1jD0IJf0UVU_!!6000000004513-2-tps-980-980.png_110x10000.jpg_.webp"],["旺财","https://img.alicdn.com/imgextra/i3/O1CN01A25Mv01DKjGseAmuP_!!6000000000198-2-tps-980-980.png_110x10000.jpg_.webp"],["招财猫","https://img.alicdn.com/imgextra/i3/O1CN01WmJ7Sr20EhDyp86Bd_!!6000000006818-2-tps-980-980.png_110x10000.jpg_.webp"],["酸了","https://img.alicdn.com/imgextra/i3/O1CN01UFgjn61JJi5Iqxdk7_!!6000000001008-2-tps-980-980.png_110x10000.jpg_.webp"],["鸭鸭","https://img.alicdn.com/imgextra/i3/O1CN01pHSCSQ1deaS8WDiqG_!!6000000003761-2-tps-980-980.png_110x10000.jpg_.webp"],["方了","https://img.alicdn.com/imgextra/i3/O1CN01br7g711whlu8xOPUt_!!6000000006340-2-tps-980-980.png_110x10000.jpg_.webp"],["白菜","https://img.alicdn.com/imgextra/i1/O1CN01KABFLt24WKwXjVp08_!!6000000007398-2-tps-980-980.png_110x10000.jpg_.webp"],["桃子","https://img.alicdn.com/imgextra/i1/O1CN01CQhhPH1vJfRjDGBv5_!!6000000006152-2-tps-980-980.png_110x10000.jpg_.webp"],["打包","https://img.alicdn.com/imgextra/i3/O1CN01oYOkUI1VT7c0ivZHV_!!6000000002653-2-tps-980-980.png_110x10000.jpg_.webp"],["沙发","https://img.alicdn.com/imgextra/i4/O1CN018qUFaE1DGbhqpMIit_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["南","https://img.alicdn.com/imgextra/i1/O1CN01ZSA6wg1PEZKf4h99R_!!6000000001809-2-tps-980-980.png_110x10000.jpg_.webp"],["盯","https://img.alicdn.com/imgextra/i4/O1CN01OWB1Gx1s01bzBhHN6_!!6000000005703-2-tps-980-980.png_110x10000.jpg_.webp"],["hot","https://img.alicdn.com/imgextra/i4/O1CN01DDD9uA22cAl7VDH7d_!!6000000007140-2-tps-980-980.png_110x10000.jpg_.webp"],["new","https://img.alicdn.com/imgextra/i3/O1CN01rRJXJo1qwzN4YnOHX_!!6000000005561-2-tps-980-980.png_110x10000.jpg_.webp"],["cool","https://img.alicdn.com/imgextra/i4/O1CN013bUubF2855qb2Qt5l_!!6000000007880-2-tps-980-980.png_110x10000.jpg_.webp"],["1","https://img.alicdn.com/imgextra/i1/O1CN01U8XG5y1Ie22frQHCQ_!!6000000000917-2-tps-980-980.png_110x10000.jpg_.webp"],["可","https://img.alicdn.com/imgextra/i2/O1CN01SMjtPG1iJaN17p94N_!!6000000004392-2-tps-980-980.png_110x10000.jpg_.webp"],["搬砖","https://img.alicdn.com/imgextra/i1/O1CN01GbqW6G1LOrm0Gllcb_!!6000000001290-2-tps-980-980.png_110x10000.jpg_.webp"],["菜狗","https://img.alicdn.com/imgextra/i2/O1CN01VtN0t91USNLmvfmol_!!6000000002516-2-tps-980-980.png_110x10000.jpg_.webp"],["开心面具","https://img.alicdn.com/imgextra/i3/O1CN017elkpk22EoYlBPKd3_!!6000000007089-2-tps-980-980.png_110x10000.jpg_.webp"],["快递","https://img.alicdn.com/imgextra/i2/O1CN01AmUZXk1d3wle5O8IJ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["裂开","https://img.alicdn.com/imgextra/i1/O1CN01BihwvO1a5N9bFt0LU_!!6000000003278-2-tps-980-980.png_110x10000.jpg_.webp"],["啤酒","https://img.alicdn.com/imgextra/i4/O1CN01jDkgEj1WvLdXUVBDx_!!6000000002850-2-tps-980-980.png_110x10000.jpg_.webp"],["瑞思拜","https://img.alicdn.com/imgextra/i4/O1CN011gR0Um1K3VgpYjPOi_!!6000000001108-2-tps-980-980.png_110x10000.jpg_.webp"],["小丑","https://img.alicdn.com/imgextra/i3/O1CN01jMikhO1NJUM15XKTf_!!6000000001549-2-tps-980-980.png_110x10000.jpg_.webp"],["爱心","https://img.alicdn.com/imgextra/i1/O1CN015RVSWf23s25eETJqO_!!6000000007310-2-tps-980-980.png_110x10000.jpg_.webp"]],In=t=>t,An=new Map(Ea.map(([t,s])=>[t,s])),na=t=>t.split(/(\[[^\]]+\])/g).map((s,l)=>{const o=s.startsWith("[")?An.get(s.slice(1,-1)):void 0;return o?e.jsx("img",{src:o,alt:s,title:s,className:"mx-0.5 inline-block h-7 w-7 align-middle"},l):e.jsx(xa.Fragment,{children:s},l)}),ia="ydisks.chat.account.v1",Rn=t=>{if(!t)return"";const s=new Date(t<1e10?t*1e3:t),l=new Date;return s.toDateString()===l.toDateString()?s.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},oa=t=>new Date(t<1e10?t*1e3:t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),Pn=()=>{const[t,s]=r.useState([]),[l,o]=r.useState(""),[x,v]=r.useState({}),[k,A]=r.useState(""),[b,O]=r.useState([]),[j,V]=r.useState(""),[Y,pe]=r.useState(!1),[ce,w]=r.useState(""),[M,de]=r.useState(!0),[G,X]=r.useState(!1),[U,fe]=r.useState(!1),[ge,L]=r.useState(!1),[K,ae]=r.useState(),[Z,me]=r.useState({}),[R,E]=r.useState({}),[ee,T]=r.useState(!1),[se,ke]=r.useState(!1),[ye,z]=r.useState(!1),[m,f]=r.useState(""),[W,q]=r.useState("connecting"),ne=r.useRef(""),be=r.useRef(""),ve=r.useRef(null),De=r.useRef({accountID:"",chatID:""}),Ne=r.useRef(!0),c=r.useRef(!1),S=r.useRef(null),Q=r.useRef(new Set);r.useEffect(()=>{ne.current=l},[l]),r.useEffect(()=>{be.current=k},[k]);const u=async g=>{const y=await ts(g,void 0,void 0,!0);return v(D=>({...D,[g]:y.sessions})),me(D=>({...D,[g]:y.next_cursor})),E(D=>({...D,[g]:y.has_more})),y.sessions};r.useEffect(()=>{let g=!1;return(async()=>{var D;de(!0);try{const[J,Se]=await Promise.all([Mt(),ps()]),Le=J.map(p=>{var $,ie;return{...p,runtime_state:(($=Se[p.id])==null?void 0:$.state)||(p.enabled?"connecting":"disabled"),runtime_connected:((ie=Se[p.id])==null?void 0:ie.connected)===!0}}).filter(p=>p.enabled),Ae=await Promise.all(Le.map(async p=>[p.id,await ts(p.id)]));if(g)return;s(Le),v(Object.fromEntries(Ae.map(([p,$])=>[p,$.sessions]))),me(Object.fromEntries(Ae.map(([p,$])=>[p,$.next_cursor]))),E(Object.fromEntries(Ae.map(([p,$])=>[p,$.has_more])));const te=window.localStorage.getItem(ia)||"",je=Le.some(p=>p.id===te)?te:((D=Le[0])==null?void 0:D.id)||"";o(je)}catch(J){g||f(J instanceof Error?J.message:"加载聊天数据失败")}finally{g||de(!1)}})(),()=>{g=!0}},[]),r.useEffect(()=>{let g=!1,y=0,D=null;const J=async()=>{D=new AbortController;try{const Se=await ps({signal:D.signal,timeoutMs:1e4});g||s($e=>$e.map(Le=>{var Ae,te;return{...Le,runtime_state:((Ae=Se[Le.id])==null?void 0:Ae.state)||Le.runtime_state,runtime_connected:((te=Se[Le.id])==null?void 0:te.connected)??Le.runtime_connected}}))}catch{}finally{g||(y=window.setTimeout(J,3e3))}};return y=window.setTimeout(J,3e3),()=>{g=!0,window.clearTimeout(y),D==null||D.abort()}},[]),r.useEffect(()=>{if(!l)return;window.localStorage.setItem(ia,l);const g=x[l]||[];A(y=>{var D;return g.some(J=>J.chat_id===y)?y:((D=g[0])==null?void 0:D.chat_id)||""})},[l,x]),r.useEffect(()=>{!l||Q.current.has(l)||(Q.current.add(l),u(l).catch(g=>{f(g instanceof Error?g.message:"同步会话失败")}))},[l]),r.useEffect(()=>{if(!l||!k){O([]);return}const g=new AbortController;return X(!0),Promise.all([ms(l,k,void 0,void 0,{signal:g.signal}),Us(l,k)]).then(([y])=>{O(y.messages),L(y.has_more),ae(y.next_cursor),y.session&&v(D=>({...D,[l]:(D[l]||[]).map(J=>{var Se;return J.chat_id===((Se=y.session)==null?void 0:Se.chat_id)?y.session:J})})),v(D=>({...D,[l]:(D[l]||[]).map(J=>J.chat_id===k?{...J,unread_count:0}:J)}))}).catch(y=>{g.signal.aborted||f(y instanceof Error?y.message:"加载消息失败")}).finally(()=>{g.signal.aborted||X(!1)}),()=>g.abort()},[l,k]);const d=async()=>{var D;if(!l||!k||U||!ge)return;const g=ve.current,y=(g==null?void 0:g.scrollHeight)||0;c.current=!0,fe(!0),f("");try{const J=(D=b[0])==null?void 0:D.id,Se=await ms(l,k,K,J);O($e=>{const Le=new Set($e.map(Ae=>Ae.message_key));return[...Se.messages.filter(Ae=>!Le.has(Ae.message_key)),...$e]}),L(Se.has_more),ae(Se.next_cursor),requestAnimationFrame(()=>{g&&(g.scrollTop+=g.scrollHeight-y)})}catch(J){c.current=!1,f(J instanceof Error?J.message:"加载历史消息失败")}finally{fe(!1)}};r.useEffect(()=>{let g=!1,y=0,D=0,J=null;const Se=()=>{if(g)return;q("connecting");const $e=window.location.protocol==="https:"?"wss:":"ws:";J=new WebSocket(`${$e}//${window.location.host}/api/chat/ws`),J.onopen=()=>{D=0,q("online")},J.onmessage=Le=>{try{const te=JSON.parse(Le.data).message;if(!te)return;const je=te.account_id;v(p=>{const $=p[je]||[];return $.some(re=>re.chat_id===te.chat_id)?{...p,[je]:$.map(re=>re.chat_id===te.chat_id?{...re,last_message:te.content,last_message_at:te.sent_at,unread_count:te.direction==="incoming"&&(ne.current!==je||be.current!==te.chat_id)?re.unread_count+1:re.unread_count}:re).sort((re,ze)=>ze.last_message_at-re.last_message_at)}:(u(je),p)}),ne.current===je&&be.current===te.chat_id&&(O(p=>{const $=p.findIndex(ie=>ie.message_key===te.message_key);return $>=0?p.map((ie,re)=>re===$?te:ie):[...p,te]}),te.direction==="incoming"&&Us(je,te.chat_id))}catch{}},J.onclose=()=>{if(g)return;q("offline");const Le=Math.min(15e3,1e3*2**Math.min(D++,4));y=window.setTimeout(Se,Le)},J.onerror=()=>J==null?void 0:J.close()};return Se(),()=>{g=!0,window.clearTimeout(y),J==null||J.close()}},[]);const F=()=>{const g=ve.current;if(!g)return;const y=g.scrollHeight-g.scrollTop-g.clientHeight;Ne.current=y<=48};r.useLayoutEffect(()=>{const g=De.current.accountID!==l||De.current.chatID!==k;De.current={accountID:l,chatID:k},g&&(Ne.current=!0);const y=ve.current;if(y){if(c.current){c.current=!1;return}(G||Ne.current)&&(y.scrollTop=y.scrollHeight)}},[l,k,b,G]);const I=t.find(g=>g.id===l),H=x[l]||[],P=H.find(g=>g.chat_id===k),Ce=r.useMemo(()=>{const g=j.trim().toLowerCase();return H.filter(y=>Y&&y.unread_count<=0?!1:g?[y.buyer_name,y.buyer_id,y.item_title,y.last_message].some(D=>(D||"").toLowerCase().includes(g)):!0)},[H,j,Y]),Re=g=>(x[g]||[]).reduce((y,D)=>y+D.unread_count,0),xe=async()=>{if(!(!l||ee||!R[l])){T(!0),f("");try{const g=await ts(l,Z[l],void 0,!0);v(y=>({...y,[l]:g.sessions})),me(y=>({...y,[l]:g.next_cursor})),E(y=>({...y,[l]:g.has_more}))}catch(g){f(g instanceof Error?g.message:"加载历史联系人失败")}finally{T(!1)}}},Pe=async()=>{const g=ce.trim();if(!(!g||!P||!l||ye)){z(!0),f("");try{const y=await $l({account_id:l,chat_id:P.chat_id,buyer_id:P.buyer_id,buyer_name:P.buyer_name,item_id:P.item_id,item_title:P.item_title,text:g});w(""),O(D=>D.some(J=>J.message_key===y.message.message_key)?D.map(J=>J.message_key===y.message.message_key?y.message:J):[...D,y.message])}catch(y){f(y instanceof Error?y.message:"消息发送失败"),Pl(l,P.chat_id).then(O)}finally{z(!1)}}},le=async g=>{if(!(!g||!P||!l||ye)){z(!0),f("");try{const y=await El({account_id:l,chat_id:P.chat_id,buyer_id:P.buyer_id,buyer_name:P.buyer_name,buyer_avatar_url:P.buyer_avatar_url,item_id:P.item_id,item_title:P.item_title,image:g});O(D=>D.some(J=>J.message_key===y.message.message_key)?D.map(J=>J.message_key===y.message.message_key?y.message:J):[...D,y.message])}catch(y){f(y instanceof Error?y.message:"图片发送失败")}finally{z(!1),S.current&&(S.current.value="")}}};return M?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(Ee,{className:"h-8 w-8 animate-spin text-sky-500"})}):e.jsxs("section",{className:"flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat",children:[e.jsxs("header",{className:"border-b border-slate-200 bg-slate-50/70 px-5 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-slate-950",children:"在线聊天"}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"复用账号实时连接,消息按账号完全隔离"})]}),e.jsxs("div",{className:`flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-bold ${W==="online"?"bg-emerald-50 text-emerald-700":W==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[W==="online"?e.jsx(ol,{className:"h-3.5 w-3.5"}):e.jsx(cl,{className:"h-3.5 w-3.5"}),W==="online"?"实时同步中":W==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:t.map(g=>{const y=g.id===l,D=Re(g.id),J=g.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":y,onClick:()=>o(g.id),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${y?"border-sky-500 text-sky-700":"border-transparent text-slate-500 hover:text-slate-900"}`,children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${J?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:g.nickname||g.remark||g.id}),D>0&&e.jsx("span",{className:"min-w-5 rounded-full bg-red-500 px-1.5 py-0.5 text-[10px] text-white",children:D>99?"99+":D})]},g.id)})})]}),t.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(rs,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-800",children:"暂无启用账号"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"先在账号管理中启用账号,聊天会话会自动出现。"})]}):e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-slate-200 bg-slate-50/40",children:[e.jsxs("div",{className:"space-y-3 border-b border-slate-200 p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Nt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:j,onChange:g=>V(g.target.value),placeholder:"搜索用户、商品或消息",className:"h-10 w-full rounded-xl border border-slate-200 bg-white pl-9 pr-3 text-sm outline-none transition focus:border-sky-400 focus:ring-2 focus:ring-sky-100"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>pe(g=>!g),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${Y?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:Y?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:()=>void u(l),className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(Be,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[Ce.map(g=>e.jsxs("button",{type:"button",onClick:()=>A(g.chat_id),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${g.chat_id===k?"bg-white shadow-chat-active":"hover:bg-white/80"}`,children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500",children:g.buyer_avatar_url?e.jsx("img",{src:g.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(Vt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-extrabold text-slate-900",children:g.buyer_name||`用户 ${g.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:Rn(g.last_message_at)})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs text-slate-500",children:g.last_message||"暂无消息"}),g.unread_count>0&&e.jsx("span",{className:"ml-auto min-w-5 shrink-0 rounded-full bg-red-500 px-1.5 py-0.5 text-center text-[10px] font-bold text-white",children:g.unread_count})]}),g.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",g.item_title]})]})]},g.chat_id)),Ce.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),R[l]&&!j&&!Y&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:()=>void xe(),disabled:ee,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-xs font-bold text-slate-500 shadow-sm hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[ee&&e.jsx(Ee,{className:"h-3.5 w-3.5 animate-spin"}),ee?"正在加载":"加载更多历史联系人"]})})]})]}),e.jsx("main",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle",children:P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-950",children:P.buyer_name||P.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",P.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(I==null?void 0:I.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(I==null?void 0:I.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:ve,onScroll:F,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:G?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Ee,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[ge&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:()=>void d(),disabled:U,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-1.5 text-xs font-bold text-slate-500 shadow-sm transition hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[U&&e.jsx(Ee,{className:"h-3.5 w-3.5 animate-spin"}),U?"正在加载":"加载更早消息"]})}),b.map(g=>{const y=g.direction==="outgoing";return g.message_type==="system"?e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500",children:[na(g.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:oa(g.sent_at)})]})},g.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${y?"justify-end":"justify-start"}`,children:[!y&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:P.buyer_avatar_url?e.jsx("img",{src:P.buyer_avatar_url,alt:P.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(Vt,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${y?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:y?(I==null?void 0:I.nickname)||(I==null?void 0:I.remark)||"我":P.buyer_name||g.sender_name||P.buyer_id}),g.message_type==="image"?e.jsx("a",{href:g.content,target:"_blank",rel:"noreferrer",className:`block overflow-hidden rounded-2xl border bg-white p-1 shadow-sm ${y?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:g.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):g.message_type==="video"?e.jsx("video",{src:g.content,controls:!0,preload:"metadata",className:"max-h-80 max-w-full rounded-2xl bg-black"}):e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm ${y?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:na(g.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[oa(g.sent_at),y&&(g.status==="failed"?e.jsx(at,{className:"h-3 w-3 text-red-500"}):g.status==="sent"?e.jsx(dl,{className:"h-3 w-3 text-sky-500"}):e.jsx(Qe,{className:"h-3 w-3"}))]})]}),y&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:I!=null&&I.avatar_url?e.jsx("img",{src:I.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(Vt,{className:"m-2 h-5 w-5 text-sky-600"})})]},g.message_key)})]})}),m&&e.jsx("div",{className:"border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:m}),e.jsxs("div",{className:"relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>ke(g=>!g),disabled:ye||(I==null?void 0:I.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"闲鱼表情",children:e.jsx(xl,{className:"h-5 w-5"})}),se&&e.jsxs("div",{className:"absolute bottom-11 left-0 z-30 w-[360px] rounded-2xl border border-slate-200 bg-white p-3 shadow-2xl",children:[e.jsx("div",{className:"mb-2 text-xs font-bold text-slate-500",children:"全部表情"}),e.jsx("div",{className:"grid max-h-72 grid-cols-8 gap-1 overflow-y-auto",children:Ea.map(([g,y])=>e.jsx("button",{type:"button",title:`[${g}]`,onClick:()=>{w(D=>D+`[${g}]`),ke(!1)},className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:In(y),alt:`[${g}]`,className:"h-8 w-8 object-contain"})},g))})]})]}),e.jsx("input",{ref:S,type:"file",accept:"image/*",className:"hidden",onChange:g=>{var y;return void le((y=g.target.files)==null?void 0:y[0])}}),e.jsx("button",{type:"button",onClick:()=>{var g;return(g=S.current)==null?void 0:g.click()},disabled:ye||(I==null?void 0:I.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 transition hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"发送图片(最大 10MB)",children:e.jsx(ml,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-2 transition focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100",children:[e.jsx("textarea",{value:ce,onChange:g=>w(g.target.value),rows:2,maxLength:2e3,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),Pe())},disabled:(I==null?void 0:I.runtime_state)!=="online",placeholder:(I==null?void 0:I.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行":"账号离线,暂时无法发送",className:"max-h-32 min-h-12 flex-1 resize-none bg-transparent px-2 py-2 text-sm leading-6 outline-none disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:()=>void Pe(),disabled:!ce.trim()||ye||(I==null?void 0:I.runtime_state)!=="online",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:shadow-none","aria-label":"发送消息",children:ye?e.jsx(Ee,{className:"h-4 w-4 animate-spin"}):e.jsx(Kt,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(rs,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-700",children:"选择一个用户开始聊天"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"该账号的新消息会实时出现在左侧列表。"})]})})]})]})},Da="ydisks.sidebar.v1",$n=()=>{try{return window.localStorage.getItem(Da)==="collapsed"}catch{return!1}},En=t=>{try{window.localStorage.setItem(Da,t?"collapsed":"expanded")}catch{}},Ta={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/chat":"chat","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},ca=Object.fromEntries(Object.entries(Ta).map(([t,s])=>[s,t])),da=()=>Ta[window.location.pathname]||"dashboard",Dn=()=>{const[t,s]=r.useState(!1),[l,o]=r.useState(!1),[x,v]=r.useState(da),[k,A]=r.useState(!0),[b,O]=r.useState(!1),[j,V]=r.useState(""),[Y,pe]=r.useState(""),[ce,w]=r.useState(!1),[M,de]=r.useState(""),[G,X]=r.useState(""),[U,fe]=r.useState(""),[ge,L]=r.useState(!1),[K,ae]=r.useState(""),[Z,me]=r.useState(),[R,E]=r.useState($n),ee=z=>{const m=z==="settings"&&!l?"dashboard":z,f=ca[m];f&&f!==window.location.pathname&&window.history.pushState({},"",f),v(m)};r.useEffect(()=>{const z=()=>v(da());return window.addEventListener("popstate",z),()=>window.removeEventListener("popstate",z)},[]),r.useEffect(()=>{wa().then(m=>{if((m==null?void 0:m.initialized)===!1){O(!0),s(!1),o(!1);return}O(!1),m!=null&&m.authenticated?(s(!0),o(m.is_admin===!0)):o(!1)}).catch(()=>{s(!1),o(!1)}).finally(()=>A(!1));const z=()=>{s(!1),o(!1)};return window.addEventListener("auth:logout",z),()=>window.removeEventListener("auth:logout",z)},[]),r.useEffect(()=>{!k&&t&&!l&&x==="settings"&&(window.history.replaceState({},"",ca.dashboard),v("dashboard"))},[k,t,l,x]);const T=async z=>{z.preventDefault(),w(!0),de("");try{const m=await Cl({username:j,password:Y});m.success?(s(!0),o(m.is_admin===!0)):de(m.message||"登录失败")}catch(m){const f=m instanceof Error?m.message:String(m);de(f||"登录失败")}finally{w(!1)}},se=async z=>{if(z.preventDefault(),ae(""),G.length<8){ae("密码至少需要 8 个字符");return}if(G!==U){ae("两次输入的密码不一致");return}L(!0);try{const m=await Sl(G);if(!m.success){ae(m.message||"初始化失败,请重试");return}O(!1),s(!0),o(m.is_admin===!0),X(""),fe("")}catch(m){const f=m instanceof Error?m.message:String(m);ae(f||"初始化失败,请重试")}finally{L(!1)}},ke=async()=>{try{await Ll()}catch(z){console.error("退出登录失败",z)}finally{s(!1),o(!1)}};if(k)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-surface",children:e.jsx(Ee,{className:"w-8 h-8 text-brand animate-spin"})});if(b)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-panel w-full max-w-xl border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"mx-auto mb-6 flex justify-center",children:e.jsx(ds,{sizeClass:"w-24 h-24"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"首次设置管理员密码"}),e.jsx("p",{className:"text-gray-600 font-medium",children:"设置完成后会自动进入系统,管理员账号为 admin。"})]}),e.jsxs("form",{onSubmit:se,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(Ds,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"设置管理员密码(至少 8 个字符)",value:G,onChange:z=>X(z.target.value),autoFocus:!0,className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Dt,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"再次输入密码",value:U,onChange:z=>fe(z.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),K&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[e.jsx(Dt,{className:"w-4 h-4"})," ",K]}),e.jsx("button",{type:"submit",disabled:ge,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:ge?e.jsx(Ee,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["设置密码并进入系统 ",e.jsx(cs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Secure Bootstrap"})})]})]});if(!t)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-panel w-full max-w-lg border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"group mx-auto mb-6 flex cursor-pointer justify-center",children:e.jsx(ds,{sizeClass:"w-24 h-24",logoClassName:"w-full h-full text-white group-hover:scale-110 transition-transform"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"欢迎回来"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Ydisks闲鱼助手 · 自动发货与管家系统"})]}),e.jsxs("form",{onSubmit:T,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(xt,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"text",placeholder:"管理员账号",value:j,onChange:z=>V(z.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Ds,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"密码",value:Y,onChange:z=>pe(z.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),M&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[e.jsx(Dt,{className:"w-4 h-4"})," ",M]}),e.jsx("button",{type:"submit",disabled:ce,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:ce?e.jsx(Ee,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(cs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100",children:e.jsx("div",{className:"mt-6 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Ydisks闲鱼助手 v1.0"})})})]})]});const ye=()=>{switch(x){case"dashboard":return e.jsx(as,{});case"accounts":return e.jsx(en,{});case"chat":return e.jsx(Pn,{});case"orders":return e.jsx(an,{});case"cards":return e.jsx(rn,{});case"items":return e.jsx(un,{onConfigureDelivery:z=>{me({cookieId:z.cookie_id,itemId:z.item_id,requestId:Date.now()}),ee("rules")}});case"rules":return e.jsx(kn,{initialDeliveryTarget:Z,onDeliveryTargetHandled:()=>me(void 0)});case"notifications":return e.jsx(On,{isAdmin:l});case"settings":return l?e.jsx(bn,{}):e.jsx(as,{});default:return e.jsx(as,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[e.jsx(jl,{activeTab:x,isAdmin:l,collapsed:R,onToggleCollapsed:()=>E(z=>{const m=!z;return En(m),m}),onNavigate:ee,onLogout:ke}),e.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${R?"ml-16":"ml-64"} ${x==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,children:[e.jsx("div",{className:"fixed top-0 right-0 w-[800px] h-[800px] bg-gradient-to-bl from-blue-50 to-transparent rounded-full blur-[120px] pointer-events-none -z-10 opacity-60"}),e.jsx("div",{className:`${x==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:ye()})]})]})},Ma=document.getElementById("root");if(!Ma)throw new Error("Could not find root element to mount to");const Tn=Fa.createRoot(Ma);Tn.render(e.jsx(xa.StrictMode,{children:e.jsx(Dn,{})})); diff --git a/internal/webui/static/assets/index-Nsmvj8uh.js b/internal/webui/static/assets/index-Nsmvj8uh.js new file mode 100644 index 0000000..54840b5 --- /dev/null +++ b/internal/webui/static/assets/index-Nsmvj8uh.js @@ -0,0 +1,19 @@ +import{j as e,r,c as ys,b as qe,d as Ua}from"./react-vendor-C_od1ZSF.js";import{L as Wa,U as ha,M as is,C as os,B as ga,S as ba,Z as cs,a as jt,b as js,G as As,c as _s,d as Ns,e as Ja,f as rt,A as $s,D as Va,g as Ps,P as fa,h as qt,E as ya,T as Qa,i as Ga,j as Pe,X as Me,k as Ka,l as Ha,m as vs,n as ja,o as He,Q as Xt,p as xt,q as Ke,r as yt,s as Tt,t as Rs,R as ze,u as _a,v as Za,w as Qe,K as Ya,x as dt,y as lt,z as et,F as Es,H as Nt,I as _t,J as Dt,N as Na,O as Xa,V as Ds,W as Ts,Y as el,_ as tl,$ as sl,a0 as al,a1 as es,a2 as Bt,a3 as ds,a4 as ll,a5 as rl,a6 as xs,a7 as Ms,a8 as nl,a9 as il,aa as Mt,ab as qs,ac as Gt,ad as va,ae as ol,af as cl,ag as Zt,ah as wa,ai as dl,aj as xl,ak as ml,al as pl,am as ul,an as hl,ao as Fs}from"./icons-vendor-BpMgNNfy.js";import{R as zt,B as gl,X as Bs,Y as zs,T as Ut,a as bl,C as ts,A as fl,b as yl,c as jl,P as Us,d as Ws,L as _l}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))i(m);new MutationObserver(m=>{for(const _ of m)if(_.type==="childList")for(const N of _.addedNodes)N.tagName==="LINK"&&N.rel==="modulepreload"&&i(N)}).observe(document,{childList:!0,subtree:!0});function l(m){const _={};return m.integrity&&(_.integrity=m.integrity),m.referrerPolicy&&(_.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?_.credentials="include":m.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function i(m){if(m.ep)return;m.ep=!0;const _=l(m);fetch(m.href,_)}})();const Nl=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ms=({sizeClass:t="w-12 h-12",logoClassName:a="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),e.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:e.jsx(Nl,{className:a})})]})]}),vl=({activeTab:t,isAdmin:a=!1,collapsed:l,onToggleCollapsed:i,onNavigate:m,onLogout:_})=>{const[N,I]=r.useState({version:"dev",commit:"unknown"});r.useEffect(()=>{const j=new AbortController;return fetch("/health",{signal:j.signal}).then(F=>F.ok?F.json():Promise.reject(new Error("health request failed"))).then(F=>I({version:String(F.version||"dev"),commit:String(F.commit||"unknown")})).catch(F=>{F instanceof DOMException&&F.name}),()=>j.abort()},[]);const g=[{id:"dashboard",icon:Wa,label:"仪表盘"},{id:"accounts",icon:ha,label:"账号管理"},{id:"chat",icon:is,label:"在线聊天"},{id:"cards",icon:os,label:"卡密库存"},{id:"items",icon:ga,label:"商品列表"},{id:"orders",icon:ba,label:"订单管理"},{id:"rules",icon:cs,label:"自动化规则"},{id:"notifications",icon:jt,label:"通知设置"},...a?[{id:"settings",icon:js,label:"系统与AI"}]:[]],C=/^\d+\.\d+\.\d+$/.test(N.version)?`v${N.version}`:N.version;return e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${l?"w-16":"w-64"}`,children:[e.jsxs("div",{className:`flex h-20 items-center border-b border-slate-100 ${l?"justify-center px-2":"gap-3 px-5"}`,children:[e.jsx(ms,{sizeClass:"h-10 w-10"}),!l&&e.jsxs("div",{className:"min-w-0 leading-tight",children:[e.jsx("div",{className:"truncate text-base font-black tracking-tight text-slate-950",children:"Ydisks 闲鱼助手"}),e.jsx("div",{className:"mt-1 text-[10px] font-extrabold uppercase tracking-[0.22em] text-sky-600",children:"Operations"})]})]}),e.jsx("nav",{className:`flex-1 space-y-1.5 overflow-y-auto pt-5 ${l?"px-2":"px-3"}`,"aria-label":"主导航",children:g.map(j=>{const F=j.icon,G=t===j.id;return e.jsx(ys.Fragment,{children:e.jsxs("button",{type:"button",title:l?j.label:void 0,"aria-label":j.label,"aria-current":G?"page":void 0,onClick:()=>m(j.id),className:`group relative flex h-11 w-full items-center rounded-xl transition-colors ${l?"justify-center":"gap-3 px-3.5"} ${G?"bg-brand text-white shadow-brand-active":"text-slate-500 hover:bg-slate-100 hover:text-slate-900"}`,children:[e.jsx(F,{className:`h-[19px] w-[19px] shrink-0 ${G?"text-white":"text-slate-400 group-hover:text-slate-700"}`}),!l&&e.jsx("span",{className:"truncate text-sm font-bold",children:j.label}),G&&!l&&e.jsx("span",{className:"ml-auto h-1.5 w-1.5 rounded-full bg-white/90"})]})},j.id)})}),e.jsxs("div",{children:[e.jsx("div",{title:l?`版本 ${N.version} · ${N.commit}`:void 0,className:`border-y border-slate-100 bg-slate-50/70 py-2.5 ${l?"flex justify-center px-1":"px-6"}`,children:l?e.jsx(As,{className:"h-[18px] w-[18px] text-slate-400","aria-label":`版本 ${N.version}`}):e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-extrabold uppercase tracking-[0.18em] text-slate-400",children:[e.jsx(As,{className:"h-3.5 w-3.5"}),"运行版本"]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs font-bold text-slate-700",children:C}),e.jsx("span",{className:"truncate font-mono text-[10px] text-slate-400",children:N.commit})]})]})}),e.jsxs("div",{className:`space-y-2 p-2 ${l?"":"p-3"}`,children:[e.jsxs("button",{type:"button",onClick:i,title:l?"展开侧边栏":"收起侧边栏","aria-label":l?"展开侧边栏":"收起侧边栏",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-900 ${l?"justify-center":"gap-3 px-3"}`,children:[l?e.jsx(_s,{className:"h-5 w-5"}):e.jsx(Ns,{className:"h-5 w-5"}),!l&&e.jsx("span",{className:"text-sm font-bold",children:"收起侧边栏"})]}),e.jsxs("button",{type:"button",onClick:_,title:l?"退出登录":void 0,"aria-label":"退出登录",className:`flex h-10 w-full items-center rounded-xl text-slate-500 transition-colors hover:bg-red-50 hover:text-red-600 ${l?"justify-center":"gap-3 px-3"}`,children:[e.jsx(Ja,{className:"h-5 w-5"}),!l&&e.jsx("span",{className:"text-sm font-bold",children:"退出登录"})]})]})]})]})},wl=3e4,kl=10*6e4;let ss=!1;const ka=()=>{ss||typeof window>"u"||(ss=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{ss=!1}))},Cl=t=>{if(!t)return"";const a=new URLSearchParams;for(const[i,m]of Object.entries(t))m!=null&&a.set(i,String(m));const l=a.toString();return l?`?${l}`:""},Yt=async(t,a,l={})=>{var C;const i=Cl(l.params),m=`${a}${i}`,_=Ca(l.signal,l.timeoutMs??wl);let N;try{N=await fetch(m,{method:t,credentials:"include",signal:_.signal,headers:{...l.body===void 0?{}:{"Content-Type":"application/json"}},body:l.body===void 0?void 0:JSON.stringify(l.body)})}catch(j){throw _.signal.aborted?new Error((C=l.signal)!=null&&C.aborted?"请求已取消":"请求超时,请稍后重试"):j}finally{_.cleanup()}const g=(N.headers.get("content-type")||"").includes("application/json");if(!N.ok){N.status===401&&!l.skipAuthLogout&&ka();const j=g?await N.json().catch(()=>{}):await N.text().catch(()=>{}),F=typeof j=="string"?j:(j==null?void 0:j.detail)||(j==null?void 0:j.message)||(j==null?void 0:j.msg);throw new Error(F||`请求失败: ${N.status}`)}return g?await N.json():await N.text()},Le=async(t,a,l)=>Yt("GET",t,{params:a,...l}),Ce=async(t,a,l)=>Yt("POST",t,{body:a,...l}),Be=async(t,a,l)=>Yt("PUT",t,{body:a,...l}),Ze=async(t,a,l)=>Yt("DELETE",t,{params:a,...l}),wt=async(t,a,l={})=>{var g;const i=Ca(l.signal,l.timeoutMs??kl);let m;try{m=await fetch(t,{method:"POST",credentials:"include",signal:i.signal,body:a})}catch(C){throw i.signal.aborted?new Error((g=l.signal)!=null&&g.aborted?"请求已取消":"上传超时,请稍后重试"):C}finally{i.cleanup()}const I=(m.headers.get("content-type")||"").includes("application/json")?await m.json().catch(()=>{}):await m.text().catch(()=>{});if(!m.ok){m.status===401&&ka();const C=typeof I=="string"?I:(I==null?void 0:I.detail)||(I==null?void 0:I.message)||(I==null?void 0:I.msg),j=new Error(C||"请求失败: "+m.status);throw j.payload=I,j}return I},Ca=(t,a)=>{const l=new AbortController,i=()=>l.abort(t==null?void 0:t.reason);t!=null&&t.aborted?i():t==null||t.addEventListener("abort",i,{once:!0});const m=globalThis.setTimeout(()=>l.abort(new DOMException("timeout","TimeoutError")),Math.max(1,a));return{signal:l.signal,cleanup:()=>{globalThis.clearTimeout(m),t==null||t.removeEventListener("abort",i)}}},Kt=t=>{const a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${a}-${l}-${i}`},ws=(t,a)=>{const l=new Date(t);return l.setHours(12,0,0,0),l.setDate(l.getDate()+a),l},ps=(t,a)=>({startDate:Kt(ws(t,-(a-1))),endDate:Kt(t)}),Js=(t,a=new Date,l="",i="")=>{if(t==="custom"&&l&&i){if(l>i)throw new Error("开始日期不能晚于结束日期");return{startDate:l,endDate:i}}return t==="yesterday"?ps(ws(a,-1),1):ps(a,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Sl=t=>{const a=new Date(`${t.startDate}T12:00:00`),l=new Date(`${t.endDate}T12:00:00`),i=Math.round((l.getTime()-a.getTime())/864e5)+1,m=ws(a,-1);return ps(m,i)},Ll=t=>{const a={...t};if("renewal_log_retention_days"in a){const l=Number(a.renewal_log_retention_days);a.renewal_log_retention_days=Number.isFinite(l)?l:10}return a},Ol=async t=>Ce("/login",t,{skipAuthLogout:!0}),Il=async t=>Ce("/initialize",{password:t},{skipAuthLogout:!0}),Sa=async()=>Le("/verify"),Al=async()=>Ce("/logout",{}),$l=async t=>Be("/account/credentials",t),Pl=(t,a)=>{const l=t.avatar_url||"";if(!l)return"";try{const i=new URL(l,window.location.origin);return i.hostname.endsWith("alicdn.com")&&i.searchParams.set("_v",a),i.toString()}catch{return l}},Ft=async t=>{const a=await Le("/cookies/details",void 0,t),l=Date.now().toString();return a.map(i=>({id:i.id,value:"",cookie:"",enabled:i.enabled,auto_confirm:i.auto_confirm,remark:i.remark,note:i.remark,pause_duration:i.pause_duration,paused_until:Number(i.paused_until||0),paused:i.paused===!0,username:i.username||"",login_password:"",show_browser:i.show_browser===!0||i.show_browser===1||i.show_browser==="1"||i.show_browser==="true",nickname:i.nickname||i.remark||`账号 ${i.id.substring(0,6)}`,avatar_url:Pl(i,l),profile_error:i.profile_error||"",ai_enabled:!1,auto_rate_enabled:i.auto_rate_enabled===!0||i.auto_rate_enabled===1,rate_content:i.rate_content||"不错的买家,交易愉快",auto_polish_enabled:i.auto_polish_enabled===!0||i.auto_polish_enabled===1,polish_time:i.polish_time||"03:00",last_rate_scan_at:Number(i.last_rate_scan_at||0),last_polish_date:i.last_polish_date||"",last_polish_at:Number(i.last_polish_at||0)}))},Rl=async t=>Le(`/api/account-tasks/${t}`),Vs=async(t,a)=>Be(`/api/account-tasks/${t}`,a),El=async(t,a)=>Ce(`/api/account-tasks/${t}/run`,{task_type:a},{timeoutMs:12e4}),as=async(t,a,l,i=!1)=>{const m=await Le("/api/chat/sessions",{account_id:t,cursor:a,refresh:i?1:void 0},i?{timeoutMs:6e4,...l}:l);return{sessions:m.sessions||[],has_more:m.has_more===!0,next_cursor:m.next_cursor}},us=async(t,a,l,i,m)=>{const _=await Le("/api/chat/messages",{account_id:t,chat_id:a,cursor:l,before_id:i},m);return{messages:_.messages||[],has_more:_.has_more===!0,next_cursor:_.next_cursor,session:_.session}},Dl=async(t,a,l,i)=>(await us(t,a,void 0,l,i)).messages,Tl=async t=>Ce("/api/chat/messages",t),Ml=async t=>{const a=new FormData;return Object.entries(t).forEach(([l,i])=>a.append(l,i)),wt("/api/chat/images",a,{timeoutMs:12e4})},Qs=async(t,a)=>Ce("/api/chat/read",{account_id:t,chat_id:a}),hs=async t=>Le("/cookies/runtime-status",void 0,t),ql=async t=>Ce("/qr-login/generate",void 0,{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),Fl=async(t,a)=>Le(`/qr-login/check/${t}`,void 0,{signal:a,timeoutMs:1e4}),Bl=async(t,a)=>Ce(`/qr-login/complete-verification/${t}`,{target_account_id:a||""}),zl=async(t,a)=>Be(`/cookies/${t}/status`,{enabled:a}),Ul=async t=>Ze(`/cookies/${t}`),Wl=async(t,a)=>Be(`/cookies/${t}/pause-duration`,{pause_duration:a}),Jl=async(t,a)=>Be(`/cookies/${t}/settings`,a),Vl=async t=>Le(`/cookies/${t}/long-login`),Ql=async(t,a)=>Be(`/cookies/${t}/long-login`,{enabled:a}),Gl=async t=>Ce("/password-login",t),Kl=async(t,a)=>Le(`/password-login/check/${t}`,void 0,{signal:a,timeoutMs:1e4}),Hl=async t=>Ze(`/password-login/cancel/${t}`),Zl=async t=>Ce(`/cookies/${t}/refresh-profile`,{}),Yl=async t=>Le("/ai-reply-settings",void 0,t),La=t=>{const a=String(t||"");return a==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(a)?a:"unknown"},Xl=async(t,a,l=1,i=20,m)=>{const _={page:l,page_size:i};t&&(_.cookie_id=t),a&&a!=="all"&&(_.status=a),m!=null&&m.trim()&&(_.search=m.trim());const N=await Le("/api/orders",_),g=(N.orders||N.data||[]).map(C=>({...C,id:C.id||C.order_id,status:La(C.status||C.order_status),quantity:Number(C.quantity||1)}));return{success:!0,data:g,total:N.total||g.length,page:N.page||l,page_size:N.page_size||i,total_pages:N.total_pages||1}},er=async(t,a)=>Be(`/api/orders/${t}`,a),tr=async t=>Ze(`/api/orders/${t}`),sr=async(t,a)=>{const l=new FormData;return t&&l.append("cookie_id",t),a&&l.append("status",a),wt("/api/orders/refresh",l)},ar=async t=>Ce(`/api/orders/${t}/refresh`),lr=async(t,a)=>Ce("/api/orders/manual-ship",{order_ids:t,ship_mode:a}),rr=async t=>t instanceof FormData?wt("/api/orders/import",t):Ce("/api/orders/import",t),nr=async()=>Le("/dashboard/stats"),Gs=async(t=7)=>{let a;if(typeof t=="number"){const l=new Date,i=new Date;i.setDate(i.getDate()-t),a={start_date:Kt(i),end_date:Kt(l)}}else a=t;return Le("/analytics/orders",{...a,timezone_offset_minutes:-new Date().getTimezoneOffset()})},ir=async t=>{const a=await Le("/analytics/orders/valid",{start_date:t.start_date,end_date:t.end_date,timezone_offset_minutes:-new Date().getTimezoneOffset()}),i=(Array.isArray(a)?a:a.orders||[]).map(m=>({...m,id:m.id||m.order_id,status:La(m.status||m.order_status),quantity:Number(m.quantity||1)}));return{orders:i,total:Array.isArray(a)?i.length:Number(a.total??i.length),truncated:Array.isArray(a)?!1:a.truncated===!0}},or=t=>{let a=t.api_config;if(typeof a=="string"&&a.trim())try{a=JSON.parse(a)}catch{a=void 0}return{...t,api_config:a||void 0}},Oa=t=>({...t,api_config:t.api_config?JSON.stringify(t.api_config):""}),Xe=async()=>{const t=await Le("/cards");return(Array.isArray(t)?t:t.cards||[]).map(or)},cr=async t=>Ce("/cards",Oa(t)),Ks=async(t,a)=>Be(`/cards/${t}`,Oa(a)),dr=async t=>Ze(`/cards/${t}`),xr=async t=>{const a=new FormData;return a.append("file",t),wt("/cards/batch",a)},mr=async(t,a)=>Ce(`/cards/${t}/append-data`,{content:a}),ls=t=>t===!0||t===1||t==="1",vt=async t=>{const a=await Le("/items",void 0);return(Array.isArray(a)?a:a.items||[]).map(i=>({...i,id:i.id||`${i.cookie_id}-${i.item_id}`,is_multi_spec:ls(i.is_multi_spec),is_multi_qty_ship:ls(i.is_multi_qty_ship??i.multi_quantity_delivery),multi_quantity_delivery:ls(i.multi_quantity_delivery??i.is_multi_qty_ship)}))},pr=async t=>Ce("/items/get-all-from-account",{cookie_id:t}),ur=async(t,a)=>Ze(`/items/${t}/${a}`),hr=async(t,a)=>Ce(`/items/${t}`,a),gr=async t=>{const a=new FormData;a.set("cookie_id",t.cookie_id),a.set("title",t.title),a.set("description",t.description),a.set("price",t.price),a.set("original_price",t.original_price||""),a.set("quantity",String(t.quantity)),a.set("postage_mode",t.postage_mode),a.set("postage",t.postage||""),t.location&&a.set("location",JSON.stringify(t.location));for(const l of t.images)a.append("images",l);return wt("/items/publish",a)},br=async(t,a)=>Ce("/items/publish-categories/recommend",{cookie_id:t,keyword:a}),fr=async t=>{const a=new FormData;return a.set("file",t.file),t.imagesZip&&a.set("images_zip",t.imagesZip),t.defaultCookieId&&a.set("default_cookie_id",t.defaultCookieId),a.set("fallback_category_id",t.fallbackCategory.catId),a.set("fallback_category_name",t.fallbackCategory.catName),a.set("fallback_channel_category_id",t.fallbackCategory.channelCatId||""),a.set("fallback_tb_category_id",t.fallbackCategory.tbCatId||""),t.location&&a.set("location",JSON.stringify(t.location)),wt("/items/publish-batches/preview",a)},yr=async t=>Ce("/items/publish-batches",{preview_id:t}),bt=async t=>Le(`/items/publish-batches/${t}`),Hs=async(t=20)=>{const a=await Le("/items/publish-batches",{limit:t});return Array.isArray(a)?a:a.batches||[]},jr=async t=>Ze(`/items/publish-batches/${t}`),_r=async t=>Ce(`/items/publish-batches/${t}/cancel`,{}),Nr=async t=>Ce(`/items/publish-batches/${t}/retry-failed`,{}),vr=async(t,a,l)=>Be(`/items/${t}/${a}`,l),Ia=t=>t.map(a=>{var l,i;return{id:String(a.id),name:a.name||"",trigger_type:a.trigger_type||"order_paid",item_keyword:a.item_title||a.item_id||"",cookie_id:a.cookie_id||"",item_id:a.item_id||"",item_title:a.item_title||"",card_group_id:Number(((l=(a.actions||[]).find(m=>m.action_type==="send_card"))==null?void 0:l.card_id)||0),card_group_name:((i=(a.actions||[]).find(m=>m.action_type==="send_card"))==null?void 0:i.card_name)||"",priority:a.priority||100,enabled:a.enabled||!1,config_json:a.config_json||"{}",actions:(a.actions||[]).map(m=>({id:m.id?String(m.id):void 0,action_type:m.action_type,card_id:Number(m.card_id||0),card_name:m.card_name||"",delivery_count:Number(m.delivery_count||1),message_template:m.message_template||"",delay_seconds:Number(m.delay_seconds||0),config_json:m.config_json||"{}",enabled:m.enabled!==!1,sort_order:Number(m.sort_order||0)})),variants:(a.actions||[]).filter(m=>m.action_type==="send_card").map(m=>{let _={};try{_=JSON.parse(m.config_json||"{}")}catch{}return{id:m.id?String(m.id):void 0,spec_name:_.spec_name||"",spec_value:_.spec_value||"",card_id:Number(m.card_id||0),card_name:m.card_name||"",delivery_count:Number(m.delivery_count||1),enabled:m.enabled!==!1,delay_override:_.delay_override===!0,delay_seconds:Number(m.delay_seconds||0),config_json:m.config_json||"{}"}})}}),gs=async()=>{const t=await Le("/automation-rules"),a=Array.isArray(t)?t:t.data||t.rules||[];return Ia(a)},wr=async({cookieId:t,triggerType:a,enabled:l,search:i,page:m=1,pageSize:_=10}={})=>{const N=await Le("/automation-rules",{page:m,page_size:_,cookie_id:t||void 0,trigger_type:a||void 0,enabled:l,search:(i==null?void 0:i.trim())||void 0}),I=Ia(Array.isArray(N)?N:N.data||N.rules||[]);return{success:!0,data:I,total:Number(N.total??I.length),page:Number(N.page??m),page_size:Number(N.page_size??_),total_pages:Number(N.total_pages??(I.length?1:0)),trigger_counts:Object.fromEntries(Object.entries(N.trigger_counts||{}).map(([g,C])=>[g,Number(C)]))}},kr=(t,a)=>{if(t!=="order_paid")return a.map((m,_)=>({...m,sort_order:m.sort_order||_+1}));const l=a.filter(m=>m.action_type==="send_card").map((m,_)=>({...m,sort_order:_+1})),i=a.filter(m=>m.action_type!=="send_card"&&m.action_type!=="confirm_shipment");return[...l,...i.map((m,_)=>({...m,sort_order:l.length+_+1})),{action_type:"confirm_shipment",enabled:!0,sort_order:l.length+i.length+1}]},Zs=async t=>{const a=t.trigger_type||"order_paid",i=[{order_paid:"付款后自动发货",buyer_reviewed:"评价后发送赠品",review_missing_timeout:"超时未评价求评价"}[a]||"自动化规则",t.item_title||t.item_id||t.cookie_id||""].filter(Boolean).join(" - "),m=(t.actions||[]).filter(g=>g.action_type!=="send_card"&&g.action_type!=="confirm_shipment"),_=t.variants&&t.variants.length>0?[...t.variants.map((g,C)=>({action_type:"send_card",card_id:g.card_id,delivery_count:g.delivery_count||1,enabled:g.enabled!==!1,sort_order:C+1,delay_seconds:g.delay_seconds||0,config_json:JSON.stringify({spec_name:g.spec_name||"",spec_value:g.spec_value||"",delay_override:g.delay_override===!0})})),...m]:t.actions&&t.actions.length>0?t.actions:[{action_type:"send_card",card_id:t.card_group_id||0,delivery_count:1,enabled:!0,sort_order:1}],N=kr(a,_),I={cookie_id:t.cookie_id||"",item_id:t.item_id||"",name:(t.name||"").trim()||i||"自动化规则",trigger_type:a,enabled:t.enabled??!0,priority:t.priority||100,config_json:t.config_json||"{}",actions:N.map((g,C)=>({action_type:g.action_type,card_id:g.card_id||0,delivery_count:g.delivery_count||1,message_template:g.message_template||"",delay_seconds:g.delay_seconds||0,config_json:g.config_json||"{}",enabled:g.enabled!==!1,sort_order:g.sort_order||C+1}))};return t.id?Be(`/automation-rules/${t.id}`,I):Ce("/automation-rules",I)},Cr=async t=>Ze(`/automation-rules/${t}`),Sr=async()=>{const t=await Le("/automation-issues");return{runs:Array.isArray(t==null?void 0:t.runs)?t.runs:[],pending_tasks:Array.isArray(t==null?void 0:t.pending_tasks)?t.pending_tasks:[]}},Lr=async(t,a)=>Ce(`/automation-runs/${t}/resolve`,{resolution:a}),Or=async(t,a)=>Ce(`/automation-pending-tasks/${t}/resolve`,{resolution:a}),Ir=t=>({id:String((t==null?void 0:t.id)||""),keyword:(t==null?void 0:t.keyword)||"",reply:(t==null?void 0:t.reply)||"",item_id:(t==null?void 0:t.item_id)||"",type:(t==null?void 0:t.type)==="image"?"image":"text",image_url:(t==null?void 0:t.image_url)||""}),Ar=async t=>{const a=await Le(`/keywords-with-type/${t}`);return Array.isArray(a)?a.map(Ir):[]},$r=async t=>t?(await Ar(t)).map(l=>({id:l.id,keyword:l.keyword||"",reply_content:l.reply||"",match_type:"fuzzy",enabled:!0,item_id:l.item_id||"",type:l.type==="image"?"image":"text",image_url:l.image_url||""})):[],Pr=async(t,a)=>{const l=t.type||"text",i={keyword:t.keyword||"",reply:l==="text"&&t.reply_content||"",item_id:t.item_id||"",type:l,image_url:l==="image"&&t.image_url||""};return t.id?Be(`/keywords-with-type/${a}/${t.id}`,i):Ce(`/keywords-with-item-id/${a}`,i)},Rr=async(t,a)=>Ze(`/keywords-with-type/${a}/${t}`),Aa=async()=>{const t=await Le("/system-settings");return Ll(t.data||t)},$a=async t=>{const a=Object.fromEntries(Object.entries(t).filter(([,l])=>l!=null));return Be("/system-settings",a)},Er=async(t,a)=>Le(`/ai-reply-settings/${t}`,void 0,a),Dr=async(t,a)=>{const l={ai_enabled:a.ai_enabled??!1,max_discount_percent:a.max_discount_percent??10,max_discount_amount:a.max_discount_amount??100,max_bargain_rounds:a.max_bargain_rounds??3,custom_prompts:a.custom_prompts??""};return Be(`/ai-reply-settings/${t}`,l)},Tr=async(t,a="")=>(await Ce("/ai-models",{base_url:t,api_key:a})).models||[],Mr=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const a=JSON.parse(t);if(Array.isArray(a))return a.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(a=>a.trim()).filter(Boolean)},Pa=t=>{const a=Array.from(new Set((t||[]).filter(Boolean)));return a.length>0?JSON.stringify(a):""},Ra=async t=>({success:!0,data:(await Le("/notification-channels",void 0,t)||[]).map(i=>{let m;try{m=typeof i.config=="string"?JSON.parse(i.config):i.config}catch{m={}}return{id:String(i.id),name:i.name,type:i.type==="ding_talk"?"dingtalk":i.type==="lark"?"feishu":i.type,config:m,event_types:Mr(i.event_types),enabled:i.enabled,created_at:i.created_at,updated_at:i.updated_at}})}),qr=async t=>Ce("/notification-channels",{...t,config:JSON.stringify(t.config),event_types:Pa(t.event_types)}),Ys=async(t,a)=>{const l={...a};return"config"in a&&(l.config=JSON.stringify(a.config)),"event_types"in a&&(l.event_types=Pa(a.event_types)),Be(`/notification-channels/${t}`,l)},Fr=async t=>Ze(`/notification-channels/${t}`),Br=async(t,a)=>{const l=await Le(`/message-notifications/${t}`,void 0,a);return(l==null?void 0:l.channel_ids)||[]},zr=async t=>Ce(`/notification-channels/${t}/test`,{}),Xs=async()=>Le("/api/default-replies"),Ur=async t=>{const a=await Le(`/api/default-reply/${t}`);return{cookie_id:t,enabled:a.enabled||!1,reply_content:a.reply_content||"",reply_once:a.reply_once||!1,reply_image_url:a.reply_image_url||""}},Wr=async(t,a)=>Be(`/api/default-reply/${t}`,{enabled:a.enabled??!1,reply_content:a.reply_content||"",reply_once:a.reply_once??!1,reply_image_url:a.reply_image_url||""}),Jr=async t=>Ze(`/api/default-reply/${t}`),Vr=async t=>Ce(`/api/default-reply/${t}/clear-records`,{}),At=t=>String(t).padStart(2,"0"),bs=t=>{if(t==null||t==="")return"-";const a=t instanceof Date?t:new Date(t);return Number.isNaN(a.getTime())?"-":[a.getFullYear(),At(a.getMonth()+1),At(a.getDate())].join("-")+" "+[At(a.getHours()),At(a.getMinutes()),At(a.getSeconds())].join(":")},Ne=(t,a)=>a===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${a})`,Qr=({status:t})=>{const a={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`inline-flex items-center justify-center whitespace-nowrap px-3 py-1.5 rounded-lg text-xs leading-none font-bold ${a[t]||a.cancelled}`,children:l[t]||t})},Wt=({title:t,value:a,icon:l,colorClass:i,trend:m})=>e.jsxs("div",{className:"ios-card p-6 rounded-xl flex flex-col justify-between hover:translate-y-[-4px] transition-all duration-300 h-full relative overflow-hidden group border-0",children:[e.jsx("div",{className:`absolute -right-6 -top-6 w-32 h-32 ${i} opacity-10 rounded-full group-hover:scale-125 transition-transform duration-500 blur-2xl`}),e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsx("div",{className:`p-4 rounded-2xl ${i} bg-opacity-10 backdrop-blur-sm`,children:e.jsx(l,{className:`w-6 h-6 ${i.replace("bg-","text-")}`})}),m&&e.jsxs("span",{className:"text-xs font-bold text-white bg-brand px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm",children:[e.jsx(Qa,{className:"w-3 h-3"})," ",m]})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h3",{className:"text-3xl font-extrabold text-gray-900 tracking-tight font-feature-settings-tnum",children:a}),e.jsx("p",{className:"text-gray-500 text-sm font-medium mt-1",children:t})]})]}),rs=()=>{var V,X;const[t,a]=r.useState(null),[l,i]=r.useState(null),[m,_]=r.useState(""),[N,I]=r.useState("7days"),[g,C]=r.useState(""),[j,F]=r.useState(""),[G,me]=r.useState(null),[oe,v]=r.useState(""),[q,ce]=r.useState([]),[Q,ee]=r.useState(0),[B,ge]=r.useState(!1),[ue,k]=r.useState(!1),[Z,se]=r.useState([]),[K,ve]=r.useState({}),J=r.useRef(0),A=[Ne("brand"),Ne("brand-highlight"),Ne("success-500"),Ne("warning-500"),Ne("accent-500")],E=c=>`¥${Number(c||0).toLocaleString("zh-CN",{maximumFractionDigits:2})}`,P=async c=>{let d;try{d=Js(c,new Date,g,j)}catch(Se){_(Se instanceof Error?Se.message:"日期范围无效");return}const{startDate:D,endDate:S}=d,Y={start_date:D,end_date:S},O=Sl(d),de=++J.current;k(!0),_("");try{const[Se,fe,Oe]=await Promise.all([Gs(Y),Gs({start_date:O.startDate,end_date:O.endDate}),ir(Y)]);if(de!==J.current)return;i(Se),me(fe),ce(Oe.orders),ee(Oe.total),ge(Oe.truncated)}catch(Se){de===J.current&&_(Se instanceof Error?Se.message:"经营数据加载失败")}finally{de===J.current&&k(!1)}},be=()=>{if(!l||!G)return null;const c=l.revenue_stats.total_amount,d=G.revenue_stats.total_amount;if(d===0)return c>0?"+100%":"0%";const D=(c-d)/d*100;return`${D>=0?"+":""}${D.toFixed(1)}%`};if(r.useEffect(()=>{let c=!1;return Promise.all([nr(),vt()]).then(([d,D])=>{if(c)return;a(d),se(D);const S={};D.forEach(Y=>{S[Y.item_id]=Y.item_title||Y.item_id}),ve(S)}).catch(d=>{c||_(d instanceof Error?d.message:"概览加载失败")}),()=>{c=!0}},[]),r.useEffect(()=>{N!=="custom"&&P(N)},[N]),m&&(!t||!l))return e.jsxs("div",{className:"p-8 flex flex-col items-center gap-3 text-red-600",children:[e.jsx(rt,{className:"w-8 h-8"}),e.jsx("span",{children:m}),e.jsx("button",{type:"button",className:"ios-btn-primary px-4 py-2 rounded-xl",onClick:()=>window.location.reload(),children:"重新加载"})]});if(!t||!l)return e.jsx("div",{className:"p-8 flex justify-center text-gray-400",children:e.jsx($s,{className:"w-8 h-8 animate-spin text-brand"})});const Re=((V=l.daily_stats)==null?void 0:V.map(c=>({name:c.date.slice(5),amount:c.amount,orders:c.order_count,avgAmount:c.order_count>0?(c.amount/c.order_count).toFixed(2):0})))||[],ae=l.item_stats||[],T=l.revenue_stats.total_orders||0,p=l.revenue_stats.total_amount||0,b=ae.length>0?ae.map(c=>({name:(K[c.item_id]||c.item_id).length>12?(K[c.item_id]||c.item_id).substring(0,12)+"...":K[c.item_id]||c.item_id,sales:c.order_count})).sort((c,d)=>d.sales-c.sales).slice(0,10):[],U=Math.max(...b.map(c=>c.sales),1),M=ae.length>0?ae.map(c=>({name:(K[c.item_id]||c.item_id).length>10?(K[c.item_id]||c.item_id).substring(0,10)+"...":K[c.item_id]||c.item_id,value:c.order_count,percent:T>0?c.order_count/T*100:0})).sort((c,d)=>d.value-c.value).slice(0,6).map((c,d)=>({...c,color:A[d%A.length]})):[],ne=ae.length>0?ae.map(c=>({name:(K[c.item_id]||c.item_id).length>12?(K[c.item_id]||c.item_id).substring(0,12)+"...":K[c.item_id]||c.item_id,value:c.total_amount,orderCount:c.order_count,percentage:p>0?c.total_amount/p*100:0})).sort((c,d)=>d.value-c.value).slice(0,5).map((c,d)=>({...c,color:A[d%A.length],percentage:c.percentage.toFixed(1)})):[],he=[{key:"today",label:"今天"},{key:"yesterday",label:"昨天"},{key:"3days",label:"三天内"},{key:"7days",label:"7天内"},{key:"30days",label:"一个月内"},{key:"custom",label:"自定义"}],ye=((X=he.find(c=>c.key===N))==null?void 0:X.label)||"所选范围";let Ee;try{Ee=Js(N,new Date,g,j)}catch{Ee={startDate:g,endDate:j}}const ke=oe.trim().toLowerCase(),x=q.filter(c=>{var d,D,S,Y;return((d=c.order_id)==null?void 0:d.toLowerCase().includes(ke))||((D=c.item_id)==null?void 0:D.toLowerCase().includes(ke))||((S=c.item_title)==null?void 0:S.toLowerCase().includes(ke))||((Y=c.buyer_id)==null?void 0:Y.toLowerCase().includes(ke))});return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"运营概览"}),e.jsx("p",{className:"text-gray-500 mt-2 text-base",children:"欢迎回来,以下是闲鱼店铺的实时经营数据。"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-sm font-bold text-gray-700 bg-white px-5 py-2.5 rounded-full shadow-sm border border-gray-100 flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 bg-green-500 rounded-full animate-pulse"}),"系统正常运行"]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[he.map(c=>e.jsx("button",{onClick:()=>I(c.key),className:`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${N===c.key?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:c.label},c.key)),N==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"date",value:g,onChange:c=>C(c.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("span",{className:"self-center text-gray-400",children:"-"}),e.jsx("input",{type:"date",value:j,onChange:c=>F(c.target.value),className:"px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"}),e.jsx("button",{onClick:()=>{try{_(""),P("custom")}catch(c){_(c instanceof Error?c.message:"日期范围无效")}},className:"px-4 py-2 rounded-xl text-sm font-bold bg-black text-white hover:bg-gray-800 transition-colors",children:"应用"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsx(Wt,{title:"累计营收 (CNY)",value:`¥${l.revenue_stats.total_amount.toLocaleString("zh-CN",{minimumFractionDigits:2})}`,icon:Va,colorClass:"bg-blue-400",trend:be()||void 0}),e.jsx(Wt,{title:"活跃账号 / 总数",value:`${t.active_cookies} / ${t.total_cookies}`,icon:ha,colorClass:"bg-blue-500"}),e.jsx(Wt,{title:"订单数",value:l.revenue_stats.total_orders.toLocaleString(),icon:Ps,colorClass:"bg-blue-500"}),e.jsx(Wt,{title:"库存卡密余量",value:t.available_card_stock,icon:fa,colorClass:"bg-purple-500"})]}),e.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[ye,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:Re.length===0||l.revenue_stats.total_amount===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(Ps,{className:"w-16 h-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),e.jsx("p",{className:"text-sm mt-2",children:"所选时间范围内暂无订单记录"})]}):Re.length<=2?e.jsx(zt,{width:"100%",height:"100%",children:e.jsxs(gl,{data:Re,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(Bs,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:Ne("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(zs,{axisLine:!1,tickLine:!1,tick:{fill:Ne("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:c=>`¥${c}`}),e.jsx(Ut,{contentStyle:{backgroundColor:Ne("white"),borderRadius:"8px",border:`1px solid ${Ne("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:Ne("neutral-500"),fontWeight:500},itemStyle:{color:Ne("brand"),fontWeight:600},cursor:{fill:Ne("brand",.08)},formatter:c=>[`¥${Number(c).toFixed(2)}`,"营收"]}),e.jsx(bl,{dataKey:"amount",fill:Ne("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:Re.map((c,d)=>e.jsx(ts,{fill:Ne("brand"),stroke:"none",strokeWidth:0},`cell-${d}`))})]})}):e.jsx(zt,{width:"100%",height:"100%",children:e.jsxs(fl,{data:Re,margin:{top:10,right:10,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:Ne("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:Ne("brand"),stopOpacity:0})]})}),e.jsx(Bs,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:Ne("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(zs,{axisLine:!1,tickLine:!1,tick:{fill:Ne("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(yl,{vertical:!1,stroke:Ne("neutral-100"),strokeDasharray:"3 3"}),e.jsx(Ut,{contentStyle:{backgroundColor:Ne("white"),borderRadius:"8px",border:`1px solid ${Ne("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:Ne("neutral-500"),fontWeight:500},itemStyle:{color:Ne("brand"),fontWeight:600},cursor:{stroke:Ne("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(jl,{type:"monotone",dataKey:"amount",stroke:Ne("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:Ne("white"),stroke:Ne("brand"),strokeWidth:2}})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品销量排行"}),e.jsx("div",{className:"h-[280px]",children:b.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsx("div",{className:"h-full space-y-4 overflow-y-auto pr-2",children:b.map((c,d)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:`w-7 h-7 rounded-xl flex items-center justify-center text-xs font-extrabold ${d<3?"bg-blue-600 text-white":"bg-gray-100 text-gray-500"}`,children:d+1}),e.jsx("span",{className:"font-bold text-gray-800 text-sm truncate",children:c.name})]}),e.jsxs("span",{className:"font-mono text-sm font-extrabold text-gray-900",children:[c.sales," 单"]})]}),e.jsx("div",{className:"h-3 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${Math.max(8,c.sales/U*100)}%`}})})]},`${c.name}-${d}`))})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品下单占比"}),e.jsx("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品下单占比,共 ${T} 单`,children:M.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsx(zt,{width:"100%",height:"100%",children:e.jsxs(Us,{accessibilityLayer:!1,children:[e.jsx(Ws,{data:M,cx:"50%",cy:"45%",innerRadius:60,outerRadius:90,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:96,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:M.map((c,d)=>e.jsx(ts,{fill:c.color},`cell-${d}`))}),e.jsx(Ut,{formatter:c=>`${Number(c||0)} 单`,wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:Ne("white"),border:`1px solid ${Ne("neutral-200")}`,borderRadius:"10px",boxShadow:"var(--shadow-md)"}}),e.jsx(_l,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:c=>e.jsx("span",{style:{color:Ne("neutral-500"),fontWeight:500},children:c})})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center pb-9",children:[e.jsx("span",{className:"text-2xl font-extrabold text-gray-900 tabular-nums",children:T}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总订单"})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 ios-card p-0 rounded-xl border-0 bg-white overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b border-gray-50 flex justify-between items-center bg-surface-muted",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:"参与统计的订单"}),B&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["当前显示最近 ",q.length," / ",Q," 条,搜索仅覆盖已加载明细。"]})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{placeholder:"搜索订单号/商品/买家...",value:oe,onChange:c=>v(c.target.value),className:"pl-4 pr-4 py-2 rounded-xl bg-white border border-gray-100 text-sm focus:border-blue-400 outline-none w-48",type:"text"})})]}),e.jsx("div",{className:"overflow-x-auto flex-1 max-h-[400px]",children:ue?e.jsxs("div",{className:"flex items-center justify-center py-20 text-gray-400",children:[e.jsx($s,{className:"w-6 h-6 animate-spin mr-2"}),"加载中..."]}):x.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:e.jsx(qt,{className:"w-7 h-7 text-gray-300"})}),ke?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"没有匹配的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-md",children:["当前共有 ",q.length," 单参与统计,但没有订单号、商品、买家匹配“",oe,"”。"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"当前范围内没有参与统计的订单"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 max-w-lg leading-6",children:["日期范围:",Ee.startDate," 至 ",Ee.endDate,"; 统计口径:待发货、已发货、已完成,且订单金额不为空。 当前统计卡片订单数:",l.revenue_stats.total_orders," 单。"]})]})]}):e.jsxs("table",{className:"w-full min-w-[760px] text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-4",children:"订单信息"}),e.jsx("th",{className:"px-6 py-4",children:"买家信息"}),e.jsx("th",{className:"px-6 py-4",children:"金额"}),e.jsx("th",{className:"px-6 py-4 whitespace-nowrap",children:"状态"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:x.map(c=>e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:e.jsx(qt,{className:"w-full h-full text-gray-300 p-2"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm line-clamp-1",children:c.item_title||c.item_id||"未知商品"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:c.order_id}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",c.quantity||1]})]})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-bold text-gray-800",children:c.buyer_id}),c.created_at&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:bs(c.created_at)})]}),e.jsxs("td",{className:"px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:["¥",c.amount||"0.00"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx(Qr,{status:c.status||c.order_status||"unknown"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${c.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(ya,{className:"w-4 h-4"})})})]},c.order_id))})]})})]}),e.jsxs("div",{className:"ios-card p-6 rounded-xl bg-white",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 mb-6",children:"商品金额分析 (TOP5)"}),ne.length===0?e.jsx("div",{className:"flex items-center justify-center h-[300px] text-gray-400",children:"暂无数据"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dashboard-pie-chart h-[280px] relative",role:"img","aria-label":`商品金额分析,总金额 ${E(p)}`,children:[e.jsx(zt,{width:"100%",height:"100%",children:e.jsxs(Us,{accessibilityLayer:!1,children:[e.jsx(Ws,{data:ne,cx:"50%",cy:"50%",innerRadius:60,outerRadius:92,paddingAngle:2,dataKey:"value",activeShape:{outerRadius:98,stroke:"none",strokeWidth:0},rootTabIndex:-1,label:!1,labelLine:!1,children:ne.map((c,d)=>e.jsx(ts,{fill:c.color||A[d%A.length]},`cell-${d}`))}),e.jsx(Ut,{wrapperStyle:{zIndex:30,outline:"none"},contentStyle:{backgroundColor:Ne("white"),border:`1px solid ${Ne("neutral-200")}`,borderRadius:"6px",boxShadow:"var(--shadow-md)"},formatter:c=>`¥${Number(c||0).toLocaleString()}`})]})}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-lg font-extrabold text-gray-900 tabular-nums",children:E(p)}),e.jsx("span",{className:"text-xs font-medium text-gray-400 mt-0.5",children:"总金额"})]})]}),e.jsx("div",{className:"space-y-3 mt-4",children:ne.map(c=>e.jsxs("div",{className:"flex justify-between items-center gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:c.color||A[ne.indexOf(c)%A.length]}}),e.jsx("span",{className:"text-gray-600 font-medium truncate",title:c.name,children:c.name})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 whitespace-nowrap",children:[e.jsxs("span",{className:"font-bold text-gray-900",children:["¥",c.value.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded",children:[c.percentage,"%"]})]})]},c.name))})]})]})]})]})},Gr=(t,a)=>{const l=a.pause_duration||0;return t!==l},Kr=(t,a)=>{const l=a.username!==(t.username||""),i=a.show_browser!==(t.show_browser||!1),m=a.login_password!=="",_=a.clear_password===!0;if(!l&&!i&&!m&&!_)return null;const N={username:a.username,show_browser:a.show_browser};return _?N.clear_password=!0:m&&(N.login_password=a.login_password),N},Hr=(t,a)=>t&&a,Zr=(t,a)=>{if(!t||!a)return!1;const l=Date.parse(t),i=Date.parse(a);return Number.isFinite(l)&&Number.isFinite(i)&&it.map(l=>{const i=a[l.id];return!i||Zr(l.runtime_updated_at,i.updated_at)?l:{...l,runtime_state:i.state,runtime_message:i.message||"",runtime_connected:i.connected,runtime_updated_at:i.updated_at}}),Xr=new Set(["expired","cancelled","error","not_found"]),Jt=()=>{let t=0;return{next:()=>(t+=1,t),cancel:()=>{t+=1},isCurrent:a=>a===t}},en=(t={setInterval:globalThis.setInterval.bind(globalThis),clearInterval:globalThis.clearInterval.bind(globalThis)})=>{let a=null,l=null,i=-1,m=0;const _=()=>{m+=1,l==null||l.abort(),l=null,a!==null&&(t.clearInterval(a),a=null)};return{start:(I,g,C,j=2e3)=>{_();const F=m;l=new AbortController;const G=l.signal;a=t.setInterval(()=>{i===F||F!==m||(i=F,(async()=>{var me,oe;try{const v=await g(I,G);if(v.status==="success"){_(),await C.onSuccess(v);return}if(v.status==="scanned"){(me=C.onScanned)==null||me.call(C,v);return}if(v.status==="verification_required"){(oe=C.onVerificationRequired)==null||oe.call(C,v);return}v.status&&Xr.has(v.status)&&(_(),C.onTerminalError(v))}catch(v){if(G.aborted||F!==m)return;_(),C.onPollError(v)}finally{i===F&&(i=-1)}})())},j)},stop:_,isActive:()=>a!==null}},tn=({faceQrUrl:t,verificationScreenshot:a})=>e.jsxs("div",{className:"w-full min-w-0 max-h-[min(64vh,28rem)] overflow-y-auto overscroll-contain px-1 py-2 text-center",children:[e.jsx("div",{className:"mx-auto mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-700",children:e.jsx(Ga,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("h4",{className:"break-words text-base font-extrabold leading-6 text-amber-900",children:"需要完成安全风控验证"}),e.jsx("p",{className:"mx-auto mt-1 max-w-[15rem] break-words text-xs leading-5 text-amber-800",children:"当前账号触发了闲鱼平台风控。请使用手机闲鱼 App 扫描下方二维码,并按 App 提示完成人脸识别。"}),e.jsx("div",{className:"mx-auto mt-3 flex min-h-36 w-full max-w-[12rem] items-center justify-center overflow-hidden rounded-xl border border-amber-200 bg-white p-2 shadow-sm",children:t?e.jsx("img",{src:t,alt:"闲鱼安全风控验证二维码",className:"block max-h-44 w-full object-contain"}):a?e.jsx("img",{src:a,alt:"闲鱼风控验证页面",className:"block max-h-44 w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-2 text-amber-700",children:[e.jsx(Pe,{className:"h-6 w-6 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"text-xs font-bold",children:"正在准备风控二维码…"})]})}),e.jsx("p",{className:"mx-auto mt-2 max-w-[15rem] break-words text-[11px] leading-4 text-gray-500",children:"请勿在浏览器中打开验证链接。完成验证后系统会自动检测并刷新登录状态,无需手动确认。"})]}),ea=({src:t,alt:a,className:l=""})=>e.jsx("img",{src:t,alt:a,className:`block aspect-square h-auto w-full object-contain ${l}`.trim()}),ta=({checked:t,onChange:a,label:l})=>e.jsx("button",{type:"button","aria-label":l,"aria-pressed":t,onClick:a,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),sn=({account:t,onClose:a,onSaved:l})=>{const[i,m]=r.useState({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),[_,N]=r.useState(!1),[I,g]=r.useState(""),[C,j]=r.useState(""),[F,G]=r.useState(null),me=async()=>{N(!0),j("");try{const v=await Vs(t.id,i);m(v),l(v)}catch(v){j(v instanceof Error?v.message:"保存失败")}finally{N(!1)}},oe=async v=>{g(v),j(""),G(null);try{await Vs(t.id,i);const q=await El(t.id,v),ce=await Rl(t.id);G(q.summary),m(ce),l(ce)}catch(q){j(q instanceof Error?q.message:"任务执行失败")}finally{g("")}};return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:a,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(Me,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(Ka,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(ta,{checked:i.auto_rate_enabled,onChange:()=>m(v=>({...v,auto_rate_enabled:!v.auto_rate_enabled})),label:"自动评价"})]}),e.jsx("label",{className:"mt-4 block text-xs font-extrabold text-slate-600",children:"统一好评文案"}),e.jsx("textarea",{"aria-label":"统一好评文案",value:i.rate_content,maxLength:500,onChange:v=>m(q=>({...q,rate_content:v.target.value})),className:"mt-2 h-24 w-full resize-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm leading-6 text-slate-800 placeholder:text-slate-400 outline-none focus:border-sky-400 focus:ring-2 focus:ring-sky-100"}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:["最近扫描:",i.last_rate_scan_at?new Date(i.last_rate_scan_at*1e3).toLocaleString("zh-CN"):"尚未执行"]}),e.jsxs("button",{type:"button",disabled:I!==""||!t.enabled,onClick:()=>void oe("auto_rate"),className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-extrabold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50",children:[I==="auto_rate"?e.jsx(Pe,{className:"h-4 w-4 animate-spin"}):e.jsx(Ha,{className:"h-4 w-4"}),"立即评价"]})]})]})]})}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-50 text-amber-600",children:e.jsx(vs,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"每日自动擦亮"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"每个账号每天最多执行一次,按北京时间判断。"})]}),e.jsx(ta,{checked:i.auto_polish_enabled,onChange:()=>m(v=>({...v,auto_polish_enabled:!v.auto_polish_enabled})),label:"每日自动擦亮"})]}),e.jsxs("div",{className:"mt-4 flex items-end justify-between gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-extrabold text-slate-600",children:"每日执行时间"}),e.jsx("input",{type:"time",value:i.polish_time,onChange:v=>m(q=>({...q,polish_time:v.target.value})),className:"mt-2 block rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-bold text-slate-800 outline-none focus:border-sky-400"})]}),e.jsxs("button",{type:"button",disabled:I!==""||!t.enabled,onClick:()=>void oe("auto_polish"),className:"flex items-center gap-2 rounded-xl bg-amber-50 px-3 py-2 text-xs font-extrabold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:[I==="auto_polish"?e.jsx(Pe,{className:"h-4 w-4 animate-spin"}):e.jsx(ja,{className:"h-4 w-4"}),"立即擦亮"]})]}),e.jsxs("div",{className:"mt-3 text-xs text-slate-400",children:["上次完成:",i.last_polish_at?new Date(i.last_polish_at*1e3).toLocaleString("zh-CN"):"尚未执行"]})]})]})}),F&&e.jsxs("div",{className:"rounded-xl border border-sky-100 bg-sky-50 px-4 py-3 text-sm text-sky-900",children:["本次发现 ",F.found," 项,成功 ",F.success,",失败 ",F.failed,",跳过 ",F.skipped,"。",F.message||""]}),C&&e.jsx("div",{className:"rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:C})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex w-full gap-3",children:[e.jsx("button",{type:"button",onClick:a,disabled:_||I!=="",className:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-bold text-gray-700 transition-colors hover:bg-gray-200 disabled:opacity-50",children:"关闭"}),e.jsxs("button",{type:"button",onClick:()=>void me(),disabled:_||I!==""||i.auto_rate_enabled&&!i.rate_content.trim(),className:"ios-btn-primary flex flex-1 items-center justify-center gap-2 rounded-xl px-6 py-3 font-bold disabled:opacity-50",children:[_?e.jsx(Pe,{className:"h-4 w-4 animate-spin"}):e.jsx(He,{className:"h-4 w-4"}),"保存"]})]})})]})})},an=()=>{const[t,a]=r.useState([]),[l,i]=r.useState(!0),[m,_]=r.useState(""),[N,I]=r.useState(""),[g,C]=r.useState(""),[j,F]=r.useState(null),[G,me]=r.useState(""),[oe,v]=r.useState(!1),[q,ce]=r.useState(""),[Q,ee]=r.useState("pending"),[B,ge]=r.useState(""),[ue,k]=r.useState(""),[Z,se]=r.useState(""),[K,ve]=r.useState(null),[J,A]=r.useState(null),[E,P]=r.useState(null),[be,Re]=r.useState(null),[ae,T]=r.useState({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:""}),[p,b]=r.useState([]),[U,M]=r.useState([]),[ne,he]=r.useState(!1),[ye,Ee]=r.useState(!1),[ke,x]=r.useState(!1),[V,X]=r.useState(""),[c,d]=r.useState({remark:"",cookie:"",auto_confirm:!1,pause_duration:0,username:"",login_password:"",show_browser:!1,showLoginPassword:!1,clear_password:!1}),[D,S]=r.useState({ai_enabled:!1,max_discount_percent:10,max_discount_amount:100,max_bargain_rounds:3,custom_prompts:""}),[Y,O]=r.useState(!1),[de,Se]=r.useState({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),fe=r.useRef(null),Oe=r.useRef(null),re=r.useRef(null),h=r.useRef(null),f=r.useRef(null),R=r.useRef(null),z=r.useRef(null),Ie=r.useRef(null),Ae=r.useRef(null),we=r.useRef(null),De=r.useRef(null),te=r.useRef(null),je=r.useRef(0);fe.current===null&&(fe.current=en()),Oe.current===null&&(Oe.current=Jt()),re.current===null&&(re.current=Jt()),h.current===null&&(h.current=Jt()),f.current===null&&(f.current=Jt());const u=()=>{De.current!==null&&(window.clearTimeout(De.current),De.current=null)},L=()=>{te.current!==null&&(window.clearTimeout(te.current),te.current=null)},le=()=>{var s;(s=fe.current)==null||s.stop()},_e=()=>{var s,o;(s=Ae.current)==null||s.abort(),(o=Oe.current)==null||o.cancel(),le(),u(),v(!1)},Ue=()=>{u(),De.current=window.setTimeout(()=>{De.current=null,v(!1),Fe()},1e3)},Fe=async()=>{var y,$,W,pe,xe;const s=re.current.next();(y=R.current)==null||y.abort();const o=new AbortController;R.current=o,i(!0);try{const $e={signal:o.signal},[ie,Ye]=await Promise.allSettled([Ft($e),Yl($e)]);if(!(($=re.current)!=null&&$.isCurrent(s)))return;if(ie.status==="rejected")throw ie.reason;const Ve=ie.value,It=Ye.status==="fulfilled"?Ye.value:{};Ye.status==="rejected"&&console.error("Failed to load AI settings:",Ye.reason);const za=Ve.map(gt=>{var Cs,Ss,Ls,Os,Is;return{...gt,ai_enabled:((Cs=It[gt.id])==null?void 0:Cs.ai_enabled)??!1,max_discount_percent:((Ss=It[gt.id])==null?void 0:Ss.max_discount_percent)??10,max_discount_amount:((Ls=It[gt.id])==null?void 0:Ls.max_discount_amount)??100,max_bargain_rounds:((Os=It[gt.id])==null?void 0:Os.max_bargain_rounds)??3,custom_prompts:((Is=It[gt.id])==null?void 0:Is.custom_prompts)??""}});(W=re.current)!=null&&W.isCurrent(s)&&a(za)}catch($e){(pe=re.current)!=null&&pe.isCurrent(s)&&!o.signal.aborted&&console.error("Failed to load accounts:",$e)}finally{(xe=re.current)!=null&&xe.isCurrent(s)&&i(!1)}};r.useEffect(()=>{let s=!1,o=null;const y=new AbortController,$=async()=>{try{const W=await hs({signal:y.signal,timeoutMs:1e4});s||a(pe=>Yr(pe,W))}catch(W){s||console.error("Failed to load account runtime statuses:",W)}finally{s||(o=window.setTimeout(()=>void $(),2e3))}};return Fe().finally(()=>{s||$()}),()=>{s=!0,y.abort(),o!==null&&window.clearTimeout(o)}},[]),r.useEffect(()=>()=>{var s,o,y,$,W,pe,xe,$e,ie;le(),(s=Oe.current)==null||s.cancel(),(o=re.current)==null||o.cancel(),(y=h.current)==null||y.cancel(),($=f.current)==null||$.cancel(),(W=R.current)==null||W.abort(),(pe=z.current)==null||pe.abort(),(xe=Ie.current)==null||xe.abort(),($e=Ae.current)==null||$e.abort(),(ie=we.current)==null||ie.abort(),u(),je.current+=1,L()},[]);const tt=s=>{if(!s.enabled||s.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(s.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},kt=async(s,o)=>{await zl(s,!o),Fe()},Je=s=>{g||(me(""),F(s))},We=()=>{g||(me(""),F(null))},Ct=async()=>{const s=j;if(!(!s||g)){C(s.id),me("");try{await Ul(s.id),a(o=>o.filter(y=>y.id!==s.id)),F(null)}catch(o){console.error("删除账号失败:",o),me((o==null?void 0:o.message)||"删除账号失败,请稍后重试")}finally{C("")}}},St=async s=>{I(s.id);try{const o=await Zl(s.id);o!=null&&o.profile_error&&alert("资料刷新失败:"+o.profile_error),await Fe()}catch(o){console.error("刷新账号资料失败:",o),alert((o==null?void 0:o.message)||"刷新账号资料失败,请先重新授权该账号")}finally{I("")}},mt=async s=>{var pe,xe;const o=h.current.next();(pe=z.current)==null||pe.abort();const y=new AbortController;z.current=y,Ee(!0),he(!1),x(!1),X("");const[$,W]=await Promise.allSettled([Ra({signal:y.signal}),Br(s,{signal:y.signal})]);(xe=h.current)!=null&&xe.isCurrent(o)&&($.status==="fulfilled"?b($.value.data||[]):(b([]),X("通知渠道列表加载失败,请重试")),W.status==="fulfilled"?(M(W.value||[]),he(!0)):(M([]),X("通知绑定加载失败;本次保存不会修改现有绑定")),Ee(!1))},Lt=async s=>{var y;je.current+=1,(y=we.current)==null||y.abort(),L(),Se({sessionId:"",status:"idle",message:"",qrCodeUrl:""}),P(s),d({remark:s.remark||s.note||"",cookie:s.cookie||s.value||"",auto_confirm:s.auto_confirm||!1,pause_duration:s.pause_duration||0,username:s.username||"",login_password:s.login_password||"",show_browser:s.show_browser||!1,showLoginPassword:!1,clear_password:!1}),A("edit"),T({loading:!0,saving:!1,canOpen:!1,enabled:!1,error:""});const[,o]=await Promise.allSettled([mt(s.id),Vl(s.id)]);o.status==="fulfilled"?T({loading:!1,saving:!1,canOpen:o.value.can_open_long_login,enabled:o.value.enabled,error:""}):T({loading:!1,saving:!1,canOpen:!1,enabled:!1,error:"无法读取闲鱼保存登录信息状态"})},nt=async()=>{if(!E||ae.loading||ae.saving||!ae.canOpen)return;const s=!ae.enabled;T(o=>({...o,saving:!0,error:""}));try{const o=await Ql(E.id,s);T({loading:!1,saving:!1,canOpen:o.can_open_long_login,enabled:o.enabled,error:""})}catch(o){T(y=>({...y,saving:!1,error:o instanceof Error?o.message:"保存登录信息设置失败"}))}},it=async s=>{var $,W,pe,xe;const o=f.current.next();($=Ie.current)==null||$.abort();const y=new AbortController;Ie.current=y,P(s),A("ai-settings"),O(!0);try{const $e=await Er(s.id,{signal:y.signal});if(!((W=f.current)!=null&&W.isCurrent(o)))return;S({ai_enabled:$e.ai_enabled??!1,max_discount_percent:$e.max_discount_percent??10,max_discount_amount:$e.max_discount_amount??100,max_bargain_rounds:$e.max_bargain_rounds??3,custom_prompts:$e.custom_prompts??""})}catch($e){(pe=f.current)!=null&&pe.isCurrent(o)&&console.error("Failed to load AI settings:",$e)}finally{(xe=f.current)!=null&&xe.isCurrent(o)&&O(!1)}},Ot=async()=>{if(E){O(!0);try{const s={};c.remark!==(E.remark||E.note||"")&&(s.remark=c.remark),c.cookie&&c.cookie!==(E.cookie||E.value||"")&&(s.cookie=c.cookie),c.auto_confirm!==E.auto_confirm&&(s.auto_confirm=c.auto_confirm),Gr(c.pause_duration,E)&&(s.pause_duration=c.pause_duration);const o=Kr(E,c);o&&Object.assign(s,o),Hr(ne,ke)&&(s.channel_ids=U),Object.keys(s).length>0&&await Jl(E.id,s),A(null),Fe()}catch(s){console.error("更新账号失败:",s),alert("更新失败,请重试")}finally{O(!1)}}},pt=async()=>{if(!(!E||c.pause_duration<=0)){O(!0);try{const s=await Wl(E.id,c.pause_duration);P({...E,pause_duration:c.pause_duration,paused:(s==null?void 0:s.paused)===!0,paused_until:Number((s==null?void 0:s.paused_until)||0)}),await Fe()}catch(s){alert(s instanceof Error?s.message:"重新暂停失败")}finally{O(!1)}}},ut=async()=>{if(E){O(!0);try{await Dr(E.id,D),A(null),Fe()}catch(s){console.error("更新AI设置失败:",s),alert("更新失败,请重试")}finally{O(!1)}}},st=async(s,o)=>{var $;($=we.current)==null||$.abort();const y=new AbortController;we.current=y;try{const W=await Kl(s,y.signal);if(o!==je.current)return;if(W.status==="success"){L(),Se({sessionId:s,status:"success",message:W.message||"账号密码登录成功,授权信息已更新",qrCodeUrl:""}),d(pe=>({...pe,login_password:"",showLoginPassword:!1})),await Fe();return}if(W.status==="processing"||W.status==="verification_required"){Se({sessionId:s,status:W.status,message:W.message||(W.status==="verification_required"?"账号触发风控,需要完成人脸识别":"登录处理中"),qrCodeUrl:W.qr_code_url||""}),L(),te.current=window.setTimeout(()=>void st(s,o),1500);return}L(),Se({sessionId:s,status:"failed",message:W.error||W.message||"密码登录失败,请检查账号信息后重试",qrCodeUrl:""})}catch(W){if(o!==je.current)return;L(),Se({sessionId:s,status:"failed",message:W instanceof Error?W.message:"查询密码登录状态失败",qrCodeUrl:""})}},ht=async()=>{var y;if(!E)return;const s=c.username.trim();if(!s||!c.login_password){alert("请先填写登录账号和本次登录密码");return}L(),(y=we.current)==null||y.abort();const o=++je.current;Se({sessionId:"",status:"processing",message:"正在启动密码登录…",qrCodeUrl:""});try{const $=await Gl({account_id:E.id,account:s,password:c.login_password,show_browser:c.show_browser});if(o!==je.current)return;if(!$.success||!$.session_id)throw new Error($.message||"无法启动密码登录");Se({sessionId:$.session_id,status:"processing",message:$.message||"登录处理中",qrCodeUrl:""}),await st($.session_id,o)}catch($){if(o!==je.current)return;Se({sessionId:"",status:"failed",message:$ instanceof Error?$.message:"启动密码登录失败",qrCodeUrl:""})}},Ge=async()=>{var o;const s=de.sessionId;if(je.current+=1,(o=we.current)==null||o.abort(),L(),s)try{await Hl(s)}catch(y){console.error("取消密码登录失败",y)}Se({sessionId:"",status:"idle",message:"",qrCodeUrl:""})},ot=async()=>{var s,o;(s=h.current)==null||s.cancel(),(o=z.current)==null||o.abort(),(de.status==="processing"||de.status==="verification_required")&&await Ge(),A(null)},n=()=>{var s,o;(s=f.current)==null||s.cancel(),(o=Ie.current)==null||o.abort(),A(null)},w=async(s,o)=>{const y=await Bl(s,o==null?void 0:o.id);if(!y.success||!y.account_id)throw new Error(y.message||"保存扫码授权失败");return y.account_id},H=async s=>{var W,pe,xe,$e;le(),(W=Ae.current)==null||W.abort();const o=new AbortController;Ae.current=o;const y=Oe.current.next();u();const $=s||null;ve($),v(!0),ee("loading"),ge(""),ce(""),k(""),se("");try{const ie=await ql({signal:o.signal});if(!((pe=Oe.current)!=null&&pe.isCurrent(y)))return;if(!ie.success||!ie.qr_code_url||!ie.session_id)throw new Error(ie.message||"闲鱼未返回可用的登录二维码");if(ie.success&&ie.qr_code_url&&ie.session_id){const Ye=ie.session_id;ce(ie.qr_code_url),ee("waiting"),(xe=fe.current)==null||xe.start(Ye,Fl,{onSuccess:async()=>{try{if(!await w(Ye,$)){ee("error");return}}catch(Ve){console.error("保存扫码授权失败",Ve),ee("error");return}ee("success"),Ue()},onScanned:()=>{ee("waiting")},onTerminalError:()=>{ee("error")},onPollError:Ve=>{console.error("轮询扫码状态失败",Ve),ee("error")},onVerificationRequired:Ve=>{ee("verification"),Ve.face_qr_url&&se(Ve.face_qr_url),Ve.verification_screenshot&&k(Ve.verification_screenshot)}})}}catch(ie){if(!(($e=Oe.current)!=null&&$e.isCurrent(y)))return;ge(ie instanceof Error?ie.message:"二维码获取失败,请稍后重试"),ee("error")}finally{Ae.current===o&&(Ae.current=null)}};if(l)return e.jsx("div",{className:"p-20 flex justify-center",children:e.jsx(Pe,{className:"w-8 h-8 text-brand animate-spin"})});const Te=t.filter(s=>{const o=m.trim().toLowerCase();return o?[s.id,s.nickname,s.remark,s.note,s.username,s.runtime_message].some(y=>(y||"").toLowerCase().includes(o)):!0});return e.jsxs("div",{className:"space-y-8 animate-fade-in relative",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"账号管理"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("input",{value:m,onChange:s=>_(s.target.value),placeholder:"搜索昵称 / 备注 / 账号ID",className:"ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72"}),e.jsxs("button",{onClick:()=>H(),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(Xt,{className:"w-5 h-5"}),"扫码添加新账号"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 px-5 py-4 text-sm text-blue-900 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[e.jsxs("div",{className:"font-bold",children:["当前显示 ",Te.length," / ",t.length," 个账号"]}),e.jsx("div",{className:"text-blue-700",children:"如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[Te.map(s=>{const o=tt(s),y=s.runtime_state==="auth_expired"||s.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:e.jsx(xt,{className:"w-9 h-9"})}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${o.dot}`,children:s.runtime_state==="online"&&e.jsx(Ke,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:s.nickname||s.remark||`账号 ${s.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${o.badge}`,children:o.label}),s.ai_enabled&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[e.jsx(yt,{className:"w-3 h-3"})," AI"]}),s.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx(Tt,{className:"h-3 w-3"})," 自动评价"]}),s.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(vs,{className:"h-3 w-3"})," 每日擦亮"]}),s.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(Ke,{className:"h-3 w-3"})," 自动确认发货"]}),s.profile_error&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:s.profile_error,children:[e.jsx(rt,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-500",children:[e.jsx("p",{children:s.remark||s.note||"暂无备注"}),e.jsxs("p",{className:"font-mono text-xs text-gray-400",children:["ID: ",s.id]})]}),s.runtime_message&&s.runtime_state!=="online"&&s.runtime_state!=="disabled"&&e.jsxs("div",{className:`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${y?"text-red-700":"text-amber-700"}`,children:[e.jsx(rt,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:s.runtime_message}),y&&e.jsxs("button",{type:"button",onClick:()=>H(s),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100",children:[e.jsx(Xt,{className:"w-3.5 h-3.5"})," 重新授权"]})]}),s.paused&&e.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700",children:[e.jsx(Rs,{className:"h-3 w-3"})," 暂停处理中"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>St(s),disabled:N===s.id,className:"p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50",title:"刷新昵称和头像",children:e.jsx(ze,{className:`w-5 h-5 ${N===s.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>H(s),className:`p-3 rounded-xl transition-colors ${y?"text-red-600 bg-red-50 hover:bg-red-100":"text-blue-600 hover:bg-blue-50"}`,title:"重新扫码授权当前账号",children:e.jsx(Xt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Lt(s),className:"p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600",title:"编辑账号",children:e.jsx(_a,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>it(s),className:"p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600",title:"AI设置",children:e.jsx(yt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Re(s),className:"p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600",title:"自动评价与每日擦亮",children:e.jsx(ja,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>kt(s.id,s.enabled),className:`p-3 rounded-xl transition-colors ${s.enabled?"text-green-600 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:s.enabled?"停用账号":"启用账号",children:e.jsx(Za,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Je(s),disabled:g!=="",className:"p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40",title:g===s.id?"删除中…":`删除账号 ${s.nickname||s.remark||s.id}`,children:g===s.id?e.jsx(Pe,{className:"w-5 h-5 animate-spin"}):e.jsx(Qe,{className:"w-5 h-5"})})]})]})]})]})},s.id)}),t.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(xt,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"暂无账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"请点击右上角扫码添加您的闲鱼账号"})]}),t.length>0&&Te.length===0&&e.jsxs("div",{className:"ios-card p-12 text-center",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"没有匹配的账号"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"换一个关键词搜索昵称、备注或账号ID。"})]})]}),be&&qe.createPortal(e.jsx(sn,{account:be,onClose:()=>Re(null),onSaved:s=>{a(o=>o.map(y=>y.id===be.id?{...y,auto_rate_enabled:s.auto_rate_enabled,rate_content:s.rate_content,auto_polish_enabled:s.auto_polish_enabled,polish_time:s.polish_time,last_rate_scan_at:s.last_rate_scan_at,last_polish_date:s.last_polish_date,last_polish_at:s.last_polish_at}:y))}}),document.body),j&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",role:"presentation",children:e.jsxs("div",{className:"h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-modal",role:"dialog","aria-modal":"true","aria-labelledby":"delete-account-title","aria-describedby":"delete-account-description",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5",children:[e.jsx("div",{className:"absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl"}),e.jsxs("div",{className:"relative flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200",children:e.jsx(Qe,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{id:"delete-account-title",className:"text-lg font-extrabold tracking-tight text-gray-950",children:"删除这个账号?"}),e.jsx("p",{id:"delete-account-description",className:"mt-1 text-xs leading-5 text-gray-600",children:"删除后,该账号的关联配置也会一并清理,此操作无法撤销。"})]}),e.jsx("button",{type:"button",onClick:We,disabled:g!=="",className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"关闭删除确认",children:e.jsx(Me,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:j.nickname||j.remark||"未命名账号"}),j.remark&&j.nickname&&e.jsxs("div",{className:"mt-1 text-sm text-gray-500",children:["备注:",j.remark]}),e.jsxs("div",{className:"mt-1.5 break-all font-mono text-[11px] text-gray-400",children:["ID: ",j.id]})]}),g===j.id&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3",role:"progressbar","aria-label":"正在删除账号",children:[e.jsx(Pe,{className:"h-5 w-5 flex-shrink-0 animate-spin text-brand"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-blue-950",children:"正在删除账号"}),e.jsx("div",{className:"mt-0.5 text-xs text-blue-700",children:"正在清理关联数据,请保持页面打开…"})]})]}),G&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3",role:"alert",children:[e.jsx(rt,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-red-800",children:"删除失败"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-red-700",children:G})]})]})]}),e.jsxs("div",{className:"flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4",children:[e.jsx("button",{type:"button",onClick:We,disabled:g!=="",className:"flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:"取消"}),e.jsx("button",{type:"button",onClick:()=>void Ct(),disabled:g!=="",className:"flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400",children:g===j.id?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"h-4 w-4 animate-spin"}),"处理中"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{className:"h-4 w-4"}),"确认删除"]})})]})]})}),document.body),oe&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container relative",style:{maxWidth:"26rem"},children:[e.jsx("button",{onClick:_e,className:"absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:K?"重新授权账号":"扫码添加账号"}),e.jsx("p",{className:"text-gray-500 mb-8 font-medium",children:K?`请用闲鱼APP扫码,为「${K.nickname||K.remark||K.id}」刷新授权`:"请打开闲鱼APP扫描下方二维码"}),e.jsxs("div",{className:`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${Q==="verification"?"max-w-72 min-h-64 h-auto p-2":"max-w-64 aspect-square"}`,children:[Q==="loading"&&e.jsx(Pe,{className:"w-10 h-10 text-brand animate-spin"}),Q==="waiting"&&e.jsx(ea,{src:q,alt:"闲鱼登录二维码",className:"p-2"}),Q==="success"&&e.jsxs("div",{className:"absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(Ke,{className:"w-8 h-8"})}),e.jsx("span",{className:"font-bold text-lg",children:"登录成功"})]}),Q==="error"&&e.jsxs("div",{className:"px-5 text-center",children:[e.jsx("span",{className:"block text-red-600 font-bold",children:"二维码获取失败"}),e.jsx("span",{className:"mt-2 block text-xs leading-5 text-gray-500",children:B||"请关闭窗口后重新发起扫码登录。"})]}),Q==="verification"&&e.jsx(tn,{faceQrUrl:Z,verificationScreenshot:ue})]}),Q!=="verification"&&e.jsx("p",{className:"text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl",children:"二维码有效期为5分钟,请尽快扫码。"})]})})]})}),document.body),J==="edit"&&E&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑账号"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:E.nickname||E.remark||E.id})]}),e.jsx("button",{onClick:()=>void ot(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"账号ID"}),e.jsx("input",{type:"text",value:E.id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注"}),e.jsx("input",{type:"text",value:c.remark,onChange:s=>d({...c,remark:s.target.value}),placeholder:"为账号添加备注",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"Cookie"}),e.jsx("textarea",{value:c.cookie,onChange:s=>d({...c,cookie:s.target.value}),placeholder:"更新账号Cookie",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none font-mono text-xs"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["当前Cookie长度: ",c.cookie.length," 字符"]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Ke,{className:"w-4 h-4 text-green-500"}),"自动确认发货"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"自动将闲鱼订单标记为已发货"})]}),e.jsx("button",{type:"button",onClick:()=>d({...c,auto_confirm:!c.auto_confirm}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${c.auto_confirm?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${c.auto_confirm?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2 flex items-center gap-2",children:[e.jsx(Rs,{className:"w-4 h-4 text-blue-500"}),"暂停处理时长(分钟)"]}),e.jsx("input",{type:"number",value:c.pause_duration,onChange:s=>d({...c,pause_duration:parseInt(s.target.value)||0}),placeholder:"0",min:"0",max:"1440",className:"w-full ios-input px-4 py-3 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"设置后会暂停处理该账号的订单,到时间后自动恢复"}),c.pause_duration>0&&!E.paused&&c.pause_duration===(E.pause_duration||0)&&e.jsx("button",{type:"button",disabled:Y,onClick:()=>void pt(),className:"mt-3 px-4 py-2 rounded-xl bg-amber-50 text-amber-700 hover:bg-amber-100 text-sm font-bold disabled:opacity-50",children:"立即按当前时长重新暂停"})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(Ya,{className:"w-5 h-5 text-blue-500"}),"登录信息"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"保存登录信息"}),e.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"状态直接读取并修改闲鱼官方长登录设置"}),ae.error&&e.jsx("div",{className:"mt-1 text-xs text-red-600",children:ae.error})]}),e.jsx("button",{type:"button","aria-label":"保存登录信息",disabled:ae.loading||ae.saving||!ae.canOpen,onClick:()=>void nt(),className:`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${ae.enabled?"bg-brand":"bg-gray-300"} disabled:cursor-not-allowed disabled:opacity-50`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${ae.enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"用户名"}),e.jsx("input",{type:"text",value:c.username,onChange:s=>d({...c,username:s.target.value}),placeholder:"闲鱼账号/手机号",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"登录密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:c.showLoginPassword?"text":"password",value:c.login_password,onChange:s=>d({...c,login_password:s.target.value,clear_password:!1}),placeholder:"用于自动登录",className:"w-full ios-input px-4 py-3 rounded-xl pr-12"}),e.jsx("button",{type:"button",onClick:()=>d({...c,showLoginPassword:!c.showLoginPassword}),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:c.showLoginPassword?e.jsx(dt,{className:"w-5 h-5"}):e.jsx(lt,{className:"w-5 h-5"})})]}),e.jsxs("label",{className:"mt-3 flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:c.clear_password,onChange:s=>d({...c,clear_password:s.target.checked,login_password:s.target.checked?"":c.login_password}),className:"w-4 h-4 accent-brand"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:"清空已保存密码"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"登录时显示浏览器"}),e.jsx("div",{className:"text-xs text-gray-500",children:"调试时可开启查看登录过程"})]}),e.jsx("button",{type:"button",onClick:()=>d({...c,show_browser:!c.show_browser}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${c.show_browser?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${c.show_browser?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-blue-950",children:"立即执行账号密码登录"}),e.jsx("div",{className:"text-xs text-blue-700 mt-1",children:"需要在上方重新输入本次登录密码;成功后后端会更新 Cookie 和保存的登录信息。"})]}),de.status==="processing"||de.status==="verification_required"?e.jsx("button",{type:"button",onClick:Ge,className:"px-4 py-2 rounded-xl bg-white text-red-600 font-bold text-sm border border-red-100",children:"取消登录"}):e.jsx("button",{type:"button",onClick:ht,className:"px-4 py-2 rounded-xl bg-blue-600 text-white font-bold text-sm whitespace-nowrap",children:"密码登录刷新授权"})]}),de.message&&e.jsx("div",{className:`text-sm font-medium ${de.status==="failed"?"text-red-700":de.status==="success"?"text-green-700":"text-blue-800"}`,children:de.message}),de.status==="verification_required"&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-amber-900",children:[e.jsx("div",{className:"font-extrabold",children:"账号已触发平台风控,需要完成人脸识别"}),e.jsx("div",{className:"text-xs mt-1 leading-5",children:"请在闲鱼 App 或已打开的登录浏览器中按提示完成验证。本页面不会提供可直接打开的风控链接。"}),de.qrCodeUrl&&e.jsx("div",{className:"mt-3 aspect-square w-48 overflow-hidden rounded-xl border bg-white",children:e.jsx(ea,{src:de.qrCodeUrl,alt:"密码登录风控二维码",className:"p-2"})})]})]})]})]}),(p.length>0||ye||V)&&e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 mb-1 flex items-center gap-2",children:[e.jsx(jt,{className:"w-5 h-5 text-blue-500"}),"通知渠道绑定"]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"勾选后,该账号的 token 失效、自动恢复失败、风控验证等事件会推送到这些渠道"}),ye&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Pe,{className:"w-4 h-4 animate-spin"}),"正在加载通知绑定"]}),V&&!ye&&e.jsxs("div",{className:"mb-3 rounded-xl bg-amber-50 p-3 text-sm text-amber-800 flex items-center justify-between gap-3",children:[e.jsx("span",{children:V}),e.jsx("button",{type:"button",className:"font-bold whitespace-nowrap",onClick:()=>mt(E.id),children:"重试"})]}),e.jsx("div",{className:"space-y-2",children:p.map(s=>{const o=U.includes(Number(s.id));return e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-xl border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[e.jsx("button",{type:"button",onClick:()=>{ne&&(M(y=>o?y.filter($=>$!==Number(s.id)):[...y,Number(s.id)]),x(!0))},disabled:!ne,className:`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${o?"bg-brand border-brand":"bg-white border-gray-300"}`,children:o&&e.jsx(Ke,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:s.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[s.type,s.enabled?"":" · 已停用"]})]})]},s.id)})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>void ot(),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:Y,children:"取消"}),e.jsxs("button",{onClick:Ot,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:Y,children:[Y?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),Y?"保存中...":"保存"]})]})})]})}),document.body),J==="ai-settings"&&E&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"600px"},children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-2xl font-extrabold text-gray-900 flex items-center gap-2",children:[e.jsx(yt,{className:"w-6 h-6 text-purple-500"}),"AI助手设置"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:E.nickname||E.remark||E.id})]}),e.jsx("button",{onClick:n,className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-purple-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(yt,{className:"w-4 h-4 text-purple-500"}),"启用AI自动回复"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"AI将自动处理买家的砍价消息"})]}),e.jsx("button",{type:"button",onClick:()=>S({...D,ai_enabled:!D.ai_enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${D.ai_enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${D.ai_enabled?"translate-x-6":"translate-x-0"}`})})]}),e.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"砍价策略"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣比例 (%)"}),e.jsx("input",{type:"number",value:D.max_discount_percent,onChange:s=>S({...D,max_discount_percent:parseInt(s.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"100"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:10 表示最多降价 10%;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大折扣金额 (元)"}),e.jsx("input",{type:"number",value:D.max_discount_amount,onChange:s=>S({...D,max_discount_amount:parseInt(s.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"例如:100 表示最多降价 100 元;设为 0 表示不允许降价"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最大砍价轮次"}),e.jsx("input",{type:"number",value:D.max_bargain_rounds,onChange:s=>S({...D,max_bargain_rounds:parseInt(s.target.value)||1}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"10"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"买家最多可以砍价的次数"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"自定义提示词(可选)"}),e.jsx("textarea",{value:D.custom_prompts,onChange:s=>S({...D,custom_prompts:s.target.value}),placeholder:`输入自定义的AI回复规则或风格指引... + +例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(js,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:n,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:Y,children:"取消"}),e.jsxs("button",{onClick:ut,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:Y,children:[Y?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),Y?"保存中...":"保存"]})]})})]})}),document.body)]})},ln=t=>({total:Number((t==null?void 0:t.total)||0),success_count:Number((t==null?void 0:t.success_count)||0),failed_count:Number((t==null?void 0:t.failed_count)||0),results:Array.isArray(t==null?void 0:t.results)?t.results.map(a=>({order_id:String((a==null?void 0:a.order_id)||"unknown"),success:(a==null?void 0:a.success)===!0,message:String((a==null?void 0:a.message)||"")})):[]}),rn=t=>(t==null?void 0:t.results.filter(a=>!a.success))||[],sa=({status:t})=>{const a={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-brand text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},l={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${a[t]||a.cancelled}`,children:l[t]||t})},nn=()=>{const[t,a]=r.useState([]),[l,i]=r.useState([]),[m,_]=r.useState([]),[N,I]=r.useState({}),[g,C]=r.useState("all"),[j,F]=r.useState(""),[G,me]=r.useState(""),[oe,v]=r.useState(""),q=r.useRef(0),[ce,Q]=r.useState(1),[ee,B]=r.useState(1),[ge,ue]=r.useState(!1),[k,Z]=r.useState(!1),[se,K]=r.useState(!1),[ve,J]=r.useState(!1),[A,E]=r.useState(null),[P,be]=r.useState(null),[Re,ae]=r.useState({}),[T,p]=r.useState(!1),[b,U]=r.useState(""),[M,ne]=r.useState(!1),[he,ye]=r.useState(null),[Ee,ke]=r.useState(null),[x,V]=r.useState(null),[X,c]=r.useState(!1),[d,D]=r.useState(null),[S,Y]=r.useState(null),O=async()=>{const u=++q.current;ue(!0);try{const L=await Xl(j||void 0,g,ce,20,oe);if(u!==q.current)return;a(L.data),B(L.total_pages)}catch(L){console.error("加载订单失败:",L)}finally{u===q.current&&ue(!1)}},de=(u,L,le)=>{if(le&&le.trim())return le;if(N[`${u}:${L}`])return N[`${u}:${L}`];const _e=l.find(Ue=>{if(le&&Ue.item_title){const Fe=le.toLowerCase(),tt=Ue.item_title.toLowerCase();return tt.includes(Fe)||Fe.includes(tt)}return!1});return _e!=null&&_e.item_title?_e.item_title:"未知商品"},Se=u=>{const L={};u.forEach(le=>{le.item_id&&(L[`${le.cookie_id}:${le.item_id}`]=le.item_title||le.item_id)}),I(L)};r.useEffect(()=>{const u=window.setTimeout(()=>{Q(1),v(G.trim())},300);return()=>window.clearTimeout(u)},[G]),r.useEffect(()=>{O()},[j,g,ce,oe]),r.useEffect(()=>{Promise.all([Ft(),vt()]).then(([u,L])=>{_(u),i(L),Se(L)}).catch(u=>{console.error("加载商品列表失败:",u)})},[]);const fe=r.useMemo(()=>new Map(m.map(u=>[u.id,u])),[m]),Oe=u=>{const L=fe.get(u),le=(L==null?void 0:L.remark)||(L==null?void 0:L.nickname);return le?`${le} · ${u.slice(0,6)}`:`账号 ${u.slice(0,8)}`},re=u=>{const L=fe.get(u);return(L==null?void 0:L.remark)||(L==null?void 0:L.nickname)||"未命名账号"},h=async()=>{ue(!0);try{const u=await sr(j||void 0,g);await O(),u!=null&&u.message&&alert(u.message)}catch(u){console.error("同步订单失败:",u),alert((u==null?void 0:u.message)||"同步失败,请重试")}finally{ue(!1)}},f=u=>{U(u),ye(null),p(!0)},R=async u=>{var L;ne(!0),ye(null);try{const le=await lr([b],u),_e=(L=le==null?void 0:le.results)==null?void 0:L[0];_e!=null&&_e.success?(ye({success:!0,message:_e.message}),O()):ye({success:!1,message:(_e==null?void 0:_e.message)||"发货失败"})}catch(le){ye({success:!1,message:(le==null?void 0:le.message)||"请求失败"})}finally{ne(!1)}},z=u=>{E(u),Z(!0)},Ie=u=>{be({...u}),K(!0)},Ae=async()=>{if(!(!P||!P.order_id))try{const u={};P.status!==void 0&&(u.order_status=P.status),P.buyer_id!==void 0&&(u.buyer_id=P.buyer_id),P.amount!==void 0&&(u.amount=P.amount),P.receiver_name!==void 0&&(u.receiver_name=P.receiver_name),P.receiver_phone!==void 0&&(u.receiver_phone=P.receiver_phone),P.receiver_address!==void 0&&(u.receiver_address=P.receiver_address),P.item_id!==void 0&&(u.item_id=P.item_id),P.quantity!==void 0&&(u.quantity=P.quantity),P.item_title!==void 0&&(u.item_title=P.item_title),await er(P.order_id,u),K(!1),be(null),O()}catch(u){console.error("更新订单失败:",u),alert("更新失败,请重试")}},we=async()=>{if(Ee){c(!0);try{const u=new FormData;u.append("file",Ee);const L=ln(await rr(u));V(L),ke(null),await O(),L.failed_count===0&&(J(!1),V(null),alert(`订单导入成功,共 ${L.success_count} 条`))}catch(u){alert((u==null?void 0:u.message)||"导入失败,请检查文件格式")}finally{c(!1)}}},De=()=>{X||(J(!1),ke(null),V(null))},te=async u=>{D(u);try{const L=await ar(u);L.success?await O():alert(L.message||"同步失败")}catch(L){console.error("同步订单失败:",L),alert((L==null?void 0:L.message)||"同步失败,请重试")}finally{D(null)}},je=async u=>{if(confirm("确认删除该订单吗?删除后无法恢复。")){Y(u);try{await tr(u),t.length===1&&ce>1?Q(L=>L-1):await O()}catch(L){console.error("删除订单失败:",L),alert((L==null?void 0:L.message)||"删除失败,请重试"),await O()}finally{Y(null)}}};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"订单中心"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"查看所有闲鱼交易记录与状态。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:O,className:"p-3 rounded-2xl bg-white border border-gray-100 text-gray-600 hover:bg-gray-50 hover:text-black transition-colors shadow-sm",children:e.jsx(ze,{className:`w-5 h-5 ${ge?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{V(null),J(!0)},className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors text-sm flex items-center gap-2 shadow-lg",children:[e.jsx(et,{className:"w-4 h-4"}),"插入订单"]}),e.jsxs("button",{onClick:h,className:"ios-btn-primary px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 text-sm flex items-center gap-2",children:[e.jsx(Es,{className:"w-5 h-5"}),"一键同步订单"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:[{k:"all",v:"全部"},{k:"processing",v:"处理中"},{k:"shipped",v:"已发货"},{k:"pending_ship",v:"待发货"},{k:"completed",v:"已完成"},{k:"cancelled",v:"已取消"},{k:"refunding",v:"退款中"}].map(u=>e.jsx("button",{onClick:()=>{C(u.k),Q(1),me("")},className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${g===u.k?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:u.v},u.k))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:j,onChange:u=>{F(u.target.value),Q(1)},className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),m.map(u=>e.jsx("option",{value:u.id,children:Oe(u.id)},u.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Nt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:G,onChange:u=>{me(u.target.value),Q(1)},className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]}),e.jsx("div",{className:"overflow-x-auto min-h-[400px]",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"px-6 py-5",style:{width:"28%"},children:"订单信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"26%"},children:"买家信息"}),e.jsx("th",{className:"px-6 py-5",style:{width:"11%"},children:"实付金额"}),e.jsx("th",{className:"px-6 py-5",style:{width:"13%"},children:"当前状态"}),e.jsx("th",{className:"px-6 py-5 text-right",style:{width:"22%"},children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.map(u=>e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0",children:u.item_image?e.jsx("img",{src:u.item_image,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(qt,{})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-gray-900 line-clamp-1 text-sm",children:de(u.cookie_id,u.item_id,u.item_title)}),e.jsxs("div",{className:"mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:re(u.cookie_id),children:[e.jsx(xt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:re(u.cookie_id)})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-medium",children:["订单ID: ",u.order_id]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5",children:["数量: ",u.quantity," • ",bs(u.created_at)]})]})]})}),e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"买家ID"}),e.jsx("div",{className:"text-sm font-bold text-gray-800",children:u.buyer_id}),u.receiver_name&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货人"}),e.jsx("div",{className:"text-xs text-gray-600",children:u.receiver_name})]}),u.receiver_phone&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"联系电话"}),e.jsx("div",{className:"text-xs text-gray-600 font-mono",children:u.receiver_phone})]}),u.receiver_address&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"收货地址"}),e.jsx("div",{className:"text-xs text-gray-600 line-clamp-1",children:u.receiver_address})]})]})}),e.jsx("td",{className:"px-6 py-5 text-base font-extrabold text-gray-900 font-feature-settings-tnum",children:u.amount?`¥${u.amount}`:e.jsx("span",{className:"text-xs text-amber-600 font-bold",children:"待获取"})}),e.jsx("td",{className:"px-6 py-5",children:e.jsx(sa,{status:u.status})}),e.jsxs("td",{className:"px-6 py-5 text-right",children:[u.status==="pending_ship"&&e.jsx("button",{onClick:()=>f(u.order_id),className:"mr-2 text-white bg-black hover:bg-gray-800 shadow-lg shadow-gray-200 text-xs font-bold px-3 py-2 rounded-xl transition-all active:scale-95",children:"立即发货"}),e.jsx("a",{href:`https://www.goofish.com/order-detail?orderId=${u.order_id}&role=seller`,target:"_blank",rel:"noopener noreferrer",className:"mr-2 inline-flex text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看闲鱼详情",children:e.jsx(ya,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>z(u),className:"mr-2 text-gray-400 hover:text-blue-600 p-2 rounded-xl hover:bg-blue-50 transition-colors",title:"查看详情",children:e.jsx(lt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ie(u),className:"mr-2 text-gray-400 hover:text-black p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"编辑订单",children:e.jsx(_t,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(u.order_id),disabled:d===u.order_id,className:"mr-2 text-gray-400 hover:text-green-600 p-2 rounded-xl hover:bg-green-50 transition-colors disabled:opacity-50",title:"同步订单",children:e.jsx(ze,{className:`w-4 h-4 ${d===u.order_id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>je(u.order_id),disabled:S===u.order_id,className:"text-gray-400 hover:text-red-500 p-2 rounded-xl hover:bg-red-50 transition-colors disabled:opacity-50",title:"删除订单",children:e.jsx(Qe,{className:"w-4 h-4"})})]})]},u.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-50 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"text-sm text-gray-500 font-medium pl-2",children:["第 ",ce," 页 / 共 ",ee," 页"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:ce<=1,onClick:()=>Q(u=>u-1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(Ns,{className:"w-5 h-5"})}),e.jsx("button",{disabled:ce>=ee,onClick:()=>Q(u=>u+1),className:"p-2.5 rounded-xl bg-gray-50 hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed text-gray-600 transition-colors",children:e.jsx(_s,{className:"w-5 h-5"})})]})]})]}),k&&A&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"订单详情"}),e.jsx("button",{onClick:()=>Z(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"订单信息"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"订单号"}),e.jsx("div",{className:"font-mono text-sm font-bold text-gray-900",children:A.order_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"所属账号"}),e.jsx("div",{className:"truncate whitespace-nowrap text-sm font-bold text-blue-700",title:re(A.cookie_id),children:re(A.cookie_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"状态"}),e.jsx(sa,{status:A.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"实付金额"}),e.jsx("div",{className:"text-lg font-extrabold text-gray-900",children:A.amount?`¥${A.amount}`:"待获取"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"数量"}),e.jsx("div",{className:"font-bold text-gray-900",children:A.quantity})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"创建时间"}),e.jsx("div",{className:"text-sm font-medium text-gray-700",children:bs(A.created_at)})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"商品信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl flex items-center gap-4",children:[A.item_image&&e.jsx("img",{src:A.item_image,alt:"",className:"w-20 h-20 rounded-xl object-cover border border-gray-200"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-bold text-gray-900 mb-1",children:de(A.cookie_id,A.item_id,A.item_title)}),e.jsxs("div",{className:"text-sm text-gray-500",children:["商品ID: ",A.item_id]}),A.item_price&&e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:["标价: ¥",A.item_price]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-gray-800",children:"买家信息"}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"买家ID"}),e.jsx("div",{className:"font-bold text-gray-900",children:A.buyer_id})]}),A.receiver_name&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货人"}),e.jsx("div",{className:"font-medium text-gray-700",children:A.receiver_name})]}),A.receiver_phone&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"联系电话"}),e.jsx("div",{className:"font-mono text-sm text-gray-700",children:A.receiver_phone})]}),A.receiver_address&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"收货地址"}),e.jsx("div",{className:"text-sm text-gray-700",children:A.receiver_address})]})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>Z(!1),className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"关闭"}),A.status==="pending_ship"&&e.jsx("button",{onClick:()=>{Z(!1),f(A.order_id)},className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200",children:"立即发货"})]})})]})}),document.body),ve&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:De,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:u=>{var L;return ke(((L=u.target.files)==null?void 0:L[0])||null)},className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),Ee&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dt,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:Ee.name})]})}),x&&x.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",x.success_count," 条,失败 ",x.failed_count," 条"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"订单ID"}),e.jsx("th",{className:"px-3 py-2",children:"失败原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:rn(x).map((u,L)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:u.order_id}),e.jsx("td",{className:"px-3 py-2 text-red-600",children:u.message||"导入失败"})]},`${u.order_id}-${L}`))})]})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:De,disabled:X,className:"flex-1 px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:"取消"}),e.jsx("button",{onClick:we,disabled:!Ee||X,className:"flex-1 px-6 py-3 rounded-xl ios-btn-primary font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:X?"正在导入…":"导入订单"})]})})]})}),document.body),T&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"480px"},children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"立即发货"}),e.jsx("button",{onClick:()=>{p(!1),ye(null)},className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"请选择发货方式:"}),e.jsx("button",{onClick:()=>R("status_only"),disabled:M,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-gray-400 hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Es,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"仅修改闲鱼发货状态"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:'不实际扣除或发送卡券,仅在闲鱼平台将订单标记为"已发货"。 适用于已经给客户发过货、只是忘记在闲鱼修改状态的情况。'})]})]})}),e.jsx("button",{onClick:()=>R("full_delivery"),disabled:M,className:"w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(qt,{className:"w-5 h-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900 text-sm",children:"完整发货(匹配卡券并发送)"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"自动匹配发货规则、获取卡券、发送卡券信息给买家,并修改发货状态。 适用于订单既没有发送卡券给买家、也没有修改发货状态的情况。"})]})]})}),M&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[e.jsx(ze,{className:"w-4 h-4 animate-spin text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"正在处理中..."})]}),he&&e.jsxs("div",{className:`p-3 rounded-xl text-sm ${he.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[he.success?"✓ ":"✗ ",he.message]})]}),e.jsx("div",{className:"modal-footer",children:e.jsx("button",{onClick:()=>{p(!1),ye(null)},className:"w-full px-6 py-3 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold transition-colors",children:he!=null&&he.success?"完成":"取消"})})]})}),document.body),se&&P&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑订单"}),e.jsx("button",{onClick:()=>K(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单号"}),e.jsx("input",{type:"text",value:P.order_id,disabled:!0,className:"w-full ios-input px-4 py-3 rounded-xl bg-gray-50 text-gray-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"订单状态"}),e.jsxs("select",{value:P.status,onChange:u=>be({...P,status:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"processing",children:"处理中"}),e.jsx("option",{value:"pending_ship",children:"待发货"}),e.jsx("option",{value:"shipped",children:"已发货"}),e.jsx("option",{value:"completed",children:"已完成"}),e.jsx("option",{value:"cancelled",children:"已取消"}),e.jsx("option",{value:"refunding",children:"退款中"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"买家ID"}),e.jsx("input",{type:"text",value:P.buyer_id,onChange:u=>be({...P,buyer_id:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"实付金额"}),e.jsx("input",{type:"number",value:P.amount,onChange:u=>be({...P,amount:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货人"}),e.jsx("input",{type:"text",value:P.receiver_name||"",onChange:u=>be({...P,receiver_name:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"联系电话"}),e.jsx("input",{type:"text",value:P.receiver_phone||"",onChange:u=>be({...P,receiver_phone:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"收货地址"}),e.jsx("textarea",{value:P.receiver_address||"",onChange:u=>be({...P,receiver_address:u.target.value}),rows:2,className:"w-full ios-input px-4 py-3 rounded-xl resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"商品标题"}),e.jsx("input",{type:"text",value:P.item_title||"",onChange:u=>be({...P,item_title:u.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>K(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Ae,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body)]})},on=(t,a,l)=>{const i=l.trim().toLocaleLowerCase();return t.filter(m=>(!a||m.type===a)&&(!i||m.name.toLocaleLowerCase().includes(i)))},aa=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),cn=()=>{const[t,a]=r.useState([]),[l,i]=r.useState(!1),[m,_]=r.useState(!1),[N,I]=r.useState(null),[g,C]=r.useState({}),[j,F]=r.useState(aa),[G,me]=r.useState(!1),[oe,v]=r.useState("create"),[q,ce]=r.useState(null),[Q,ee]=r.useState(null),[B,ge]=r.useState(!1),[ue,k]=r.useState(""),[Z,se]=r.useState(""),[K,ve]=r.useState(null),[J,A]=r.useState(""),[E,P]=r.useState("");r.useEffect(()=>{Xe().then(a)},[]);const be=({type:x})=>{switch(x){case"text":return e.jsx(Ds,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Ts,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(sl,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(os,{className:"w-5 h-5 text-gray-500"})}},Re=x=>{var V,X,c,d,D;I(x),C({id:x.id,name:x.name||"",type:x.type||"text",api_url:((V=x.api_config)==null?void 0:V.url)||"",api_method:((X=x.api_config)==null?void 0:X.method)||"GET",api_timeout:((c=x.api_config)==null?void 0:c.timeout)||10,api_headers:((d=x.api_config)==null?void 0:d.headers)||"",api_params:((D=x.api_config)==null?void 0:D.params)||"",text_content:x.text_content||"",data_content:x.data_content||"",image_url:x.image_url||"",delay_seconds:x.delay_seconds||0,description:x.description||"",enabled:x.enabled}),i(!0)},ae=async()=>{var x,V,X,c,d,D,S,Y;if(N){if(!((x=g.name)!=null&&x.trim())){alert("请输入卡密名称");return}if(!g.type){alert("请选择卡密类型");return}try{const O={name:g.name.trim(),type:g.type,description:(V=g.description)==null?void 0:V.trim(),delay_seconds:g.delay_seconds||0,enabled:g.enabled??!0};g.type==="api"?O.api_config={url:((X=g.api_url)==null?void 0:X.trim())||"",method:g.api_method,timeout:g.api_timeout||10,headers:((c=g.api_headers)==null?void 0:c.trim())||void 0,params:((d=g.api_params)==null?void 0:d.trim())||void 0}:g.type==="text"?O.text_content=((D=g.text_content)==null?void 0:D.trim())||"":g.type==="data"?O.data_content=((S=g.data_content)==null?void 0:S.trim())||"":g.type==="image"&&(O.image_url=((Y=g.image_url)==null?void 0:Y.trim())||""),await Ks(N.id,O),i(!1),Xe().then(a)}catch(O){console.error("更新卡密失败:",O),alert("更新失败,请重试")}}},T=async x=>{if(confirm("确认删除该卡密吗?"))try{await dr(x),Xe().then(a)}catch(V){console.error("删除卡密失败:",V),alert("删除失败,请重试")}},p=async()=>{if(!j.name.trim()){alert("请输入卡密名称");return}if(!j.content.trim()){alert(j.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const x={name:j.name.trim(),type:j.type,description:j.description.trim(),enabled:j.enabled,delay_seconds:j.delay_seconds};j.type==="text"&&(x.text_content=j.content.trim()),j.type==="data"&&(x.data_content=j.content.trim()),j.type==="image"&&(x.image_url=j.content.trim()),j.type==="api"&&(x.api_config={url:j.content.trim(),method:j.api_method,timeout:j.api_timeout,headers:j.api_headers.trim()||void 0,params:j.api_params.trim()||void 0}),await cr(x),_(!1),F(aa()),Xe().then(a)}catch(x){console.error("添加卡密失败:",x),alert("添加失败,请重试")}},b=async x=>{try{await Ks(x.id,{...x,enabled:!x.enabled}),Xe().then(a)}catch(V){console.error("切换状态失败:",V)}},U=async x=>{try{await navigator.clipboard.writeText(String(x)),alert(`已复制卡密组ID:${x}`)}catch{prompt("复制卡密组ID",String(x))}},M=t.filter(x=>x.type==="data"),ne=r.useMemo(()=>on(t,J,E),[t,E,J]),he=()=>{const X=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001 +VIP-MONTH-002 +VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(S=>S.map(Y=>`"${String(Y).replace(/"/g,'""')}"`).join(",")).join(` +`),c=new Blob(["\uFEFF"+X],{type:"text/csv;charset=utf-8"}),d=URL.createObjectURL(c),D=document.createElement("a");D.href=d,D.download="卡密组批量导入模板.csv",document.body.appendChild(D),D.click(),D.remove(),URL.revokeObjectURL(d)},ye=async()=>{if(q){ge(!0),ee(null);try{const x=await xr(q);if(ee(x),x.created>0){const V=await Xe();a(V)}}catch(x){ee({error:(x==null?void 0:x.message)||"上传失败"})}finally{ge(!1)}}},Ee=async()=>{if(!(!ue||!Z.trim())){ge(!0),ve(null);try{const x=await mr(ue,Z);ve({added:x.added}),se("");const V=await Xe();a(V)}catch(x){alert("追加失败:"+((x==null?void 0:x.message)||"未知错误"))}finally{ge(!1)}}},ke=()=>{var x;v("create"),ce(null),ee(null),k((x=M[0])!=null&&x.id?String(M[0].id):""),se(""),ve(null),me(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:ke,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Dt,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>_(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(et,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Na,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:J,onChange:x=>A(x.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(Nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:E,onChange:x=>P(x.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",ne.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:ne.map(x=>{let V="";return x.type==="data"&&x.data_content?V=`库存: ${x.data_content.split(` +`).filter(c=>c.trim()).length} 条`:x.type==="text"&&x.text_content?V=x.text_content:x.type==="api"&&x.api_config?V=x.api_config.url:x.type==="image"&&x.image_url&&(V="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(be,{type:x.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:x.name,children:x.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>U(x.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:x.id}),e.jsx(Xa,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${x.type==="text"?"bg-blue-50 text-blue-600":x.type==="data"?"bg-purple-50 text-purple-600":x.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:x.type==="text"?"文本":x.type==="data"?"批量":x.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:V,children:V})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:x.description||"-",children:x.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>b(x),className:`w-12 h-8 rounded-full relative transition-colors ${x.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${x.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>Re(x),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(_t,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>T(x.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Qe,{className:"h-4 w-4"})})]})})]},x.id)})})]})}),ne.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(fa,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),l&&N&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>i(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:g.name||"",onChange:x=>C({...g,name:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:g.type||"text",onChange:x=>C({...g,type:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(N==null?void 0:N.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),g.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:g.api_url||"",onChange:x=>C({...g,api_url:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求方法"}),e.jsxs("select",{value:g.api_method||"GET",onChange:x=>C({...g,api_method:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"超时时间(秒)"}),e.jsx("input",{type:"number",value:g.api_timeout||10,onChange:x=>C({...g,api_timeout:parseInt(x.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"1",max:"60"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求头(JSON 格式)"}),e.jsx("textarea",{value:g.api_headers||"",onChange:x=>C({...g,api_headers:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"Authorization": "Bearer token"}'})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"请求参数(JSON 格式)"}),e.jsx("textarea",{value:g.api_params||"",onChange:x=>C({...g,api_params:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-20 resize-none font-mono text-sm",placeholder:'{"type": "card", "count": 1}'})]})]}),g.type==="text"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"固定文字配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"文字内容"}),e.jsx("textarea",{value:g.text_content||"",onChange:x=>C({...g,text_content:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none",placeholder:"请输入要发送的固定文字内容..."})]})]}),g.type==="data"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"批量数据配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"数据内容(一行一个)"}),e.jsx("textarea",{value:g.data_content||"",onChange:x=>C({...g,data_content:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-80 resize-none font-mono text-sm",placeholder:`请输入数据,每行一个: +卡号1:密码1 +卡号2:密码2 +或者 +兑换码1 +兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:g.data_content?g.data_content.split(` +`).filter(x=>x.trim()).length:0})," 条"]})]})]}),g.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:g.image_url||"",onChange:x=>C({...g,image_url:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),g.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:g.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:x=>{x.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:g.delay_seconds||0,onChange:x=>C({...g,delay_seconds:parseInt(x.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:g.description||"",onChange:x=>C({...g,description:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>C({...g,enabled:!g.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${g.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${g.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>i(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:ae,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),m&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>_(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:j.name,onChange:x=>F({...j,name:x.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>F({...j,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(os,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>F({...j,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Ds,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>F({...j,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${j.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Ts,{className:"w-5 h-5 mx-auto mb-1"}),"图片"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:j.type==="data"?"库存内容(一行一个)":j.type==="text"?"固定回复内容":j.type==="image"?"图片 URL":"API 地址"}),j.type==="api"?e.jsx("input",{type:"url",value:j.content,onChange:x=>F({...j,content:x.target.value}),placeholder:"https://api.example.com/get-code",className:"w-full ios-input px-4 py-3 rounded-xl"}):j.type==="image"?e.jsx("input",{type:"url",value:j.content,onChange:x=>F({...j,content:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://example.com/card.png"}):e.jsx("textarea",{value:j.content,onChange:x=>F({...j,content:x.target.value}),className:`w-full ios-input px-4 py-3 rounded-xl resize-none text-sm ${j.type==="data"?"h-48 font-mono":"h-32"}`,placeholder:j.type==="data"?`CODE-123456 +CODE-789012 +...`:"请输入每次发货时发送的固定文字"}),j.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:j.content.split(` +`).filter(x=>x.trim()).length})," 条"]})]}),j.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:j.api_method,onChange:x=>F({...j,api_method:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:j.api_timeout,onChange:x=>F({...j,api_timeout:parseInt(x.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:j.api_headers,onChange:x=>F({...j,api_headers:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:j.api_params,onChange:x=>F({...j,api_params:x.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:j.description,onChange:x=>F({...j,description:x.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:j.delay_seconds,onChange:x=>F({...j,delay_seconds:parseInt(x.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>_(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:p,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(et,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),G&&qe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>me(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>v("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${oe==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(el,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>v("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${oe==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Dt,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),oe==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:he,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[e.jsx(tl,{className:"w-4 h-4"}),"下载模板"]}),e.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[e.jsx(Dt,{className:"w-4 h-4"}),q?q.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:x=>{var V;return ce(((V=x.target.files)==null?void 0:V[0])||null)}})]})]}),Q&&!Q.error&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[e.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",Q.total," 行 · 成功 ",Q.created," · 失败 ",Q.failed]}),Q.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:Q.rows.filter(x=>!x.success).map(x=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",x.row_no," 行「",x.name,"」:",x.error]},x.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:M.length===0?e.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),e.jsx("select",{value:ue,onChange:x=>k(x.target.value),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:M.map(x=>e.jsxs("option",{value:String(x.id),children:[x.name,"(ID: ",x.id,")"]},x.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),e.jsx("textarea",{value:Z,onChange:x=>se(x.target.value),placeholder:`VIP-001 +VIP-002 +VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),K&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",K.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>me(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),oe==="create"?e.jsxs("button",{onClick:ye,disabled:!q||B,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[B?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(Dt,{className:"w-4 h-4"}),B?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:Ee,disabled:!ue||!Z.trim()||B||M.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[B?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(et,{className:"w-4 h-4"}),B?"处理中...":"追加卡密"]})]})]})}),document.body)]})},dn=t=>t.find(a=>a.status==="running"||a.status==="canceling"),la="ydisks-amap-js-api",xn="c9b68d4ce9a2a97f22a4a439404488ca";let $t=null;const mn=()=>xn,pn=()=>window.AMap?Promise.resolve(window.AMap):$t||($t=new Promise((t,a)=>{const l=document.getElementById(la),i=l||document.createElement("script"),m=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(N)},_=()=>{window.AMap?(m(),t(window.AMap)):(m(),a(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},N=window.setTimeout(()=>{m(),a(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=_,i.id=la,i.async=!0,i.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(mn())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,i.onerror=()=>{m(),a(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},l||document.head.appendChild(i)}).catch(t=>{throw $t=null,t}),$t),Ht=t=>Number.isFinite(t)&&t!==0,un=t=>{var m,_;const a=Number((m=t.location)==null?void 0:m.lng),l=Number((_=t.location)==null?void 0:_.lat),i={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:a,latitude:l,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!i.division_id||!i.province||!i.city||!i.poi_id||!i.poi_name||!Ht(a)||!Ht(l)||a<-180||a>180||l<-90||l>90?null:i},hn=async(t,a)=>{if(!Ht(t)||!Ht(a)||t<-180||t>180||a<-90||a>90)throw new Error("经纬度无效");const l=await pn();return new Promise((i,m)=>{new l.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,a],1e3,(N,I)=>{var C;if(N!=="complete"){if(N==="no_data"){i([]);return}m(new Error("高德地图附近地址查询失败,请稍后重试"));return}const g=(((C=I==null?void 0:I.poiList)==null?void 0:C.pois)||[]).map(un).filter(j=>j!==null);i(g)})})},gn=t=>{const a=String(t||"").trim();return a?/^[¥¥]/.test(a)?a:`¥${a}`:"-"},bn=({onConfigureDelivery:t})=>{const[a,l]=r.useState([]),[i,m]=r.useState([]),[_,N]=r.useState([]),[I,g]=r.useState(""),[C,j]=r.useState(""),[F,G]=r.useState(!1),[me,oe]=r.useState(!1),[v,q]=r.useState(!1),[ce,Q]=r.useState(!1),[ee,B]=r.useState(!1),[ge,ue]=r.useState(!1),[k,Z]=r.useState(!1),[se,K]=r.useState("upload"),[ve,J]=r.useState(null),[A,E]=r.useState(null),[P,be]=r.useState(""),[Re,ae]=r.useState(!1),[T,p]=r.useState(!1),[b,U]=r.useState([]),[M,ne]=r.useState(null),[he,ye]=r.useState([]),[Ee,ke]=r.useState(null),[x,V]=r.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[X,c]=r.useState(null),[d,D]=r.useState(null),[S,Y]=r.useState(null),O=r.useRef(!1),[de,Se]=r.useState(null),[fe,Oe]=r.useState({}),[re,h]=r.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[f,R]=r.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[z,Ie]=r.useState([]);r.useEffect(()=>{if(!ge||f.images.length===0){Ie([]);return}const n=f.images.map((w,H)=>({key:w.name+H,url:URL.createObjectURL(w)}));return Ie(n),()=>{n.forEach(w=>URL.revokeObjectURL(w.url))}},[ge,f.images]);const Ae=async()=>{const n=await vt();l(n)},we=async()=>{m(await gs())};r.useEffect(()=>{Promise.all([Ft(),vt(),gs(),Hs(20)]).then(([n,w,H,Te])=>{N(n),l(w),m(H);const s=Te.find(o=>["running","canceling"].includes(o.status))||Te.find(o=>o.status!=="preview");Y(s||null)}).catch(n=>console.error("加载商品配置失败:",n))},[]),r.useEffect(()=>{if(!k||!(d!=null&&d.id)||!["running","canceling"].includes(d.status))return;const n=window.setInterval(async()=>{if(!O.current){O.current=!0;try{const w=await bt(d.id);D(w),Y(w),["running","canceling"].includes(w.status)||(K("done"),await Ae(),await we())}catch(w){console.error("刷新批量铺货进度失败:",w)}finally{O.current=!1}}},3e3);return()=>{window.clearInterval(n)}},[k,d==null?void 0:d.id,d==null?void 0:d.status]);const De=async()=>{if(!I)return alert("请先选择账号");G(!0);try{const n=await pr(I);await Ae(),alert((n==null?void 0:n.message)||"商品同步完成")}catch(n){console.error("同步商品失败:",n),alert((n==null?void 0:n.message)||"同步失败,请重试")}finally{G(!1)}},te=n=>{Se(n),Oe({...n}),Q(!0)},je=async()=>{if(de)try{await vr(de.cookie_id,de.item_id,{item_title:fe.item_title||"",item_description:fe.item_description||"",item_category:fe.item_category||"",item_price:fe.item_price||"",item_detail:fe.item_detail||de.item_detail||""}),await Ae(),await we(),Q(!1),Se(null)}catch(n){console.error("更新商品失败:",n),alert("更新失败,请重试")}},u=async n=>{if(confirm(`确认删除商品"${n.item_title}"吗?`))try{await ur(n.cookie_id,n.item_id),l(w=>w.filter(H=>!(H.cookie_id===n.cookie_id&&H.item_id===n.item_id)))}catch(w){console.error("删除商品失败:",w),alert("删除失败,请重试")}},L=async()=>{try{if(!re.cookie_id||!re.item_id){alert("请选择账号并填写商品ID");return}await hr(re.cookie_id,{item_id:re.item_id,item_title:re.item_title,item_price:re.item_price,item_detail:re.item_image?JSON.stringify({item_image:re.item_image}):""}),await Ae(),B(!1),h({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(n){console.error("添加商品失败:",n),alert("添加失败,请重试")}},le=async()=>{if(!f.cookie_id)return alert("请选择发布账号");if(!f.title.trim())return alert("请填写商品标题");if(!f.price.trim())return alert("请填写商品价格");if(!f.quantity||Number(f.quantity)<=0)return alert("库存数量必须大于 0");if(f.images.length===0)return alert("至少上传 1 张商品图片");if(f.postage_mode==="fixed"&&!f.postage.trim())return alert("请填写一口价邮费");oe(!0);try{const n=await gr({...f,location:M||void 0});if(await Ae(),ue(!1),R({cookie_id:I||"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),U([]),ne(null),n!=null&&n.item_id){const w={id:n.item_id,cookie_id:f.cookie_id,item_id:n.item_id,item_title:n.item_title||f.title,item_price:n.item_price||f.price,item_image:n.item_image};t(w),alert("商品发布成功,ID: "+n.item_id+",已为你打开发货规则配置")}else alert("商品发布成功")}catch(n){console.error("发布商品失败:",n);const w=n==null?void 0:n.payload;if((w==null?void 0:w.code)==="stock_permission_missing"){alert("发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。");return}alert((n==null?void 0:n.message)||"发布失败,请重试")}finally{oe(!1)}},_e=async()=>{K("upload"),c(null),D(null),J(null),E(null),be(""),V({catId:"",catName:"",channelCatId:"",tbCatId:""}),ye([]),ke(null),Z(!0),q(!0);try{const n=await Hs(20),w=dn(n);if(w!=null&&w.id){const H=await bt(w.id);Y(H),D(H),K(["running","canceling"].includes(H.status)?"running":"done")}}catch(n){console.error("恢复最近批量铺货任务失败:",n)}finally{q(!1)}},Ue=async()=>{const n=P.trim();if(!I)return alert("请先选择默认发布账号");if(!n)return alert("请输入类目关键词");ae(!0);try{const H=(await br(I,n)).category;V({catId:H.cat_id,catName:H.cat_name,channelCatId:H.channel_cat_id,tbCatId:H.tb_cat_id||""})}catch(w){console.error("获取推荐类目失败:",w),alert((w==null?void 0:w.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{ae(!1)}},Fe=async()=>{if(S!=null&&S.id){q(!0),Z(!0);try{const n=await bt(S.id);D(n),K(["running","canceling"].includes(n.status)?"running":"done")}catch(n){console.error("加载最近批量铺货结果失败:",n)}finally{q(!1)}}},tt=async()=>{if(!ve)return alert("请先上传商品表格");if(!I)return alert("请先选择默认发布账号");q(!0);try{const n=await fr({file:ve,imagesZip:A,defaultCookieId:I,fallbackCategory:x,location:Ee||void 0});c(n),D(null),K("preview")}catch(n){console.error("批量铺货预检失败:",n),alert((n==null?void 0:n.message)||"预检失败,请检查表格和图片 zip")}finally{q(!1)}},kt=async()=>{if(X!=null&&X.preview_id){if(X.valid<=0)return alert("没有可发布的商品行");q(!0);try{const n=await yr(X.preview_id),w=await bt(n.batch_id||X.preview_id);D(w),Y(w),K(w.status==="running"?"running":"done")}catch(n){console.error("启动批量铺货失败:",n),alert((n==null?void 0:n.message)||"启动发布任务失败")}finally{q(!1)}}},Je=async()=>{if(d!=null&&d.id&&confirm("确认取消当前批量铺货任务吗?正在发布的单个商品可能会继续完成。")){q(!0);try{const n=await _r(d.id),w=await bt(d.id);D(w),K((n==null?void 0:n.status)==="canceling"||w.status==="canceling"?"running":"done")}catch(n){alert((n==null?void 0:n.message)||"取消失败")}finally{q(!1)}}},We=async()=>{const n=X==null?void 0:X.preview_id;if(n&&se==="preview")try{await jr(n)}catch(w){console.error("清理批量铺货预检失败:",w)}c(null),K("upload")},Ct=async()=>{await We(),Z(!1)},St=async()=>{if(d!=null&&d.id){q(!0);try{await Nr(d.id),D(await bt(d.id)),K("running")}catch(n){alert((n==null?void 0:n.message)||"重试失败")}finally{q(!1)}}},mt=()=>{const H=[["账号ID","标题","描述","价格","原价","库存","邮费模式","邮费","图片","类目ID","类目名称","频道类目ID","淘宝类目ID","付款发货启用","付款发货内容","评价赠品启用","评价赠品内容","求评价启用","求评价等待小时","求评价文案","求评价最多次数"],...[["","会员组合包自动发货","下单后发送主卡和附赠卡。","19.90","29.90","10","free","","images/bundle-1.jpg;images/bundle-2.jpg","","","","","是","101:1;102:1","是","201:1;202:2","是","72","亲,满意的话麻烦给个评价,谢谢~","1"],["","普通商品","仅发布商品,不创建自动化规则。","49.90","","10","fixed","8.00","https://example.com/product.jpg","","","","","否","","否","","否","","",""]]].map(y=>y.map($=>`"${String($).replace(/"/g,'""')}"`).join(",")).join(` +`),Te=new Blob(["\uFEFF"+H],{type:"text/csv;charset=utf-8"}),s=URL.createObjectURL(Te),o=document.createElement("a");o.href=s,o.download="批量铺货模板.csv",document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s)},Lt=()=>{h(n=>({...n,cookie_id:I||n.cookie_id})),B(!0)},nt=()=>{R(n=>({...n,cookie_id:I||n.cookie_id})),ue(!0)},it=async n=>{if(!(n?I:f.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");p(!0),navigator.geolocation.getCurrentPosition(async H=>{try{const Te=await hn(H.coords.longitude,H.coords.latitude);if(!Te.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");n?(ye(Te),ke(Te[0])):(U(Te),ne(Te[0]))}catch(Te){alert((Te==null?void 0:Te.message)||"获取发货地失败")}finally{p(!1)}},H=>{p(!1),alert(H.code===H.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},Ot=n=>i.filter(w=>w.cookie_id===n.cookie_id&&w.item_id===n.item_id).length>0?i.filter(w=>w.cookie_id===n.cookie_id&&w.item_id===n.item_id):i.filter(w=>w.cookie_id===n.cookie_id&&!w.item_id),pt=n=>{switch(n){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return n||"-"}},ut=n=>{switch(n){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},st=r.useMemo(()=>new Map(_.map(n=>[n.id,n])),[_]),ht=r.useMemo(()=>C?a.filter(n=>n.cookie_id===C):a,[C,a]),Ge=n=>{const w=st.get(n),H=(w==null?void 0:w.remark)||(w==null?void 0:w.nickname);return H?`${H} · ${n.slice(0,6)}`:`账号 ${n.slice(0,8)}`},ot=n=>{const w=st.get(n);return(w==null?void 0:w.remark)||(w==null?void 0:w.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(al,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:C,onChange:n=>j(n.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),_.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(xt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:I,onChange:n=>g(n.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),_.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]})]}),e.jsxs("button",{onClick:De,disabled:F||!I,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(ze,{className:`w-4 h-4 ${F?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:Lt,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(et,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:nt,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(es,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void _e(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Bt,{className:"w-4 h-4"}),S&&["running","canceling"].includes(S.status)?"继续批量任务":"批量铺货"]}),S&&!["running","canceling"].includes(S.status)&&e.jsx("button",{onClick:()=>void Fe(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[ht.map(n=>{const w=Ot(n),H=w.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:[e.jsx("button",{onClick:()=>te(n),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors",title:"编辑",children:e.jsx(_t,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>u(n),className:"p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md hover:bg-red-100 text-red-500 transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"aspect-square bg-gray-100 rounded-xl mb-2.5 overflow-hidden relative",children:[n.item_image?e.jsx("img",{src:n.item_image,alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(ga,{className:"w-8 h-8"})}),e.jsx("div",{className:"absolute top-1.5 left-1.5 bg-black/50 backdrop-blur-md text-white text-[10px] font-bold px-1.5 py-0.5 rounded-md",children:gn(n.item_price)})]}),e.jsx("h3",{className:"font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4",children:n.item_title}),e.jsxs("div",{className:"mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700",title:ot(n.cookie_id),children:[e.jsx(xt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",children:ot(n.cookie_id)})]}),e.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500 mb-2",children:[e.jsxs("span",{className:"bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]",children:["ID: ",n.item_id]}),e.jsxs("span",{className:`inline-flex items-center gap-1 font-bold ${H?"text-emerald-600":"text-amber-600"}`,children:[H?e.jsx(ds,{className:"w-3 h-3"}):e.jsx(ll,{className:"w-3 h-3"}),H?`${w.length} 规则`:"未配置"]})]}),e.jsx("div",{className:"space-y-2 mt-auto",children:e.jsxs("button",{onClick:()=>t(n),className:`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${H?"bg-gray-900 text-white hover:bg-black":"bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(rl,{className:"w-3.5 h-3.5"}),H?"查看发货规则":"关联发货规则"]}),e.jsx(xs,{className:"w-3.5 h-3.5"})]})})]},`${n.cookie_id}-${n.item_id}`)}),ht.length===0&&e.jsxs("div",{className:"col-span-full py-20 text-center text-gray-400",children:[e.jsx(ba,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),C?"该账号暂无商品数据":"暂无商品数据,请选择账号进行同步"]})]}),ce&&de&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"560px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"编辑商品"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",de.item_id]})]}),e.jsx("button",{onClick:()=>Q(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-4",children:[e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"商品标题",value:fe.item_title||"",onChange:n=>Oe({...fe,item_title:n.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"价格",value:fe.item_price||"",onChange:n=>Oe({...fe,item_price:n.target.value})}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"分类",value:fe.item_category||"",onChange:n=>Oe({...fe,item_category:n.target.value})}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述",value:fe.item_description||"",onChange:n=>Oe({...fe,item_description:n.target.value})})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:je,className:"w-full ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),"保存"]})})]})}),document.body),ee&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"720px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"添加商品"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"手动建立商品与自动发货规则的关联"})]}),e.jsx("button",{onClick:()=>B(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"所属账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:re.cookie_id,onChange:n=>h({...re,cookie_id:n.target.value}),children:[e.jsx("option",{value:"",children:"选择账号"}),_.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品 ID"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入闲鱼商品 ID",value:re.item_id,onChange:n=>h({...re,item_id:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品价格"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 99.00",value:re.item_price,onChange:n=>h({...re,item_price:n.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"输入商品标题",value:re.item_title,onChange:n=>h({...re,item_title:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"图片 URL"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"https://...",value:re.item_image,onChange:n=>h({...re,item_image:n.target.value})})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{onClick:L,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(et,{className:"w-4 h-4"}),"添加商品"]})})]})}),document.body),ge&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"820px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"发布商品到闲鱼"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"普通单规格发布;库存数量会写入闲鱼发布参数,用于判断账号库存能力。"})]}),e.jsx("button",{onClick:()=>ue(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800 leading-6",children:"发布时必须填写库存。若账号没有库存发布能力,后端会返回明确的“库存权限不足”错误,不会误报为普通发布失败。"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:f.cookie_id,onChange:n=>{R({...f,cookie_id:n.target.value}),U([]),ne(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),_.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品标题"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:会员月卡自动发货",value:f.title,onChange:n=>R({...f,title:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"库存数量"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",type:"number",min:"1",placeholder:"必须大于 0",value:f.quantity,onChange:n=>R({...f,quantity:n.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品描述"}),e.jsx("textarea",{className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none",placeholder:"描述会用于自动识别类目;留空时使用标题",value:f.description,onChange:n=>R({...f,description:n.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"售价"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"99.00",value:f.price,onChange:n=>R({...f,price:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"原价(可选)"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"129.00",value:f.original_price,onChange:n=>R({...f,original_price:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"运费方式"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:f.postage_mode,onChange:n=>R({...f,postage_mode:n.target.value}),children:[e.jsx("option",{value:"free",children:"包邮"}),e.jsx("option",{value:"distance",children:"按距离计费"}),e.jsx("option",{value:"fixed",children:"一口价邮费"}),e.jsx("option",{value:"none",children:"无需邮寄"})]})]})]}),f.postage_mode==="fixed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"一口价邮费"}),e.jsx("input",{className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如 8.00",value:f.postage,onChange:n=>R({...f,postage:n.target.value})})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品无需发货地;发布失败时可再定位并作为补充信息提交。"})]}),e.jsxs("button",{type:"button",disabled:T||!f.cookie_id,onClick:()=>void it(!1),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Ms,{className:"h-4 w-4"}),T?"定位中...":"获取当前位置"]})]}),b.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,b.indexOf(M))),onChange:n=>ne(b[Number(n.target.value)]||null),children:b.map((n,w)=>e.jsx("option",{value:String(w),children:[n.province,n.city,n.area,n.poi_name].filter(Boolean).join(" ")},`${n.division_id}-${n.poi_id}-${w}`))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"商品图片(1-9 张)"}),e.jsxs("label",{className:"flex min-h-[120px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50/50 transition-colors",children:[e.jsx(Bt,{className:"w-8 h-8 text-emerald-600 mb-2"}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"选择图片"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:f.images.length?"已选择 "+f.images.length+" 张":"支持 JPG / PNG / GIF"}),e.jsx("input",{className:"hidden",type:"file",accept:"image/*",multiple:!0,onChange:n=>R({...f,images:Array.from(n.target.files||[]).slice(0,9)})})]}),z.length>0&&e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-3",children:z.map(n=>e.jsx("div",{className:"aspect-square rounded-xl bg-gray-100 overflow-hidden border border-gray-100",children:e.jsx("img",{src:n.url,alt:"",className:"w-full h-full object-cover"})},n.key))})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("button",{disabled:me,onClick:le,className:"w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(es,{className:"w-4 h-4"}),me?"正在发布...":"发布到闲鱼"]})})]})}),document.body),k&&qe.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"980px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量铺货"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"上传商品表格和图片 zip,先预检,再逐条发布到闲鱼。"})]}),e.jsx("button",{onClick:()=>void Ct(),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",title:"关闭",children:e.jsx(Me,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["upload","1 上传"],["preview","2 预检"],["running","3 发布"],["done","4 结果"]].map(([n,w])=>e.jsx("div",{className:`rounded-xl px-3 py-2 text-center text-xs font-extrabold border ${se===n?"bg-blue-600 text-white border-blue-600":"bg-gray-50 text-gray-500 border-gray-100"}`,children:w},n))}),se==="upload"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-sm text-blue-900 leading-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:"先下载模板,再按字段填写。"}),e.jsxs("div",{children:["图片字段写 zip 内相对路径,多个图片用英文分号分隔,例如 ",e.jsx("span",{className:"font-mono font-bold",children:"images/a.jpg;images/b.jpg"}),"。也支持直接填写图片 URL。"]})]}),e.jsx("button",{type:"button",onClick:mt,className:"shrink-0 rounded-xl bg-blue-600 px-4 py-2 text-sm font-extrabold text-white hover:bg-blue-700",children:"下载CSV模板"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"默认发布账号"}),e.jsxs("select",{className:"w-full ios-input px-4 py-3 rounded-xl",value:I,onChange:n=>{g(n.target.value),ye([]),ke(null)},children:[e.jsx("option",{value:"",children:"选择账号"}),_.map(n=>e.jsx("option",{value:n.id,children:Ge(n.id)},n.id))]}),e.jsx("p",{className:"text-xs text-gray-500",children:"表格中“账号ID”为空时,会使用这里选择的账号。"})]}),e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/70 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-extrabold text-gray-900",children:["默认类目 ",e.jsx("span",{className:"font-medium text-gray-500",children:"(可为空)"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-800",children:"填写后优先使用该类目;留空时由闲鱼根据每件商品自动识别。仍无法识别时,系统最终使用“电子资料”兜底。"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("label",{className:"relative flex-1",children:[e.jsx("span",{className:"sr-only",children:"类目关键词"}),e.jsx(Nt,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{className:"w-full ios-input rounded-xl bg-white py-2.5 pl-10 pr-3",placeholder:"输入关键词,例如:课程资料、设计素材",value:P,onChange:n=>be(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),Ue())}})]}),e.jsxs("button",{type:"button",disabled:!I||!P.trim()||Re,onClick:()=>void Ue(),className:"ios-btn-primary flex min-h-[42px] items-center justify-center gap-2 rounded-xl px-4 text-sm font-bold disabled:opacity-50",children:[e.jsx(Nt,{className:"h-4 w-4"}),Re?"匹配中...":"获取类目"]})]}),x.catId?e.jsxs("div",{className:"flex min-h-[46px] items-center justify-between gap-3 border-t border-amber-200 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-gray-900",children:[e.jsx(ds,{className:"h-4 w-4 shrink-0 text-emerald-600"}),e.jsx("span",{className:"truncate",children:x.catName})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-gray-500",children:["类目 ",x.catId," · 频道 ",x.channelCatId]})]}),e.jsx("button",{type:"button",title:"清除默认类目",onClick:()=>V({catId:"",catName:"",channelCatId:"",tbCatId:""}),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",children:e.jsx(Me,{className:"h-4 w-4"})})]}):null]}),e.jsxs("div",{className:"rounded-xl border border-sky-200 bg-sky-50 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"批次发货地(可选)"}),e.jsx("p",{className:"mt-1 text-xs text-sky-800",children:"虚拟商品可留空;填写后整个批次使用同一个发货地,并随任务保存用于恢复和重试。"})]}),e.jsxs("button",{type:"button",disabled:T||!I,onClick:()=>void it(!0),className:"ios-btn-primary flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-bold disabled:opacity-50",children:[e.jsx(Ms,{className:"h-4 w-4"}),T?"定位中...":"获取当前位置"]})]}),he.length>0&&e.jsx("select",{className:"w-full ios-input rounded-xl bg-white px-4 py-3",value:String(Math.max(0,he.indexOf(Ee))),onChange:n=>ke(he[Number(n.target.value)]||null),children:he.map((n,w)=>e.jsx("option",{value:String(w),children:[n.province,n.city,n.area,n.poi_name].filter(Boolean).join(" ")},`${n.division_id}-${n.poi_id}-${w}`))})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-blue-300 hover:bg-blue-50 transition-colors",children:[e.jsx(Bt,{className:"w-9 h-9 text-blue-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传商品表格"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:ve?ve.name:"支持 .xlsx / .csv / .tsv"}),e.jsx("input",{className:"hidden",type:"file",accept:".xlsx,.csv,.tsv",onChange:n=>{var w;return J(((w=n.target.files)==null?void 0:w[0])||null)}})]}),e.jsxs("label",{className:"flex min-h-[150px] cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center hover:border-emerald-300 hover:bg-emerald-50 transition-colors",children:[e.jsx(Bt,{className:"w-9 h-9 text-emerald-600 mb-3"}),e.jsx("span",{className:"text-sm font-extrabold text-gray-900",children:"上传图片 zip(可选)"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:A?A.name:"表格图片字段使用 zip 内相对路径"}),e.jsx("input",{className:"hidden",type:"file",accept:".zip",onChange:n=>{var w;return E(((w=n.target.files)==null?void 0:w[0])||null)}})]})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 border border-gray-100 p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"字段说明"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"照着下面的“什么时候填写”处理即可。预检发现问题时,会指出具体哪一行需要修改。"})]}),e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-4 text-xs text-blue-950",children:[e.jsx("div",{className:"text-sm font-extrabold",children:"“付款后发送的卡密”怎么填"}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101"}),e.jsx("p",{className:"mt-1 leading-5",children:"从卡密组 101 立即发送 1 份。卡密组 ID 可以在“卡密库存”页面查看。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:2"}),e.jsx("p",{className:"mt-1 leading-5",children:"每购买 1 件,就从卡密组 101 发送 2 份。买家购买 3 件时会发送 6 份。"})]}),e.jsxs("div",{className:"rounded-lg bg-white/80 p-3",children:[e.jsx("code",{className:"font-bold text-blue-700",children:"101:1:0;102:2:3"}),e.jsx("p",{className:"mt-1 leading-5",children:"先立即发送卡密组 101 的 1 份,再等待 3 秒发送卡密组 102 的 2 份。"})]})]}),e.jsxs("p",{className:"mt-3 leading-5 text-blue-800",children:["每一组依次写“卡密组 ID : 每件发送几份 : 等待几秒”。份数不写时按 1 份处理,等待时间不写时立即发送。需要发送多种卡密时,用英文分号 ",e.jsx("code",{className:"font-bold",children:";"})," 隔开。"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"字段"}),e.jsx("th",{className:"px-3 py-2",children:"什么时候填写"}),e.jsx("th",{className:"px-3 py-2",children:"填写方法"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 text-gray-700",children:[["账号ID","需要覆盖默认账号时填写","上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行"],["标题","每个商品都要填","填写买家能看到的商品标题"],["描述","可以留空","留空时会使用商品标题作为描述"],["价格","每个商品都要填","只填数字,例如 19.90"],["原价","可以留空","需要展示划线原价时填写,例如 29.90"],["库存","可以留空","留空按 1 件处理;填写时必须大于 0"],["邮费模式","可以留空","留空表示包邮;包邮填 free,固定邮费填 fixed"],["邮费","邮费模式填 fixed 时填写","只填数字,例如 8.00"],["图片","每个商品都要填","填写 zip 内图片路径或图片网址;多张图片用英文分号隔开"],["类目ID","需要指定当前行默认类目时填写","必须和“类目名称、频道类目ID”同时填写;优先于自动识别"],["类目名称","填写了“类目ID”时必填","填写该 ID 对应的准确类目名称"],["频道类目ID","覆盖类目时必填","必须填写闲鱼返回的准确频道类目 ID"],["淘宝类目ID","按闲鱼返回填写","“电子资料”无淘宝类目 ID,保持为空"],["付款发货启用","需要付款后自动发货时填写","填“是”表示开启;不需要时填“否”或留空"],["付款发货内容","“付款发货启用”填“是”时填写","从“卡密库存”页面取得卡密组 ID,按上方示例填写"],["评价赠品启用","需要评价赠品时填写","填“是”表示开启;不需要时填“否”或留空"],["评价赠品内容","“评价赠品启用”填“是”时填写","格式和付款发货内容相同,也可以同时发送多个卡密组"],["求评价启用","需要自动求评价时填写","填“是”表示开启;不需要时填“否”或留空"],["求评价等待小时","“求评价启用”填“是”时填写","填写等待小时数;留空按 72 小时处理"],["求评价文案","“求评价启用”填“是”时填写","填写要发送给买家的求评价消息"],["求评价最多次数","可以留空","留空只提醒 1 次"]].map(([n,w,H])=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-bold text-gray-900 whitespace-nowrap",children:n}),e.jsx("td",{className:`px-3 py-2 min-w-[210px] font-bold ${w==="每个商品都要填"?"text-red-600":w==="可以留空"?"text-gray-500":"text-amber-700"}`,children:w}),e.jsx("td",{className:"px-3 py-2 min-w-[260px]",children:H})]},n))})]})})]})]}),se==="preview"&&X&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总行数"}),e.jsx("div",{className:"text-2xl font-extrabold text-gray-900 mt-1",children:X.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"可发布"}),e.jsx("div",{className:"text-2xl font-extrabold text-emerald-700 mt-1",children:X.valid})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"有问题"}),e.jsx("div",{className:"text-2xl font-extrabold text-red-700 mt-1",children:X.invalid})]})]}),e.jsx("div",{className:"max-h-[380px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"价格/库存"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"图片"}),e.jsx("th",{className:"px-4 py-3",children:"问题"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:X.rows.map(n=>{var w,H,Te,s;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:n.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${n.valid?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-red-50 text-red-700 border-red-100"}`,children:n.valid?"可发布":"需修正"})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[240px] truncate",children:n.title||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:["¥",n.price||"-"," / ",n.quantity||1]}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((w=n.category)==null?void 0:w.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((H=n.category)==null?void 0:H.cat_id)||"失败后使用电子资料"})]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600",children:[((Te=n.images)==null?void 0:Te.length)||0," 张"]}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[280px]",children:((s=n.errors)==null?void 0:s.join(";"))||"-"})]},n.row_no)})})]})})]}),(se==="running"||se==="done")&&d&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("div",{className:`rounded-2xl p-4 border ${ut(d.status)}`,children:[e.jsx("div",{className:"text-xs font-bold opacity-70",children:"任务状态"}),e.jsx("div",{className:"text-xl font-extrabold mt-1",children:pt(d.status)})]}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 border border-gray-100",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500",children:"总数"}),e.jsx("div",{className:"text-xl font-extrabold text-gray-900 mt-1",children:d.total})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-4 border border-emerald-100",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-700",children:"成功"}),e.jsx("div",{className:"text-xl font-extrabold text-emerald-700 mt-1",children:d.success})]}),e.jsxs("div",{className:"rounded-2xl bg-red-50 p-4 border border-red-100",children:[e.jsx("div",{className:"text-xs font-bold text-red-700",children:"失败"}),e.jsx("div",{className:"text-xl font-extrabold text-red-700 mt-1",children:d.failed})]}),e.jsxs("div",{className:"rounded-2xl bg-blue-50 p-4 border border-blue-100",children:[e.jsx("div",{className:"text-xs font-bold text-blue-700",children:"等待"}),e.jsx("div",{className:"text-xl font-extrabold text-blue-700 mt-1",children:d.pending})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto rounded-2xl border border-gray-100",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-white text-xs text-gray-400 border-b border-gray-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"行号"}),e.jsx("th",{className:"px-4 py-3",children:"状态"}),e.jsx("th",{className:"px-4 py-3",children:"标题"}),e.jsx("th",{className:"px-4 py-3",children:"类目策略"}),e.jsx("th",{className:"px-4 py-3",children:"商品ID"}),e.jsx("th",{className:"px-4 py-3",children:"错误原因"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:d.rows.map(n=>{var w,H;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:n.row_no}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-lg border text-xs font-extrabold ${ut(n.status)}`,children:pt(n.status)})}),e.jsx("td",{className:"px-4 py-3 font-bold text-gray-900 max-w-[260px] truncate",children:n.title}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-600 min-w-[150px]",children:[e.jsx("div",{className:"font-bold text-gray-800",children:((w=n.category)==null?void 0:w.cat_name)||"自动识别"}),e.jsx("div",{className:"font-mono text-gray-400",children:((H=n.category)==null?void 0:H.cat_id)||"失败后使用电子资料"})]}),e.jsx("td",{className:"px-4 py-3 text-xs font-mono",children:n.item_url?e.jsx("a",{href:n.item_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline",children:n.item_id}):n.item_id||"-"}),e.jsx("td",{className:"px-4 py-3 text-red-600 text-xs max-w-[340px]",children:n.error_message||"-"})]},n.id)})})]})})]})]}),e.jsxs("div",{className:"modal-footer",children:[se==="upload"&&e.jsxs("button",{disabled:v||!ve||!I,onClick:tt,className:"w-full ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(ze,{className:`w-4 h-4 ${v?"animate-spin":""}`}),v?"正在预检...":"开始预检"]}),se==="preview"&&X&&e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{disabled:v,onClick:()=>void We(),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"返回修改"}),e.jsxs("button",{disabled:v||X.valid<=0,onClick:kt,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(es,{className:"w-4 h-4"}),v?"启动中...":`确认发布 ${X.valid} 个商品`]})]}),(se==="running"||se==="done")&&d&&e.jsxs("div",{className:"flex gap-3 w-full",children:[d.status==="running"?e.jsx("button",{disabled:v,onClick:Je,className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"取消任务"}):d.status==="canceling"?e.jsx("button",{disabled:!0,className:"flex-1 px-6 py-3.5 rounded-xl bg-amber-100 text-amber-800 font-bold",children:"正在保存远端结果并安全取消…"}):e.jsx("button",{onClick:()=>window.open(`/items/publish-batches/${d.id}/result.csv`,"_blank"),className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-900 text-white hover:bg-black font-bold",children:"下载结果"}),d.retryable>0&&!["running","canceling"].includes(d.status)&&e.jsxs("button",{disabled:v,onClick:St,className:"flex-1 ios-btn-primary px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ze,{className:`w-4 h-4 ${v?"animate-spin":""}`}),"重试失败项"]}),!["running","canceling"].includes(d.status)&&e.jsx("button",{onClick:()=>{Z(!1),Ae(),we()},className:"flex-1 px-6 py-3.5 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold",children:"完成"})]})]})]})}),document.body)]})},ra="https://dashscope.aliyuncs.com/compatible-mode/v1",fn=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],yn=new Set(["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),jn=()=>{const[t,a]=r.useState(null),[l,i]=r.useState(!1),[m,_]=r.useState(""),[N,I]=r.useState(!1),[g,C]=r.useState([]),[j,F]=r.useState(!1),[G,me]=r.useState(""),[oe,v]=r.useState(!1),q=r.useRef(null),[ce,Q]=r.useState(!1),[ee,B]=r.useState(!1),[ge,ue]=r.useState(!1),[k,Z]=r.useState(!1),[se,K]=r.useState(!1),[ve,J]=r.useState(null),[A,E]=r.useState({new_username:"",current_password:"",new_password:"",confirm_password:""});r.useEffect(()=>{be(),Sa().then(b=>{b.username&&E(U=>({...U,new_username:b.username||""}))}).catch(()=>{})},[]),r.useEffect(()=>{const b=U=>{var M;(M=q.current)!=null&&M.contains(U.target)||v(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]);const P=async(b,U=!1)=>{const M=b||t,ne=(M==null?void 0:M.ai_api_url)||(M==null?void 0:M.ai_base_url)||ra;F(!0),me("");try{const he=await Tr(ne,(M==null?void 0:M.ai_api_key)||"");C(he),v(U&&he.length>0),!(M!=null&&M.ai_model)&&he.length>0&&a(ye=>ye&&{...ye,ai_model:he[0]})}catch(he){C([]),v(!1),me(he.message||"读取模型失败")}finally{F(!1)}},be=()=>{i(!0),_(""),Aa().then(b=>{a(b),P(b)}).catch(b=>{a(null),_(b.message||"加载配置失败")}).finally(()=>i(!1))},Re=async()=>{if(t){I(!0);try{const b=Object.fromEntries(Object.entries(t).filter(([U,M])=>!yn.has(U)&&M!==void 0&&M!==null));await $a(b),alert("系统配置已保存")}catch(b){alert("保存失败:"+b.message)}finally{I(!1)}}},ae=async b=>{b.preventDefault(),J(null);const U=A.new_username.trim();if(U.length<3){J({type:"error",text:"用户名至少需要 3 个字符"});return}if(!A.current_password){J({type:"error",text:"请输入当前密码确认身份"});return}if(A.new_password&&A.new_password.length<8){J({type:"error",text:"新密码至少需要 8 个字符"});return}if(A.new_password!==A.confirm_password){J({type:"error",text:"两次输入的新密码不一致"});return}K(!0);try{const M=await $l({current_password:A.current_password,new_username:U,new_password:A.new_password||void 0});if(!M.success){J({type:"error",text:M.message||"登录凭据更新失败"});return}J({type:"success",text:M.message||"登录凭据已更新"}),window.setTimeout(()=>window.location.reload(),1400)}catch(M){J({type:"error",text:M.message||"登录凭据更新失败"})}finally{K(!1)}};if(!t)return e.jsx("div",{className:"p-8 text-center text-gray-400",children:m||(l?"加载配置中...":"暂无配置")});const T=t.ai_model||"",p=g;return e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-fade-in pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-2xl flex items-center justify-center",children:e.jsx(js,{className:"w-6 h-6 text-gray-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900",children:"系统设置"}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm font-medium",children:"配置全局自动化规则与系统参数"})]})]}),e.jsxs("button",{onClick:be,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(ze,{className:"w-4 h-4"}),"刷新"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-100 text-gray-600",children:e.jsx(nl,{className:"w-4 h-4"})}),"基础设置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出等级"}),e.jsx("select",{value:t.log_level||"info",onChange:b=>a({...t,log_level:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:fn.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))}),e.jsx("p",{className:"text-xs text-gray-500",children:"等级越低输出越详细,Debug 适合排查问题"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"日志输出格式"}),e.jsxs("select",{value:t.log_format||"text",onChange:b=>a({...t,log_format:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"json",children:"JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"JSON 适合接入集中式日志系统,保存后需重启服务生效"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"续期日志保留天数"}),e.jsx("input",{type:"number",value:t.renewal_log_retention_days??10,onChange:b=>a({...t,renewal_log_retention_days:parseInt(b.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"365"}),e.jsx("p",{className:"text-xs text-gray-500",children:"0 表示不自动清理续期日志"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-brand text-white",children:e.jsx(vs,{className:"w-4 h-4"})}),"AI 智能回复配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API 地址"}),e.jsx("input",{type:"text",value:t.ai_api_url||ra,onChange:b=>a({...t,ai_api_url:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://api.openai.com/v1"}),e.jsx("p",{className:"text-xs text-gray-500",children:"无需补全 /chat/completions"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:ce?"text":"password",value:t.ai_api_key||"",onChange:b=>a({...t,ai_api_key:b.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",placeholder:"sk-..."}),e.jsx("button",{type:"button",onClick:()=>Q(!ce),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:ce?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(lt,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"模型"}),e.jsxs("div",{ref:q,className:"relative flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{value:T,onFocus:()=>g.length>0&&v(!0),onChange:b=>{a({...t,ai_model:b.target.value}),g.length>0&&v(!0)},onKeyDown:b=>{b.key==="Escape"&&v(!1),b.key==="ArrowDown"&&g.length>0&&v(!0)},className:"w-full ios-input px-4 py-3 pr-10 rounded-xl",placeholder:"从接口读取或手动输入模型名"}),e.jsx("button",{type:"button",onClick:()=>g.length>0&&v(b=>!b),disabled:g.length===0,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 disabled:opacity-30","aria-label":"展开模型列表",children:e.jsx(il,{className:`w-4 h-4 transition-transform ${oe?"rotate-180":""}`})}),oe&&e.jsx("div",{className:"absolute left-0 right-0 top-[calc(100%+6px)] z-40 max-h-64 overflow-y-auto rounded-xl border border-gray-200 bg-white shadow-xl shadow-gray-200/70 py-1",children:p.length>0?p.map(b=>e.jsxs("button",{type:"button",onClick:()=>{a({...t,ai_model:b}),v(!1)},className:"w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-brand flex items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:b}),b===T&&e.jsx(Ke,{className:"w-4 h-4 shrink-0 text-brand"})]},b)):e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"没有匹配的模型"})})]}),e.jsxs("button",{type:"button",onClick:()=>P(void 0,!0),disabled:j,className:"px-4 py-3 rounded-xl bg-gray-100 text-gray-700 hover:bg-gray-200 disabled:opacity-60 font-bold flex items-center justify-center gap-2 whitespace-nowrap",children:[e.jsx(ze,{className:`w-4 h-4 ${j?"animate-spin":""}`}),"读取模型"]})]}),G?e.jsx("p",{className:"text-xs text-red-500",children:G}):e.jsx("p",{className:"text-xs text-gray-500",children:g.length>0?`已从当前 API 地址读取到 ${g.length} 个模型`:"模型列表从当前 API 地址读取,也可以手动输入模型名"})]}),e.jsxs("div",{className:"p-3 bg-blue-50 rounded-xl text-xs text-blue-700",children:[e.jsx("strong",{children:"常见 AI 服务:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-0.5",children:[e.jsx("li",{children:"阿里云通义千问: https://dashscope.aliyuncs.com/compatible-mode/v1"}),e.jsx("li",{children:"OpenAI: https://api.openai.com/v1"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-amber-500 text-white",children:e.jsx(Mt,{className:"w-4 h-4"})}),"远程过滑块配置"]}),e.jsxs("div",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务地址"}),e.jsx("input",{type:"url",value:t["captcha.remote_service_url"]||"",onChange:b=>a({...t,"captcha.remote_service_url":b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"https://example.com/internal/captcha/solve"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"服务秘钥"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:ee?"text":"password",value:t["captcha.remote_secret_key"]||"",onChange:b=>a({...t,"captcha.remote_secret_key":b.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl font-mono text-sm",autoComplete:"off"}),e.jsx("button",{type:"button",onClick:()=>B(!ee),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:ee?"隐藏秘钥":"显示秘钥",children:ee?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(lt,{className:"w-4 h-4"})})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-amber-50 p-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:String(t["captcha.remote_pass_cookies"]||"").toLowerCase()==="true",onChange:b=>a({...t,"captcha.remote_pass_cookies":b.target.checked}),className:"mt-0.5 w-4 h-4 rounded border-gray-300"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-bold text-amber-900",children:"允许向远程服务传递账号 Cookie"}),e.jsx("span",{className:"block mt-1 text-xs text-amber-700",children:"默认关闭。仅在信任远程服务且需要由其自动重取过期验证链接时开启。"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"配置地址和秘钥后优先调用远程服务;只有网络不可用或超时才回退本机引擎,远程明确返回失败时不会重复触发本机验证。"})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-extrabold text-gray-800 flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gray-900 text-white",children:e.jsx(qs,{className:"w-4 h-4"})}),"登录凭据"]}),e.jsxs("form",{onSubmit:ae,className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"登录用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Gt,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:A.new_username,onChange:b=>E({...A,new_username:b.target.value}),className:"w-full ios-input pl-11 pr-4 py-3 rounded-xl text-sm",autoComplete:"username"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"当前密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:ge?"text":"password",value:A.current_password,onChange:b=>E({...A,current_password:b.target.value}),className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm",placeholder:"用于确认当前身份",autoComplete:"current-password"}),e.jsx("button",{type:"button",onClick:()=>ue(!ge),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:ge?"隐藏密码":"显示密码",children:ge?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(lt,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"新密码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:k?"text":"password",value:A.new_password,onChange:b=>E({...A,new_password:b.target.value}),className:"w-full ios-input px-4 py-3 pr-11 rounded-xl text-sm",placeholder:"不修改则留空",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>Z(!k),className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",title:k?"隐藏密码":"显示密码",children:k?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(lt,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"确认新密码"}),e.jsx("input",{type:k?"text":"password",value:A.confirm_password,onChange:b=>E({...A,confirm_password:b.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl text-sm",placeholder:"再次输入新密码",autoComplete:"new-password"})]})]}),ve&&e.jsxs("div",{className:`flex items-start gap-2 rounded-xl px-3 py-2.5 text-sm font-medium ${ve.type==="success"?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:[e.jsx(Mt,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:ve.text})]}),e.jsxs("button",{type:"submit",disabled:se||!A.new_username||!A.current_password,className:"w-full bg-gray-900 hover:bg-black text-white px-5 py-3 rounded-xl font-bold text-sm flex items-center justify-center gap-2 transition-colors disabled:opacity-40",children:[e.jsx(qs,{className:"w-4 h-4"}),se?"正在更新...":"更新登录凭据"]})]})]})]})]}),e.jsx("div",{className:"fixed bottom-10 right-10 z-30",children:e.jsxs("button",{onClick:Re,disabled:N,className:"ios-btn-primary px-10 py-5 rounded-xl text-lg shadow-2xl shadow-blue-200 flex items-center gap-3 transform hover:scale-105 active:scale-95 transition-all disabled:opacity-70",children:[e.jsx(He,{className:"w-6 h-6"}),N?"保存中...":"保存所有配置"]})})]})},ns=(t,a)=>t.allowed_resolutions.includes(a),_n=(t,a)=>({runs:t.runs.filter(l=>!a||l.cookie_id===a),pending_tasks:t.pending_tasks.filter(l=>!a||l.cookie_id===a)}),Nn=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",vn=(t,a,l,i,m,_)=>t!==a||l!==i?!1:(_(m),!0),at={order_paid:{label:"付款后自动发货",shortLabel:"自动发货",description:"闲鱼付款系统卡片进入自动化中心后,先发送卡密,成功后再确认发货。",flow:["付款系统卡片","匹配商品/规格","发送卡密","确认发货"],accent:"blue",icon:qt},buyer_reviewed:{label:"评价后发送赠品",shortLabel:"评价赠品",description:"闲鱼评价系统卡片进入自动化中心后,给买家发送赠品卡密。",flow:["评价系统卡片","匹配商品/规格","发送赠品"],accent:"emerald",icon:ol},review_missing_timeout:{label:"超时未评价求评价",shortLabel:"求评价",description:"计划任务扫描已发货未评价订单,到期后发送求评价文案。",flow:["计划任务扫描","已发货未评价","达到等待时间","发送提醒"],accent:"amber",icon:va}},Vt=["order_paid","buyer_reviewed","review_missing_timeout"],wn="亲,商品使用满意的话,麻烦给个评价,谢谢~",Pt=()=>({spec_name:"",spec_value:"",card_id:0,delivery_count:1,enabled:!0,delay_override:!1,delay_seconds:0}),Ea=t=>{if(!t)return{};try{const a=JSON.parse(t);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}},ct=(t,a={})=>{const l=Ea(t);return JSON.stringify({after_shipped_hours:Number(l.after_shipped_hours||72),repeat_interval_hours:Number(l.repeat_interval_hours||24),max_attempts:Number(l.max_attempts||1),...a})},Rt=(t,a)=>{var i;const l=((i=at[t])==null?void 0:i.label)||"自动化规则";return a?`${l} - ${a}`:l},na=t=>{const a=(t||"").trim();return a?Object.values(at).some(l=>a===l.label||a.startsWith(`${l.label} -`)):!0},Et=(t,a=0)=>{if(t==="review_missing_timeout")return[{action_type:"send_text",message_template:wn,enabled:!0,sort_order:1}];const l={action_type:"send_card",card_id:a,delivery_count:1,enabled:!0,sort_order:1};return t==="order_paid"?[l,{action_type:"confirm_shipment",enabled:!0,sort_order:2}]:[l]},kn=t=>{var l,i;if(t.trigger_type==="review_missing_timeout")return((i=(l=t.actions)==null?void 0:l.find(m=>m.action_type==="send_text"))==null?void 0:i.message_template)||"发送求评价文案";const a=(t.actions||[]).filter(m=>m.action_type==="send_card");return a.length?a.map(m=>m.card_name||`卡密 ${m.card_id}`).join(" / "):"未配置卡密库存"},ia=(t,a=!1)=>{const l={blue:a?"border-blue-500 bg-blue-50 text-blue-700":"border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300",emerald:a?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300",amber:a?"border-amber-500 bg-amber-50 text-amber-700":"border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300"};return l[t]||l.blue},Cn=t=>t?"bg-emerald-100 text-emerald-700":"bg-gray-200 text-gray-500",Qt=t=>(t==null?void 0:t.nickname)||(t==null?void 0:t.remark)||(t==null?void 0:t.id)||"未知账号",Sn=t=>t===!0||t===1||t==="1",Ln=({initialDeliveryTarget:t,onDeliveryTargetHandled:a})=>{var w,H,Te;const[l,i]=r.useState("automation"),[m,_]=r.useState([]),[N,I]=r.useState({runs:[],pending_tasks:[]}),[g,C]=r.useState([]),[j,F]=r.useState({}),[G,me]=r.useState([]),[oe,v]=r.useState([]),[q,ce]=r.useState([]),[Q,ee]=r.useState(!1),[B,ge]=r.useState(""),[ue,k]=r.useState(""),[Z,se]=r.useState(""),[K,ve]=r.useState(""),[J,A]=r.useState("all"),[E,P]=r.useState(1),[be,Re]=r.useState(10),[ae,T]=r.useState(0),[p,b]=r.useState(0),[U,M]=r.useState({}),ne=r.useRef(0),he=r.useRef(0),ye=r.useRef("");ye.current=B;const[Ee,ke]=r.useState(!1),[x,V]=r.useState(!1),[X,c]=r.useState(!1),[d,D]=r.useState(null),[S,Y]=r.useState(null),[O,de]=r.useState({cookie_id:"",enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""});G.find(s=>s.id===B);const Se=r.useCallback(async()=>{const[s,o,y,$]=await Promise.all([Ft(),Xe(),vt(),Xs()]);me(s),v(o),ce(y),F($),ge(W=>{var pe;return W||((pe=s[0])==null?void 0:pe.id)||""})},[]),fe=r.useCallback(async()=>{const s=++ne.current,o=Sr().catch(W=>(console.warn("加载自动化异常列表失败,不阻断规则展示",W),null)),y=await wr({cookieId:B||void 0,triggerType:K,enabled:J==="all"?void 0:J==="enabled",search:Z,page:E,pageSize:be});if(s!==ne.current)return;_(y.data),T(y.total),b(y.total_pages),M(y.trigger_counts||{}),y.page!==E&&P(y.page);const $=await o;s===ne.current&&$&&I($)},[E,be,J,K,Z,B]),Oe=r.useCallback(async()=>{const s=B;if(s!==ye.current)return;const o=++he.current;if(C([]),!s)return;const y=await $r(s);vn(o,he.current,s,ye.current,y,C)},[B]),re=r.useCallback(async()=>{F(await Xs())},[]),h=r.useCallback(async()=>{ee(!0);try{l==="automation"?await fe():l==="reply"?await Oe():await re()}finally{ee(!1)}},[l,fe,re,Oe]);r.useEffect(()=>{const s=window.setTimeout(()=>{P(1),se(ue.trim())},300);return()=>window.clearTimeout(s)},[ue]),r.useEffect(()=>{Se().catch(s=>console.error("加载规则参考数据失败",s))},[Se]),r.useEffect(()=>{h().catch(s=>console.error("刷新规则页面失败",s))},[h]);const f=r.useMemo(()=>m.filter(s=>!B||s.cookie_id===B),[m,B]),R=r.useMemo(()=>_n(N,B),[N,B]),z=r.useMemo(()=>G.filter(s=>!B||s.id===B),[G,B]),Ie=r.useMemo(()=>{if(p<=1)return[];const s=Math.max(1,Math.min(E-2,p-4)),o=Math.min(p,s+4);return Array.from({length:o-s+1},(y,$)=>s+$)},[E,p]),Ae=!!(ue.trim()||K||J!=="all"),we=()=>{k(""),se(""),ve(""),A("all"),P(1)},De=r.useMemo(()=>{const s=(d==null?void 0:d.cookie_id)||B;return q.filter(o=>o.cookie_id===s)},[d==null?void 0:d.cookie_id,q,B]),te=r.useMemo(()=>{if(!(!(d!=null&&d.cookie_id)||!(d!=null&&d.item_id)))return q.find(s=>s.cookie_id===d.cookie_id&&s.item_id===d.item_id)},[d==null?void 0:d.cookie_id,d==null?void 0:d.item_id,q]),je=Sn(te==null?void 0:te.is_multi_spec),u=(d==null?void 0:d.trigger_type)||"order_paid",L=at[u],le=Ea(d==null?void 0:d.config_json),_e=r.useCallback((s="order_paid",o=B,y="")=>{const $=q.find(pe=>pe.cookie_id===o&&pe.item_id===y),W=($==null?void 0:$.item_title)||y;return{name:Rt(s,W),trigger_type:s,cookie_id:o,item_id:y,item_title:($==null?void 0:$.item_title)||"",item_keyword:W,card_group_id:0,priority:100,enabled:!0,config_json:s==="review_missing_timeout"?ct():"{}",actions:Et(s),variants:s==="review_missing_timeout"?[]:[Pt()]}},[q,B]),Ue=r.useCallback(s=>{var y,$;const o=s.trigger_type||"order_paid";D({...s,trigger_type:o,config_json:o==="review_missing_timeout"?ct(s.config_json):s.config_json||"{}",actions:(y=s.actions)!=null&&y.length?s.actions.map(W=>({...W})):Et(o,s.card_group_id),variants:($=s.variants)!=null&&$.length?s.variants.map(W=>({...W})):o==="review_missing_timeout"?[]:[Pt()]}),ke(!0)},[]);r.useEffect(()=>{if(!t)return;let s=!1;return(async()=>{i("automation"),ge(t.cookieId),ee(!0);try{const[y,$,W]=await Promise.all([gs(),vt(),Xe().catch(xe=>(console.warn("加载卡密库存失败,不阻断打开自动化规则",xe),[]))]);if(s)return;_(y),ce($),v(W);const pe=y.find(xe=>xe.cookie_id===t.cookieId&&xe.item_id===t.itemId&&xe.trigger_type==="order_paid");if(pe)Ue(pe);else{const xe=$.find($e=>$e.cookie_id===t.cookieId&&$e.item_id===t.itemId);D({..._e("order_paid",t.cookieId,t.itemId),item_title:(xe==null?void 0:xe.item_title)||"",item_keyword:(xe==null?void 0:xe.item_title)||t.itemId,name:Rt("order_paid",(xe==null?void 0:xe.item_title)||t.itemId)}),ke(!0)}}catch(y){console.error("打开商品自动化规则失败",y),alert("无法加载该商品的自动化规则")}finally{s||(ee(!1),a==null||a())}})(),()=>{s=!0}},[_e,t,a,Ue]);const Fe=(s="order_paid")=>{if(!B){alert("请先选择账号");return}D(_e(s)),ke(!0)},tt=s=>{var $,W,pe,xe,$e;if(!d)return;const o=((W=($=d.variants)==null?void 0:$.find(ie=>ie.card_id))==null?void 0:W.card_id)||((xe=(pe=d.actions)==null?void 0:pe.find(ie=>ie.action_type==="send_card"))==null?void 0:xe.card_id)||d.card_group_id||0,y=(te==null?void 0:te.item_title)||d.item_title||d.item_id||"";D({...d,trigger_type:s,name:na(d.name)?Rt(s,y):d.name,card_group_id:o,config_json:s==="review_missing_timeout"?ct(d.config_json):"{}",actions:Et(s,o),variants:s==="review_missing_timeout"?[]:($e=d.variants)!=null&&$e.length?d.variants:[{...Pt(),card_id:o}]})},kt=s=>{if(!d)return;const o=q.find($=>$.cookie_id===(d.cookie_id||B)&&$.item_id===s),y=(o==null?void 0:o.item_title)||s;D({...d,item_id:s,item_title:(o==null?void 0:o.item_title)||"",item_keyword:y,name:na(d.name)?Rt(u,y):d.name})},Je=(w=d==null?void 0:d.variants)!=null&&w.length?d.variants:[Pt()],We=(s,o)=>{var $;if(!d)return;const y=Je.map((W,pe)=>pe===s?{...W,...o}:W);D({...d,variants:y,card_group_id:(($=y[0])==null?void 0:$.card_id)||0})},Ct=()=>{if(!d)return;const s=Je[Je.length-1];D({...d,variants:[...Je,{...Pt(),spec_name:je&&(s==null?void 0:s.spec_name)||"",spec_value:je&&(s==null?void 0:s.spec_value)||""}]})},St=async()=>{var $,W,pe,xe,$e;if(!d)return;const s=d.trigger_type||"order_paid";if(!d.cookie_id){alert("请选择账号");return}const o=($=d.variants)!=null&&$.length?d.variants:[];if(s!=="review_missing_timeout"){if(!o.length||o.some(ie=>!ie.card_id)){alert(s==="buyer_reviewed"?"请选择评价赠品卡密库存":"请选择发货卡密库存");return}if(je&&o.some(ie=>!ie.spec_name.trim()||!ie.spec_value.trim())){alert("多规格商品必须填写每一行的规格名称和规格值");return}}if(s==="review_missing_timeout"&&!(((pe=(W=d.actions)==null?void 0:W.find(Ye=>Ye.action_type==="send_text"))==null?void 0:pe.message_template)||"").trim()){alert("请填写求评价文案");return}const y=s==="review_missing_timeout"?[]:o.map(ie=>({...ie,spec_name:je?ie.spec_name.trim():"",spec_value:je?ie.spec_value.trim():"",delivery_count:Math.max(1,Number(ie.delivery_count)||1),enabled:ie.enabled!==!1}));try{await Zs({...d,trigger_type:s,name:(d.name||"").trim()||Rt(s,(te==null?void 0:te.item_title)||d.item_id||""),config_json:s==="review_missing_timeout"?ct(d.config_json):d.config_json||"{}",actions:(xe=d.actions)!=null&&xe.length?d.actions:Et(s,(($e=y[0])==null?void 0:$e.card_id)||d.card_group_id||0),variants:y}),ke(!1),await Promise.all([fe(),Se()]),alert("保存成功")}catch(ie){console.error("保存自动化规则失败:",ie),alert("保存失败:"+ie.message)}},mt=async s=>{if(confirm("确定删除该自动化规则吗?"))try{await Cr(s),await fe(),alert("删除成功")}catch(o){alert("删除失败:"+o.message)}},Lt=async s=>{try{await Zs({...s,enabled:!s.enabled}),await fe()}catch(o){alert("操作失败:"+o.message)}},nt=async(s,o)=>{if(confirm(o==="continue"?"确认外部动作已经执行成功,并跳到下一步吗?":o==="retry"?"确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。":"确认终止该自动化运行吗?"))try{await Lr(s,o),await fe()}catch($){alert("处理失败:"+$.message)}},it=async(s,o)=>{if(confirm(o==="retry"?"确认重新执行该任务吗?":"确认忽略并删除该异常任务吗?"))try{await Or(s,o),await fe()}catch(y){alert("处理失败:"+y.message)}},Ot=()=>{if(!B){alert("请先选择账号");return}Y({keyword:"",reply_content:"",image_url:"",item_id:"",type:"text",match_type:"fuzzy",enabled:!0}),V(!0)},pt=async()=>{var o,y,$;if(!S||!B)return;const s=S.type==="image"?!!((o=S.image_url)!=null&&o.trim()):!!((y=S.reply_content)!=null&&y.trim());if(!(($=S.keyword)!=null&&$.trim())||!s){alert("请填写关键词和回复内容");return}try{await Pr({...S,match_type:"fuzzy",enabled:!0},B),V(!1),await Oe(),alert("保存成功")}catch(W){alert("保存失败:"+W.message)}},ut=async s=>{if(!(!B||!confirm("确定删除该回复规则吗?")))try{await Rr(s,B),await Oe(),alert("删除成功")}catch(o){alert("删除失败:"+o.message)}},st=async(s=B)=>{if(!s){alert("请先选择账号");return}try{const o=await Ur(s);de({cookie_id:s,enabled:o.enabled,reply_content:o.reply_content,reply_once:o.reply_once,reply_image_url:o.reply_image_url||""})}catch{de({cookie_id:s,enabled:!1,reply_content:"",reply_once:!1,reply_image_url:""})}c(!0)},ht=async()=>{if(!O.cookie_id){alert("请先选择账号");return}if(O.enabled&&!O.reply_content.trim()&&!O.reply_image_url.trim()){alert("启用默认回复时,请填写回复内容或图片 URL");return}try{await Wr(O.cookie_id,{enabled:O.enabled,reply_content:O.reply_content,reply_once:O.reply_once,reply_image_url:O.reply_image_url}),c(!1),await re(),alert("保存成功")}catch(s){alert("保存失败:"+s.message)}},Ge=async s=>{if(confirm("确定删除该账号默认回复吗?"))try{await Jr(s),await re(),alert("删除成功")}catch(o){alert("删除失败:"+o.message)}},ot=async s=>{if(confirm("确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。"))try{await Vr(s),alert("清空成功")}catch(o){alert("清空失败:"+o.message)}},n=l==="automation"?"新建自动化":l==="reply"?"新增关键词":"编辑默认回复";return e.jsxs("div",{className:"min-w-0 space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row justify-between xl:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"系统通知卡片只进入自动化判断;买家消息进入关键词、默认或 AI 回复。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap gap-3",children:[e.jsxs("select",{value:B,onChange:s=>{ge(s.target.value),P(1)},className:"ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64",children:[e.jsx("option",{value:"",children:"全部账号"}),G.map(s=>e.jsx("option",{value:s.id,children:Qt(s)},s.id))]}),e.jsxs("button",{onClick:h,className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 hover:bg-gray-200 text-gray-700 flex items-center justify-center gap-2 whitespace-nowrap transition-colors",children:[e.jsx(ze,{className:`w-4 h-4 ${Q?"animate-spin":""}`}),"刷新"]}),e.jsxs("button",{onClick:l==="automation"?()=>Fe("order_paid"):l==="reply"?Ot:()=>void st(),disabled:!B,className:"ios-btn-primary px-5 py-3 rounded-2xl text-sm font-extrabold flex items-center justify-center gap-2 whitespace-nowrap disabled:opacity-50",children:[e.jsx(et,{className:"w-4 h-4"}),n]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[{id:"automation",label:"交易自动化",icon:cs},{id:"reply",label:"关键词回复",icon:Tt},{id:"default",label:"账号默认回复",icon:yt}].map(s=>{const o=s.icon;return e.jsxs("button",{onClick:()=>i(s.id),className:`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${l===s.id?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:text-black hover:bg-gray-50"}`,children:[e.jsx(o,{className:"w-4 h-4"}),s.label]},s.id)})}),l==="automation"&&(R.runs.length>0||R.pending_tasks.length>0)&&e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(rt,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[R.runs.map(s=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",s.cookie_id," · 订单 ",s.order_id||"-"," · 已记录发送 ",s.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Nn(s.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:s.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[ns(s,"continue")&&e.jsx("button",{onClick:()=>void nt(s.id,"continue"),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),ns(s,"retry")&&e.jsx("button",{onClick:()=>void nt(s.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),ns(s,"cancel")&&e.jsx("button",{onClick:()=>void nt(s.id,"cancel"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${s.id}`)),R.pending_tasks.map(s=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",s.cookie_id," · 延迟任务重试已达 ",s.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:s.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>void it(s.id,"retry"),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:()=>void it(s.id,"dismiss"),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${s.id}`))]})]}),l==="automation"&&e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-6 xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]",children:[e.jsxs("aside",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsx("h3",{className:"font-black text-gray-900 mb-1",children:"新建规则"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"先选自动化类型,再配置对应动作。"}),e.jsx("div",{className:"space-y-3",children:Vt.map(s=>{const o=at[s],y=o.icon;return e.jsx("button",{type:"button",onClick:()=>Fe(s),className:`w-full text-left rounded-2xl border p-4 transition-colors ${ia(o.accent)}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/80 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-extrabold",children:o.label}),e.jsx("div",{className:"text-xs opacity-75 mt-1 leading-5",children:o.description})]})]})},s)})})]}),e.jsxs("div",{className:"bg-white rounded-xl p-5 border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"font-black text-gray-900",children:"筛选结果构成"}),e.jsxs("span",{className:"text-xs font-bold text-gray-400",children:["共 ",ae," 条"]})]}),e.jsx("div",{className:"space-y-3",children:Vt.map(s=>{const o=at[s],y=o.icon;return e.jsxs("div",{className:"flex items-center justify-between rounded-2xl bg-gray-50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(y,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-bold text-gray-700",children:o.shortLabel})]}),e.jsx("span",{className:"text-sm font-black text-gray-900",children:U[s]||0})]},s)})})]})]}),e.jsxs("section",{className:"min-w-0 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-surface-muted p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(Nt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"搜索自动化规则",placeholder:"搜索规则名、商品名或商品 ID...",value:ue,onChange:s=>{k(s.target.value),P(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]}),e.jsxs("div",{className:"relative xl:w-52",children:[e.jsx(Na,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按自动化类型筛选",value:K,onChange:s=>{ve(s.target.value),P(1)},className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部自动化类型"}),Vt.map(s=>e.jsx("option",{value:s,children:at[s].shortLabel},s))]})]}),e.jsxs("select",{"aria-label":"按启用状态筛选",value:J,onChange:s=>{A(s.target.value),P(1)},className:"ios-input rounded-xl border-none bg-white px-4 py-2.5 text-sm shadow-sm xl:w-36",children:[e.jsx("option",{value:"all",children:"全部状态"}),e.jsx("option",{value:"enabled",children:"已启用"}),e.jsx("option",{value:"disabled",children:"已禁用"})]}),Ae&&e.jsx("button",{type:"button",onClick:we,className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white text-gray-500 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900",title:"清除筛选","aria-label":"清除筛选",children:e.jsx(Me,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs font-bold text-gray-400",children:[e.jsxs("span",{children:["找到 ",ae," 条规则"]}),Q&&e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(ze,{className:"h-3.5 w-3.5 animate-spin"}),"正在更新"]})]})]}),Q&&f.length===0?e.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-xl border border-gray-100 bg-white text-sm font-bold text-gray-400",children:[e.jsx(ze,{className:"mr-2 h-4 w-4 animate-spin"}),"正在加载规则"]}):f.length===0?e.jsxs("div",{className:"bg-white rounded-xl border border-dashed border-gray-200 p-16 text-center",children:[e.jsx(cs,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-black text-gray-900",children:Ae?"没有匹配的自动化规则":"还没有自动化规则"}),e.jsx("p",{className:"text-gray-500 mt-2",children:Ae?"调整或清除筛选条件后再试。":"从左侧选择一个模板开始配置。"})]}):f.map(s=>{const o=at[s.trigger_type],y=o.icon;return e.jsx("article",{className:"bg-white rounded-xl border border-gray-100 p-5 shadow-sm hover:shadow-lg transition-all",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center shrink-0 ${ia(o.accent,!0)}`,children:e.jsx(y,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-lg font-black text-gray-900 truncate",children:s.name}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-bold ${Cn(s.enabled)}`,children:s.enabled?"已启用":"已禁用"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-bold",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:o.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-gray-100 text-gray-600",children:s.item_title||s.item_id||"账号级规则"}),e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-blue-50 text-blue-700",children:kn(s)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>Ue(s),className:"px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-bold flex items-center gap-2",children:[e.jsx(_t,{className:"w-4 h-4"}),"编辑"]}),e.jsx("button",{onClick:()=>Lt(s),className:`px-4 py-2 rounded-xl text-sm font-bold ${s.enabled?"bg-amber-50 text-amber-700 hover:bg-amber-100":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:s.enabled?"禁用":"启用"}),e.jsx("button",{onClick:()=>mt(s.id),className:"p-2.5 rounded-xl text-red-500 hover:bg-red-50",title:"删除",children:e.jsx(Qe,{className:"w-4 h-4"})})]})]})},s.id)}),ae>0&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-gray-500",children:[e.jsxs("span",{children:["第 ",E," / ",Math.max(p,1)," 页"]}),e.jsx("span",{className:"h-4 w-px bg-gray-200"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"sr-only",children:"每页显示数量"}),e.jsx("select",{value:be,onChange:s=>{Re(Number(s.target.value)),P(1)},className:"ios-input rounded-lg border-none bg-gray-50 px-2.5 py-2 text-sm",children:[10,20,50].map(s=>e.jsxs("option",{value:s,children:[s," 条/页"]},s))})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",disabled:E<=1||Q,onClick:()=>P(s=>Math.max(1,s-1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"上一页",title:"上一页",children:e.jsx(Ns,{className:"h-4 w-4"})}),Ie.map(s=>e.jsx("button",{type:"button",disabled:Q,onClick:()=>P(s),className:`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${s===E?"bg-brand text-white":"bg-gray-50 text-gray-600 hover:bg-gray-100"} disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`第 ${s} 页`,"aria-current":s===E?"page":void 0,children:s},s)),e.jsx("button",{type:"button",disabled:E>=p||Q,onClick:()=>P(s=>Math.min(p,s+1)),className:"flex h-9 w-9 items-center justify-center rounded-lg bg-gray-50 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40","aria-label":"下一页",title:"下一页",children:e.jsx(_s,{className:"h-4 w-4"})})]})]})]})]}),l==="reply"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(rt,{className:"w-4 h-4"}),"这里只处理买家用户消息;系统通知不会进入关键词或 AI 回复。"]}),e.jsxs("div",{className:"space-y-3",children:[g.map(s=>e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-surface-subtle hover:bg-white hover:shadow-lg transition-all gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"px-3 py-1 bg-black text-white rounded-lg text-xs font-bold",children:"包含匹配"}),e.jsxs("h3",{className:"font-bold text-gray-900",children:["“",s.keyword,"”"]})]}),e.jsx("div",{className:"bg-white p-3 rounded-xl border border-gray-100 text-sm text-gray-600 leading-relaxed",children:s.type==="image"&&s.image_url?s.image_url:s.reply_content})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>{Y({...s}),V(!0)},className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(_t,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ut(s.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-5 h-5"})})]})]},s.id)),g.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无关键词回复规则"})]})]}),l==="default"&&e.jsxs("section",{className:"bg-white rounded-xl border border-gray-100 p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 bg-blue-50 px-4 py-2 rounded-xl mb-5 w-fit",children:[e.jsx(rt,{className:"w-4 h-4"}),"默认回复只处理买家用户消息;关键词未命中且 AI 未接管时才会使用。"]}),e.jsxs("div",{className:"space-y-3",children:[z.map(s=>{const o=j[s.id],y=!!(o!=null&&o.enabled);return e.jsxs("div",{className:`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${y?"border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg":"border-gray-100 bg-surface-subtle hover:bg-white hover:shadow-lg"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl flex items-center justify-center ${y?"bg-purple-600 text-white":"bg-gray-200 text-gray-400"}`,children:e.jsx(yt,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg truncate",children:Qt(s)}),e.jsx("span",{className:`px-2 py-0.5 rounded-lg text-xs font-bold ${y?"bg-green-100 text-green-700":"bg-gray-200 text-gray-500"}`,children:y?"已启用":"未启用"}),(o==null?void 0:o.reply_once)&&e.jsx("span",{className:"px-2 py-0.5 rounded-lg text-xs font-bold bg-purple-100 text-purple-700",children:"只回复一次"})]}),e.jsx("div",{className:"text-sm text-gray-600 line-clamp-2",children:y?o.reply_content||o.reply_image_url||"已配置默认回复":"未配置默认回复"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 border-t md:border-t-0 md:border-l border-gray-200 pt-4 md:pt-0 md:pl-6",children:[e.jsx("button",{onClick:()=>void st(s.id),className:"p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors",title:"编辑",children:e.jsx(_t,{className:"w-4 h-4"})}),y&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void ot(s.id),className:"px-3 py-2 text-xs font-bold text-blue-600 hover:bg-blue-50 rounded-xl transition-colors",children:"清空记录"}),e.jsx("button",{onClick:()=>void Ge(s.id),className:"p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-5 h-5"})})]})]})]},s.id)}),z.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-400",children:"暂无账号"})]})]}),Ee&&d&&qe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"72rem",maxHeight:"92vh"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-black text-gray-900",children:d.id?"编辑自动化规则":"新建自动化规则"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:L.description})]}),e.jsx("button",{onClick:()=>ke(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",title:"关闭",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] min-h-0",children:[e.jsxs("aside",{className:"bg-slate-900 text-white p-5 overflow-y-auto",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"选择自动化类型"}),e.jsx("div",{className:"space-y-3",children:Vt.map(s=>{const o=at[s],y=o.icon,$=u===s;return e.jsx("button",{type:"button",onClick:()=>tt(s),className:`w-full rounded-2xl p-4 text-left border transition-all ${$?"bg-white text-slate-950 border-white":"bg-white/5 text-white border-white/10 hover:bg-white/10"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(y,{className:`w-5 h-5 mt-0.5 ${$?"text-brand":"text-white"}`}),e.jsxs("div",{children:[e.jsx("div",{className:"font-black",children:o.label}),e.jsx("div",{className:`text-xs mt-1 leading-5 ${$?"text-gray-500":"text-gray-400"}`,children:o.description})]})]})},s)})}),e.jsxs("div",{className:"mt-6 rounded-2xl bg-white/5 border border-white/10 p-4",children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 mb-3",children:"执行流程"}),e.jsx("div",{className:"space-y-3",children:L.flow.map((s,o)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-white text-slate-950 text-xs font-black flex items-center justify-center",children:o+1}),e.jsx("span",{className:"text-sm font-bold text-gray-100",children:s})]},s))})]})]}),e.jsx("div",{className:"p-6 overflow-y-auto bg-surface-subtle",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(ds,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:"生效范围"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"规则名称"}),e.jsx("input",{type:"text",value:d.name||"",onChange:s=>D({...d,name:s.target.value}),placeholder:"不填时按类型和商品自动生成",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:d.cookie_id||"",onChange:s=>D({...d,cookie_id:s.target.value,item_id:"",item_title:"",item_keyword:""}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),G.map(s=>e.jsx("option",{value:s.id,children:Qt(s)},s.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:d.item_id||"",onChange:s=>kt(s.target.value),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级规则(不限定商品)"}),De.map(s=>e.jsx("option",{value:s.item_id,children:s.item_title||s.item_id},`${s.cookie_id}-${s.item_id}`))]})]})]}),te&&u!=="review_missing_timeout"&&e.jsxs("div",{className:"mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:te.item_title||te.item_id}),e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${je?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-500"}`,children:je?"多规格商品":"普通商品"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-emerald-50 text-emerald-700",children:"按订单购买数量自动发货"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-500",children:"多规格状态来自闲鱼商品本身,发布后不能在这里修改;系统会在买家付款后读取订单详情,按实际购买规格和数量匹配下面的发货规则。"})]})]}),u!=="review_missing_timeout"?e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cl,{className:"w-5 h-5 text-brand"}),e.jsx("h4",{className:"font-black text-gray-900",children:u==="buyer_reviewed"?"赠品库存":"发货库存"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:je?"每条发货内容绑定一个订单规格;同一规格可添加多条内容并全部发送。":"可添加多条发货内容,买家付款后会按顺序全部发送。"})]}),e.jsxs("button",{type:"button",onClick:Ct,className:"px-3 py-2 rounded-xl bg-gray-900 text-white text-xs font-bold hover:bg-black flex items-center gap-1.5",children:[e.jsx(et,{className:"w-3.5 h-3.5"}),"添加发货内容"]})]}),e.jsx("div",{className:"space-y-3",children:Je.map((s,o)=>e.jsxs("div",{className:`grid grid-cols-1 gap-3 items-end rounded-2xl border border-gray-200 p-4 ${je?"md:grid-cols-[1fr_1fr_1.4fr_110px_40px]":"md:grid-cols-[1.4fr_110px_40px]"}`,children:[je&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格名称"}),e.jsx("input",{value:s.spec_name,onChange:y=>We(o,{spec_name:y.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:套餐"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"规格值"}),e.jsx("input",{value:s.spec_value,onChange:y=>We(o,{spec_value:y.target.value}),className:"w-full ios-input px-3 py-2.5 rounded-lg",placeholder:"例如:30天"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"卡密库存"}),e.jsxs("select",{value:s.card_id||"",onChange:y=>We(o,{card_id:Number(y.target.value)}),className:"w-full ios-input px-3 py-2.5 rounded-lg",children:[e.jsx("option",{value:"",children:"请选择卡密库存"}),oe.filter(y=>y.enabled&&y.type!=="api").map(y=>e.jsx("option",{value:y.id,children:y.name},y.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-600 mb-2",children:"每件份数"}),e.jsx("input",{type:"number",min:"1",max:"100",value:s.delivery_count,onChange:y=>We(o,{delivery_count:Math.max(1,Number(y.target.value)||1)}),className:"w-full ios-input px-3 py-2.5 rounded-lg"})]}),e.jsxs("div",{className:"md:col-span-full flex flex-wrap items-center gap-3 rounded-xl bg-gray-50 px-3 py-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-bold text-gray-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.delay_override===!0,onChange:y=>We(o,{delay_override:y.target.checked}),className:"accent-brand"}),"覆盖卡密默认延时"]}),s.delay_override&&e.jsx("input",{type:"number",min:"0",max:"3600",value:s.delay_seconds||0,onChange:y=>We(o,{delay_seconds:Math.max(0,Number(y.target.value)||0)}),className:"w-28 ios-input px-2 py-1.5 rounded-lg text-xs","aria-label":"动作延时秒数"}),e.jsx("span",{className:"text-xs text-gray-500",children:s.delay_override?`本动作延时 ${s.delay_seconds||0} 秒`:"使用卡密默认延时"})]}),e.jsx("button",{type:"button",disabled:Je.length===1,onClick:()=>D({...d,variants:Je.filter((y,$)=>$!==o)}),className:"w-10 h-10 flex items-center justify-center rounded-lg text-red-500 hover:bg-red-50 disabled:opacity-25",title:"删除发货内容",children:e.jsx(Qe,{className:"w-4 h-4"})})]},s.id||o))})]}):e.jsxs("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(va,{className:"w-5 h-5 text-amber-600"}),e.jsx("h4",{className:"font-black text-gray-900",children:"求评价计划"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"发货后等待小时"}),e.jsx("input",{type:"number",min:"1",value:Number(le.after_shipped_hours||72),onChange:s=>D({...d,config_json:ct(d.config_json,{after_shipped_hours:Math.max(1,Number(s.target.value)||72)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"再次求评间隔小时"}),e.jsx("input",{type:"number",min:"1",value:Number(le.repeat_interval_hours||24),onChange:s=>D({...d,config_json:ct(d.config_json,{repeat_interval_hours:Math.max(1,Number(s.target.value)||24)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"最多求评次数"}),e.jsx("input",{type:"number",min:"1",value:Number(le.max_attempts||1),onChange:s=>D({...d,config_json:ct(d.config_json,{max_attempts:Math.max(1,Number(s.target.value)||1)})}),className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"求评价文案"}),e.jsx("textarea",{value:((Te=(H=d.actions)==null?void 0:H.find(s=>s.action_type==="send_text"))==null?void 0:Te.message_template)||"",onChange:s=>{var o;return D({...d,actions:((o=d.actions)!=null&&o.length?d.actions:Et("review_missing_timeout")).map(y=>y.action_type==="send_text"?{...y,message_template:s.target.value}:y)})},className:"w-full ios-input px-4 py-3 rounded-xl h-28 resize-none"})]})]})]}),e.jsx("section",{className:"bg-white rounded-3xl border border-gray-100 p-5",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[180px_1fr] gap-4 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"优先级"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"数字越小优先级越高;同一账号、商品和触发条件只执行优先级最高的一条规则。"}),e.jsx("input",{type:"number",value:d.priority||100,onChange:s=>D({...d,priority:Number(s.target.value)||100}),min:"1",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"h-[48px] flex items-center gap-3 px-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsx("input",{type:"checkbox",checked:d.enabled!==!1,onChange:s=>D({...d,enabled:s.target.checked}),className:"w-4 h-4 rounded"}),"启用规则"]})]})})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 bg-white flex gap-3",children:[e.jsx("button",{onClick:()=>ke(!1),className:"flex-1 px-6 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200",children:"取消"}),e.jsxs("button",{onClick:St,className:"flex-1 ios-btn-primary px-6 py-3 rounded-2xl font-bold flex items-center justify-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),"保存自动化规则"]})]})]})}),document.body),x&&S&&qe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:S.id?"编辑回复规则":"新增回复规则"}),e.jsx("button",{onClick:()=>V(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关联商品"}),e.jsxs("select",{value:S.item_id||"",onChange:s=>Y({...S,item_id:s.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"账号级回复"}),q.filter(s=>!B||s.cookie_id===B).map(s=>e.jsx("option",{value:s.item_id,children:s.item_title||s.item_id},`${s.cookie_id}-${s.item_id}`))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复类型"}),e.jsxs("select",{value:S.type||"text",onChange:s=>{const o=s.target.value;Y({...S,type:o,reply_content:o==="text"?S.reply_content:"",image_url:o==="image"?S.image_url:""})},className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"text",children:"文字"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"关键词"}),e.jsx("input",{type:"text",value:S.keyword||"",onChange:s=>Y({...S,keyword:s.target.value}),placeholder:"买家发送的关键词",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),S.type==="image"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{value:S.image_url||"",onChange:s=>Y({...S,image_url:s.target.value}),placeholder:"https://...",className:"w-full ios-input px-4 py-3 rounded-xl"})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:S.reply_content||"",onChange:s=>Y({...S,reply_content:s.target.value}),placeholder:"自动回复的内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>V(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:pt,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Zt,{className:"w-4 h-4"}),"保存规则"]})]})]})]})}),document.body),X&&qe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"账号默认回复"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"关键词和 AI 都未处理时,才会使用默认回复。"})]}),e.jsx("button",{onClick:()=>c(!1),className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",title:"关闭",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"闲鱼账号"}),e.jsxs("select",{value:O.cookie_id,onChange:s=>de({...O,cookie_id:s.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"选择账号"}),G.map(s=>e.jsx("option",{value:s.id,children:Qt(s)},s.id))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-gray-900",children:"启用默认回复"}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"启用后,未命中关键词时自动发送"})]}),e.jsx("button",{type:"button",onClick:()=>de({...O,enabled:!O.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${O.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${O.enabled?"translate-x-7":"translate-x-1"}`})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复内容"}),e.jsx("textarea",{value:O.reply_content,onChange:s=>de({...O,reply_content:s.target.value}),placeholder:"输入默认回复内容",className:"w-full ios-input px-4 py-3 rounded-xl h-32 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"回复图片 URL(可选)"}),e.jsx("input",{type:"text",value:O.reply_image_url,onChange:s=>de({...O,reply_image_url:s.target.value}),placeholder:"https://example.com/image.jpg",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("label",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl text-sm font-bold text-gray-800",children:[e.jsxs("span",{children:["只回复一次",e.jsx("span",{className:"block text-xs text-gray-500 font-medium mt-1",children:"同一会话只发送一次默认回复"})]}),e.jsx("input",{type:"checkbox",checked:O.reply_once,onChange:s=>de({...O,reply_once:s.target.checked}),className:"w-4 h-4 rounded"})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>c(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:ht,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),"保存默认回复"]})]})]})]})}),document.body)]})},On=t=>{const a=String(t.smtp_from||"").trim(),l=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a);return{...t,smtp_from_name:t.smtp_from_name||(l?"":a),smtp_from_address:t.smtp_from_address||(l?a:t.smtp_user||""),smtp_use_tls:oa(t.smtp_use_tls,!0),smtp_use_ssl:oa(t.smtp_use_ssl,!1)}},oa=(t,a)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return a},ks=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],fs=(t,a)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(["true","1","yes","on"].includes(t.toLowerCase()))return!0;if(["false","0","no","off"].includes(t.toLowerCase()))return!1}return a},Da=t=>{const a=Object.prototype.hasOwnProperty.call(t,"use_custom_smtp"),l=ks.some(i=>String(t[i]??"").trim()!=="");return{...t,use_custom_smtp:a?fs(t.use_custom_smtp,!1):l}},ca=(t,a)=>{const l={...t,use_custom_smtp:!0};for(const i of ks)String(l[i]??"").trim()===""&&a[i]!==void 0&&(l[i]=a[i]);return l.smtp_port||(l.smtp_port=587),l.smtp_from_address||(l.smtp_from_address=l.smtp_user||""),l.smtp_use_tls=fs(l.smtp_use_tls,!0),l.smtp_use_ssl=fs(l.smtp_use_ssl,!1),l},In=t=>{const a=Da(t),l={to_email:String(a.to_email??"").trim(),use_custom_smtp:a.use_custom_smtp===!0};if(l.use_custom_smtp)for(const i of ks)l[i]=a[i];return l},ft={bark:{label:"Bark",icon:jt,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"Ydisks闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app//这是测试推送内容","URL 路径里 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:Tt,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:Tt,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:Tt,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:dl,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:Zt,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的用户 ID",required:!0}],guide:{steps:["在 Telegram 搜索 @BotFather,发送 /newbot,按提示创建机器人,拿到 Bot Token","把你的 Bot 拉进一个群,或私聊它发一条消息","浏览器访问 https://api.telegram.org/bot<你的Token>/getUpdates",'从返回 JSON 里找 "chat":{"id":xxx},xxx 就是 Chat ID(群是负数,私聊是正数)'],urlFormat:"Bot Token: 123456:ABC-DEF... Chat ID: -1001234567890",note:"群聊需先把 Bot 设为管理员才能发消息。"}},email:{label:"邮件",icon:wa,fields:[{key:"to_email",label:"收件邮箱",placeholder:"receiver@example.com",required:!0}],guide:{steps:["通常先保存页面中的系统 SMTP 配置","邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP","只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置"],note:"继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。"}}},Ta=[{value:"account_offline",label:"掉线通知",description:"账号过期、断线或登录态失效"},{value:"account_recovered",label:"恢复通知",description:"自动恢复成功并重新在线"},{value:"account_disabled",label:"禁用通知",description:"连续失败、账密错误等导致账号停用"},{value:"security_verification",label:"风控验证",description:"滑块、人脸、扫码验证等安全校验"},{value:"delivery_result",label:"交易通知",description:"订单发货、卡密发送等交易结果"},{value:"token_renewal",label:"续期通知",description:"Cookie/token 续期和自动恢复过程"},{value:"system_error",label:"系统错误",description:"后台任务或系统级异常"}],An=t=>!t||t.length===0?"全部事件":t.map(l=>{var i;return((i=Ta.find(m=>m.value===l))==null?void 0:i.label)||l}).join("、"),$n=({isAdmin:t=!1})=>{const[a,l]=r.useState([]),[i,m]=r.useState(!0),[_,N]=r.useState(!1),[I,g]=r.useState(null),[C,j]=r.useState(!1),[F,G]=r.useState(""),[me,oe]=r.useState(null),[v,q]=r.useState({}),[ce,Q]=r.useState(!1),[ee,B]=r.useState(!1),[ge,ue]=r.useState(!1),[k,Z]=r.useState({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),se=async()=>{m(!0);try{const p=await Ra();l(p.data||[])}catch(p){console.error("加载通知渠道失败",p)}finally{m(!1)}},K=async()=>{try{const p=await Aa();q(On(p||{}))}catch(p){console.error("加载 SMTP 配置失败",p)}},ve=async()=>{Q(!0);try{await $a({smtp_server:v.smtp_server||"",smtp_port:v.smtp_port||587,smtp_user:v.smtp_user||"",smtp_password:v.smtp_password||"",smtp_from_name:v.smtp_from_name||"",smtp_from_address:v.smtp_from_address||v.smtp_user||"",smtp_use_tls:v.smtp_use_tls!==!1,smtp_use_ssl:v.smtp_use_ssl===!0}),J("success","SMTP 配置已保存")}catch(p){J("error",(p==null?void 0:p.message)||"保存失败")}finally{Q(!1)}};r.useEffect(()=>{se(),t?K():q({})},[t]);const J=(p,b)=>{oe({type:p,text:b}),window.setTimeout(()=>oe(null),3e3)},A=()=>{g(null),Z({name:"",type:"bark",enabled:!0,config:{},event_types:[]}),ue(!1),N(!0)},E=p=>{g(p);const b=p.type==="email"?Da({...p.config||{}}):null,U=b?b.use_custom_smtp===!0?ca(b,v):b:{...p.config||{}};Z({name:p.name,type:p.type,enabled:p.enabled,config:U,event_types:p.event_types||[]}),ue(!1),N(!0)},P=async()=>{const p=ft[k.type];for(const U of p.fields)if(U.required&&!String(k.config[U.key]||"").trim()){J("error",`请填写 ${U.label}`);return}if(!k.name.trim()){J("error","请填写渠道名称");return}let b=k.config;if(k.type==="email"&&(b=In(k.config),b.use_custom_smtp)){const M=[["smtp_server","独立 SMTP 服务器"],["smtp_port","独立 SMTP 端口"],["smtp_user","独立 SMTP 登录邮箱"],["smtp_password","独立 SMTP 密码 / 授权码"],["smtp_from_address","独立 SMTP 发件地址"]].find(([ne])=>!String(b[ne]||"").trim());if(M){J("error",`请填写 ${M[1]}`);return}}j(!0);try{const U={name:k.name.trim(),type:k.type,config:b,event_types:k.event_types,enabled:k.enabled};I?await Ys(I.id,U):await qr(U),N(!1),await se(),J("success",I?"已更新":"已创建")}catch(U){console.error("保存失败",U),J("error",(U==null?void 0:U.message)||"保存失败")}finally{j(!1)}},be=async p=>{if(confirm(`确认删除渠道「${p.name}」吗?已绑定该渠道的账号会自动解绑。`))try{await Fr(p.id),await se(),J("success","已删除")}catch(b){J("error",(b==null?void 0:b.message)||"删除失败")}},Re=async p=>{try{await Ys(p.id,{enabled:!p.enabled}),l(b=>b.map(U=>U.id===p.id?{...U,enabled:!U.enabled}:U))}catch(b){J("error",(b==null?void 0:b.message)||"切换失败")}},ae=async p=>{G(p.id);try{await zr(p.id),J("success","测试通知已发送,请检查对应渠道")}catch(b){J("error",(b==null?void 0:b.message)||"发送失败")}finally{G("")}},T=ft[k.type];return e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"通知设置"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"配置通知渠道,账号异常时主动推送告警"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:se,className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(ze,{className:"w-4 h-4"}),"刷新"]}),e.jsxs("button",{onClick:A,className:"ios-btn-primary px-5 py-2.5 rounded-xl font-bold flex items-center gap-2",children:[e.jsx(et,{className:"w-4 h-4"}),"新建渠道"]})]})]}),e.jsx("div",{className:"ios-card rounded-xl p-5 bg-blue-50/50 border border-blue-100",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(jt,{className:"w-5 h-5 text-brand mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-gray-700 leading-6",children:["配置通知渠道并在「账号管理 → 编辑」里绑定后,以下事件会主动推送到该账号绑定的渠道:",e.jsxs("ul",{className:"mt-2 space-y-1 text-gray-600",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"账号 session 失效"}),":系统正在尝试自动恢复(警告)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"自动恢复失败"}),":账号已停止,需人工处理(严重)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"触发风控验证"}),":可能需要扫码完成验证(警告)"]})]})]})]})}),i?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(Pe,{className:"w-8 h-8 text-brand animate-spin"})}):a.length===0?e.jsxs("div",{className:"ios-card rounded-xl p-12 bg-white text-center",children:[e.jsx(jt,{className:"w-12 h-12 text-gray-300 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"还没有配置任何通知渠道"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"点击右上角「新建渠道」开始配置"})]}):e.jsx("div",{className:"space-y-3",children:a.map(p=>{const b=ft[p.type]||ft.webhook,U=b.icon;return e.jsxs("div",{className:"ios-card rounded-xl p-5 bg-white flex items-center gap-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-gray-100 flex items-center justify-center flex-shrink-0",children:e.jsx(U,{className:"w-5 h-5 text-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-gray-900 truncate",children:p.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 font-medium",children:b.label}),!p.enabled&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-400 font-medium",children:"已停用"})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-1 truncate",children:b.fields.map(M=>{var ne;return(ne=p.config)==null?void 0:ne[M.key]}).filter(Boolean).map((M,ne)=>e.jsx("span",{className:"mr-3",children:String(M).length>40?String(M).slice(0,40)+"…":String(M)},ne))}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1 truncate",children:["订阅:",An(p.event_types)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>Re(p),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors ${p.enabled?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-200"}`,children:p.enabled?"启用中":"已停用"}),e.jsxs("button",{onClick:()=>ae(p),disabled:F===p.id,className:"px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-brand hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50",children:[F===p.id?e.jsx(Pe,{className:"w-3 h-3 animate-spin"}):e.jsx(Zt,{className:"w-3 h-3"}),"测试"]}),e.jsx("button",{onClick:()=>E(p),className:"w-8 h-8 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center text-gray-600 transition-colors",title:"编辑",children:e.jsx(_a,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>be(p),className:"w-8 h-8 rounded-lg bg-red-50 hover:bg-red-100 flex items-center justify-center text-red-500 transition-colors",title:"删除",children:e.jsx(Qe,{className:"w-4 h-4"})})]})]},p.id)})}),t&&e.jsxs("section",{className:"ios-card rounded-xl p-6 bg-white space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-extrabold text-gray-800",children:"SMTP 邮件配置"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"系统级邮件发送服务,供邮件通知渠道复用"})]}),e.jsx("div",{className:"p-2 rounded-xl bg-blue-50 text-blue-600",children:e.jsx(wa,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 服务器"}),e.jsx("input",{type:"text",value:v.smtp_server||"",onChange:p=>q({...v,smtp_server:p.target.value}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"SMTP 端口"}),e.jsx("input",{type:"number",value:v.smtp_port||587,onChange:p=>q({...v,smtp_port:parseInt(p.target.value)||587}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱"}),e.jsx("input",{type:"email",value:v.smtp_user||"",onChange:p=>q({...v,smtp_user:p.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"邮箱密码 / 授权码"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:ee?"text":"password",value:v.smtp_password||"",onChange:p=>q({...v,smtp_password:p.target.value}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>B(!ee),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 transition-colors",children:ee?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(lt,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"QQ 邮箱需使用授权码(QQ 邮箱设置 → 账号 → 开启 SMTP → 生成授权码)"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:v.smtp_from_name||"",onChange:p=>q({...v,smtp_from_name:p.target.value}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件邮箱地址"}),e.jsx("input",{type:"email",value:v.smtp_from_address||v.smtp_user||"",onChange:p=>q({...v,smtp_from_address:p.target.value}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:v.smtp_use_tls!==!1,onChange:p=>q({...v,smtp_use_tls:p.target.checked,smtp_use_ssl:p.target.checked?!1:v.smtp_use_ssl})}),"STARTTLS(常用于 587 端口)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-4 text-sm font-semibold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:v.smtp_use_ssl===!0,onChange:p=>q({...v,smtp_use_ssl:p.target.checked,smtp_use_tls:p.target.checked?!1:v.smtp_use_tls})}),"SSL/TLS 直连(常用于 465 端口)"]})]}),e.jsxs("button",{onClick:ve,disabled:ce,className:"ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[ce?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(He,{className:"w-4 h-4"}),ce?"保存中...":"保存 SMTP 配置"]})]}),_&&qe.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"36rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:I?"编辑通知渠道":"新建通知渠道"}),e.jsx("button",{onClick:()=>N(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道名称"}),e.jsx("input",{type:"text",value:k.name,onChange:p=>Z({...k,name:p.target.value}),placeholder:"例如:我的 Bark",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"渠道类型"}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:Object.keys(ft).map(p=>{const b=ft[p],U=b.icon,M=k.type===p;return e.jsxs("button",{type:"button",onClick:()=>Z({...k,type:p,config:{}}),className:`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${M?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsx(U,{className:`w-5 h-5 ${M?"text-brand":"text-gray-500"}`}),e.jsx("span",{className:`text-xs font-bold ${M?"text-brand":"text-gray-600"}`,children:b.label})]},p)})})]}),e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jt,{className:"w-4 h-4 text-amber-600"}),e.jsxs("span",{className:"text-sm font-bold text-amber-800",children:["如何获取 ",T.label," 配置?"]})]}),e.jsx("ol",{className:"space-y-1.5 text-xs text-amber-900/90 leading-5 list-decimal pl-5",children:T.guide.steps.map((p,b)=>e.jsx("li",{children:p},b))}),T.guide.urlFormat&&e.jsxs("div",{className:"text-xs text-amber-900/90",children:[e.jsx("span",{className:"font-bold",children:"格式示例:"}),e.jsx("code",{className:"mt-1 block bg-amber-100/70 px-2.5 py-1.5 rounded-lg break-all font-mono text-[11px]",children:T.guide.urlFormat})]}),T.guide.note&&e.jsxs("p",{className:"text-xs text-amber-800/80 leading-5 pt-1",children:["💡 ",T.guide.note]})]}),e.jsx("div",{className:"space-y-3",children:T.fields.map(p=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:[p.label,p.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{type:p.type==="password"?"password":p.type==="number"?"number":"text",value:String(k.config[p.key]||""),onChange:b=>Z({...k,config:{...k.config,[p.key]:b.target.value}}),placeholder:p.placeholder,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),p.help&&e.jsx("p",{className:"text-xs text-gray-500",children:p.help})]},p.key))}),k.type==="email"&&e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-blue-100 bg-blue-50/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-extrabold text-gray-900",children:"SMTP 来源"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-gray-500",children:k.config.use_custom_smtp===!0?"当前渠道使用一套完整、独立的发件配置。":"当前渠道完整继承系统 SMTP,只单独设置收件邮箱。"})]}),e.jsx("button",{type:"button",onClick:()=>{const p=k.config.use_custom_smtp===!0;Z({...k,config:p?{...k.config,use_custom_smtp:!1}:ca(k.config,v)})},className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${k.config.use_custom_smtp===!0?"bg-brand":"bg-gray-300"}`,"aria-label":"使用独立 SMTP",children:e.jsx("span",{className:`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${k.config.use_custom_smtp===!0?"translate-x-5":""}`})})]}),k.config.use_custom_smtp===!0&&e.jsxs("div",{className:"space-y-4 border-t border-blue-100 bg-white/80 p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 服务器 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:String(k.config.smtp_server||""),onChange:p=>Z({...k,config:{...k.config,smtp_server:p.target.value}}),placeholder:"smtp.qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["SMTP 端口 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",value:String(k.config.smtp_port||587),onChange:p=>Z({...k,config:{...k.config,smtp_port:p.target.value}}),placeholder:"587",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["登录邮箱 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(k.config.smtp_user||""),onChange:p=>Z({...k,config:{...k.config,smtp_user:p.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["密码 / 授权码 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:ge?"text":"password",value:String(k.config.smtp_password||""),onChange:p=>Z({...k,config:{...k.config,smtp_password:p.target.value}}),placeholder:"输入密码或授权码",className:"w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"}),e.jsx("button",{type:"button",onClick:()=>ue(p=>!p),className:"absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600",children:ge?e.jsx(dt,{className:"w-4 h-4"}):e.jsx(lt,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"发件人显示名(可选)"}),e.jsx("input",{type:"text",value:String(k.config.smtp_from_name||""),onChange:p=>Z({...k,config:{...k.config,smtp_from_name:p.target.value}}),placeholder:"闲鱼自动回复系统",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-800",children:["发件邮箱地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:String(k.config.smtp_from_address||""),onChange:p=>Z({...k,config:{...k.config,smtp_from_address:p.target.value}}),placeholder:"your-email@qq.com",className:"w-full ios-input px-4 py-3 rounded-xl text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:k.config.smtp_use_tls!==!1,onChange:p=>Z({...k,config:{...k.config,smtp_use_tls:p.target.checked,smtp_use_ssl:p.target.checked?!1:k.config.smtp_use_ssl}})}),"STARTTLS(常用于 587)"]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:k.config.smtp_use_ssl===!0,onChange:p=>Z({...k,config:{...k.config,smtp_use_ssl:p.target.checked,smtp_use_tls:p.target.checked?!1:k.config.smtp_use_tls}})}),"SSL/TLS 直连(常用于 465)"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"通知内容"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"不选择表示接收全部通知;选择后仅接收勾选类型。"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Ta.map(p=>{const b=k.event_types.includes(p.value);return e.jsxs("button",{type:"button",onClick:()=>{const U=b?k.event_types.filter(M=>M!==p.value):[...k.event_types,p.value];Z({...k,event_types:U})},className:`text-left rounded-xl border px-3 py-2.5 transition-colors ${b?"border-brand bg-blue-50":"border-gray-100 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center ${b?"bg-brand border-brand":"border-gray-300"}`,children:b&&e.jsx(Ke,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:`text-sm font-bold ${b?"text-brand":"text-gray-800"}`,children:p.label})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 pl-6 leading-5",children:p.description})]},p.value)})})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>Z({...k,enabled:!k.enabled}),className:`relative w-11 h-6 rounded-full transition-colors ${k.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform ${k.enabled?"translate-x-5":""}`})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"启用此渠道"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>N(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"取消"}),e.jsxs("button",{onClick:P,disabled:C,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[C?e.jsx(Pe,{className:"w-4 h-4 animate-spin"}):e.jsx(Ke,{className:"w-4 h-4"}),C?"保存中...":"保存"]})]})]})}),document.body),me&&e.jsxs("div",{className:`fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in text-white ${me.type==="success"?"bg-success-500":"bg-danger-500"}`,children:[me.type==="success"?e.jsx(Ke,{className:"w-4 h-4"}):e.jsx(Me,{className:"w-4 h-4"}),me.text]})]})},Ma=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["流汗","https://img.alicdn.com/imgextra/i4/O1CN01BU3NZ21gdcSjkqnST_!!6000000004165-2-tps-980-980.png_110x10000.jpg_.webp"],["憨笑","https://img.alicdn.com/imgextra/i2/O1CN01Pee9Ql1SJ661eH9By_!!6000000002225-2-tps-980-980.png_110x10000.jpg_.webp"],["耶","https://img.alicdn.com/imgextra/i2/O1CN01pFicsL1ipBhIqzcgs_!!6000000004461-2-tps-980-980.png_110x10000.jpg_.webp"],["奋斗","https://img.alicdn.com/imgextra/i3/O1CN01ZhQ4AV25xBmTK3CnF_!!6000000007592-2-tps-980-980.png_110x10000.jpg_.webp"],["咒骂","https://img.alicdn.com/imgextra/i3/O1CN01r1Zh9927QKb4pnf7k_!!6000000007791-2-tps-980-980.png_110x10000.jpg_.webp"],["疑问","https://img.alicdn.com/imgextra/i4/O1CN01UZqbzt29MmlNctCQS_!!6000000008054-2-tps-980-980.png_110x10000.jpg_.webp"],["嘘","https://img.alicdn.com/imgextra/i1/O1CN01qBlYkM1ojaYF75On5_!!6000000005261-2-tps-980-980.png_110x10000.jpg_.webp"],["晕","https://img.alicdn.com/imgextra/i2/O1CN014zhM2h1wPuSUFoMwV_!!6000000006301-2-tps-980-980.png_110x10000.jpg_.webp"],["开心到模糊","https://img.alicdn.com/imgextra/i1/O1CN01T1Dy271j6akZWo7Vr_!!6000000004499-2-tps-980-980.png_110x10000.jpg_.webp"],["衰","https://img.alicdn.com/imgextra/i1/O1CN01aOXsNr1LmgMvtyzOO_!!6000000001342-2-tps-980-980.png_110x10000.jpg_.webp"],["委屈","https://img.alicdn.com/imgextra/i2/O1CN013J0bMk1QNYih3UFTk_!!6000000001964-2-tps-980-980.png_110x10000.jpg_.webp"],["再见","https://img.alicdn.com/imgextra/i2/O1CN01IHKsQx1UdpFgeTHcA_!!6000000002541-2-tps-980-980.png_110x10000.jpg_.webp"],["鼓掌","https://img.alicdn.com/imgextra/i4/O1CN01DHxB5s1G1RRBxekIu_!!6000000000562-2-tps-980-980.png_110x10000.jpg_.webp"],["吐","https://img.alicdn.com/imgextra/i1/O1CN01xyVxH21LNUaMgW4hh_!!6000000001287-2-tps-980-980.png_110x10000.jpg_.webp"],["坏笑","https://img.alicdn.com/imgextra/i1/O1CN01zV7opv1bIU6iI8OhM_!!6000000003442-2-tps-980-980.png_110x10000.jpg_.webp"],["抠鼻","https://img.alicdn.com/imgextra/i1/O1CN01QOanju1sNqCrtYstu_!!6000000005755-2-tps-980-980.png_110x10000.jpg_.webp"],["叹气","https://img.alicdn.com/imgextra/i3/O1CN01RElx7R1QD1c8ZN07f_!!6000000001941-2-tps-980-980.png_110x10000.jpg_.webp"],["无聊","https://img.alicdn.com/imgextra/i2/O1CN01d91LnZ1UJDQjKCouC_!!6000000002496-2-tps-980-980.png_110x10000.jpg_.webp"],["思考","https://img.alicdn.com/imgextra/i2/O1CN01wQjg2f1tO84ZWitn9_!!6000000005891-2-tps-980-980.png_110x10000.jpg_.webp"],["呆","https://img.alicdn.com/imgextra/i1/O1CN01GLqBWC1DGbhqmpD2L_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["哇哦","https://img.alicdn.com/imgextra/i2/O1CN01MtLpS21qRO2bnAA5k_!!6000000005492-2-tps-980-980.png_110x10000.jpg_.webp"],["飞吻","https://img.alicdn.com/imgextra/i4/O1CN01q1WpFE25ljsNKjvHX_!!6000000007567-2-tps-980-980.png_110x10000.jpg_.webp"],["好喜欢","https://img.alicdn.com/imgextra/i2/O1CN01mD4iQM1O57XyQ5SHD_!!6000000001653-2-tps-980-980.png_110x10000.jpg_.webp"],["拜托","https://img.alicdn.com/imgextra/i4/O1CN01SQgrTH1dzCH3pIyRN_!!6000000003806-2-tps-980-980.png_110x10000.jpg_.webp"],["真棒","https://img.alicdn.com/imgextra/i2/O1CN017fcAmd1SCgYCj9Upk_!!6000000002211-2-tps-980-980.png_110x10000.jpg_.webp"],["流鼻血","https://img.alicdn.com/imgextra/i3/O1CN0139JscY1rC6RS9GR4j_!!6000000005594-2-tps-980-980.png_110x10000.jpg_.webp"],["费解","https://img.alicdn.com/imgextra/i1/O1CN01FqAVvR1tyJMPj13ie_!!6000000005970-2-tps-980-980.png_110x10000.jpg_.webp"],["秃头","https://img.alicdn.com/imgextra/i4/O1CN01ZF4bV11thMhqm2Z1h_!!6000000005933-2-tps-980-980.png_110x10000.jpg_.webp"],["嘿哈","https://img.alicdn.com/imgextra/i4/O1CN01ObcOw61FOVlvQg7Mw_!!6000000000477-2-tps-980-980.png_110x10000.jpg_.webp"],["吃土","https://img.alicdn.com/imgextra/i3/O1CN01Z6nJ1b1ZYr22YseHN_!!6000000003207-2-tps-980-980.png_110x10000.jpg_.webp"],["机智","https://img.alicdn.com/imgextra/i1/O1CN01rfKY351zDUZJlBiir_!!6000000006680-2-tps-980-980.png_110x10000.jpg_.webp"],["举杯","https://img.alicdn.com/imgextra/i4/O1CN01R2tn4F1mn8NuEIE8J_!!6000000004998-2-tps-980-980.png_110x10000.jpg_.webp"],["握手","https://img.alicdn.com/imgextra/i4/O1CN01NDcA251JDkvuFhSDb_!!6000000000995-2-tps-980-980.png_110x10000.jpg_.webp"],["挥手","https://img.alicdn.com/imgextra/i4/O1CN01iVN0ht1TmEuSwauGt_!!6000000002424-2-tps-980-980.png_110x10000.jpg_.webp"],["yeah","https://img.alicdn.com/imgextra/i3/O1CN01opt7hh27Wk8omjR4t_!!6000000007805-2-tps-980-980.png_110x10000.jpg_.webp"],["666","https://img.alicdn.com/imgextra/i3/O1CN01YRWDPF1OjQOpXeuTC_!!6000000001741-2-tps-980-980.png_110x10000.jpg_.webp"],["棒","https://img.alicdn.com/imgextra/i3/O1CN01agprvs1HU7rPRxOnB_!!6000000000760-2-tps-980-980.png_110x10000.jpg_.webp"],["爱你","https://img.alicdn.com/imgextra/i1/O1CN01SzxgcH1GSSo6Lwmwk_!!6000000000621-2-tps-980-980.png_110x10000.jpg_.webp"],["比心","https://img.alicdn.com/imgextra/i1/O1CN01YHZ39t1DeQIeb0TWQ_!!6000000000241-2-tps-980-980.png_110x10000.jpg_.webp"],["感谢","https://img.alicdn.com/imgextra/i3/O1CN01ywacF81baLYNeyK1n_!!6000000003481-2-tps-980-980.png_110x10000.jpg_.webp"],["拍手","https://img.alicdn.com/imgextra/i4/O1CN01wbj4wv1K7ArD9AU44_!!6000000001116-2-tps-980-980.png_110x10000.jpg_.webp"],["拉钩","https://img.alicdn.com/imgextra/i1/O1CN01dePkKH1HOd6ivAcu8_!!6000000000748-2-tps-980-980.png_110x10000.jpg_.webp"],["没钱","https://img.alicdn.com/imgextra/i3/O1CN01qhxGjp1zD2AfqmWx5_!!6000000006679-2-tps-980-980.png_110x10000.jpg_.webp"],["小刀","https://img.alicdn.com/imgextra/i3/O1CN01tFVx5Y1T2thPjhR6b_!!6000000002325-2-tps-980-980.png_110x10000.jpg_.webp"],["不刀","https://img.alicdn.com/imgextra/i4/O1CN01zTxff61clcvOcTS3n_!!6000000003641-2-tps-980-980.png_110x10000.jpg_.webp"],["同出","https://img.alicdn.com/imgextra/i3/O1CN01URKas6249R8ozS98O_!!6000000007348-2-tps-980-980.png_110x10000.jpg_.webp"],["递钱","https://img.alicdn.com/imgextra/i4/O1CN01PzhgV51FLlOaZHZ6n_!!6000000000471-2-tps-980-980.png_110x10000.jpg_.webp"],["数钱","https://img.alicdn.com/imgextra/i3/O1CN01CzXXvp23khkljToQH_!!6000000007294-2-tps-980-980.png_110x10000.jpg_.webp"],["打call","https://img.alicdn.com/imgextra/i1/O1CN01X7VUVm1il48IYv8Qw_!!6000000004452-2-tps-980-980.png_110x10000.jpg_.webp"],["号外","https://img.alicdn.com/imgextra/i2/O1CN01vg6xSM1Vxo9EKyfjR_!!6000000002720-2-tps-980-980.png_110x10000.jpg_.webp"],["包邮","https://img.alicdn.com/imgextra/i3/O1CN01yVS7ys24jA22oVZ2T_!!6000000007426-2-tps-980-980.png_110x10000.jpg_.webp"],["求赞","https://img.alicdn.com/imgextra/i1/O1CN01Xwqi5A1giCQMRcX6N_!!6000000004175-2-tps-980-980.png_110x10000.jpg_.webp"],["非主流","https://img.alicdn.com/imgextra/i1/O1CN013wyI1j1hlEfDUoATI_!!6000000004317-2-tps-980-980.png_110x10000.jpg_.webp"],["吃瓜","https://img.alicdn.com/imgextra/i1/O1CN01LLOFsh1UUCw0deZba_!!6000000002520-2-tps-980-980.png_110x10000.jpg_.webp"],["种草","https://img.alicdn.com/imgextra/i2/O1CN01ooeRC81hA8a4x9S3q_!!6000000004236-2-tps-980-980.png_110x10000.jpg_.webp"],["佛系","https://img.alicdn.com/imgextra/i4/O1CN01BYXEe321GMHMZ9w66_!!6000000006957-2-tps-980-980.png_110x10000.jpg_.webp"],["超便宜","https://img.alicdn.com/imgextra/i4/O1CN01mqgSZi1Er4rOIDiP7_!!6000000000404-2-tps-980-980.png_110x10000.jpg_.webp"],["拥抱","https://img.alicdn.com/imgextra/i1/O1CN01yuGD9c1hJkttfKHAm_!!6000000004257-2-tps-980-980.png_110x10000.jpg_.webp"],["摊手","https://img.alicdn.com/imgextra/i2/O1CN014AiIqE1o9repE6STR_!!6000000005183-2-tps-980-980.png_110x10000.jpg_.webp"],["举手","https://img.alicdn.com/imgextra/i1/O1CN01xizuHZ1WPkJCogbuj_!!6000000002781-2-tps-980-980.png_110x10000.jpg_.webp"],["蹲","https://img.alicdn.com/imgextra/i3/O1CN01Midjjn1FrMj2CWer6_!!6000000000540-2-tps-980-980.png_110x10000.jpg_.webp"],["跪了","https://img.alicdn.com/imgextra/i3/O1CN01F2y52j24E16L6RIjF_!!6000000007358-2-tps-980-980.png_110x10000.jpg_.webp"],["拜","https://img.alicdn.com/imgextra/i4/O1CN01Jldd1G1oXDrEHH2qr_!!6000000005234-2-tps-980-980.png_110x10000.jpg_.webp"],["排","https://img.alicdn.com/imgextra/i3/O1CN01uSUmYD1jD0IJf0UVU_!!6000000004513-2-tps-980-980.png_110x10000.jpg_.webp"],["旺财","https://img.alicdn.com/imgextra/i3/O1CN01A25Mv01DKjGseAmuP_!!6000000000198-2-tps-980-980.png_110x10000.jpg_.webp"],["招财猫","https://img.alicdn.com/imgextra/i3/O1CN01WmJ7Sr20EhDyp86Bd_!!6000000006818-2-tps-980-980.png_110x10000.jpg_.webp"],["酸了","https://img.alicdn.com/imgextra/i3/O1CN01UFgjn61JJi5Iqxdk7_!!6000000001008-2-tps-980-980.png_110x10000.jpg_.webp"],["鸭鸭","https://img.alicdn.com/imgextra/i3/O1CN01pHSCSQ1deaS8WDiqG_!!6000000003761-2-tps-980-980.png_110x10000.jpg_.webp"],["方了","https://img.alicdn.com/imgextra/i3/O1CN01br7g711whlu8xOPUt_!!6000000006340-2-tps-980-980.png_110x10000.jpg_.webp"],["白菜","https://img.alicdn.com/imgextra/i1/O1CN01KABFLt24WKwXjVp08_!!6000000007398-2-tps-980-980.png_110x10000.jpg_.webp"],["桃子","https://img.alicdn.com/imgextra/i1/O1CN01CQhhPH1vJfRjDGBv5_!!6000000006152-2-tps-980-980.png_110x10000.jpg_.webp"],["打包","https://img.alicdn.com/imgextra/i3/O1CN01oYOkUI1VT7c0ivZHV_!!6000000002653-2-tps-980-980.png_110x10000.jpg_.webp"],["沙发","https://img.alicdn.com/imgextra/i4/O1CN018qUFaE1DGbhqpMIit_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["南","https://img.alicdn.com/imgextra/i1/O1CN01ZSA6wg1PEZKf4h99R_!!6000000001809-2-tps-980-980.png_110x10000.jpg_.webp"],["盯","https://img.alicdn.com/imgextra/i4/O1CN01OWB1Gx1s01bzBhHN6_!!6000000005703-2-tps-980-980.png_110x10000.jpg_.webp"],["hot","https://img.alicdn.com/imgextra/i4/O1CN01DDD9uA22cAl7VDH7d_!!6000000007140-2-tps-980-980.png_110x10000.jpg_.webp"],["new","https://img.alicdn.com/imgextra/i3/O1CN01rRJXJo1qwzN4YnOHX_!!6000000005561-2-tps-980-980.png_110x10000.jpg_.webp"],["cool","https://img.alicdn.com/imgextra/i4/O1CN013bUubF2855qb2Qt5l_!!6000000007880-2-tps-980-980.png_110x10000.jpg_.webp"],["1","https://img.alicdn.com/imgextra/i1/O1CN01U8XG5y1Ie22frQHCQ_!!6000000000917-2-tps-980-980.png_110x10000.jpg_.webp"],["可","https://img.alicdn.com/imgextra/i2/O1CN01SMjtPG1iJaN17p94N_!!6000000004392-2-tps-980-980.png_110x10000.jpg_.webp"],["搬砖","https://img.alicdn.com/imgextra/i1/O1CN01GbqW6G1LOrm0Gllcb_!!6000000001290-2-tps-980-980.png_110x10000.jpg_.webp"],["菜狗","https://img.alicdn.com/imgextra/i2/O1CN01VtN0t91USNLmvfmol_!!6000000002516-2-tps-980-980.png_110x10000.jpg_.webp"],["开心面具","https://img.alicdn.com/imgextra/i3/O1CN017elkpk22EoYlBPKd3_!!6000000007089-2-tps-980-980.png_110x10000.jpg_.webp"],["快递","https://img.alicdn.com/imgextra/i2/O1CN01AmUZXk1d3wle5O8IJ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["裂开","https://img.alicdn.com/imgextra/i1/O1CN01BihwvO1a5N9bFt0LU_!!6000000003278-2-tps-980-980.png_110x10000.jpg_.webp"],["啤酒","https://img.alicdn.com/imgextra/i4/O1CN01jDkgEj1WvLdXUVBDx_!!6000000002850-2-tps-980-980.png_110x10000.jpg_.webp"],["瑞思拜","https://img.alicdn.com/imgextra/i4/O1CN011gR0Um1K3VgpYjPOi_!!6000000001108-2-tps-980-980.png_110x10000.jpg_.webp"],["小丑","https://img.alicdn.com/imgextra/i3/O1CN01jMikhO1NJUM15XKTf_!!6000000001549-2-tps-980-980.png_110x10000.jpg_.webp"],["爱心","https://img.alicdn.com/imgextra/i1/O1CN015RVSWf23s25eETJqO_!!6000000007310-2-tps-980-980.png_110x10000.jpg_.webp"]],Pn=t=>t,Rn=new Map(Ma.map(([t,a])=>[t,a])),da=t=>t.split(/(\[[^\]]+\])/g).map((a,l)=>{const i=a.startsWith("[")?Rn.get(a.slice(1,-1)):void 0;return i?e.jsx("img",{src:i,alt:a,title:a,className:"mx-0.5 inline-block h-7 w-7 align-middle"},l):e.jsx(ys.Fragment,{children:a},l)}),xa="ydisks.chat.account.v1",En=t=>{if(!t)return"";const a=new Date(t<1e10?t*1e3:t),l=new Date;return a.toDateString()===l.toDateString()?a.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):a.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},ma=t=>new Date(t<1e10?t*1e3:t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),Dn=()=>{const[t,a]=r.useState([]),[l,i]=r.useState(""),[m,_]=r.useState({}),[N,I]=r.useState(""),[g,C]=r.useState([]),[j,F]=r.useState(""),[G,me]=r.useState(!1),[oe,v]=r.useState(""),[q,ce]=r.useState(!0),[Q,ee]=r.useState(!1),[B,ge]=r.useState(!1),[ue,k]=r.useState(!1),[Z,se]=r.useState(),[K,ve]=r.useState({}),[J,A]=r.useState({}),[E,P]=r.useState(!1),[be,Re]=r.useState(!1),[ae,T]=r.useState(!1),[p,b]=r.useState(""),[U,M]=r.useState("connecting"),ne=r.useRef(""),he=r.useRef(""),ye=r.useRef(null),Ee=r.useRef({accountID:"",chatID:""}),ke=r.useRef(!0),x=r.useRef(!1),V=r.useRef(null),X=r.useRef(new Set);r.useEffect(()=>{ne.current=l},[l]),r.useEffect(()=>{he.current=N},[N]);const c=async h=>{const f=await as(h,void 0,void 0,!0);return _(R=>({...R,[h]:f.sessions})),ve(R=>({...R,[h]:f.next_cursor})),A(R=>({...R,[h]:f.has_more})),f.sessions};r.useEffect(()=>{let h=!1;return(async()=>{var R;ce(!0);try{const[z,Ie]=await Promise.all([Ft(),hs()]),we=z.map(u=>{var L,le;return{...u,runtime_state:((L=Ie[u.id])==null?void 0:L.state)||(u.enabled?"connecting":"disabled"),runtime_connected:((le=Ie[u.id])==null?void 0:le.connected)===!0}}).filter(u=>u.enabled),De=await Promise.all(we.map(async u=>[u.id,await as(u.id)]));if(h)return;a(we),_(Object.fromEntries(De.map(([u,L])=>[u,L.sessions]))),ve(Object.fromEntries(De.map(([u,L])=>[u,L.next_cursor]))),A(Object.fromEntries(De.map(([u,L])=>[u,L.has_more])));const te=window.localStorage.getItem(xa)||"",je=we.some(u=>u.id===te)?te:((R=we[0])==null?void 0:R.id)||"";i(je)}catch(z){h||b(z instanceof Error?z.message:"加载聊天数据失败")}finally{h||ce(!1)}})(),()=>{h=!0}},[]),r.useEffect(()=>{let h=!1,f=0,R=null;const z=async()=>{R=new AbortController;try{const Ie=await hs({signal:R.signal,timeoutMs:1e4});h||a(Ae=>Ae.map(we=>{var De,te;return{...we,runtime_state:((De=Ie[we.id])==null?void 0:De.state)||we.runtime_state,runtime_connected:((te=Ie[we.id])==null?void 0:te.connected)??we.runtime_connected}}))}catch{}finally{h||(f=window.setTimeout(z,3e3))}};return f=window.setTimeout(z,3e3),()=>{h=!0,window.clearTimeout(f),R==null||R.abort()}},[]),r.useEffect(()=>{if(!l)return;window.localStorage.setItem(xa,l);const h=m[l]||[];I(f=>{var R;return h.some(z=>z.chat_id===f)?f:((R=h[0])==null?void 0:R.chat_id)||""})},[l,m]),r.useEffect(()=>{!l||X.current.has(l)||(X.current.add(l),c(l).catch(h=>{b(h instanceof Error?h.message:"同步会话失败")}))},[l]),r.useEffect(()=>{if(!l||!N){C([]);return}const h=new AbortController;return ee(!0),Promise.all([us(l,N,void 0,void 0,{signal:h.signal}),Qs(l,N)]).then(([f])=>{C(f.messages),k(f.has_more),se(f.next_cursor),f.session&&_(R=>({...R,[l]:(R[l]||[]).map(z=>{var Ie;return z.chat_id===((Ie=f.session)==null?void 0:Ie.chat_id)?f.session:z})})),_(R=>({...R,[l]:(R[l]||[]).map(z=>z.chat_id===N?{...z,unread_count:0}:z)}))}).catch(f=>{h.signal.aborted||b(f instanceof Error?f.message:"加载消息失败")}).finally(()=>{h.signal.aborted||ee(!1)}),()=>h.abort()},[l,N]);const d=async()=>{var R;if(!l||!N||B||!ue)return;const h=ye.current,f=(h==null?void 0:h.scrollHeight)||0;x.current=!0,ge(!0),b("");try{const z=(R=g[0])==null?void 0:R.id,Ie=await us(l,N,Z,z);C(Ae=>{const we=new Set(Ae.map(De=>De.message_key));return[...Ie.messages.filter(De=>!we.has(De.message_key)),...Ae]}),k(Ie.has_more),se(Ie.next_cursor),requestAnimationFrame(()=>{h&&(h.scrollTop+=h.scrollHeight-f)})}catch(z){x.current=!1,b(z instanceof Error?z.message:"加载历史消息失败")}finally{ge(!1)}};r.useEffect(()=>{let h=!1,f=0,R=0,z=null;const Ie=()=>{if(h)return;M("connecting");const Ae=window.location.protocol==="https:"?"wss:":"ws:";z=new WebSocket(`${Ae}//${window.location.host}/api/chat/ws`),z.onopen=()=>{R=0,M("online")},z.onmessage=we=>{try{const te=JSON.parse(we.data).message;if(!te)return;const je=te.account_id;_(u=>{const L=u[je]||[];return L.some(_e=>_e.chat_id===te.chat_id)?{...u,[je]:L.map(_e=>_e.chat_id===te.chat_id?{..._e,last_message:te.content,last_message_at:te.sent_at,unread_count:te.direction==="incoming"&&(ne.current!==je||he.current!==te.chat_id)?_e.unread_count+1:_e.unread_count}:_e).sort((_e,Ue)=>Ue.last_message_at-_e.last_message_at)}:(c(je),u)}),ne.current===je&&he.current===te.chat_id&&(C(u=>{const L=u.findIndex(le=>le.message_key===te.message_key);return L>=0?u.map((le,_e)=>_e===L?te:le):[...u,te]}),te.direction==="incoming"&&Qs(je,te.chat_id))}catch{}},z.onclose=()=>{if(h)return;M("offline");const we=Math.min(15e3,1e3*2**Math.min(R++,4));f=window.setTimeout(Ie,we)},z.onerror=()=>z==null?void 0:z.close()};return Ie(),()=>{h=!0,window.clearTimeout(f),z==null||z.close()}},[]);const D=()=>{const h=ye.current;if(!h)return;const f=h.scrollHeight-h.scrollTop-h.clientHeight;ke.current=f<=48};r.useLayoutEffect(()=>{const h=Ee.current.accountID!==l||Ee.current.chatID!==N;Ee.current={accountID:l,chatID:N},h&&(ke.current=!0);const f=ye.current;if(f){if(x.current){x.current=!1;return}(Q||ke.current)&&(f.scrollTop=f.scrollHeight)}},[l,N,g,Q]);const S=t.find(h=>h.id===l),Y=m[l]||[],O=Y.find(h=>h.chat_id===N),de=r.useMemo(()=>{const h=j.trim().toLowerCase();return Y.filter(f=>G&&f.unread_count<=0?!1:h?[f.buyer_name,f.buyer_id,f.item_title,f.last_message].some(R=>(R||"").toLowerCase().includes(h)):!0)},[Y,j,G]),Se=h=>(m[h]||[]).reduce((f,R)=>f+R.unread_count,0),fe=async()=>{if(!(!l||E||!J[l])){P(!0),b("");try{const h=await as(l,K[l],void 0,!0);_(f=>({...f,[l]:h.sessions})),ve(f=>({...f,[l]:h.next_cursor})),A(f=>({...f,[l]:h.has_more}))}catch(h){b(h instanceof Error?h.message:"加载历史联系人失败")}finally{P(!1)}}},Oe=async()=>{const h=oe.trim();if(!(!h||!O||!l||ae)){T(!0),b("");try{const f=await Tl({account_id:l,chat_id:O.chat_id,buyer_id:O.buyer_id,buyer_name:O.buyer_name,item_id:O.item_id,item_title:O.item_title,text:h});v(""),C(R=>R.some(z=>z.message_key===f.message.message_key)?R.map(z=>z.message_key===f.message.message_key?f.message:z):[...R,f.message])}catch(f){b(f instanceof Error?f.message:"消息发送失败"),Dl(l,O.chat_id).then(C)}finally{T(!1)}}},re=async h=>{if(!(!h||!O||!l||ae)){T(!0),b("");try{const f=await Ml({account_id:l,chat_id:O.chat_id,buyer_id:O.buyer_id,buyer_name:O.buyer_name,buyer_avatar_url:O.buyer_avatar_url,item_id:O.item_id,item_title:O.item_title,image:h});C(R=>R.some(z=>z.message_key===f.message.message_key)?R.map(z=>z.message_key===f.message.message_key?f.message:z):[...R,f.message])}catch(f){b(f instanceof Error?f.message:"图片发送失败")}finally{T(!1),V.current&&(V.current.value="")}}};return q?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx(Pe,{className:"h-8 w-8 animate-spin text-sky-500"})}):e.jsxs("section",{className:"flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat",children:[e.jsxs("header",{className:"border-b border-slate-200 bg-slate-50/70 px-5 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-slate-950",children:"在线聊天"}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"复用账号实时连接,消息按账号完全隔离"})]}),e.jsxs("div",{className:`flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-bold ${U==="online"?"bg-emerald-50 text-emerald-700":U==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[U==="online"?e.jsx(xl,{className:"h-3.5 w-3.5"}):e.jsx(ml,{className:"h-3.5 w-3.5"}),U==="online"?"实时同步中":U==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:t.map(h=>{const f=h.id===l,R=Se(h.id),z=h.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":f,onClick:()=>i(h.id),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${f?"border-sky-500 text-sky-700":"border-transparent text-slate-500 hover:text-slate-900"}`,children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${z?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:h.nickname||h.remark||h.id}),R>0&&e.jsx("span",{className:"min-w-5 rounded-full bg-red-500 px-1.5 py-0.5 text-[10px] text-white",children:R>99?"99+":R})]},h.id)})})]}),t.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(is,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-800",children:"暂无启用账号"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"先在账号管理中启用账号,聊天会话会自动出现。"})]}):e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-slate-200 bg-slate-50/40",children:[e.jsxs("div",{className:"space-y-3 border-b border-slate-200 p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Nt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:j,onChange:h=>F(h.target.value),placeholder:"搜索用户、商品或消息",className:"h-10 w-full rounded-xl border border-slate-200 bg-white pl-9 pr-3 text-sm outline-none transition focus:border-sky-400 focus:ring-2 focus:ring-sky-100"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>me(h=>!h),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${G?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:G?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:()=>void c(l),className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(ze,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[de.map(h=>e.jsxs("button",{type:"button",onClick:()=>I(h.chat_id),className:`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${h.chat_id===N?"bg-white shadow-chat-active":"hover:bg-white/80"}`,children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500",children:h.buyer_avatar_url?e.jsx("img",{src:h.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(Gt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-extrabold text-slate-900",children:h.buyer_name||`用户 ${h.buyer_id}`}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] font-medium text-slate-400",children:En(h.last_message_at)})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs text-slate-500",children:h.last_message||"暂无消息"}),h.unread_count>0&&e.jsx("span",{className:"ml-auto min-w-5 shrink-0 rounded-full bg-red-500 px-1.5 py-0.5 text-center text-[10px] font-bold text-white",children:h.unread_count})]}),h.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",h.item_title]})]})]},h.chat_id)),de.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),J[l]&&!j&&!G&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:()=>void fe(),disabled:E,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-xs font-bold text-slate-500 shadow-sm hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[E&&e.jsx(Pe,{className:"h-3.5 w-3.5 animate-spin"}),E?"正在加载":"加载更多历史联系人"]})})]})]}),e.jsx("main",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle",children:O?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-950",children:O.buyer_name||O.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",O.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(S==null?void 0:S.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(S==null?void 0:S.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:ye,onScroll:D,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:Q?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Pe,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[ue&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:()=>void d(),disabled:B,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-1.5 text-xs font-bold text-slate-500 shadow-sm transition hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[B&&e.jsx(Pe,{className:"h-3.5 w-3.5 animate-spin"}),B?"正在加载":"加载更早消息"]})}),g.map(h=>{const f=h.direction==="outgoing";return h.message_type==="system"?e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500",children:[da(h.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:ma(h.sent_at)})]})},h.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${f?"justify-end":"justify-start"}`,children:[!f&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:O.buyer_avatar_url?e.jsx("img",{src:O.buyer_avatar_url,alt:O.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(Gt,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${f?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:f?(S==null?void 0:S.nickname)||(S==null?void 0:S.remark)||"我":O.buyer_name||h.sender_name||O.buyer_id}),h.message_type==="image"?e.jsx("a",{href:h.content,target:"_blank",rel:"noreferrer",className:`block overflow-hidden rounded-2xl border bg-white p-1 shadow-sm ${f?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:h.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):h.message_type==="video"?e.jsx("video",{src:h.content,controls:!0,preload:"metadata",className:"max-h-80 max-w-full rounded-2xl bg-black"}):e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm ${f?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:da(h.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[ma(h.sent_at),f&&(h.status==="failed"?e.jsx(rt,{className:"h-3 w-3 text-red-500"}):h.status==="sent"?e.jsx(pl,{className:"h-3 w-3 text-sky-500"}):e.jsx(Ke,{className:"h-3 w-3"}))]})]}),f&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:S!=null&&S.avatar_url?e.jsx("img",{src:S.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(Gt,{className:"m-2 h-5 w-5 text-sky-600"})})]},h.message_key)})]})}),p&&e.jsx("div",{className:"border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:p}),e.jsxs("div",{className:"relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>Re(h=>!h),disabled:ae||(S==null?void 0:S.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"闲鱼表情",children:e.jsx(ul,{className:"h-5 w-5"})}),be&&e.jsxs("div",{className:"absolute bottom-11 left-0 z-30 w-[360px] rounded-2xl border border-slate-200 bg-white p-3 shadow-2xl",children:[e.jsx("div",{className:"mb-2 text-xs font-bold text-slate-500",children:"全部表情"}),e.jsx("div",{className:"grid max-h-72 grid-cols-8 gap-1 overflow-y-auto",children:Ma.map(([h,f])=>e.jsx("button",{type:"button",title:`[${h}]`,onClick:()=>{v(R=>R+`[${h}]`),Re(!1)},className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:Pn(f),alt:`[${h}]`,className:"h-8 w-8 object-contain"})},h))})]})]}),e.jsx("input",{ref:V,type:"file",accept:"image/*",className:"hidden",onChange:h=>{var f;return void re((f=h.target.files)==null?void 0:f[0])}}),e.jsx("button",{type:"button",onClick:()=>{var h;return(h=V.current)==null?void 0:h.click()},disabled:ae||(S==null?void 0:S.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 transition hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"发送图片(最大 10MB)",children:e.jsx(hl,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-2 transition focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100",children:[e.jsx("textarea",{value:oe,onChange:h=>v(h.target.value),rows:2,maxLength:2e3,onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),Oe())},disabled:(S==null?void 0:S.runtime_state)!=="online",placeholder:(S==null?void 0:S.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行":"账号离线,暂时无法发送",className:"max-h-32 min-h-12 flex-1 resize-none bg-transparent px-2 py-2 text-sm leading-6 outline-none disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:()=>void Oe(),disabled:!oe.trim()||ae||(S==null?void 0:S.runtime_state)!=="online",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:shadow-none","aria-label":"发送消息",children:ae?e.jsx(Pe,{className:"h-4 w-4 animate-spin"}):e.jsx(Zt,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(is,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-700",children:"选择一个用户开始聊天"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"该账号的新消息会实时出现在左侧列表。"})]})})]})]})},qa="ydisks.sidebar.v1",Tn=()=>{try{return window.localStorage.getItem(qa)==="collapsed"}catch{return!1}},Mn=t=>{try{window.localStorage.setItem(qa,t?"collapsed":"expanded")}catch{}},Fa={"/app/dashboard":"dashboard","/app/accounts":"accounts","/app/chat":"chat","/app/orders":"orders","/app/cards":"cards","/app/items":"items","/app/rules":"rules","/app/notifications":"notifications","/app/settings":"settings"},pa=Object.fromEntries(Object.entries(Fa).map(([t,a])=>[a,t])),ua=()=>Fa[window.location.pathname]||"dashboard",qn=()=>{const[t,a]=r.useState(!1),[l,i]=r.useState(!1),[m,_]=r.useState(ua),[N,I]=r.useState(!0),[g,C]=r.useState(!1),[j,F]=r.useState(""),[G,me]=r.useState(""),[oe,v]=r.useState(!1),[q,ce]=r.useState(""),[Q,ee]=r.useState(""),[B,ge]=r.useState(""),[ue,k]=r.useState(!1),[Z,se]=r.useState(""),[K,ve]=r.useState(),[J,A]=r.useState(Tn),E=T=>{const p=T==="settings"&&!l?"dashboard":T,b=pa[p];b&&b!==window.location.pathname&&window.history.pushState({},"",b),_(p)};r.useEffect(()=>{const T=()=>_(ua());return window.addEventListener("popstate",T),()=>window.removeEventListener("popstate",T)},[]),r.useEffect(()=>{Sa().then(p=>{if((p==null?void 0:p.initialized)===!1){C(!0),a(!1),i(!1);return}C(!1),p!=null&&p.authenticated?(a(!0),i(p.is_admin===!0)):i(!1)}).catch(()=>{a(!1),i(!1)}).finally(()=>I(!1));const T=()=>{a(!1),i(!1)};return window.addEventListener("auth:logout",T),()=>window.removeEventListener("auth:logout",T)},[]),r.useEffect(()=>{!N&&t&&!l&&m==="settings"&&(window.history.replaceState({},"",pa.dashboard),_("dashboard"))},[N,t,l,m]);const P=async T=>{T.preventDefault(),v(!0),ce("");try{const p=await Ol({username:j,password:G});p.success?(a(!0),i(p.is_admin===!0)):ce(p.message||"登录失败")}catch(p){const b=p instanceof Error?p.message:String(p);ce(b||"登录失败")}finally{v(!1)}},be=async T=>{if(T.preventDefault(),se(""),Q.length<8){se("密码至少需要 8 个字符");return}if(Q!==B){se("两次输入的密码不一致");return}k(!0);try{const p=await Il(Q);if(!p.success){se(p.message||"初始化失败,请重试");return}C(!1),a(!0),i(p.is_admin===!0),ee(""),ge("")}catch(p){const b=p instanceof Error?p.message:String(p);se(b||"初始化失败,请重试")}finally{k(!1)}},Re=async()=>{try{await Al()}catch(T){console.error("退出登录失败",T)}finally{a(!1),i(!1)}};if(N)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-surface",children:e.jsx(Pe,{className:"w-8 h-8 text-brand animate-spin"})});if(g)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-panel w-full max-w-xl border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"mx-auto mb-6 flex justify-center",children:e.jsx(ms,{sizeClass:"w-24 h-24"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"首次设置管理员密码"}),e.jsx("p",{className:"text-gray-600 font-medium",children:"设置完成后会自动进入系统,管理员账号为 admin。"})]}),e.jsxs("form",{onSubmit:be,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(Fs,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"设置管理员密码(至少 8 个字符)",value:Q,onChange:T=>ee(T.target.value),autoFocus:!0,className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Mt,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"再次输入密码",value:B,onChange:T=>ge(T.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),Z&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[e.jsx(Mt,{className:"w-4 h-4"})," ",Z]}),e.jsx("button",{type:"submit",disabled:ue,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:ue?e.jsx(Pe,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["设置密码并进入系统 ",e.jsx(xs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Secure Bootstrap"})})]})]});if(!t)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-canvas p-4 relative overflow-hidden font-sans",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-panel w-full max-w-lg border border-white relative z-10 animate-fade-in",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"group mx-auto mb-6 flex cursor-pointer justify-center",children:e.jsx(ms,{sizeClass:"w-24 h-24",logoClassName:"w-full h-full text-white group-hover:scale-110 transition-transform"})}),e.jsx("h2",{className:"text-3xl font-extrabold text-gray-900 mb-2 tracking-tight",children:"欢迎回来"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Ydisks闲鱼助手 · 自动发货与管家系统"})]}),e.jsxs("form",{onSubmit:P,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(xt,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"text",placeholder:"管理员账号",value:j,onChange:T=>F(T.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Fs,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 group-focus-within:text-black transition-colors"}),e.jsx("input",{type:"password",placeholder:"密码",value:G,onChange:T=>me(T.target.value),className:"w-full ios-input pl-14 pr-6 py-4.5 rounded-2xl text-base h-14"})]})]}),q&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-500 text-sm text-center font-bold flex items-center justify-center gap-2",children:[e.jsx(Mt,{className:"w-4 h-4"})," ",q]}),e.jsx("button",{type:"submit",disabled:oe,className:"w-full ios-btn-primary h-14 rounded-2xl text-lg shadow-xl shadow-blue-200 mt-2 flex items-center justify-center gap-2 group disabled:opacity-70",children:oe?e.jsx(Pe,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:["立即登录 ",e.jsx(xs,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-gray-100",children:e.jsx("div",{className:"mt-6 text-center",children:e.jsx("span",{className:"text-xs text-gray-400 font-medium tracking-widest uppercase",children:"Ydisks闲鱼助手 v1.0"})})})]})]});const ae=()=>{switch(m){case"dashboard":return e.jsx(rs,{});case"accounts":return e.jsx(an,{});case"chat":return e.jsx(Dn,{});case"orders":return e.jsx(nn,{});case"cards":return e.jsx(cn,{});case"items":return e.jsx(bn,{onConfigureDelivery:T=>{ve({cookieId:T.cookie_id,itemId:T.item_id,requestId:Date.now()}),E("rules")}});case"rules":return e.jsx(Ln,{initialDeliveryTarget:K,onDeliveryTargetHandled:()=>ve(void 0)});case"notifications":return e.jsx($n,{isAdmin:l});case"settings":return l?e.jsx(jn,{}):e.jsx(rs,{});default:return e.jsx(rs,{})}};return e.jsxs("div",{className:"flex min-h-screen bg-canvas text-ink",children:[e.jsx(vl,{activeTab:m,isAdmin:l,collapsed:J,onToggleCollapsed:()=>A(T=>{const p=!T;return Mn(p),p}),onNavigate:E,onLogout:Re}),e.jsxs("main",{className:`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${J?"ml-16":"ml-64"} ${m==="chat"?"p-4 md:p-6":"p-8 md:p-12"}`,children:[e.jsx("div",{className:"fixed top-0 right-0 w-[800px] h-[800px] bg-gradient-to-bl from-blue-50 to-transparent rounded-full blur-[120px] pointer-events-none -z-10 opacity-60"}),e.jsx("div",{className:`${m==="chat"?"mx-auto max-w-[1680px]":"mx-auto max-w-[1400px] pb-10"}`,children:ae()})]})]})},Ba=document.getElementById("root");if(!Ba)throw new Error("Could not find root element to mount to");const Fn=Ua.createRoot(Ba);Fn.render(e.jsx(ys.StrictMode,{children:e.jsx(qn,{})})); diff --git a/internal/webui/static/index.html b/internal/webui/static/index.html index d685976..ecd8f5a 100644 --- a/internal/webui/static/index.html +++ b/internal/webui/static/index.html @@ -6,12 +6,12 @@ Ydisks闲鱼助手 - 自动发货与管家系统 - + - + - +
diff --git a/internal/xianyu/mtop/account_tasks.go b/internal/xianyu/mtop/account_tasks.go index 42efd66..fc9a590 100644 --- a/internal/xianyu/mtop/account_tasks.go +++ b/internal/xianyu/mtop/account_tasks.go @@ -93,6 +93,9 @@ func (c *ClientImpl) PolishItem(ctx context.Context, cookiesStr, itemID string) if duplicatePolishError(err) { return &AccountTaskResult{Success: true, Message: "商品今天已经擦亮", UpdatedCookies: updated}, nil } + if IsSessionExpiredErr(err) || IsRiskVerificationErr(err) { + return nil, err + } primaryErr := err if strings.TrimSpace(updated) == "" { updated = cookiesStr @@ -141,6 +144,9 @@ func (c *ClientImpl) accountTaskRequest(ctx context.Context, cookiesStr, endpoin if isRiskVerificationRet(decoded.Ret) { return nil, updated, &RiskVerificationError{Ret: decoded.Ret} } + if isSessionExpiredRet(decoded.Ret) { + return nil, updated, sessionExpiredError(api, decoded.Ret) + } if !isTokenExpiredRet(decoded.Ret) { return nil, updated, fmt.Errorf("%s 返回失败: %s", api, firstRet(decoded.Ret)) } diff --git a/internal/xianyu/mtop/account_tasks_test.go b/internal/xianyu/mtop/account_tasks_test.go index 1fe4607..68850a8 100644 --- a/internal/xianyu/mtop/account_tasks_test.go +++ b/internal/xianyu/mtop/account_tasks_test.go @@ -101,3 +101,22 @@ func TestPolishItemFallsBackToAlternateAPI(t *testing.T) { t.Fatalf("calls=%v want=%v", calls, want) } } + +func TestPolishItemSessionExpiredDoesNotCallBackupOrTokenAPI(t *testing.T) { + calls := 0 + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + calls++ + _, _ = w.Write([]byte(`{"ret":["FAIL_SYS_SESSION_EXPIRED::Session过期"],"data":{}}`)) + })) + defer server.Close() + client := &ClientImpl{ + HTTPClient: server.Client(), PolishItemURL: server.URL, PolishItemBackupURL: server.URL, TokenURL: server.URL, + } + _, err := client.PolishItem(context.Background(), "unb=123; _m_h5_tk=token_1", "item-1") + if err == nil || !IsSessionExpiredErr(err) { + t.Fatalf("err=%v want session expired", err) + } + if calls != 1 { + t.Fatalf("session expiry must stop all fallback/retry requests, calls=%d", calls) + } +} diff --git a/internal/xianyu/mtop/client.go b/internal/xianyu/mtop/client.go index f16accf..4498eed 100644 --- a/internal/xianyu/mtop/client.go +++ b/internal/xianyu/mtop/client.go @@ -208,14 +208,48 @@ func isTokenExpiredRet(ret []string) bool { for _, r := range ret { if strings.Contains(r, "FAIL_SYS_TOKEN_EXOIRED") || strings.Contains(r, "FAIL_SYS_TOKEN_EXPIRED") || - strings.Contains(r, "FAIL_SYS_TOKEN_EMPTY") || - strings.Contains(r, "FAIL_SYS_SESSION_EXPIRED") { + strings.Contains(r, "FAIL_SYS_TOKEN_EMPTY") { return true } } return false } +// SessionExpiredError 表示平台已经明确判定整个登录 Session 失效。 +// 它与可通过响应 Set-Cookie 重签的普通 MTOP token 过期不同:调用方必须 +// 立刻停止业务 API 重试,转入账号级 Session 续期流程。 +type SessionExpiredError struct { + API string + Ret []string +} + +func (e *SessionExpiredError) Error() string { + if e == nil { + return "" + } + if e.API == "" { + return fmt.Sprintf("Session 过期: ret=%v", e.Ret) + } + return fmt.Sprintf("%s Session 过期: ret=%v", e.API, e.Ret) +} + +func isSessionExpiredRet(ret []string) bool { + for _, value := range ret { + lower := strings.ToLower(value) + if strings.Contains(lower, "fail_sys_session_expired") || + strings.Contains(lower, "session过期") || + strings.Contains(lower, "session expired") || + strings.Contains(lower, "会话过期") { + return true + } + } + return false +} + +func sessionExpiredError(api string, ret []string) error { + return &SessionExpiredError{API: api, Ret: append([]string(nil), ret...)} +} + // RiskVerificationError 表示闲鱼服务端要求用户验证(滑块/人脸/风控页)。 // 这类错误不能按普通 token 过期快速重试,否则会持续打接口并放大风控。 type RiskVerificationError struct { @@ -269,9 +303,15 @@ func IsSessionExpiredErr(err error) bool { if err == nil { return false } + var sessionErr *SessionExpiredError + if errors.As(err, &sessionErr) { + return true + } msg := strings.ToLower(err.Error()) return strings.Contains(msg, "fail_sys_session_expired") || strings.Contains(msg, "session过期") || + strings.Contains(msg, "session expired") || + strings.Contains(msg, "会话过期") || strings.Contains(msg, "登录凭证已失效") } diff --git a/internal/xianyu/mtop/client_test.go b/internal/xianyu/mtop/client_test.go index 04d5580..d767f59 100644 --- a/internal/xianyu/mtop/client_test.go +++ b/internal/xianyu/mtop/client_test.go @@ -170,7 +170,7 @@ func TestIsTokenExpiredRet(t *testing.T) { }{ {[]string{"FAIL_SYS_TOKEN_EXOIRED::令牌过期"}, true}, {[]string{"FAIL_SYS_TOKEN_EXPIRED::令牌过期"}, true}, - {[]string{"FAIL_SYS_SESSION_EXPIRED::会话过期"}, true}, + {[]string{"FAIL_SYS_SESSION_EXPIRED::会话过期"}, false}, {[]string{"FAIL_SYS_USER_VALIDATE::非法请求TOKEN"}, false}, {[]string{"SUCCESS::调用成功"}, false}, {[]string{"FAIL_BIZ_ORDER_STATUS_ERROR::订单状态错误"}, false}, @@ -184,6 +184,20 @@ func TestIsTokenExpiredRet(t *testing.T) { } } +func TestSessionExpiredRetIsSeparateFromTokenExpiry(t *testing.T) { + ret := []string{"FAIL_SYS_SESSION_EXPIRED::会话过期"} + if !isSessionExpiredRet(ret) { + t.Fatal("session expiry must be recognized") + } + if isTokenExpiredRet(ret) { + t.Fatal("session expiry must not enter token retry path") + } + err := sessionExpiredError("test API", ret) + if !IsSessionExpiredErr(fmt.Errorf("wrapped: %w", err)) { + t.Fatalf("typed wrapped error not recognized: %v", err) + } +} + func TestIsSessionExpiredErr(t *testing.T) { cases := []struct { err error diff --git a/internal/xianyu/mtop/consign.go b/internal/xianyu/mtop/consign.go index 3310bfe..a9bcc01 100644 --- a/internal/xianyu/mtop/consign.go +++ b/internal/xianyu/mtop/consign.go @@ -42,6 +42,9 @@ func (c *ClientImpl) ConsignContext(ctx context.Context, cookiesStr, orderID str if ok { return true, ret, currentCookies, nil } + if isSessionExpiredRet(ret) { + return false, ret, currentCookies, sessionExpiredError("确认发货接口", ret) + } if !isTokenExpiredRet(ret) { return false, ret, currentCookies, nil } diff --git a/internal/xianyu/mtop/item_detail.go b/internal/xianyu/mtop/item_detail.go index 23be89b..c790f89 100644 --- a/internal/xianyu/mtop/item_detail.go +++ b/internal/xianyu/mtop/item_detail.go @@ -67,6 +67,9 @@ func (c *ClientImpl) DetectItemMultiSpec(ctx context.Context, cookies, itemID st if err := json.Unmarshal(raw, &decoded); err != nil { return false, fmt.Errorf("解析商品详情响应失败: %w (body=%s)", err, truncate(string(raw), 300)) } + if isSessionExpiredRet(decoded.Ret) { + return false, sessionExpiredError("商品详情接口", decoded.Ret) + } if !hasMTopSuccess(decoded.Ret) { return false, fmt.Errorf("商品详情接口返回非成功: ret=%v", decoded.Ret) } diff --git a/internal/xianyu/mtop/items.go b/internal/xianyu/mtop/items.go index 566c1bb..f68c0bf 100644 --- a/internal/xianyu/mtop/items.go +++ b/internal/xianyu/mtop/items.go @@ -36,6 +36,9 @@ func (c *ClientImpl) FetchItemsPage(ctx context.Context, cookiesStr string, page if res != nil { return res, nil } + if isSessionExpiredRet(ret) { + return nil, sessionExpiredError("商品列表接口", ret) + } if !isTokenExpiredRet(ret) { return nil, fmt.Errorf("商品列表接口返回非成功: ret=%v", ret) } diff --git a/internal/xianyu/mtop/order_detail.go b/internal/xianyu/mtop/order_detail.go index a898d2a..8e914da 100644 --- a/internal/xianyu/mtop/order_detail.go +++ b/internal/xianyu/mtop/order_detail.go @@ -45,6 +45,9 @@ func (c *ClientImpl) FetchOrderDetail(ctx context.Context, cookiesStr, orderID s result.UpdatedCookies = currentCookies return result, nil } + if isSessionExpiredRet(ret) { + return nil, sessionExpiredError("订单详情接口", ret) + } if !isTokenExpiredRet(ret) { return nil, fmt.Errorf("订单详情接口返回非成功: ret=%v", ret) } diff --git a/internal/xianyu/mtop/sold_orders.go b/internal/xianyu/mtop/sold_orders.go index 1c70989..b27813e 100644 --- a/internal/xianyu/mtop/sold_orders.go +++ b/internal/xianyu/mtop/sold_orders.go @@ -108,6 +108,9 @@ func (c *ClientImpl) FetchSoldOrdersPage(ctx context.Context, cookies string, pa if err := json.Unmarshal(raw, &decoded); err != nil { return nil, fmt.Errorf("解析订单列表响应失败: %w (body=%s)", err, truncate(string(raw), 300)) } + if isSessionExpiredRet(decoded.Ret) { + return nil, sessionExpiredError("订单列表接口", decoded.Ret) + } if !hasMTopSuccess(decoded.Ret) { return nil, fmt.Errorf("订单列表接口返回非成功: ret=%v", decoded.Ret) } diff --git a/internal/xianyu/mtop/token.go b/internal/xianyu/mtop/token.go index 95c6d27..d9ed0a5 100644 --- a/internal/xianyu/mtop/token.go +++ b/internal/xianyu/mtop/token.go @@ -77,6 +77,9 @@ func (c *ClientImpl) RefreshTokenWithCredentialContext(ctx context.Context, cook if isRiskVerificationRet(ret) { return refreshResultFromContext(ctx, currentCookies, currentSnapshot, currentSnapshotComplete, cookieStateChanged), &RiskVerificationError{Ret: ret, VerificationURL: verificationURL} } + if isSessionExpiredRet(ret) { + return refreshResultFromContext(ctx, currentCookies, currentSnapshot, currentSnapshotComplete, cookieStateChanged), sessionExpiredError("token API", ret) + } if !isOfficialTokenRetryRet(ret) { return refreshResultFromContext(ctx, currentCookies, currentSnapshot, currentSnapshotComplete, cookieStateChanged), fmt.Errorf("token API 返回非成功: ret=%v (status=%d)", ret, status) } diff --git a/internal/xianyu/mtop/user_profile.go b/internal/xianyu/mtop/user_profile.go index fec109a..425728b 100644 --- a/internal/xianyu/mtop/user_profile.go +++ b/internal/xianyu/mtop/user_profile.go @@ -30,6 +30,9 @@ func (c *ClientImpl) FetchUserProfile(ctx context.Context, cookiesStr string) (* if res != nil { return res, nil } + if isSessionExpiredRet(ret) { + return nil, sessionExpiredError("账号资料接口", ret) + } if !isTokenExpiredRet(ret) { return nil, fmt.Errorf("账号资料接口返回非成功: ret=%v", ret) }