From d34d209b37f1879b2ef41e46639ac15ea1ad23eb Mon Sep 17 00:00:00 2001 From: Alex-larget <33240357+Alex-larget@users.noreply.github.com> Date: Fri, 20 Mar 2026 14:38:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=BF=87=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E7=AE=A1=E7=90=86=E7=AB=AF=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E8=AF=8D=E6=96=87=E6=A1=A3=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=B4=A2=E5=BC=95=E4=BB=A5=E5=8F=8D=E6=98=A0?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E8=A7=A6=E5=8F=91=E8=AF=8D=E7=BA=A6=E5=AE=9A?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=96=87=E6=A1=A3=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=80=A7=E5=92=8C=E5=87=86=E7=A1=AE=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../evolution/2026-03-20-管理端部署触发词.md | 26 ++ .../evolution/2026-03-20-部署API触发词.md | 18 ++ .../evolution/2026-03-20-部署管理端触发词.md | 24 -- .cursor/agent/安全工程师/evolution/索引.md | 3 +- .../evolution/2026-03-20-手机号登录与公用组件.md | 39 +++ .../agent/小程序开发工程师/evolution/索引.md | 1 + .cursor/agent/开发助理/经验清单.md | 4 +- .cursor/agent/开发助理/项目索引/产品.md | 2 +- .cursor/agent/开发助理/项目索引/团队.md | 3 +- .cursor/agent/开发助理/项目索引/小程序.md | 3 +- .cursor/rules/assistant-xiaofeng.mdc | 2 +- .cursor/rules/soul-project-boundary.mdc | 10 +- .cursor/skills/assistant-doc-sync/SKILL.md | 9 +- .cursor/skills/miniprogram-dev/SKILL.md | 2 + .cursor/skills/new-version-analyze/SKILL.md | 8 +- .cursor/skills/product-manager/SKILL.md | 6 +- .cursor/skills/security-server-ops/SKILL.md | 20 +- miniprogram/app.json | 3 +- .../components/login-modal/login-modal.js | 79 +++++ .../components/login-modal/login-modal.json | 6 + .../components/login-modal/login-modal.wxml | 27 ++ .../components/login-modal/login-modal.wxss | 136 ++++++++ miniprogram/pages/gift-pay/detail.js | 49 +-- miniprogram/pages/gift-pay/detail.wxml | 33 +- miniprogram/pages/my/my.js | 87 +---- miniprogram/pages/my/my.wxml | 35 +-- miniprogram/pages/read/read.js | 70 +---- miniprogram/pages/read/read.wxml | 35 +-- miniprogram/utils/ruleEngine.js | 28 +- soul-admin/dist/assets/index-BHvHUv2T.css | 1 - .../{index-uFsIOb55.js => index-DCoaVA6V.js} | 176 +++++------ soul-admin/dist/assets/index-DGXqHqcA.css | 1 + soul-admin/dist/index.html | 4 +- soul-api/devloy.py | 2 +- soul-api/wechat/info.log | 8 + soul-api/文档索引.md | 10 +- 开发文档/10、项目管理/README.md | 8 + 开发文档/10、项目管理/运营与变更.md | 51 +++ 开发文档/1、需求/2026-03-20-需求.md | 63 ++++ 开发文档/1、需求/archive/README.md | 11 + .../{ => archive}/文章详情-阅读页线框图.md | 0 .../{ => archive}/链接人与事-存客宝同步-需求规划.md | 0 .../1、需求/{ => archive}/链接人与事-实现方案.md | 0 .../{ => archive}/链接人与事-所有同步需求.md | 0 .../{ => archive}/链接人与事-置顶功能-技术分析.md | 0 开发文档/1、需求/以界面定需求.md | 4 +- 开发文档/1、需求/索引.md | 25 ++ 开发文档/1、需求/需求汇总.md | 60 ---- 开发文档/6、后端/README.md | 9 + 开发文档/8、部署/DOCKER部署说明.md | 289 +++-------------- 开发文档/8、部署/README.md | 13 + 开发文档/8、部署/宝塔-Docker首次配置指南.md | 90 +++--- 开发文档/8、部署/宝塔反向代理说明.md | 35 ++- 开发文档/8、部署/部署总览.md | 144 +++++++++ 开发文档/README.md | 102 ++---- 开发文档/config接口优化分析.md | 163 ---------- 开发文档/代付-业务线框图.md | 296 ------------------ 开发文档/代付-简化流程设计.md | 157 ---------- 开发文档/代付-需求分析与待完善.md | 91 ------ 开发文档/代付逻辑-检查与修复记录.md | 63 ---- 开发文档/存客宝对接逻辑图.md | 121 ------- 开发文档/小程序-图标清单-阿里云iconfont.md | 147 --------- 开发文档/小程序变更影响分析-20260318.md | 67 ---- 开发文档/小程序性能分析-20260318.md | 142 --------- 开发文档/废弃接口清单.md | 34 -- 开发文档/性能优化-综合分析.md | 124 -------- 开发文档/提现流程图.md | 112 ------- 开发文档/新版与稳定版-小程序界面差异清单.md | 115 ------- .../新版与稳定版-管理端功能样式差异分析.md | 113 ------- 开发文档/新版管理端迁移到稳定版-需求评估.md | 154 --------- 开发文档/新版迁移-功能差异清单.md | 185 ----------- 开发文档/新版迁移-开发方案与清单.md | 107 ------- 开发文档/新版迁移-管理端功能差异清单.md | 129 -------- 开发文档/新版迁移-需求采纳清单.md | 61 ---- ...试报告-文章阅读与界面预览响应速度-20260318.md | 32 -- 开发文档/稳定版-小程序与API对比.md | 269 ---------------- 开发文档/稳定版-源码质量分析报告.md | 175 ----------- 开发文档/稳定版-管理端与小程序对接分析.md | 123 -------- 开发文档/稳定版适配新界面-调整清单.md | 87 ----- 开发文档/管理端两版界面差异-新需求参考.md | 37 --- 开发文档/管理端迁移分析-基于小程序功能.md | 89 ------ 开发文档/索引.md | 97 ++++++ 开发文档/规则引擎迁移-影响分析.md | 77 ----- 开发文档/迁移完成度与待办清单.md | 127 -------- 84 files changed, 1127 insertions(+), 4241 deletions(-) create mode 100644 .cursor/agent/安全工程师/evolution/2026-03-20-管理端部署触发词.md create mode 100644 .cursor/agent/安全工程师/evolution/2026-03-20-部署API触发词.md delete mode 100644 .cursor/agent/安全工程师/evolution/2026-03-20-部署管理端触发词.md create mode 100644 .cursor/agent/小程序开发工程师/evolution/2026-03-20-手机号登录与公用组件.md create mode 100644 miniprogram/components/login-modal/login-modal.js create mode 100644 miniprogram/components/login-modal/login-modal.json create mode 100644 miniprogram/components/login-modal/login-modal.wxml create mode 100644 miniprogram/components/login-modal/login-modal.wxss delete mode 100644 soul-admin/dist/assets/index-BHvHUv2T.css rename soul-admin/dist/assets/{index-uFsIOb55.js => index-DCoaVA6V.js} (65%) create mode 100644 soul-admin/dist/assets/index-DGXqHqcA.css create mode 100644 开发文档/10、项目管理/README.md create mode 100644 开发文档/1、需求/2026-03-20-需求.md create mode 100644 开发文档/1、需求/archive/README.md rename 开发文档/1、需求/{ => archive}/文章详情-阅读页线框图.md (100%) rename 开发文档/1、需求/{ => archive}/链接人与事-存客宝同步-需求规划.md (100%) rename 开发文档/1、需求/{ => archive}/链接人与事-实现方案.md (100%) rename 开发文档/1、需求/{ => archive}/链接人与事-所有同步需求.md (100%) rename 开发文档/1、需求/{ => archive}/链接人与事-置顶功能-技术分析.md (100%) create mode 100644 开发文档/1、需求/索引.md delete mode 100644 开发文档/1、需求/需求汇总.md create mode 100644 开发文档/6、后端/README.md create mode 100644 开发文档/8、部署/README.md create mode 100644 开发文档/8、部署/部署总览.md delete mode 100644 开发文档/config接口优化分析.md delete mode 100644 开发文档/代付-业务线框图.md delete mode 100644 开发文档/代付-简化流程设计.md delete mode 100644 开发文档/代付-需求分析与待完善.md delete mode 100644 开发文档/代付逻辑-检查与修复记录.md delete mode 100644 开发文档/存客宝对接逻辑图.md delete mode 100644 开发文档/小程序-图标清单-阿里云iconfont.md delete mode 100644 开发文档/小程序变更影响分析-20260318.md delete mode 100644 开发文档/小程序性能分析-20260318.md delete mode 100644 开发文档/废弃接口清单.md delete mode 100644 开发文档/性能优化-综合分析.md delete mode 100644 开发文档/提现流程图.md delete mode 100644 开发文档/新版与稳定版-小程序界面差异清单.md delete mode 100644 开发文档/新版与稳定版-管理端功能样式差异分析.md delete mode 100644 开发文档/新版管理端迁移到稳定版-需求评估.md delete mode 100644 开发文档/新版迁移-功能差异清单.md delete mode 100644 开发文档/新版迁移-开发方案与清单.md delete mode 100644 开发文档/新版迁移-管理端功能差异清单.md delete mode 100644 开发文档/新版迁移-需求采纳清单.md delete mode 100644 开发文档/测试报告-文章阅读与界面预览响应速度-20260318.md delete mode 100644 开发文档/稳定版-小程序与API对比.md delete mode 100644 开发文档/稳定版-源码质量分析报告.md delete mode 100644 开发文档/稳定版-管理端与小程序对接分析.md delete mode 100644 开发文档/稳定版适配新界面-调整清单.md delete mode 100644 开发文档/管理端两版界面差异-新需求参考.md delete mode 100644 开发文档/管理端迁移分析-基于小程序功能.md create mode 100644 开发文档/索引.md delete mode 100644 开发文档/规则引擎迁移-影响分析.md delete mode 100644 开发文档/迁移完成度与待办清单.md diff --git a/.cursor/agent/安全工程师/evolution/2026-03-20-管理端部署触发词.md b/.cursor/agent/安全工程师/evolution/2026-03-20-管理端部署触发词.md new file mode 100644 index 00000000..b8464d04 --- /dev/null +++ b/.cursor/agent/安全工程师/evolution/2026-03-20-管理端部署触发词.md @@ -0,0 +1,26 @@ +# 管理端部署触发词约定 + +**日期**:2026-03-20 + +## 场景 + +用户说「管理端帮我部署到xx环境」时,安全工程师应语义化解析 xx,直接执行对应部署脚本。 + +## 解决方案 + +- **触发词**:管理端帮我部署到xx环境(语义化,理解意图即可) +- **脚本映射**: + - 含「正式」「线上」「生产」→ `cd soul-admin && python master.py`(正式环境,/www/wwwroot/self/soul-admin) + - 含「测试」「dev」→ `cd soul-admin && python deploy.py`(测试环境,/www/wwwroot/self/soul-admin-dev) + +## soul-admin 部署脚本 + +| 脚本 | 环境 | 目标目录 | 构建命令 | +|------|------|----------|----------| +| master.py | 正式 | soul-admin | pnpm build | +| deploy.py | 测试 | soul-admin-dev | pnpm run build:dev | + +## 已升级 Skills + +1. **security-server-ops**:何时使用表、2.2 soul-admin 脚本索引、4.4/4.5 常用操作 +2. **soul-project-boundary**:按场景触发词表新增 diff --git a/.cursor/agent/安全工程师/evolution/2026-03-20-部署API触发词.md b/.cursor/agent/安全工程师/evolution/2026-03-20-部署API触发词.md new file mode 100644 index 00000000..63fb2dc4 --- /dev/null +++ b/.cursor/agent/安全工程师/evolution/2026-03-20-部署API触发词.md @@ -0,0 +1,18 @@ +# 部署 API 触发词约定 + +**日期**:2026-03-20 + +## 场景 + +用户说「帮我部署api到线上」时,安全工程师应直接执行部署脚本,无需再询问或选择。 + +## 解决方案 + +- **触发词**:帮我部署api到线上 +- **动作**:直接执行 `cd soul-api && python master.py` +- **脚本**:`soul-api/master.py`(soul-api 正式环境部署) + +## 已升级 Skills + +1. **security-server-ops**:何时使用表新增该触发词,明确直接执行命令 +2. **soul-project-boundary**:按场景触发词表新增,加载 security-server-ops 后执行 diff --git a/.cursor/agent/安全工程师/evolution/2026-03-20-部署管理端触发词.md b/.cursor/agent/安全工程师/evolution/2026-03-20-部署管理端触发词.md deleted file mode 100644 index 75e7cd1d..00000000 --- a/.cursor/agent/安全工程师/evolution/2026-03-20-部署管理端触发词.md +++ /dev/null @@ -1,24 +0,0 @@ -# 部署管理端触发词约定 - -**日期**:2026-03-20 - -## 场景 - -用户说「帮我部署管理端到线上」时,安全工程师应直接执行部署脚本,无需再询问或选择。 - -## 解决方案 - -- **触发词**:帮我部署管理端到线上 -- **动作**:直接执行 `cd soul-api && python master.py` -- **脚本**:`soul-api/master.py`(soul-api 正式环境部署) - -## 已升级 Skills - -1. **security-server-ops**:何时使用表新增该触发词,明确直接执行命令 -2. **soul-project-boundary**:按场景触发词表新增,加载 security-server-ops 后执行 - -## 说明 - -- `master.py` 部署的是 soul-api(Go 后端),非 soul-admin 前端 -- 若需部署 soul-admin 前端,应使用 `soul-admin/deploy.py` -- 用户明确指定「管理端」对应 master.py,按约定执行 diff --git a/.cursor/agent/安全工程师/evolution/索引.md b/.cursor/agent/安全工程师/evolution/索引.md index 4f6ca005..905caa6a 100644 --- a/.cursor/agent/安全工程师/evolution/索引.md +++ b/.cursor/agent/安全工程师/evolution/索引.md @@ -5,4 +5,5 @@ | 日期 | 摘要 | 文件 | |------|------|------| | 2026-03-20 | 挖矿病毒排查经验转化为 Skills;服务器操作 Skill 创建 | 2026-03-20-挖矿与服务器Skills.md | -| 2026-03-20 | 「帮我部署管理端到线上」→ 执行 soul-api/master.py | 2026-03-20-部署管理端触发词.md | +| 2026-03-20 | 「帮我部署api到线上」→ 执行 soul-api/master.py | 2026-03-20-部署API触发词.md | +| 2026-03-20 | 「管理端帮我部署到xx环境」→ 语义化解析,正式→master.py,测试→deploy.py | 2026-03-20-管理端部署触发词.md | diff --git a/.cursor/agent/小程序开发工程师/evolution/2026-03-20-手机号登录与公用组件.md b/.cursor/agent/小程序开发工程师/evolution/2026-03-20-手机号登录与公用组件.md new file mode 100644 index 00000000..1df4e174 --- /dev/null +++ b/.cursor/agent/小程序开发工程师/evolution/2026-03-20-手机号登录与公用组件.md @@ -0,0 +1,39 @@ +# 手机号一键登录与登录弹窗公用组件 + +> 日期:2026-03-20 | 角色:小程序开发工程师 + +## 问题与场景 + +1. **getPhoneNumber 不弹窗**:点击手机号登录按钮时,无法弹出手机号选择界面,也无法获取手机号 +2. **登录弹窗重复**:read、my、gift-pay/detail 三处各自维护一套登录弹窗,逻辑重复、维护成本高 +3. **登录后手机号未同步**:手机号登录后若响应中 user.phone 为空,本地 userInfo 未更新 + +## 解决方案 + +### 1. getPhoneNumber 必须与隐私协议耦合 + +- **open-type**:`open-type="getPhoneNumber|agreePrivacyAuthorization"`(基础库 2.32.3+) +- **onNeedPrivacyAuthorization**:app.js 中需将使用 getPhoneNumber 的页面加入支持列表,否则会 `resolve({ event: 'disagree' })` 导致获取失败 +- **支持页面**:avatar-nickname、profile-edit、read、my、gift-pay/detail、index、settings +- **隐私弹窗**:当 onNeedPrivacyAuthorization 触发时,页面需有 `showPrivacyModal` + ` + + + 为获取手机号,请先同意《用户隐私保护指引》 + + + 取消 + + + 我已阅读并同意 + 《用户协议》 + + 《隐私政策》 + + + diff --git a/miniprogram/components/login-modal/login-modal.wxss b/miniprogram/components/login-modal/login-modal.wxss new file mode 100644 index 00000000..116bef83 --- /dev/null +++ b/miniprogram/components/login-modal/login-modal.wxss @@ -0,0 +1,136 @@ +/* Soul 创业派对 - 公用登录弹窗 */ +.modal-overlay { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.7); + z-index: 1000; + display: flex; + align-items: center; + justify-content: center; + padding: 48rpx; +} +.modal-content { + width: 100%; + max-width: 600rpx; + background: #1c1c1e; + border-radius: 32rpx; + overflow: hidden; +} +.modal-close { + position: absolute; + top: 24rpx; + right: 24rpx; + z-index: 1; + padding: 16rpx; +} +.login-modal { + padding: 48rpx 32rpx; + text-align: center; +} +.login-icon { + font-size: 80rpx; + display: block; + margin-bottom: 24rpx; +} +.login-title { + font-size: 36rpx; + font-weight: 700; + color: #ffffff; + display: block; + margin-bottom: 16rpx; +} +.login-desc { + font-size: 26rpx; + color: rgba(255, 255, 255, 0.5); + display: block; + margin-bottom: 48rpx; +} +.btn-wechat { + display: flex; + align-items: center; + justify-content: center; + gap: 16rpx; + padding: 28rpx; + background: #07C160; + color: #ffffff; + font-size: 30rpx; + font-weight: 600; + border-radius: 24rpx; + margin-bottom: 20rpx; + border: none; +} +.btn-wechat::after { border: none; } +.btn-wechat-icon { + width: 40rpx; + height: 40rpx; + background: rgba(255, 255, 255, 0.2); + border-radius: 8rpx; + font-size: 24rpx; + display: flex; + align-items: center; + justify-content: center; +} +.btn-wechat-disabled { opacity: 0.6; } +.login-modal-cancel { + margin-top: 24rpx; + padding: 24rpx; + font-size: 28rpx; + color: rgba(255, 255, 255, 0.5); + text-align: center; +} +.privacy-wechat-row { + margin: 24rpx 0; + padding: 24rpx; + background: rgba(0, 206, 209, 0.1); + border-radius: 16rpx; +} +.privacy-wechat-desc { + display: block; + font-size: 26rpx; + color: rgba(255, 255, 255, 0.8); + margin-bottom: 16rpx; +} +.privacy-agree-btn { + width: 100%; + padding: 20rpx; + background: #07C160; + color: #fff; + font-size: 28rpx; + border-radius: 16rpx; + border: none; +} +.privacy-agree-btn::after { border: none; } +.login-agree-row { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: center; + margin-top: 32rpx; + font-size: 22rpx; + color: rgba(255, 255, 255, 0.5); +} +.agree-checkbox { + width: 32rpx; + height: 32rpx; + border: 2rpx solid rgba(255, 255, 255, 0.5); + border-radius: 6rpx; + margin-right: 12rpx; + display: flex; + align-items: center; + justify-content: center; + font-size: 22rpx; + flex-shrink: 0; +} +.agree-checked { + background: #00CED1; + border-color: #00CED1; +} +.agree-text { color: rgba(255, 255, 255, 0.6); } +.agree-link { + color: #00CED1; + text-decoration: underline; + padding: 0 4rpx; +} diff --git a/miniprogram/pages/gift-pay/detail.js b/miniprogram/pages/gift-pay/detail.js index de734ce5..fde113c3 100644 --- a/miniprogram/pages/gift-pay/detail.js +++ b/miniprogram/pages/gift-pay/detail.js @@ -18,7 +18,6 @@ Page({ amountDisplay: '0.00', isSinglePageMode: false, showLoginModal: false, - agreeProtocol: false, showPrivacyModal: false, // 创建态 isCreateMode: false, @@ -227,7 +226,7 @@ Page({ } const userId = app.globalData.userInfo?.id if (!userId) { - this.setData({ showLoginModal: true, agreeProtocol: false }) + this.setData({ showLoginModal: true }) return } await this._doRedeem() @@ -265,51 +264,15 @@ Page({ } }, - closeLoginModal() { + onLoginModalClose() { this.setData({ showLoginModal: false, showPrivacyModal: false }) }, - toggleAgree() { - this.setData({ agreeProtocol: !this.data.agreeProtocol }) - }, - async handleWechatLogin() { - if (!this.data.agreeProtocol) { - wx.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' }) - return - } - try { - const result = await app.login() - if (!result) return - this.setData({ showLoginModal: false, agreeProtocol: false }) - await this._doRedeem() - } catch (e) { - wx.showToast({ title: '登录失败', icon: 'none' }) - } - }, - handleAgreePrivacyForPhone() { - if (app._privacyResolve) { - app._privacyResolve({ buttonId: 'agree-privacy-btn', event: 'agree' }) - app._privacyResolve = null - } + onLoginModalPrivacyAgree() { this.setData({ showPrivacyModal: false }) }, - async handlePhoneLogin(e) { - if (!e.detail.code) return this.handleWechatLogin() - try { - const result = await app.loginWithPhone(e.detail.code) - if (!result) return - this.setData({ showLoginModal: false }) - await this._doRedeem() - } catch (e) { - wx.showToast({ title: '登录失败', icon: 'none' }) - } - }, - - stopPropagation() {}, - openUserProtocol() { - wx.navigateTo({ url: '/pages/agreement/agreement' }) - }, - openPrivacy() { - wx.navigateTo({ url: '/pages/privacy/privacy' }) + async onLoginModalSuccess() { + this.setData({ showLoginModal: false }) + await this._doRedeem() }, goBack() { diff --git a/miniprogram/pages/gift-pay/detail.wxml b/miniprogram/pages/gift-pay/detail.wxml index 1d960245..2fde1afb 100644 --- a/miniprogram/pages/gift-pay/detail.wxml +++ b/miniprogram/pages/gift-pay/detail.wxml @@ -145,30 +145,15 @@ - - - - - - - - - - 为获取手机号,请先同意《用户隐私保护指引》 - - - - - + + diff --git a/miniprogram/pages/my/my.js b/miniprogram/pages/my/my.js index 1f2562b7..973c1e59 100644 --- a/miniprogram/pages/my/my.js +++ b/miniprogram/pages/my/my.js @@ -60,9 +60,6 @@ Page({ // 登录弹窗 showLoginModal: false, - isLoggingIn: false, - // 用户须主动勾选同意协议(审核要求:不得默认同意) - agreeProtocol: false, showPrivacyModal: false, // 修改昵称弹窗 @@ -691,93 +688,23 @@ Page({ console.warn('[My] 检测单页模式失败,回退为正常登录弹窗:', e) } try { - this.setData({ showLoginModal: true, agreeProtocol: false }) + this.setData({ showLoginModal: true }) } catch (e) { console.error('[My] showLogin error:', e) this.setData({ showLoginModal: true }) } }, - // 切换协议勾选(用户主动勾选,非默认同意) - toggleAgree() { - this.setData({ agreeProtocol: !this.data.agreeProtocol }) - }, - - // 打开用户协议页(审核要求:点击《用户协议》需有响应) - openUserProtocol() { - wx.navigateTo({ url: '/pages/agreement/agreement' }) - }, - - // 打开隐私政策页(审核要求:点击《隐私政策》需有响应) - openPrivacy() { - wx.navigateTo({ url: '/pages/privacy/privacy' }) - }, - - // 关闭登录弹窗 - closeLoginModal() { - if (this.data.isLoggingIn) return + onLoginModalClose() { this.setData({ showLoginModal: false, showPrivacyModal: false }) }, - - // 微信登录(须已勾选同意协议,且做好错误处理避免审核报错) - async handleWechatLogin() { - if (!this.data.agreeProtocol) { - wx.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' }) - return - } - this.setData({ isLoggingIn: true }) - try { - const result = await app.login() - if (result) { - this.initUserStatus() - this.setData({ showLoginModal: false, agreeProtocol: false }) - wx.showToast({ title: '登录成功', icon: 'success' }) - } else { - wx.showToast({ title: '登录失败,请重试', icon: 'none' }) - } - } catch (e) { - console.error('[My] 微信登录错误:', e) - wx.showToast({ title: '登录失败,请重试', icon: 'none' }) - } finally { - this.setData({ isLoggingIn: false }) - } - }, - - // 微信隐私协议同意(getPhoneNumber 需先同意) - handleAgreePrivacyForPhone() { - if (app._privacyResolve) { - app._privacyResolve({ buttonId: 'agree-privacy-btn', event: 'agree' }) - app._privacyResolve = null - } + onLoginModalPrivacyAgree() { this.setData({ showPrivacyModal: false }) }, - - // 手机号登录(需要用户授权) - async handlePhoneLogin(e) { - // 检查是否有授权code - if (!e.detail.code) { - // 用户拒绝授权或获取失败,尝试使用微信登录 - console.log('手机号授权失败,尝试微信登录') - return this.handleWechatLogin() - } - - this.setData({ isLoggingIn: true }) - - try { - const result = await app.loginWithPhone(e.detail.code) - if (result) { - this.initUserStatus() - this.setData({ showLoginModal: false }) - wx.showToast({ title: '登录成功', icon: 'success' }) - } else { - wx.showToast({ title: '登录失败,请重试', icon: 'none' }) - } - } catch (e) { - console.error('手机号登录错误:', e) - wx.showToast({ title: '登录失败,请重试', icon: 'none' }) - } finally { - this.setData({ isLoggingIn: false }) - } + onLoginModalSuccess() { + this.initUserStatus() + this.setData({ showLoginModal: false }) + wx.showToast({ title: '登录成功', icon: 'success' }) }, // 点击菜单 diff --git a/miniprogram/pages/my/my.wxml b/miniprogram/pages/my/my.wxml index b0ab7270..440771a7 100644 --- a/miniprogram/pages/my/my.wxml +++ b/miniprogram/pages/my/my.wxml @@ -171,31 +171,16 @@ - - - - + + diff --git a/miniprogram/pages/read/read.js b/miniprogram/pages/read/read.js index f39218a5..c3590bfc 100644 --- a/miniprogram/pages/read/read.js +++ b/miniprogram/pages/read/read.js @@ -74,7 +74,6 @@ Page({ giftPaid: false, giftRequestSn: '', showLoginModal: false, - agreeProtocol: false, showPrivacyModal: false, showPosterModal: false, isPaying: false, @@ -975,78 +974,23 @@ Page({ console.warn('[Read] 检测单页模式失败,回退为正常登录流程:', e) } try { - this.setData({ showLoginModal: true, agreeProtocol: false }) + this.setData({ showLoginModal: true }) } catch (e) { console.error('[Read] showLoginModal error:', e) this.setData({ showLoginModal: true }) } }, - closeLoginModal() { + onLoginModalClose() { this.setData({ showLoginModal: false, showPrivacyModal: false }) }, - - toggleAgree() { - this.setData({ agreeProtocol: !this.data.agreeProtocol }) - }, - - openUserProtocol() { - wx.navigateTo({ url: '/pages/agreement/agreement' }) - }, - - openPrivacy() { - wx.navigateTo({ url: '/pages/privacy/privacy' }) - }, - - // 从服务端刷新购买状态,避免登录后误用旧数据导致误解锁 - // 【重构】微信登录(须先勾选同意协议,符合审核要求) - async handleWechatLogin() { - if (!this.data.agreeProtocol) { - wx.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' }) - return - } - try { - const result = await app.login() - if (!result) return - - this.setData({ showLoginModal: false, agreeProtocol: false }) - await this.onLoginSuccess() - wx.showToast({ title: '登录成功', icon: 'success' }) - - } catch (e) { - console.error('[Read] 登录失败:', e) - wx.showToast({ title: '登录失败,请重试', icon: 'none' }) - } - }, - - // 微信隐私协议同意(getPhoneNumber 需先同意) - handleAgreePrivacyForPhone() { - const app = getApp() - if (app._privacyResolve) { - app._privacyResolve({ buttonId: 'agree-privacy-btn', event: 'agree' }) - app._privacyResolve = null - } + onLoginModalPrivacyAgree() { this.setData({ showPrivacyModal: false }) }, - - // 【重构】手机号登录(标准流程) - async handlePhoneLogin(e) { - if (!e.detail.code) { - return this.handleWechatLogin() - } - - try { - const result = await app.loginWithPhone(e.detail.code) - if (!result) return - - this.setData({ showLoginModal: false }) - await this.onLoginSuccess() - wx.showToast({ title: '登录成功', icon: 'success' }) - - } catch (e) { - console.error('[Read] 手机号登录失败:', e) - wx.showToast({ title: '登录失败', icon: 'none' }) - } + async onLoginModalSuccess() { + this.setData({ showLoginModal: false }) + await this.onLoginSuccess() + wx.showToast({ title: '登录成功', icon: 'success' }) }, // 【新增】登录成功后的标准处理流程 diff --git a/miniprogram/pages/read/read.wxml b/miniprogram/pages/read/read.wxml index 84c5d432..0afcd585 100644 --- a/miniprogram/pages/read/read.wxml +++ b/miniprogram/pages/read/read.wxml @@ -333,32 +333,15 @@ - - - - + + diff --git a/miniprogram/utils/ruleEngine.js b/miniprogram/utils/ruleEngine.js index 002cc66d..89c3be58 100644 --- a/miniprogram/utils/ruleEngine.js +++ b/miniprogram/utils/ruleEngine.js @@ -16,7 +16,14 @@ * 浏览导师页 → browse_mentor */ -const app = getApp() +function getAppInstance() { + try { + const a = getApp() + return a && a.globalData ? a : null + } catch (e) { + return null + } +} const RULE_COOLDOWN_KEY = 'rule_engine_cooldown' const COOLDOWN_MS = 60 * 1000 @@ -60,11 +67,14 @@ function setCooldown(ruleId) { } function getUserInfo() { - return app.globalData.userInfo || {} + const app = getAppInstance() + return app ? (app.globalData.userInfo || {}) : {} } async function loadRules() { if (_cachedRules && Date.now() - _cacheTs < CACHE_TTL) return _cachedRules + const app = getAppInstance() + if (!app) return _cachedRules || [] try { const res = await app.request({ url: '/api/miniprogram/user-rules', method: 'GET', silent: true }) if (res && res.success && res.rules) { @@ -90,7 +100,8 @@ function getRuleInfo(rules, triggerName) { // VIP 用户不触发:统一由 checkVipContactRequiredAndGuide 引导到 profile-edit,避免与主流程冲突 function checkRule_FillAvatar(rules) { if (!isRuleEnabled(rules, '注册')) return null - if (app.globalData.isVip) return null + const app = getAppInstance() + if (app && app.globalData.isVip) return null const user = getUserInfo() if (!user.id) return null const avatar = user.avatar || user.avatarUrl || '' @@ -147,7 +158,8 @@ function checkRule_ShareAfter5Chapters(rules) { if (!isRuleEnabled(rules, '累计浏览5章节')) return null const user = getUserInfo() if (!user.id) return null - const readCount = (typeof app.getReadCount === 'function' ? app.getReadCount() : (app.globalData.readCount || 0)) + const app = getAppInstance() + const readCount = app ? (typeof app.getReadCount === 'function' ? app.getReadCount() : (app.globalData.readCount || 0)) : 0 if (readCount < 5) return null if (isInCooldown('share_after_5')) return null setCooldown('share_after_5') @@ -166,7 +178,8 @@ function checkRule_FillVipInfo(rules) { if (!isRuleEnabled(rules, '完成付款')) return null const user = getUserInfo() if (!user.id) return null - if (!(app.globalData.hasFullBook || app.globalData.hasPurchasedFull)) return null + const app = getAppInstance() + if (!app || !(app.globalData.hasFullBook || app.globalData.hasPurchasedFull)) return null if (user.wechatId && user.address) return null if (isInCooldown('fill_vip_info')) return null setCooldown('fill_vip_info') @@ -218,7 +231,8 @@ function checkRule_Withdraw(rules) { if (!isRuleEnabled(rules, '收益满50元')) return null const user = getUserInfo() if (!user.id) return null - const earnings = app.globalData.totalEarnings || 0 + const app = getAppInstance() + const earnings = app ? (app.globalData.totalEarnings || 0) : 0 if (earnings < 50) return null if (isInCooldown('withdraw_50')) return null setCooldown('withdraw_50') @@ -280,6 +294,8 @@ function executeRule(rule, pageInstance) { function _trackRuleAction(ruleId, action) { const userId = getUserInfo().id if (!userId) return + const app = getAppInstance() + if (!app) return app.request({ url: '/api/miniprogram/track', method: 'POST', diff --git a/soul-admin/dist/assets/index-BHvHUv2T.css b/soul-admin/dist/assets/index-BHvHUv2T.css deleted file mode 100644 index f7f37b46..00000000 --- a/soul-admin/dist/assets/index-BHvHUv2T.css +++ /dev/null @@ -1 +0,0 @@ -.rich-editor-wrapper{border:1px solid #374151;border-radius:.5rem;background:#0a1628;overflow:hidden}.rich-editor-toolbar{display:flex;align-items:center;gap:2px;padding:6px 8px;border-bottom:1px solid #374151;background:#0f1d32;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:1px}.toolbar-divider{width:1px;height:20px;background:#374151;margin:0 4px}.rich-editor-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer;transition:all .15s}.rich-editor-toolbar button:hover{background:#1f2937;color:#d1d5db}.rich-editor-toolbar button.is-active{background:#38bdac33;color:#38bdac}.rich-editor-toolbar button:disabled{opacity:.3;cursor:not-allowed}.link-tag-select{background:#0a1628;border:1px solid #374151;color:#d1d5db;font-size:12px;padding:2px 6px;border-radius:4px;cursor:pointer;max-width:160px}.link-input-bar{display:flex;align-items:center;gap:4px;padding:4px 8px;border-bottom:1px solid #374151;background:#0f1d32}.link-input{flex:1;background:#0a1628;border:1px solid #374151;color:#fff;padding:4px 8px;border-radius:4px;font-size:13px}.link-confirm,.link-remove{padding:4px 10px;border-radius:4px;border:none;font-size:12px;cursor:pointer}.link-confirm{background:#38bdac;color:#fff}.link-remove{background:#374151;color:#9ca3af}.rich-editor-content{min-height:450px;max-height:720px;overflow-y:auto;padding:12px 16px;color:#e5e7eb;font-size:14px;line-height:1.7}.rich-editor-content:focus{outline:none}.rich-editor-content h1{font-size:1.5em;font-weight:700;margin:.8em 0 .4em;color:#fff}.rich-editor-content h2{font-size:1.3em;font-weight:600;margin:.7em 0 .3em;color:#fff}.rich-editor-content h3{font-size:1.15em;font-weight:600;margin:.6em 0 .3em;color:#fff}.rich-editor-content p{margin:.4em 0}.rich-editor-content strong{color:#fff}.rich-editor-content code{background:#1f2937;padding:2px 6px;border-radius:3px;font-size:.9em;color:#38bdac}.rich-editor-content pre{background:#1f2937;padding:12px;border-radius:6px;overflow-x:auto;margin:.6em 0}.rich-editor-content blockquote{border-left:3px solid #38bdac;padding-left:12px;margin:.6em 0;color:#9ca3af}.rich-editor-content ul,.rich-editor-content ol{padding-left:1.5em;margin:.4em 0}.rich-editor-content li{margin:.2em 0}.rich-editor-content hr{border:none;border-top:1px solid #374151;margin:1em 0}.rich-editor-content img{max-width:100%;border-radius:6px;margin:.5em 0}.rich-editor-content a,.rich-link{color:#38bdac;text-decoration:underline;cursor:pointer}.rich-editor-content table{border-collapse:collapse;width:100%;margin:.5em 0}.rich-editor-content th,.rich-editor-content td{border:1px solid #374151;padding:6px 10px;text-align:left}.rich-editor-content th{background:#1f2937;font-weight:600}.rich-editor-content .ProseMirror-placeholder:before{content:attr(data-placeholder);color:#6b7280;float:left;height:0;pointer-events:none}.mention-tag{background:#38bdac26;color:#38bdac;border-radius:4px;padding:1px 4px;font-weight:500}.link-tag-node{background:#ffd7001f;color:gold;border-radius:4px;padding:1px 4px;font-weight:500;cursor:default;-webkit-user-select:all;user-select:all}.mention-popup{position:fixed;z-index:9999;background:#1a2638;border:1px solid #374151;border-radius:8px;padding:4px;min-width:180px;max-height:240px;overflow-y:auto;box-shadow:0 4px 20px #0006}.mention-item{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-radius:4px;cursor:pointer;color:#d1d5db;font-size:13px}.mention-item:hover,.mention-item.is-selected{background:#38bdac26;color:#38bdac}.mention-name{font-weight:500}.mention-id{font-size:11px;color:#6b7280}.bubble-menu{display:flex;gap:2px;background:#1a2638;border:1px solid #374151;border-radius:6px;padding:4px;box-shadow:0 4px 12px #0000004d}.bubble-menu button{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer}.bubble-menu button:hover{background:#1f2937;color:#d1d5db}.bubble-menu button.is-active{color:#38bdac}/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-pan-x:initial;--tw-pan-y:initial;--tw-pinch-zoom:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-100:oklch(93.6% .032 17.717);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-rose-400:oklch(71.2% .194 13.428);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--blur-xl:24px;--blur-3xl:64px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}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;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.not-sr-only{clip-path:none;white-space:normal;width:auto;height:auto;margin:0;padding:0;position:static;overflow:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.-top-2\.5{top:calc(var(--spacing)*-2.5)}.top-0{top:calc(var(--spacing)*0)}.top-1\/2{top:50%}.top-1\/4{top:25%}.top-4{top:calc(var(--spacing)*4)}.top-16{top:calc(var(--spacing)*16)}.top-\[50\%\]{top:50%}.top-full{top:100%}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\/4{right:25%}.right-4{right:calc(var(--spacing)*4)}.bottom-1\/4{bottom:25%}.-left-2\.5{left:calc(var(--spacing)*-2.5)}.left-0{left:calc(var(--spacing)*0)}.left-1\/4{left:25%}.left-2{left:calc(var(--spacing)*2)}.left-3{left:calc(var(--spacing)*3)}.left-\[50\%\]{left:50%}.isolate{isolation:isolate}.isolation-auto{isolation:auto}.z-10{z-index:10}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-mx-2{margin-inline:calc(var(--spacing)*-2)}.-mx-8{margin-inline:calc(var(--spacing)*-8)}.mx-20{margin-inline:calc(var(--spacing)*20)}.mx-auto{margin-inline:auto}.-mt-6{margin-top:calc(var(--spacing)*-6)}.mt-0{margin-top:calc(var(--spacing)*0)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-auto{margin-right:auto}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.flow-root{display:flow-root}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline\!{display:inline!important}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.inline-table{display:inline-table}.list-item{display:list-item}.table{display:table}.table\!{display:table!important}.table-caption{display:table-caption}.table-cell{display:table-cell}.table-column{display:table-column}.table-column-group{display:table-column-group}.table-footer-group{display:table-footer-group}.table-header-group{display:table-header-group}.table-row{display:table-row}.table-row-group{display:table-row-group}.size-4{width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.size-8{width:calc(var(--spacing)*8);height:calc(var(--spacing)*8)}.size-9{width:calc(var(--spacing)*9);height:calc(var(--spacing)*9)}.size-10{width:calc(var(--spacing)*10);height:calc(var(--spacing)*10)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-96{height:calc(var(--spacing)*96)}.h-\[75vh\]{height:75vh}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[450px\]{max-height:450px}.max-h-none{max-height:none}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-8{min-height:calc(var(--spacing)*8)}.min-h-\[32px\]{min-height:32px}.min-h-\[40px\]{min-height:40px}.min-h-\[60vh\]{min-height:60vh}.min-h-\[72px\]{min-height:72px}.min-h-\[80px\]{min-height:80px}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[260px\]{min-height:260px}.min-h-\[400px\]{min-height:400px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing)*.5)}.w-2{width:calc(var(--spacing)*2)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-28{width:calc(var(--spacing)*28)}.w-32{width:calc(var(--spacing)*32)}.w-40{width:calc(var(--spacing)*40)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-96{width:calc(var(--spacing)*96)}.w-\[280px\]{width:280px}.w-fit{width:fit-content}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-\[72px\]{max-width:72px}.max-w-\[96px\]{max-width:96px}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[140px\]{max-width:140px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[420px\]{max-width:420px}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[60px\]{min-width:60px}.min-w-\[120px\]{min-width:120px}.min-w-\[200px\]{min-width:200px}.min-w-\[1024px\]{min-width:1024px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-3d{scale:var(--tw-scale-x)var(--tw-scale-y)var(--tw-scale-z)}.scale-\[0\.98\]{scale:.98}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.touch-none{touch-action:none}.resize{resize:both}.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-\[40px_40px_1fr_80px_80px_80px_60px\]{grid-template-columns:40px 40px 1fr 80px 80px 80px 60px}.grid-cols-\[60px_1fr_100px_100px_80px_120px\]{grid-template-columns:60px 1fr 100px 100px 80px 120px}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-reverse>:not(:last-child)){--tw-space-y-reverse:1}.gap-x-8{column-gap:calc(var(--spacing)*8)}:where(.space-x-reverse>:not(:last-child)){--tw-space-x-reverse:1}.gap-y-4{row-gap:calc(var(--spacing)*4)}:where(.divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px*var(--tw-divide-x-reverse));border-inline-end-width:calc(1px*calc(1 - var(--tw-divide-x-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-y-reverse>:not(:last-child)){--tw-divide-y-reverse:1}:where(.divide-gray-700\/50>:not(:last-child)){border-color:#36415380}@supports (color:color-mix(in lab,red,red)){:where(.divide-gray-700\/50>:not(:last-child)){border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}:where(.divide-white\/5>:not(:last-child)){border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){:where(.divide-white\/5>:not(:last-child)){border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[\#07C160\]{border-color:#07c160}.border-\[\#07C160\]\/20{border-color:#07c16033}.border-\[\#07C160\]\/30{border-color:#07c1604d}.border-\[\#38bdac\]{border-color:#38bdac}.border-\[\#38bdac\]\/20{border-color:#38bdac33}.border-\[\#38bdac\]\/30{border-color:#38bdac4d}.border-\[\#38bdac\]\/40{border-color:#38bdac66}.border-\[\#38bdac\]\/50{border-color:#38bdac80}.border-amber-400\/60{border-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.border-amber-400\/60{border-color:color-mix(in oklab,var(--color-amber-400)60%,transparent)}}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500)40%,transparent)}}.border-amber-500\/50{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/50{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-cyan-500\/30{border-color:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/30{border-color:color-mix(in oklab,var(--color-cyan-500)30%,transparent)}}.border-cyan-500\/40{border-color:#00b7d766}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/40{border-color:color-mix(in oklab,var(--color-cyan-500)40%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-700\/30{border-color:#3641534d}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/30{border-color:color-mix(in oklab,var(--color-gray-700)30%,transparent)}}.border-gray-700\/40{border-color:#36415366}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/40{border-color:color-mix(in oklab,var(--color-gray-700)40%,transparent)}}.border-gray-700\/50{border-color:#36415380}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/50{border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.border-gray-700\/60{border-color:#36415399}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/60{border-color:color-mix(in oklab,var(--color-gray-700)60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-inherit{border-color:inherit}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-orange-500\/50{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/50{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-purple-500\/40{border-color:#ac4bff66}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/40{border-color:color-mix(in oklab,var(--color-purple-500)40%,transparent)}}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-600\/50{border-color:#e4001480}@supports (color:color-mix(in lab,red,red)){.border-red-600\/50{border-color:color-mix(in oklab,var(--color-red-600)50%,transparent)}}.border-transparent{border-color:#0000}.border-white\/5{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/5{border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/40{border-color:#edb20066}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/40{border-color:color-mix(in oklab,var(--color-yellow-500)40%,transparent)}}.bg-\[\#0a1628\]{background-color:#0a1628}.bg-\[\#0a1628\]\/50{background-color:#0a162880}.bg-\[\#0a1628\]\/60{background-color:#0a162899}.bg-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#07C160\]{background-color:#07c160}.bg-\[\#07C160\]\/5{background-color:#07c1600d}.bg-\[\#07C160\]\/10{background-color:#07c1601a}.bg-\[\#38bdac\]{background-color:#38bdac}.bg-\[\#38bdac\]\/5{background-color:#38bdac0d}.bg-\[\#38bdac\]\/10{background-color:#38bdac1a}.bg-\[\#38bdac\]\/15{background-color:#38bdac26}.bg-\[\#38bdac\]\/20{background-color:#38bdac33}.bg-\[\#38bdac\]\/30{background-color:#38bdac4d}.bg-\[\#38bdac\]\/60{background-color:#38bdac99}.bg-\[\#38bdac\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#162840\]{background-color:#162840}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/10{background-color:#6a72821a}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/10{background-color:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-600\/20{background-color:#4a556533}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/20{background-color:color-mix(in oklab,var(--color-gray-600)20%,transparent)}}.bg-gray-600\/50{background-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/50{background-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.bg-gray-700{background-color:var(--color-gray-700)}.bg-gray-700\/50{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.bg-gray-700\/50{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab,red,red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/80{background-color:#82181acc}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/80{background-color:color-mix(in oklab,var(--color-red-900)80%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/5{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-\[\#0f2137\]{--tw-gradient-from:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#00CED1\]{--tw-gradient-from:#00ced1;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#38bdac\]\/10{--tw-gradient-from:oklab(72.378% -.11483 -.0053193/.1);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/20{--tw-gradient-from:#3080ff33}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.from-blue-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-cyan-500\/20{--tw-gradient-from:#00b7d733}@supports (color:color-mix(in lab,red,red)){.from-cyan-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.from-cyan-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-green-500\/20{--tw-gradient-from:#00c75833}@supports (color:color-mix(in lab,red,red)){.from-green-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.from-green-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/20{--tw-gradient-from:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.from-purple-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/20{--tw-gradient-from:#edb20033}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.from-yellow-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-\[\#38bdac\]\/30{--tw-gradient-via:oklab(72.378% -.11483 -.0053193/.3);--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-\[\#0f2137\]{--tw-gradient-to:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#20B2AA\]{--tw-gradient-to:#20b2aa;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#162d4a\]{--tw-gradient-to:#162d4a;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-amber-500\/20{--tw-gradient-to:#f99c0033}@supports (color:color-mix(in lab,red,red)){.to-amber-500\/20{--tw-gradient-to:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.to-amber-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-cyan-500\/5{--tw-gradient-to:#00b7d70d}@supports (color:color-mix(in lab,red,red)){.to-cyan-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-cyan-500)5%,transparent)}}.to-cyan-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-green-500\/5{--tw-gradient-to:#00c7580d}@supports (color:color-mix(in lab,red,red)){.to-green-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-green-500)5%,transparent)}}.to-green-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-purple-500\/5{--tw-gradient-to:#ac4bff0d}@supports (color:color-mix(in lab,red,red)){.to-purple-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-purple-500)5%,transparent)}}.to-purple-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-yellow-500\/5{--tw-gradient-to:#edb2000d}@supports (color:color-mix(in lab,red,red)){.to-yellow-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.to-yellow-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-repeat{background-repeat:repeat}.mask-no-clip{-webkit-mask-clip:no-clip;mask-clip:no-clip}.mask-repeat{-webkit-mask-repeat:repeat;mask-repeat:repeat}.fill-amber-400{fill:var(--color-amber-400)}.fill-current{fill:currentColor}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.px-0{padding-inline:calc(var(--spacing)*0)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-5{padding-block:calc(var(--spacing)*5)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-10{padding-block:calc(var(--spacing)*10)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-5{padding-top:calc(var(--spacing)*5)}.pt-6{padding-top:calc(var(--spacing)*6)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-4{padding-right:calc(var(--spacing)*4)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-6{--tw-leading:calc(var(--spacing)*6);line-height:calc(var(--spacing)*6)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-wrap{text-wrap:wrap}.wrap-break-word{overflow-wrap:break-word}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#00CED1\]{color:#00ced1}.text-\[\#07C160\]{color:#07c160}.text-\[\#07C160\]\/60{color:#07c16099}.text-\[\#07C160\]\/70{color:#07c160b3}.text-\[\#07C160\]\/80{color:#07c160cc}.text-\[\#26A17B\]{color:#26a17b}.text-\[\#38bdac\]{color:#38bdac}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/30{color:#fcbb004d}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/30{color:color-mix(in oklab,var(--color-amber-400)30%,transparent)}}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400)80%,transparent)}}.text-amber-400\/90{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/90{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.text-black{color:var(--color-black)}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/60{color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/60{color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-400\/60{color:#54a2ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-400\/60{color:color-mix(in oklab,var(--color-blue-400)60%,transparent)}}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-200{color:var(--color-gray-200)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/90{color:#05df72e6}@supports (color:color-mix(in lab,red,red)){.text-green-400\/90{color:color-mix(in oklab,var(--color-green-400)90%,transparent)}}.text-green-500{color:var(--color-green-500)}.text-orange-300{color:var(--color-orange-300)}.text-orange-300\/60{color:#ffb96d99}@supports (color:color-mix(in lab,red,red)){.text-orange-300\/60{color:color-mix(in oklab,var(--color-orange-300)60%,transparent)}}.text-orange-400{color:var(--color-orange-400)}.text-orange-400\/60{color:#ff8b1a99}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/60{color:color-mix(in oklab,var(--color-orange-400)60%,transparent)}}.text-orange-400\/70{color:#ff8b1ab3}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/70{color:color-mix(in oklab,var(--color-orange-400)70%,transparent)}}.text-orange-400\/80{color:#ff8b1acc}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/80{color:color-mix(in oklab,var(--color-orange-400)80%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-red-100{color:var(--color-red-100)}.text-red-300{color:var(--color-red-300)}.text-red-400{color:var(--color-red-400)}.text-rose-400{color:var(--color-rose-400)}.text-sky-300{color:var(--color-sky-300)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-400\/60{color:#fac80099}@supports (color:color-mix(in lab,red,red)){.text-yellow-400\/60{color:color-mix(in oklab,var(--color-yellow-400)60%,transparent)}}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.capitalize{text-transform:capitalize}.lowercase{text-transform:lowercase}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.italic\!{font-style:italic!important}.not-italic{font-style:normal}.diagonal-fractions{--tw-numeric-fraction:diagonal-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.lining-nums{--tw-numeric-figure:lining-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.oldstyle-nums{--tw-numeric-figure:oldstyle-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.proportional-nums{--tw-numeric-spacing:proportional-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.slashed-zero{--tw-slashed-zero:slashed-zero;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.stacked-fractions{--tw-numeric-fraction:stacked-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.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,)}.normal-nums{font-variant-numeric:normal}.line-through{text-decoration-line:line-through}.no-underline{text-decoration-line:none}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.underline\!{text-decoration-line:underline!important}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.subpixel-antialiased{-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto}.accent-\[\#38bdac\]{accent-color:#38bdac}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-55{opacity:.55}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.inset-ring{--tw-inset-ring-shadow:inset 0 0 0 1px var(--tw-inset-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[\#38bdac\]\/20{--tw-shadow-color:#38bdac33}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/20{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.2) var(--tw-shadow-alpha),transparent)}}.shadow-\[\#38bdac\]\/30{--tw-shadow-color:#38bdac4d}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/30{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.3) var(--tw-shadow-alpha),transparent)}}.ring-\[\#38bdac\]{--tw-ring-color:#38bdac}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.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-3xl{--tw-blur:blur(var(--blur-3xl));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,)}.drop-shadow{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#0000001a))drop-shadow(0 1px 1px var(--tw-drop-shadow-color,#0000000f));--tw-drop-shadow:drop-shadow(0 1px 2px #0000001a)drop-shadow(0 1px 1px #0000000f);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,)}.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,)!important}.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-xl{--tw-backdrop-blur:blur(var(--blur-xl));-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-grayscale{--tw-backdrop-grayscale:grayscale(100%);-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-invert{--tw-backdrop-invert:invert(100%);-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-sepia{--tw-backdrop-sepia:sepia(100%);-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-filter{-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,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition\!{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events!important;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))!important;transition-duration:var(--tw-duration,var(--default-transition-duration))!important}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}@media(hover:hover){.group-hover\:text-\[\#38bdac\]:is(:where(.group):hover *){color:#38bdac}.group-hover\:text-gray-400:is(:where(.group):hover *){color:var(--color-gray-400)}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.peer-disabled\:opacity-70:is(:where(.peer):disabled~*){opacity:.7}.placeholder\:text-gray-500::placeholder{color:var(--color-gray-500)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-\[\#38bdac\]\/30:hover{border-color:#38bdac4d}.hover\:border-\[\#38bdac\]\/50:hover{border-color:#38bdac80}.hover\:border-\[\#38bdac\]\/60:hover{border-color:#38bdac99}.hover\:border-\[\#38bdac\]\/70:hover{border-color:#38bdacb3}.hover\:border-blue-500\/60:hover{border-color:#3080ff99}@supports (color:color-mix(in lab,red,red)){.hover\:border-blue-500\/60:hover{border-color:color-mix(in oklab,var(--color-blue-500)60%,transparent)}}.hover\:border-gray-500:hover{border-color:var(--color-gray-500)}.hover\:border-gray-600:hover{border-color:var(--color-gray-600)}.hover\:border-orange-500\/50:hover{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.hover\:border-orange-500\/50:hover{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.hover\:border-yellow-500\/60:hover{border-color:#edb20099}@supports (color:color-mix(in lab,red,red)){.hover\:border-yellow-500\/60:hover{border-color:color-mix(in oklab,var(--color-yellow-500)60%,transparent)}}.hover\:bg-\[\#0a1628\]:hover{background-color:#0a1628}.hover\:bg-\[\#0a1628\]\/80:hover{background-color:#0a1628cc}.hover\:bg-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-emerald-500\/20:hover{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/20:hover{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.hover\:bg-gray-500:hover{background-color:var(--color-gray-500)}.hover\:bg-gray-500\/20:hover{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-500\/20:hover{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-gray-700\/50:hover{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-700\/50:hover{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.hover\:bg-gray-800:hover{background-color:var(--color-gray-800)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-500\/10:hover{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/10:hover{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.hover\:bg-orange-500\/20:hover{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/20:hover{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.hover\:bg-orange-600:hover{background-color:var(--color-orange-600)}.hover\:bg-purple-500\/10:hover{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/10:hover{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.hover\:bg-purple-500\/20:hover{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/20:hover{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.hover\:bg-purple-500\/30:hover{background-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/30:hover{background-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-red-800\/50:hover{background-color:#9f071280}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-800\/50:hover{background-color:color-mix(in oklab,var(--color-red-800)50%,transparent)}}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/20:hover{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/20:hover{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.hover\:bg-yellow-500\/20:hover{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:text-\[\#2da396\]:hover{color:#2da396}.hover\:text-\[\#5fe0cd\]:hover{color:#5fe0cd}.hover\:text-\[\#38bdac\]:hover{color:#38bdac}.hover\:text-amber-200:hover{color:var(--color-amber-200)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-400:hover{color:var(--color-amber-400)}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-green-400:hover{color:var(--color-green-400)}.hover\:text-orange-400:hover{color:var(--color-orange-400)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-sky-200:hover{color:var(--color-sky-200)}.hover\:text-white:hover{color:var(--color-white)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}}.focus\:border-\[\#38bdac\]:focus{border-color:#38bdac}.focus\:border-orange-500\/50:focus{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.focus\:border-orange-500\/50:focus{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.focus\:bg-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-\[\#38bdac\]:focus{--tw-ring-color:#38bdac}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-0:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[\#38bdac\]:focus-visible{--tw-ring-color:#38bdac}.focus-visible\:ring-red-500:focus-visible{--tw-ring-color:var(--color-red-500)}.focus-visible\:ring-offset-0:focus-visible{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-\[\#0a1628\]:focus-visible{--tw-ring-offset-color:#0a1628}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing)*2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing)*3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing)*4)}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=active\]\:bg-\[\#07C160\]\/20[data-state=active]{background-color:#07c16033}.data-\[state\=active\]\:bg-\[\#26A17B\]\/20[data-state=active]{background-color:#26a17b33}.data-\[state\=active\]\:bg-\[\#38bdac\]\/20[data-state=active]{background-color:#38bdac33}.data-\[state\=active\]\:bg-\[\#1677FF\]\/20[data-state=active]{background-color:#1677ff33}.data-\[state\=active\]\:bg-\[\#003087\]\/20[data-state=active]{background-color:#00308733}.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.data-\[state\=active\]\:font-medium[data-state=active]{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.data-\[state\=active\]\:text-\[\#07C160\][data-state=active]{color:#07c160}.data-\[state\=active\]\:text-\[\#26A17B\][data-state=active]{color:#26a17b}.data-\[state\=active\]\:text-\[\#38bdac\][data-state=active]{color:#38bdac}.data-\[state\=active\]\:text-\[\#169BD7\][data-state=active]{color:#169bd7}.data-\[state\=active\]\:text-\[\#1677FF\][data-state=active]{color:#1677ff}.data-\[state\=active\]\:text-amber-400[data-state=active]{color:var(--color-amber-400)}.data-\[state\=active\]\:text-purple-400[data-state=active]{color:var(--color-purple-400)}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=checked\]\:bg-\[\#38bdac\][data-state=checked]{background-color:#38bdac}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-gray-600[data-state=unchecked]{background-color:var(--color-gray-600)}@media(min-width:40rem){.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:text-left{text-align:left}}@media(min-width:48rem){.md\:col-span-2{grid-column:span 2/span 2}.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-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:64rem){.lg\:block{display:block}.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-8{grid-template-columns:repeat(8,minmax(0,1fr))}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:calc(var(--spacing)*0)}.\[\&\>span\]\:line-clamp-1>span{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}}:root{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20% .02 240);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20% .02 240);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(65% .15 180);--primary-foreground:oklch(20% 0 0);--secondary:oklch(27% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(27% 0 0);--muted-foreground:oklch(65% 0 0);--accent:oklch(27% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(55% .2 25);--destructive-foreground:oklch(98.5% 0 0);--border:oklch(35% 0 0);--input:oklch(35% 0 0);--ring:oklch(65% .15 180);--radius:.625rem}body{font-family:var(--font-sans);color:var(--foreground);background:#0a1628}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-pan-x{syntax:"*";inherits:false}@property --tw-pan-y{syntax:"*";inherits:false}@property --tw-pinch-zoom{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/soul-admin/dist/assets/index-uFsIOb55.js b/soul-admin/dist/assets/index-DCoaVA6V.js similarity index 65% rename from soul-admin/dist/assets/index-uFsIOb55.js rename to soul-admin/dist/assets/index-DCoaVA6V.js index c406b221..4a4997d0 100644 --- a/soul-admin/dist/assets/index-uFsIOb55.js +++ b/soul-admin/dist/assets/index-DCoaVA6V.js @@ -6,7 +6,7 @@ function vE(t,e){for(var n=0;n>>1,W=A[D];if(0>>1;Da(Me,U))tea(K,Me)?(A[D]=K,A[te]=U,D=te):(A[D]=Me,A[xe]=U,D=xe);else if(tea(K,U))A[D]=K,A[te]=U,D=te;else break e}}return J}function a(A,J){var U=A.sortIndex-J.sortIndex;return U!==0?U:A.id-J.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var u=[],h=[],f=1,m=null,g=3,y=!1,N=!1,j=!1,v=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(A){for(var J=n(h);J!==null;){if(J.callback===null)s(h);else if(J.startTime<=A)s(h),J.sortIndex=J.expirationTime,e(u,J);else break;J=n(h)}}function M(A){if(j=!1,E(A),!N)if(n(u)!==null)N=!0,q(P);else{var J=n(h);J!==null&&F(M,J.startTime-A)}}function P(A,J){N=!1,j&&(j=!1,k(R),R=-1),y=!0;var U=g;try{for(E(J),m=n(u);m!==null&&(!(m.expirationTime>J)||A&&!ie());){var D=m.callback;if(typeof D=="function"){m.callback=null,g=m.priorityLevel;var W=D(m.expirationTime<=J);J=t.unstable_now(),typeof W=="function"?m.callback=W:m===n(u)&&s(u),E(J)}else s(u);m=n(u)}if(m!==null)var le=!0;else{var xe=n(h);xe!==null&&F(M,xe.startTime-J),le=!1}return le}finally{m=null,g=U,y=!1}}var H=!1,L=null,R=-1,O=5,ne=-1;function ie(){return!(t.unstable_now()-neA||125D?(A.sortIndex=U,e(h,A),n(u)===null&&A===n(h)&&(j?(k(R),R=-1):j=!0,F(M,U-D))):(A.sortIndex=W,e(u,A),N||y||(N=!0,q(P))),A},t.unstable_shouldYield=ie,t.unstable_wrapCallback=function(A){var J=g;return function(){var U=g;g=J;try{return A.apply(this,arguments)}finally{g=U}}}})(Fm)),Fm}var Ov;function SE(){return Ov||(Ov=1,$m.exports=kE()),$m.exports}/** + */var Pv;function kE(){return Pv||(Pv=1,(function(t){function e(A,Y){var U=A.length;A.push(Y);e:for(;0>>1,W=A[D];if(0>>1;Da(Ae,U))nea(K,Ae)?(A[D]=K,A[ne]=U,D=ne):(A[D]=Ae,A[ye]=U,D=ye);else if(nea(K,U))A[D]=K,A[ne]=U,D=ne;else break e}}return Y}function a(A,Y){var U=A.sortIndex-Y.sortIndex;return U!==0?U:A.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var u=[],h=[],f=1,m=null,g=3,y=!1,N=!1,j=!1,v=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(A){for(var Y=n(h);Y!==null;){if(Y.callback===null)s(h);else if(Y.startTime<=A)s(h),Y.sortIndex=Y.expirationTime,e(u,Y);else break;Y=n(h)}}function M(A){if(j=!1,E(A),!N)if(n(u)!==null)N=!0,G(P);else{var Y=n(h);Y!==null&&$(M,Y.startTime-A)}}function P(A,Y){N=!1,j&&(j=!1,k(R),R=-1),y=!0;var U=g;try{for(E(Y),m=n(u);m!==null&&(!(m.expirationTime>Y)||A&&!ie());){var D=m.callback;if(typeof D=="function"){m.callback=null,g=m.priorityLevel;var W=D(m.expirationTime<=Y);Y=t.unstable_now(),typeof W=="function"?m.callback=W:m===n(u)&&s(u),E(Y)}else s(u);m=n(u)}if(m!==null)var le=!0;else{var ye=n(h);ye!==null&&$(M,ye.startTime-Y),le=!1}return le}finally{m=null,g=U,y=!1}}var H=!1,L=null,R=-1,O=5,se=-1;function ie(){return!(t.unstable_now()-seA||125D?(A.sortIndex=U,e(h,A),n(u)===null&&A===n(h)&&(j?(k(R),R=-1):j=!0,$(M,U-D))):(A.sortIndex=W,e(u,A),N||y||(N=!0,G(P))),A},t.unstable_shouldYield=ie,t.unstable_wrapCallback=function(A){var Y=g;return function(){var U=g;g=Y;try{return A.apply(this,arguments)}finally{g=U}}}})($m)),$m}var Ov;function SE(){return Ov||(Ov=1,Fm.exports=kE()),Fm.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ function vE(t,e){for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function g(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function y(l,d,p,x){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return x?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,d,p,x){if(d===null||typeof d>"u"||y(l,d,p,x))return!0;if(x)return!1;if(p!==null)switch(p.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function j(l,d,p,x,w,S,I){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=w,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=S,this.removeEmptyString=I}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){v[l]=new j(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var d=l[0];v[d]=new j(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){v[l]=new j(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){v[l]=new j(l,2,!1,l,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(l){v[l]=new j(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){v[l]=new j(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){v[l]=new j(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){v[l]=new j(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){v[l]=new j(l,5,!1,l.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function C(l){return l[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(l){var d=l.replace(k,C);v[d]=new j(d,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var d=l.replace(k,C);v[d]=new j(d,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var d=l.replace(k,C);v[d]=new j(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){v[l]=new j(l,1,!1,l.toLowerCase(),null,!1,!1)}),v.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){v[l]=new j(l,1,!1,l.toLowerCase(),null,!0,!0)});function E(l,d,p,x){var w=v.hasOwnProperty(d)?v[d]:null;(w!==null?w.type!==0:x||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function g(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function y(l,d,p,x){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return x?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,d,p,x){if(d===null||typeof d>"u"||y(l,d,p,x))return!0;if(x)return!1;if(p!==null)switch(p.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function j(l,d,p,x,w,S,I){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=w,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=S,this.removeEmptyString=I}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){v[l]=new j(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var d=l[0];v[d]=new j(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){v[l]=new j(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){v[l]=new j(l,2,!1,l,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(l){v[l]=new j(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){v[l]=new j(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){v[l]=new j(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){v[l]=new j(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){v[l]=new j(l,5,!1,l.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function C(l){return l[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(l){var d=l.replace(k,C);v[d]=new j(d,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var d=l.replace(k,C);v[d]=new j(d,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var d=l.replace(k,C);v[d]=new j(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){v[l]=new j(l,1,!1,l.toLowerCase(),null,!1,!1)}),v.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){v[l]=new j(l,1,!1,l.toLowerCase(),null,!0,!0)});function E(l,d,p,x){var w=v.hasOwnProperty(d)?v[d]:null;(w!==null?w.type!==0:x||!(2V||w[I]!==S[V]){var Q=` -`+w[I].replace(" at new "," at ");return l.displayName&&Q.includes("")&&(Q=Q.replace("",l.displayName)),Q}while(1<=I&&0<=V);break}}}finally{le=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?W(l):""}function Me(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=xe(l.type,!1),l;case 11:return l=xe(l.type.render,!1),l;case 1:return l=xe(l.type,!0),l;default:return""}}function te(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case L:return"Fragment";case H:return"Portal";case O:return"Profiler";case R:return"StrictMode";case ce:return"Suspense";case pe:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case ie:return(l.displayName||"Context")+".Consumer";case ne:return(l._context.displayName||"Context")+".Provider";case _:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case z:return d=l.displayName||null,d!==null?d:te(l.type)||"Memo";case q:d=l._payload,l=l._init;try{return te(l(d))}catch{}}return null}function K(l){var d=l.type;switch(l.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=d.render,l=l.displayName||l.name||"",d.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return te(d);case 8:return d===R?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function G(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ge(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ae(l){var d=ge(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),x=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var w=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return w.call(this)},set:function(I){x=""+I,S.call(this,I)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(I){x=""+I},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function fe(l){l._valueTracker||(l._valueTracker=ae(l))}function Se(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=ge(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function et(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function st(l,d){var p=d.checked;return U({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function _t(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=G(d.value!=null?d.value:p),l._wrapperState={initialChecked:x,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function At(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function Ut(l,d){At(l,d);var p=G(d.value),x=d.type;if(p!=null)x==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?In(l,d.type,p):d.hasOwnProperty("defaultValue")&&In(l,d.type,G(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function An(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var x=d.type;if(!(x!=="submit"&&x!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+l._wrapperState.initialValue,p||d===l.value||(l.value=d),l.defaultValue=d}p=l.name,p!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,p!==""&&(l.name=p)}function In(l,d,p){(d!=="number"||et(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var It=Array.isArray;function sn(l,d,p,x){if(l=l.options,d){d={};for(var w=0;w"+d.valueOf().toString()+"",d=Qe.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function dt(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var at={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},xt=["Webkit","ms","Moz","O"];Object.keys(at).forEach(function(l){xt.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),at[d]=at[l]})});function Xt(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||at.hasOwnProperty(l)&&at[l]?(""+d).trim():d+"px"}function ln(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,w=Xt(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,w):l[p]=w}}var ss=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function xs(l,d){if(d){if(ss[l]&&(d.children!=null||d.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(d.dangerouslySetInnerHTML!=null){if(d.children!=null)throw Error(n(60));if(typeof d.dangerouslySetInnerHTML!="object"||!("__html"in d.dangerouslySetInnerHTML))throw Error(n(61))}if(d.style!=null&&typeof d.style!="object")throw Error(n(62))}}function fr(l,d){if(l.indexOf("-")===-1)return typeof d.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ys=null;function Lr(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var me=null,ye=null,Zt=null;function Rn(l){if(l=Pc(l)){if(typeof me!="function")throw Error(n(280));var d=l.stateNode;d&&(d=iu(d),me(l.stateNode,l.type,d))}}function da(l){ye?Zt?Zt.push(l):Zt=[l]:ye=l}function ua(){if(ye){var l=ye,d=Zt;if(Zt=ye=null,Rn(l),d)for(l=0;l>>=0,l===0?32:31-(Vr(l)/fc|0)|0}var xa=64,ya=4194304;function Hr(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function yn(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,w=l.suspendedLanes,S=l.pingedLanes,I=p&268435455;if(I!==0){var V=I&~w;V!==0?x=Hr(V):(S&=I,S!==0&&(x=Hr(S)))}else I=p&~w,I!==0?x=Hr(I):S!==0&&(x=Hr(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&w)===0&&(w=x&-x,S=d&-d,w>=S||w===16&&(S&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0p;p++)d.push(l);return d}function _e(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-vs(d),l[d]=p}function ct(l,d){var p=l.pendingLanes&~d;l.pendingLanes=d,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=d,l.mutableReadLanes&=d,l.entangledLanes&=d,d=l.entanglements;var x=l.eventTimes;for(l=l.expirationTimes;0=kc),wy=" ",jy=!1;function ky(l,d){switch(l){case"keyup":return m3.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var rl=!1;function x3(l,d){switch(l){case"compositionend":return Sy(d);case"keypress":return d.which!==32?null:(jy=!0,wy);case"textInput":return l=d.data,l===wy&&jy?null:l;default:return null}}function y3(l,d){if(rl)return l==="compositionend"||!gp&&ky(l,d)?(l=wc(),sl=Nc=Kr=null,rl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1=d)return{node:p,offset:d-l};l=x}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Ry(p)}}function Oy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?Oy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function Dy(){for(var l=window,d=et();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=et(l.document)}return d}function bp(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d&&(d==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||d==="textarea"||l.contentEditable==="true")}function E3(l){var d=Dy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&Oy(p.ownerDocument.documentElement,p)){if(x!==null&&bp(p)){if(d=x.start,l=x.end,l===void 0&&(l=d),"selectionStart"in p)p.selectionStart=d,p.selectionEnd=Math.min(l,p.value.length);else if(l=(d=p.ownerDocument||document)&&d.defaultView||window,l.getSelection){l=l.getSelection();var w=p.textContent.length,S=Math.min(x.start,w);x=x.end===void 0?S:Math.min(x.end,w),!l.extend&&S>x&&(w=x,x=S,S=w),w=Py(p,S);var I=Py(p,x);w&&I&&(l.rangeCount!==1||l.anchorNode!==w.node||l.anchorOffset!==w.offset||l.focusNode!==I.node||l.focusOffset!==I.offset)&&(d=d.createRange(),d.setStart(w.node,w.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(I.node,I.offset)):(d.setEnd(I.node,I.offset),l.addRange(d)))}}for(d=[],l=p;l=l.parentNode;)l.nodeType===1&&d.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p=document.documentMode,al=null,vp=null,Tc=null,Np=!1;function Ly(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Np||al==null||al!==et(x)||(x=al,"selectionStart"in x&&bp(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Tc&&Ec(Tc,x)||(Tc=x,x=su(vp,"onSelect"),0dl||(l.current=Pp[dl],Pp[dl]=null,dl--)}function Ft(l,d){dl++,Pp[dl]=l.current,l.current=d}var ai={},is=ri(ai),Is=ri(!1),lo=ai;function ul(l,d){var p=l.type.contextTypes;if(!p)return ai;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var w={},S;for(S in p)w[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=w),w}function Rs(l){return l=l.childContextTypes,l!=null}function ou(){Gt(Is),Gt(is)}function Qy(l,d,p){if(is.current!==ai)throw Error(n(168));Ft(is,d),Ft(Is,p)}function Xy(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var w in x)if(!(w in d))throw Error(n(108,K(l)||"Unknown",w));return U({},p,x)}function lu(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||ai,lo=is.current,Ft(is,l),Ft(Is,Is.current),!0}function Zy(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Xy(l,d,lo),x.__reactInternalMemoizedMergedChildContext=l,Gt(Is),Gt(is),Ft(is,l)):Gt(Is),Ft(Is,p)}var ja=null,cu=!1,Op=!1;function eb(l){ja===null?ja=[l]:ja.push(l)}function $3(l){cu=!0,eb(l)}function ii(){if(!Op&&ja!==null){Op=!0;var l=0,d=ut;try{var p=ja;for(ut=1;l>=I,w-=I,ka=1<<32-vs(d)+w|p<ot?(Fn=nt,nt=null):Fn=nt.sibling;var jt=je(oe,nt,ue[ot],Re);if(jt===null){nt===null&&(nt=Fn);break}l&&nt&&jt.alternate===null&&d(oe,nt),ee=S(jt,ee,ot),tt===null?We=jt:tt.sibling=jt,tt=jt,nt=Fn}if(ot===ue.length)return p(oe,nt),en&&uo(oe,ot),We;if(nt===null){for(;otot?(Fn=nt,nt=null):Fn=nt.sibling;var mi=je(oe,nt,jt.value,Re);if(mi===null){nt===null&&(nt=Fn);break}l&&nt&&mi.alternate===null&&d(oe,nt),ee=S(mi,ee,ot),tt===null?We=mi:tt.sibling=mi,tt=mi,nt=Fn}if(jt.done)return p(oe,nt),en&&uo(oe,ot),We;if(nt===null){for(;!jt.done;ot++,jt=ue.next())jt=Ce(oe,jt.value,Re),jt!==null&&(ee=S(jt,ee,ot),tt===null?We=jt:tt.sibling=jt,tt=jt);return en&&uo(oe,ot),We}for(nt=x(oe,nt);!jt.done;ot++,jt=ue.next())jt=Le(nt,oe,ot,jt.value,Re),jt!==null&&(l&&jt.alternate!==null&&nt.delete(jt.key===null?ot:jt.key),ee=S(jt,ee,ot),tt===null?We=jt:tt.sibling=jt,tt=jt);return l&&nt.forEach(function(bE){return d(oe,bE)}),en&&uo(oe,ot),We}function vn(oe,ee,ue,Re){if(typeof ue=="object"&&ue!==null&&ue.type===L&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case P:e:{for(var We=ue.key,tt=ee;tt!==null;){if(tt.key===We){if(We=ue.type,We===L){if(tt.tag===7){p(oe,tt.sibling),ee=w(tt,ue.props.children),ee.return=oe,oe=ee;break e}}else if(tt.elementType===We||typeof We=="object"&&We!==null&&We.$$typeof===q&&ib(We)===tt.type){p(oe,tt.sibling),ee=w(tt,ue.props),ee.ref=Oc(oe,tt,ue),ee.return=oe,oe=ee;break e}p(oe,tt);break}else d(oe,tt);tt=tt.sibling}ue.type===L?(ee=bo(ue.props.children,oe.mode,Re,ue.key),ee.return=oe,oe=ee):(Re=_u(ue.type,ue.key,ue.props,null,oe.mode,Re),Re.ref=Oc(oe,ee,ue),Re.return=oe,oe=Re)}return I(oe);case H:e:{for(tt=ue.key;ee!==null;){if(ee.key===tt)if(ee.tag===4&&ee.stateNode.containerInfo===ue.containerInfo&&ee.stateNode.implementation===ue.implementation){p(oe,ee.sibling),ee=w(ee,ue.children||[]),ee.return=oe,oe=ee;break e}else{p(oe,ee);break}else d(oe,ee);ee=ee.sibling}ee=Im(ue,oe.mode,Re),ee.return=oe,oe=ee}return I(oe);case q:return tt=ue._init,vn(oe,ee,tt(ue._payload),Re)}if(It(ue))return Fe(oe,ee,ue,Re);if(J(ue))return He(oe,ee,ue,Re);fu(oe,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"?(ue=""+ue,ee!==null&&ee.tag===6?(p(oe,ee.sibling),ee=w(ee,ue),ee.return=oe,oe=ee):(p(oe,ee),ee=Am(ue,oe.mode,Re),ee.return=oe,oe=ee),I(oe)):p(oe,ee)}return vn}var ml=ob(!0),lb=ob(!1),pu=ri(null),mu=null,gl=null,Fp=null;function Bp(){Fp=gl=mu=null}function Vp(l){var d=pu.current;Gt(pu),l._currentValue=d}function Hp(l,d,p){for(;l!==null;){var x=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,x!==null&&(x.childLanes|=d)):x!==null&&(x.childLanes&d)!==d&&(x.childLanes|=d),l===p)break;l=l.return}}function xl(l,d){mu=l,Fp=gl=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(Ps=!0),l.firstContext=null)}function sr(l){var d=l._currentValue;if(Fp!==l)if(l={context:l,memoizedValue:d,next:null},gl===null){if(mu===null)throw Error(n(308));gl=l,mu.dependencies={lanes:0,firstContext:l}}else gl=gl.next=l;return d}var ho=null;function Wp(l){ho===null?ho=[l]:ho.push(l)}function cb(l,d,p,x){var w=d.interleaved;return w===null?(p.next=p,Wp(d)):(p.next=w.next,w.next=p),d.interleaved=p,Ca(l,x)}function Ca(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var oi=!1;function Up(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function db(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Ea(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function li(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(vt&2)!==0){var w=x.pending;return w===null?d.next=d:(d.next=w.next,w.next=d),x.pending=d,Ca(l,p)}return w=x.interleaved,w===null?(d.next=d,Wp(x)):(d.next=w.next,w.next=d),x.interleaved=d,Ca(l,p)}function gu(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}function ub(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var w=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var I={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?w=S=I:S=S.next=I,p=p.next}while(p!==null);S===null?w=S=d:S=S.next=d}else w=S=d;p={baseState:x.baseState,firstBaseUpdate:w,lastBaseUpdate:S,shared:x.shared,effects:x.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function xu(l,d,p,x){var w=l.updateQueue;oi=!1;var S=w.firstBaseUpdate,I=w.lastBaseUpdate,V=w.shared.pending;if(V!==null){w.shared.pending=null;var Q=V,he=Q.next;Q.next=null,I===null?S=he:I.next=he,I=Q;var ke=l.alternate;ke!==null&&(ke=ke.updateQueue,V=ke.lastBaseUpdate,V!==I&&(V===null?ke.firstBaseUpdate=he:V.next=he,ke.lastBaseUpdate=Q))}if(S!==null){var Ce=w.baseState;I=0,ke=he=Q=null,V=S;do{var je=V.lane,Le=V.eventTime;if((x&je)===je){ke!==null&&(ke=ke.next={eventTime:Le,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Fe=l,He=V;switch(je=d,Le=p,He.tag){case 1:if(Fe=He.payload,typeof Fe=="function"){Ce=Fe.call(Le,Ce,je);break e}Ce=Fe;break e;case 3:Fe.flags=Fe.flags&-65537|128;case 0:if(Fe=He.payload,je=typeof Fe=="function"?Fe.call(Le,Ce,je):Fe,je==null)break e;Ce=U({},Ce,je);break e;case 2:oi=!0}}V.callback!==null&&V.lane!==0&&(l.flags|=64,je=w.effects,je===null?w.effects=[V]:je.push(V))}else Le={eventTime:Le,lane:je,tag:V.tag,payload:V.payload,callback:V.callback,next:null},ke===null?(he=ke=Le,Q=Ce):ke=ke.next=Le,I|=je;if(V=V.next,V===null){if(V=w.shared.pending,V===null)break;je=V,V=je.next,je.next=null,w.lastBaseUpdate=je,w.shared.pending=null}}while(!0);if(ke===null&&(Q=Ce),w.baseState=Q,w.firstBaseUpdate=he,w.lastBaseUpdate=ke,d=w.shared.interleaved,d!==null){w=d;do I|=w.lane,w=w.next;while(w!==d)}else S===null&&(w.shared.lanes=0);mo|=I,l.lanes=I,l.memoizedState=Ce}}function hb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Yp.transition;Yp.transition={};try{l(!1),d()}finally{ut=p,Yp.transition=x}}function Ib(){return rr().memoizedState}function H3(l,d,p){var x=hi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},Rb(l))Pb(d,p);else if(p=cb(l,d,p,x),p!==null){var w=js();Er(p,l,x,w),Ob(p,d,x)}}function W3(l,d,p){var x=hi(l),w={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(Rb(l))Pb(d,w);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var I=d.lastRenderedState,V=S(I,p);if(w.hasEagerState=!0,w.eagerState=V,wr(V,I)){var Q=d.interleaved;Q===null?(w.next=w,Wp(d)):(w.next=Q.next,Q.next=w),d.interleaved=w;return}}catch{}finally{}p=cb(l,d,w,x),p!==null&&(w=js(),Er(p,l,x,w),Ob(p,d,x))}}function Rb(l){var d=l.alternate;return l===an||d!==null&&d===an}function Pb(l,d){zc=vu=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Ob(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}var ju={readContext:sr,useCallback:ls,useContext:ls,useEffect:ls,useImperativeHandle:ls,useInsertionEffect:ls,useLayoutEffect:ls,useMemo:ls,useReducer:ls,useRef:ls,useState:ls,useDebugValue:ls,useDeferredValue:ls,useTransition:ls,useMutableSource:ls,useSyncExternalStore:ls,useId:ls,unstable_isNewReconciler:!1},U3={readContext:sr,useCallback:function(l,d){return Yr().memoizedState=[l,d===void 0?null:d],l},useContext:sr,useEffect:jb,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Nu(4194308,4,Cb.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Nu(4194308,4,l,d)},useInsertionEffect:function(l,d){return Nu(4,2,l,d)},useMemo:function(l,d){var p=Yr();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=Yr();return d=p!==void 0?p(d):d,x.memoizedState=x.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},x.queue=l,l=l.dispatch=H3.bind(null,an,l),[x.memoizedState,l]},useRef:function(l){var d=Yr();return l={current:l},d.memoizedState=l},useState:Nb,useDebugValue:sm,useDeferredValue:function(l){return Yr().memoizedState=l},useTransition:function(){var l=Nb(!1),d=l[0];return l=V3.bind(null,l[1]),Yr().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=an,w=Yr();if(en){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),$n===null)throw Error(n(349));(po&30)!==0||gb(x,d,p)}w.memoizedState=p;var S={value:p,getSnapshot:d};return w.queue=S,jb(yb.bind(null,x,S,l),[l]),x.flags|=2048,Bc(9,xb.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=Yr(),d=$n.identifierPrefix;if(en){var p=Sa,x=ka;p=(x&~(1<<32-vs(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=$c++,0")&&(Q=Q.replace("",l.displayName)),Q}while(1<=I&&0<=V);break}}}finally{le=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?W(l):""}function Ae(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=ye(l.type,!1),l;case 11:return l=ye(l.type.render,!1),l;case 1:return l=ye(l.type,!0),l;default:return""}}function ne(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case L:return"Fragment";case H:return"Portal";case O:return"Profiler";case R:return"StrictMode";case ce:return"Suspense";case me:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case ie:return(l.displayName||"Context")+".Consumer";case se:return(l._context.displayName||"Context")+".Provider";case z:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case _:return d=l.displayName||null,d!==null?d:ne(l.type)||"Memo";case G:d=l._payload,l=l._init;try{return ne(l(d))}catch{}}return null}function K(l){var d=l.type;switch(l.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=d.render,l=l.displayName||l.name||"",d.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ne(d);case 8:return d===R?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function J(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ge(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ae(l){var d=ge(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),x=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var w=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return w.call(this)},set:function(I){x=""+I,S.call(this,I)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(I){x=""+I},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function pe(l){l._valueTracker||(l._valueTracker=ae(l))}function Se(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=ge(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function tt(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function at(l,d){var p=d.checked;return U({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function Dt(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=J(d.value!=null?d.value:p),l._wrapperState={initialChecked:x,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function kt(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function At(l,d){kt(l,d);var p=J(d.value),x=d.type;if(p!=null)x==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?In(l,d.type,p):d.hasOwnProperty("defaultValue")&&In(l,d.type,J(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function Gt(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var x=d.type;if(!(x!=="submit"&&x!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+l._wrapperState.initialValue,p||d===l.value||(l.value=d),l.defaultValue=d}p=l.name,p!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,p!==""&&(l.name=p)}function In(l,d,p){(d!=="number"||tt(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Lt=Array.isArray;function xn(l,d,p,x){if(l=l.options,d){d={};for(var w=0;w"+d.valueOf().toString()+"",d=_t.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function zn(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var ls={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},q=["Webkit","ms","Moz","O"];Object.keys(ls).forEach(function(l){q.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),ls[d]=ls[l]})});function He(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||ls.hasOwnProperty(l)&&ls[l]?(""+d).trim():d+"px"}function mt(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,w=He(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,w):l[p]=w}}var $t=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ut(l,d){if(d){if($t[l]&&(d.children!=null||d.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(d.dangerouslySetInnerHTML!=null){if(d.children!=null)throw Error(n(60));if(typeof d.dangerouslySetInnerHTML!="object"||!("__html"in d.dangerouslySetInnerHTML))throw Error(n(61))}if(d.style!=null&&typeof d.style!="object")throw Error(n(62))}}function ot(l,d){if(l.indexOf("-")===-1)return typeof d.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var xt=null;function tn(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var he=null,xe=null,zt=null;function Rn(l){if(l=Pc(l)){if(typeof he!="function")throw Error(n(280));var d=l.stateNode;d&&(d=iu(d),he(l.stateNode,l.type,d))}}function da(l){xe?zt?zt.push(l):zt=[l]:xe=l}function ua(){if(xe){var l=xe,d=zt;if(zt=xe=null,Rn(l),d)for(l=0;l>>=0,l===0?32:31-(Vr(l)/fc|0)|0}var xa=64,ya=4194304;function Hr(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function bn(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,w=l.suspendedLanes,S=l.pingedLanes,I=p&268435455;if(I!==0){var V=I&~w;V!==0?x=Hr(V):(S&=I,S!==0&&(x=Hr(S)))}else I=p&~w,I!==0?x=Hr(I):S!==0&&(x=Hr(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&w)===0&&(w=x&-x,S=d&-d,w>=S||w===16&&(S&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0p;p++)d.push(l);return d}function _e(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-ws(d),l[d]=p}function lt(l,d){var p=l.pendingLanes&~d;l.pendingLanes=d,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=d,l.mutableReadLanes&=d,l.entangledLanes&=d,d=l.entanglements;var x=l.eventTimes;for(l=l.expirationTimes;0=kc),wy=" ",jy=!1;function ky(l,d){switch(l){case"keyup":return m3.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var rl=!1;function x3(l,d){switch(l){case"compositionend":return Sy(d);case"keypress":return d.which!==32?null:(jy=!0,wy);case"textInput":return l=d.data,l===wy&&jy?null:l;default:return null}}function y3(l,d){if(rl)return l==="compositionend"||!gp&&ky(l,d)?(l=wc(),sl=Nc=Kr=null,rl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1=d)return{node:p,offset:d-l};l=x}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Ry(p)}}function Oy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?Oy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function Dy(){for(var l=window,d=tt();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=tt(l.document)}return d}function bp(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d&&(d==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||d==="textarea"||l.contentEditable==="true")}function E3(l){var d=Dy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&Oy(p.ownerDocument.documentElement,p)){if(x!==null&&bp(p)){if(d=x.start,l=x.end,l===void 0&&(l=d),"selectionStart"in p)p.selectionStart=d,p.selectionEnd=Math.min(l,p.value.length);else if(l=(d=p.ownerDocument||document)&&d.defaultView||window,l.getSelection){l=l.getSelection();var w=p.textContent.length,S=Math.min(x.start,w);x=x.end===void 0?S:Math.min(x.end,w),!l.extend&&S>x&&(w=x,x=S,S=w),w=Py(p,S);var I=Py(p,x);w&&I&&(l.rangeCount!==1||l.anchorNode!==w.node||l.anchorOffset!==w.offset||l.focusNode!==I.node||l.focusOffset!==I.offset)&&(d=d.createRange(),d.setStart(w.node,w.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(I.node,I.offset)):(d.setEnd(I.node,I.offset),l.addRange(d)))}}for(d=[],l=p;l=l.parentNode;)l.nodeType===1&&d.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p=document.documentMode,al=null,vp=null,Tc=null,Np=!1;function Ly(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Np||al==null||al!==tt(x)||(x=al,"selectionStart"in x&&bp(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Tc&&Ec(Tc,x)||(Tc=x,x=su(vp,"onSelect"),0dl||(l.current=Pp[dl],Pp[dl]=null,dl--)}function Ht(l,d){dl++,Pp[dl]=l.current,l.current=d}var ii={},us=ai(ii),Rs=ai(!1),lo=ii;function ul(l,d){var p=l.type.contextTypes;if(!p)return ii;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var w={},S;for(S in p)w[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=w),w}function Ps(l){return l=l.childContextTypes,l!=null}function ou(){Qt(Rs),Qt(us)}function Qy(l,d,p){if(us.current!==ii)throw Error(n(168));Ht(us,d),Ht(Rs,p)}function Xy(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var w in x)if(!(w in d))throw Error(n(108,K(l)||"Unknown",w));return U({},p,x)}function lu(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||ii,lo=us.current,Ht(us,l),Ht(Rs,Rs.current),!0}function Zy(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Xy(l,d,lo),x.__reactInternalMemoizedMergedChildContext=l,Qt(Rs),Qt(us),Ht(us,l)):Qt(Rs),Ht(Rs,p)}var ja=null,cu=!1,Op=!1;function eb(l){ja===null?ja=[l]:ja.push(l)}function F3(l){cu=!0,eb(l)}function oi(){if(!Op&&ja!==null){Op=!0;var l=0,d=ct;try{var p=ja;for(ct=1;l>=I,w-=I,ka=1<<32-ws(d)+w|p<rt?(Bn=et,et=null):Bn=et.sibling;var wt=je(oe,et,ue[rt],Re);if(wt===null){et===null&&(et=Bn);break}l&&et&&wt.alternate===null&&d(oe,et),ee=S(wt,ee,rt),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt,et=Bn}if(rt===ue.length)return p(oe,et),nn&&uo(oe,rt),Ue;if(et===null){for(;rtrt?(Bn=et,et=null):Bn=et.sibling;var gi=je(oe,et,wt.value,Re);if(gi===null){et===null&&(et=Bn);break}l&&et&&gi.alternate===null&&d(oe,et),ee=S(gi,ee,rt),Ze===null?Ue=gi:Ze.sibling=gi,Ze=gi,et=Bn}if(wt.done)return p(oe,et),nn&&uo(oe,rt),Ue;if(et===null){for(;!wt.done;rt++,wt=ue.next())wt=Ce(oe,wt.value,Re),wt!==null&&(ee=S(wt,ee,rt),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt);return nn&&uo(oe,rt),Ue}for(et=x(oe,et);!wt.done;rt++,wt=ue.next())wt=Le(et,oe,rt,wt.value,Re),wt!==null&&(l&&wt.alternate!==null&&et.delete(wt.key===null?rt:wt.key),ee=S(wt,ee,rt),Ze===null?Ue=wt:Ze.sibling=wt,Ze=wt);return l&&et.forEach(function(bE){return d(oe,bE)}),nn&&uo(oe,rt),Ue}function Nn(oe,ee,ue,Re){if(typeof ue=="object"&&ue!==null&&ue.type===L&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case P:e:{for(var Ue=ue.key,Ze=ee;Ze!==null;){if(Ze.key===Ue){if(Ue=ue.type,Ue===L){if(Ze.tag===7){p(oe,Ze.sibling),ee=w(Ze,ue.props.children),ee.return=oe,oe=ee;break e}}else if(Ze.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===G&&ib(Ue)===Ze.type){p(oe,Ze.sibling),ee=w(Ze,ue.props),ee.ref=Oc(oe,Ze,ue),ee.return=oe,oe=ee;break e}p(oe,Ze);break}else d(oe,Ze);Ze=Ze.sibling}ue.type===L?(ee=bo(ue.props.children,oe.mode,Re,ue.key),ee.return=oe,oe=ee):(Re=_u(ue.type,ue.key,ue.props,null,oe.mode,Re),Re.ref=Oc(oe,ee,ue),Re.return=oe,oe=Re)}return I(oe);case H:e:{for(Ze=ue.key;ee!==null;){if(ee.key===Ze)if(ee.tag===4&&ee.stateNode.containerInfo===ue.containerInfo&&ee.stateNode.implementation===ue.implementation){p(oe,ee.sibling),ee=w(ee,ue.children||[]),ee.return=oe,oe=ee;break e}else{p(oe,ee);break}else d(oe,ee);ee=ee.sibling}ee=Im(ue,oe.mode,Re),ee.return=oe,oe=ee}return I(oe);case G:return Ze=ue._init,Nn(oe,ee,Ze(ue._payload),Re)}if(Lt(ue))return $e(oe,ee,ue,Re);if(Y(ue))return We(oe,ee,ue,Re);fu(oe,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"?(ue=""+ue,ee!==null&&ee.tag===6?(p(oe,ee.sibling),ee=w(ee,ue),ee.return=oe,oe=ee):(p(oe,ee),ee=Am(ue,oe.mode,Re),ee.return=oe,oe=ee),I(oe)):p(oe,ee)}return Nn}var ml=ob(!0),lb=ob(!1),pu=ai(null),mu=null,gl=null,$p=null;function Bp(){$p=gl=mu=null}function Vp(l){var d=pu.current;Qt(pu),l._currentValue=d}function Hp(l,d,p){for(;l!==null;){var x=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,x!==null&&(x.childLanes|=d)):x!==null&&(x.childLanes&d)!==d&&(x.childLanes|=d),l===p)break;l=l.return}}function xl(l,d){mu=l,$p=gl=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(Os=!0),l.firstContext=null)}function ar(l){var d=l._currentValue;if($p!==l)if(l={context:l,memoizedValue:d,next:null},gl===null){if(mu===null)throw Error(n(308));gl=l,mu.dependencies={lanes:0,firstContext:l}}else gl=gl.next=l;return d}var ho=null;function Wp(l){ho===null?ho=[l]:ho.push(l)}function cb(l,d,p,x){var w=d.interleaved;return w===null?(p.next=p,Wp(d)):(p.next=w.next,w.next=p),d.interleaved=p,Ca(l,x)}function Ca(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var li=!1;function Up(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function db(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Ea(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function ci(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(vt&2)!==0){var w=x.pending;return w===null?d.next=d:(d.next=w.next,w.next=d),x.pending=d,Ca(l,p)}return w=x.interleaved,w===null?(d.next=d,Wp(x)):(d.next=w.next,w.next=d),x.interleaved=d,Ca(l,p)}function gu(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}function ub(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var w=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var I={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?w=S=I:S=S.next=I,p=p.next}while(p!==null);S===null?w=S=d:S=S.next=d}else w=S=d;p={baseState:x.baseState,firstBaseUpdate:w,lastBaseUpdate:S,shared:x.shared,effects:x.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function xu(l,d,p,x){var w=l.updateQueue;li=!1;var S=w.firstBaseUpdate,I=w.lastBaseUpdate,V=w.shared.pending;if(V!==null){w.shared.pending=null;var Q=V,fe=Q.next;Q.next=null,I===null?S=fe:I.next=fe,I=Q;var ke=l.alternate;ke!==null&&(ke=ke.updateQueue,V=ke.lastBaseUpdate,V!==I&&(V===null?ke.firstBaseUpdate=fe:V.next=fe,ke.lastBaseUpdate=Q))}if(S!==null){var Ce=w.baseState;I=0,ke=fe=Q=null,V=S;do{var je=V.lane,Le=V.eventTime;if((x&je)===je){ke!==null&&(ke=ke.next={eventTime:Le,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var $e=l,We=V;switch(je=d,Le=p,We.tag){case 1:if($e=We.payload,typeof $e=="function"){Ce=$e.call(Le,Ce,je);break e}Ce=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=We.payload,je=typeof $e=="function"?$e.call(Le,Ce,je):$e,je==null)break e;Ce=U({},Ce,je);break e;case 2:li=!0}}V.callback!==null&&V.lane!==0&&(l.flags|=64,je=w.effects,je===null?w.effects=[V]:je.push(V))}else Le={eventTime:Le,lane:je,tag:V.tag,payload:V.payload,callback:V.callback,next:null},ke===null?(fe=ke=Le,Q=Ce):ke=ke.next=Le,I|=je;if(V=V.next,V===null){if(V=w.shared.pending,V===null)break;je=V,V=je.next,je.next=null,w.lastBaseUpdate=je,w.shared.pending=null}}while(!0);if(ke===null&&(Q=Ce),w.baseState=Q,w.firstBaseUpdate=fe,w.lastBaseUpdate=ke,d=w.shared.interleaved,d!==null){w=d;do I|=w.lane,w=w.next;while(w!==d)}else S===null&&(w.shared.lanes=0);mo|=I,l.lanes=I,l.memoizedState=Ce}}function hb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Yp.transition;Yp.transition={};try{l(!1),d()}finally{ct=p,Yp.transition=x}}function Ib(){return ir().memoizedState}function H3(l,d,p){var x=fi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},Rb(l))Pb(d,p);else if(p=cb(l,d,p,x),p!==null){var w=Ss();Tr(p,l,x,w),Ob(p,d,x)}}function W3(l,d,p){var x=fi(l),w={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(Rb(l))Pb(d,w);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var I=d.lastRenderedState,V=S(I,p);if(w.hasEagerState=!0,w.eagerState=V,jr(V,I)){var Q=d.interleaved;Q===null?(w.next=w,Wp(d)):(w.next=Q.next,Q.next=w),d.interleaved=w;return}}catch{}finally{}p=cb(l,d,w,x),p!==null&&(w=Ss(),Tr(p,l,x,w),Ob(p,d,x))}}function Rb(l){var d=l.alternate;return l===on||d!==null&&d===on}function Pb(l,d){zc=vu=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Ob(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,cn(l,p)}}var ju={readContext:ar,useCallback:hs,useContext:hs,useEffect:hs,useImperativeHandle:hs,useInsertionEffect:hs,useLayoutEffect:hs,useMemo:hs,useReducer:hs,useRef:hs,useState:hs,useDebugValue:hs,useDeferredValue:hs,useTransition:hs,useMutableSource:hs,useSyncExternalStore:hs,useId:hs,unstable_isNewReconciler:!1},U3={readContext:ar,useCallback:function(l,d){return Yr().memoizedState=[l,d===void 0?null:d],l},useContext:ar,useEffect:jb,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Nu(4194308,4,Cb.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Nu(4194308,4,l,d)},useInsertionEffect:function(l,d){return Nu(4,2,l,d)},useMemo:function(l,d){var p=Yr();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=Yr();return d=p!==void 0?p(d):d,x.memoizedState=x.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},x.queue=l,l=l.dispatch=H3.bind(null,on,l),[x.memoizedState,l]},useRef:function(l){var d=Yr();return l={current:l},d.memoizedState=l},useState:Nb,useDebugValue:sm,useDeferredValue:function(l){return Yr().memoizedState=l},useTransition:function(){var l=Nb(!1),d=l[0];return l=V3.bind(null,l[1]),Yr().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=on,w=Yr();if(nn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),$n===null)throw Error(n(349));(po&30)!==0||gb(x,d,p)}w.memoizedState=p;var S={value:p,getSnapshot:d};return w.queue=S,jb(yb.bind(null,x,S,l),[l]),x.flags|=2048,Bc(9,xb.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=Yr(),d=$n.identifierPrefix;if(nn){var p=Sa,x=ka;p=(x&~(1<<32-ws(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=Fc++,0<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=I.createElement(p,{is:x.is}):(l=I.createElement(p),p==="select"&&(I=l,x.multiple?I.multiple=!0:x.size&&(I.size=x.size))):l=I.createElementNS(l,p),l[Gr]=d,l[Rc]=x,ev(l,d,!1,!1),d.stateNode=l;e:{switch(I=fr(p,x),p){case"dialog":qt("cancel",l),qt("close",l),w=x;break;case"iframe":case"object":case"embed":qt("load",l),w=x;break;case"video":case"audio":for(w=0;wwl&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304)}else{if(!x)if(l=yu(I),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Vc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!I.alternate&&!en)return cs(d),null}else 2*Kt()-S.renderingStartTime>wl&&p!==1073741824&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304);S.isBackwards?(I.sibling=d.child,d.child=I):(p=S.last,p!==null?p.sibling=I:d.child=I,S.last=I)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=Kt(),d.sibling=null,p=rn.current,Ft(rn,x?p&1|2:p&1),d):(cs(d),null);case 22:case 23:return Em(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Hs&1073741824)!==0&&(cs(d),d.subtreeFlags&6&&(d.flags|=8192)):cs(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function Z3(l,d){switch(Lp(d),d.tag){case 1:return Rs(d.type)&&ou(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return yl(),Gt(Is),Gt(is),Jp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return qp(d),null;case 13:if(Gt(rn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));pl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return Gt(rn),null;case 4:return yl(),null;case 10:return Vp(d.type._context),null;case 22:case 23:return Em(),null;case 24:return null;default:return null}}var Eu=!1,ds=!1,eE=typeof WeakSet=="function"?WeakSet:Set,ze=null;function vl(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){un(l,d,x)}else p.current=null}function mm(l,d,p){try{p()}catch(x){un(l,d,x)}}var sv=!1;function tE(l,d){if(Ep=tl,l=Dy(),bp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var w=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var I=0,V=-1,Q=-1,he=0,ke=0,Ce=l,je=null;t:for(;;){for(var Le;Ce!==p||w!==0&&Ce.nodeType!==3||(V=I+w),Ce!==S||x!==0&&Ce.nodeType!==3||(Q=I+x),Ce.nodeType===3&&(I+=Ce.nodeValue.length),(Le=Ce.firstChild)!==null;)je=Ce,Ce=Le;for(;;){if(Ce===l)break t;if(je===p&&++he===w&&(V=I),je===S&&++ke===x&&(Q=I),(Le=Ce.nextSibling)!==null)break;Ce=je,je=Ce.parentNode}Ce=Le}p=V===-1||Q===-1?null:{start:V,end:Q}}else p=null}p=p||{start:0,end:0}}else p=null;for(Tp={focusedElem:l,selectionRange:p},tl=!1,ze=d;ze!==null;)if(d=ze,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,ze=l;else for(;ze!==null;){d=ze;try{var Fe=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Fe!==null){var He=Fe.memoizedProps,vn=Fe.memoizedState,oe=d.stateNode,ee=oe.getSnapshotBeforeUpdate(d.elementType===d.type?He:kr(d.type,He),vn);oe.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var ue=d.stateNode.containerInfo;ue.nodeType===1?ue.textContent="":ue.nodeType===9&&ue.documentElement&&ue.removeChild(ue.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){un(d,d.return,Re)}if(l=d.sibling,l!==null){l.return=d.return,ze=l;break}ze=d.return}return Fe=sv,sv=!1,Fe}function Hc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var w=x=x.next;do{if((w.tag&l)===l){var S=w.destroy;w.destroy=void 0,S!==void 0&&mm(d,p,S)}w=w.next}while(w!==x)}}function Tu(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var x=p.create;p.destroy=x()}p=p.next}while(p!==d)}}function gm(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function rv(l){var d=l.alternate;d!==null&&(l.alternate=null,rv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Gr],delete d[Rc],delete d[Rp],delete d[_3],delete d[z3])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function av(l){return l.tag===5||l.tag===3||l.tag===4}function iv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||av(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function xm(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=au));else if(x!==4&&(l=l.child,l!==null))for(xm(l,d,p),l=l.sibling;l!==null;)xm(l,d,p),l=l.sibling}function ym(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(ym(l,d,p),l=l.sibling;l!==null;)ym(l,d,p),l=l.sibling}var qn=null,Sr=!1;function ci(l,d,p){for(p=p.child;p!==null;)ov(l,d,p),p=p.sibling}function ov(l,d,p){if(bs&&typeof bs.onCommitFiberUnmount=="function")try{bs.onCommitFiberUnmount(Br,p)}catch{}switch(p.tag){case 5:ds||vl(p,d);case 6:var x=qn,w=Sr;qn=null,ci(l,d,p),qn=x,Sr=w,qn!==null&&(Sr?(l=qn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):qn.removeChild(p.stateNode));break;case 18:qn!==null&&(Sr?(l=qn,p=p.stateNode,l.nodeType===8?Ip(l.parentNode,p):l.nodeType===1&&Ip(l,p),ao(l)):Ip(qn,p.stateNode));break;case 4:x=qn,w=Sr,qn=p.stateNode.containerInfo,Sr=!0,ci(l,d,p),qn=x,Sr=w;break;case 0:case 11:case 14:case 15:if(!ds&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){w=x=x.next;do{var S=w,I=S.destroy;S=S.tag,I!==void 0&&((S&2)!==0||(S&4)!==0)&&mm(p,d,I),w=w.next}while(w!==x)}ci(l,d,p);break;case 1:if(!ds&&(vl(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(V){un(p,d,V)}ci(l,d,p);break;case 21:ci(l,d,p);break;case 22:p.mode&1?(ds=(x=ds)||p.memoizedState!==null,ci(l,d,p),ds=x):ci(l,d,p);break;default:ci(l,d,p)}}function lv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new eE),d.forEach(function(x){var w=dE.bind(null,l,x);p.has(x)||(p.add(x),x.then(w,w))})}}function Cr(l,d){var p=d.deletions;if(p!==null)for(var x=0;xw&&(w=I),x&=~S}if(x=w,x=Kt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*sE(x/1960))-x,10l?16:l,ui===null)var x=!1;else{if(l=ui,ui=null,Pu=0,(vt&6)!==0)throw Error(n(331));var w=vt;for(vt|=4,ze=l.current;ze!==null;){var S=ze,I=S.child;if((ze.flags&16)!==0){var V=S.deletions;if(V!==null){for(var Q=0;QKt()-Nm?xo(l,0):vm|=p),Ds(l,d)}function Nv(l,d){d===0&&((l.mode&1)===0?d=1:(d=ya,ya<<=1,(ya&130023424)===0&&(ya=4194304)));var p=js();l=Ca(l,d),l!==null&&(_e(l,d,p),Ds(l,p))}function cE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),Nv(l,p)}function dE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,w=l.memoizedState;w!==null&&(p=w.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),Nv(l,p)}var wv;wv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||Is.current)Ps=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return Ps=!1,Q3(l,d,p);Ps=(l.flags&131072)!==0}else Ps=!1,en&&(d.flags&1048576)!==0&&tb(d,uu,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;Cu(l,d),l=d.pendingProps;var w=ul(d,is.current);xl(d,p),w=Xp(null,d,x,l,w,p);var S=Zp();return d.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Rs(x)?(S=!0,lu(d)):S=!1,d.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Up(d),w.updater=ku,d.stateNode=w,w._reactInternals=d,am(d,x,l,p),d=cm(null,d,x,!0,S,p)):(d.tag=0,en&&S&&Dp(d),ws(null,d,w,p),d=d.child),d;case 16:x=d.elementType;e:{switch(Cu(l,d),l=d.pendingProps,w=x._init,x=w(x._payload),d.type=x,w=d.tag=hE(x),l=kr(x,l),w){case 0:d=lm(null,d,x,l,p);break e;case 1:d=Gb(null,d,x,l,p);break e;case 11:d=Hb(null,d,x,l,p);break e;case 14:d=Wb(null,d,x,kr(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:kr(x,w),lm(l,d,x,w,p);case 1:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:kr(x,w),Gb(l,d,x,w,p);case 3:e:{if(Jb(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,w=S.element,db(l,d),xu(d,x,null,p);var I=d.memoizedState;if(x=I.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){w=bl(Error(n(423)),d),d=Yb(l,d,x,p,w);break e}else if(x!==w){w=bl(Error(n(424)),d),d=Yb(l,d,x,p,w);break e}else for(Vs=si(d.stateNode.containerInfo.firstChild),Bs=d,en=!0,jr=null,p=lb(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(pl(),x===w){d=Ta(l,d,p);break e}ws(l,d,x,p)}d=d.child}return d;case 5:return fb(d),l===null&&zp(d),x=d.type,w=d.pendingProps,S=l!==null?l.memoizedProps:null,I=w.children,Mp(x,w)?I=null:S!==null&&Mp(x,S)&&(d.flags|=32),qb(l,d),ws(l,d,I,p),d.child;case 6:return l===null&&zp(d),null;case 13:return Qb(l,d,p);case 4:return Kp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=ml(d,null,x,p):ws(l,d,x,p),d.child;case 11:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:kr(x,w),Hb(l,d,x,w,p);case 7:return ws(l,d,d.pendingProps,p),d.child;case 8:return ws(l,d,d.pendingProps.children,p),d.child;case 12:return ws(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,w=d.pendingProps,S=d.memoizedProps,I=w.value,Ft(pu,x._currentValue),x._currentValue=I,S!==null)if(wr(S.value,I)){if(S.children===w.children&&!Is.current){d=Ta(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var V=S.dependencies;if(V!==null){I=S.child;for(var Q=V.firstContext;Q!==null;){if(Q.context===x){if(S.tag===1){Q=Ea(-1,p&-p),Q.tag=2;var he=S.updateQueue;if(he!==null){he=he.shared;var ke=he.pending;ke===null?Q.next=Q:(Q.next=ke.next,ke.next=Q),he.pending=Q}}S.lanes|=p,Q=S.alternate,Q!==null&&(Q.lanes|=p),Hp(S.return,p,d),V.lanes|=p;break}Q=Q.next}}else if(S.tag===10)I=S.type===d.type?null:S.child;else if(S.tag===18){if(I=S.return,I===null)throw Error(n(341));I.lanes|=p,V=I.alternate,V!==null&&(V.lanes|=p),Hp(I,p,d),I=S.sibling}else I=S.child;if(I!==null)I.return=S;else for(I=S;I!==null;){if(I===d){I=null;break}if(S=I.sibling,S!==null){S.return=I.return,I=S;break}I=I.return}S=I}ws(l,d,w.children,p),d=d.child}return d;case 9:return w=d.type,x=d.pendingProps.children,xl(d,p),w=sr(w),x=x(w),d.flags|=1,ws(l,d,x,p),d.child;case 14:return x=d.type,w=kr(x,d.pendingProps),w=kr(x.type,w),Wb(l,d,x,w,p);case 15:return Ub(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:kr(x,w),Cu(l,d),d.tag=1,Rs(x)?(l=!0,lu(d)):l=!1,xl(d,p),Lb(d,x,w),am(d,x,w,p),cm(null,d,x,!0,l,p);case 19:return Zb(l,d,p);case 22:return Kb(l,d,p)}throw Error(n(156,d.tag))};function jv(l,d){return $r(l,d)}function uE(l,d,p,x){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ir(l,d,p,x){return new uE(l,d,p,x)}function Mm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function hE(l){if(typeof l=="function")return Mm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===_)return 11;if(l===z)return 14}return 2}function pi(l,d){var p=l.alternate;return p===null?(p=ir(l.tag,d,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=d,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,d=l.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function _u(l,d,p,x,w,S){var I=2;if(x=l,typeof l=="function")Mm(l)&&(I=1);else if(typeof l=="string")I=5;else e:switch(l){case L:return bo(p.children,w,S,d);case R:I=8,w|=8;break;case O:return l=ir(12,p,d,w|2),l.elementType=O,l.lanes=S,l;case ce:return l=ir(13,p,d,w),l.elementType=ce,l.lanes=S,l;case pe:return l=ir(19,p,d,w),l.elementType=pe,l.lanes=S,l;case F:return zu(p,w,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case ne:I=10;break e;case ie:I=9;break e;case _:I=11;break e;case z:I=14;break e;case q:I=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=ir(I,p,d,w),d.elementType=l,d.type=x,d.lanes=S,d}function bo(l,d,p,x){return l=ir(7,l,x,d),l.lanes=p,l}function zu(l,d,p,x){return l=ir(22,l,x,d),l.elementType=F,l.lanes=p,l.stateNode={isHidden:!1},l}function Am(l,d,p){return l=ir(6,l,null,d),l.lanes=p,l}function Im(l,d,p){return d=ir(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function fE(l,d,p,x,w){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pe(0),this.expirationTimes=Pe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pe(0),this.identifierPrefix=x,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function Rm(l,d,p,x,w,S,I,V,Q){return l=new fE(l,d,p,V,Q),d===1?(d=1,S===!0&&(d|=8)):d=0,S=ir(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Up(S),l}function pE(l,d,p){var x=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),zm.exports=CE(),zm.exports}var _v;function EE(){if(_v)return Uu;_v=1;var t=Ww();return Uu.createRoot=t.createRoot,Uu.hydrateRoot=t.hydrateRoot,Uu}var TE=EE(),Bd=Ww();const Uw=Hw(Bd);/** +`+S.stack}return{value:l,source:d,stack:w,digest:null}}function im(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function om(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var G3=typeof WeakMap=="function"?WeakMap:Map;function zb(l,d,p){p=Ea(-1,p),p.tag=3,p.payload={element:null};var x=d.value;return p.callback=function(){Iu||(Iu=!0,wm=x),om(l,d)},p}function Fb(l,d,p){p=Ea(-1,p),p.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var w=d.value;p.payload=function(){return x(w)},p.callback=function(){om(l,d)}}var S=l.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){om(l,d),typeof x!="function"&&(ui===null?ui=new Set([this]):ui.add(this));var I=d.stack;this.componentDidCatch(d.value,{componentStack:I!==null?I:""})}),p}function $b(l,d,p){var x=l.pingCache;if(x===null){x=l.pingCache=new G3;var w=new Set;x.set(d,w)}else w=x.get(d),w===void 0&&(w=new Set,x.set(d,w));w.has(p)||(w.add(p),l=lE.bind(null,l,d,p),d.then(l,l))}function Bb(l){do{var d;if((d=l.tag===13)&&(d=l.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return l;l=l.return}while(l!==null);return null}function Vb(l,d,p,x,w){return(l.mode&1)===0?(l===d?l.flags|=65536:(l.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(d=Ea(-1,1),d.tag=2,ci(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=w,l)}var J3=M.ReactCurrentOwner,Os=!1;function ks(l,d,p,x){d.child=l===null?lb(d,null,p,x):ml(d,l.child,p,x)}function Hb(l,d,p,x,w){p=p.render;var S=d.ref;return xl(d,w),x=Xp(l,d,p,x,S,w),p=Zp(),l!==null&&!Os?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~w,Ta(l,d,w)):(nn&&p&&Dp(d),d.flags|=1,ks(l,d,x,w),d.child)}function Wb(l,d,p,x,w){if(l===null){var S=p.type;return typeof S=="function"&&!Mm(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=S,Ub(l,d,S,x,w)):(l=_u(p.type,null,x,d,d.mode,w),l.ref=d.ref,l.return=d,d.child=l)}if(S=l.child,(l.lanes&w)===0){var I=S.memoizedProps;if(p=p.compare,p=p!==null?p:Ec,p(I,x)&&l.ref===d.ref)return Ta(l,d,w)}return d.flags|=1,l=mi(S,x),l.ref=d.ref,l.return=d,d.child=l}function Ub(l,d,p,x,w){if(l!==null){var S=l.memoizedProps;if(Ec(S,x)&&l.ref===d.ref)if(Os=!1,d.pendingProps=x=S,(l.lanes&w)!==0)(l.flags&131072)!==0&&(Os=!0);else return d.lanes=l.lanes,Ta(l,d,w)}return lm(l,d,p,x,w)}function Kb(l,d,p){var x=d.pendingProps,w=x.children,S=l!==null?l.memoizedState:null;if(x.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ht(Nl,Us),Us|=p;else{if((p&1073741824)===0)return l=S!==null?S.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,Ht(Nl,Us),Us|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=S!==null?S.baseLanes:p,Ht(Nl,Us),Us|=x}else S!==null?(x=S.baseLanes|p,d.memoizedState=null):x=p,Ht(Nl,Us),Us|=x;return ks(l,d,w,p),d.child}function qb(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function lm(l,d,p,x,w){var S=Ps(p)?lo:us.current;return S=ul(d,S),xl(d,w),p=Xp(l,d,p,x,S,w),x=Zp(),l!==null&&!Os?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~w,Ta(l,d,w)):(nn&&x&&Dp(d),d.flags|=1,ks(l,d,p,w),d.child)}function Gb(l,d,p,x,w){if(Ps(p)){var S=!0;lu(d)}else S=!1;if(xl(d,w),d.stateNode===null)Cu(l,d),Lb(d,p,x),am(d,p,x,w),x=!0;else if(l===null){var I=d.stateNode,V=d.memoizedProps;I.props=V;var Q=I.context,fe=p.contextType;typeof fe=="object"&&fe!==null?fe=ar(fe):(fe=Ps(p)?lo:us.current,fe=ul(d,fe));var ke=p.getDerivedStateFromProps,Ce=typeof ke=="function"||typeof I.getSnapshotBeforeUpdate=="function";Ce||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==x||Q!==fe)&&_b(d,I,x,fe),li=!1;var je=d.memoizedState;I.state=je,xu(d,x,I,w),Q=d.memoizedState,V!==x||je!==Q||Rs.current||li?(typeof ke=="function"&&(rm(d,p,ke,x),Q=d.memoizedState),(V=li||Db(d,p,V,x,je,Q,fe))?(Ce||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(d.flags|=4194308)):(typeof I.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=x,d.memoizedState=Q),I.props=x,I.state=Q,I.context=fe,x=V):(typeof I.componentDidMount=="function"&&(d.flags|=4194308),x=!1)}else{I=d.stateNode,db(l,d),V=d.memoizedProps,fe=d.type===d.elementType?V:Sr(d.type,V),I.props=fe,Ce=d.pendingProps,je=I.context,Q=p.contextType,typeof Q=="object"&&Q!==null?Q=ar(Q):(Q=Ps(p)?lo:us.current,Q=ul(d,Q));var Le=p.getDerivedStateFromProps;(ke=typeof Le=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==Ce||je!==Q)&&_b(d,I,x,Q),li=!1,je=d.memoizedState,I.state=je,xu(d,x,I,w);var $e=d.memoizedState;V!==Ce||je!==$e||Rs.current||li?(typeof Le=="function"&&(rm(d,p,Le,x),$e=d.memoizedState),(fe=li||Db(d,p,fe,x,je,$e,Q)||!1)?(ke||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(x,$e,Q),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(x,$e,Q)),typeof I.componentDidUpdate=="function"&&(d.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof I.componentDidUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=1024),d.memoizedProps=x,d.memoizedState=$e),I.props=x,I.state=$e,I.context=Q,x=fe):(typeof I.componentDidUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===l.memoizedProps&&je===l.memoizedState||(d.flags|=1024),x=!1)}return cm(l,d,p,x,S,w)}function cm(l,d,p,x,w,S){qb(l,d);var I=(d.flags&128)!==0;if(!x&&!I)return w&&Zy(d,p,!1),Ta(l,d,S);x=d.stateNode,J3.current=d;var V=I&&typeof p.getDerivedStateFromError!="function"?null:x.render();return d.flags|=1,l!==null&&I?(d.child=ml(d,l.child,null,S),d.child=ml(d,null,V,S)):ks(l,d,V,S),d.memoizedState=x.state,w&&Zy(d,p,!0),d.child}function Jb(l){var d=l.stateNode;d.pendingContext?Qy(l,d.pendingContext,d.pendingContext!==d.context):d.context&&Qy(l,d.context,!1),Kp(l,d.containerInfo)}function Yb(l,d,p,x,w){return pl(),Fp(w),d.flags|=256,ks(l,d,p,x),d.child}var dm={dehydrated:null,treeContext:null,retryLane:0};function um(l){return{baseLanes:l,cachePool:null,transitions:null}}function Qb(l,d,p){var x=d.pendingProps,w=an.current,S=!1,I=(d.flags&128)!==0,V;if((V=I)||(V=l!==null&&l.memoizedState===null?!1:(w&2)!==0),V?(S=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(w|=1),Ht(an,w&1),l===null)return zp(d),l=d.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((d.mode&1)===0?d.lanes=1:l.data==="$!"?d.lanes=8:d.lanes=1073741824,null):(I=x.children,l=x.fallback,S?(x=d.mode,S=d.child,I={mode:"hidden",children:I},(x&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=I):S=zu(I,x,0,null),l=bo(l,x,p,null),S.return=d,l.return=d,S.sibling=l,d.child=S,d.child.memoizedState=um(p),d.memoizedState=dm,l):hm(d,I));if(w=l.memoizedState,w!==null&&(V=w.dehydrated,V!==null))return Y3(l,d,I,x,V,w,p);if(S){S=x.fallback,I=d.mode,w=l.child,V=w.sibling;var Q={mode:"hidden",children:x.children};return(I&1)===0&&d.child!==w?(x=d.child,x.childLanes=0,x.pendingProps=Q,d.deletions=null):(x=mi(w,Q),x.subtreeFlags=w.subtreeFlags&14680064),V!==null?S=mi(V,S):(S=bo(S,I,p,null),S.flags|=2),S.return=d,x.return=d,x.sibling=S,d.child=x,x=S,S=d.child,I=l.child.memoizedState,I=I===null?um(p):{baseLanes:I.baseLanes|p,cachePool:null,transitions:I.transitions},S.memoizedState=I,S.childLanes=l.childLanes&~p,d.memoizedState=dm,x}return S=l.child,l=S.sibling,x=mi(S,{mode:"visible",children:x.children}),(d.mode&1)===0&&(x.lanes=p),x.return=d,x.sibling=null,l!==null&&(p=d.deletions,p===null?(d.deletions=[l],d.flags|=16):p.push(l)),d.child=x,d.memoizedState=null,x}function hm(l,d){return d=zu({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function Su(l,d,p,x){return x!==null&&Fp(x),ml(d,l.child,null,p),l=hm(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function Y3(l,d,p,x,w,S,I){if(p)return d.flags&256?(d.flags&=-257,x=im(Error(n(422))),Su(l,d,I,x)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(S=x.fallback,w=d.mode,x=zu({mode:"visible",children:x.children},w,0,null),S=bo(S,w,I,null),S.flags|=2,x.return=d,S.return=d,x.sibling=S,d.child=x,(d.mode&1)!==0&&ml(d,l.child,null,I),d.child.memoizedState=um(I),d.memoizedState=dm,S);if((d.mode&1)===0)return Su(l,d,I,null);if(w.data==="$!"){if(x=w.nextSibling&&w.nextSibling.dataset,x)var V=x.dgst;return x=V,S=Error(n(419)),x=im(S,x,void 0),Su(l,d,I,x)}if(V=(I&l.childLanes)!==0,Os||V){if(x=$n,x!==null){switch(I&-I){case 4:w=2;break;case 16:w=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:w=32;break;case 536870912:w=268435456;break;default:w=0}w=(w&(x.suspendedLanes|I))!==0?0:w,w!==0&&w!==S.retryLane&&(S.retryLane=w,Ca(l,w),Tr(x,l,w,-1))}return Tm(),x=im(Error(n(421))),Su(l,d,I,x)}return w.data==="$?"?(d.flags|=128,d.child=l.child,d=cE.bind(null,l),w._reactRetry=d,null):(l=S.treeContext,Ws=ri(w.nextSibling),Hs=d,nn=!0,kr=null,l!==null&&(sr[rr++]=ka,sr[rr++]=Sa,sr[rr++]=co,ka=l.id,Sa=l.overflow,co=d),d=hm(d,x.children),d.flags|=4096,d)}function Xb(l,d,p){l.lanes|=d;var x=l.alternate;x!==null&&(x.lanes|=d),Hp(l.return,d,p)}function fm(l,d,p,x,w){var S=l.memoizedState;S===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:x,tail:p,tailMode:w}:(S.isBackwards=d,S.rendering=null,S.renderingStartTime=0,S.last=x,S.tail=p,S.tailMode=w)}function Zb(l,d,p){var x=d.pendingProps,w=x.revealOrder,S=x.tail;if(ks(l,d,x.children,p),x=an.current,(x&2)!==0)x=x&1|2,d.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=d.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&Xb(l,p,d);else if(l.tag===19)Xb(l,p,d);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===d)break e;for(;l.sibling===null;){if(l.return===null||l.return===d)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}x&=1}if(Ht(an,x),(d.mode&1)===0)d.memoizedState=null;else switch(w){case"forwards":for(p=d.child,w=null;p!==null;)l=p.alternate,l!==null&&yu(l)===null&&(w=p),p=p.sibling;p=w,p===null?(w=d.child,d.child=null):(w=p.sibling,p.sibling=null),fm(d,!1,w,p,S);break;case"backwards":for(p=null,w=d.child,d.child=null;w!==null;){if(l=w.alternate,l!==null&&yu(l)===null){d.child=w;break}l=w.sibling,w.sibling=p,p=w,w=l}fm(d,!0,p,null,S);break;case"together":fm(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function Cu(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function Ta(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),mo|=d.lanes,(p&d.childLanes)===0)return null;if(l!==null&&d.child!==l.child)throw Error(n(153));if(d.child!==null){for(l=d.child,p=mi(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=mi(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function Q3(l,d,p){switch(d.tag){case 3:Jb(d),pl();break;case 5:fb(d);break;case 1:Ps(d.type)&&lu(d);break;case 4:Kp(d,d.stateNode.containerInfo);break;case 10:var x=d.type._context,w=d.memoizedProps.value;Ht(pu,x._currentValue),x._currentValue=w;break;case 13:if(x=d.memoizedState,x!==null)return x.dehydrated!==null?(Ht(an,an.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?Qb(l,d,p):(Ht(an,an.current&1),l=Ta(l,d,p),l!==null?l.sibling:null);Ht(an,an.current&1);break;case 19:if(x=(p&d.childLanes)!==0,(l.flags&128)!==0){if(x)return Zb(l,d,p);d.flags|=128}if(w=d.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),Ht(an,an.current),x)break;return null;case 22:case 23:return d.lanes=0,Kb(l,d,p)}return Ta(l,d,p)}var ev,pm,tv,nv;ev=function(l,d){for(var p=d.child;p!==null;){if(p.tag===5||p.tag===6)l.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},pm=function(){},tv=function(l,d,p,x){var w=l.memoizedProps;if(w!==x){l=d.stateNode,fo(Jr.current);var S=null;switch(p){case"input":w=at(l,w),x=at(l,x),S=[];break;case"select":w=U({},w,{value:void 0}),x=U({},x,{value:void 0}),S=[];break;case"textarea":w=ln(l,w),x=ln(l,x),S=[];break;default:typeof w.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=au)}ut(p,x);var I;p=null;for(fe in w)if(!x.hasOwnProperty(fe)&&w.hasOwnProperty(fe)&&w[fe]!=null)if(fe==="style"){var V=w[fe];for(I in V)V.hasOwnProperty(I)&&(p||(p={}),p[I]="")}else fe!=="dangerouslySetInnerHTML"&&fe!=="children"&&fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&fe!=="autoFocus"&&(a.hasOwnProperty(fe)?S||(S=[]):(S=S||[]).push(fe,null));for(fe in x){var Q=x[fe];if(V=w!=null?w[fe]:void 0,x.hasOwnProperty(fe)&&Q!==V&&(Q!=null||V!=null))if(fe==="style")if(V){for(I in V)!V.hasOwnProperty(I)||Q&&Q.hasOwnProperty(I)||(p||(p={}),p[I]="");for(I in Q)Q.hasOwnProperty(I)&&V[I]!==Q[I]&&(p||(p={}),p[I]=Q[I])}else p||(S||(S=[]),S.push(fe,p)),p=Q;else fe==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,V=V?V.__html:void 0,Q!=null&&V!==Q&&(S=S||[]).push(fe,Q)):fe==="children"?typeof Q!="string"&&typeof Q!="number"||(S=S||[]).push(fe,""+Q):fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&(a.hasOwnProperty(fe)?(Q!=null&&fe==="onScroll"&&Yt("scroll",l),S||V===Q||(S=[])):(S=S||[]).push(fe,Q))}p&&(S=S||[]).push("style",p);var fe=S;(d.updateQueue=fe)&&(d.flags|=4)}},nv=function(l,d,p,x){p!==x&&(d.flags|=4)};function Vc(l,d){if(!nn)switch(l.tailMode){case"hidden":d=l.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var x=null;p!==null;)p.alternate!==null&&(x=p),p=p.sibling;x===null?d||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function fs(l){var d=l.alternate!==null&&l.alternate.child===l.child,p=0,x=0;if(d)for(var w=l.child;w!==null;)p|=w.lanes|w.childLanes,x|=w.subtreeFlags&14680064,x|=w.flags&14680064,w.return=l,w=w.sibling;else for(w=l.child;w!==null;)p|=w.lanes|w.childLanes,x|=w.subtreeFlags,x|=w.flags,w.return=l,w=w.sibling;return l.subtreeFlags|=x,l.childLanes=p,d}function X3(l,d,p){var x=d.pendingProps;switch(Lp(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fs(d),null;case 1:return Ps(d.type)&&ou(),fs(d),null;case 3:return x=d.stateNode,yl(),Qt(Rs),Qt(us),Jp(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(hu(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,kr!==null&&(Sm(kr),kr=null))),pm(l,d),fs(d),null;case 5:qp(d);var w=fo(_c.current);if(p=d.type,l!==null&&d.stateNode!=null)tv(l,d,p,x,w),l.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!x){if(d.stateNode===null)throw Error(n(166));return fs(d),null}if(l=fo(Jr.current),hu(d)){x=d.stateNode,p=d.type;var S=d.memoizedProps;switch(x[Gr]=d,x[Rc]=S,l=(d.mode&1)!==0,p){case"dialog":Yt("cancel",x),Yt("close",x);break;case"iframe":case"object":case"embed":Yt("load",x);break;case"video":case"audio":for(w=0;w<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=I.createElement(p,{is:x.is}):(l=I.createElement(p),p==="select"&&(I=l,x.multiple?I.multiple=!0:x.size&&(I.size=x.size))):l=I.createElementNS(l,p),l[Gr]=d,l[Rc]=x,ev(l,d,!1,!1),d.stateNode=l;e:{switch(I=ot(p,x),p){case"dialog":Yt("cancel",l),Yt("close",l),w=x;break;case"iframe":case"object":case"embed":Yt("load",l),w=x;break;case"video":case"audio":for(w=0;wwl&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304)}else{if(!x)if(l=yu(I),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Vc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!I.alternate&&!nn)return fs(d),null}else 2*Jt()-S.renderingStartTime>wl&&p!==1073741824&&(d.flags|=128,x=!0,Vc(S,!1),d.lanes=4194304);S.isBackwards?(I.sibling=d.child,d.child=I):(p=S.last,p!==null?p.sibling=I:d.child=I,S.last=I)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=Jt(),d.sibling=null,p=an.current,Ht(an,x?p&1|2:p&1),d):(fs(d),null);case 22:case 23:return Em(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Us&1073741824)!==0&&(fs(d),d.subtreeFlags&6&&(d.flags|=8192)):fs(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function Z3(l,d){switch(Lp(d),d.tag){case 1:return Ps(d.type)&&ou(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return yl(),Qt(Rs),Qt(us),Jp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return qp(d),null;case 13:if(Qt(an),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));pl()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return Qt(an),null;case 4:return yl(),null;case 10:return Vp(d.type._context),null;case 22:case 23:return Em(),null;case 24:return null;default:return null}}var Eu=!1,ps=!1,eE=typeof WeakSet=="function"?WeakSet:Set,ze=null;function vl(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){un(l,d,x)}else p.current=null}function mm(l,d,p){try{p()}catch(x){un(l,d,x)}}var sv=!1;function tE(l,d){if(Ep=tl,l=Dy(),bp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var w=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var I=0,V=-1,Q=-1,fe=0,ke=0,Ce=l,je=null;t:for(;;){for(var Le;Ce!==p||w!==0&&Ce.nodeType!==3||(V=I+w),Ce!==S||x!==0&&Ce.nodeType!==3||(Q=I+x),Ce.nodeType===3&&(I+=Ce.nodeValue.length),(Le=Ce.firstChild)!==null;)je=Ce,Ce=Le;for(;;){if(Ce===l)break t;if(je===p&&++fe===w&&(V=I),je===S&&++ke===x&&(Q=I),(Le=Ce.nextSibling)!==null)break;Ce=je,je=Ce.parentNode}Ce=Le}p=V===-1||Q===-1?null:{start:V,end:Q}}else p=null}p=p||{start:0,end:0}}else p=null;for(Tp={focusedElem:l,selectionRange:p},tl=!1,ze=d;ze!==null;)if(d=ze,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,ze=l;else for(;ze!==null;){d=ze;try{var $e=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if($e!==null){var We=$e.memoizedProps,Nn=$e.memoizedState,oe=d.stateNode,ee=oe.getSnapshotBeforeUpdate(d.elementType===d.type?We:Sr(d.type,We),Nn);oe.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var ue=d.stateNode.containerInfo;ue.nodeType===1?ue.textContent="":ue.nodeType===9&&ue.documentElement&&ue.removeChild(ue.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){un(d,d.return,Re)}if(l=d.sibling,l!==null){l.return=d.return,ze=l;break}ze=d.return}return $e=sv,sv=!1,$e}function Hc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var w=x=x.next;do{if((w.tag&l)===l){var S=w.destroy;w.destroy=void 0,S!==void 0&&mm(d,p,S)}w=w.next}while(w!==x)}}function Tu(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var x=p.create;p.destroy=x()}p=p.next}while(p!==d)}}function gm(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function rv(l){var d=l.alternate;d!==null&&(l.alternate=null,rv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Gr],delete d[Rc],delete d[Rp],delete d[_3],delete d[z3])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function av(l){return l.tag===5||l.tag===3||l.tag===4}function iv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||av(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function xm(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=au));else if(x!==4&&(l=l.child,l!==null))for(xm(l,d,p),l=l.sibling;l!==null;)xm(l,d,p),l=l.sibling}function ym(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(ym(l,d,p),l=l.sibling;l!==null;)ym(l,d,p),l=l.sibling}var Yn=null,Cr=!1;function di(l,d,p){for(p=p.child;p!==null;)ov(l,d,p),p=p.sibling}function ov(l,d,p){if(Ns&&typeof Ns.onCommitFiberUnmount=="function")try{Ns.onCommitFiberUnmount(Br,p)}catch{}switch(p.tag){case 5:ps||vl(p,d);case 6:var x=Yn,w=Cr;Yn=null,di(l,d,p),Yn=x,Cr=w,Yn!==null&&(Cr?(l=Yn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):Yn.removeChild(p.stateNode));break;case 18:Yn!==null&&(Cr?(l=Yn,p=p.stateNode,l.nodeType===8?Ip(l.parentNode,p):l.nodeType===1&&Ip(l,p),ao(l)):Ip(Yn,p.stateNode));break;case 4:x=Yn,w=Cr,Yn=p.stateNode.containerInfo,Cr=!0,di(l,d,p),Yn=x,Cr=w;break;case 0:case 11:case 14:case 15:if(!ps&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){w=x=x.next;do{var S=w,I=S.destroy;S=S.tag,I!==void 0&&((S&2)!==0||(S&4)!==0)&&mm(p,d,I),w=w.next}while(w!==x)}di(l,d,p);break;case 1:if(!ps&&(vl(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(V){un(p,d,V)}di(l,d,p);break;case 21:di(l,d,p);break;case 22:p.mode&1?(ps=(x=ps)||p.memoizedState!==null,di(l,d,p),ps=x):di(l,d,p);break;default:di(l,d,p)}}function lv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new eE),d.forEach(function(x){var w=dE.bind(null,l,x);p.has(x)||(p.add(x),x.then(w,w))})}}function Er(l,d){var p=d.deletions;if(p!==null)for(var x=0;xw&&(w=I),x&=~S}if(x=w,x=Jt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*sE(x/1960))-x,10l?16:l,hi===null)var x=!1;else{if(l=hi,hi=null,Pu=0,(vt&6)!==0)throw Error(n(331));var w=vt;for(vt|=4,ze=l.current;ze!==null;){var S=ze,I=S.child;if((ze.flags&16)!==0){var V=S.deletions;if(V!==null){for(var Q=0;QJt()-Nm?xo(l,0):vm|=p),Ls(l,d)}function Nv(l,d){d===0&&((l.mode&1)===0?d=1:(d=ya,ya<<=1,(ya&130023424)===0&&(ya=4194304)));var p=Ss();l=Ca(l,d),l!==null&&(_e(l,d,p),Ls(l,p))}function cE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),Nv(l,p)}function dE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,w=l.memoizedState;w!==null&&(p=w.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),Nv(l,p)}var wv;wv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||Rs.current)Os=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return Os=!1,Q3(l,d,p);Os=(l.flags&131072)!==0}else Os=!1,nn&&(d.flags&1048576)!==0&&tb(d,uu,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;Cu(l,d),l=d.pendingProps;var w=ul(d,us.current);xl(d,p),w=Xp(null,d,x,l,w,p);var S=Zp();return d.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Ps(x)?(S=!0,lu(d)):S=!1,d.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Up(d),w.updater=ku,d.stateNode=w,w._reactInternals=d,am(d,x,l,p),d=cm(null,d,x,!0,S,p)):(d.tag=0,nn&&S&&Dp(d),ks(null,d,w,p),d=d.child),d;case 16:x=d.elementType;e:{switch(Cu(l,d),l=d.pendingProps,w=x._init,x=w(x._payload),d.type=x,w=d.tag=hE(x),l=Sr(x,l),w){case 0:d=lm(null,d,x,l,p);break e;case 1:d=Gb(null,d,x,l,p);break e;case 11:d=Hb(null,d,x,l,p);break e;case 14:d=Wb(null,d,x,Sr(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),lm(l,d,x,w,p);case 1:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Gb(l,d,x,w,p);case 3:e:{if(Jb(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,w=S.element,db(l,d),xu(d,x,null,p);var I=d.memoizedState;if(x=I.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){w=bl(Error(n(423)),d),d=Yb(l,d,x,p,w);break e}else if(x!==w){w=bl(Error(n(424)),d),d=Yb(l,d,x,p,w);break e}else for(Ws=ri(d.stateNode.containerInfo.firstChild),Hs=d,nn=!0,kr=null,p=lb(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(pl(),x===w){d=Ta(l,d,p);break e}ks(l,d,x,p)}d=d.child}return d;case 5:return fb(d),l===null&&zp(d),x=d.type,w=d.pendingProps,S=l!==null?l.memoizedProps:null,I=w.children,Mp(x,w)?I=null:S!==null&&Mp(x,S)&&(d.flags|=32),qb(l,d),ks(l,d,I,p),d.child;case 6:return l===null&&zp(d),null;case 13:return Qb(l,d,p);case 4:return Kp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=ml(d,null,x,p):ks(l,d,x,p),d.child;case 11:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Hb(l,d,x,w,p);case 7:return ks(l,d,d.pendingProps,p),d.child;case 8:return ks(l,d,d.pendingProps.children,p),d.child;case 12:return ks(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,w=d.pendingProps,S=d.memoizedProps,I=w.value,Ht(pu,x._currentValue),x._currentValue=I,S!==null)if(jr(S.value,I)){if(S.children===w.children&&!Rs.current){d=Ta(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var V=S.dependencies;if(V!==null){I=S.child;for(var Q=V.firstContext;Q!==null;){if(Q.context===x){if(S.tag===1){Q=Ea(-1,p&-p),Q.tag=2;var fe=S.updateQueue;if(fe!==null){fe=fe.shared;var ke=fe.pending;ke===null?Q.next=Q:(Q.next=ke.next,ke.next=Q),fe.pending=Q}}S.lanes|=p,Q=S.alternate,Q!==null&&(Q.lanes|=p),Hp(S.return,p,d),V.lanes|=p;break}Q=Q.next}}else if(S.tag===10)I=S.type===d.type?null:S.child;else if(S.tag===18){if(I=S.return,I===null)throw Error(n(341));I.lanes|=p,V=I.alternate,V!==null&&(V.lanes|=p),Hp(I,p,d),I=S.sibling}else I=S.child;if(I!==null)I.return=S;else for(I=S;I!==null;){if(I===d){I=null;break}if(S=I.sibling,S!==null){S.return=I.return,I=S;break}I=I.return}S=I}ks(l,d,w.children,p),d=d.child}return d;case 9:return w=d.type,x=d.pendingProps.children,xl(d,p),w=ar(w),x=x(w),d.flags|=1,ks(l,d,x,p),d.child;case 14:return x=d.type,w=Sr(x,d.pendingProps),w=Sr(x.type,w),Wb(l,d,x,w,p);case 15:return Ub(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,w=d.pendingProps,w=d.elementType===x?w:Sr(x,w),Cu(l,d),d.tag=1,Ps(x)?(l=!0,lu(d)):l=!1,xl(d,p),Lb(d,x,w),am(d,x,w,p),cm(null,d,x,!0,l,p);case 19:return Zb(l,d,p);case 22:return Kb(l,d,p)}throw Error(n(156,d.tag))};function jv(l,d){return Fr(l,d)}function uE(l,d,p,x){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lr(l,d,p,x){return new uE(l,d,p,x)}function Mm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function hE(l){if(typeof l=="function")return Mm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===z)return 11;if(l===_)return 14}return 2}function mi(l,d){var p=l.alternate;return p===null?(p=lr(l.tag,d,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=d,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,d=l.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function _u(l,d,p,x,w,S){var I=2;if(x=l,typeof l=="function")Mm(l)&&(I=1);else if(typeof l=="string")I=5;else e:switch(l){case L:return bo(p.children,w,S,d);case R:I=8,w|=8;break;case O:return l=lr(12,p,d,w|2),l.elementType=O,l.lanes=S,l;case ce:return l=lr(13,p,d,w),l.elementType=ce,l.lanes=S,l;case me:return l=lr(19,p,d,w),l.elementType=me,l.lanes=S,l;case $:return zu(p,w,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case se:I=10;break e;case ie:I=9;break e;case z:I=11;break e;case _:I=14;break e;case G:I=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=lr(I,p,d,w),d.elementType=l,d.type=x,d.lanes=S,d}function bo(l,d,p,x){return l=lr(7,l,x,d),l.lanes=p,l}function zu(l,d,p,x){return l=lr(22,l,x,d),l.elementType=$,l.lanes=p,l.stateNode={isHidden:!1},l}function Am(l,d,p){return l=lr(6,l,null,d),l.lanes=p,l}function Im(l,d,p){return d=lr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function fE(l,d,p,x,w){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pe(0),this.expirationTimes=Pe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pe(0),this.identifierPrefix=x,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function Rm(l,d,p,x,w,S,I,V,Q){return l=new fE(l,d,p,V,Q),d===1?(d=1,S===!0&&(d|=8)):d=0,S=lr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Up(S),l}function pE(l,d,p){var x=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),zm.exports=CE(),zm.exports}var _v;function EE(){if(_v)return Uu;_v=1;var t=Ww();return Uu.createRoot=t.createRoot,Uu.hydrateRoot=t.hydrateRoot,Uu}var TE=EE(),Bd=Ww();const Uw=Hw(Bd);/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. @@ -46,7 +46,7 @@ Error generating stack: `+S.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function wd(){return wd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Xx(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function AE(){return Math.random().toString(36).substr(2,8)}function $v(t,e){return{usr:t.state,key:t.key,idx:e}}function $g(t,e,n,s){return n===void 0&&(n=null),wd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Zl(e):e,{state:n,key:e&&e.key||s||AE()})}function Mh(t){let{pathname:e="/",search:n="",hash:s=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(e+=s.charAt(0)==="#"?s:"#"+s),e}function Zl(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substr(s),t=t.substr(0,s)),t&&(e.pathname=t)}return e}function IE(t,e,n,s){s===void 0&&(s={});let{window:a=document.defaultView,v5Compat:i=!1}=s,o=a.history,c=Ei.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(wd({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=Ei.Pop;let v=f(),k=v==null?null:v-h;h=v,u&&u({action:c,location:j.location,delta:k})}function g(v,k){c=Ei.Push;let C=$g(j.location,v,k);h=f()+1;let E=$v(C,h),M=j.createHref(C);try{o.pushState(E,"",M)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;a.location.assign(M)}i&&u&&u({action:c,location:j.location,delta:1})}function y(v,k){c=Ei.Replace;let C=$g(j.location,v,k);h=f();let E=$v(C,h),M=j.createHref(C);o.replaceState(E,"",M),i&&u&&u({action:c,location:j.location,delta:0})}function N(v){let k=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof v=="string"?v:Mh(v);return C=C.replace(/ $/,"%20"),wn(k,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,k)}let j={get action(){return c},get location(){return t(a,o)},listen(v){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(zv,m),u=v,()=>{a.removeEventListener(zv,m),u=null}},createHref(v){return e(a,v)},createURL:N,encodeLocation(v){let k=N(v);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(v){return o.go(v)}};return j}var Fv;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Fv||(Fv={}));function RE(t,e,n){return n===void 0&&(n="/"),PE(t,e,n)}function PE(t,e,n,s){let a=typeof e=="string"?Zl(e):e,i=Zx(a.pathname||"/",n);if(i==null)return null;let o=Kw(t);OE(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(wn(u.relativePath.startsWith(s),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(s.length));let h=Ri([s,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(wn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Kw(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:BE(h,i.index),routesMeta:f})};return t.forEach((i,o)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,o);else for(let u of qw(i.path))a(i,o,u)}),e}function qw(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=qw(s.join("/")),c=[];return c.push(...o.map(u=>u===""?i:[i,u].join("/"))),a&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function OE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:VE(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const DE=/^:[\w-]+$/,LE=3,_E=2,zE=1,$E=10,FE=-2,Bv=t=>t==="*";function BE(t,e){let n=t.split("/"),s=n.length;return n.some(Bv)&&(s+=FE),e&&(s+=_E),n.filter(a=>!Bv(a)).reduce((a,i)=>a+(DE.test(i)?LE:i===""?zE:$E),s)}function VE(t,e){return t.length===e.length&&t.slice(0,-1).every((s,a)=>s===e[a])?t[t.length-1]-e[e.length-1]:0}function HE(t,e,n){let{routesMeta:s}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let j=c[m]||"";o=i.slice(0,i.length-j.length).replace(/(.)\/+$/,"$1")}const N=c[m];return y&&!N?h[g]=void 0:h[g]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function UE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),Xx(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let s=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(s.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),s]}function KE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Xx(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function Zx(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}const qE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,GE=t=>qE.test(t);function JE(t,e){e===void 0&&(e="/");let{pathname:n,search:s="",hash:a=""}=typeof t=="string"?Zl(t):t,i;if(n)if(GE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Xx(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Vv(n.substring(1),"/"):i=Vv(n,e)}else i=e;return{pathname:i,search:XE(s),hash:ZE(a)}}function Vv(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Bm(t,e,n,s){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function YE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function e0(t,e){let n=YE(t);return e?n.map((s,a)=>a===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function t0(t,e,n,s){s===void 0&&(s=!1);let a;typeof t=="string"?a=Zl(t):(a=wd({},t),wn(!a.pathname||!a.pathname.includes("?"),Bm("?","pathname","search",a)),wn(!a.pathname||!a.pathname.includes("#"),Bm("#","pathname","hash",a)),wn(!a.search||!a.search.includes("#"),Bm("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!s&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=JE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Ri=t=>t.join("/").replace(/\/\/+/g,"/"),QE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),XE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ZE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function eT(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Gw=["post","put","patch","delete"];new Set(Gw);const tT=["get",...Gw];new Set(tT);/** + */function wd(){return wd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Xx(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function AE(){return Math.random().toString(36).substr(2,8)}function Fv(t,e){return{usr:t.state,key:t.key,idx:e}}function Fg(t,e,n,s){return n===void 0&&(n=null),wd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Zl(e):e,{state:n,key:e&&e.key||s||AE()})}function Mh(t){let{pathname:e="/",search:n="",hash:s=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(e+=s.charAt(0)==="#"?s:"#"+s),e}function Zl(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substr(s),t=t.substr(0,s)),t&&(e.pathname=t)}return e}function IE(t,e,n,s){s===void 0&&(s={});let{window:a=document.defaultView,v5Compat:i=!1}=s,o=a.history,c=Ti.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(wd({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=Ti.Pop;let v=f(),k=v==null?null:v-h;h=v,u&&u({action:c,location:j.location,delta:k})}function g(v,k){c=Ti.Push;let C=Fg(j.location,v,k);h=f()+1;let E=Fv(C,h),M=j.createHref(C);try{o.pushState(E,"",M)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;a.location.assign(M)}i&&u&&u({action:c,location:j.location,delta:1})}function y(v,k){c=Ti.Replace;let C=Fg(j.location,v,k);h=f();let E=Fv(C,h),M=j.createHref(C);o.replaceState(E,"",M),i&&u&&u({action:c,location:j.location,delta:0})}function N(v){let k=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof v=="string"?v:Mh(v);return C=C.replace(/ $/,"%20"),jn(k,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,k)}let j={get action(){return c},get location(){return t(a,o)},listen(v){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(zv,m),u=v,()=>{a.removeEventListener(zv,m),u=null}},createHref(v){return e(a,v)},createURL:N,encodeLocation(v){let k=N(v);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(v){return o.go(v)}};return j}var $v;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})($v||($v={}));function RE(t,e,n){return n===void 0&&(n="/"),PE(t,e,n)}function PE(t,e,n,s){let a=typeof e=="string"?Zl(e):e,i=Zx(a.pathname||"/",n);if(i==null)return null;let o=Kw(t);OE(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(jn(u.relativePath.startsWith(s),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(s.length));let h=Ri([s,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(jn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Kw(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:BE(h,i.index),routesMeta:f})};return t.forEach((i,o)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,o);else for(let u of qw(i.path))a(i,o,u)}),e}function qw(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=qw(s.join("/")),c=[];return c.push(...o.map(u=>u===""?i:[i,u].join("/"))),a&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function OE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:VE(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const DE=/^:[\w-]+$/,LE=3,_E=2,zE=1,FE=10,$E=-2,Bv=t=>t==="*";function BE(t,e){let n=t.split("/"),s=n.length;return n.some(Bv)&&(s+=$E),e&&(s+=_E),n.filter(a=>!Bv(a)).reduce((a,i)=>a+(DE.test(i)?LE:i===""?zE:FE),s)}function VE(t,e){return t.length===e.length&&t.slice(0,-1).every((s,a)=>s===e[a])?t[t.length-1]-e[e.length-1]:0}function HE(t,e,n){let{routesMeta:s}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let j=c[m]||"";o=i.slice(0,i.length-j.length).replace(/(.)\/+$/,"$1")}const N=c[m];return y&&!N?h[g]=void 0:h[g]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function UE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),Xx(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let s=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(s.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),s]}function KE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Xx(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function Zx(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}const qE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,GE=t=>qE.test(t);function JE(t,e){e===void 0&&(e="/");let{pathname:n,search:s="",hash:a=""}=typeof t=="string"?Zl(t):t,i;if(n)if(GE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Xx(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Vv(n.substring(1),"/"):i=Vv(n,e)}else i=e;return{pathname:i,search:XE(s),hash:ZE(a)}}function Vv(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Bm(t,e,n,s){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function YE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function e0(t,e){let n=YE(t);return e?n.map((s,a)=>a===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function t0(t,e,n,s){s===void 0&&(s=!1);let a;typeof t=="string"?a=Zl(t):(a=wd({},t),jn(!a.pathname||!a.pathname.includes("?"),Bm("?","pathname","search",a)),jn(!a.pathname||!a.pathname.includes("#"),Bm("#","pathname","hash",a)),jn(!a.search||!a.search.includes("#"),Bm("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!s&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=JE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Ri=t=>t.join("/").replace(/\/\/+/g,"/"),QE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),XE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ZE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function eT(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Gw=["post","put","patch","delete"];new Set(Gw);const tT=["get",...Gw];new Set(tT);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. @@ -55,7 +55,7 @@ Error generating stack: `+S.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function jd(){return jd=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){s.go(h);return}let m=t0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Ri([e,m.pathname])),(f.replace?s.replace:s.push)(m,f.state,f)},[e,s,o,i,t])}const aT=b.createContext(null);function iT(t){let e=b.useContext(Ka).outlet;return e&&b.createElement(aT.Provider,{value:t},e)}function Qw(t,e){let{relative:n}=e===void 0?{}:e,{future:s}=b.useContext(Wi),{matches:a}=b.useContext(Ka),{pathname:i}=Ui(),o=JSON.stringify(e0(a,s.v7_relativeSplatPath));return b.useMemo(()=>t0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function oT(t,e){return lT(t,e)}function lT(t,e,n,s){ec()||wn(!1);let{navigator:a}=b.useContext(Wi),{matches:i}=b.useContext(Ka),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Ui(),f;if(e){var m;let v=typeof e=="string"?Zl(e):e;u==="/"||(m=v.pathname)!=null&&m.startsWith(u)||wn(!1),f=v}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let v=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(v.length).join("/")}let N=RE(t,{pathname:y}),j=fT(N&&N.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:Ri([u,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:Ri([u,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,n,s);return e&&j?b.createElement(Pf.Provider,{value:{location:jd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Ei.Pop}},j):j}function cT(){let t=xT(),e=eT(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),n?b.createElement("pre",{style:a},n):null,null)}const dT=b.createElement(cT,null);class uT extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?b.createElement(Ka.Provider,{value:this.props.routeContext},b.createElement(Jw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function hT(t){let{routeContext:e,match:n,children:s}=t,a=b.useContext(n0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(Ka.Provider,{value:e},s)}function fT(t,e,n,s){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),s===void 0&&(s=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=s)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(a=n)==null?void 0:a.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||wn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&s&&s.v7_partialHydration)for(let f=0;f=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,N=!1,j=null,v=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,j=m.route.errorElement||dT,u&&(h<0&&g===0?(bT("route-fallback"),N=!0,v=null):h===g&&(N=!0,v=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),C=()=>{let E;return y?E=j:N?E=v:m.route.Component?E=b.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,b.createElement(hT,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(uT,{location:n.location,revalidation:n.revalidation,component:j,error:y,children:C(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):C()},null)}var Xw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Xw||{}),Zw=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(Zw||{});function pT(t){let e=b.useContext(n0);return e||wn(!1),e}function mT(t){let e=b.useContext(nT);return e||wn(!1),e}function gT(t){let e=b.useContext(Ka);return e||wn(!1),e}function ej(t){let e=gT(),n=e.matches[e.matches.length-1];return n.route.id||wn(!1),n.route.id}function xT(){var t;let e=b.useContext(Jw),n=mT(),s=ej();return e!==void 0?e:(t=n.errors)==null?void 0:t[s]}function yT(){let{router:t}=pT(Xw.UseNavigateStable),e=ej(Zw.UseNavigateStable),n=b.useRef(!1);return Yw(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,jd({fromRouteId:e},i)))},[t,e])}const Hv={};function bT(t,e,n){Hv[t]||(Hv[t]=!0)}function vT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Vm(t){let{to:e,replace:n,state:s,relative:a}=t;ec()||wn(!1);let{future:i,static:o}=b.useContext(Wi),{matches:c}=b.useContext(Ka),{pathname:u}=Ui(),h=Ki(),f=t0(e,e0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:s,relative:a}),[h,m,a,n,s]),null}function NT(t){return iT(t.context)}function Bt(t){wn(!1)}function wT(t){let{basename:e="/",children:n=null,location:s,navigationType:a=Ei.Pop,navigator:i,static:o=!1,future:c}=t;ec()&&wn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:jd({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof s=="string"&&(s=Zl(s));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:N="default"}=s,j=b.useMemo(()=>{let v=Zx(f,u);return v==null?null:{location:{pathname:v,search:m,hash:g,state:y,key:N},navigationType:a}},[u,f,m,g,y,N,a]);return j==null?null:b.createElement(Wi.Provider,{value:h},b.createElement(Pf.Provider,{children:n,value:j}))}function jT(t){let{children:e,location:n}=t;return oT(Fg(e),n)}new Promise(()=>{});function Fg(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(s,a)=>{if(!b.isValidElement(s))return;let i=[...e,a];if(s.type===b.Fragment){n.push.apply(n,Fg(s.props.children,i));return}s.type!==Bt&&wn(!1),!s.props.index||!s.props.children||wn(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=Fg(s.props.children,i)),n.push(o)}),n}/** + */function jd(){return jd=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){s.go(h);return}let m=t0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Ri([e,m.pathname])),(f.replace?s.replace:s.push)(m,f.state,f)},[e,s,o,i,t])}const aT=b.createContext(null);function iT(t){let e=b.useContext(qa).outlet;return e&&b.createElement(aT.Provider,{value:t},e)}function Qw(t,e){let{relative:n}=e===void 0?{}:e,{future:s}=b.useContext(Wi),{matches:a}=b.useContext(qa),{pathname:i}=Ui(),o=JSON.stringify(e0(a,s.v7_relativeSplatPath));return b.useMemo(()=>t0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function oT(t,e){return lT(t,e)}function lT(t,e,n,s){ec()||jn(!1);let{navigator:a}=b.useContext(Wi),{matches:i}=b.useContext(qa),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Ui(),f;if(e){var m;let v=typeof e=="string"?Zl(e):e;u==="/"||(m=v.pathname)!=null&&m.startsWith(u)||jn(!1),f=v}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let v=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(v.length).join("/")}let N=RE(t,{pathname:y}),j=fT(N&&N.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:Ri([u,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:Ri([u,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,n,s);return e&&j?b.createElement(Pf.Provider,{value:{location:jd({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Ti.Pop}},j):j}function cT(){let t=xT(),e=eT(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),n?b.createElement("pre",{style:a},n):null,null)}const dT=b.createElement(cT,null);class uT extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?b.createElement(qa.Provider,{value:this.props.routeContext},b.createElement(Jw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function hT(t){let{routeContext:e,match:n,children:s}=t,a=b.useContext(n0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(qa.Provider,{value:e},s)}function fT(t,e,n,s){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),s===void 0&&(s=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=s)!=null&&i.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(a=n)==null?void 0:a.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||jn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&s&&s.v7_partialHydration)for(let f=0;f=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,N=!1,j=null,v=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,j=m.route.errorElement||dT,u&&(h<0&&g===0?(bT("route-fallback"),N=!0,v=null):h===g&&(N=!0,v=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),C=()=>{let E;return y?E=j:N?E=v:m.route.Component?E=b.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,b.createElement(hT,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(uT,{location:n.location,revalidation:n.revalidation,component:j,error:y,children:C(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):C()},null)}var Xw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Xw||{}),Zw=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(Zw||{});function pT(t){let e=b.useContext(n0);return e||jn(!1),e}function mT(t){let e=b.useContext(nT);return e||jn(!1),e}function gT(t){let e=b.useContext(qa);return e||jn(!1),e}function ej(t){let e=gT(),n=e.matches[e.matches.length-1];return n.route.id||jn(!1),n.route.id}function xT(){var t;let e=b.useContext(Jw),n=mT(),s=ej();return e!==void 0?e:(t=n.errors)==null?void 0:t[s]}function yT(){let{router:t}=pT(Xw.UseNavigateStable),e=ej(Zw.UseNavigateStable),n=b.useRef(!1);return Yw(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,jd({fromRouteId:e},i)))},[t,e])}const Hv={};function bT(t,e,n){Hv[t]||(Hv[t]=!0)}function vT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Vm(t){let{to:e,replace:n,state:s,relative:a}=t;ec()||jn(!1);let{future:i,static:o}=b.useContext(Wi),{matches:c}=b.useContext(qa),{pathname:u}=Ui(),h=Ki(),f=t0(e,e0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:s,relative:a}),[h,m,a,n,s]),null}function NT(t){return iT(t.context)}function Wt(t){jn(!1)}function wT(t){let{basename:e="/",children:n=null,location:s,navigationType:a=Ti.Pop,navigator:i,static:o=!1,future:c}=t;ec()&&jn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:jd({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof s=="string"&&(s=Zl(s));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:N="default"}=s,j=b.useMemo(()=>{let v=Zx(f,u);return v==null?null:{location:{pathname:v,search:m,hash:g,state:y,key:N},navigationType:a}},[u,f,m,g,y,N,a]);return j==null?null:b.createElement(Wi.Provider,{value:h},b.createElement(Pf.Provider,{children:n,value:j}))}function jT(t){let{children:e,location:n}=t;return oT($g(e),n)}new Promise(()=>{});function $g(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(s,a)=>{if(!b.isValidElement(s))return;let i=[...e,a];if(s.type===b.Fragment){n.push.apply(n,$g(s.props.children,i));return}s.type!==Wt&&jn(!1),!s.props.index||!s.props.children||jn(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=$g(s.props.children,i)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. @@ -79,17 +79,17 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const $T=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...zT,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:nj("lucide",a),...!i&&!_T(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>b.createElement(h,f)),...Array.isArray(i)?i:[i]]));/** + */const FT=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...zT,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:nj("lucide",a),...!i&&!_T(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>b.createElement(h,f)),...Array.isArray(i)?i:[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 Ie=(t,e)=>{const n=b.forwardRef(({className:s,...a},i)=>b.createElement($T,{ref:i,iconNode:e,className:nj(`lucide-${DT(qv(t))}`,`lucide-${t}`,s),...a}));return n.displayName=qv(t),n};/** + */const Ie=(t,e)=>{const n=b.forwardRef(({className:s,...a},i)=>b.createElement(FT,{ref:i,iconNode:e,className:nj(`lucide-${DT(qv(t))}`,`lucide-${t}`,s),...a}));return n.displayName=qv(t),n};/** * @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 FT=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Hm=Ie("arrow-up-down",FT);/** + */const $T=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Hm=Ie("arrow-up-down",$T);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -104,7 +104,7 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const WT=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Gs=Ie("book-open",WT);/** + */const WT=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Ys=Ie("book-open",WT);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -199,7 +199,7 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const hM=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],$l=Ie("crown",hM);/** + */const hM=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],Fl=Ie("crown",hM);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -294,12 +294,12 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const $M=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ku=Ie("info",$M);/** + */const FM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ku=Ie("info",FM);/** * @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 FM=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],BM=Ie("italic",FM);/** + */const $M=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],BM=Ie("italic",$M);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -314,7 +314,7 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const UM=[["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"}]],Ir=Ie("link-2",UM);/** + */const UM=[["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"}]],Rr=Ie("link-2",UM);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -374,7 +374,7 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const u5=[["path",{d:"M13 21h8",key:"1jsn5i"}],["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"}]],Vt=Ie("pen-line",u5);/** + */const u5=[["path",{d:"M13 21h8",key:"1jsn5i"}],["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"}]],Ut=Ie("pen-line",u5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -419,17 +419,17 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const S5=[["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"}]],$e=Ie("refresh-cw",S5);/** + */const S5=[["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"}]],Fe=Ie("refresh-cw",S5);/** * @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 C5=[["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"}]],Nn=Ie("save",C5);/** + */const C5=[["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"}]],wn=Ie("save",C5);/** * @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 E5=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Fa=Ie("search",E5);/** + */const E5=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ba=Ie("search",E5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -474,17 +474,17 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const z5=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],$5=Ie("table",z5);/** + */const z5=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],F5=Ie("table",z5);/** * @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 F5=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],ld=Ie("tag",F5);/** + */const $5=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],ld=Ie("tag",$5);/** * @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 B5=[["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"}]],Yn=Ie("trash-2",B5);/** + */const B5=[["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"}]],Zn=Ie("trash-2",B5);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -534,17 +534,17 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const X5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],hs=Ie("x",X5);/** + */const X5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gs=Ie("x",X5);/** * @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 Z5=[["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"}]],Ti=Ie("zap",Z5),r0="admin_token";function Df(){try{return localStorage.getItem(r0)}catch{return null}}function eA(t){try{localStorage.setItem(r0,t)}catch{}}function Um(){try{localStorage.removeItem(r0)}catch{}}const tA="https://soulapi.quwanzhi.com",nA=15e3,Zv=6e4,sA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):tA};function Lo(t){const e=sA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Lf(t,e={}){const{data:n,...s}=e,a=Lo(t),i=new Headers(s.headers),o=Df();o&&i.set("Authorization",`Bearer ${o}`),n!=null&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):s.body,u=s.timeout??nA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...s,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),y=(m.headers.get("Content-Type")||"").includes("application/json")?await m.json():m,N=j=>{const v=j,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(y);const j=new Error((y==null?void 0:y.error)||`HTTP ${m.status}`);throw j.status=m.status,j.data=y,j}return N(y),y}function De(t,e){return Lf(t,{...e,method:"GET"})}function Nt(t,e,n){return Lf(t,{...n,method:"POST",data:e})}function Dt(t,e,n){return Lf(t,{...n,method:"PUT",data:e})}function ea(t,e){return Lf(t,{...e,method:"DELETE"})}function rA(){const[t,e]=b.useState(!1),[n,s]=b.useState("");return b.useEffect(()=>{const a=i=>{const o=i.detail;s(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?r.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(rj,{className:"w-5 h-5 shrink-0 text-red-400"}),r.jsxs("span",{className:"text-sm font-medium",children:[n,r.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),r.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:r.jsx(hs,{className:"w-4 h-4"})})]}):null}const aA=[{icon:WM,label:"数据概览",href:"/dashboard"},{icon:Gs,label:"内容管理",href:"/content"},{icon:_n,label:"用户管理",href:"/users"},{icon:wM,label:"找伙伴",href:"/find-partner"},{icon:Wl,label:"推广中心",href:"/distribution"}];function iA(){const t=Ui(),e=Ki(),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{s(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!Df()){e("/login",{replace:!0});return}return De("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(Um(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(Um(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{Um();try{await Nt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[r.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[r.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),r.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[aA.map(c=>{const u=t.pathname===c.href;return r.jsxs(Hg,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),r.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:r.jsxs(Hg,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(Mo,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),r.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:r.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[r.jsx(e5,{className:"w-5 h-5"}),r.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),r.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[r.jsx(rA,{}),r.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:r.jsx(NT,{})})]})]})}function e1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function a0(...t){return e=>{let n=!1;const s=t.map(a=>{const i=e1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=s;pj(i)&&typeof Ph=="function"&&(i=Ph(i._payload));const c=b.Children.toArray(i),u=c.find(uA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var gj=mj("Slot");function cA(t){const e=b.forwardRef((n,s)=>{let{children:a,...i}=n;if(pj(a)&&typeof Ph=="function"&&(a=Ph(a._payload)),b.isValidElement(a)){const o=fA(a),c=hA(i,a.props);return a.type!==b.Fragment&&(c.ref=s?a0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dA=Symbol("radix.slottable");function uA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dA}function hA(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function fA(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function xj(t){var e,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,n1=yj,bj=(t,e)=>n=>{var s;if((e==null?void 0:e.variants)==null)return n1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=e,o=Object.keys(a).map(h=>{const f=n==null?void 0:n[h],m=i==null?void 0:i[h];if(f===null)return null;const g=t1(f)||t1(m);return a[h][g]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,g]=f;return g===void 0||(h[m]=g),h},{}),u=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(N=>{let[j,v]=N;return Array.isArray(v)?v.includes({...i,...c}[j]):{...i,...c}[j]===v})?[...h,m,g]:h},[]);return n1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},pA=(t,e)=>{const n=new Array(t.length+e.length);for(let s=0;s({classGroupId:t,validator:e}),vj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Oh="-",s1=[],gA="arbitrary..",xA=t=>{const e=bA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return yA(o);const c=o.split(Oh),u=c[0]===""&&c.length>1?1:0;return Nj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=s[o],h=n[o];return u?h?pA(h,u):u:h||s1}return n[o]||s1}}},Nj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=Nj(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Oh):t.slice(e).join(Oh),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),s=e.slice(0,n);return s?gA+s:void 0})(),bA=t=>{const{theme:e,classGroups:n}=t;return vA(n,e)},vA=(t,e)=>{const n=vj();for(const s in t){const a=t[s];i0(a,n,s,e)}return n},i0=(t,e,n,s)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){wA(t,e,n);return}if(typeof t=="function"){jA(t,e,n,s);return}kA(t,e,n,s)},wA=(t,e,n)=>{const s=t===""?e:wj(e,t);s.classGroupId=n},jA=(t,e,n,s)=>{if(SA(t)){i0(t(s),e,n,s);return}e.validators===null&&(e.validators=[]),e.validators.push(mA(n,t))},kA=(t,e,n,s)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const s=e.split(Oh),a=s.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,CA=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),s=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,s=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=s[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},Zg="!",r1=":",EA=[],a1=(t,e,n,s,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:s,isExternal:a}),TA=t=>{const{prefix:e,experimentalParseClassName:n}=t;let s=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let j=0;ju?h-u:void 0;return a1(i,y,g,N)};if(e){const a=e+r1,i=s;s=o=>o.startsWith(a)?i(o.slice(a.length)):a1(EA,!1,o,void 0,!0)}if(n){const a=s;s=i=>n({className:i,parseClassName:a})}return s},MA=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,s)=>{e.set(n,1e6+s)}),n=>{const s=[];let a=[];for(let i=0;i0&&(a.sort(),s.push(...a),a=[]),s.push(o)):a.push(o)}return a.length>0&&(a.sort(),s.push(...a)),s}},AA=t=>({cache:CA(t.cacheSize),parseClassName:TA(t),sortModifiers:MA(t),...xA(t)}),IA=/\s+/,RA=(t,e)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(IA);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:N,maybePostfixModifierPosition:j}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!j,k=s(v?N.substring(0,j):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=s(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const C=g.length===0?"":g.length===1?g[0]:i(g).join(":"),E=y?C+Zg:C,M=E+k;if(o.indexOf(M)>-1)continue;o.push(M);const P=a(k,v);for(let H=0;H0?" "+u:u)}return u},PA=(...t)=>{let e=0,n,s,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let s=0;s{let n,s,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=AA(h),s=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=s(u);if(h)return h;const f=RA(u,n);return a(u,f),f};return i=o,(...u)=>i(PA(...u))},DA=[],Dn=t=>{const e=n=>n[t]||DA;return e.isThemeGetter=!0,e},kj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Sj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,LA=/^\d+\/\d+$/,_A=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,zA=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,$A=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,FA=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,BA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kl=t=>LA.test(t),pt=t=>!!t&&!Number.isNaN(Number(t)),gi=t=>!!t&&Number.isInteger(Number(t)),Km=t=>t.endsWith("%")&&pt(t.slice(0,-1)),Ia=t=>_A.test(t),VA=()=>!0,HA=t=>zA.test(t)&&!$A.test(t),Cj=()=>!1,WA=t=>FA.test(t),UA=t=>BA.test(t),KA=t=>!Be(t)&&!Ve(t),qA=t=>tc(t,Mj,Cj),Be=t=>kj.test(t),vo=t=>tc(t,Aj,HA),qm=t=>tc(t,XA,pt),i1=t=>tc(t,Ej,Cj),GA=t=>tc(t,Tj,UA),Gu=t=>tc(t,Ij,WA),Ve=t=>Sj.test(t),Jc=t=>nc(t,Aj),JA=t=>nc(t,ZA),o1=t=>nc(t,Ej),YA=t=>nc(t,Mj),QA=t=>nc(t,Tj),Ju=t=>nc(t,Ij,!0),tc=(t,e,n)=>{const s=kj.exec(t);return s?s[1]?e(s[1]):n(s[2]):!1},nc=(t,e,n=!1)=>{const s=Sj.exec(t);return s?s[1]?e(s[1]):n:!1},Ej=t=>t==="position"||t==="percentage",Tj=t=>t==="image"||t==="url",Mj=t=>t==="length"||t==="size"||t==="bg-size",Aj=t=>t==="length",XA=t=>t==="number",ZA=t=>t==="family-name",Ij=t=>t==="shadow",eI=()=>{const t=Dn("color"),e=Dn("font"),n=Dn("text"),s=Dn("font-weight"),a=Dn("tracking"),i=Dn("leading"),o=Dn("breakpoint"),c=Dn("container"),u=Dn("spacing"),h=Dn("radius"),f=Dn("shadow"),m=Dn("inset-shadow"),g=Dn("text-shadow"),y=Dn("drop-shadow"),N=Dn("blur"),j=Dn("perspective"),v=Dn("aspect"),k=Dn("ease"),C=Dn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...M(),Ve,Be],H=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto","contain","none"],R=()=>[Ve,Be,u],O=()=>[kl,"full","auto",...R()],ne=()=>[gi,"none","subgrid",Ve,Be],ie=()=>["auto",{span:["full",gi,Ve,Be]},gi,Ve,Be],_=()=>[gi,"auto",Ve,Be],ce=()=>["auto","min","max","fr",Ve,Be],pe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],q=()=>["auto",...R()],F=()=>[kl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],A=()=>[t,Ve,Be],J=()=>[...M(),o1,i1,{position:[Ve,Be]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],D=()=>["auto","cover","contain",YA,qA,{size:[Ve,Be]}],W=()=>[Km,Jc,vo],le=()=>["","none","full",h,Ve,Be],xe=()=>["",pt,Jc,vo],Me=()=>["solid","dashed","dotted","double"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[pt,Km,o1,i1],G=()=>["","none",N,Ve,Be],ge=()=>["none",pt,Ve,Be],ae=()=>["none",pt,Ve,Be],fe=()=>[pt,Ve,Be],Se=()=>[kl,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ia],breakpoint:[Ia],color:[VA],container:[Ia],"drop-shadow":[Ia],ease:["in","out","in-out"],font:[KA],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ia],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ia],shadow:[Ia],spacing:["px",pt],text:[Ia],"text-shadow":[Ia],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kl,Be,Ve,v]}],container:["container"],columns:[{columns:[pt,Be,Ve,c]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[gi,"auto",Ve,Be]}],basis:[{basis:[kl,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[pt,kl,"auto","initial","none",Be]}],grow:[{grow:["",pt,Ve,Be]}],shrink:[{shrink:["",pt,Ve,Be]}],order:[{order:[gi,"first","last","none",Ve,Be]}],"grid-cols":[{"grid-cols":ne()}],"col-start-end":[{col:ie()}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":ne()}],"row-start-end":[{row:ie()}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ce()}],"auto-rows":[{"auto-rows":ce()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...pe(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...pe()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":pe()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:q()}],mx:[{mx:q()}],my:[{my:q()}],ms:[{ms:q()}],me:[{me:q()}],mt:[{mt:q()}],mr:[{mr:q()}],mb:[{mb:q()}],ml:[{ml:q()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],w:[{w:[c,"screen",...F()]}],"min-w":[{"min-w":[c,"screen","none",...F()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,Jc,vo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,Ve,qm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Km,Be]}],"font-family":[{font:[JA,Be,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,Ve,Be]}],"line-clamp":[{"line-clamp":[pt,"none",Ve,qm]}],leading:[{leading:[i,...R()]}],"list-image":[{"list-image":["none",Ve,Be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ve,Be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Me(),"wavy"]}],"text-decoration-thickness":[{decoration:[pt,"from-font","auto",Ve,vo]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[pt,"auto",Ve,Be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ve,Be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ve,Be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:D()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},gi,Ve,Be],radial:["",Ve,Be],conic:[gi,Ve,Be]},QA,GA]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:xe()}],"border-w-x":[{"border-x":xe()}],"border-w-y":[{"border-y":xe()}],"border-w-s":[{"border-s":xe()}],"border-w-e":[{"border-e":xe()}],"border-w-t":[{"border-t":xe()}],"border-w-r":[{"border-r":xe()}],"border-w-b":[{"border-b":xe()}],"border-w-l":[{"border-l":xe()}],"divide-x":[{"divide-x":xe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":xe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Me(),"hidden","none"]}],"divide-style":[{divide:[...Me(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...Me(),"none","hidden"]}],"outline-offset":[{"outline-offset":[pt,Ve,Be]}],"outline-w":[{outline:["",pt,Jc,vo]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",f,Ju,Gu]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",m,Ju,Gu]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:xe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[pt,vo]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":xe()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",g,Ju,Gu]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[pt,Ve,Be]}],"mix-blend":[{"mix-blend":[...te(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":te()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[pt]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[Ve,Be]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[pt]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:D()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ve,Be]}],filter:[{filter:["","none",Ve,Be]}],blur:[{blur:G()}],brightness:[{brightness:[pt,Ve,Be]}],contrast:[{contrast:[pt,Ve,Be]}],"drop-shadow":[{"drop-shadow":["","none",y,Ju,Gu]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",pt,Ve,Be]}],"hue-rotate":[{"hue-rotate":[pt,Ve,Be]}],invert:[{invert:["",pt,Ve,Be]}],saturate:[{saturate:[pt,Ve,Be]}],sepia:[{sepia:["",pt,Ve,Be]}],"backdrop-filter":[{"backdrop-filter":["","none",Ve,Be]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[pt,Ve,Be]}],"backdrop-contrast":[{"backdrop-contrast":[pt,Ve,Be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",pt,Ve,Be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[pt,Ve,Be]}],"backdrop-invert":[{"backdrop-invert":["",pt,Ve,Be]}],"backdrop-opacity":[{"backdrop-opacity":[pt,Ve,Be]}],"backdrop-saturate":[{"backdrop-saturate":[pt,Ve,Be]}],"backdrop-sepia":[{"backdrop-sepia":["",pt,Ve,Be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ve,Be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[pt,"initial",Ve,Be]}],ease:[{ease:["linear","initial",k,Ve,Be]}],delay:[{delay:[pt,Ve,Be]}],animate:[{animate:["none",C,Ve,Be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,Ve,Be]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:fe()}],"skew-x":[{"skew-x":fe()}],"skew-y":[{"skew-y":fe()}],transform:[{transform:[Ve,Be,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ve,Be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ve,Be]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[pt,Jc,vo,qm]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},tI=OA(eI);function Mt(...t){return tI(yj(t))}const nI=bj("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function X({className:t,variant:e,size:n,asChild:s=!1,...a}){const i=s?gj:"button";return r.jsx(i,{"data-slot":"button",className:Mt(nI({variant:e,size:n,className:t})),...a})}function re({className:t,type:e,...n}){return r.jsx("input",{type:e,"data-slot":"input",className:Mt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 md:text-sm focus-visible:ring-2 focus-visible:ring-ring",t),...n})}function sI(){const t=Ki(),[e,n]=b.useState(""),[s,a]=b.useState(""),[i,o]=b.useState(""),[c,u]=b.useState(!1),h=async()=>{o(""),u(!0);try{const f=await Nt("/api/admin",{username:e.trim(),password:s});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){eA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return r.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[r.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[r.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),r.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),r.jsxs("div",{className:"w-full max-w-md relative z-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:r.jsx(od,{className:"w-8 h-8 text-[#38bdac]"})}),r.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),r.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),r.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[r.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ao,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"text",value:e,onChange:f=>n(f.target.value),placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),r.jsxs("div",{className:"relative",children:[r.jsx(XM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"password",value:s,onChange:f=>a(f.target.value),placeholder:"请输入密码",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]",onKeyDown:f=>f.key==="Enter"&&h()})]})]}),i&&r.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),r.jsx(X,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),r.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Ee=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Ee.displayName="Card";const Je=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("flex flex-col space-y-1.5 p-6",t),...e}));Je.displayName="CardHeader";const Ye=b.forwardRef(({className:t,...e},n)=>r.jsx("h3",{ref:n,className:Mt("font-semibold leading-none tracking-tight",t),...e}));Ye.displayName="CardTitle";const Lt=b.forwardRef(({className:t,...e},n)=>r.jsx("p",{ref:n,className:Mt("text-sm text-muted-foreground",t),...e}));Lt.displayName="CardDescription";const Te=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("p-6 pt-0",t),...e}));Te.displayName="CardContent";const rI=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("flex items-center p-6 pt-0",t),...e}));rI.displayName="CardFooter";const aI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Gm(t,e="info",n=3e3){const s=`toast-${Date.now()}`,a=aI[e],i=document.createElement("div");i.id=s,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(s),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const se={success:(t,e)=>Gm(t,"success",e),error:(t,e)=>Gm(t,"error",e),info:(t,e)=>Gm(t,"info",e)};function ht(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function iI(t,e){const n=b.createContext(e),s=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:u,children:o})};s.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[s,a]}function qi(t,e=[]){let n=[];function s(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:g,children:y,...N}=m,j=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,v=b.useMemo(()=>N,Object.values(N));return r.jsx(j.Provider,{value:v,children:y})};h.displayName=i+"Provider";function f(m,g){var j;const y=((j=g==null?void 0:g[t])==null?void 0:j[u])||c,N=b.useContext(y);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[s,oI(a,...e)]}function oI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const s=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var fs=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},lI=Rf[" useId ".trim().toString()]||(()=>{}),cI=0;function Pi(t){const[e,n]=b.useState(lI());return fs(()=>{n(s=>s??String(cI++))},[t]),e?`radix-${e}`:""}var dI=Rf[" useInsertionEffect ".trim().toString()]||fs;function _o({prop:t,defaultProp:e,onChange:n=()=>{},caller:s}){const[a,i,o]=uI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,s])}const h=b.useCallback(f=>{var m;if(c){const g=hI(f)?f(t):f;g!==t&&((m=o.current)==null||m.call(o,g))}else i(f)},[c,t,i,o]);return[u,h]}function uI({defaultProp:t,onChange:e}){const[n,s]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return dI(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,s,i]}function hI(t){return typeof t=="function"}function Sd(t){const e=fI(t),n=b.forwardRef((s,a)=>{const{children:i,...o}=s,c=b.Children.toArray(i),u=c.find(mI);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function fI(t){const e=b.forwardRef((n,s)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=xI(a),c=gI(i,a.props);return a.type!==b.Fragment&&(c.ref=s?a0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pI=Symbol("radix.slottable");function mI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pI}function gI(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function xI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var yI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mt=yI.reduce((t,e)=>{const n=Sd(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function bI(t,e){t&&Bd.flushSync(()=>t.dispatchEvent(e))}function $i(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var s;return(s=e.current)==null?void 0:s.call(e,...n)},[])}function vI(t,e=globalThis==null?void 0:globalThis.document){const n=$i(t);b.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",s,{capture:!0}),()=>e.removeEventListener("keydown",s,{capture:!0})},[n,e])}var NI="DismissableLayer",ex="dismissableLayer.update",wI="dismissableLayer.pointerDownOutside",jI="dismissableLayer.focusOutside",l1,Rj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),o0=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(Rj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),N=Tt(e,L=>m(L)),j=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=j.indexOf(v),C=f?j.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,M=C>=k,P=CI(L=>{const R=L.target,O=[...h.branches].some(ne=>ne.contains(R));!M||O||(a==null||a(L),o==null||o(L),L.defaultPrevented||c==null||c())},g),H=EI(L=>{const R=L.target;[...h.branches].some(ne=>ne.contains(R))||(i==null||i(L),o==null||o(L),L.defaultPrevented||c==null||c())},g);return vI(L=>{C===h.layers.size-1&&(s==null||s(L),!L.defaultPrevented&&c&&(L.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(l1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),c1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=l1)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),c1())},[f,h]),b.useEffect(()=>{const L=()=>y({});return document.addEventListener(ex,L),()=>document.removeEventListener(ex,L)},[]),r.jsx(mt.div,{...u,ref:N,style:{pointerEvents:E?M?"auto":"none":void 0,...t.style},onFocusCapture:ht(t.onFocusCapture,H.onFocusCapture),onBlurCapture:ht(t.onBlurCapture,H.onBlurCapture),onPointerDownCapture:ht(t.onPointerDownCapture,P.onPointerDownCapture)})});o0.displayName=NI;var kI="DismissableLayerBranch",SI=b.forwardRef((t,e)=>{const n=b.useContext(Rj),s=b.useRef(null),a=Tt(e,s);return b.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(mt.div,{...t,ref:a})});SI.displayName=kI;function CI(t,e=globalThis==null?void 0:globalThis.document){const n=$i(t),s=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!s.current){let u=function(){Pj(wI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=u,e.addEventListener("click",a.current,{once:!0})):u()}else e.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>s.current=!0}}function EI(t,e=globalThis==null?void 0:globalThis.document){const n=$i(t),s=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!s.current&&Pj(jI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function c1(){const t=new CustomEvent(ex);document.dispatchEvent(t)}function Pj(t,e,n,{discrete:s}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),s?bI(a,i):a.dispatchEvent(i)}var Jm="focusScope.autoFocusOnMount",Ym="focusScope.autoFocusOnUnmount",d1={bubbles:!1,cancelable:!0},TI="FocusScope",l0=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=$i(a),f=$i(i),m=b.useRef(null),g=Tt(e,j=>u(j)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(s){let j=function(E){if(y.paused||!c)return;const M=E.target;c.contains(M)?m.current=M:bi(m.current,{select:!0})},v=function(E){if(y.paused||!c)return;const M=E.relatedTarget;M!==null&&(c.contains(M)||bi(m.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const P of E)P.removedNodes.length>0&&bi(c)};document.addEventListener("focusin",j),document.addEventListener("focusout",v);const C=new MutationObserver(k);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",v),C.disconnect()}}},[s,c,y.paused]),b.useEffect(()=>{if(c){h1.add(y);const j=document.activeElement;if(!c.contains(j)){const k=new CustomEvent(Jm,d1);c.addEventListener(Jm,h),c.dispatchEvent(k),k.defaultPrevented||(MI(OI(Oj(c)),{select:!0}),document.activeElement===j&&bi(c))}return()=>{c.removeEventListener(Jm,h),setTimeout(()=>{const k=new CustomEvent(Ym,d1);c.addEventListener(Ym,f),c.dispatchEvent(k),k.defaultPrevented||bi(j??document.body,{select:!0}),c.removeEventListener(Ym,f),h1.remove(y)},0)}}},[c,h,f,y]);const N=b.useCallback(j=>{if(!n&&!s||y.paused)return;const v=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,k=document.activeElement;if(v&&k){const C=j.currentTarget,[E,M]=AI(C);E&&M?!j.shiftKey&&k===M?(j.preventDefault(),n&&bi(E,{select:!0})):j.shiftKey&&k===E&&(j.preventDefault(),n&&bi(M,{select:!0})):k===C&&j.preventDefault()}},[n,s,y.paused]);return r.jsx(mt.div,{tabIndex:-1,...o,ref:g,onKeyDown:N})});l0.displayName=TI;function MI(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(bi(s,{select:e}),document.activeElement!==n)return}function AI(t){const e=Oj(t),n=u1(e,t),s=u1(e.reverse(),t);return[n,s]}function Oj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function u1(t,e){for(const n of t)if(!II(n,{upTo:e}))return n}function II(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function RI(t){return t instanceof HTMLInputElement&&"select"in t}function bi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&RI(t)&&e&&t.select()}}var h1=PI();function PI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=f1(t,e),t.unshift(e)},remove(e){var n;t=f1(t,e),(n=t[0])==null||n.resume()}}}function f1(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}function OI(t){return t.filter(e=>e.tagName!=="A")}var DI="Portal",c0=b.forwardRef((t,e)=>{var c;const{container:n,...s}=t,[a,i]=b.useState(!1);fs(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Uw.createPortal(r.jsx(mt.div,{...s,ref:e}),o):null});c0.displayName=DI;function LI(t,e){return b.useReducer((n,s)=>e[n][s]??n,t)}var Vd=t=>{const{present:e,children:n}=t,s=_I(e),a=typeof n=="function"?n({present:s.isPresent}):b.Children.only(n),i=Tt(s.ref,zI(a));return typeof n=="function"||s.isPresent?b.cloneElement(a,{ref:i}):null};Vd.displayName="Presence";function _I(t){const[e,n]=b.useState(),s=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=LI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=Yu(s.current);i.current=c==="mounted"?h:"none"},[c]),fs(()=>{const h=s.current,f=a.current;if(f!==t){const g=i.current,y=Yu(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),fs(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const j=Yu(s.current).includes(CSS.escape(y.animationName));if(y.target===e&&j&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},g=y=>{y.target===e&&(i.current=Yu(s.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(h=>{s.current=h?getComputedStyle(h):null,n(h)},[])}}function Yu(t){return(t==null?void 0:t.animationName)||"none"}function zI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Qm=0;function Dj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??p1()),document.body.insertAdjacentElement("beforeend",t[1]??p1()),Qm++,()=>{Qm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qm--}},[])}function p1(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var ta=function(){return ta=Object.assign||function(e){for(var n,s=1,a=arguments.length;s"u")return tR;var e=nR(t),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,s-n+e[2]-e[0])}},rR=$j(),Fl="data-scroll-locked",aR=function(t,e,n,s){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` - .`.concat(FI,` { + */const Z5=[["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"}]],Fa=Ie("zap",Z5),r0="admin_token";function Df(){try{return localStorage.getItem(r0)}catch{return null}}function eA(t){try{localStorage.setItem(r0,t)}catch{}}function Um(){try{localStorage.removeItem(r0)}catch{}}const tA="https://soulapi.quwanzhi.com",nA=15e3,Zv=6e4,sA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):tA};function Lo(t){const e=sA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Lf(t,e={}){const{data:n,...s}=e,a=Lo(t),i=new Headers(s.headers),o=Df();o&&i.set("Authorization",`Bearer ${o}`),n!=null&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):s.body,u=s.timeout??nA,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...s,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),y=(m.headers.get("Content-Type")||"").includes("application/json")?await m.json():m,N=j=>{const v=j,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(y);const j=new Error((y==null?void 0:y.error)||`HTTP ${m.status}`);throw j.status=m.status,j.data=y,j}return N(y),y}function De(t,e){return Lf(t,{...e,method:"GET"})}function Nt(t,e,n){return Lf(t,{...n,method:"POST",data:e})}function Ot(t,e,n){return Lf(t,{...n,method:"PUT",data:e})}function ea(t,e){return Lf(t,{...e,method:"DELETE"})}function rA(){const[t,e]=b.useState(!1),[n,s]=b.useState("");return b.useEffect(()=>{const a=i=>{const o=i.detail;s(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?r.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(rj,{className:"w-5 h-5 shrink-0 text-red-400"}),r.jsxs("span",{className:"text-sm font-medium",children:[n,r.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),r.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:r.jsx(gs,{className:"w-4 h-4"})})]}):null}const aA=[{icon:WM,label:"数据概览",href:"/dashboard"},{icon:Ys,label:"内容管理",href:"/content"},{icon:_n,label:"用户管理",href:"/users"},{icon:wM,label:"找伙伴",href:"/find-partner"},{icon:Wl,label:"推广中心",href:"/distribution"}];function iA(){const t=Ui(),e=Ki(),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{s(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;if(!Df()){e("/login",{replace:!0});return}return De("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):(Um(),e("/login",{replace:!0,state:{from:t.pathname}})))}).catch(()=>{c||(Um(),e("/login",{replace:!0,state:{from:t.pathname}}))}),()=>{c=!0}},[t.pathname,n,e]);const o=async()=>{Um();try{await Nt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):r.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[r.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[r.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[r.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),r.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[aA.map(c=>{const u=t.pathname===c.href;return r.jsxs(Hg,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),r.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:r.jsxs(Hg,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[r.jsx(Mo,{className:"w-5 h-5 shrink-0"}),r.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),r.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:r.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[r.jsx(e5,{className:"w-5 h-5"}),r.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),r.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[r.jsx(rA,{}),r.jsx("div",{className:"w-full min-w-[1024px] min-h-full flex-1",children:r.jsx(NT,{})})]})]})}function e1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function a0(...t){return e=>{let n=!1;const s=t.map(a=>{const i=e1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=s;pj(i)&&typeof Ph=="function"&&(i=Ph(i._payload));const c=b.Children.toArray(i),u=c.find(uA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var gj=mj("Slot");function cA(t){const e=b.forwardRef((n,s)=>{let{children:a,...i}=n;if(pj(a)&&typeof Ph=="function"&&(a=Ph(a._payload)),b.isValidElement(a)){const o=fA(a),c=hA(i,a.props);return a.type!==b.Fragment&&(c.ref=s?a0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dA=Symbol("radix.slottable");function uA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dA}function hA(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function fA(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function xj(t){var e,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,n1=yj,bj=(t,e)=>n=>{var s;if((e==null?void 0:e.variants)==null)return n1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=e,o=Object.keys(a).map(h=>{const f=n==null?void 0:n[h],m=i==null?void 0:i[h];if(f===null)return null;const g=t1(f)||t1(m);return a[h][g]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,g]=f;return g===void 0||(h[m]=g),h},{}),u=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(N=>{let[j,v]=N;return Array.isArray(v)?v.includes({...i,...c}[j]):{...i,...c}[j]===v})?[...h,m,g]:h},[]);return n1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},pA=(t,e)=>{const n=new Array(t.length+e.length);for(let s=0;s({classGroupId:t,validator:e}),vj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Oh="-",s1=[],gA="arbitrary..",xA=t=>{const e=bA(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return yA(o);const c=o.split(Oh),u=c[0]===""&&c.length>1?1:0;return Nj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=s[o],h=n[o];return u?h?pA(h,u):u:h||s1}return n[o]||s1}}},Nj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=Nj(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Oh):t.slice(e).join(Oh),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),s=e.slice(0,n);return s?gA+s:void 0})(),bA=t=>{const{theme:e,classGroups:n}=t;return vA(n,e)},vA=(t,e)=>{const n=vj();for(const s in t){const a=t[s];i0(a,n,s,e)}return n},i0=(t,e,n,s)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){wA(t,e,n);return}if(typeof t=="function"){jA(t,e,n,s);return}kA(t,e,n,s)},wA=(t,e,n)=>{const s=t===""?e:wj(e,t);s.classGroupId=n},jA=(t,e,n,s)=>{if(SA(t)){i0(t(s),e,n,s);return}e.validators===null&&(e.validators=[]),e.validators.push(mA(n,t))},kA=(t,e,n,s)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const s=e.split(Oh),a=s.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,CA=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),s=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,s=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=s[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},Zg="!",r1=":",EA=[],a1=(t,e,n,s,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:s,isExternal:a}),TA=t=>{const{prefix:e,experimentalParseClassName:n}=t;let s=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let j=0;ju?h-u:void 0;return a1(i,y,g,N)};if(e){const a=e+r1,i=s;s=o=>o.startsWith(a)?i(o.slice(a.length)):a1(EA,!1,o,void 0,!0)}if(n){const a=s;s=i=>n({className:i,parseClassName:a})}return s},MA=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,s)=>{e.set(n,1e6+s)}),n=>{const s=[];let a=[];for(let i=0;i0&&(a.sort(),s.push(...a),a=[]),s.push(o)):a.push(o)}return a.length>0&&(a.sort(),s.push(...a)),s}},AA=t=>({cache:CA(t.cacheSize),parseClassName:TA(t),sortModifiers:MA(t),...xA(t)}),IA=/\s+/,RA=(t,e)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(IA);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:N,maybePostfixModifierPosition:j}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!j,k=s(v?N.substring(0,j):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=s(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const C=g.length===0?"":g.length===1?g[0]:i(g).join(":"),E=y?C+Zg:C,M=E+k;if(o.indexOf(M)>-1)continue;o.push(M);const P=a(k,v);for(let H=0;H0?" "+u:u)}return u},PA=(...t)=>{let e=0,n,s,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let s=0;s{let n,s,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=AA(h),s=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=s(u);if(h)return h;const f=RA(u,n);return a(u,f),f};return i=o,(...u)=>i(PA(...u))},DA=[],Dn=t=>{const e=n=>n[t]||DA;return e.isThemeGetter=!0,e},kj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Sj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,LA=/^\d+\/\d+$/,_A=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,zA=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,FA=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$A=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,BA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kl=t=>LA.test(t),ft=t=>!!t&&!Number.isNaN(Number(t)),xi=t=>!!t&&Number.isInteger(Number(t)),Km=t=>t.endsWith("%")&&ft(t.slice(0,-1)),Ia=t=>_A.test(t),VA=()=>!0,HA=t=>zA.test(t)&&!FA.test(t),Cj=()=>!1,WA=t=>$A.test(t),UA=t=>BA.test(t),KA=t=>!Be(t)&&!Ve(t),qA=t=>tc(t,Mj,Cj),Be=t=>kj.test(t),vo=t=>tc(t,Aj,HA),qm=t=>tc(t,XA,ft),i1=t=>tc(t,Ej,Cj),GA=t=>tc(t,Tj,UA),Gu=t=>tc(t,Ij,WA),Ve=t=>Sj.test(t),Jc=t=>nc(t,Aj),JA=t=>nc(t,ZA),o1=t=>nc(t,Ej),YA=t=>nc(t,Mj),QA=t=>nc(t,Tj),Ju=t=>nc(t,Ij,!0),tc=(t,e,n)=>{const s=kj.exec(t);return s?s[1]?e(s[1]):n(s[2]):!1},nc=(t,e,n=!1)=>{const s=Sj.exec(t);return s?s[1]?e(s[1]):n:!1},Ej=t=>t==="position"||t==="percentage",Tj=t=>t==="image"||t==="url",Mj=t=>t==="length"||t==="size"||t==="bg-size",Aj=t=>t==="length",XA=t=>t==="number",ZA=t=>t==="family-name",Ij=t=>t==="shadow",eI=()=>{const t=Dn("color"),e=Dn("font"),n=Dn("text"),s=Dn("font-weight"),a=Dn("tracking"),i=Dn("leading"),o=Dn("breakpoint"),c=Dn("container"),u=Dn("spacing"),h=Dn("radius"),f=Dn("shadow"),m=Dn("inset-shadow"),g=Dn("text-shadow"),y=Dn("drop-shadow"),N=Dn("blur"),j=Dn("perspective"),v=Dn("aspect"),k=Dn("ease"),C=Dn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...M(),Ve,Be],H=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto","contain","none"],R=()=>[Ve,Be,u],O=()=>[kl,"full","auto",...R()],se=()=>[xi,"none","subgrid",Ve,Be],ie=()=>["auto",{span:["full",xi,Ve,Be]},xi,Ve,Be],z=()=>[xi,"auto",Ve,Be],ce=()=>["auto","min","max","fr",Ve,Be],me=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...R()],$=()=>[kl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],A=()=>[t,Ve,Be],Y=()=>[...M(),o1,i1,{position:[Ve,Be]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],D=()=>["auto","cover","contain",YA,qA,{size:[Ve,Be]}],W=()=>[Km,Jc,vo],le=()=>["","none","full",h,Ve,Be],ye=()=>["",ft,Jc,vo],Ae=()=>["solid","dashed","dotted","double"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[ft,Km,o1,i1],J=()=>["","none",N,Ve,Be],ge=()=>["none",ft,Ve,Be],ae=()=>["none",ft,Ve,Be],pe=()=>[ft,Ve,Be],Se=()=>[kl,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ia],breakpoint:[Ia],color:[VA],container:[Ia],"drop-shadow":[Ia],ease:["in","out","in-out"],font:[KA],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ia],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ia],shadow:[Ia],spacing:["px",ft],text:[Ia],"text-shadow":[Ia],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kl,Be,Ve,v]}],container:["container"],columns:[{columns:[ft,Be,Ve,c]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[xi,"auto",Ve,Be]}],basis:[{basis:[kl,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ft,kl,"auto","initial","none",Be]}],grow:[{grow:["",ft,Ve,Be]}],shrink:[{shrink:["",ft,Ve,Be]}],order:[{order:[xi,"first","last","none",Ve,Be]}],"grid-cols":[{"grid-cols":se()}],"col-start-end":[{col:ie()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":se()}],"row-start-end":[{row:ie()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ce()}],"auto-rows":[{"auto-rows":ce()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...me(),"normal"]}],"justify-items":[{"justify-items":[..._(),"normal"]}],"justify-self":[{"justify-self":["auto",..._()]}],"align-content":[{content:["normal",...me()]}],"align-items":[{items:[..._(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._(),{baseline:["","last"]}]}],"place-content":[{"place-content":me()}],"place-items":[{"place-items":[..._(),"baseline"]}],"place-self":[{"place-self":["auto",..._()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],w:[{w:[c,"screen",...$()]}],"min-w":[{"min-w":[c,"screen","none",...$()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh",...$()]}],"font-size":[{text:["base",n,Jc,vo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,Ve,qm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Km,Be]}],"font-family":[{font:[JA,Be,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,Ve,Be]}],"line-clamp":[{"line-clamp":[ft,"none",Ve,qm]}],leading:[{leading:[i,...R()]}],"list-image":[{"list-image":["none",Ve,Be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ve,Be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[ft,"from-font","auto",Ve,vo]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[ft,"auto",Ve,Be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ve,Be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ve,Be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:D()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xi,Ve,Be],radial:["",Ve,Be],conic:[xi,Ve,Be]},QA,GA]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:ye()}],"border-w-x":[{"border-x":ye()}],"border-w-y":[{"border-y":ye()}],"border-w-s":[{"border-s":ye()}],"border-w-e":[{"border-e":ye()}],"border-w-t":[{"border-t":ye()}],"border-w-r":[{"border-r":ye()}],"border-w-b":[{"border-b":ye()}],"border-w-l":[{"border-l":ye()}],"divide-x":[{"divide-x":ye()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ye()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Ae(),"hidden","none"]}],"divide-style":[{divide:[...Ae(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...Ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ft,Ve,Be]}],"outline-w":[{outline:["",ft,Jc,vo]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",f,Ju,Gu]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",m,Ju,Gu]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:ye()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[ft,vo]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":ye()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",g,Ju,Gu]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[ft,Ve,Be]}],"mix-blend":[{"mix-blend":[...ne(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ne()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ft]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[Ve,Be]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[ft]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:D()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ve,Be]}],filter:[{filter:["","none",Ve,Be]}],blur:[{blur:J()}],brightness:[{brightness:[ft,Ve,Be]}],contrast:[{contrast:[ft,Ve,Be]}],"drop-shadow":[{"drop-shadow":["","none",y,Ju,Gu]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",ft,Ve,Be]}],"hue-rotate":[{"hue-rotate":[ft,Ve,Be]}],invert:[{invert:["",ft,Ve,Be]}],saturate:[{saturate:[ft,Ve,Be]}],sepia:[{sepia:["",ft,Ve,Be]}],"backdrop-filter":[{"backdrop-filter":["","none",Ve,Be]}],"backdrop-blur":[{"backdrop-blur":J()}],"backdrop-brightness":[{"backdrop-brightness":[ft,Ve,Be]}],"backdrop-contrast":[{"backdrop-contrast":[ft,Ve,Be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ft,Ve,Be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ft,Ve,Be]}],"backdrop-invert":[{"backdrop-invert":["",ft,Ve,Be]}],"backdrop-opacity":[{"backdrop-opacity":[ft,Ve,Be]}],"backdrop-saturate":[{"backdrop-saturate":[ft,Ve,Be]}],"backdrop-sepia":[{"backdrop-sepia":["",ft,Ve,Be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ve,Be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ft,"initial",Ve,Be]}],ease:[{ease:["linear","initial",k,Ve,Be]}],delay:[{delay:[ft,Ve,Be]}],animate:[{animate:["none",C,Ve,Be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,Ve,Be]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:pe()}],"skew-x":[{"skew-x":pe()}],"skew-y":[{"skew-y":pe()}],transform:[{transform:[Ve,Be,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ve,Be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ve,Be]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[ft,Jc,vo,qm]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},tI=OA(eI);function Mt(...t){return tI(yj(t))}const nI=bj("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function X({className:t,variant:e,size:n,asChild:s=!1,...a}){const i=s?gj:"button";return r.jsx(i,{"data-slot":"button",className:Mt(nI({variant:e,size:n,className:t})),...a})}function re({className:t,type:e,...n}){return r.jsx("input",{type:e,"data-slot":"input",className:Mt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 md:text-sm focus-visible:ring-2 focus-visible:ring-ring",t),...n})}function sI(){const t=Ki(),[e,n]=b.useState(""),[s,a]=b.useState(""),[i,o]=b.useState(""),[c,u]=b.useState(!1),h=async()=>{o(""),u(!0);try{const f=await Nt("/api/admin",{username:e.trim(),password:s});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){eA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return r.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[r.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[r.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),r.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),r.jsxs("div",{className:"w-full max-w-md relative z-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:r.jsx(od,{className:"w-8 h-8 text-[#38bdac]"})}),r.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),r.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),r.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[r.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ao,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"text",value:e,onChange:f=>n(f.target.value),placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),r.jsxs("div",{className:"relative",children:[r.jsx(XM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),r.jsx(re,{type:"password",value:s,onChange:f=>a(f.target.value),placeholder:"请输入密码",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]",onKeyDown:f=>f.key==="Enter"&&h()})]})]}),i&&r.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),r.jsx(X,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),r.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Ee=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Ee.displayName="Card";const Je=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("flex flex-col space-y-1.5 p-6",t),...e}));Je.displayName="CardHeader";const Ye=b.forwardRef(({className:t,...e},n)=>r.jsx("h3",{ref:n,className:Mt("font-semibold leading-none tracking-tight",t),...e}));Ye.displayName="CardTitle";const Ft=b.forwardRef(({className:t,...e},n)=>r.jsx("p",{ref:n,className:Mt("text-sm text-muted-foreground",t),...e}));Ft.displayName="CardDescription";const Te=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("p-6 pt-0",t),...e}));Te.displayName="CardContent";const rI=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{ref:n,className:Mt("flex items-center p-6 pt-0",t),...e}));rI.displayName="CardFooter";const aI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Gm(t,e="info",n=3e3){const s=`toast-${Date.now()}`,a=aI[e],i=document.createElement("div");i.id=s,i.setAttribute("role","alert"),Object.assign(i.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:a.bg,border:`1.5px solid ${a.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:a.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=a.icon;const c=document.createElement("span");c.textContent=t,i.appendChild(o),i.appendChild(c),document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"});const u=setTimeout(()=>h(s),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const te={success:(t,e)=>Gm(t,"success",e),error:(t,e)=>Gm(t,"error",e),info:(t,e)=>Gm(t,"info",e)};function dt(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function iI(t,e){const n=b.createContext(e),s=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:u,children:o})};s.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[s,a]}function qi(t,e=[]){let n=[];function s(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:g,children:y,...N}=m,j=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,v=b.useMemo(()=>N,Object.values(N));return r.jsx(j.Provider,{value:v,children:y})};h.displayName=i+"Provider";function f(m,g){var j;const y=((j=g==null?void 0:g[t])==null?void 0:j[u])||c,N=b.useContext(y);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[s,oI(a,...e)]}function oI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const s=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((c,{useScope:u,scopeName:h})=>{const m=u(i)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var xs=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},lI=Rf[" useId ".trim().toString()]||(()=>{}),cI=0;function Pi(t){const[e,n]=b.useState(lI());return xs(()=>{n(s=>s??String(cI++))},[t]),e?`radix-${e}`:""}var dI=Rf[" useInsertionEffect ".trim().toString()]||xs;function _o({prop:t,defaultProp:e,onChange:n=()=>{},caller:s}){const[a,i,o]=uI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,s])}const h=b.useCallback(f=>{var m;if(c){const g=hI(f)?f(t):f;g!==t&&((m=o.current)==null||m.call(o,g))}else i(f)},[c,t,i,o]);return[u,h]}function uI({defaultProp:t,onChange:e}){const[n,s]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return dI(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,s,i]}function hI(t){return typeof t=="function"}function Sd(t){const e=fI(t),n=b.forwardRef((s,a)=>{const{children:i,...o}=s,c=b.Children.toArray(i),u=c.find(mI);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return r.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return r.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function fI(t){const e=b.forwardRef((n,s)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=xI(a),c=gI(i,a.props);return a.type!==b.Fragment&&(c.ref=s?a0(s,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pI=Symbol("radix.slottable");function mI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pI}function gI(t,e){const n={...e};for(const s in e){const a=t[s],i=e[s];/^on[A-Z]/.test(s)?a&&i?n[s]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...i}:s==="className"&&(n[s]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function xI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var yI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pt=yI.reduce((t,e)=>{const n=Sd(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function bI(t,e){t&&Bd.flushSync(()=>t.dispatchEvent(e))}function Fi(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var s;return(s=e.current)==null?void 0:s.call(e,...n)},[])}function vI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t);b.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",s,{capture:!0}),()=>e.removeEventListener("keydown",s,{capture:!0})},[n,e])}var NI="DismissableLayer",ex="dismissableLayer.update",wI="dismissableLayer.pointerDownOutside",jI="dismissableLayer.focusOutside",l1,Rj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),o0=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(Rj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),N=Tt(e,L=>m(L)),j=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=j.indexOf(v),C=f?j.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,M=C>=k,P=CI(L=>{const R=L.target,O=[...h.branches].some(se=>se.contains(R));!M||O||(a==null||a(L),o==null||o(L),L.defaultPrevented||c==null||c())},g),H=EI(L=>{const R=L.target;[...h.branches].some(se=>se.contains(R))||(i==null||i(L),o==null||o(L),L.defaultPrevented||c==null||c())},g);return vI(L=>{C===h.layers.size-1&&(s==null||s(L),!L.defaultPrevented&&c&&(L.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(l1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),c1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=l1)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),c1())},[f,h]),b.useEffect(()=>{const L=()=>y({});return document.addEventListener(ex,L),()=>document.removeEventListener(ex,L)},[]),r.jsx(pt.div,{...u,ref:N,style:{pointerEvents:E?M?"auto":"none":void 0,...t.style},onFocusCapture:dt(t.onFocusCapture,H.onFocusCapture),onBlurCapture:dt(t.onBlurCapture,H.onBlurCapture),onPointerDownCapture:dt(t.onPointerDownCapture,P.onPointerDownCapture)})});o0.displayName=NI;var kI="DismissableLayerBranch",SI=b.forwardRef((t,e)=>{const n=b.useContext(Rj),s=b.useRef(null),a=Tt(e,s);return b.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(pt.div,{...t,ref:a})});SI.displayName=kI;function CI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t),s=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!s.current){let u=function(){Pj(wI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=u,e.addEventListener("click",a.current,{once:!0})):u()}else e.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>s.current=!0}}function EI(t,e=globalThis==null?void 0:globalThis.document){const n=Fi(t),s=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!s.current&&Pj(jI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function c1(){const t=new CustomEvent(ex);document.dispatchEvent(t)}function Pj(t,e,n,{discrete:s}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),s?bI(a,i):a.dispatchEvent(i)}var Jm="focusScope.autoFocusOnMount",Ym="focusScope.autoFocusOnUnmount",d1={bubbles:!1,cancelable:!0},TI="FocusScope",l0=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=Fi(a),f=Fi(i),m=b.useRef(null),g=Tt(e,j=>u(j)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(s){let j=function(E){if(y.paused||!c)return;const M=E.target;c.contains(M)?m.current=M:vi(m.current,{select:!0})},v=function(E){if(y.paused||!c)return;const M=E.relatedTarget;M!==null&&(c.contains(M)||vi(m.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const P of E)P.removedNodes.length>0&&vi(c)};document.addEventListener("focusin",j),document.addEventListener("focusout",v);const C=new MutationObserver(k);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",v),C.disconnect()}}},[s,c,y.paused]),b.useEffect(()=>{if(c){h1.add(y);const j=document.activeElement;if(!c.contains(j)){const k=new CustomEvent(Jm,d1);c.addEventListener(Jm,h),c.dispatchEvent(k),k.defaultPrevented||(MI(OI(Oj(c)),{select:!0}),document.activeElement===j&&vi(c))}return()=>{c.removeEventListener(Jm,h),setTimeout(()=>{const k=new CustomEvent(Ym,d1);c.addEventListener(Ym,f),c.dispatchEvent(k),k.defaultPrevented||vi(j??document.body,{select:!0}),c.removeEventListener(Ym,f),h1.remove(y)},0)}}},[c,h,f,y]);const N=b.useCallback(j=>{if(!n&&!s||y.paused)return;const v=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,k=document.activeElement;if(v&&k){const C=j.currentTarget,[E,M]=AI(C);E&&M?!j.shiftKey&&k===M?(j.preventDefault(),n&&vi(E,{select:!0})):j.shiftKey&&k===E&&(j.preventDefault(),n&&vi(M,{select:!0})):k===C&&j.preventDefault()}},[n,s,y.paused]);return r.jsx(pt.div,{tabIndex:-1,...o,ref:g,onKeyDown:N})});l0.displayName=TI;function MI(t,{select:e=!1}={}){const n=document.activeElement;for(const s of t)if(vi(s,{select:e}),document.activeElement!==n)return}function AI(t){const e=Oj(t),n=u1(e,t),s=u1(e.reverse(),t);return[n,s]}function Oj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function u1(t,e){for(const n of t)if(!II(n,{upTo:e}))return n}function II(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function RI(t){return t instanceof HTMLInputElement&&"select"in t}function vi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&RI(t)&&e&&t.select()}}var h1=PI();function PI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=f1(t,e),t.unshift(e)},remove(e){var n;t=f1(t,e),(n=t[0])==null||n.resume()}}}function f1(t,e){const n=[...t],s=n.indexOf(e);return s!==-1&&n.splice(s,1),n}function OI(t){return t.filter(e=>e.tagName!=="A")}var DI="Portal",c0=b.forwardRef((t,e)=>{var c;const{container:n,...s}=t,[a,i]=b.useState(!1);xs(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Uw.createPortal(r.jsx(pt.div,{...s,ref:e}),o):null});c0.displayName=DI;function LI(t,e){return b.useReducer((n,s)=>e[n][s]??n,t)}var Vd=t=>{const{present:e,children:n}=t,s=_I(e),a=typeof n=="function"?n({present:s.isPresent}):b.Children.only(n),i=Tt(s.ref,zI(a));return typeof n=="function"||s.isPresent?b.cloneElement(a,{ref:i}):null};Vd.displayName="Presence";function _I(t){const[e,n]=b.useState(),s=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=LI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=Yu(s.current);i.current=c==="mounted"?h:"none"},[c]),xs(()=>{const h=s.current,f=a.current;if(f!==t){const g=i.current,y=Yu(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),xs(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const j=Yu(s.current).includes(CSS.escape(y.animationName));if(y.target===e&&j&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},g=y=>{y.target===e&&(i.current=Yu(s.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(h=>{s.current=h?getComputedStyle(h):null,n(h)},[])}}function Yu(t){return(t==null?void 0:t.animationName)||"none"}function zI(t){var s,a;let e=(s=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Qm=0;function Dj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??p1()),document.body.insertAdjacentElement("beforeend",t[1]??p1()),Qm++,()=>{Qm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qm--}},[])}function p1(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var ta=function(){return ta=Object.assign||function(e){for(var n,s=1,a=arguments.length;s"u")return tR;var e=nR(t),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,s-n+e[2]-e[0])}},rR=Fj(),$l="data-scroll-locked",aR=function(t,e,n,s){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` + .`.concat($I,` { overflow: hidden `).concat(s,`; padding-right: `).concat(c,"px ").concat(s,`; } - body[`).concat(Fl,`] { + body[`).concat($l,`] { overflow: hidden `).concat(s,`; overscroll-behavior: contain; `).concat([e&&"position: relative ".concat(s,";"),n==="margin"&&` @@ -573,26 +573,26 @@ Error generating stack: `+S.message+` margin-right: 0 `).concat(s,`; } - body[`).concat(Fl,`] { + body[`).concat($l,`] { `).concat(BI,": ").concat(c,`px; } -`)},g1=function(){var t=parseInt(document.body.getAttribute(Fl)||"0",10);return isFinite(t)?t:0},iR=function(){b.useEffect(function(){return document.body.setAttribute(Fl,(g1()+1).toString()),function(){var t=g1()-1;t<=0?document.body.removeAttribute(Fl):document.body.setAttribute(Fl,t.toString())}},[])},oR=function(t){var e=t.noRelative,n=t.noImportant,s=t.gapMode,a=s===void 0?"margin":s;iR();var i=b.useMemo(function(){return sR(a)},[a]);return b.createElement(rR,{styles:aR(i,!e,a,n?"":"!important")})},tx=!1;if(typeof window<"u")try{var Qu=Object.defineProperty({},"passive",{get:function(){return tx=!0,!0}});window.addEventListener("test",Qu,Qu),window.removeEventListener("test",Qu,Qu)}catch{tx=!1}var Sl=tx?{passive:!1}:!1,lR=function(t){return t.tagName==="TEXTAREA"},Fj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!lR(t)&&n[e]==="visible")},cR=function(t){return Fj(t,"overflowY")},dR=function(t){return Fj(t,"overflowX")},x1=function(t,e){var n=e.ownerDocument,s=e;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Bj(t,s);if(a){var i=Vj(t,s),o=i[1],c=i[2];if(o>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},uR=function(t){var e=t.scrollTop,n=t.scrollHeight,s=t.clientHeight;return[e,n,s]},hR=function(t){var e=t.scrollLeft,n=t.scrollWidth,s=t.clientWidth;return[e,n,s]},Bj=function(t,e){return t==="v"?cR(e):dR(e)},Vj=function(t,e){return t==="v"?uR(e):hR(e)},fR=function(t,e){return t==="h"&&e==="rtl"?-1:1},pR=function(t,e,n,s,a){var i=fR(t,window.getComputedStyle(e).direction),o=i*s,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=Vj(t,c),N=y[0],j=y[1],v=y[2],k=j-v-i*N;(N||k)&&Bj(t,c)&&(m+=k,g+=N);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(g)<1)&&(h=!0),h},Xu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},y1=function(t){return[t.deltaX,t.deltaY]},b1=function(t){return t&&"current"in t?t.current:t},mR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},gR=function(t){return` +`)},g1=function(){var t=parseInt(document.body.getAttribute($l)||"0",10);return isFinite(t)?t:0},iR=function(){b.useEffect(function(){return document.body.setAttribute($l,(g1()+1).toString()),function(){var t=g1()-1;t<=0?document.body.removeAttribute($l):document.body.setAttribute($l,t.toString())}},[])},oR=function(t){var e=t.noRelative,n=t.noImportant,s=t.gapMode,a=s===void 0?"margin":s;iR();var i=b.useMemo(function(){return sR(a)},[a]);return b.createElement(rR,{styles:aR(i,!e,a,n?"":"!important")})},tx=!1;if(typeof window<"u")try{var Qu=Object.defineProperty({},"passive",{get:function(){return tx=!0,!0}});window.addEventListener("test",Qu,Qu),window.removeEventListener("test",Qu,Qu)}catch{tx=!1}var Sl=tx?{passive:!1}:!1,lR=function(t){return t.tagName==="TEXTAREA"},$j=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!lR(t)&&n[e]==="visible")},cR=function(t){return $j(t,"overflowY")},dR=function(t){return $j(t,"overflowX")},x1=function(t,e){var n=e.ownerDocument,s=e;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Bj(t,s);if(a){var i=Vj(t,s),o=i[1],c=i[2];if(o>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},uR=function(t){var e=t.scrollTop,n=t.scrollHeight,s=t.clientHeight;return[e,n,s]},hR=function(t){var e=t.scrollLeft,n=t.scrollWidth,s=t.clientWidth;return[e,n,s]},Bj=function(t,e){return t==="v"?cR(e):dR(e)},Vj=function(t,e){return t==="v"?uR(e):hR(e)},fR=function(t,e){return t==="h"&&e==="rtl"?-1:1},pR=function(t,e,n,s,a){var i=fR(t,window.getComputedStyle(e).direction),o=i*s,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=Vj(t,c),N=y[0],j=y[1],v=y[2],k=j-v-i*N;(N||k)&&Bj(t,c)&&(m+=k,g+=N);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(g)<1)&&(h=!0),h},Xu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},y1=function(t){return[t.deltaX,t.deltaY]},b1=function(t){return t&&"current"in t?t.current:t},mR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},gR=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} -`)},xR=0,Cl=[];function yR(t){var e=b.useRef([]),n=b.useRef([0,0]),s=b.useRef(),a=b.useState(xR++)[0],i=b.useState($j)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=$I([t.lockRef.current],(t.shards||[]).map(b1),!0).filter(Boolean);return j.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(j,v){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!o.current.allowPinchZoom;var k=Xu(j),C=n.current,E="deltaX"in j?j.deltaX:C[0]-k[0],M="deltaY"in j?j.deltaY:C[1]-k[1],P,H=j.target,L=Math.abs(E)>Math.abs(M)?"h":"v";if("touches"in j&&L==="h"&&H.type==="range")return!1;var R=window.getSelection(),O=R&&R.anchorNode,ne=O?O===H||O.contains(H):!1;if(ne)return!1;var ie=x1(L,H);if(!ie)return!0;if(ie?P=L:(P=L==="v"?"h":"v",ie=x1(L,H)),!ie)return!1;if(!s.current&&"changedTouches"in j&&(E||M)&&(s.current=P),!P)return!0;var _=s.current||P;return pR(_,v,j,_==="h"?E:M)},[]),u=b.useCallback(function(j){var v=j;if(!(!Cl.length||Cl[Cl.length-1]!==i)){var k="deltaY"in v?y1(v):Xu(v),C=e.current.filter(function(P){return P.name===v.type&&(P.target===v.target||v.target===P.shadowParent)&&mR(P.delta,k)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var E=(o.current.shards||[]).map(b1).filter(Boolean).filter(function(P){return P.contains(v.target)}),M=E.length>0?c(v,E[0]):!o.current.noIsolation;M&&v.cancelable&&v.preventDefault()}}},[]),h=b.useCallback(function(j,v,k,C){var E={name:j,delta:v,target:k,should:C,shadowParent:bR(k)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(M){return M!==E})},1)},[]),f=b.useCallback(function(j){n.current=Xu(j),s.current=void 0},[]),m=b.useCallback(function(j){h(j.type,y1(j),j.target,c(j,t.lockRef.current))},[]),g=b.useCallback(function(j){h(j.type,Xu(j),j.target,c(j,t.lockRef.current))},[]);b.useEffect(function(){return Cl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Sl),document.addEventListener("touchmove",u,Sl),document.addEventListener("touchstart",f,Sl),function(){Cl=Cl.filter(function(j){return j!==i}),document.removeEventListener("wheel",u,Sl),document.removeEventListener("touchmove",u,Sl),document.removeEventListener("touchstart",f,Sl)}},[]);var y=t.removeScrollBar,N=t.inert;return b.createElement(b.Fragment,null,N?b.createElement(i,{styles:gR(a)}):null,y?b.createElement(oR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function bR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const vR=GI(zj,yR);var d0=b.forwardRef(function(t,e){return b.createElement(_f,ta({},t,{ref:e,sideCar:vR}))});d0.classNames=_f.classNames;var NR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},El=new WeakMap,Zu=new WeakMap,eh={},tg=0,Hj=function(t){return t&&(t.host||Hj(t.parentNode))},wR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=Hj(n);return s&&t.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},jR=function(t,e,n,s){var a=wR(e,Array.isArray(t)?t:[t]);eh[n]||(eh[n]=new WeakMap);var i=eh[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(c.has(g))f(g);else try{var y=g.getAttribute(s),N=y!==null&&y!=="false",j=(El.get(g)||0)+1,v=(i.get(g)||0)+1;El.set(g,j),i.set(g,v),o.push(g),j===1&&N&&Zu.set(g,!0),v===1&&g.setAttribute(n,"true"),N||g.setAttribute(s,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return f(e),c.clear(),tg++,function(){o.forEach(function(m){var g=El.get(m)-1,y=i.get(m)-1;El.set(m,g),i.set(m,y),g||(Zu.has(m)||m.removeAttribute(s),Zu.delete(m)),y||m.removeAttribute(n)}),tg--,tg||(El=new WeakMap,El=new WeakMap,Zu=new WeakMap,eh={})}},Wj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),a=NR(t);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),jR(s,a,n,"aria-hidden")):function(){return null}},zf="Dialog",[Uj]=qi(zf),[kR,Or]=Uj(zf),Kj=t=>{const{__scopeDialog:e,children:n,open:s,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=_o({prop:s,defaultProp:a??!1,onChange:i,caller:zf});return r.jsx(kR,{scope:e,triggerRef:c,contentRef:u,contentId:Pi(),titleId:Pi(),descriptionId:Pi(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Kj.displayName=zf;var qj="DialogTrigger",SR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Or(qj,n),i=Tt(e,a.triggerRef);return r.jsx(mt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":f0(a.open),...s,ref:i,onClick:ht(t.onClick,a.onOpenToggle)})});SR.displayName=qj;var u0="DialogPortal",[CR,Gj]=Uj(u0,{forceMount:void 0}),Jj=t=>{const{__scopeDialog:e,forceMount:n,children:s,container:a}=t,i=Or(u0,e);return r.jsx(CR,{scope:e,forceMount:n,children:b.Children.map(s,o=>r.jsx(Vd,{present:n||i.open,children:r.jsx(c0,{asChild:!0,container:a,children:o})}))})};Jj.displayName=u0;var Dh="DialogOverlay",Yj=b.forwardRef((t,e)=>{const n=Gj(Dh,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Or(Dh,t.__scopeDialog);return i.modal?r.jsx(Vd,{present:s||i.open,children:r.jsx(TR,{...a,ref:e})}):null});Yj.displayName=Dh;var ER=Sd("DialogOverlay.RemoveScroll"),TR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Or(Dh,n);return r.jsx(d0,{as:ER,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(mt.div,{"data-state":f0(a.open),...s,ref:e,style:{pointerEvents:"auto",...s.style}})})}),zo="DialogContent",Qj=b.forwardRef((t,e)=>{const n=Gj(zo,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Or(zo,t.__scopeDialog);return r.jsx(Vd,{present:s||i.open,children:i.modal?r.jsx(MR,{...a,ref:e}):r.jsx(AR,{...a,ref:e})})});Qj.displayName=zo;var MR=b.forwardRef((t,e)=>{const n=Or(zo,t.__scopeDialog),s=b.useRef(null),a=Tt(e,n.contentRef,s);return b.useEffect(()=>{const i=s.current;if(i)return Wj(i)},[]),r.jsx(Xj,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ht(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:ht(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:ht(t.onFocusOutside,i=>i.preventDefault())})}),AR=b.forwardRef((t,e)=>{const n=Or(zo,t.__scopeDialog),s=b.useRef(!1),a=b.useRef(!1);return r.jsx(Xj,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Xj=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Or(zo,n),u=b.useRef(null),h=Tt(e,u);return Dj(),r.jsxs(r.Fragment,{children:[r.jsx(l0,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:r.jsx(o0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":f0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(IR,{titleId:c.titleId}),r.jsx(PR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),h0="DialogTitle",Zj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Or(h0,n);return r.jsx(mt.h2,{id:a.titleId,...s,ref:e})});Zj.displayName=h0;var ek="DialogDescription",tk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Or(ek,n);return r.jsx(mt.p,{id:a.descriptionId,...s,ref:e})});tk.displayName=ek;var nk="DialogClose",sk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Or(nk,n);return r.jsx(mt.button,{type:"button",...s,ref:e,onClick:ht(t.onClick,()=>a.onOpenChange(!1))})});sk.displayName=nk;function f0(t){return t?"open":"closed"}var rk="DialogTitleWarning",[YV,ak]=iI(rk,{contentName:zo,titleName:h0,docsSlug:"dialog"}),IR=({titleId:t})=>{const e=ak(rk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. +`)},xR=0,Cl=[];function yR(t){var e=b.useRef([]),n=b.useRef([0,0]),s=b.useRef(),a=b.useState(xR++)[0],i=b.useState(Fj)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=FI([t.lockRef.current],(t.shards||[]).map(b1),!0).filter(Boolean);return j.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(j,v){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!o.current.allowPinchZoom;var k=Xu(j),C=n.current,E="deltaX"in j?j.deltaX:C[0]-k[0],M="deltaY"in j?j.deltaY:C[1]-k[1],P,H=j.target,L=Math.abs(E)>Math.abs(M)?"h":"v";if("touches"in j&&L==="h"&&H.type==="range")return!1;var R=window.getSelection(),O=R&&R.anchorNode,se=O?O===H||O.contains(H):!1;if(se)return!1;var ie=x1(L,H);if(!ie)return!0;if(ie?P=L:(P=L==="v"?"h":"v",ie=x1(L,H)),!ie)return!1;if(!s.current&&"changedTouches"in j&&(E||M)&&(s.current=P),!P)return!0;var z=s.current||P;return pR(z,v,j,z==="h"?E:M)},[]),u=b.useCallback(function(j){var v=j;if(!(!Cl.length||Cl[Cl.length-1]!==i)){var k="deltaY"in v?y1(v):Xu(v),C=e.current.filter(function(P){return P.name===v.type&&(P.target===v.target||v.target===P.shadowParent)&&mR(P.delta,k)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var E=(o.current.shards||[]).map(b1).filter(Boolean).filter(function(P){return P.contains(v.target)}),M=E.length>0?c(v,E[0]):!o.current.noIsolation;M&&v.cancelable&&v.preventDefault()}}},[]),h=b.useCallback(function(j,v,k,C){var E={name:j,delta:v,target:k,should:C,shadowParent:bR(k)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(M){return M!==E})},1)},[]),f=b.useCallback(function(j){n.current=Xu(j),s.current=void 0},[]),m=b.useCallback(function(j){h(j.type,y1(j),j.target,c(j,t.lockRef.current))},[]),g=b.useCallback(function(j){h(j.type,Xu(j),j.target,c(j,t.lockRef.current))},[]);b.useEffect(function(){return Cl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Sl),document.addEventListener("touchmove",u,Sl),document.addEventListener("touchstart",f,Sl),function(){Cl=Cl.filter(function(j){return j!==i}),document.removeEventListener("wheel",u,Sl),document.removeEventListener("touchmove",u,Sl),document.removeEventListener("touchstart",f,Sl)}},[]);var y=t.removeScrollBar,N=t.inert;return b.createElement(b.Fragment,null,N?b.createElement(i,{styles:gR(a)}):null,y?b.createElement(oR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function bR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const vR=GI(zj,yR);var d0=b.forwardRef(function(t,e){return b.createElement(_f,ta({},t,{ref:e,sideCar:vR}))});d0.classNames=_f.classNames;var NR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},El=new WeakMap,Zu=new WeakMap,eh={},tg=0,Hj=function(t){return t&&(t.host||Hj(t.parentNode))},wR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var s=Hj(n);return s&&t.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},jR=function(t,e,n,s){var a=wR(e,Array.isArray(t)?t:[t]);eh[n]||(eh[n]=new WeakMap);var i=eh[n],o=[],c=new Set,u=new Set(a),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};a.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(c.has(g))f(g);else try{var y=g.getAttribute(s),N=y!==null&&y!=="false",j=(El.get(g)||0)+1,v=(i.get(g)||0)+1;El.set(g,j),i.set(g,v),o.push(g),j===1&&N&&Zu.set(g,!0),v===1&&g.setAttribute(n,"true"),N||g.setAttribute(s,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return f(e),c.clear(),tg++,function(){o.forEach(function(m){var g=El.get(m)-1,y=i.get(m)-1;El.set(m,g),i.set(m,y),g||(Zu.has(m)||m.removeAttribute(s),Zu.delete(m)),y||m.removeAttribute(n)}),tg--,tg||(El=new WeakMap,El=new WeakMap,Zu=new WeakMap,eh={})}},Wj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),a=NR(t);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),jR(s,a,n,"aria-hidden")):function(){return null}},zf="Dialog",[Uj]=qi(zf),[kR,Dr]=Uj(zf),Kj=t=>{const{__scopeDialog:e,children:n,open:s,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=_o({prop:s,defaultProp:a??!1,onChange:i,caller:zf});return r.jsx(kR,{scope:e,triggerRef:c,contentRef:u,contentId:Pi(),titleId:Pi(),descriptionId:Pi(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Kj.displayName=zf;var qj="DialogTrigger",SR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(qj,n),i=Tt(e,a.triggerRef);return r.jsx(pt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":f0(a.open),...s,ref:i,onClick:dt(t.onClick,a.onOpenToggle)})});SR.displayName=qj;var u0="DialogPortal",[CR,Gj]=Uj(u0,{forceMount:void 0}),Jj=t=>{const{__scopeDialog:e,forceMount:n,children:s,container:a}=t,i=Dr(u0,e);return r.jsx(CR,{scope:e,forceMount:n,children:b.Children.map(s,o=>r.jsx(Vd,{present:n||i.open,children:r.jsx(c0,{asChild:!0,container:a,children:o})}))})};Jj.displayName=u0;var Dh="DialogOverlay",Yj=b.forwardRef((t,e)=>{const n=Gj(Dh,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Dr(Dh,t.__scopeDialog);return i.modal?r.jsx(Vd,{present:s||i.open,children:r.jsx(TR,{...a,ref:e})}):null});Yj.displayName=Dh;var ER=Sd("DialogOverlay.RemoveScroll"),TR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(Dh,n);return r.jsx(d0,{as:ER,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(pt.div,{"data-state":f0(a.open),...s,ref:e,style:{pointerEvents:"auto",...s.style}})})}),zo="DialogContent",Qj=b.forwardRef((t,e)=>{const n=Gj(zo,t.__scopeDialog),{forceMount:s=n.forceMount,...a}=t,i=Dr(zo,t.__scopeDialog);return r.jsx(Vd,{present:s||i.open,children:i.modal?r.jsx(MR,{...a,ref:e}):r.jsx(AR,{...a,ref:e})})});Qj.displayName=zo;var MR=b.forwardRef((t,e)=>{const n=Dr(zo,t.__scopeDialog),s=b.useRef(null),a=Tt(e,n.contentRef,s);return b.useEffect(()=>{const i=s.current;if(i)return Wj(i)},[]),r.jsx(Xj,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:dt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:dt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:dt(t.onFocusOutside,i=>i.preventDefault())})}),AR=b.forwardRef((t,e)=>{const n=Dr(zo,t.__scopeDialog),s=b.useRef(!1),a=b.useRef(!1);return r.jsx(Xj,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Xj=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Dr(zo,n),u=b.useRef(null),h=Tt(e,u);return Dj(),r.jsxs(r.Fragment,{children:[r.jsx(l0,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:r.jsx(o0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":f0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(IR,{titleId:c.titleId}),r.jsx(PR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),h0="DialogTitle",Zj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(h0,n);return r.jsx(pt.h2,{id:a.titleId,...s,ref:e})});Zj.displayName=h0;var ek="DialogDescription",tk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(ek,n);return r.jsx(pt.p,{id:a.descriptionId,...s,ref:e})});tk.displayName=ek;var nk="DialogClose",sk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...s}=t,a=Dr(nk,n);return r.jsx(pt.button,{type:"button",...s,ref:e,onClick:dt(t.onClick,()=>a.onOpenChange(!1))})});sk.displayName=nk;function f0(t){return t?"open":"closed"}var rk="DialogTitleWarning",[YV,ak]=iI(rk,{contentName:zo,titleName:h0,docsSlug:"dialog"}),IR=({titleId:t})=>{const e=ak(rk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component. -For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},RR="DialogDescriptionWarning",PR=({contentRef:t,descriptionId:e})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ak(RR).contentName}}.`;return b.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(s))},[s,t,e]),null},OR=Kj,DR=Jj,LR=Yj,_R=Qj,zR=Zj,$R=tk,FR=sk;function Rt(t){return r.jsx(OR,{"data-slot":"dialog",...t})}function BR(t){return r.jsx(DR,{...t})}const ik=b.forwardRef(({className:t,...e},n)=>r.jsx(LR,{ref:n,className:Mt("fixed inset-0 z-50 bg-black/50",t),...e}));ik.displayName="DialogOverlay";const St=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...s},a)=>r.jsxs(BR,{children:[r.jsx(ik,{}),r.jsxs(_R,{ref:a,"aria-describedby":void 0,className:Mt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg",t),...s,children:[e,n&&r.jsxs(FR,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[r.jsx(hs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));St.displayName="DialogContent";function Pt({className:t,...e}){return r.jsx("div",{className:Mt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function tn({className:t,...e}){return r.jsx("div",{className:Mt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Ot(t){return r.jsx(zR,{className:"text-lg font-semibold leading-none",...t})}function Cd(t){return r.jsx($R,{className:"text-sm text-muted-foreground",...t})}const VR=bj("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ke({className:t,variant:e,asChild:n=!1,...s}){const a=n?gj:"span";return r.jsx(a,{className:Mt(VR({variant:e}),t),...s})}var HR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],WR=HR.reduce((t,e)=>{const n=mj(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{}),UR="Label",ok=b.forwardRef((t,e)=>r.jsx(WR.label,{...t,ref:e,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));ok.displayName=UR;var lk=ok;const Z=b.forwardRef(({className:t,...e},n)=>r.jsx(lk,{ref:n,className:Mt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Z.displayName=lk.displayName;function p0(t){const e=t+"CollectionProvider",[n,s]=qi(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=j=>{const{scope:v,children:k}=j,C=ks.useRef(null),E=ks.useRef(new Map).current;return r.jsx(a,{scope:v,itemMap:E,collectionRef:C,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Sd(c),h=ks.forwardRef((j,v)=>{const{scope:k,children:C}=j,E=i(c,k),M=Tt(v,E.collectionRef);return r.jsx(u,{ref:M,children:C})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Sd(f),y=ks.forwardRef((j,v)=>{const{scope:k,children:C,...E}=j,M=ks.useRef(null),P=Tt(v,M),H=i(f,k);return ks.useEffect(()=>(H.itemMap.set(M,{ref:M,...E}),()=>void H.itemMap.delete(M))),r.jsx(g,{[m]:"",ref:P,children:C})});y.displayName=f;function N(j){const v=i(t+"CollectionConsumer",j);return ks.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((H,L)=>E.indexOf(H.ref.current)-E.indexOf(L.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},N,s]}var KR=b.createContext(void 0);function $f(t){const e=b.useContext(KR);return t||e||"ltr"}var ng="rovingFocusGroup.onEntryFocus",qR={bubbles:!1,cancelable:!0},Hd="RovingFocusGroup",[nx,ck,GR]=p0(Hd),[JR,dk]=qi(Hd,[GR]),[YR,QR]=JR(Hd),uk=b.forwardRef((t,e)=>r.jsx(nx.Provider,{scope:t.__scopeRovingFocusGroup,children:r.jsx(nx.Slot,{scope:t.__scopeRovingFocusGroup,children:r.jsx(XR,{...t,ref:e})})}));uk.displayName=Hd;var XR=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=Tt(e,g),N=$f(i),[j,v]=_o({prop:o,defaultProp:c??null,onChange:u,caller:Hd}),[k,C]=b.useState(!1),E=$i(h),M=ck(n),P=b.useRef(!1),[H,L]=b.useState(0);return b.useEffect(()=>{const R=g.current;if(R)return R.addEventListener(ng,E),()=>R.removeEventListener(ng,E)},[E]),r.jsx(YR,{scope:n,orientation:s,dir:N,loop:a,currentTabStopId:j,onItemFocus:b.useCallback(R=>v(R),[v]),onItemShiftTab:b.useCallback(()=>C(!0),[]),onFocusableItemAdd:b.useCallback(()=>L(R=>R+1),[]),onFocusableItemRemove:b.useCallback(()=>L(R=>R-1),[]),children:r.jsx(mt.div,{tabIndex:k||H===0?-1:0,"data-orientation":s,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:ht(t.onMouseDown,()=>{P.current=!0}),onFocus:ht(t.onFocus,R=>{const O=!P.current;if(R.target===R.currentTarget&&O&&!k){const ne=new CustomEvent(ng,qR);if(R.currentTarget.dispatchEvent(ne),!ne.defaultPrevented){const ie=M().filter(q=>q.focusable),_=ie.find(q=>q.active),ce=ie.find(q=>q.id===j),z=[_,ce,...ie].filter(Boolean).map(q=>q.ref.current);pk(z,f)}}P.current=!1}),onBlur:ht(t.onBlur,()=>C(!1))})})}),hk="RovingFocusGroupItem",fk=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=Pi(),h=i||u,f=QR(hk,n),m=f.currentTabStopId===h,g=ck(n),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:j}=f;return b.useEffect(()=>{if(s)return y(),()=>N()},[s,y,N]),r.jsx(nx.ItemSlot,{scope:n,id:h,focusable:s,active:a,children:r.jsx(mt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:ht(t.onMouseDown,v=>{s?f.onItemFocus(h):v.preventDefault()}),onFocus:ht(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:ht(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=tP(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=g().filter(M=>M.focusable).map(M=>M.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const M=E.indexOf(v.currentTarget);E=f.loop?nP(E,M+1):E.slice(M+1)}setTimeout(()=>pk(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:j!=null}):o})})});fk.displayName=hk;var ZR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function tP(t,e,n){const s=eP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return ZR[s]}function pk(t,e=!1){const n=document.activeElement;for(const s of t)if(s===n||(s.focus({preventScroll:e}),document.activeElement!==n))return}function nP(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var sP=uk,rP=fk,Ff="Tabs",[aP]=qi(Ff,[dk]),mk=dk(),[iP,m0]=aP(Ff),gk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=$f(c),[m,g]=_o({prop:s,onChange:a,defaultProp:i??"",caller:Ff});return r.jsx(iP,{scope:n,baseId:Pi(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:r.jsx(mt.div,{dir:f,"data-orientation":o,...h,ref:e})})});gk.displayName=Ff;var xk="TabsList",yk=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:s=!0,...a}=t,i=m0(xk,n),o=mk(n);return r.jsx(sP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(mt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});yk.displayName=xk;var bk="TabsTrigger",vk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...i}=t,o=m0(bk,n),c=mk(n),u=jk(o.baseId,s),h=kk(o.baseId,s),f=s===o.value;return r.jsx(rP,{asChild:!0,...c,focusable:!a,active:f,children:r.jsx(mt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...i,ref:e,onMouseDown:ht(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(s):m.preventDefault()}),onKeyDown:ht(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(s)}),onFocus:ht(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(s)})})})});vk.displayName=bk;var Nk="TabsContent",wk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,forceMount:a,children:i,...o}=t,c=m0(Nk,n),u=jk(c.baseId,s),h=kk(c.baseId,s),f=s===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),r.jsx(Vd,{present:a||f,children:({present:g})=>r.jsx(mt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&i})})});wk.displayName=Nk;function jk(t,e){return`${t}-trigger-${e}`}function kk(t,e){return`${t}-content-${e}`}var oP=gk,Sk=yk,Ck=vk,Ek=wk;const Wd=oP,sc=b.forwardRef(({className:t,...e},n)=>r.jsx(Sk,{ref:n,className:Mt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));sc.displayName=Sk.displayName;const Yt=b.forwardRef(({className:t,...e},n)=>r.jsx(Ck,{ref:n,className:Mt("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));Yt.displayName=Ck.displayName;const Qt=b.forwardRef(({className:t,...e},n)=>r.jsx(Ek,{ref:n,className:Mt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Qt.displayName=Ek.displayName;function g0(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function x0(t){const[e,n]=b.useState(void 0);return fs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,c;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return s.observe(t,{box:"border-box"}),()=>s.unobserve(t)}else n(void 0)},[t]),e}var Bf="Switch",[lP]=qi(Bf),[cP,dP]=lP(Bf),Tk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:s,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),N=Tt(e,E=>y(E)),j=b.useRef(!1),v=g?f||!!g.closest("form"):!0,[k,C]=_o({prop:a,defaultProp:i??!1,onChange:h,caller:Bf});return r.jsxs(cP,{scope:n,checked:k,disabled:c,children:[r.jsx(mt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":Rk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:ht(t.onClick,E=>{C(M=>!M),v&&(j.current=E.isPropagationStopped(),j.current||E.stopPropagation())})}),v&&r.jsx(Ik,{control:g,bubbles:!j.current,name:s,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});Tk.displayName=Bf;var Mk="SwitchThumb",Ak=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...s}=t,a=dP(Mk,n);return r.jsx(mt.span,{"data-state":Rk(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:e})});Ak.displayName=Mk;var uP="SwitchBubbleInput",Ik=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:s=!0,...a},i)=>{const o=b.useRef(null),c=Tt(o,i),u=g0(n),h=x0(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const N=new Event("click",{bubbles:s});y.call(f,n),f.dispatchEvent(N)}},[u,n,s]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ik.displayName=uP;function Rk(t){return t?"checked":"unchecked"}var Pk=Tk,hP=Ak;const Ct=b.forwardRef(({className:t,...e},n)=>r.jsx(Pk,{className:Mt("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:r.jsx(hP,{className:Mt("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Ct.displayName=Pk.displayName;function y0({open:t,onClose:e,userId:n,onUserUpdated:s}){var Lr;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState(null),[g,y]=b.useState(!1),[N,j]=b.useState(!1),[v,k]=b.useState(!1),[C,E]=b.useState("info"),[M,P]=b.useState(""),[H,L]=b.useState(""),[R,O]=b.useState([]),[ne,ie]=b.useState(""),[_,ce]=b.useState(""),[pe,z]=b.useState(""),[q,F]=b.useState(!1),[A,J]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[U,D]=b.useState([]),[W,le]=b.useState(!1),[xe,Me]=b.useState(""),[te,K]=b.useState(""),[G,ge]=b.useState(!1),[ae,fe]=b.useState(!1),[Se,et]=b.useState(null),[st,_t]=b.useState(null),[At,Ut]=b.useState(""),[An,In]=b.useState(""),[It,sn]=b.useState(""),[on,Es]=b.useState(!1),[xn,Wn]=b.useState(null),[Y,Ue]=b.useState("");b.useEffect(()=>{t&&n&&(E("info"),et(null),_t(null),Wn(null),Ue(""),ce(""),z(""),Qe(),De("/api/db/vip-roles").then(me=>{me!=null&&me.success&&me.data&&D(me.data)}).catch(()=>{}))},[t,n]);async function Qe(){if(n){y(!0);try{const me=await De(`/api/db/users?id=${encodeURIComponent(n)}`);if(me!=null&&me.success&&me.user){const ye=me.user;i(ye),P(ye.phone||""),L(ye.nickname||""),Ut(ye.phone||""),In(ye.wechatId||""),sn(ye.openId||"");try{O(typeof ye.tags=="string"?JSON.parse(ye.tags||"[]"):[])}catch{O([])}J({isVip:!!(ye.isVip??!1),vipExpireDate:ye.vipExpireDate?String(ye.vipExpireDate).slice(0,10):"",vipRole:String(ye.vipRole??""),vipName:String(ye.vipName??""),vipProject:String(ye.vipProject??""),vipContact:String(ye.vipContact??""),vipBio:String(ye.vipBio??"")})}try{const ye=await De(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=50`);ye!=null&&ye.success&&ye.tracks&&c(ye.tracks)}catch{c([])}try{const ye=await De(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ye!=null&&ye.success&&ye.referrals&&h(ye.referrals)}catch{h([])}try{const ye=await De(`/api/admin/users/${encodeURIComponent(n)}/balance`);ye!=null&&ye.success&&ye.data?m(ye.data):m(null)}catch{m(null)}}catch(me){console.error("Load user detail error:",me)}finally{y(!1)}}}async function wt(){if(!(a!=null&&a.phone)){se.info("用户未绑定手机号,无法同步");return}j(!0);try{const me=await Nt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});me!=null&&me.success?(se.success("同步成功"),Qe()):se.error("同步失败: "+(me==null?void 0:me.error))}catch(me){console.error("Sync CKB error:",me),se.error("同步失败")}finally{j(!1)}}async function dt(){if(a){if(A.isVip&&!A.vipExpireDate.trim()){se.error("开启 VIP 请填写有效到期日");return}k(!0);try{const me={id:a.id,phone:M||void 0,nickname:H||void 0,tags:JSON.stringify(R),isVip:A.isVip,vipExpireDate:A.isVip?A.vipExpireDate:void 0,vipRole:A.vipRole||void 0,vipName:A.vipName||void 0,vipProject:A.vipProject||void 0,vipContact:A.vipContact||void 0,vipBio:A.vipBio||void 0},ye=await Dt("/api/db/users",me);ye!=null&&ye.success?(se.success("保存成功"),Qe(),s==null||s()):se.error("保存失败: "+(ye==null?void 0:ye.error))}catch(me){console.error("Save user error:",me),se.error("保存失败")}finally{k(!1)}}}const at=()=>{ne&&!R.includes(ne)&&(O([...R,ne]),ie(""))},xt=me=>O(R.filter(ye=>ye!==me));async function Xt(){if(a){if(!_){se.error("请输入新密码");return}if(_!==pe){se.error("两次密码不一致");return}if(_.length<6){se.error("密码至少 6 位");return}F(!0);try{const me=await Dt("/api/db/users",{id:a.id,password:_});me!=null&&me.success?(se.success("修改成功"),ce(""),z("")):se.error("修改失败: "+((me==null?void 0:me.error)||""))}catch{se.error("修改失败")}finally{F(!1)}}}async function ln(){if(!a)return;const me=parseFloat(xe);if(Number.isNaN(me)||me===0){se.error("请输入有效金额(正数增加、负数扣减)");return}ge(!0);try{const ye=await Nt(`/api/admin/users/${a.id}/balance/adjust`,{amount:me,remark:te||void 0});ye!=null&&ye.success?(se.success("余额已调整"),le(!1),Me(""),K(""),Qe(),s==null||s()):se.error("调整失败: "+((ye==null?void 0:ye.error)||""))}catch{se.error("调整失败")}finally{ge(!1)}}async function ss(){if(!At&&!It&&!An){_t("请至少输入手机号、微信号或 OpenID 中的一项");return}fe(!0),_t(null),et(null);try{const me=new URLSearchParams;At&&me.set("phone",At),It&&me.set("openId",It),An&&me.set("wechatId",An);const ye=await De(`/api/admin/shensheshou/query?${me}`);ye!=null&&ye.success&&ye.data?(et(ye.data),a&&await xs(ye.data)):_t((ye==null?void 0:ye.error)||"未查询到数据,该用户可能未在神射手收录")}catch(me){console.error("SSS query error:",me),_t("请求失败,请检查神射手接口配置")}finally{fe(!1)}}async function xs(me){if(a)try{await Nt("/api/admin/shensheshou/enrich",{userId:a.id,phone:At||a.phone||"",openId:It||a.openId||"",wechatId:An||a.wechatId||""}),Qe()}catch(ye){console.error("SSS enrich error:",ye)}}async function fr(){if(a){Es(!0),Wn(null);try{const me={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:R}]},ye=await Nt("/api/admin/shensheshou/ingest",me);ye!=null&&ye.success&&ye.data?Wn(ye.data):Wn({error:(ye==null?void 0:ye.error)||"推送失败"})}catch(me){console.error("SSS ingest error:",me),Wn({error:"请求失败"})}finally{Es(!1)}}}const ys=me=>{const Zt={view_chapter:Gs,purchase:Qg,match:_n,login:Ao,register:Ao,share:Ir,bind_phone:g5,bind_wechat:a5,fill_profile:ld,visit_page:Ll}[me]||Kg;return r.jsx(Zt,{className:"w-4 h-4"})};return t?r.jsxs(r.Fragment,{children:[r.jsx(Rt,{open:t,onOpenChange:()=>e(),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?r.jsxs("div",{className:"flex flex-col h-[75vh]",children:[r.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:a.avatar?r.jsx("img",{src:a.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Lr=a.nickname)==null?void 0:Lr.charAt(0))||"?"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("h3",{className:"text-lg font-bold text-white",children:a.nickname}),a.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),a.hasFullBook&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),a.vipRole&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:a.vipRole})]}),r.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[a.phone?`📱 ${a.phone}`:"未绑定手机",a.wechatId&&` · 💬 ${a.wechatId}`,a.mbti&&` · ${a.mbti}`]}),r.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[r.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",a.id.slice(0,16),"…"]}),a.referralCode&&r.jsxs("p",{className:"text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"推广码:"}),r.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:a.referralCode})]})]})]}),r.jsxs("div",{className:"text-right shrink-0",children:[r.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(a.earnings||0).toFixed(2)]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),r.jsxs(Wd,{value:C,onValueChange:E,className:"flex-1 flex flex-col overflow-hidden",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[r.jsx(Yt,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),r.jsx(Yt,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),r.jsxs(Yt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Ll,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),r.jsx(Yt,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),r.jsxs(Yt,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Ti,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),r.jsxs(Qt,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:M,onChange:me=>P(me.target.value),disabled:!!(a!=null&&a.phone)}),(a==null?void 0:a.phone)&&r.jsx("p",{className:"text-xs text-gray-500",children:"编辑时手机号不可修改"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:H,onChange:me=>L(me.target.value)})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.openId&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),r.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:a.openId})]}),a.region&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(hj,{className:"w-4 h-4 text-gray-500"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),r.jsx("p",{className:"text-white",children:a.region})]})]}),a.industry&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),r.jsx("p",{className:"text-white",children:a.industry})]}),a.position&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),r.jsx("p",{className:"text-white",children:a.position})]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:a.referralCount??0})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),r.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(a.pendingEarnings??0).toFixed(2)]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg flex flex-col justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"当前余额"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac]",children:["¥",((f==null?void 0:f.balance)??0).toFixed(2)]})]}),r.jsx(X,{size:"sm",variant:"outline",className:"mt-2 border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 text-xs",onClick:()=>{Me(""),K(""),le(!0)},children:"调整余额"})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),r.jsx("p",{className:"text-sm text-white",children:a.createdAt?new Date(a.createdAt).toLocaleDateString():"-"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(uj,{className:"w-4 h-4 text-yellow-400"}),r.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:_,onChange:me=>ce(me.target.value)}),r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:pe,onChange:me=>z(me.target.value)}),r.jsx(X,{size:"sm",onClick:Xt,disabled:q||!_||!pe,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:q?"保存中...":"确认修改"})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx($l,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-400 text-sm",children:"VIP 会员"}),r.jsx(Ct,{checked:A.isVip,onCheckedChange:me=>J(ye=>({...ye,isVip:me}))})]}),A.isVip&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"到期日"}),r.jsx(re,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:A.vipExpireDate,onChange:me=>J(ye=>({...ye,vipExpireDate:me.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"角色"}),r.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:A.vipRole,onChange:me=>J(ye=>({...ye,vipRole:me.target.value})),children:[r.jsx("option",{value:"",children:"请选择"}),U.map(me=>r.jsx("option",{value:me.name,children:me.name},me.id))]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"展示名"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:A.vipName,onChange:me=>J(ye=>({...ye,vipName:me.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"项目"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"如:某某科技",value:A.vipProject,onChange:me=>J(ye=>({...ye,vipProject:me.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"联系方式"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"微信/手机等",value:A.vipContact,onChange:me=>J(ye=>({...ye,vipContact:me.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"简介"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"简短介绍",value:A.vipBio,onChange:me=>J(ye=>({...ye,vipBio:me.target.value}))})]})]})]})]}),a.isVip&&r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx($l,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:a.vipRole||"VIP"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.vipName&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"展示名:"}),r.jsx("span",{className:"text-white",children:a.vipName})]}),a.vipProject&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"项目:"}),r.jsx("span",{className:"text-white",children:a.vipProject})]}),a.vipContact&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"联系方式:"}),r.jsx("span",{className:"text-white",children:a.vipContact})]}),a.vipExpireDate&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"到期时间:"}),r.jsx("span",{className:"text-white",children:new Date(a.vipExpireDate).toLocaleDateString()})]})]}),a.vipBio&&r.jsx("p",{className:"text-gray-400 text-sm mt-2",children:a.vipBio})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(zi,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"微信归属"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:Y,onChange:me=>Ue(me.target.value)}),r.jsxs(X,{size:"sm",onClick:async()=>{if(!(!Y||!a))try{await Dt("/api/db/users",{id:a.id,wechatId:Y}),se.success("已保存微信归属"),Qe()}catch{se.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[r.jsx(Nn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),a.wechatId&&r.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",r.jsx("span",{className:"text-purple-400",children:a.wechatId})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ir,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),r.jsx(X,{size:"sm",onClick:wt,disabled:N||!a.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:N?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"同步状态:"}),a.ckbSyncedAt?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"最后同步:"}),r.jsx("span",{className:"text-gray-300 ml-1",children:a.ckbSyncedAt?new Date(a.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),r.jsxs(Qt,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(ld,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户标签"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),r.jsxs("div",{className:"mb-3 p-2.5 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-center gap-2 text-xs text-gray-400",children:[r.jsx(Ug,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),r.jsx("div",{className:"mb-4 space-y-3",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(me=>r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:me.category}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:me.tags.map(ye=>r.jsxs("button",{type:"button",onClick:()=>{R.includes(ye)?xt(ye):O([...R,ye])},className:`px-2 py-0.5 rounded text-xs border transition-all ${R.includes(ye)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[R.includes(ye)?"✓ ":"",ye]},ye))})]},me.category))}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),r.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[R.map((me,ye)=>r.jsxs(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[me,r.jsx("button",{type:"button",onClick:()=>xt(me),className:"ml-1 hover:text-red-400",children:r.jsx(hs,{className:"w-3 h-3"})})]},ye)),R.length===0&&r.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:ne,onChange:me=>ie(me.target.value),onKeyDown:me=>me.key==="Enter"&&at()}),r.jsx(X,{onClick:at,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),(()=>{const me=a.tags||a.ckbTags||"";let ye=[];try{const Rn=typeof me=="string"?JSON.parse(me||"[]"):[];ye=Array.isArray(Rn)?Rn:typeof me=="string"?me.split(","):[]}catch{ye=typeof me=="string"?me.split(","):[]}const Zt=ye.map(Rn=>String(Rn).trim()).filter(Boolean);return Zt.length===0?null:r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(ld,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Zt.map((Rn,da)=>r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:Rn},da))})]})})()]}),r.jsxs(Qt,{value:"journey",className:"flex-1 overflow-auto",children:[r.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(Ll,{className:"w-4 h-4 text-[#38bdac]"}),r.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),r.jsx("div",{className:"space-y-2",children:o.length>0?o.map((me,ye)=>r.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:ys(me.action)}),ye0?u.map((me,ye)=>{var Rn;const Zt=me;return r.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((Rn=Zt.nickname)==null?void 0:Rn.charAt(0))||"?"}),r.jsx("span",{className:"text-white text-sm",children:Zt.nickname})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[Zt.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),r.jsx("span",{className:"text-gray-500 text-xs",children:Zt.createdAt?new Date(Zt.createdAt).toLocaleDateString():""})]})]},Zt.id||ye)}):r.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),r.jsxs(Qt,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Ti,{className:"w-5 h-5 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:At,onChange:me=>Ut(me.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:An,onChange:me=>In(me.target.value)})]}),r.jsxs("div",{className:"col-span-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:It,onChange:me=>sn(me.target.value)})]})]}),r.jsx(X,{onClick:ss,disabled:ae,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:ae?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Fa,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),r.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),st&&r.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:st}),Se&&r.jsxs("div",{className:"mt-3 space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),r.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:Se.rfm_score??"-"})]}),r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:Se.user_level??"-"})]})]}),Se.tags&&Se.tags.length>0&&r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Se.tags.map((me,ye)=>r.jsx(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:me},ye))})]}),Se.last_active&&r.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",Se.last_active]})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Ti,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),r.jsx(X,{onClick:fr,disabled:on||!a.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:on?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ti,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!a.phone&&r.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),xn&&r.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:xn.error?r.jsx("p",{className:"text-red-400",children:String(xn.error)}):r.jsxs("div",{className:"space-y-1",children:[r.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[r.jsx(Ug,{className:"w-4 h-4"})," 推送成功"]}),xn.enriched!==void 0&&r.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(xn.new_tags_added??0)]})]})})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[r.jsxs(X,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"关闭"]}),r.jsxs(X,{onClick:dt,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存修改"]})]})]}):r.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),r.jsx(Rt,{open:W,onOpenChange:le,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsx(Ot,{children:"调整余额"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:xe,onChange:me=>Me(me.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"备注(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:te,onChange:me=>K(me.target.value)})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>le(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(X,{onClick:ln,disabled:G,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:G?"提交中...":"确认调整"})]})]})})]}):null}function fP(){const t=Ki(),[e,n]=b.useState(!0),[s,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,N]=b.useState(0),[j,v]=b.useState(0),[k,C]=b.useState(0),[E,M]=b.useState(null),[P,H]=b.useState(null),[L,R]=b.useState(!1),[O,ne]=b.useState(0),[ie,_]=b.useState(!1),[ce,pe]=b.useState(null),[z,q]=b.useState("week"),[F,A]=b.useState(null),[J,U]=b.useState(!1),D=K=>{const G=K;if((G==null?void 0:G.status)===401)M("登录已过期,请重新登录");else{if((G==null?void 0:G.name)==="AbortError")return;M("加载失败,请检查网络或联系管理员")}};async function W(K){const G=K?{signal:K}:void 0;n(!0),M(null);try{const fe=await De("/api/admin/dashboard/stats",G);fe!=null&&fe.success&&(g(fe.totalUsers??0),N(fe.paidOrderCount??0),v(fe.totalRevenue??0),C(fe.conversionRate??0))}catch(fe){if((fe==null?void 0:fe.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",fe);try{const Se=await De("/api/admin/dashboard/overview",G);Se!=null&&Se.success&&(g(Se.totalUsers??0),N(Se.paidOrderCount??0),v(Se.totalRevenue??0),C(Se.conversionRate??0))}catch(Se){D(Se)}}}finally{n(!1)}try{const fe=await De("/api/admin/balance/summary",G);fe!=null&&fe.success&&fe.data&&ne(fe.data.totalGifted??0)}catch{}try{const fe=await De("/api/db/ckb-plan-stats",G);fe!=null&&fe.success&&fe.data?pe({ckbTotal:fe.data.ckbTotal??0,withContact:fe.data.withContact??0}):pe(null)}catch{pe(null)}a(!0),o(!0);const ge=async()=>{try{const fe=await De("/api/admin/dashboard/recent-orders?limit=10",G);if(fe!=null&&fe.success&&fe.recentOrders)f(fe.recentOrders);else throw new Error("no data")}catch(fe){if((fe==null?void 0:fe.name)!=="AbortError")try{const Se=await De("/api/admin/orders?page=1&pageSize=20&status=paid",G),st=((Se==null?void 0:Se.orders)??[]).filter(_t=>["paid","completed","success"].includes(_t.status||""));f(st.slice(0,5))}catch{f([])}}finally{a(!1)}},ae=async()=>{try{const fe=await De("/api/admin/dashboard/new-users",G);if(fe!=null&&fe.success&&fe.newUsers)u(fe.newUsers);else throw new Error("no data")}catch(fe){if((fe==null?void 0:fe.name)!=="AbortError")try{const Se=await De("/api/db/users?page=1&pageSize=10",G);u((Se==null?void 0:Se.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([ge(),ae()])}async function le(K){const G=K||z;U(!0);try{const ge=await De(`/api/admin/track/stats?period=${G}`);ge!=null&&ge.success&&A({total:ge.total??0,byModule:ge.byModule??{}})}catch{A(null)}finally{U(!1)}}b.useEffect(()=>{const K=new AbortController;W(K.signal),le();const G=setInterval(()=>{W(),le()},3e4);return()=>{K.abort(),clearInterval(G)}},[]);const xe=m,Me=K=>{const G=K.productType||"",ge=K.description||"";if(G==="balance_recharge")return{title:`余额充值 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(G==="gift_pay")return{title:`代付 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(G==="gift_pay_batch"){const ae=typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2);return{title:ge||`代付分享 ¥${ae}`,subtitle:"代付分享"}}if(G==="section"&&ge.includes("代付领取"))return{title:ge.replace("代付领取 - ",""),subtitle:"代付领取"};if(ge){if(G==="section"&&ge.includes("章节")){if(ge.includes("-")){const ae=ge.split("-");if(ae.length>=3)return{title:`第${ae[1]}章 第${ae[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:ge,subtitle:"章节购买"}}return G==="fullbook"||ge.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:G==="vip"||ge.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:G==="match"||ge.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:ge,subtitle:G==="section"?"单章":G==="fullbook"?"全书":"其他"}}return G==="section"?{title:`章节 ${K.productId||""}`,subtitle:"单章购买"}:G==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:G==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:G==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:G||"其他"}},te=[{title:"总用户数",value:e?null:xe,sub:null,icon:_n,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(j??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:cd,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:Qg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:Gs,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ce?ce.ckbTotal??0:null,sub:(ce==null?void 0:ce.withContact)!=null?`含联系方式 ${ce.withContact} 人`:null,icon:dd,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"}];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),E&&r.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[r.jsx("span",{children:E}),r.jsx("button",{type:"button",onClick:()=>W(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:te.map((K,G)=>r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>K.link&&t(K.link),children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsx(Ye,{className:"text-sm font-medium text-gray-400",children:K.title}),r.jsx("div",{className:`p-2 rounded-lg ${K.bg}`,children:r.jsx(K.icon,{className:`w-4 h-4 ${K.color}`})})]}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:K.value!=null?K.value:r.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[r.jsx($e,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),K.sub&&r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:K.sub})]}),r.jsx(Dl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},G))}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsx(Ye,{className:"text-white",children:"最近订单"}),r.jsxs("button",{type:"button",onClick:()=>W(),disabled:s||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[s||i?r.jsx($e,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx($e,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:s&&h.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx($e,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[h.slice(0,ie?10:4).map(K=>{var Se;const G=K.referrerId?c.find(et=>et.id===K.referrerId):void 0,ge=K.referralCode||(G==null?void 0:G.referralCode)||(G==null?void 0:G.nickname)||(K.referrerId?String(K.referrerId).slice(0,8):""),ae=Me(K),fe=K.userNickname||((Se=c.find(et=>et.id===K.userId))==null?void 0:Se.nickname)||"匿名用户";return r.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[K.userAvatar?r.jsx("img",{src:K.userAvatar,alt:fe,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:et=>{et.currentTarget.style.display="none";const st=et.currentTarget.nextElementSibling;st&&st.classList.remove("hidden")}}):null,r.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 mt-0.5 ${K.userAvatar?"hidden":""}`,children:fe.charAt(0)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("button",{type:"button",onClick:()=>{K.userId&&(H(K.userId),R(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:fe}),r.jsx("span",{className:"text-gray-600",children:"·"}),r.jsx("span",{className:"text-sm font-medium text-white truncate",children:ae.title})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[ae.subtitle&&ae.subtitle!=="章节购买"&&r.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:ae.subtitle}),r.jsx("span",{children:new Date(K.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),ge&&r.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",ge]})]})]}),r.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[r.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(K.amount).toFixed(2)]}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:K.paymentMethod||"微信"})]})]},K.id)}),h.length>4&&!ie&&r.jsx("button",{type:"button",onClick:()=>_(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!s&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Qg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"新注册用户"})}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:i&&c.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx($e,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[c.slice(0,5).map(K=>{var G;return r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((G=K.nickname)==null?void 0:G.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("button",{type:"button",onClick:()=>{H(K.id),R(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:K.nickname||"匿名用户"}),r.jsx("p",{className:"text-xs text-gray-500",children:K.phone||"-"})]})]}),r.jsx("p",{className:"text-xs text-gray-400",children:K.createdAt?new Date(K.createdAt).toLocaleDateString():"-"})]},K.id)}),c.length===0&&!i&&r.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),r.jsxs(Ee,{className:"mt-8 bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Wg,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),r.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(K=>r.jsx("button",{type:"button",onClick:()=>{q(K),le(K)},className:`px-3 py-1 text-xs rounded-full transition-colors ${z===K?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[K]},K))})]}),r.jsx(Te,{children:J&&!F?r.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[r.jsx($e,{className:"w-6 h-6 animate-spin mr-2"}),r.jsx("span",{children:"加载中..."})]}):F&&Object.keys(F.byModule).length>0?r.jsxs("div",{className:"space-y-6",children:[r.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",r.jsx("span",{className:"text-white font-bold text-lg",children:F.total})," 次"]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(F.byModule).sort((K,G)=>G[1].reduce((ge,ae)=>ge+ae.count,0)-K[1].reduce((ge,ae)=>ge+ae.count,0)).map(([K,G])=>{const ge=G.reduce((fe,Se)=>fe+Se.count,0),ae={home:"首页",chapters:"目录",read:"阅读",my:"我的",vip:"VIP",wallet:"钱包",match:"找伙伴",referral:"推广",search:"搜索",settings:"设置",about:"关于",other:"其他"};return r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:ae[K]||K}),r.jsxs("span",{className:"text-xs text-gray-500",children:[ge," 次"]})]}),r.jsx("div",{className:"space-y-2",children:G.sort((fe,Se)=>Se.count-fe.count).slice(0,8).map((fe,Se)=>{const et={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",rule_trigger:"规则触发",view_chapter:"浏览章节",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元"},st={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节"},_t=et[fe.target]||fe.target||st[fe.action]||fe.action;return r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-gray-300 truncate mr-2",title:`${fe.action}: ${fe.target}`,children:_t}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${ge>0?fe.count/ge*100:0}%`}})}),r.jsx("span",{className:"text-gray-400 w-8 text-right",children:fe.count})]})]},Se)})})]},K)})})]}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),r.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),r.jsx(y0,{open:L,onClose:()=>{R(!1),H(null)},userId:P,onUserUpdated:()=>W()})]})}const es=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:Mt("w-full caption-bottom text-sm",t),...e})}));es.displayName="Table";const ts=b.forwardRef(({className:t,...e},n)=>r.jsx("thead",{ref:n,className:Mt("[&_tr]:border-b",t),...e}));ts.displayName="TableHeader";const ns=b.forwardRef(({className:t,...e},n)=>r.jsx("tbody",{ref:n,className:Mt("[&_tr:last-child]:border-0",t),...e}));ns.displayName="TableBody";const lt=b.forwardRef(({className:t,...e},n)=>r.jsx("tr",{ref:n,className:Mt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));lt.displayName="TableRow";const we=b.forwardRef(({className:t,...e},n)=>r.jsx("th",{ref:n,className:Mt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));we.displayName="TableHead";const ve=b.forwardRef(({className:t,...e},n)=>r.jsx("td",{ref:n,className:Mt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));ve.displayName="TableCell";function b0(t,e){const[n,s]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>s(t),e);return()=>clearTimeout(a)},[t,e]),n}function zs({page:t,totalPages:e,total:n,pageSize:s,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:r.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[r.jsxs("span",{children:["共 ",n," 条"]}),i&&r.jsx("select",{value:s,onChange:c=>i(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>r.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>a(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),r.jsx("button",{type:"button",onClick:()=>a(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),r.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),r.jsx("button",{type:"button",onClick:()=>a(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),r.jsx("button",{type:"button",onClick:()=>a(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function pP(){const[t,e]=b.useState([]),[n,s]=b.useState([]),[a,i]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(""),v=b0(N,300),[k,C]=b.useState("all"),[E,M]=b.useState(!0),[P,H]=b.useState(null),[L,R]=b.useState(null),[O,ne]=b.useState(""),[ie,_]=b.useState(!1);async function ce(){M(!0),H(null);try{const U=k==="all"?"":k==="completed"?"completed":k,D=new URLSearchParams({page:String(f),pageSize:String(g),...U&&{status:U},...v&&{search:v}}),[W,le]=await Promise.all([De(`/api/admin/orders?${D}`),De("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),le!=null&&le.success&&le.users&&s(le.users)}catch(U){console.error("加载订单失败",U),H("加载订单失败,请检查网络后重试")}finally{M(!1)}}b.useEffect(()=>{m(1)},[v,k]),b.useEffect(()=>{ce()},[f,g,v,k]);const pe=U=>{var D;return U.userNickname||((D=n.find(W=>W.id===U.userId))==null?void 0:D.nickname)||"匿名用户"},z=U=>{var D;return((D=n.find(W=>W.id===U))==null?void 0:D.phone)||"-"},q=U=>{const D=U.productType||U.type||"",W=U.description||"";if(D==="balance_recharge")return{name:`余额充值 ¥${Number(U.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(D==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const le=W.split("-");if(le.length>=3)return{name:`第${le[1]}章 第${le[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return D==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:D==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:D==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return D==="section"?{name:`章节 ${U.productId||U.sectionId||""}`,type:"单章"}:D==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:D==="vip"?{name:"超级个体开通费用",type:"超级个体"}:D==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:D||"其他"}},F=Math.ceil(a/g)||1;async function A(){var U;if(!(!(L!=null&&L.orderSn)&&!(L!=null&&L.id))){_(!0),H(null);try{const D=await Dt("/api/admin/orders/refund",{orderSn:L.orderSn||L.id,reason:O||void 0});D!=null&&D.success?(R(null),ne(""),ce()):H((D==null?void 0:D.error)||"退款失败")}catch(D){const W=D;H(((U=W==null?void 0:W.data)==null?void 0:U.error)||"退款失败,请检查网络后重试")}finally{_(!1)}}}function J(){if(t.length===0){se.info("暂无数据可导出");return}const U=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],D=t.map(te=>{const K=q(te);return[te.orderSn||te.id||"",pe(te),z(te.userId),K.name,Number(te.amount||0).toFixed(2),te.paymentMethod==="wechat"?"微信支付":te.paymentMethod==="balance"?"余额支付":te.paymentMethod==="alipay"?"支付宝":te.paymentMethod||"微信支付",te.status==="refunded"?"已退款":te.status==="paid"||te.status==="completed"?"已完成":te.status==="pending"||te.status==="created"?"待支付":"已失败",te.status==="refunded"&&te.refundReason?te.refundReason:"-",te.referrerEarnings?Number(te.referrerEarnings).toFixed(2):"-",te.createdAt?new Date(te.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[U.join(","),...D].join(` -`),le=new Blob([W],{type:"text/csv;charset=utf-8"}),xe=URL.createObjectURL(le),Me=document.createElement("a");Me.href=xe,Me.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,Me.click(),URL.revokeObjectURL(xe)}return r.jsxs("div",{className:"p-8 w-full",children:[P&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:P}),r.jsx("button",{type:"button",onClick:()=>H(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(X,{variant:"outline",onClick:ce,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`}),"刷新"]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-400",children:"总收入:"}),r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),r.jsx("span",{className:"text-gray-600",children:"|"}),r.jsx("span",{className:"text-gray-400",children:"今日:"}),r.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[r.jsxs("div",{className:"relative flex-1 max-w-md",children:[r.jsx(Fa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:U=>j(U.target.value)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lj,{className:"w-4 h-4 text-gray-400"}),r.jsxs("select",{value:k,onChange:U=>C(U.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"created",children:"已创建"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]})]}),r.jsxs(X,{variant:"outline",onClick:J,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(mM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:E?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"订单号"}),r.jsx(we,{className:"text-gray-400",children:"用户"}),r.jsx(we,{className:"text-gray-400",children:"商品"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"支付方式"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"退款原因"}),r.jsx(we,{className:"text-gray-400",children:"分销佣金"}),r.jsx(we,{className:"text-gray-400",children:"下单时间"}),r.jsx(we,{className:"text-gray-400",children:"操作"})]})}),r.jsxs(ns,{children:[t.map(U=>{const D=q(U);return r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsxs(ve,{className:"font-mono text-xs text-gray-400",children:[(U.orderSn||U.id||"").slice(0,12),"..."]}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[pe(U),U.paymentMethod==="gift_pay"&&r.jsx(Ke,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),U.payerUserId&&U.paymentMethod!=="gift_pay"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:z(U.userId)}),U.payerUserId&&U.payerNickname&&r.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[U.paymentMethod==="gift_pay"?"赠送人:":"代付人:",U.payerNickname]})]})}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[D.name,(U.productType||U.type)==="vip"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:D.type})]})}),r.jsxs(ve,{className:"text-[#38bdac] font-bold",children:["¥",Number(U.amount||0).toFixed(2)]}),r.jsx(ve,{className:"text-gray-300",children:U.paymentMethod==="wechat"?"微信支付":U.paymentMethod==="balance"?"余额支付":U.paymentMethod==="alipay"?"支付宝":U.paymentMethod||"微信支付"}),r.jsx(ve,{children:U.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):U.status==="paid"||U.status==="completed"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):U.status==="pending"||U.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),r.jsx(ve,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:U.refundReason,children:U.status==="refunded"&&U.refundReason?U.refundReason:"-"}),r.jsx(ve,{className:"text-[#FFD700]",children:U.referrerEarnings?`¥${Number(U.referrerEarnings).toFixed(2)}`:"-"}),r.jsx(ve,{className:"text-gray-400 text-sm",children:new Date(U.createdAt).toLocaleString("zh-CN")}),r.jsx(ve,{children:(U.status==="paid"||U.status==="completed")&&U.paymentMethod!=="balance"&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{R(U),ne("")},children:[r.jsx(fj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},U.id)}),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),r.jsx(zs,{page:f,totalPages:F,total:a,pageSize:g,onPageChange:m,onPageSizeChange:U=>{y(U),m(1)}})]})})}),r.jsx(Rt,{open:!!L,onOpenChange:U=>!U&&R(null),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Pt,{children:r.jsx(Ot,{className:"text-white",children:"订单退款"})}),L&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",L.orderSn||L.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(L.amount||0).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:U=>ne(U.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>R(null),disabled:ie,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:A,disabled:ie,children:ie?"退款中...":"确认退款"})]})]})})]})}const rc=b.forwardRef(({className:t,...e},n)=>r.jsx("textarea",{className:Mt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...e}));rc.displayName="Textarea";const th=[{id:"register",label:"注册/登录",icon:"👤",color:"bg-blue-500/20 border-blue-500/40 text-blue-400",desc:"微信授权登录或手机号注册"},{id:"browse",label:"浏览章节",icon:"📖",color:"bg-purple-500/20 border-purple-500/40 text-purple-400",desc:"点击免费/付费章节预览"},{id:"bind_phone",label:"绑定手机",icon:"📱",color:"bg-cyan-500/20 border-cyan-500/40 text-cyan-400",desc:"触发付费章节后绑定手机"},{id:"first_pay",label:"首次付款",icon:"💳",color:"bg-green-500/20 border-green-500/40 text-green-400",desc:"购买单章或全书"},{id:"fill_profile",label:"完善资料",icon:"✍️",color:"bg-yellow-500/20 border-yellow-500/40 text-yellow-400",desc:"填写头像、MBTI、行业等"},{id:"match",label:"派对房匹配",icon:"🤝",color:"bg-orange-500/20 border-orange-500/40 text-orange-400",desc:"参与 Soul 派对房"},{id:"vip",label:"升级 VIP",icon:"👑",color:"bg-amber-500/20 border-amber-500/40 text-amber-400",desc:"付款 ¥1980 购买全书"},{id:"distribution",label:"开启分销",icon:"🔗",color:"bg-[#38bdac]/20 border-[#38bdac]/40 text-[#38bdac]",desc:"生成推广码并推荐好友"}];function mP(){var Hr,yn,so,ba,Wr;const[t,e]=tj(),n=t.get("pool"),s=t.get("tab")||"users",[a,i]=b.useState([]),[o,c]=b.useState(0),[u,h]=b.useState(1),[f,m]=b.useState(10),[g,y]=b.useState(""),N=b0(g,300),j=n==="vip"?"vip":n==="complete"?"complete":"all",[v,k]=b.useState(j),[C,E]=b.useState(!0),[M,P]=b.useState(!1),[H,L]=b.useState(null),[R,O]=b.useState(!1),[ne,ie]=b.useState("desc");b.useEffect(()=>{n==="vip"?k("vip"):n==="complete"?k("complete"):n==="all"&&k("all")},[n]);const[_,ce]=b.useState(!1),[pe,z]=b.useState(null),[q,F]=b.useState(!1),[A,J]=b.useState(!1),[U,D]=b.useState({referrals:[],stats:{}}),[W,le]=b.useState(!1),[xe,Me]=b.useState(null),[te,K]=b.useState(!1),[G,ge]=b.useState(null),[ae,fe]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Se,et]=b.useState([]),[st,_t]=b.useState(!1),[At,Ut]=b.useState(!1),[An,In]=b.useState(null),[It,sn]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[on,Es]=b.useState([]),[xn,Wn]=b.useState(!1),[Y,Ue]=b.useState(null),[Qe,wt]=b.useState(null),[dt,at]=b.useState({}),[xt,Xt]=b.useState(!1),[ln,ss]=b.useState([]),[xs,fr]=b.useState(0),[ys,Lr]=b.useState(1),[me]=b.useState(20),[ye,Zt]=b.useState(!1),Rn=b.useCallback(async()=>{Zt(!0);try{const $=await De(`/api/db/ckb-leads?mode=contact&page=${ys}&pageSize=${me}`);$!=null&&$.success&&(ss($.records||[]),fr($.total??0))}catch{ss([]),fr(0)}finally{Zt(!1)}},[ys,me]);b.useEffect(()=>{t.get("tab")==="leads"&&Rn()},[t.get("tab"),ys,Rn]);const[da,ua]=b.useState(null),_r=b.useCallback(async()=>{try{const $=await De("/api/admin/users/online-stats");$!=null&&$.success&&typeof $.onlineCount=="number"?ua($.onlineCount):ua(0)}catch{ua(null)}},[]);b.useEffect(()=>{_r();const $=setInterval(_r,1e4);return()=>clearInterval($)},[_r]);async function Qs($=!1){var Pe;E(!0),$&&P(!0),L(null);try{if(R){const _e=new URLSearchParams({search:N,limit:String(f*5)}),ct=await De(`/api/db/users/rfm?${_e}`);if(ct!=null&&ct.success){let cn=ct.users||[];ne==="asc"&&(cn=[...cn].reverse());const ut=(u-1)*f;i(cn.slice(ut,ut+f)),c(((Pe=ct.users)==null?void 0:Pe.length)??0),cn.length===0&&(O(!1),L("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else O(!1),L((ct==null?void 0:ct.error)||"RFM 加载失败,已切回普通模式")}else{const _e=new URLSearchParams({page:String(u),pageSize:String(f),search:N,...v==="vip"&&{vip:"true"},...v==="complete"&&{pool:"complete"}}),ct=await De(`/api/db/users?${_e}`);ct!=null&&ct.success?(i(ct.users||[]),c(ct.total??0)):L((ct==null?void 0:ct.error)||"加载失败")}}catch(_e){console.error("Load users error:",_e),L("网络错误")}finally{E(!1),$&&P(!1)}}b.useEffect(()=>{h(1)},[N,v,R]),b.useEffect(()=>{Qs()},[u,f,N,v,R,ne]);const ha=Math.ceil(o/f)||1,Xo=()=>{R?ne==="desc"?ie("asc"):(O(!1),ie("desc")):(O(!0),ie("desc"))},fa=$=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[$||""]||"bg-gray-500/20 text-gray-400";async function Zi($){var Pe;if(confirm("确定要删除这个用户吗?"))try{const _e=await ea(`/api/db/users?id=${encodeURIComponent($)}`);_e!=null&&_e.success?(se.success("已删除"),Qs()):se.error("删除失败: "+((_e==null?void 0:_e.error)||"未知错误"))}catch(_e){const ct=_e,cn=((Pe=ct==null?void 0:ct.data)==null?void 0:Pe.error)||(ct==null?void 0:ct.message)||"网络错误";se.error("删除失败: "+cn)}}const pa=$=>{z($),fe({phone:$.phone||"",nickname:$.nickname||"",password:"",isAdmin:!!($.isAdmin??!1),hasFullBook:!!($.hasFullBook??!1)}),ce(!0)},dc=()=>{z(null),fe({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),ce(!0)};async function pr(){if(!ae.phone||!ae.nickname){se.error("请填写手机号和昵称");return}F(!0);try{if(pe){const $=await Dt("/api/db/users",{id:pe.id,phone:ae.phone||void 0,nickname:ae.nickname,isAdmin:ae.isAdmin,hasFullBook:ae.hasFullBook,...ae.password&&{password:ae.password}});if(!($!=null&&$.success)){se.error("更新失败: "+(($==null?void 0:$.error)||""));return}}else{const $=await Nt("/api/db/users",{phone:ae.phone,nickname:ae.nickname,password:ae.password,isAdmin:ae.isAdmin});if(!($!=null&&$.success)){se.error("创建失败: "+(($==null?void 0:$.error)||""));return}}ce(!1),Qs()}catch{se.error("保存失败")}finally{F(!1)}}async function ma($){Me($),J(!0),le(!0);try{const Pe=await De(`/api/db/users/referrals?userId=${encodeURIComponent($.id)}`);Pe!=null&&Pe.success?D({referrals:Pe.referrals||[],stats:Pe.stats||{}}):D({referrals:[],stats:{}})}catch{D({referrals:[],stats:{}})}finally{le(!1)}}const Fs=b.useCallback(async()=>{_t(!0);try{const $=await De("/api/db/user-rules");$!=null&&$.success&&et($.rules||[])}catch{}finally{_t(!1)}},[]);async function mr(){if(!It.title){se.error("请填写规则标题");return}F(!0);try{if(An){const $=await Dt("/api/db/user-rules",{id:An.id,...It});if(!($!=null&&$.success)){se.error("更新失败: "+(($==null?void 0:$.error)||""));return}}else{const $=await Nt("/api/db/user-rules",It);if(!($!=null&&$.success)){se.error("创建失败: "+(($==null?void 0:$.error)||""));return}}Ut(!1),Fs()}catch{se.error("保存失败")}finally{F(!1)}}async function eo($){if(confirm("确定删除?"))try{const Pe=await ea(`/api/db/user-rules?id=${$}`);Pe!=null&&Pe.success&&Fs()}catch{}}async function Zo($){try{await Dt("/api/db/user-rules",{id:$.id,enabled:!$.enabled}),Fs()}catch{}}const yt=b.useCallback(async()=>{Wn(!0);try{const $=await De("/api/db/vip-members?limit=500");if($!=null&&$.success&&$.data){const Pe=[...$.data].map((_e,ct)=>({..._e,vipSort:typeof _e.vipSort=="number"?_e.vipSort:ct+1}));Pe.sort((_e,ct)=>(_e.vipSort??999999)-(ct.vipSort??999999)),Es(Pe)}else $&&$.error&&se.error($.error)}catch{se.error("加载超级个体列表失败")}finally{Wn(!1)}},[]),[jn,zr]=b.useState(!1),[gr,to]=b.useState(null),[xr,ga]=b.useState(""),[$r,Xs]=b.useState(!1),Ga=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],uc=$=>{to($),ga($.vipRole||""),zr(!0)},Kt=async $=>{const Pe=$.trim();if(gr){if(!Pe){se.error("请选择或输入标签");return}Xs(!0);try{const _e=await Dt("/api/db/users",{id:gr.id,vipRole:Pe});if(!(_e!=null&&_e.success)){se.error((_e==null?void 0:_e.error)||"更新超级个体标签失败");return}se.success("已更新超级个体标签"),zr(!1),to(null),await yt()}catch{se.error("更新超级个体标签失败")}finally{Xs(!1)}}},[hc,yr]=b.useState(!1),[br,Fr]=b.useState(null),[Ja,no]=b.useState(""),[Br,bs]=b.useState(!1),Ya=$=>{Fr($),no($.vipSort!=null?String($.vipSort):""),yr(!0)},vs=async()=>{if(!br)return;const $=Number(Ja);if(!Number.isFinite($)){se.error("请输入有效的数字序号");return}bs(!0);try{const Pe=await Dt("/api/db/users",{id:br.id,vipSort:$});if(!(Pe!=null&&Pe.success)){se.error((Pe==null?void 0:Pe.error)||"更新排序序号失败");return}se.success("已更新排序序号"),yr(!1),Fr(null),await yt()}catch{se.error("更新排序序号失败")}finally{bs(!1)}},Vr=($,Pe)=>{$.dataTransfer.effectAllowed="move",$.dataTransfer.setData("text/plain",Pe),Ue(Pe)},fc=($,Pe)=>{$.preventDefault(),Qe!==Pe&&wt(Pe)},pc=()=>{Ue(null),wt(null)},xa=async($,Pe)=>{$.preventDefault();const _e=$.dataTransfer.getData("text/plain")||Y;if(Ue(null),wt(null),!_e||_e===Pe)return;const ct=on.find(dn=>dn.id===_e),cn=on.find(dn=>dn.id===Pe);if(!ct||!cn)return;const ut=ct.vipSort??on.findIndex(dn=>dn.id===_e)+1,Qa=cn.vipSort??on.findIndex(dn=>dn.id===Pe)+1;Es(dn=>{const Un=[...dn],Ts=Un.findIndex(rs=>rs.id===_e),Ms=Un.findIndex(rs=>rs.id===Pe);if(Ts===-1||Ms===-1)return dn;const vr=[...Un],[va,Zs]=[vr[Ts],vr[Ms]];return vr[Ts]={...Zs,vipSort:ut},vr[Ms]={...va,vipSort:Qa},vr});try{const[dn,Un]=await Promise.all([Dt("/api/db/users",{id:_e,vipSort:Qa}),Dt("/api/db/users",{id:Pe,vipSort:ut})]);if(!(dn!=null&&dn.success)||!(Un!=null&&Un.success)){se.error((dn==null?void 0:dn.error)||(Un==null?void 0:Un.error)||"更新排序失败"),await yt();return}se.success("已更新排序"),await yt()}catch{se.error("更新排序失败"),await yt()}},ya=b.useCallback(async()=>{Xt(!0);try{const $=await De("/api/db/users/journey-stats");$!=null&&$.success&&$.stats&&at($.stats)}catch{}finally{Xt(!1)}},[]);return r.jsxs("div",{className:"p-8 w-full",children:[H&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:H}),r.jsx("button",{type:"button",onClick:()=>L(null),children:"×"})]}),r.jsx("div",{className:"flex justify-between items-center mb-6",children:r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),r.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",o," 位注册用户",da!==null&&r.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",da," 人"]}),R&&" · RFM 排序中"]})]})}),r.jsxs(Wd,{value:s,onValueChange:$=>{const Pe=new URLSearchParams(t);$==="users"?Pe.delete("tab"):Pe.set("tab",$),e(Pe)},className:"w-full",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[r.jsxs(Yt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[r.jsx(_n,{className:"w-4 h-4"})," 用户列表"]}),r.jsxs(Yt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Rn(),children:[r.jsx(dd,{className:"w-4 h-4"})," 获客列表"]}),r.jsxs(Yt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ya,children:[r.jsx(Ll,{className:"w-4 h-4"})," 用户旅程总览"]}),r.jsxs(Yt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Fs,children:[r.jsx(Mo,{className:"w-4 h-4"})," 规则配置"]}),r.jsxs(Yt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:yt,children:[r.jsx($l,{className:"w-4 h-4"})," 超级个体列表"]})]}),r.jsxs(Qt,{value:"users",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[r.jsxs(X,{variant:"outline",onClick:()=>Qs(!0),disabled:M,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${M?"animate-spin":""}`})," 刷新"]}),r.jsxs("select",{value:v,onChange:$=>{const Pe=$.target.value;k(Pe),h(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:R,children:[r.jsx("option",{value:"all",children:"全部用户"}),r.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),r.jsx("option",{value:"complete",children:"完善资料用户"})]}),r.jsxs("div",{className:"relative",children:[r.jsx(Fa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:g,onChange:$=>y($.target.value)})]}),r.jsxs(X,{onClick:dc,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(dd,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:C?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"用户信息"}),r.jsx(we,{className:"text-gray-400",children:"绑定信息"}),r.jsx(we,{className:"text-gray-400",children:"购买状态"}),r.jsx(we,{className:"text-gray-400",children:"分销收益"}),r.jsxs(we,{className:"text-gray-400 cursor-pointer select-none",onClick:Xo,children:[r.jsxs("div",{className:"flex items-center gap-1 group",children:[r.jsx(cd,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:"RFM分值"}),R?ne==="desc"?r.jsx(kd,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(sj,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(Hm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),R&&r.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),r.jsx(we,{className:"text-gray-400",children:"注册时间"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(ns,{children:[a.map($=>{var Pe,_e,ct;return r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:$.avatar?r.jsx("img",{src:$.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Pe=$.nickname)==null?void 0:Pe.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("button",{type:"button",onClick:()=>{ge($.id),K(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:$.nickname}),$.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),$.openId&&!((_e=$.id)!=null&&_e.startsWith("user_"))&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:$.openId?$.openId.slice(0,12)+"...":(ct=$.id)==null?void 0:ct.slice(0,12)})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[$.phone&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"📱"}),r.jsx("span",{className:"text-gray-300",children:$.phone})]}),$.wechatId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"💬"}),r.jsx("span",{className:"text-gray-300",children:$.wechatId})]}),$.openId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"🔗"}),r.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:$.openId,children:[$.openId.slice(0,12),"..."]})]}),!$.phone&&!$.wechatId&&!$.openId&&r.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),r.jsx(ve,{children:$.hasFullBook?r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String($.earnings||0)).toFixed(2)]}),parseFloat(String($.pendingEarnings||0))>0&&r.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String($.pendingEarnings||0)).toFixed(2)]}),r.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>ma($),role:"button",tabIndex:0,onKeyDown:cn=>cn.key==="Enter"&&ma($),children:[r.jsx(_n,{className:"w-3 h-3"})," 绑定",$.referralCount||0,"人"]})]})}),r.jsx(ve,{children:$.rfmScore!==void 0?r.jsx("div",{className:"flex flex-col gap-1",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-white font-bold text-base",children:$.rfmScore}),r.jsx(Ke,{className:`border-0 text-xs ${fa($.rfmLevel)}`,children:$.rfmLevel})]})}):r.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",r.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),r.jsx(ve,{className:"text-gray-400",children:$.createdAt?new Date($.createdAt).toLocaleDateString():"-"}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{ge($.id),K(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:r.jsx(qg,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>pa($),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:r.jsx(Vt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Zi($.id),title:"删除",children:r.jsx(Yn,{className:"w-4 h-4"})})]})})]},$.id)}),a.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),r.jsx(zs,{page:u,totalPages:ha,total:o,pageSize:f,onPageChange:h,onPageSizeChange:$=>{m($),h(1)}})]})})})]}),r.jsxs(Qt,{value:"leads",children:[r.jsx("div",{className:"flex items-center justify-end mb-4",children:r.jsxs(X,{variant:"outline",onClick:Rn,disabled:ye,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${ye?"animate-spin":""}`})," 刷新"]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:ye?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"昵称"}),r.jsx(we,{className:"text-gray-400",children:"手机号"}),r.jsx(we,{className:"text-gray-400",children:"微信号"}),r.jsx(we,{className:"text-gray-400",children:"对应 @人"}),r.jsx(we,{className:"text-gray-400",children:"获客计划"}),r.jsx(we,{className:"text-gray-400",children:"来源"}),r.jsx(we,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(ns,{children:[ln.map($=>r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:$.userNickname||$.name||"-"}),r.jsx(ve,{className:"text-gray-300",children:$.phone||"-"}),r.jsx(ve,{className:"text-gray-300",children:$.wechatId||"-"}),r.jsx(ve,{className:"text-[#38bdac]",children:$.personName||"-"}),r.jsx(ve,{className:"text-gray-400",children:$.ckbPlanId?`#${$.ckbPlanId}`:"-"}),r.jsx(ve,{className:"text-gray-400",children:$.source||"-"}),r.jsx(ve,{className:"text-gray-400",children:$.createdAt?new Date($.createdAt).toLocaleString():"-"})]},$.id)),ln.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无获客数据"})})]})]}),r.jsx(zs,{page:ys,totalPages:Math.ceil(xs/me)||1,total:xs,pageSize:me,onPageChange:Lr,onPageSizeChange:()=>{}})]})})})]}),r.jsxs(Qt,{value:"journey",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),r.jsxs(X,{variant:"outline",onClick:ya,disabled:xt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${xt?"animate-spin":""}`})," 刷新数据"]})]}),r.jsxs("div",{className:"relative mb-8",children:[r.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),r.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:th.map(($,Pe)=>r.jsxs("div",{className:"relative flex flex-col items-center",children:[r.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${$.color} text-center cursor-default`,children:[r.jsx("div",{className:"text-2xl mb-1",children:$.icon}),r.jsx("div",{className:`text-xs font-medium ${$.color.split(" ").find(_e=>_e.startsWith("text-"))}`,children:$.label}),dt[$.id]!==void 0&&r.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[r.jsx("span",{className:"font-bold text-white",children:dt[$.id]})," 人"]}),r.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:Pe+1})]}),Per.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:$.step}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-300",children:$.action}),r.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",$.next]})]})]},$.step))})]}),r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Gs,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),r.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),xt?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($e,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(dt).length>0?r.jsx("div",{className:"space-y-2",children:th.map($=>{const Pe=dt[$.id]||0,_e=Math.max(...th.map(cn=>dt[cn.id]||0),1),ct=Math.round(Pe/_e*100);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[$.icon," ",$.label]}),r.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${ct}%`}})}),r.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Pe})]},$.id)})}):r.jsx("div",{className:"text-center py-8",children:r.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),r.jsxs(Qt,{value:"rules",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"outline",onClick:Fs,disabled:st,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${st?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:()=>{In(null),sn({title:"",description:"",trigger:"",sort:0,enabled:!0}),Ut(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),st?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Se.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Gs,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),r.jsxs(X,{onClick:Fs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx($e,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):r.jsx("div",{className:"space-y-2",children:Se.map($=>r.jsx("div",{className:`p-4 rounded-lg border transition-all ${$.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[r.jsx(Vt,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),r.jsx("span",{className:"text-white font-medium",children:$.title}),$.trigger&&r.jsxs(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",$.trigger]}),r.jsx(Ke,{className:`text-xs border-0 ${$.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:$.enabled?"启用":"禁用"})]}),$.description&&r.jsx("p",{className:"text-gray-400 text-sm ml-6",children:$.description})]}),r.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[r.jsx(Ct,{checked:$.enabled,onCheckedChange:()=>Zo($)}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{In($),sn({title:$.title,description:$.description,trigger:$.trigger,sort:$.sort,enabled:$.enabled}),Ut(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Vt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>eo($.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Yn,{className:"w-4 h-4"})})]})]})},$.id))})]}),r.jsxs(Qt,{value:"vip-roles",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),r.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(X,{variant:"outline",onClick:yt,disabled:xn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${xn?"animate-spin":""}`})," ","刷新"]})})]}),xn?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):on.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx($l,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400 w-16",children:"序号"}),r.jsx(we,{className:"text-gray-400",children:"成员"}),r.jsx(we,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),r.jsx(we,{className:"text-gray-400 w-24",children:"排序值"}),r.jsx(we,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),r.jsx(ns,{children:on.map(($,Pe)=>{var cn;const _e=Y===$.id,ct=Qe===$.id;return r.jsxs(lt,{draggable:!0,onDragStart:ut=>Vr(ut,$.id),onDragOver:ut=>fc(ut,$.id),onDrop:ut=>xa(ut,$.id),onDragEnd:pc,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${_e?"opacity-60":""} ${ct?"bg-[#38bdac]/10":""}`,children:[r.jsx(ve,{className:"text-gray-300",children:Pe+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[$.avatar?r.jsx("img",{src:$.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((cn=$.name)==null?void 0:cn[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:$.name})})]})}),r.jsx(ve,{className:"text-gray-300 whitespace-nowrap",children:$.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),r.jsx(ve,{className:"text-gray-300",children:$.vipSort??Pe+1}),r.jsx(ve,{className:"text-right text-xs text-gray-300",children:r.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>uc($),title:"设置超级个体标签",children:r.jsx(ld,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{ge($.id),K(!0)},title:"编辑资料",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Ya($),title:"设置排序序号",children:r.jsx(Hm,{className:"w-3.5 h-3.5"})})]})})]},$.id)})})]})})})]})]}),r.jsx(Rt,{open:hc,onOpenChange:$=>{yr($),$||Fr(null)},children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Hm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",br==null?void 0:br.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Ja,onChange:$=>no($.target.value)})]}),r.jsxs(tn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>yr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:vs,disabled:Br,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),Br?"保存中...":"保存"]})]})]})}),r.jsx(Rt,{open:jn,onOpenChange:$=>{zr($),$||to(null)},children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx($l,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",gr==null?void 0:gr.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Ga.map($=>r.jsx(X,{variant:xr===$?"default":"outline",size:"sm",className:xr===$?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>ga($),children:$},$))}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"或手动输入"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:xr,onChange:$=>ga($.target.value)})]})]}),r.jsxs(tn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>zr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:()=>Kt(xr),disabled:$r,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),$r?"保存中...":"保存"]})]})]})}),r.jsx(Rt,{open:_,onOpenChange:ce,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[pe?r.jsx(Vt,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(dd,{className:"w-5 h-5 text-[#38bdac]"}),pe?"编辑用户":"添加用户"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:ae.phone,onChange:$=>fe({...ae,phone:$.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:ae.nickname,onChange:$=>fe({...ae,nickname:$.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:pe?"新密码 (留空则不修改)":"密码"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:pe?"留空则不修改":"请输入密码",value:ae.password,onChange:$=>fe({...ae,password:$.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"管理员权限"}),r.jsx(Ct,{checked:ae.isAdmin,onCheckedChange:$=>fe({...ae,isAdmin:$})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"已购全书"}),r.jsx(Ct,{checked:ae.hasFullBook,onCheckedChange:$=>fe({...ae,hasFullBook:$})})]})]}),r.jsxs(tn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>ce(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:pr,disabled:q,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),q?"保存中...":"保存"]})]})]})}),r.jsx(Rt,{open:At,onOpenChange:Ut,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Vt,{className:"w-5 h-5 text-[#38bdac]"}),An?"编辑规则":"添加规则"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则标题 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:It.title,onChange:$=>sn({...It,title:$.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则描述"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:It.description,onChange:$=>sn({...It,description:$.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"触发条件"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:It.trigger,onChange:$=>sn({...It,trigger:$.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:r.jsx(Z,{className:"text-gray-300",children:"启用状态"})}),r.jsx(Ct,{checked:It.enabled,onCheckedChange:$=>sn({...It,enabled:$})})]})]}),r.jsxs(tn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>Ut(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:mr,disabled:q,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),q?"保存中...":"保存"]})]})]})}),r.jsx(Rt,{open:A,onOpenChange:J,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",xe==null?void 0:xe.nickname]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Hr=U.stats)==null?void 0:Hr.total)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-green-400",children:((yn=U.stats)==null?void 0:yn.purchased)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((so=U.stats)==null?void 0:so.earnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((ba=U.stats)==null?void 0:ba.pendingEarnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),W?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx($e,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Wr=U.referrals)==null?void 0:Wr.length)??0)>0?r.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(U.referrals??[]).map(($,Pe)=>{var ct;const _e=$;return r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((ct=_e.nickname)==null?void 0:ct.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white text-sm",children:_e.nickname}),r.jsx("div",{className:"text-xs text-gray-500",children:_e.phone||(_e.hasOpenId?"微信用户":"未绑定")})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[_e.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),_e.status==="paid"&&r.jsxs(Ke,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",_e.purchasedSections,"章"]}),_e.status==="free"&&r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),r.jsx("span",{className:"text-xs text-gray-500",children:_e.createdAt?new Date(_e.createdAt).toLocaleDateString():""})]})]},_e.id||Pe)})}):r.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),r.jsx(tn,{children:r.jsx(X,{variant:"outline",onClick:()=>J(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),r.jsx(y0,{open:te,onClose:()=>K(!1),userId:G,onUserUpdated:Qs})]})}function Lh(t,[e,n]){return Math.min(n,Math.max(e,t))}var Ok=["PageUp","PageDown"],Dk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Lk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ac="Slider",[sx,gP,xP]=p0(ac),[_k]=qi(ac,[xP]),[yP,Vf]=_k(ac),zk=b.forwardRef((t,e)=>{const{name:n,min:s=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[s],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:N,...j}=t,v=b.useRef(new Set),k=b.useRef(0),E=o==="horizontal"?bP:vP,[M=[],P]=_o({prop:f,defaultProp:h,onChange:ie=>{var ce;(ce=[...v.current][k.current])==null||ce.focus(),m(ie)}}),H=b.useRef(M);function L(ie){const _=SP(M,ie);ne(ie,_)}function R(ie){ne(ie,k.current)}function O(){const ie=H.current[k.current];M[k.current]!==ie&&g(M)}function ne(ie,_,{commit:ce}={commit:!1}){const pe=MP(i),z=AP(Math.round((ie-s)/i)*i+s,pe),q=Lh(z,[s,a]);P((F=[])=>{const A=jP(F,q,_);if(TP(A,u*i)){k.current=A.indexOf(q);const J=String(A)!==String(F);return J&&ce&&g(A),J?A:F}else return F})}return r.jsx(yP,{scope:t.__scopeSlider,name:n,disabled:c,min:s,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:M,orientation:o,form:N,children:r.jsx(sx.Provider,{scope:t.__scopeSlider,children:r.jsx(sx.Slot,{scope:t.__scopeSlider,children:r.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...j,ref:e,onPointerDown:ht(j.onPointerDown,()=>{c||(H.current=M)}),min:s,max:a,inverted:y,onSlideStart:c?void 0:L,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&ne(s,0,{commit:!0}),onEndKeyDown:()=>!c&&ne(a,M.length-1,{commit:!0}),onStepKeyDown:({event:ie,direction:_})=>{if(!c){const z=Ok.includes(ie.key)||ie.shiftKey&&Dk.includes(ie.key)?10:1,q=k.current,F=M[q],A=i*z*_;ne(F+A,q,{commit:!0})}}})})})})});zk.displayName=ac;var[$k,Fk]=_k(ac,{startEdge:"left",endEdge:"right",size:"width",direction:1}),bP=b.forwardRef((t,e)=>{const{min:n,max:s,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=Tt(e,E=>g(E)),N=b.useRef(void 0),j=$f(a),v=j==="ltr",k=v&&!i||!v&&i;function C(E){const M=N.current||m.getBoundingClientRect(),P=[0,M.width],L=v0(P,k?[n,s]:[s,n]);return N.current=M,L(E-M.left)}return r.jsx($k,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:r.jsx(Bk,{dir:j,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const M=C(E.clientX);o==null||o(M)},onSlideMove:E=>{const M=C(E.clientX);c==null||c(M)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:E=>{const P=Lk[k?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:P?-1:1})}})})}),vP=b.forwardRef((t,e)=>{const{min:n,max:s,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=Tt(e,f),g=b.useRef(void 0),y=!a;function N(j){const v=g.current||f.current.getBoundingClientRect(),k=[0,v.height],E=v0(k,y?[s,n]:[n,s]);return g.current=v,E(j-v.top)}return r.jsx($k,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:r.jsx(Bk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const v=N(j.clientY);i==null||i(v)},onSlideMove:j=>{const v=N(j.clientY);o==null||o(v)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:j=>{const k=Lk[y?"from-bottom":"from-top"].includes(j.key);u==null||u({event:j,direction:k?-1:1})}})})}),Bk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:s,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Vf(ac,n);return r.jsx(mt.span,{...h,ref:e,onKeyDown:ht(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):Ok.concat(Dk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:ht(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():s(m)}),onPointerMove:ht(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:ht(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),i(m))})})}),Vk="SliderTrack",Hk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(Vk,n);return r.jsx(mt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:e})});Hk.displayName=Vk;var rx="SliderRange",Wk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(rx,n),i=Fk(rx,n),o=b.useRef(null),c=Tt(e,o),u=a.values.length,h=a.values.map(g=>qk(g,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return r.jsx(mt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});Wk.displayName=rx;var ax="SliderThumb",Uk=b.forwardRef((t,e)=>{const n=gP(t.__scopeSlider),[s,a]=b.useState(null),i=Tt(e,c=>a(c)),o=b.useMemo(()=>s?n().findIndex(c=>c.ref.current===s):-1,[n,s]);return r.jsx(NP,{...t,ref:i,index:o})}),NP=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:s,name:a,...i}=t,o=Vf(ax,n),c=Fk(ax,n),[u,h]=b.useState(null),f=Tt(e,C=>h(C)),m=u?o.form||!!u.closest("form"):!0,g=x0(u),y=o.values[s],N=y===void 0?0:qk(y,o.min,o.max),j=kP(s,o.values.length),v=g==null?void 0:g[c.size],k=v?CP(v,N,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),r.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${k}px)`},children:[r.jsx(sx.ItemSlot,{scope:t.__scopeSlider,children:r.jsx(mt.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":o.min,"aria-valuenow":y,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:ht(t.onFocus,()=>{o.valueIndexToChangeRef.current=s})})}),m&&r.jsx(Kk,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},s)]})});Uk.displayName=ax;var wP="RadioBubbleInput",Kk=b.forwardRef(({__scopeSlider:t,value:e,...n},s)=>{const a=b.useRef(null),i=Tt(a,s),o=g0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(mt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});Kk.displayName=wP;function jP(t=[],e,n){const s=[...t];return s[n]=e,s.sort((a,i)=>a-i)}function qk(t,e,n){const i=100/(n-e)*(t-e);return Lh(i,[0,100])}function kP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function SP(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),s=Math.min(...n);return n.indexOf(s)}function CP(t,e,n){const s=t/2,i=v0([0,50],[0,s]);return(s-i(e)*n)*n}function EP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function TP(t,e){if(e>0){const n=EP(t);return Math.min(...n)>=e}return!0}function v0(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(n-t[0])}}function MP(t){return(String(t).split(".")[1]||"").length}function AP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var IP=zk,RP=Hk,PP=Wk,OP=Uk;function DP({className:t,defaultValue:e,value:n,min:s=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[s,a],[n,e,s,a]);return r.jsxs(IP,{defaultValue:e,value:n,min:s,max:a,className:Mt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[r.jsx(RP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:r.jsx(PP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>r.jsx(OP,{className:"block size-4 shrink-0 rounded-full border-2 border-[#38bdac] bg-white shadow-sm focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},u))]})}const LP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Gk(t){const[e,n]=b.useState(LP),[s,a]=b.useState(!0),[i,o]=b.useState(!1);b.useEffect(()=>{De("/api/admin/referral-settings").then(h=>{const f=h==null?void 0:h.data;f&&typeof f=="object"&&n({distributorShare:f.distributorShare??90,minWithdrawAmount:f.minWithdrawAmount??10,bindingDays:f.bindingDays??30,userDiscount:f.userDiscount??5,enableAutoWithdraw:f.enableAutoWithdraw??!1,vipOrderShareVip:f.vipOrderShareVip??20,vipOrderShareNonVip:f.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>a(!1))},[]);const c=async()=>{o(!0);try{const h={distributorShare:Number(e.distributorShare)||0,minWithdrawAmount:Number(e.minWithdrawAmount)||0,bindingDays:Number(e.bindingDays)||0,userDiscount:Number(e.userDiscount)||0,enableAutoWithdraw:!!e.enableAutoWithdraw,vipOrderShareVip:Number(e.vipOrderShareVip)||20,vipOrderShareNonVip:Number(e.vipOrderShareNonVip)||10},f=await Nt("/api/admin/referral-settings",h);if(!f||f.success===!1){se.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}se.success(`✅ 分销配置已保存成功! +For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},RR="DialogDescriptionWarning",PR=({contentRef:t,descriptionId:e})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ak(RR).contentName}}.`;return b.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(s))},[s,t,e]),null},OR=Kj,DR=Jj,LR=Yj,_R=Qj,zR=Zj,FR=tk,$R=sk;function It(t){return r.jsx(OR,{"data-slot":"dialog",...t})}function BR(t){return r.jsx(DR,{...t})}const ik=b.forwardRef(({className:t,...e},n)=>r.jsx(LR,{ref:n,className:Mt("fixed inset-0 z-50 bg-black/50",t),...e}));ik.displayName="DialogOverlay";const Ct=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...s},a)=>r.jsxs(BR,{children:[r.jsx(ik,{}),r.jsxs(_R,{ref:a,"aria-describedby":void 0,className:Mt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg",t),...s,children:[e,n&&r.jsxs($R,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[r.jsx(gs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ct.displayName="DialogContent";function Rt({className:t,...e}){return r.jsx("div",{className:Mt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function sn({className:t,...e}){return r.jsx("div",{className:Mt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Pt(t){return r.jsx(zR,{className:"text-lg font-semibold leading-none",...t})}function Cd(t){return r.jsx(FR,{className:"text-sm text-muted-foreground",...t})}const VR=bj("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ke({className:t,variant:e,asChild:n=!1,...s}){const a=n?gj:"span";return r.jsx(a,{className:Mt(VR({variant:e}),t),...s})}var HR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],WR=HR.reduce((t,e)=>{const n=mj(`Primitive.${e}`),s=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{}),UR="Label",ok=b.forwardRef((t,e)=>r.jsx(WR.label,{...t,ref:e,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));ok.displayName=UR;var lk=ok;const Z=b.forwardRef(({className:t,...e},n)=>r.jsx(lk,{ref:n,className:Mt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Z.displayName=lk.displayName;function p0(t){const e=t+"CollectionProvider",[n,s]=qi(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=j=>{const{scope:v,children:k}=j,C=Cs.useRef(null),E=Cs.useRef(new Map).current;return r.jsx(a,{scope:v,itemMap:E,collectionRef:C,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Sd(c),h=Cs.forwardRef((j,v)=>{const{scope:k,children:C}=j,E=i(c,k),M=Tt(v,E.collectionRef);return r.jsx(u,{ref:M,children:C})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Sd(f),y=Cs.forwardRef((j,v)=>{const{scope:k,children:C,...E}=j,M=Cs.useRef(null),P=Tt(v,M),H=i(f,k);return Cs.useEffect(()=>(H.itemMap.set(M,{ref:M,...E}),()=>void H.itemMap.delete(M))),r.jsx(g,{[m]:"",ref:P,children:C})});y.displayName=f;function N(j){const v=i(t+"CollectionConsumer",j);return Cs.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((H,L)=>E.indexOf(H.ref.current)-E.indexOf(L.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},N,s]}var KR=b.createContext(void 0);function Ff(t){const e=b.useContext(KR);return t||e||"ltr"}var ng="rovingFocusGroup.onEntryFocus",qR={bubbles:!1,cancelable:!0},Hd="RovingFocusGroup",[nx,ck,GR]=p0(Hd),[JR,dk]=qi(Hd,[GR]),[YR,QR]=JR(Hd),uk=b.forwardRef((t,e)=>r.jsx(nx.Provider,{scope:t.__scopeRovingFocusGroup,children:r.jsx(nx.Slot,{scope:t.__scopeRovingFocusGroup,children:r.jsx(XR,{...t,ref:e})})}));uk.displayName=Hd;var XR=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=Tt(e,g),N=Ff(i),[j,v]=_o({prop:o,defaultProp:c??null,onChange:u,caller:Hd}),[k,C]=b.useState(!1),E=Fi(h),M=ck(n),P=b.useRef(!1),[H,L]=b.useState(0);return b.useEffect(()=>{const R=g.current;if(R)return R.addEventListener(ng,E),()=>R.removeEventListener(ng,E)},[E]),r.jsx(YR,{scope:n,orientation:s,dir:N,loop:a,currentTabStopId:j,onItemFocus:b.useCallback(R=>v(R),[v]),onItemShiftTab:b.useCallback(()=>C(!0),[]),onFocusableItemAdd:b.useCallback(()=>L(R=>R+1),[]),onFocusableItemRemove:b.useCallback(()=>L(R=>R-1),[]),children:r.jsx(pt.div,{tabIndex:k||H===0?-1:0,"data-orientation":s,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:dt(t.onMouseDown,()=>{P.current=!0}),onFocus:dt(t.onFocus,R=>{const O=!P.current;if(R.target===R.currentTarget&&O&&!k){const se=new CustomEvent(ng,qR);if(R.currentTarget.dispatchEvent(se),!se.defaultPrevented){const ie=M().filter(G=>G.focusable),z=ie.find(G=>G.active),ce=ie.find(G=>G.id===j),_=[z,ce,...ie].filter(Boolean).map(G=>G.ref.current);pk(_,f)}}P.current=!1}),onBlur:dt(t.onBlur,()=>C(!1))})})}),hk="RovingFocusGroupItem",fk=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=Pi(),h=i||u,f=QR(hk,n),m=f.currentTabStopId===h,g=ck(n),{onFocusableItemAdd:y,onFocusableItemRemove:N,currentTabStopId:j}=f;return b.useEffect(()=>{if(s)return y(),()=>N()},[s,y,N]),r.jsx(nx.ItemSlot,{scope:n,id:h,focusable:s,active:a,children:r.jsx(pt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:dt(t.onMouseDown,v=>{s?f.onItemFocus(h):v.preventDefault()}),onFocus:dt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:dt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=tP(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=g().filter(M=>M.focusable).map(M=>M.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const M=E.indexOf(v.currentTarget);E=f.loop?nP(E,M+1):E.slice(M+1)}setTimeout(()=>pk(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:j!=null}):o})})});fk.displayName=hk;var ZR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function tP(t,e,n){const s=eP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return ZR[s]}function pk(t,e=!1){const n=document.activeElement;for(const s of t)if(s===n||(s.focus({preventScroll:e}),document.activeElement!==n))return}function nP(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var sP=uk,rP=fk,$f="Tabs",[aP]=qi($f,[dk]),mk=dk(),[iP,m0]=aP($f),gk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Ff(c),[m,g]=_o({prop:s,onChange:a,defaultProp:i??"",caller:$f});return r.jsx(iP,{scope:n,baseId:Pi(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:r.jsx(pt.div,{dir:f,"data-orientation":o,...h,ref:e})})});gk.displayName=$f;var xk="TabsList",yk=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:s=!0,...a}=t,i=m0(xk,n),o=mk(n);return r.jsx(sP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(pt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});yk.displayName=xk;var bk="TabsTrigger",vk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...i}=t,o=m0(bk,n),c=mk(n),u=jk(o.baseId,s),h=kk(o.baseId,s),f=s===o.value;return r.jsx(rP,{asChild:!0,...c,focusable:!a,active:f,children:r.jsx(pt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...i,ref:e,onMouseDown:dt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(s):m.preventDefault()}),onKeyDown:dt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(s)}),onFocus:dt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(s)})})})});vk.displayName=bk;var Nk="TabsContent",wk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:s,forceMount:a,children:i,...o}=t,c=m0(Nk,n),u=jk(c.baseId,s),h=kk(c.baseId,s),f=s===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),r.jsx(Vd,{present:a||f,children:({present:g})=>r.jsx(pt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&i})})});wk.displayName=Nk;function jk(t,e){return`${t}-trigger-${e}`}function kk(t,e){return`${t}-content-${e}`}var oP=gk,Sk=yk,Ck=vk,Ek=wk;const Wd=oP,sc=b.forwardRef(({className:t,...e},n)=>r.jsx(Sk,{ref:n,className:Mt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));sc.displayName=Sk.displayName;const Zt=b.forwardRef(({className:t,...e},n)=>r.jsx(Ck,{ref:n,className:Mt("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));Zt.displayName=Ck.displayName;const en=b.forwardRef(({className:t,...e},n)=>r.jsx(Ek,{ref:n,className:Mt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));en.displayName=Ek.displayName;function g0(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function x0(t){const[e,n]=b.useState(void 0);return xs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,c;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return s.observe(t,{box:"border-box"}),()=>s.unobserve(t)}else n(void 0)},[t]),e}var Bf="Switch",[lP]=qi(Bf),[cP,dP]=lP(Bf),Tk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:s,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),N=Tt(e,E=>y(E)),j=b.useRef(!1),v=g?f||!!g.closest("form"):!0,[k,C]=_o({prop:a,defaultProp:i??!1,onChange:h,caller:Bf});return r.jsxs(cP,{scope:n,checked:k,disabled:c,children:[r.jsx(pt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":Rk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:dt(t.onClick,E=>{C(M=>!M),v&&(j.current=E.isPropagationStopped(),j.current||E.stopPropagation())})}),v&&r.jsx(Ik,{control:g,bubbles:!j.current,name:s,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});Tk.displayName=Bf;var Mk="SwitchThumb",Ak=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...s}=t,a=dP(Mk,n);return r.jsx(pt.span,{"data-state":Rk(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:e})});Ak.displayName=Mk;var uP="SwitchBubbleInput",Ik=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:s=!0,...a},i)=>{const o=b.useRef(null),c=Tt(o,i),u=g0(n),h=x0(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const N=new Event("click",{bubbles:s});y.call(f,n),f.dispatchEvent(N)}},[u,n,s]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ik.displayName=uP;function Rk(t){return t?"checked":"unchecked"}var Pk=Tk,hP=Ak;const jt=b.forwardRef(({className:t,...e},n)=>r.jsx(Pk,{className:Mt("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:r.jsx(hP,{className:Mt("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));jt.displayName=Pk.displayName;function y0({open:t,onClose:e,userId:n,onUserUpdated:s}){var tn;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState(null),[g,y]=b.useState(!1),[N,j]=b.useState(!1),[v,k]=b.useState(!1),[C,E]=b.useState("info"),[M,P]=b.useState(""),[H,L]=b.useState(""),[R,O]=b.useState([]),[se,ie]=b.useState(""),[z,ce]=b.useState(""),[me,_]=b.useState(""),[G,$]=b.useState(!1),[A,Y]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[U,D]=b.useState([]),[W,le]=b.useState(!1),[ye,Ae]=b.useState(""),[ne,K]=b.useState(""),[J,ge]=b.useState(!1),[ae,pe]=b.useState(!1),[Se,tt]=b.useState(null),[at,Dt]=b.useState(null),[kt,At]=b.useState(""),[Gt,In]=b.useState(""),[Lt,xn]=b.useState(""),[ln,Bs]=b.useState(!1),[yn,is]=b.useState(null),[Un,Kn]=b.useState("");b.useEffect(()=>{t&&n&&(E("info"),tt(null),Dt(null),is(null),Kn(""),ce(""),_(""),_t(),De("/api/db/vip-roles").then(he=>{he!=null&&he.success&&he.data&&D(he.data)}).catch(()=>{}))},[t,n]);async function _t(){if(n){y(!0);try{const he=await De(`/api/db/users?id=${encodeURIComponent(n)}`);if(he!=null&&he.success&&he.user){const xe=he.user;i(xe),P(xe.phone||""),L(xe.nickname||""),At(xe.phone||""),In(xe.wechatId||""),xn(xe.openId||"");try{O(typeof xe.tags=="string"?JSON.parse(xe.tags||"[]"):[])}catch{O([])}Y({isVip:!!(xe.isVip??!1),vipExpireDate:xe.vipExpireDate?String(xe.vipExpireDate).slice(0,10):"",vipRole:String(xe.vipRole??""),vipName:String(xe.vipName??""),vipProject:String(xe.vipProject??""),vipContact:String(xe.vipContact??""),vipBio:String(xe.vipBio??"")})}try{const xe=await De(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=50`);xe!=null&&xe.success&&xe.tracks&&c(xe.tracks)}catch{c([])}try{const xe=await De(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);xe!=null&&xe.success&&xe.referrals&&h(xe.referrals)}catch{h([])}try{const xe=await De(`/api/admin/users/${encodeURIComponent(n)}/balance`);xe!=null&&xe.success&&xe.data?m(xe.data):m(null)}catch{m(null)}}catch(he){console.error("Load user detail error:",he)}finally{y(!1)}}}async function qn(){if(!(a!=null&&a.phone)){te.info("用户未绑定手机号,无法同步");return}j(!0);try{const he=await Nt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});he!=null&&he.success?(te.success("同步成功"),_t()):te.error("同步失败: "+(he==null?void 0:he.error))}catch(he){console.error("Sync CKB error:",he),te.error("同步失败")}finally{j(!1)}}async function zn(){if(a){if(A.isVip&&!A.vipExpireDate.trim()){te.error("开启 VIP 请填写有效到期日");return}k(!0);try{const he={id:a.id,phone:M||void 0,nickname:H||void 0,tags:JSON.stringify(R),isVip:A.isVip,vipExpireDate:A.isVip?A.vipExpireDate:void 0,vipRole:A.vipRole||void 0,vipName:A.vipName||void 0,vipProject:A.vipProject||void 0,vipContact:A.vipContact||void 0,vipBio:A.vipBio||void 0},xe=await Ot("/api/db/users",he);xe!=null&&xe.success?(te.success("保存成功"),_t(),s==null||s()):te.error("保存失败: "+(xe==null?void 0:xe.error))}catch(he){console.error("Save user error:",he),te.error("保存失败")}finally{k(!1)}}}const ls=()=>{se&&!R.includes(se)&&(O([...R,se]),ie(""))},q=he=>O(R.filter(xe=>xe!==he));async function He(){if(a){if(!z){te.error("请输入新密码");return}if(z!==me){te.error("两次密码不一致");return}if(z.length<6){te.error("密码至少 6 位");return}$(!0);try{const he=await Ot("/api/db/users",{id:a.id,password:z});he!=null&&he.success?(te.success("修改成功"),ce(""),_("")):te.error("修改失败: "+((he==null?void 0:he.error)||""))}catch{te.error("修改失败")}finally{$(!1)}}}async function mt(){if(!a)return;const he=parseFloat(ye);if(Number.isNaN(he)||he===0){te.error("请输入有效金额(正数增加、负数扣减)");return}ge(!0);try{const xe=await Nt(`/api/admin/users/${a.id}/balance/adjust`,{amount:he,remark:ne||void 0});xe!=null&&xe.success?(te.success("余额已调整"),le(!1),Ae(""),K(""),_t(),s==null||s()):te.error("调整失败: "+((xe==null?void 0:xe.error)||""))}catch{te.error("调整失败")}finally{ge(!1)}}async function $t(){if(!kt&&!Lt&&!Gt){Dt("请至少输入手机号、微信号或 OpenID 中的一项");return}pe(!0),Dt(null),tt(null);try{const he=new URLSearchParams;kt&&he.set("phone",kt),Lt&&he.set("openId",Lt),Gt&&he.set("wechatId",Gt);const xe=await De(`/api/admin/shensheshou/query?${he}`);xe!=null&&xe.success&&xe.data?(tt(xe.data),a&&await ut(xe.data)):Dt((xe==null?void 0:xe.error)||"未查询到数据,该用户可能未在神射手收录")}catch(he){console.error("SSS query error:",he),Dt("请求失败,请检查神射手接口配置")}finally{pe(!1)}}async function ut(he){if(a)try{await Nt("/api/admin/shensheshou/enrich",{userId:a.id,phone:kt||a.phone||"",openId:Lt||a.openId||"",wechatId:Gt||a.wechatId||""}),_t()}catch(xe){console.error("SSS enrich error:",xe)}}async function ot(){if(a){Bs(!0),is(null);try{const he={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:R}]},xe=await Nt("/api/admin/shensheshou/ingest",he);xe!=null&&xe.success&&xe.data?is(xe.data):is({error:(xe==null?void 0:xe.error)||"推送失败"})}catch(he){console.error("SSS ingest error:",he),is({error:"请求失败"})}finally{Bs(!1)}}}const xt=he=>{const zt={view_chapter:Ys,purchase:Qg,match:_n,login:Ao,register:Ao,share:Rr,bind_phone:g5,bind_wechat:a5,fill_profile:ld,visit_page:Ll}[he]||Kg;return r.jsx(zt,{className:"w-4 h-4"})};return t?r.jsxs(r.Fragment,{children:[r.jsx(It,{open:t,onOpenChange:()=>e(),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?r.jsxs("div",{className:"flex flex-col h-[75vh]",children:[r.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:a.avatar?r.jsx("img",{src:a.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((tn=a.nickname)==null?void 0:tn.charAt(0))||"?"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("h3",{className:"text-lg font-bold text-white",children:a.nickname}),a.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),a.hasFullBook&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),a.vipRole&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:a.vipRole})]}),r.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[a.phone?`📱 ${a.phone}`:"未绑定手机",a.wechatId&&` · 💬 ${a.wechatId}`,a.mbti&&` · ${a.mbti}`]}),r.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[r.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",a.id.slice(0,16),"…"]}),a.referralCode&&r.jsxs("p",{className:"text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"推广码:"}),r.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:a.referralCode})]})]})]}),r.jsxs("div",{className:"text-right shrink-0",children:[r.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(a.earnings||0).toFixed(2)]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),r.jsxs(Wd,{value:C,onValueChange:E,className:"flex-1 flex flex-col overflow-hidden",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[r.jsx(Zt,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),r.jsx(Zt,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),r.jsxs(Zt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Ll,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),r.jsx(Zt,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),r.jsxs(Zt,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[r.jsx(Fa,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),r.jsxs(en,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:M,onChange:he=>P(he.target.value),disabled:!!(a!=null&&a.phone)}),(a==null?void 0:a.phone)&&r.jsx("p",{className:"text-xs text-gray-500",children:"编辑时手机号不可修改"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:H,onChange:he=>L(he.target.value)})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.openId&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),r.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:a.openId})]}),a.region&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(hj,{className:"w-4 h-4 text-gray-500"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),r.jsx("p",{className:"text-white",children:a.region})]})]}),a.industry&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),r.jsx("p",{className:"text-white",children:a.industry})]}),a.position&&r.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),r.jsx("p",{className:"text-white",children:a.position})]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:a.referralCount??0})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),r.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(a.pendingEarnings??0).toFixed(2)]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg flex flex-col justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"当前余额"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac]",children:["¥",((f==null?void 0:f.balance)??0).toFixed(2)]})]}),r.jsx(X,{size:"sm",variant:"outline",className:"mt-2 border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 text-xs",onClick:()=>{Ae(""),K(""),le(!0)},children:"调整余额"})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),r.jsx("p",{className:"text-sm text-white",children:a.createdAt?new Date(a.createdAt).toLocaleDateString():"-"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(uj,{className:"w-4 h-4 text-yellow-400"}),r.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:z,onChange:he=>ce(he.target.value)}),r.jsx(re,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:me,onChange:he=>_(he.target.value)}),r.jsx(X,{size:"sm",onClick:He,disabled:G||!z||!me,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:G?"保存中...":"确认修改"})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fl,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-400 text-sm",children:"VIP 会员"}),r.jsx(jt,{checked:A.isVip,onCheckedChange:he=>Y(xe=>({...xe,isVip:he}))})]}),A.isVip&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"到期日"}),r.jsx(re,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:A.vipExpireDate,onChange:he=>Y(xe=>({...xe,vipExpireDate:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"角色"}),r.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:A.vipRole,onChange:he=>Y(xe=>({...xe,vipRole:he.target.value})),children:[r.jsx("option",{value:"",children:"请选择"}),U.map(he=>r.jsx("option",{value:he.name,children:he.name},he.id))]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"展示名"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:A.vipName,onChange:he=>Y(xe=>({...xe,vipName:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"项目"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"如:某某科技",value:A.vipProject,onChange:he=>Y(xe=>({...xe,vipProject:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"联系方式"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"微信/手机等",value:A.vipContact,onChange:he=>Y(xe=>({...xe,vipContact:he.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"简介"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"简短介绍",value:A.vipBio,onChange:he=>Y(xe=>({...xe,vipBio:he.target.value}))})]})]})]})]}),a.isVip&&r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fl,{className:"w-4 h-4 text-amber-400"}),r.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:a.vipRole||"VIP"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.vipName&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"展示名:"}),r.jsx("span",{className:"text-white",children:a.vipName})]}),a.vipProject&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"项目:"}),r.jsx("span",{className:"text-white",children:a.vipProject})]}),a.vipContact&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"联系方式:"}),r.jsx("span",{className:"text-white",children:a.vipContact})]}),a.vipExpireDate&&r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"到期时间:"}),r.jsx("span",{className:"text-white",children:new Date(a.vipExpireDate).toLocaleDateString()})]})]}),a.vipBio&&r.jsx("p",{className:"text-gray-400 text-sm mt-2",children:a.vipBio})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(zi,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"微信归属"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:Un,onChange:he=>Kn(he.target.value)}),r.jsxs(X,{size:"sm",onClick:async()=>{if(!(!Un||!a))try{await Ot("/api/db/users",{id:a.id,wechatId:Un}),te.success("已保存微信归属"),_t()}catch{te.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[r.jsx(wn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),a.wechatId&&r.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",r.jsx("span",{className:"text-purple-400",children:a.wechatId})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Rr,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),r.jsx(X,{size:"sm",onClick:qn,disabled:N||!a.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:N?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"同步状态:"}),a.ckbSyncedAt?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-gray-500",children:"最后同步:"}),r.jsx("span",{className:"text-gray-300 ml-1",children:a.ckbSyncedAt?new Date(a.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),r.jsxs(en,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(ld,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户标签"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),r.jsxs("div",{className:"mb-3 p-2.5 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-center gap-2 text-xs text-gray-400",children:[r.jsx(Ug,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),r.jsx("div",{className:"mb-4 space-y-3",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(he=>r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:he.category}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:he.tags.map(xe=>r.jsxs("button",{type:"button",onClick:()=>{R.includes(xe)?q(xe):O([...R,xe])},className:`px-2 py-0.5 rounded text-xs border transition-all ${R.includes(xe)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[R.includes(xe)?"✓ ":"",xe]},xe))})]},he.category))}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),r.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[R.map((he,xe)=>r.jsxs(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[he,r.jsx("button",{type:"button",onClick:()=>q(he),className:"ml-1 hover:text-red-400",children:r.jsx(gs,{className:"w-3 h-3"})})]},xe)),R.length===0&&r.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:se,onChange:he=>ie(he.target.value),onKeyDown:he=>he.key==="Enter"&&ls()}),r.jsx(X,{onClick:ls,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),(()=>{const he=a.tags||a.ckbTags||"";let xe=[];try{const Rn=typeof he=="string"?JSON.parse(he||"[]"):[];xe=Array.isArray(Rn)?Rn:typeof he=="string"?he.split(","):[]}catch{xe=typeof he=="string"?he.split(","):[]}const zt=xe.map(Rn=>String(Rn).trim()).filter(Boolean);return zt.length===0?null:r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(ld,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:zt.map((Rn,da)=>r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:Rn},da))})]})})()]}),r.jsxs(en,{value:"journey",className:"flex-1 overflow-auto",children:[r.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[r.jsx(Ll,{className:"w-4 h-4 text-[#38bdac]"}),r.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),r.jsx("div",{className:"space-y-2",children:o.length>0?o.map((he,xe)=>r.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:xt(he.action)}),xe0?u.map((he,xe)=>{var Rn;const zt=he;return r.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((Rn=zt.nickname)==null?void 0:Rn.charAt(0))||"?"}),r.jsx("span",{className:"text-white text-sm",children:zt.nickname})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[zt.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),r.jsx("span",{className:"text-gray-500 text-xs",children:zt.createdAt?new Date(zt.createdAt).toLocaleDateString():""})]})]},zt.id||xe)}):r.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),r.jsxs(en,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Fa,{className:"w-5 h-5 text-[#38bdac]"}),r.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),r.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:kt,onChange:he=>At(he.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:Gt,onChange:he=>In(he.target.value)})]}),r.jsxs("div",{className:"col-span-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),r.jsx(re,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:Lt,onChange:he=>xn(he.target.value)})]})]}),r.jsx(X,{onClick:$t,disabled:ae,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:ae?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Ba,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),r.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),at&&r.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:at}),Se&&r.jsxs("div",{className:"mt-3 space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),r.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:Se.rfm_score??"-"})]}),r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),r.jsx("p",{className:"text-2xl font-bold text-white",children:Se.user_level??"-"})]})]}),Se.tags&&Se.tags.length>0&&r.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[r.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Se.tags.map((he,xe)=>r.jsx(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:he},xe))})]}),Se.last_active&&r.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",Se.last_active]})]})]}),r.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Fa,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),r.jsx(X,{onClick:ot,disabled:ln||!a.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:ln?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):r.jsxs(r.Fragment,{children:[r.jsx(Fa,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!a.phone&&r.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),yn&&r.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:yn.error?r.jsx("p",{className:"text-red-400",children:String(yn.error)}):r.jsxs("div",{className:"space-y-1",children:[r.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[r.jsx(Ug,{className:"w-4 h-4"})," 推送成功"]}),yn.enriched!==void 0&&r.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(yn.new_tags_added??0)]})]})})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[r.jsxs(X,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"关闭"]}),r.jsxs(X,{onClick:zn,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存修改"]})]})]}):r.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),r.jsx(It,{open:W,onOpenChange:le,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsx(Pt,{children:"调整余额"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ye,onChange:he=>Ae(he.target.value)})]}),r.jsxs("div",{children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"备注(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:ne,onChange:he=>K(he.target.value)})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>le(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(X,{onClick:mt,disabled:J,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:J?"提交中...":"确认调整"})]})]})})]}):null}function fP(){const t=Ki(),[e,n]=b.useState(!0),[s,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,N]=b.useState(0),[j,v]=b.useState(0),[k,C]=b.useState(0),[E,M]=b.useState(null),[P,H]=b.useState(null),[L,R]=b.useState(!1),[O,se]=b.useState(0),[ie,z]=b.useState(!1),[ce,me]=b.useState(null),[_,G]=b.useState("week"),[$,A]=b.useState(null),[Y,U]=b.useState(!1),D=K=>{const J=K;if((J==null?void 0:J.status)===401)M("登录已过期,请重新登录");else{if((J==null?void 0:J.name)==="AbortError")return;M("加载失败,请检查网络或联系管理员")}};async function W(K){const J=K?{signal:K}:void 0;n(!0),M(null);try{const pe=await De("/api/admin/dashboard/stats",J);pe!=null&&pe.success&&(g(pe.totalUsers??0),N(pe.paidOrderCount??0),v(pe.totalRevenue??0),C(pe.conversionRate??0))}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",pe);try{const Se=await De("/api/admin/dashboard/overview",J);Se!=null&&Se.success&&(g(Se.totalUsers??0),N(Se.paidOrderCount??0),v(Se.totalRevenue??0),C(Se.conversionRate??0))}catch(Se){D(Se)}}}finally{n(!1)}try{const pe=await De("/api/admin/balance/summary",J);pe!=null&&pe.success&&pe.data&&se(pe.data.totalGifted??0)}catch{}try{const pe=await De("/api/db/ckb-plan-stats",J);pe!=null&&pe.success&&pe.data?me({ckbTotal:pe.data.ckbTotal??0,withContact:pe.data.withContact??0}):me(null)}catch{me(null)}a(!0),o(!0);const ge=async()=>{try{const pe=await De("/api/admin/dashboard/recent-orders?limit=10",J);if(pe!=null&&pe.success&&pe.recentOrders)f(pe.recentOrders);else throw new Error("no data")}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError")try{const Se=await De("/api/admin/orders?page=1&pageSize=20&status=paid",J),at=((Se==null?void 0:Se.orders)??[]).filter(Dt=>["paid","completed","success"].includes(Dt.status||""));f(at.slice(0,5))}catch{f([])}}finally{a(!1)}},ae=async()=>{try{const pe=await De("/api/admin/dashboard/new-users",J);if(pe!=null&&pe.success&&pe.newUsers)u(pe.newUsers);else throw new Error("no data")}catch(pe){if((pe==null?void 0:pe.name)!=="AbortError")try{const Se=await De("/api/db/users?page=1&pageSize=10",J);u((Se==null?void 0:Se.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([ge(),ae()])}async function le(K){const J=K||_;U(!0);try{const ge=await De(`/api/admin/track/stats?period=${J}`);ge!=null&&ge.success&&A({total:ge.total??0,byModule:ge.byModule??{}})}catch{A(null)}finally{U(!1)}}b.useEffect(()=>{const K=new AbortController;W(K.signal),le();const J=setInterval(()=>{W(),le()},3e4);return()=>{K.abort(),clearInterval(J)}},[]);const ye=m,Ae=K=>{const J=K.productType||"",ge=K.description||"";if(J==="balance_recharge")return{title:`余额充值 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(J==="gift_pay")return{title:`代付 ¥${typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(J==="gift_pay_batch"){const ae=typeof K.amount=="number"?K.amount.toFixed(2):parseFloat(String(K.amount||"0")).toFixed(2);return{title:ge||`代付分享 ¥${ae}`,subtitle:"代付分享"}}if(J==="section"&&ge.includes("代付领取"))return{title:ge.replace("代付领取 - ",""),subtitle:"代付领取"};if(ge){if(J==="section"&&ge.includes("章节")){if(ge.includes("-")){const ae=ge.split("-");if(ae.length>=3)return{title:`第${ae[1]}章 第${ae[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:ge,subtitle:"章节购买"}}return J==="fullbook"||ge.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:J==="vip"||ge.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:J==="match"||ge.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:ge,subtitle:J==="section"?"单章":J==="fullbook"?"全书":"其他"}}return J==="section"?{title:`章节 ${K.productId||""}`,subtitle:"单章购买"}:J==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:J==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:J==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:J||"其他"}},ne=[{title:"总用户数",value:e?null:ye,sub:null,icon:_n,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(j??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:cd,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:Qg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:Ys,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ce?ce.ckbTotal??0:null,sub:(ce==null?void 0:ce.withContact)!=null?`含联系方式 ${ce.withContact} 人`:null,icon:dd,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"}];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),E&&r.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[r.jsx("span",{children:E}),r.jsx("button",{type:"button",onClick:()=>W(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:ne.map((K,J)=>r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>K.link&&t(K.link),children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsx(Ye,{className:"text-sm font-medium text-gray-400",children:K.title}),r.jsx("div",{className:`p-2 rounded-lg ${K.bg}`,children:r.jsx(K.icon,{className:`w-4 h-4 ${K.color}`})})]}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:K.value!=null?K.value:r.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[r.jsx(Fe,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),K.sub&&r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:K.sub})]}),r.jsx(Dl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},J))}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsx(Ye,{className:"text-white",children:"最近订单"}),r.jsxs("button",{type:"button",onClick:()=>W(),disabled:s||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[s||i?r.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:s&&h.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx(Fe,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[h.slice(0,ie?10:4).map(K=>{var Se;const J=K.referrerId?c.find(tt=>tt.id===K.referrerId):void 0,ge=K.referralCode||(J==null?void 0:J.referralCode)||(J==null?void 0:J.nickname)||(K.referrerId?String(K.referrerId).slice(0,8):""),ae=Ae(K),pe=K.userNickname||((Se=c.find(tt=>tt.id===K.userId))==null?void 0:Se.nickname)||"匿名用户";return r.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[K.userAvatar?r.jsx("img",{src:K.userAvatar,alt:pe,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:tt=>{tt.currentTarget.style.display="none";const at=tt.currentTarget.nextElementSibling;at&&at.classList.remove("hidden")}}):null,r.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 mt-0.5 ${K.userAvatar?"hidden":""}`,children:pe.charAt(0)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("button",{type:"button",onClick:()=>{K.userId&&(H(K.userId),R(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:pe}),r.jsx("span",{className:"text-gray-600",children:"·"}),r.jsx("span",{className:"text-sm font-medium text-white truncate",children:ae.title})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[ae.subtitle&&ae.subtitle!=="章节购买"&&r.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:ae.subtitle}),r.jsx("span",{children:new Date(K.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),ge&&r.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",ge]})]})]}),r.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[r.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(K.amount).toFixed(2)]}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:K.paymentMethod||"微信"})]})]},K.id)}),h.length>4&&!ie&&r.jsx("button",{type:"button",onClick:()=>z(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!s&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Qg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"新注册用户"})}),r.jsx(Te,{children:r.jsx("div",{className:"space-y-3",children:i&&c.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx(Fe,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{className:"text-sm",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[c.slice(0,5).map(K=>{var J;return r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((J=K.nickname)==null?void 0:J.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("button",{type:"button",onClick:()=>{H(K.id),R(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:K.nickname||"匿名用户"}),r.jsx("p",{className:"text-xs text-gray-500",children:K.phone||"-"})]})]}),r.jsx("p",{className:"text-xs text-gray-400",children:K.createdAt?new Date(K.createdAt).toLocaleDateString():"-"})]},K.id)}),c.length===0&&!i&&r.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),r.jsxs(Ee,{className:"mt-8 bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Wg,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),r.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(K=>r.jsx("button",{type:"button",onClick:()=>{G(K),le(K)},className:`px-3 py-1 text-xs rounded-full transition-colors ${_===K?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[K]},K))})]}),r.jsx(Te,{children:Y&&!$?r.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[r.jsx(Fe,{className:"w-6 h-6 animate-spin mr-2"}),r.jsx("span",{children:"加载中..."})]}):$&&Object.keys($.byModule).length>0?r.jsxs("div",{className:"space-y-6",children:[r.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",r.jsx("span",{className:"text-white font-bold text-lg",children:$.total})," 次"]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries($.byModule).sort((K,J)=>J[1].reduce((ge,ae)=>ge+ae.count,0)-K[1].reduce((ge,ae)=>ge+ae.count,0)).map(([K,J])=>{const ge=J.reduce((pe,Se)=>pe+Se.count,0),ae={home:"首页",chapters:"目录",read:"阅读",my:"我的",vip:"VIP",wallet:"钱包",match:"找伙伴",referral:"推广",search:"搜索",settings:"设置",about:"关于",other:"其他"};return r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:ae[K]||K}),r.jsxs("span",{className:"text-xs text-gray-500",children:[ge," 次"]})]}),r.jsx("div",{className:"space-y-2",children:J.sort((pe,Se)=>Se.count-pe.count).slice(0,8).map((pe,Se)=>{const tt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",rule_trigger:"规则触发",view_chapter:"浏览章节",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元"},at={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节"},Dt=tt[pe.target]||pe.target||at[pe.action]||pe.action;return r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-gray-300 truncate mr-2",title:`${pe.action}: ${pe.target}`,children:Dt}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${ge>0?pe.count/ge*100:0}%`}})}),r.jsx("span",{className:"text-gray-400 w-8 text-right",children:pe.count})]})]},Se)})})]},K)})})]}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),r.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),r.jsx(y0,{open:L,onClose:()=>{R(!1),H(null)},userId:P,onUserUpdated:()=>W()})]})}const ss=b.forwardRef(({className:t,...e},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:Mt("w-full caption-bottom text-sm",t),...e})}));ss.displayName="Table";const rs=b.forwardRef(({className:t,...e},n)=>r.jsx("thead",{ref:n,className:Mt("[&_tr]:border-b",t),...e}));rs.displayName="TableHeader";const as=b.forwardRef(({className:t,...e},n)=>r.jsx("tbody",{ref:n,className:Mt("[&_tr:last-child]:border-0",t),...e}));as.displayName="TableBody";const it=b.forwardRef(({className:t,...e},n)=>r.jsx("tr",{ref:n,className:Mt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));it.displayName="TableRow";const we=b.forwardRef(({className:t,...e},n)=>r.jsx("th",{ref:n,className:Mt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));we.displayName="TableHead";const ve=b.forwardRef(({className:t,...e},n)=>r.jsx("td",{ref:n,className:Mt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));ve.displayName="TableCell";function b0(t,e){const[n,s]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>s(t),e);return()=>clearTimeout(a)},[t,e]),n}function Fs({page:t,totalPages:e,total:n,pageSize:s,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:r.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[r.jsxs("span",{children:["共 ",n," 条"]}),i&&r.jsx("select",{value:s,onChange:c=>i(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>r.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>a(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),r.jsx("button",{type:"button",onClick:()=>a(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),r.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),r.jsx("button",{type:"button",onClick:()=>a(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),r.jsx("button",{type:"button",onClick:()=>a(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function pP(){const[t,e]=b.useState([]),[n,s]=b.useState([]),[a,i]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(""),v=b0(N,300),[k,C]=b.useState("all"),[E,M]=b.useState(!0),[P,H]=b.useState(null),[L,R]=b.useState(null),[O,se]=b.useState(""),[ie,z]=b.useState(!1);async function ce(){M(!0),H(null);try{const U=k==="all"?"":k==="completed"?"completed":k,D=new URLSearchParams({page:String(f),pageSize:String(g),...U&&{status:U},...v&&{search:v}}),[W,le]=await Promise.all([De(`/api/admin/orders?${D}`),De("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),le!=null&&le.success&&le.users&&s(le.users)}catch(U){console.error("加载订单失败",U),H("加载订单失败,请检查网络后重试")}finally{M(!1)}}b.useEffect(()=>{m(1)},[v,k]),b.useEffect(()=>{ce()},[f,g,v,k]);const me=U=>{var D;return U.userNickname||((D=n.find(W=>W.id===U.userId))==null?void 0:D.nickname)||"匿名用户"},_=U=>{var D;return((D=n.find(W=>W.id===U))==null?void 0:D.phone)||"-"},G=U=>{const D=U.productType||U.type||"",W=U.description||"";if(D==="balance_recharge")return{name:`余额充值 ¥${Number(U.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(D==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const le=W.split("-");if(le.length>=3)return{name:`第${le[1]}章 第${le[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return D==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:D==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:D==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return D==="section"?{name:`章节 ${U.productId||U.sectionId||""}`,type:"单章"}:D==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:D==="vip"?{name:"超级个体开通费用",type:"超级个体"}:D==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:D||"其他"}},$=Math.ceil(a/g)||1;async function A(){var U;if(!(!(L!=null&&L.orderSn)&&!(L!=null&&L.id))){z(!0),H(null);try{const D=await Ot("/api/admin/orders/refund",{orderSn:L.orderSn||L.id,reason:O||void 0});D!=null&&D.success?(R(null),se(""),ce()):H((D==null?void 0:D.error)||"退款失败")}catch(D){const W=D;H(((U=W==null?void 0:W.data)==null?void 0:U.error)||"退款失败,请检查网络后重试")}finally{z(!1)}}}function Y(){if(t.length===0){te.info("暂无数据可导出");return}const U=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],D=t.map(ne=>{const K=G(ne);return[ne.orderSn||ne.id||"",me(ne),_(ne.userId),K.name,Number(ne.amount||0).toFixed(2),ne.paymentMethod==="wechat"?"微信支付":ne.paymentMethod==="balance"?"余额支付":ne.paymentMethod==="alipay"?"支付宝":ne.paymentMethod||"微信支付",ne.status==="refunded"?"已退款":ne.status==="paid"||ne.status==="completed"?"已完成":ne.status==="pending"||ne.status==="created"?"待支付":"已失败",ne.status==="refunded"&&ne.refundReason?ne.refundReason:"-",ne.referrerEarnings?Number(ne.referrerEarnings).toFixed(2):"-",ne.createdAt?new Date(ne.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[U.join(","),...D].join(` +`),le=new Blob([W],{type:"text/csv;charset=utf-8"}),ye=URL.createObjectURL(le),Ae=document.createElement("a");Ae.href=ye,Ae.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,Ae.click(),URL.revokeObjectURL(ye)}return r.jsxs("div",{className:"p-8 w-full",children:[P&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:P}),r.jsx("button",{type:"button",onClick:()=>H(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(X,{variant:"outline",onClick:ce,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`}),"刷新"]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-400",children:"总收入:"}),r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),r.jsx("span",{className:"text-gray-600",children:"|"}),r.jsx("span",{className:"text-gray-400",children:"今日:"}),r.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[r.jsxs("div",{className:"relative flex-1 max-w-md",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:U=>j(U.target.value)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lj,{className:"w-4 h-4 text-gray-400"}),r.jsxs("select",{value:k,onChange:U=>C(U.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"created",children:"已创建"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]})]}),r.jsxs(X,{variant:"outline",onClick:Y,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(mM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:E?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"订单号"}),r.jsx(we,{className:"text-gray-400",children:"用户"}),r.jsx(we,{className:"text-gray-400",children:"商品"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"支付方式"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"退款原因"}),r.jsx(we,{className:"text-gray-400",children:"分销佣金"}),r.jsx(we,{className:"text-gray-400",children:"下单时间"}),r.jsx(we,{className:"text-gray-400",children:"操作"})]})}),r.jsxs(as,{children:[t.map(U=>{const D=G(U);return r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsxs(ve,{className:"font-mono text-xs text-gray-400",children:[(U.orderSn||U.id||"").slice(0,12),"..."]}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[me(U),U.paymentMethod==="gift_pay"&&r.jsx(Ke,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),U.payerUserId&&U.paymentMethod!=="gift_pay"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:_(U.userId)}),U.payerUserId&&U.payerNickname&&r.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[U.paymentMethod==="gift_pay"?"赠送人:":"代付人:",U.payerNickname]})]})}),r.jsx(ve,{children:r.jsxs("div",{children:[r.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[D.name,(U.productType||U.type)==="vip"&&r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:D.type})]})}),r.jsxs(ve,{className:"text-[#38bdac] font-bold",children:["¥",Number(U.amount||0).toFixed(2)]}),r.jsx(ve,{className:"text-gray-300",children:U.paymentMethod==="wechat"?"微信支付":U.paymentMethod==="balance"?"余额支付":U.paymentMethod==="alipay"?"支付宝":U.paymentMethod||"微信支付"}),r.jsx(ve,{children:U.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):U.status==="paid"||U.status==="completed"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):U.status==="pending"||U.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),r.jsx(ve,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:U.refundReason,children:U.status==="refunded"&&U.refundReason?U.refundReason:"-"}),r.jsx(ve,{className:"text-[#FFD700]",children:U.referrerEarnings?`¥${Number(U.referrerEarnings).toFixed(2)}`:"-"}),r.jsx(ve,{className:"text-gray-400 text-sm",children:new Date(U.createdAt).toLocaleString("zh-CN")}),r.jsx(ve,{children:(U.status==="paid"||U.status==="completed")&&U.paymentMethod!=="balance"&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{R(U),se("")},children:[r.jsx(fj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},U.id)}),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),r.jsx(Fs,{page:f,totalPages:$,total:a,pageSize:g,onPageChange:m,onPageSizeChange:U=>{y(U),m(1)}})]})})}),r.jsx(It,{open:!!L,onOpenChange:U=>!U&&R(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"订单退款"})}),L&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",L.orderSn||L.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(L.amount||0).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:U=>se(U.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>R(null),disabled:ie,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:A,disabled:ie,children:ie?"退款中...":"确认退款"})]})]})})]})}const rc=b.forwardRef(({className:t,...e},n)=>r.jsx("textarea",{className:Mt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...e}));rc.displayName="Textarea";const th=[{id:"register",label:"注册/登录",icon:"👤",color:"bg-blue-500/20 border-blue-500/40 text-blue-400",desc:"微信授权登录或手机号注册"},{id:"browse",label:"浏览章节",icon:"📖",color:"bg-purple-500/20 border-purple-500/40 text-purple-400",desc:"点击免费/付费章节预览"},{id:"bind_phone",label:"绑定手机",icon:"📱",color:"bg-cyan-500/20 border-cyan-500/40 text-cyan-400",desc:"触发付费章节后绑定手机"},{id:"first_pay",label:"首次付款",icon:"💳",color:"bg-green-500/20 border-green-500/40 text-green-400",desc:"购买单章或全书"},{id:"fill_profile",label:"完善资料",icon:"✍️",color:"bg-yellow-500/20 border-yellow-500/40 text-yellow-400",desc:"填写头像、MBTI、行业等"},{id:"match",label:"派对房匹配",icon:"🤝",color:"bg-orange-500/20 border-orange-500/40 text-orange-400",desc:"参与 Soul 派对房"},{id:"vip",label:"升级 VIP",icon:"👑",color:"bg-amber-500/20 border-amber-500/40 text-amber-400",desc:"付款 ¥1980 购买全书"},{id:"distribution",label:"开启分销",icon:"🔗",color:"bg-[#38bdac]/20 border-[#38bdac]/40 text-[#38bdac]",desc:"生成推广码并推荐好友"}];function mP(){var Hr,bn,so,ba,Wr;const[t,e]=tj(),n=t.get("pool"),s=t.get("tab")||"users",[a,i]=b.useState([]),[o,c]=b.useState(0),[u,h]=b.useState(1),[f,m]=b.useState(10),[g,y]=b.useState(""),N=b0(g,300),j=n==="vip"?"vip":n==="complete"?"complete":"all",[v,k]=b.useState(j),[C,E]=b.useState(!0),[M,P]=b.useState(!1),[H,L]=b.useState(null),[R,O]=b.useState(!1),[se,ie]=b.useState("desc");b.useEffect(()=>{n==="vip"?k("vip"):n==="complete"?k("complete"):n==="all"&&k("all")},[n]);const[z,ce]=b.useState(!1),[me,_]=b.useState(null),[G,$]=b.useState(!1),[A,Y]=b.useState(!1),[U,D]=b.useState({referrals:[],stats:{}}),[W,le]=b.useState(!1),[ye,Ae]=b.useState(null),[ne,K]=b.useState(!1),[J,ge]=b.useState(null),[ae,pe]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Se,tt]=b.useState([]),[at,Dt]=b.useState(!1),[kt,At]=b.useState(!1),[Gt,In]=b.useState(null),[Lt,xn]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[ln,Bs]=b.useState([]),[yn,is]=b.useState(!1),[Un,Kn]=b.useState(null),[_t,qn]=b.useState(null),[zn,ls]=b.useState({}),[q,He]=b.useState(!1),[mt,$t]=b.useState([]),[ut,ot]=b.useState(0),[xt,tn]=b.useState(1),[he]=b.useState(20),[xe,zt]=b.useState(!1),Rn=b.useCallback(async()=>{zt(!0);try{const F=await De(`/api/db/ckb-leads?mode=contact&page=${xt}&pageSize=${he}`);F!=null&&F.success&&($t(F.records||[]),ot(F.total??0))}catch{$t([]),ot(0)}finally{zt(!1)}},[xt,he]);b.useEffect(()=>{t.get("tab")==="leads"&&Rn()},[t.get("tab"),xt,Rn]);const[da,ua]=b.useState(null),_r=b.useCallback(async()=>{try{const F=await De("/api/admin/users/online-stats");F!=null&&F.success&&typeof F.onlineCount=="number"?ua(F.onlineCount):ua(0)}catch{ua(null)}},[]);b.useEffect(()=>{_r();const F=setInterval(_r,1e4);return()=>clearInterval(F)},[_r]);async function Zs(F=!1){var Pe;E(!0),F&&P(!0),L(null);try{if(R){const _e=new URLSearchParams({search:N,limit:String(f*5)}),lt=await De(`/api/db/users/rfm?${_e}`);if(lt!=null&<.success){let cn=lt.users||[];se==="asc"&&(cn=[...cn].reverse());const ct=(u-1)*f;i(cn.slice(ct,ct+f)),c(((Pe=lt.users)==null?void 0:Pe.length)??0),cn.length===0&&(O(!1),L("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else O(!1),L((lt==null?void 0:lt.error)||"RFM 加载失败,已切回普通模式")}else{const _e=new URLSearchParams({page:String(u),pageSize:String(f),search:N,...v==="vip"&&{vip:"true"},...v==="complete"&&{pool:"complete"}}),lt=await De(`/api/db/users?${_e}`);lt!=null&<.success?(i(lt.users||[]),c(lt.total??0)):L((lt==null?void 0:lt.error)||"加载失败")}}catch(_e){console.error("Load users error:",_e),L("网络错误")}finally{E(!1),F&&P(!1)}}b.useEffect(()=>{h(1)},[N,v,R]),b.useEffect(()=>{Zs()},[u,f,N,v,R,se]);const ha=Math.ceil(o/f)||1,Xo=()=>{R?se==="desc"?ie("asc"):(O(!1),ie("desc")):(O(!0),ie("desc"))},fa=F=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[F||""]||"bg-gray-500/20 text-gray-400";async function Zi(F){var Pe;if(confirm("确定要删除这个用户吗?"))try{const _e=await ea(`/api/db/users?id=${encodeURIComponent(F)}`);_e!=null&&_e.success?(te.success("已删除"),Zs()):te.error("删除失败: "+((_e==null?void 0:_e.error)||"未知错误"))}catch(_e){const lt=_e,cn=((Pe=lt==null?void 0:lt.data)==null?void 0:Pe.error)||(lt==null?void 0:lt.message)||"网络错误";te.error("删除失败: "+cn)}}const pa=F=>{_(F),pe({phone:F.phone||"",nickname:F.nickname||"",password:"",isAdmin:!!(F.isAdmin??!1),hasFullBook:!!(F.hasFullBook??!1)}),ce(!0)},dc=()=>{_(null),pe({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),ce(!0)};async function mr(){if(!ae.phone||!ae.nickname){te.error("请填写手机号和昵称");return}$(!0);try{if(me){const F=await Ot("/api/db/users",{id:me.id,phone:ae.phone||void 0,nickname:ae.nickname,isAdmin:ae.isAdmin,hasFullBook:ae.hasFullBook,...ae.password&&{password:ae.password}});if(!(F!=null&&F.success)){te.error("更新失败: "+((F==null?void 0:F.error)||""));return}}else{const F=await Nt("/api/db/users",{phone:ae.phone,nickname:ae.nickname,password:ae.password,isAdmin:ae.isAdmin});if(!(F!=null&&F.success)){te.error("创建失败: "+((F==null?void 0:F.error)||""));return}}ce(!1),Zs()}catch{te.error("保存失败")}finally{$(!1)}}async function ma(F){Ae(F),Y(!0),le(!0);try{const Pe=await De(`/api/db/users/referrals?userId=${encodeURIComponent(F.id)}`);Pe!=null&&Pe.success?D({referrals:Pe.referrals||[],stats:Pe.stats||{}}):D({referrals:[],stats:{}})}catch{D({referrals:[],stats:{}})}finally{le(!1)}}const Vs=b.useCallback(async()=>{Dt(!0);try{const F=await De("/api/db/user-rules");F!=null&&F.success&&tt(F.rules||[])}catch{}finally{Dt(!1)}},[]);async function gr(){if(!Lt.title){te.error("请填写规则标题");return}$(!0);try{if(Gt){const F=await Ot("/api/db/user-rules",{id:Gt.id,...Lt});if(!(F!=null&&F.success)){te.error("更新失败: "+((F==null?void 0:F.error)||""));return}}else{const F=await Nt("/api/db/user-rules",Lt);if(!(F!=null&&F.success)){te.error("创建失败: "+((F==null?void 0:F.error)||""));return}}At(!1),Vs()}catch{te.error("保存失败")}finally{$(!1)}}async function eo(F){if(confirm("确定删除?"))try{const Pe=await ea(`/api/db/user-rules?id=${F}`);Pe!=null&&Pe.success&&Vs()}catch{}}async function Zo(F){try{await Ot("/api/db/user-rules",{id:F.id,enabled:!F.enabled}),Vs()}catch{}}const yt=b.useCallback(async()=>{is(!0);try{const F=await De("/api/db/vip-members?limit=500");if(F!=null&&F.success&&F.data){const Pe=[...F.data].map((_e,lt)=>({..._e,vipSort:typeof _e.vipSort=="number"?_e.vipSort:lt+1}));Pe.sort((_e,lt)=>(_e.vipSort??999999)-(lt.vipSort??999999)),Bs(Pe)}else F&&F.error&&te.error(F.error)}catch{te.error("加载超级个体列表失败")}finally{is(!1)}},[]),[kn,zr]=b.useState(!1),[xr,to]=b.useState(null),[yr,ga]=b.useState(""),[Fr,er]=b.useState(!1),Ja=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],uc=F=>{to(F),ga(F.vipRole||""),zr(!0)},Jt=async F=>{const Pe=F.trim();if(xr){if(!Pe){te.error("请选择或输入标签");return}er(!0);try{const _e=await Ot("/api/db/users",{id:xr.id,vipRole:Pe});if(!(_e!=null&&_e.success)){te.error((_e==null?void 0:_e.error)||"更新超级个体标签失败");return}te.success("已更新超级个体标签"),zr(!1),to(null),await yt()}catch{te.error("更新超级个体标签失败")}finally{er(!1)}}},[hc,br]=b.useState(!1),[vr,$r]=b.useState(null),[Ya,no]=b.useState(""),[Br,Ns]=b.useState(!1),Qa=F=>{$r(F),no(F.vipSort!=null?String(F.vipSort):""),br(!0)},ws=async()=>{if(!vr)return;const F=Number(Ya);if(!Number.isFinite(F)){te.error("请输入有效的数字序号");return}Ns(!0);try{const Pe=await Ot("/api/db/users",{id:vr.id,vipSort:F});if(!(Pe!=null&&Pe.success)){te.error((Pe==null?void 0:Pe.error)||"更新排序序号失败");return}te.success("已更新排序序号"),br(!1),$r(null),await yt()}catch{te.error("更新排序序号失败")}finally{Ns(!1)}},Vr=(F,Pe)=>{F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",Pe),Kn(Pe)},fc=(F,Pe)=>{F.preventDefault(),_t!==Pe&&qn(Pe)},pc=()=>{Kn(null),qn(null)},xa=async(F,Pe)=>{F.preventDefault();const _e=F.dataTransfer.getData("text/plain")||Un;if(Kn(null),qn(null),!_e||_e===Pe)return;const lt=ln.find(dn=>dn.id===_e),cn=ln.find(dn=>dn.id===Pe);if(!lt||!cn)return;const ct=lt.vipSort??ln.findIndex(dn=>dn.id===_e)+1,Xa=cn.vipSort??ln.findIndex(dn=>dn.id===Pe)+1;Bs(dn=>{const Gn=[...dn],Ms=Gn.findIndex(cs=>cs.id===_e),As=Gn.findIndex(cs=>cs.id===Pe);if(Ms===-1||As===-1)return dn;const Nr=[...Gn],[va,tr]=[Nr[Ms],Nr[As]];return Nr[Ms]={...tr,vipSort:ct},Nr[As]={...va,vipSort:Xa},Nr});try{const[dn,Gn]=await Promise.all([Ot("/api/db/users",{id:_e,vipSort:Xa}),Ot("/api/db/users",{id:Pe,vipSort:ct})]);if(!(dn!=null&&dn.success)||!(Gn!=null&&Gn.success)){te.error((dn==null?void 0:dn.error)||(Gn==null?void 0:Gn.error)||"更新排序失败"),await yt();return}te.success("已更新排序"),await yt()}catch{te.error("更新排序失败"),await yt()}},ya=b.useCallback(async()=>{He(!0);try{const F=await De("/api/db/users/journey-stats");F!=null&&F.success&&F.stats&&ls(F.stats)}catch{}finally{He(!1)}},[]);return r.jsxs("div",{className:"p-8 w-full",children:[H&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:H}),r.jsx("button",{type:"button",onClick:()=>L(null),children:"×"})]}),r.jsx("div",{className:"flex justify-between items-center mb-6",children:r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),r.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",o," 位注册用户",da!==null&&r.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",da," 人"]}),R&&" · RFM 排序中"]})]})}),r.jsxs(Wd,{value:s,onValueChange:F=>{const Pe=new URLSearchParams(t);F==="users"?Pe.delete("tab"):Pe.set("tab",F),e(Pe)},className:"w-full",children:[r.jsxs(sc,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[r.jsxs(Zt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[r.jsx(_n,{className:"w-4 h-4"})," 用户列表"]}),r.jsxs(Zt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Rn(),children:[r.jsx(dd,{className:"w-4 h-4"})," 获客列表"]}),r.jsxs(Zt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ya,children:[r.jsx(Ll,{className:"w-4 h-4"})," 用户旅程总览"]}),r.jsxs(Zt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Vs,children:[r.jsx(Mo,{className:"w-4 h-4"})," 规则配置"]}),r.jsxs(Zt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:yt,children:[r.jsx(Fl,{className:"w-4 h-4"})," 超级个体列表"]})]}),r.jsxs(en,{value:"users",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[r.jsxs(X,{variant:"outline",onClick:()=>Zs(!0),disabled:M,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${M?"animate-spin":""}`})," 刷新"]}),r.jsxs("select",{value:v,onChange:F=>{const Pe=F.target.value;k(Pe),h(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:R,children:[r.jsx("option",{value:"all",children:"全部用户"}),r.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),r.jsx("option",{value:"complete",children:"完善资料用户"})]}),r.jsxs("div",{className:"relative",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),r.jsx(re,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:g,onChange:F=>y(F.target.value)})]}),r.jsxs(X,{onClick:dc,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(dd,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:C?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"用户信息"}),r.jsx(we,{className:"text-gray-400",children:"绑定信息"}),r.jsx(we,{className:"text-gray-400",children:"购买状态"}),r.jsx(we,{className:"text-gray-400",children:"分销收益"}),r.jsxs(we,{className:"text-gray-400 cursor-pointer select-none",onClick:Xo,children:[r.jsxs("div",{className:"flex items-center gap-1 group",children:[r.jsx(cd,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:"RFM分值"}),R?se==="desc"?r.jsx(kd,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(sj,{className:"w-3.5 h-3.5 text-[#38bdac]"}):r.jsx(Hm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),R&&r.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),r.jsx(we,{className:"text-gray-400",children:"注册时间"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(as,{children:[a.map(F=>{var Pe,_e,lt;return r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:F.avatar?r.jsx("img",{src:F.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Pe=F.nickname)==null?void 0:Pe.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("button",{type:"button",onClick:()=>{ge(F.id),K(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:F.nickname}),F.isAdmin&&r.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),F.openId&&!((_e=F.id)!=null&&_e.startsWith("user_"))&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),r.jsx("p",{className:"text-xs text-gray-500 font-mono",children:F.openId?F.openId.slice(0,12)+"...":(lt=F.id)==null?void 0:lt.slice(0,12)})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[F.phone&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"📱"}),r.jsx("span",{className:"text-gray-300",children:F.phone})]}),F.wechatId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"💬"}),r.jsx("span",{className:"text-gray-300",children:F.wechatId})]}),F.openId&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-gray-500",children:"🔗"}),r.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:F.openId,children:[F.openId.slice(0,12),"..."]})]}),!F.phone&&!F.wechatId&&!F.openId&&r.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),r.jsx(ve,{children:F.hasFullBook?r.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),r.jsx(ve,{children:r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(F.earnings||0)).toFixed(2)]}),parseFloat(String(F.pendingEarnings||0))>0&&r.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(F.pendingEarnings||0)).toFixed(2)]}),r.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>ma(F),role:"button",tabIndex:0,onKeyDown:cn=>cn.key==="Enter"&&ma(F),children:[r.jsx(_n,{className:"w-3 h-3"})," 绑定",F.referralCount||0,"人"]})]})}),r.jsx(ve,{children:F.rfmScore!==void 0?r.jsx("div",{className:"flex flex-col gap-1",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-white font-bold text-base",children:F.rfmScore}),r.jsx(Ke,{className:`border-0 text-xs ${fa(F.rfmLevel)}`,children:F.rfmLevel})]})}):r.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",r.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),r.jsx(ve,{className:"text-gray-400",children:F.createdAt?new Date(F.createdAt).toLocaleDateString():"-"}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{ge(F.id),K(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:r.jsx(qg,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>pa(F),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Zi(F.id),title:"删除",children:r.jsx(Zn,{className:"w-4 h-4"})})]})})]},F.id)}),a.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),r.jsx(Fs,{page:u,totalPages:ha,total:o,pageSize:f,onPageChange:h,onPageSizeChange:F=>{m(F),h(1)}})]})})})]}),r.jsxs(en,{value:"leads",children:[r.jsx("div",{className:"flex items-center justify-end mb-4",children:r.jsxs(X,{variant:"outline",onClick:Rn,disabled:xe,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${xe?"animate-spin":""}`})," 刷新"]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:xe?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs("div",{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"昵称"}),r.jsx(we,{className:"text-gray-400",children:"手机号"}),r.jsx(we,{className:"text-gray-400",children:"微信号"}),r.jsx(we,{className:"text-gray-400",children:"对应 @人"}),r.jsx(we,{className:"text-gray-400",children:"获客计划"}),r.jsx(we,{className:"text-gray-400",children:"来源"}),r.jsx(we,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(as,{children:[mt.map(F=>r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:F.userNickname||F.name||"-"}),r.jsx(ve,{className:"text-gray-300",children:F.phone||"-"}),r.jsx(ve,{className:"text-gray-300",children:F.wechatId||"-"}),r.jsx(ve,{className:"text-[#38bdac]",children:F.personName||"-"}),r.jsx(ve,{className:"text-gray-400",children:F.ckbPlanId?`#${F.ckbPlanId}`:"-"}),r.jsx(ve,{className:"text-gray-400",children:F.source||"-"}),r.jsx(ve,{className:"text-gray-400",children:F.createdAt?new Date(F.createdAt).toLocaleString():"-"})]},F.id)),mt.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无获客数据"})})]})]}),r.jsx(Fs,{page:xt,totalPages:Math.ceil(ut/he)||1,total:ut,pageSize:he,onPageChange:tn,onPageSizeChange:()=>{}})]})})})]}),r.jsxs(en,{value:"journey",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),r.jsxs(X,{variant:"outline",onClick:ya,disabled:q,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${q?"animate-spin":""}`})," 刷新数据"]})]}),r.jsxs("div",{className:"relative mb-8",children:[r.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),r.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:th.map((F,Pe)=>r.jsxs("div",{className:"relative flex flex-col items-center",children:[r.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${F.color} text-center cursor-default`,children:[r.jsx("div",{className:"text-2xl mb-1",children:F.icon}),r.jsx("div",{className:`text-xs font-medium ${F.color.split(" ").find(_e=>_e.startsWith("text-"))}`,children:F.label}),zn[F.id]!==void 0&&r.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[r.jsx("span",{className:"font-bold text-white",children:zn[F.id]})," 人"]}),r.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:Pe+1})]}),Per.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:F.step}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-300",children:F.action}),r.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",F.next]})]})]},F.step))})]}),r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Ys,{className:"w-4 h-4 text-purple-400"}),r.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),r.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),q?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(zn).length>0?r.jsx("div",{className:"space-y-2",children:th.map(F=>{const Pe=zn[F.id]||0,_e=Math.max(...th.map(cn=>zn[cn.id]||0),1),lt=Math.round(Pe/_e*100);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[F.icon," ",F.label]}),r.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${lt}%`}})}),r.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Pe})]},F.id)})}):r.jsx("div",{className:"text-center py-8",children:r.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),r.jsxs(en,{value:"rules",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"outline",onClick:Vs,disabled:at,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${at?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:()=>{In(null),xn({title:"",description:"",trigger:"",sort:0,enabled:!0}),At(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),at?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Se.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Ys,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),r.jsxs(X,{onClick:Vs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Fe,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):r.jsx("div",{className:"space-y-2",children:Se.map(F=>r.jsx("div",{className:`p-4 rounded-lg border transition-all ${F.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[r.jsx(Ut,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),r.jsx("span",{className:"text-white font-medium",children:F.title}),F.trigger&&r.jsxs(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",F.trigger]}),r.jsx(Ke,{className:`text-xs border-0 ${F.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:F.enabled?"启用":"禁用"})]}),F.description&&r.jsx("p",{className:"text-gray-400 text-sm ml-6",children:F.description})]}),r.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[r.jsx(jt,{checked:F.enabled,onCheckedChange:()=>Zo(F)}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>{In(F),xn({title:F.title,description:F.description,trigger:F.trigger,sort:F.sort,enabled:F.enabled}),At(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>eo(F.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Zn,{className:"w-4 h-4"})})]})]})},F.id))})]}),r.jsxs(en,{value:"vip-roles",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),r.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(X,{variant:"outline",onClick:yt,disabled:yn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${yn?"animate-spin":""}`})," ","刷新"]})})]}),yn?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ln.length===0?r.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[r.jsx(Fl,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),r.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400 w-16",children:"序号"}),r.jsx(we,{className:"text-gray-400",children:"成员"}),r.jsx(we,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),r.jsx(we,{className:"text-gray-400 w-24",children:"排序值"}),r.jsx(we,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),r.jsx(as,{children:ln.map((F,Pe)=>{var cn;const _e=Un===F.id,lt=_t===F.id;return r.jsxs(it,{draggable:!0,onDragStart:ct=>Vr(ct,F.id),onDragOver:ct=>fc(ct,F.id),onDrop:ct=>xa(ct,F.id),onDragEnd:pc,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${_e?"opacity-60":""} ${lt?"bg-[#38bdac]/10":""}`,children:[r.jsx(ve,{className:"text-gray-300",children:Pe+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[F.avatar?r.jsx("img",{src:F.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((cn=F.name)==null?void 0:cn[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:F.name})})]})}),r.jsx(ve,{className:"text-gray-300 whitespace-nowrap",children:F.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),r.jsx(ve,{className:"text-gray-300",children:F.vipSort??Pe+1}),r.jsx(ve,{className:"text-right text-xs text-gray-300",children:r.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>uc(F),title:"设置超级个体标签",children:r.jsx(ld,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{ge(F.id),K(!0)},title:"编辑资料",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Qa(F),title:"设置排序序号",children:r.jsx(Hm,{className:"w-3.5 h-3.5"})})]})})]},F.id)})})]})})})]})]}),r.jsx(It,{open:hc,onOpenChange:F=>{br(F),F||$r(null)},children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Hm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",vr==null?void 0:vr.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Ya,onChange:F=>no(F.target.value)})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>br(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:ws,disabled:Br,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),Br?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:kn,onOpenChange:F=>{zr(F),F||to(null)},children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Fl,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",xr==null?void 0:xr.name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Ja.map(F=>r.jsx(X,{variant:yr===F?"default":"outline",size:"sm",className:yr===F?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>ga(F),children:F},F))}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"或手动输入"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:yr,onChange:F=>ga(F.target.value)})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>zr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:()=>Jt(yr),disabled:Fr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),Fr?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:z,onOpenChange:ce,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[me?r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(dd,{className:"w-5 h-5 text-[#38bdac]"}),me?"编辑用户":"添加用户"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:ae.phone,onChange:F=>pe({...ae,phone:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:ae.nickname,onChange:F=>pe({...ae,nickname:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:me?"新密码 (留空则不修改)":"密码"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:me?"留空则不修改":"请输入密码",value:ae.password,onChange:F=>pe({...ae,password:F.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"管理员权限"}),r.jsx(jt,{checked:ae.isAdmin,onCheckedChange:F=>pe({...ae,isAdmin:F})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Z,{className:"text-gray-300",children:"已购全书"}),r.jsx(jt,{checked:ae.hasFullBook,onCheckedChange:F=>pe({...ae,hasFullBook:F})})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>ce(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:mr,disabled:G,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),G?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:kt,onOpenChange:At,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}),Gt?"编辑规则":"添加规则"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则标题 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Lt.title,onChange:F=>xn({...Lt,title:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"规则描述"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Lt.description,onChange:F=>xn({...Lt,description:F.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"触发条件"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Lt.trigger,onChange:F=>xn({...Lt,trigger:F.target.value})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:r.jsx(Z,{className:"text-gray-300",children:"启用状态"})}),r.jsx(jt,{checked:Lt.enabled,onCheckedChange:F=>xn({...Lt,enabled:F})})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>At(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:gr,disabled:G,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),G?"保存中...":"保存"]})]})]})}),r.jsx(It,{open:A,onOpenChange:Y,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",ye==null?void 0:ye.nickname]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Hr=U.stats)==null?void 0:Hr.total)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-green-400",children:((bn=U.stats)==null?void 0:bn.purchased)||0}),r.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((so=U.stats)==null?void 0:so.earnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((ba=U.stats)==null?void 0:ba.pendingEarnings)||0).toFixed(2)]}),r.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),W?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Wr=U.referrals)==null?void 0:Wr.length)??0)>0?r.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(U.referrals??[]).map((F,Pe)=>{var lt;const _e=F;return r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((lt=_e.nickname)==null?void 0:lt.charAt(0))||"?"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white text-sm",children:_e.nickname}),r.jsx("div",{className:"text-xs text-gray-500",children:_e.phone||(_e.hasOpenId?"微信用户":"未绑定")})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[_e.status==="vip"&&r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),_e.status==="paid"&&r.jsxs(Ke,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",_e.purchasedSections,"章"]}),_e.status==="free"&&r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),r.jsx("span",{className:"text-xs text-gray-500",children:_e.createdAt?new Date(_e.createdAt).toLocaleDateString():""})]})]},_e.id||Pe)})}):r.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),r.jsx(sn,{children:r.jsx(X,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),r.jsx(y0,{open:ne,onClose:()=>K(!1),userId:J,onUserUpdated:Zs})]})}function Lh(t,[e,n]){return Math.min(n,Math.max(e,t))}var Ok=["PageUp","PageDown"],Dk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Lk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ac="Slider",[sx,gP,xP]=p0(ac),[_k]=qi(ac,[xP]),[yP,Vf]=_k(ac),zk=b.forwardRef((t,e)=>{const{name:n,min:s=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[s],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:N,...j}=t,v=b.useRef(new Set),k=b.useRef(0),E=o==="horizontal"?bP:vP,[M=[],P]=_o({prop:f,defaultProp:h,onChange:ie=>{var ce;(ce=[...v.current][k.current])==null||ce.focus(),m(ie)}}),H=b.useRef(M);function L(ie){const z=SP(M,ie);se(ie,z)}function R(ie){se(ie,k.current)}function O(){const ie=H.current[k.current];M[k.current]!==ie&&g(M)}function se(ie,z,{commit:ce}={commit:!1}){const me=MP(i),_=AP(Math.round((ie-s)/i)*i+s,me),G=Lh(_,[s,a]);P(($=[])=>{const A=jP($,G,z);if(TP(A,u*i)){k.current=A.indexOf(G);const Y=String(A)!==String($);return Y&&ce&&g(A),Y?A:$}else return $})}return r.jsx(yP,{scope:t.__scopeSlider,name:n,disabled:c,min:s,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:M,orientation:o,form:N,children:r.jsx(sx.Provider,{scope:t.__scopeSlider,children:r.jsx(sx.Slot,{scope:t.__scopeSlider,children:r.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...j,ref:e,onPointerDown:dt(j.onPointerDown,()=>{c||(H.current=M)}),min:s,max:a,inverted:y,onSlideStart:c?void 0:L,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&se(s,0,{commit:!0}),onEndKeyDown:()=>!c&&se(a,M.length-1,{commit:!0}),onStepKeyDown:({event:ie,direction:z})=>{if(!c){const _=Ok.includes(ie.key)||ie.shiftKey&&Dk.includes(ie.key)?10:1,G=k.current,$=M[G],A=i*_*z;se($+A,G,{commit:!0})}}})})})})});zk.displayName=ac;var[Fk,$k]=_k(ac,{startEdge:"left",endEdge:"right",size:"width",direction:1}),bP=b.forwardRef((t,e)=>{const{min:n,max:s,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=Tt(e,E=>g(E)),N=b.useRef(void 0),j=Ff(a),v=j==="ltr",k=v&&!i||!v&&i;function C(E){const M=N.current||m.getBoundingClientRect(),P=[0,M.width],L=v0(P,k?[n,s]:[s,n]);return N.current=M,L(E-M.left)}return r.jsx(Fk,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:r.jsx(Bk,{dir:j,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const M=C(E.clientX);o==null||o(M)},onSlideMove:E=>{const M=C(E.clientX);c==null||c(M)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:E=>{const P=Lk[k?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:P?-1:1})}})})}),vP=b.forwardRef((t,e)=>{const{min:n,max:s,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=Tt(e,f),g=b.useRef(void 0),y=!a;function N(j){const v=g.current||f.current.getBoundingClientRect(),k=[0,v.height],E=v0(k,y?[s,n]:[n,s]);return g.current=v,E(j-v.top)}return r.jsx(Fk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:r.jsx(Bk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const v=N(j.clientY);i==null||i(v)},onSlideMove:j=>{const v=N(j.clientY);o==null||o(v)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:j=>{const k=Lk[y?"from-bottom":"from-top"].includes(j.key);u==null||u({event:j,direction:k?-1:1})}})})}),Bk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:s,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Vf(ac,n);return r.jsx(pt.span,{...h,ref:e,onKeyDown:dt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):Ok.concat(Dk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:dt(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():s(m)}),onPointerMove:dt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:dt(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),i(m))})})}),Vk="SliderTrack",Hk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(Vk,n);return r.jsx(pt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:e})});Hk.displayName=Vk;var rx="SliderRange",Wk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...s}=t,a=Vf(rx,n),i=$k(rx,n),o=b.useRef(null),c=Tt(e,o),u=a.values.length,h=a.values.map(g=>qk(g,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return r.jsx(pt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});Wk.displayName=rx;var ax="SliderThumb",Uk=b.forwardRef((t,e)=>{const n=gP(t.__scopeSlider),[s,a]=b.useState(null),i=Tt(e,c=>a(c)),o=b.useMemo(()=>s?n().findIndex(c=>c.ref.current===s):-1,[n,s]);return r.jsx(NP,{...t,ref:i,index:o})}),NP=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:s,name:a,...i}=t,o=Vf(ax,n),c=$k(ax,n),[u,h]=b.useState(null),f=Tt(e,C=>h(C)),m=u?o.form||!!u.closest("form"):!0,g=x0(u),y=o.values[s],N=y===void 0?0:qk(y,o.min,o.max),j=kP(s,o.values.length),v=g==null?void 0:g[c.size],k=v?CP(v,N,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),r.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${N}% + ${k}px)`},children:[r.jsx(sx.ItemSlot,{scope:t.__scopeSlider,children:r.jsx(pt.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":o.min,"aria-valuenow":y,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:dt(t.onFocus,()=>{o.valueIndexToChangeRef.current=s})})}),m&&r.jsx(Kk,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},s)]})});Uk.displayName=ax;var wP="RadioBubbleInput",Kk=b.forwardRef(({__scopeSlider:t,value:e,...n},s)=>{const a=b.useRef(null),i=Tt(a,s),o=g0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(pt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});Kk.displayName=wP;function jP(t=[],e,n){const s=[...t];return s[n]=e,s.sort((a,i)=>a-i)}function qk(t,e,n){const i=100/(n-e)*(t-e);return Lh(i,[0,100])}function kP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function SP(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),s=Math.min(...n);return n.indexOf(s)}function CP(t,e,n){const s=t/2,i=v0([0,50],[0,s]);return(s-i(e)*n)*n}function EP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function TP(t,e){if(e>0){const n=EP(t);return Math.min(...n)>=e}return!0}function v0(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(n-t[0])}}function MP(t){return(String(t).split(".")[1]||"").length}function AP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var IP=zk,RP=Hk,PP=Wk,OP=Uk;function DP({className:t,defaultValue:e,value:n,min:s=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[s,a],[n,e,s,a]);return r.jsxs(IP,{defaultValue:e,value:n,min:s,max:a,className:Mt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[r.jsx(RP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:r.jsx(PP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>r.jsx(OP,{className:"block size-4 shrink-0 rounded-full border-2 border-[#38bdac] bg-white shadow-sm focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},u))]})}const LP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Gk(t){const[e,n]=b.useState(LP),[s,a]=b.useState(!0),[i,o]=b.useState(!1);b.useEffect(()=>{De("/api/admin/referral-settings").then(h=>{const f=h==null?void 0:h.data;f&&typeof f=="object"&&n({distributorShare:f.distributorShare??90,minWithdrawAmount:f.minWithdrawAmount??10,bindingDays:f.bindingDays??30,userDiscount:f.userDiscount??5,withdrawFee:f.withdrawFee??5,enableAutoWithdraw:f.enableAutoWithdraw??!1,vipOrderShareVip:f.vipOrderShareVip??20,vipOrderShareNonVip:f.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>a(!1))},[]);const c=async()=>{o(!0);try{const h={distributorShare:Number(e.distributorShare)||0,minWithdrawAmount:Number(e.minWithdrawAmount)||0,bindingDays:Number(e.bindingDays)||0,userDiscount:Number(e.userDiscount)||0,withdrawFee:Number(e.withdrawFee)??5,enableAutoWithdraw:!!e.enableAutoWithdraw,vipOrderShareVip:Number(e.vipOrderShareVip)||20,vipOrderShareNonVip:Number(e.vipOrderShareNonVip)||10},f=await Nt("/api/admin/referral-settings",h);if(!f||f.success===!1){te.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}te.success(`✅ 分销配置已保存成功! • 小程序与网站的推广规则会一起生效 • 绑定关系会使用新的天数配置 • 佣金比例会立即应用到新订单 -如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),se.error("保存失败: "+(h instanceof Error?h.message:String(h)))}finally{o(!1)}},u=h=>f=>{const m=parseFloat(f.target.value||"0");n(g=>({...g,[h]:isNaN(m)?0:m}))};return s?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Wl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),r.jsxs(X,{onClick:c,disabled:i||s,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(p5,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),r.jsx(Lt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(_n,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(DP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),r.jsx(re,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",r.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(_n,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),r.jsx(re,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),r.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(Wl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),r.jsx(Lt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最低提现金额(元)"}),r.jsx(re,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",r.jsx(Ke,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsx(Ct,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),r.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[r.jsx(Ku,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),r.jsxs(Te,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[r.jsxs("p",{children:["1. 以上配置会写入"," ",r.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),r.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),r.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function _P(){var Wn;const[t,e]=b.useState("overview"),[n,s]=b.useState([]),[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState([]),[g,y]=b.useState(!0),[N,j]=b.useState(null),[v,k]=b.useState(""),[C,E]=b.useState("all"),[M,P]=b.useState(1),[H,L]=b.useState(10),[R,O]=b.useState(0),[ne,ie]=b.useState(new Set),[_,ce]=b.useState(null),[pe,z]=b.useState(""),[q,F]=b.useState(!1),[A,J]=b.useState(null),[U,D]=b.useState(""),[W,le]=b.useState(!1),[xe,Me]=b.useState([]),[te,K]=b.useState(1),[G,ge]=b.useState(0),[ae,fe]=b.useState("");b.useEffect(()=>{Se()},[]),b.useEffect(()=>{P(1)},[t,C]),b.useEffect(()=>{et(t)},[t]),b.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&et(t,!0),t==="giftPay"&&et("giftPay",!0)},[M,H,C,v,te,ae]);async function Se(){j(null);try{const Y=await De("/api/admin/distribution/overview");Y!=null&&Y.success&&Y.overview&&i(Y.overview)}catch(Y){console.error("[Admin] 概览接口异常:",Y),j("加载概览失败")}try{const Y=await De("/api/db/users");m((Y==null?void 0:Y.users)||[])}catch(Y){console.error("[Admin] 用户数据加载失败:",Y)}}async function et(Y,Ue=!1){var Qe;if(!(!Ue&&ne.has(Y))){y(!0);try{const wt=f;switch(Y){case"overview":break;case"orders":{try{const dt=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C},...v&&{search:v}}),at=await De(`/api/admin/orders?${dt}`);if(at!=null&&at.success&&at.orders){const xt=at.orders.map(Xt=>{const ln=wt.find(xs=>xs.id===Xt.userId),ss=Xt.referrerId?wt.find(xs=>xs.id===Xt.referrerId):null;return{...Xt,amount:parseFloat(String(Xt.amount))||0,userNickname:(ln==null?void 0:ln.nickname)||Xt.userNickname||"未知用户",userPhone:(ln==null?void 0:ln.phone)||Xt.userPhone||"-",referrerNickname:(ss==null?void 0:ss.nickname)||null,referrerCode:(ss==null?void 0:ss.referralCode)??null,type:Xt.productType||Xt.type}});s(xt),O(at.total??xt.length)}else s([]),O(0)}catch(dt){console.error(dt),j("加载订单失败"),s([])}break}case"bindings":{try{const dt=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C}}),at=await De(`/api/db/distribution?${dt}`);c((at==null?void 0:at.bindings)||[]),O((at==null?void 0:at.total)??((Qe=at==null?void 0:at.bindings)==null?void 0:Qe.length)??0)}catch(dt){console.error(dt),j("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const dt=C==="completed"?"success":C==="rejected"?"failed":C,at=new URLSearchParams({...dt&&dt!=="all"&&{status:dt},page:String(M),pageSize:String(H)}),xt=await De(`/api/admin/withdrawals?${at}`);if(xt!=null&&xt.success&&xt.withdrawals){const Xt=xt.withdrawals.map(ln=>({...ln,account:ln.account??"未绑定微信号",status:ln.status==="success"?"completed":ln.status==="failed"?"rejected":ln.status}));h(Xt),O((xt==null?void 0:xt.total)??Xt.length)}else xt!=null&&xt.success||j(`获取提现记录失败: ${(xt==null?void 0:xt.error)||"未知错误"}`),h([])}catch(dt){console.error(dt),j("加载提现数据失败"),h([])}break}case"giftPay":{try{const dt=new URLSearchParams({page:String(te),pageSize:"20",...ae&&{status:ae}}),at=await De(`/api/admin/gift-pay-requests?${dt}`);at!=null&&at.success&&at.data?(Me(at.data),ge(at.total??at.data.length)):(Me([]),ge(0))}catch(dt){console.error(dt),j("加载代付请求失败"),Me([])}break}}ie(dt=>new Set(dt).add(Y))}catch(wt){console.error(wt)}finally{y(!1)}}}async function st(){j(null),ie(Y=>{const Ue=new Set(Y);return Ue.delete(t),Ue}),t==="overview"&&Se(),await et(t,!0)}async function _t(Y){if(confirm("确认审核通过并打款?"))try{const Ue=await Dt("/api/admin/withdrawals",{id:Y,action:"approve"});if(!(Ue!=null&&Ue.success)){const Qe=(Ue==null?void 0:Ue.message)||(Ue==null?void 0:Ue.error)||"操作失败";se.error(Qe);return}await st()}catch(Ue){console.error(Ue),se.error("操作失败")}}function At(Y){J(Y),D("")}async function Ut(){const Y=A;if(!Y)return;const Ue=U.trim();if(!Ue){se.error("请填写拒绝原因");return}le(!0);try{const Qe=await Dt("/api/admin/withdrawals",{id:Y,action:"reject",errorMessage:Ue});if(!(Qe!=null&&Qe.success)){se.error((Qe==null?void 0:Qe.error)||"操作失败");return}se.success("已拒绝该提现申请"),J(null),D(""),await st()}catch(Qe){console.error(Qe),se.error("操作失败")}finally{le(!1)}}function An(){A&&se.info("已取消操作"),J(null),D("")}async function In(){var Y;if(!(!(_!=null&&_.orderSn)&&!(_!=null&&_.id))){F(!0),j(null);try{const Ue=await Dt("/api/admin/orders/refund",{orderSn:_.orderSn||_.id,reason:pe||void 0});Ue!=null&&Ue.success?(ce(null),z(""),await et("orders",!0)):j((Ue==null?void 0:Ue.error)||"退款失败")}catch(Ue){const Qe=Ue;j(((Y=Qe==null?void 0:Qe.data)==null?void 0:Y.error)||"退款失败,请检查网络后重试")}finally{F(!1)}}}function It(Y){const Ue={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},Qe={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return r.jsx(Ke,{className:`${Ue[Y]||"bg-gray-500/20 text-gray-400"} border-0`,children:Qe[Y]||Y})}const sn=Math.ceil(R/H)||1,on=n,Es=o.filter(Y=>{var Qe,wt,dt,at;if(!v)return!0;const Ue=v.toLowerCase();return((Qe=Y.refereeNickname)==null?void 0:Qe.toLowerCase().includes(Ue))||((wt=Y.refereePhone)==null?void 0:wt.includes(Ue))||((dt=Y.referrerName)==null?void 0:dt.toLowerCase().includes(Ue))||((at=Y.referrerCode)==null?void 0:at.toLowerCase().includes(Ue))}),xn=u.filter(Y=>{var Qe;if(!v)return!0;const Ue=v.toLowerCase();return((Qe=Y.userName)==null?void 0:Qe.toLowerCase().includes(Ue))||Y.account&&Y.account.toLowerCase().includes(Ue)});return r.jsxs("div",{className:"p-8 w-full",children:[N&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:N}),r.jsx("button",{type:"button",onClick:()=>j(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex items-center justify-between mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),r.jsxs(X,{onClick:st,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),r.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:cd},{key:"orders",label:"订单管理",icon:Ih},{key:"bindings",label:"绑定管理",icon:Ir},{key:"withdrawals",label:"提现审核",icon:Wl},{key:"giftPay",label:"代付请求",icon:cj},{key:"settings",label:"推广设置",icon:Mo}].map(Y=>r.jsxs("button",{type:"button",onClick:()=>{e(Y.key),E("all"),k(""),Y.key==="giftPay"&&(fe(""),K(1))},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===Y.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[r.jsx(Y.icon,{className:"w-4 h-4"}),Y.label]},Y.key))}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx($e,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[t==="overview"&&a&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayClicks}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(qg,{className:"w-6 h-6 text-blue-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayUniqueVisitors??0}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:r.jsx(_n,{className:"w-6 h-6 text-cyan-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(a.todayClickRate??0).toFixed(2)}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:r.jsx(cd,{className:"w-6 h-6 text-amber-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayBindings})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:r.jsx(Ir,{className:"w-6 h-6 text-green-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayConversions})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:r.jsx(Jv,{className:"w-6 h-6 text-purple-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",a.todayEarnings.toFixed(2)]})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:r.jsx(Ih,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((Wn=a.todayClicksByPage)==null?void 0:Wn.length)??0)>0&&r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(qg,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),r.jsxs(X,{type:"button",size:"sm",variant:"outline",onClick:()=>void st(),disabled:g,className:"border-gray-600 text-gray-300 shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})}),r.jsx(Te,{children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[r.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),r.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),r.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),r.jsx("tbody",{children:[...a.todayClicksByPage??[]].sort((Y,Ue)=>Ue.clicks-Y.clicks).map((Y,Ue)=>r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:Y.page||"(未区分)"}),r.jsx("td",{className:"py-2 pr-4 text-right text-white",children:Y.clicks}),r.jsxs("td",{className:"py-2 text-right text-gray-400",children:[a.todayClicks>0?(Y.clicks/a.todayClicks*100).toFixed(1):0,"%"]})]},Ue))})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Ee,{className:"bg-orange-500/10 border-orange-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:r.jsx(Kg,{className:"w-6 h-6 text-orange-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.expiringBindings," 个"]}),r.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),r.jsx(Ee,{className:"bg-blue-500/10 border-blue-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(Wl,{className:"w-6 h-6 text-blue-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.pendingWithdrawals," 笔"]}),r.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",a.pendingWithdrawAmount.toFixed(2)]})]}),r.jsx(X,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ah,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthClicks})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthBindings})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.monthEarnings.toFixed(2)]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(cd,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),r.jsxs(Te,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalClicks.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalBindings.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.totalEarnings.toFixed(2)]})]})]}),r.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[r.jsx("span",{className:"text-gray-300",children:"点击转化率"}),r.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[a.conversionRate,"%"]})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-white",children:a.totalDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-green-400",children:a.activeDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Fa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:Y=>k(Y.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:Y=>E(Y.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void st(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[n.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:on.map(Y=>{var Ue,Qe;return r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Ue=Y.id)==null?void 0:Ue.slice(0,12),"..."]}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:Y.userNickname}),r.jsx("p",{className:"text-gray-500 text-xs",children:Y.userPhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:(()=>{const wt=Y.productType||Y.type,dt=Y.description||"",at=String(Y.productId||Y.sectionId||""),xt=wt==="vip"||dt.includes("VIP")||dt.toLowerCase().includes("vip")||at.toLowerCase().includes("vip");return wt==="balance_recharge"?`余额充值 ¥${typeof Y.amount=="number"?Y.amount.toFixed(2):parseFloat(String(Y.amount||"0")).toFixed(2)}`:xt?"超级个体开通费用":wt==="fullbook"?`${Y.bookName||"《底层逻辑》"} - 全本`:wt==="match"?"匹配次数购买":`${Y.bookName||"《底层逻辑》"} - ${Y.sectionTitle||Y.chapterTitle||`章节${Y.productId||Y.sectionId||""}`}`})()}),r.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const wt=Y.productType||Y.type,dt=Y.description||"",at=String(Y.productId||Y.sectionId||""),xt=wt==="vip"||dt.includes("VIP")||dt.toLowerCase().includes("vip")||at.toLowerCase().includes("vip");return wt==="balance_recharge"?"余额充值":xt?"超级个体":wt==="fullbook"?"全书解锁":wt==="match"?"功能权益":Y.chapterTitle||"单章购买"})()})]})}),r.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof Y.amount=="number"?Y.amount.toFixed(2):parseFloat(String(Y.amount||"0")).toFixed(2)]}),r.jsx("td",{className:"p-4 text-gray-300",children:Y.paymentMethod==="wechat"?"微信支付":Y.paymentMethod==="balance"?"余额支付":Y.paymentMethod==="alipay"?"支付宝":Y.paymentMethod||"微信支付"}),r.jsx("td",{className:"p-4",children:Y.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):Y.status==="completed"||Y.status==="paid"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):Y.status==="pending"||Y.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:Y.refundReason,children:Y.status==="refunded"&&Y.refundReason?Y.refundReason:"-"}),r.jsx("td",{className:"p-4 text-gray-300 text-sm",children:Y.referrerId||Y.referralCode?r.jsxs("span",{title:Y.referralCode||Y.referrerCode||Y.referrerId||"",children:[Y.referrerNickname||Y.referralCode||Y.referrerCode||((Qe=Y.referrerId)==null?void 0:Qe.slice(0,8)),(Y.referralCode||Y.referrerCode)&&` (${Y.referralCode||Y.referrerCode})`]}):"-"}),r.jsx("td",{className:"p-4 text-[#FFD700]",children:Y.referrerEarnings?`¥${(typeof Y.referrerEarnings=="number"?Y.referrerEarnings:parseFloat(String(Y.referrerEarnings))).toFixed(2)}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:Y.createdAt?new Date(Y.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:(Y.status==="paid"||Y.status==="completed")&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{ce(Y),z("")},children:[r.jsx(fj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},Y.id)})})]})}),t==="orders"&&r.jsx(zs,{page:M,totalPages:sn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:Y=>{L(Y),P(1)}})]})})]}),t==="bindings"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Fa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:Y=>k(Y.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:Y=>E(Y.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"active",children:"有效"}),r.jsx("option",{value:"converted",children:"已转化"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void st(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[Es.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Es.map(Y=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-medium",children:Y.refereeNickname||"匿名用户"}),r.jsx("p",{className:"text-gray-500 text-xs",children:Y.refereePhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white",children:Y.referrerName||"-"}),r.jsx("p",{className:"text-gray-500 text-xs font-mono",children:Y.referrerCode})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:Y.boundAt?new Date(Y.boundAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:Y.expiresAt?new Date(Y.expiresAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:It(Y.status)}),r.jsx("td",{className:"p-4",children:Y.commission?r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",Y.commission.toFixed(2)]}):r.jsx("span",{className:"text-gray-500",children:"-"})})]},Y.id))})]})}),t==="bindings"&&r.jsx(zs,{page:M,totalPages:sn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:Y=>{L(Y),P(1)}})]})})]}),t==="withdrawals"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Fa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:Y=>k(Y.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:Y=>E(Y.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待审核"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"rejected",children:"已拒绝"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void st(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[xn.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:xn.map(Y=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[Y.userAvatar?r.jsx("img",{src:Y.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(Y.userName||Y.name||"?").slice(0,1)}),r.jsx("p",{className:"text-white font-medium",children:Y.userName||Y.name})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",Y.amount.toFixed(2)]})}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:Y.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:Y.method==="wechat"?"微信":"支付宝"})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-mono text-xs",children:Y.account}),r.jsx("p",{className:"text-gray-500 text-xs",children:Y.name})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:Y.createdAt?new Date(Y.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:It(Y.status)}),r.jsx("td",{className:"p-4 text-right",children:Y.status==="pending"&&r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsxs(X,{size:"sm",onClick:()=>_t(Y.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Jv,{className:"w-4 h-4 mr-1"}),"通过"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>At(Y.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[r.jsx(ij,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},Y.id))})]})}),t==="withdrawals"&&r.jsx(zs,{page:M,totalPages:sn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:Y=>{L(Y),P(1)}})]})})]}),t==="giftPay"&&r.jsx("div",{className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[r.jsx(Ye,{className:"text-white",children:"代付请求列表"}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:ae,onChange:Y=>{fe(Y.target.value),K(1)},children:[r.jsx("option",{value:"",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待支付(旧)"}),r.jsx("option",{value:"pending_pay",children:"待发起人支付"}),r.jsx("option",{value:"paid",children:"已支付"}),r.jsx("option",{value:"refunded",children:"已退款"}),r.jsx("option",{value:"cancelled",children:"已取消"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>void st(),disabled:g,className:"border-gray-600 text-gray-300",children:[r.jsx($e,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})]})}),r.jsxs(Te,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"请求号"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"发起人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"商品/金额"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"份数/已领"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"付款人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"创建时间"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:xe.map(Y=>r.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[r.jsx("td",{className:"p-4 font-mono text-xs text-gray-400",children:Y.requestSn}),r.jsx("td",{className:"p-4",children:r.jsx("p",{className:"text-white text-sm",children:Y.initiatorNick||Y.initiatorUserId})}),r.jsxs("td",{className:"p-4",children:[r.jsxs("p",{className:"text-white",children:[Y.productType," · ¥",Y.amount.toFixed(2)]}),Y.description&&r.jsx("p",{className:"text-gray-500 text-xs",children:Y.description})]}),r.jsx("td",{className:"p-4 text-gray-400",children:(Y.quantity??1)>1?`${Y.quantity}份 / 已领${Y.redeemedCount??0}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:Y.payerNick||(Y.payerUserId?Y.payerUserId:"-")}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:Y.status==="paid"?"bg-green-500/20 text-green-400 border-0":Y.status==="pending"||Y.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":Y.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:Y.status==="paid"?"已支付":Y.status==="pending"||Y.status==="pending_pay"?"待支付":Y.status==="refunded"?"已退款":Y.status==="cancelled"?"已取消":"已过期"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:Y.createdAt?new Date(Y.createdAt).toLocaleString("zh-CN"):"-"})]},Y.id))})]})}),xe.length===0&&!g&&r.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),G>20&&r.jsx("div",{className:"mt-4 flex justify-center",children:r.jsx(zs,{page:te,totalPages:Math.ceil(G/20),total:G,pageSize:20,onPageChange:K,onPageSizeChange:()=>{}})})]})]})})]}),r.jsx(Rt,{open:!!_,onOpenChange:Y=>!Y&&ce(null),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Pt,{children:r.jsx(Ot,{className:"text-white",children:"订单退款"})}),_&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",_.orderSn||_.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof _.amount=="number"?_.amount.toFixed(2):parseFloat(String(_.amount||"0")).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:pe,onChange:Y=>z(Y.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>ce(null),disabled:q,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:In,disabled:q,children:q?"退款中...":"确认退款"})]})]})}),r.jsx(Rt,{open:!!A,onOpenChange:Y=>!Y&&An(),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Pt,{children:r.jsx(Ot,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:U,onChange:Y=>D(Y.target.value)})})]})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:An,disabled:W,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:Ut,disabled:W||!U.trim(),children:W?"提交中...":"确认拒绝"})]})]})}),t==="settings"&&r.jsx("div",{className:"-mx-8 -mt-6",children:r.jsx(Gk,{embedded:!0})})]})}function zP(){const[t,e]=b.useState([]),[n,s]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(0),[v,k]=b.useState(null),[C,E]=b.useState(null),[M,P]=b.useState(""),[H,L]=b.useState(!1);async function R(){var z,q,F,A,J,U,D;i(!0),c(null);try{const W=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),le=await De(`/api/admin/withdrawals?${W}`);if(le!=null&&le.success){const xe=le.withdrawals||[];e(xe),j(le.total??((z=le.stats)==null?void 0:z.total)??xe.length),s({total:((q=le.stats)==null?void 0:q.total)??le.total??xe.length,pendingCount:((F=le.stats)==null?void 0:F.pendingCount)??0,pendingAmount:((A=le.stats)==null?void 0:A.pendingAmount)??0,successCount:((J=le.stats)==null?void 0:J.successCount)??0,successAmount:((U=le.stats)==null?void 0:U.successAmount)??0,failedCount:((D=le.stats)==null?void 0:D.failedCount)??0})}else c("加载提现记录失败")}catch(W){console.error("Load withdrawals error:",W),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{R()},[u,f,g]);const O=Math.ceil(N/g)||1;async function ne(z){const q=t.find(F=>F.id===z);if(q!=null&&q.userCommissionInfo&&q.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${q.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 +如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),te.error("保存失败: "+(h instanceof Error?h.message:String(h)))}finally{o(!1)}},u=h=>f=>{const m=parseFloat(f.target.value||"0");n(g=>({...g,[h]:isNaN(m)?0:m}))};return s?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Wl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),r.jsxs(X,{onClick:c,disabled:i||s,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(p5,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),r.jsx(Ft,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(_n,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(DP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),r.jsx(re,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",r.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Ku,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),r.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(_n,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),r.jsx(re,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),r.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(Wl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),r.jsx(Ft,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),r.jsx(Te,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最低提现金额(元)"}),r.jsx(re,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"提现手续费(%)"}),r.jsx(re,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:e.withdrawFee,onChange:u("withdrawFee")}),r.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",r.jsx(Ke,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsx(jt,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),r.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[r.jsx(Ku,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),r.jsxs(Te,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[r.jsxs("p",{children:["1. 以上配置会写入"," ",r.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),r.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),r.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function _P(){var ls;const[t,e]=b.useState("overview"),[n,s]=b.useState([]),[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState([]),[g,y]=b.useState(!0),[N,j]=b.useState(null),[v,k]=b.useState(""),[C,E]=b.useState("all"),[M,P]=b.useState(1),[H,L]=b.useState(10),[R,O]=b.useState(0),[se,ie]=b.useState(new Set),[z,ce]=b.useState(null),[me,_]=b.useState(""),[G,$]=b.useState(!1),[A,Y]=b.useState(null),[U,D]=b.useState(""),[W,le]=b.useState(!1),[ye,Ae]=b.useState(!1),[ne,K]=b.useState(!1),[J,ge]=b.useState([]),[ae,pe]=b.useState(1),[Se,tt]=b.useState(0),[at,Dt]=b.useState("");b.useEffect(()=>{kt()},[]),b.useEffect(()=>{P(1)},[t,C]),b.useEffect(()=>{At(t)},[t]),b.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&At(t,!0),t==="giftPay"&&At("giftPay",!0)},[M,H,C,v,ae,at]),b.useEffect(()=>{t==="withdrawals"&&ln()},[t]);async function kt(){j(null);try{const q=await De("/api/admin/distribution/overview");q!=null&&q.success&&q.overview&&i(q.overview)}catch(q){console.error("[Admin] 概览接口异常:",q),j("加载概览失败")}try{const q=await De("/api/db/users");m((q==null?void 0:q.users)||[])}catch(q){console.error("[Admin] 用户数据加载失败:",q)}}async function At(q,He=!1){var mt;if(!(!He&&se.has(q))){y(!0);try{const $t=f;switch(q){case"overview":break;case"orders":{try{const ut=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C},...v&&{search:v}}),ot=await De(`/api/admin/orders?${ut}`);if(ot!=null&&ot.success&&ot.orders){const xt=ot.orders.map(tn=>{const he=$t.find(zt=>zt.id===tn.userId),xe=tn.referrerId?$t.find(zt=>zt.id===tn.referrerId):null;return{...tn,amount:parseFloat(String(tn.amount))||0,userNickname:(he==null?void 0:he.nickname)||tn.userNickname||"未知用户",userPhone:(he==null?void 0:he.phone)||tn.userPhone||"-",referrerNickname:(xe==null?void 0:xe.nickname)||null,referrerCode:(xe==null?void 0:xe.referralCode)??null,type:tn.productType||tn.type}});s(xt),O(ot.total??xt.length)}else s([]),O(0)}catch(ut){console.error(ut),j("加载订单失败"),s([])}break}case"bindings":{try{const ut=new URLSearchParams({page:String(M),pageSize:String(H),...C!=="all"&&{status:C}}),ot=await De(`/api/db/distribution?${ut}`);c((ot==null?void 0:ot.bindings)||[]),O((ot==null?void 0:ot.total)??((mt=ot==null?void 0:ot.bindings)==null?void 0:mt.length)??0)}catch(ut){console.error(ut),j("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const ut=C==="completed"?"success":C==="rejected"?"failed":C,ot=new URLSearchParams({...ut&&ut!=="all"&&{status:ut},page:String(M),pageSize:String(H)}),xt=await De(`/api/admin/withdrawals?${ot}`);if(xt!=null&&xt.success&&xt.withdrawals){const tn=xt.withdrawals.map(he=>({...he,account:he.account??"未绑定微信号",status:he.status==="success"?"completed":he.status==="failed"?"rejected":he.status}));h(tn),O((xt==null?void 0:xt.total)??tn.length)}else xt!=null&&xt.success||j(`获取提现记录失败: ${(xt==null?void 0:xt.error)||"未知错误"}`),h([])}catch(ut){console.error(ut),j("加载提现数据失败"),h([])}break}case"giftPay":{try{const ut=new URLSearchParams({page:String(ae),pageSize:"20",...at&&{status:at}}),ot=await De(`/api/admin/gift-pay-requests?${ut}`);ot!=null&&ot.success&&ot.data?(ge(ot.data),tt(ot.total??ot.data.length)):(ge([]),tt(0))}catch(ut){console.error(ut),j("加载代付请求失败"),ge([])}break}}ie(ut=>new Set(ut).add(q))}catch($t){console.error($t)}finally{y(!1)}}}async function Gt(){j(null),ie(q=>{const He=new Set(q);return He.delete(t),He}),t==="overview"&&kt(),await At(t,!0)}async function In(q){if(confirm("确认审核通过并打款?"))try{const He=await Ot("/api/admin/withdrawals",{id:q,action:"approve"});if(!(He!=null&&He.success)){const mt=(He==null?void 0:He.message)||(He==null?void 0:He.error)||"操作失败";te.error(mt);return}await Gt()}catch(He){console.error(He),te.error("操作失败")}}function Lt(q){Y(q),D("")}async function xn(){const q=A;if(!q)return;const He=U.trim();if(!He){te.error("请填写拒绝原因");return}le(!0);try{const mt=await Ot("/api/admin/withdrawals",{id:q,action:"reject",errorMessage:He});if(!(mt!=null&&mt.success)){te.error((mt==null?void 0:mt.error)||"操作失败");return}te.success("已拒绝该提现申请"),Y(null),D(""),await Gt()}catch(mt){console.error(mt),te.error("操作失败")}finally{le(!1)}}async function ln(){try{const q=await De("/api/admin/withdrawals/auto-approve");q!=null&&q.success&&typeof q.enableAutoApprove=="boolean"&&Ae(q.enableAutoApprove)}catch{}}async function Bs(q){K(!0);try{const He=await Ot("/api/admin/withdrawals/auto-approve",{enableAutoApprove:q});He!=null&&He.success?(Ae(q),te.success(q?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):te.error("更新失败: "+((He==null?void 0:He.error)??""))}catch{te.error("更新失败")}finally{K(!1)}}function yn(){A&&te.info("已取消操作"),Y(null),D("")}async function is(){var q;if(!(!(z!=null&&z.orderSn)&&!(z!=null&&z.id))){$(!0),j(null);try{const He=await Ot("/api/admin/orders/refund",{orderSn:z.orderSn||z.id,reason:me||void 0});He!=null&&He.success?(ce(null),_(""),await At("orders",!0)):j((He==null?void 0:He.error)||"退款失败")}catch(He){const mt=He;j(((q=mt==null?void 0:mt.data)==null?void 0:q.error)||"退款失败,请检查网络后重试")}finally{$(!1)}}}function Un(q){const He={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},mt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return r.jsx(Ke,{className:`${He[q]||"bg-gray-500/20 text-gray-400"} border-0`,children:mt[q]||q})}const Kn=Math.ceil(R/H)||1,_t=n,qn=o.filter(q=>{var mt,$t,ut,ot;if(!v)return!0;const He=v.toLowerCase();return((mt=q.refereeNickname)==null?void 0:mt.toLowerCase().includes(He))||(($t=q.refereePhone)==null?void 0:$t.includes(He))||((ut=q.referrerName)==null?void 0:ut.toLowerCase().includes(He))||((ot=q.referrerCode)==null?void 0:ot.toLowerCase().includes(He))}),zn=u.filter(q=>{var mt;if(!v)return!0;const He=v.toLowerCase();return((mt=q.userName)==null?void 0:mt.toLowerCase().includes(He))||q.account&&q.account.toLowerCase().includes(He)});return r.jsxs("div",{className:"p-8 w-full",children:[N&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:N}),r.jsx("button",{type:"button",onClick:()=>j(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex items-center justify-between mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),r.jsxs(X,{onClick:Gt,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),r.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:cd},{key:"orders",label:"订单管理",icon:Ih},{key:"bindings",label:"绑定管理",icon:Rr},{key:"withdrawals",label:"提现审核",icon:Wl},{key:"giftPay",label:"代付请求",icon:cj},{key:"settings",label:"推广设置",icon:Mo}].map(q=>r.jsxs("button",{type:"button",onClick:()=>{e(q.key),E("all"),k(""),q.key==="giftPay"&&(Dt(""),pe(1))},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===q.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[r.jsx(q.icon,{className:"w-4 h-4"}),q.label]},q.key))}),g?r.jsxs("div",{className:"flex items-center justify-center py-20",children:[r.jsx(Fe,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[t==="overview"&&a&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayClicks}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(qg,{className:"w-6 h-6 text-blue-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayUniqueVisitors??0}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:r.jsx(_n,{className:"w-6 h-6 text-cyan-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(a.todayClickRate??0).toFixed(2)}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:r.jsx(cd,{className:"w-6 h-6 text-amber-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayBindings})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:r.jsx(Rr,{className:"w-6 h-6 text-green-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),r.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayConversions})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:r.jsx(Jv,{className:"w-6 h-6 text-purple-400"})})]})})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),r.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",a.todayEarnings.toFixed(2)]})]}),r.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:r.jsx(Ih,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((ls=a.todayClicksByPage)==null?void 0:ls.length)??0)>0&&r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(qg,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),r.jsxs(X,{type:"button",size:"sm",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})}),r.jsx(Te,{children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[r.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),r.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),r.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),r.jsx("tbody",{children:[...a.todayClicksByPage??[]].sort((q,He)=>He.clicks-q.clicks).map((q,He)=>r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:q.page||"(未区分)"}),r.jsx("td",{className:"py-2 pr-4 text-right text-white",children:q.clicks}),r.jsxs("td",{className:"py-2 text-right text-gray-400",children:[a.todayClicks>0?(q.clicks/a.todayClicks*100).toFixed(1):0,"%"]})]},He))})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Ee,{className:"bg-orange-500/10 border-orange-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:r.jsx(Kg,{className:"w-6 h-6 text-orange-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.expiringBindings," 个"]}),r.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),r.jsx(Ee,{className:"bg-blue-500/10 border-blue-500/30",children:r.jsx(Te,{className:"p-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:r.jsx(Wl,{className:"w-6 h-6 text-blue-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),r.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.pendingWithdrawals," 笔"]}),r.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",a.pendingWithdrawAmount.toFixed(2)]})]}),r.jsx(X,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ah,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthClicks})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthBindings})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.monthConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.monthEarnings.toFixed(2)]})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(cd,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),r.jsxs(Te,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalClicks.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalBindings.toLocaleString()})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),r.jsx("p",{className:"text-xl font-bold text-white",children:a.totalConversions})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),r.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.totalEarnings.toFixed(2)]})]})]}),r.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[r.jsx("span",{className:"text-gray-300",children:"点击转化率"}),r.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[a.conversionRate,"%"]})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-white",children:a.totalDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-green-400",children:a.activeDistributors}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),r.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[r.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),r.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"pending",children:"待支付"}),r.jsx("option",{value:"failed",children:"已失败"}),r.jsx("option",{value:"refunded",children:"已退款"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[n.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:_t.map(q=>{var He,mt;return r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(He=q.id)==null?void 0:He.slice(0,12),"..."]}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:q.userNickname}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.userPhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white text-sm",children:(()=>{const $t=q.productType||q.type,ut=q.description||"",ot=String(q.productId||q.sectionId||""),xt=$t==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||ot.toLowerCase().includes("vip");return $t==="balance_recharge"?`余额充值 ¥${typeof q.amount=="number"?q.amount.toFixed(2):parseFloat(String(q.amount||"0")).toFixed(2)}`:xt?"超级个体开通费用":$t==="fullbook"?`${q.bookName||"《底层逻辑》"} - 全本`:$t==="match"?"匹配次数购买":`${q.bookName||"《底层逻辑》"} - ${q.sectionTitle||q.chapterTitle||`章节${q.productId||q.sectionId||""}`}`})()}),r.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const $t=q.productType||q.type,ut=q.description||"",ot=String(q.productId||q.sectionId||""),xt=$t==="vip"||ut.includes("VIP")||ut.toLowerCase().includes("vip")||ot.toLowerCase().includes("vip");return $t==="balance_recharge"?"余额充值":xt?"超级个体":$t==="fullbook"?"全书解锁":$t==="match"?"功能权益":q.chapterTitle||"单章购买"})()})]})}),r.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof q.amount=="number"?q.amount.toFixed(2):parseFloat(String(q.amount||"0")).toFixed(2)]}),r.jsx("td",{className:"p-4 text-gray-300",children:q.paymentMethod==="wechat"?"微信支付":q.paymentMethod==="balance"?"余额支付":q.paymentMethod==="alipay"?"支付宝":q.paymentMethod||"微信支付"}),r.jsx("td",{className:"p-4",children:q.status==="refunded"?r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):q.status==="completed"||q.status==="paid"?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):q.status==="pending"||q.status==="created"?r.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):r.jsx(Ke,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:q.refundReason,children:q.status==="refunded"&&q.refundReason?q.refundReason:"-"}),r.jsx("td",{className:"p-4 text-gray-300 text-sm",children:q.referrerId||q.referralCode?r.jsxs("span",{title:q.referralCode||q.referrerCode||q.referrerId||"",children:[q.referrerNickname||q.referralCode||q.referrerCode||((mt=q.referrerId)==null?void 0:mt.slice(0,8)),(q.referralCode||q.referrerCode)&&` (${q.referralCode||q.referrerCode})`]}):"-"}),r.jsx("td",{className:"p-4 text-[#FFD700]",children:q.referrerEarnings?`¥${(typeof q.referrerEarnings=="number"?q.referrerEarnings:parseFloat(String(q.referrerEarnings))).toFixed(2)}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:(q.status==="paid"||q.status==="completed")&&r.jsxs(X,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{ce(q),_("")},children:[r.jsx(fj,{className:"w-3 h-3 mr-1"}),"退款"]})})]},q.id)})})]})}),t==="orders"&&r.jsx(Fs,{page:M,totalPages:Kn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="bindings"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"active",children:"有效"}),r.jsx("option",{value:"converted",children:"已转化"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[qn.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:qn.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-medium",children:q.refereeNickname||"匿名用户"}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.refereePhone})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white",children:q.referrerName||"-"}),r.jsx("p",{className:"text-gray-500 text-xs font-mono",children:q.referrerCode})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:q.boundAt?new Date(q.boundAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:q.expiresAt?new Date(q.expiresAt).toLocaleDateString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:Un(q.status)}),r.jsx("td",{className:"p-4",children:q.commission?r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",q.commission.toFixed(2)]}):r.jsx("span",{className:"text-gray-500",children:"-"})})]},q.id))})]})}),t==="bindings"&&r.jsx(Fs,{page:M,totalPages:Kn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="withdrawals"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(Ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),r.jsx(re,{value:v,onChange:q=>k(q.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),r.jsxs("select",{value:C,onChange:q=>E(q.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",children:[r.jsx("option",{value:"all",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待审核"}),r.jsx("option",{value:"completed",children:"已完成"}),r.jsx("option",{value:"rejected",children:"已拒绝"})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[r.jsx(Fa,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),r.jsx(jt,{checked:ye,onCheckedChange:Bs,disabled:ne,className:"data-[state=checked]:bg-[#38bdac]"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-0",children:[zn.length===0?r.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:zn.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[q.userAvatar?r.jsx("img",{src:q.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(q.userName||q.name||"?").slice(0,1)}),r.jsx("p",{className:"text-white font-medium",children:q.userName||q.name})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",q.amount.toFixed(2)]})}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:q.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:q.method==="wechat"?"微信":"支付宝"})}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-mono text-xs",children:q.account}),r.jsx("p",{className:"text-gray-500 text-xs",children:q.name})]})}),r.jsx("td",{className:"p-4 text-gray-400",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"}),r.jsx("td",{className:"p-4",children:Un(q.status)}),r.jsx("td",{className:"p-4 max-w-[160px]",children:r.jsx("span",{className:`text-xs ${q.status==="rejected"||q.status==="failed"?"text-red-400":"text-gray-400"}`,title:q.remark,children:q.remark||"-"})}),r.jsx("td",{className:"p-4 text-right",children:q.status==="pending"&&r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsxs(X,{size:"sm",onClick:()=>In(q.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Jv,{className:"w-4 h-4 mr-1"}),"通过"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>Lt(q.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[r.jsx(ij,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},q.id))})]})}),t==="withdrawals"&&r.jsx(Fs,{page:M,totalPages:Kn,total:R,pageSize:H,onPageChange:P,onPageSizeChange:q=>{L(q),P(1)}})]})})]}),t==="giftPay"&&r.jsx("div",{className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsx(Je,{children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[r.jsx(Ye,{className:"text-white",children:"代付请求列表"}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:at,onChange:q=>{Dt(q.target.value),pe(1)},children:[r.jsx("option",{value:"",children:"全部状态"}),r.jsx("option",{value:"pending",children:"待支付(旧)"}),r.jsx("option",{value:"pending_pay",children:"待发起人支付"}),r.jsx("option",{value:"paid",children:"已支付"}),r.jsx("option",{value:"refunded",children:"已退款"}),r.jsx("option",{value:"cancelled",children:"已取消"}),r.jsx("option",{value:"expired",children:"已过期"})]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>void Gt(),disabled:g,className:"border-gray-600 text-gray-300",children:[r.jsx(Fe,{className:`w-4 h-4 mr-1 ${g?"animate-spin":""}`}),"刷新"]})]})]})}),r.jsxs(Te,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"请求号"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"发起人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"商品/金额"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"份数/已领"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"付款人"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium text-gray-400",children:"创建时间"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:J.map(q=>r.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[r.jsx("td",{className:"p-4 font-mono text-xs text-gray-400",children:q.requestSn}),r.jsx("td",{className:"p-4",children:r.jsx("p",{className:"text-white text-sm",children:q.initiatorNick||q.initiatorUserId})}),r.jsxs("td",{className:"p-4",children:[r.jsxs("p",{className:"text-white",children:[q.productType," · ¥",q.amount.toFixed(2)]}),q.description&&r.jsx("p",{className:"text-gray-500 text-xs",children:q.description})]}),r.jsx("td",{className:"p-4 text-gray-400",children:(q.quantity??1)>1?`${q.quantity}份 / 已领${q.redeemedCount??0}`:"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:q.payerNick||(q.payerUserId?q.payerUserId:"-")}),r.jsx("td",{className:"p-4",children:r.jsx(Ke,{className:q.status==="paid"?"bg-green-500/20 text-green-400 border-0":q.status==="pending"||q.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":q.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:q.status==="paid"?"已支付":q.status==="pending"||q.status==="pending_pay"?"待支付":q.status==="refunded"?"已退款":q.status==="cancelled"?"已取消":"已过期"})}),r.jsx("td",{className:"p-4 text-gray-400 text-sm",children:q.createdAt?new Date(q.createdAt).toLocaleString("zh-CN"):"-"})]},q.id))})]})}),J.length===0&&!g&&r.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),Se>20&&r.jsx("div",{className:"mt-4 flex justify-center",children:r.jsx(Fs,{page:ae,totalPages:Math.ceil(Se/20),total:Se,pageSize:20,onPageChange:pe,onPageSizeChange:()=>{}})})]})]})})]}),r.jsx(It,{open:!!z,onOpenChange:q=>!q&&ce(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"订单退款"})}),z&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",z.orderSn||z.id]}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof z.amount=="number"?z.amount.toFixed(2):parseFloat(String(z.amount||"0")).toFixed(2)]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:me,onChange:q=>_(q.target.value)})})]}),r.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>ce(null),disabled:G,children:"取消"}),r.jsx(X,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:is,disabled:G,children:G?"退款中...":"确认退款"})]})]})}),r.jsx(It,{open:!!A,onOpenChange:q=>!q&&yn(),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:U,onChange:q=>D(q.target.value)})})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:yn,disabled:W,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:xn,disabled:W||!U.trim(),children:W?"提交中...":"确认拒绝"})]})]})}),t==="settings"&&r.jsx("div",{className:"-mx-8 -mt-6",children:r.jsx(Gk,{embedded:!0})})]})}function zP(){const[t,e]=b.useState([]),[n,s]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[g,y]=b.useState(10),[N,j]=b.useState(0),[v,k]=b.useState(null),[C,E]=b.useState(null),[M,P]=b.useState(""),[H,L]=b.useState(!1);async function R(){var _,G,$,A,Y,U,D;i(!0),c(null);try{const W=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),le=await De(`/api/admin/withdrawals?${W}`);if(le!=null&&le.success){const ye=le.withdrawals||[];e(ye),j(le.total??((_=le.stats)==null?void 0:_.total)??ye.length),s({total:((G=le.stats)==null?void 0:G.total)??le.total??ye.length,pendingCount:(($=le.stats)==null?void 0:$.pendingCount)??0,pendingAmount:((A=le.stats)==null?void 0:A.pendingAmount)??0,successCount:((Y=le.stats)==null?void 0:Y.successCount)??0,successAmount:((U=le.stats)==null?void 0:U.successAmount)??0,failedCount:((D=le.stats)==null?void 0:D.failedCount)??0})}else c("加载提现记录失败")}catch(W){console.error("Load withdrawals error:",W),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{R()},[u,f,g]);const O=Math.ceil(N/g)||1;async function se(_){const G=t.find($=>$.id===_);if(G!=null&&G.userCommissionInfo&&G.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${G.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 -确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(z);try{const F=await Dt("/api/admin/withdrawals",{id:z,action:"approve"});F!=null&&F.success?R():se.error("操作失败: "+((F==null?void 0:F.error)??""))}catch{se.error("操作失败")}finally{k(null)}}function ie(z){E(z),P("")}async function _(){const z=C;if(!z)return;const q=M.trim();if(!q){se.error("请填写拒绝原因");return}L(!0);try{const F=await Dt("/api/admin/withdrawals",{id:z,action:"reject",errorMessage:q});F!=null&&F.success?(se.success("已拒绝该提现申请"),E(null),P(""),R()):se.error("操作失败: "+((F==null?void 0:F.error)??""))}catch{se.error("操作失败")}finally{L(!1)}}function ce(){C&&se.info("已取消操作"),E(null),P("")}function pe(z){switch(z){case"pending":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return r.jsx(Ke,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:z})}}return r.jsxs("div",{className:"p-8 w-full",children:[o&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:o}),r.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-start mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),r.jsxs(X,{variant:"outline",onClick:R,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:r.jsx(Te,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Ih,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),r.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",r.jsx("span",{className:"text-white font-medium",children:"90%"})]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准"]})]})]})]})})}),r.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),r.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),r.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),r.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),r.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(z=>r.jsx(X,{variant:u===z?"default":"outline",size:"sm",onClick:()=>h(z),className:u===z?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:z==="all"?"全部":z==="pending"?"待处理":z==="success"?"已完成":"已拒绝"},z))}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:a?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(z=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4 text-gray-400",children:new Date(z.createdAt??"").toLocaleString()}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[z.userAvatar?r.jsx("img",{src:z.userAvatar,alt:z.userName??"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(z.userName??"?").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-white",children:z.userName??"未知"}),r.jsx("p",{className:"text-xs text-gray-500",children:z.userPhone??z.referralCode??(z.userId??"").slice(0,10)})]})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(z.amount).toFixed(2)]})}),r.jsx("td",{className:"p-4",children:z.userCommissionInfo?r.jsxs("div",{className:"text-xs space-y-1",children:[r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",z.userCommissionInfo.totalCommission.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"已提现:"}),r.jsxs("span",{className:"text-gray-400",children:["¥",z.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"待审核:"}),r.jsxs("span",{className:"text-orange-400",children:["¥",z.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[r.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),r.jsxs("span",{className:z.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",z.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),r.jsxs("td",{className:"p-4",children:[pe(z.status),z.errorMessage&&r.jsx("p",{className:"text-xs text-red-400 mt-1",children:z.errorMessage})]}),r.jsx("td",{className:"p-4 text-gray-400",children:z.processedAt?new Date(z.processedAt).toLocaleString():"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:z.userConfirmedAt?r.jsxs("span",{className:"text-green-400",title:z.userConfirmedAt,children:["已确认 ",new Date(z.userConfirmedAt).toLocaleString()]}):"-"}),r.jsxs("td",{className:"p-4 text-right",children:[(z.status==="pending"||z.status==="pending_confirm")&&r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsxs(X,{size:"sm",onClick:()=>ne(z.id),disabled:v===z.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[r.jsx(Of,{className:"w-4 h-4 mr-1"}),"批准"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>ie(z.id),disabled:v===z.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[r.jsx(hs,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(z.status==="success"||z.status==="completed")&&z.transactionId&&r.jsx("span",{className:"text-xs text-gray-500 font-mono",children:z.transactionId})]})]},z.id))})]})}),r.jsx(zs,{page:f,totalPages:O,total:N,pageSize:g,onPageChange:m,onPageSizeChange:z=>{y(z),m(1)}})]})})}),r.jsx(Rt,{open:!!C,onOpenChange:z=>!z&&ce(),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Pt,{children:r.jsx(Ot,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:M,onChange:z=>P(z.target.value)})})]})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ce,disabled:H,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:_,disabled:H||!M.trim(),children:H?"提交中...":"确认拒绝"})]})]})})]})}var sg={exports:{}},rg={};/** +确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(_);try{const $=await Ot("/api/admin/withdrawals",{id:_,action:"approve"});$!=null&&$.success?R():te.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{te.error("操作失败")}finally{k(null)}}function ie(_){E(_),P("")}async function z(){const _=C;if(!_)return;const G=M.trim();if(!G){te.error("请填写拒绝原因");return}L(!0);try{const $=await Ot("/api/admin/withdrawals",{id:_,action:"reject",errorMessage:G});$!=null&&$.success?(te.success("已拒绝该提现申请"),E(null),P(""),R()):te.error("操作失败: "+(($==null?void 0:$.error)??""))}catch{te.error("操作失败")}finally{L(!1)}}function ce(){C&&te.info("已取消操作"),E(null),P("")}function me(_){switch(_){case"pending":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return r.jsx(Ke,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return r.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return r.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:_})}}return r.jsxs("div",{className:"p-8 w-full",children:[o&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:o}),r.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-start mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),r.jsxs(X,{variant:"outline",onClick:R,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),r.jsx(Ee,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:r.jsx(Te,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Ih,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),r.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",r.jsx("span",{className:"text-white font-medium",children:"90%"})]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),r.jsxs("p",{children:["• ",r.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准(自动审批开关在推广中心-提现审核)"]})]})]})]})})}),r.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),r.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),r.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),r.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsxs(Te,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),r.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),r.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(_=>r.jsx(X,{variant:u===_?"default":"outline",size:"sm",onClick:()=>h(_),className:u===_?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:_==="all"?"全部":_==="pending"?"待处理":_==="success"?"已完成":"已拒绝"},_))}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:a?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Wl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),r.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[r.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"备注"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),r.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),r.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),r.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(_=>r.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[r.jsx("td",{className:"p-4 text-gray-400",children:new Date(_.createdAt??"").toLocaleString()}),r.jsx("td",{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[_.userAvatar?r.jsx("img",{src:_.userAvatar,alt:_.userName??"",className:"w-8 h-8 rounded-full object-cover"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(_.userName??"?").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-white",children:_.userName??"未知"}),r.jsx("p",{className:"text-xs text-gray-500",children:_.userPhone??_.referralCode??(_.userId??"").slice(0,10)})]})]})}),r.jsx("td",{className:"p-4",children:r.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(_.amount).toFixed(2)]})}),r.jsx("td",{className:"p-4",children:_.userCommissionInfo?r.jsxs("div",{className:"text-xs space-y-1",children:[r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),r.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",_.userCommissionInfo.totalCommission.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"已提现:"}),r.jsxs("span",{className:"text-gray-400",children:["¥",_.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{className:"text-gray-500",children:"待审核:"}),r.jsxs("span",{className:"text-orange-400",children:["¥",_.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[r.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),r.jsxs("span",{className:_.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",_.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),r.jsx("td",{className:"p-4",children:me(_.status)}),r.jsx("td",{className:"p-4 max-w-[180px]",children:r.jsx("span",{className:`text-xs ${_.status==="rejected"||_.status==="failed"?"text-red-400":"text-gray-400"}`,title:_.remark,children:_.remark||"-"})}),r.jsx("td",{className:"p-4 text-gray-400",children:_.processedAt?new Date(_.processedAt).toLocaleString():"-"}),r.jsx("td",{className:"p-4 text-gray-400",children:_.userConfirmedAt?r.jsxs("span",{className:"text-green-400",title:_.userConfirmedAt,children:["已确认 ",new Date(_.userConfirmedAt).toLocaleString()]}):"-"}),r.jsxs("td",{className:"p-4 text-right",children:[(_.status==="pending"||_.status==="pending_confirm")&&r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsxs(X,{size:"sm",onClick:()=>se(_.id),disabled:v===_.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[r.jsx(Of,{className:"w-4 h-4 mr-1"}),"批准"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>ie(_.id),disabled:v===_.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(_.status==="success"||_.status==="completed")&&_.transactionId&&r.jsx("span",{className:"text-xs text-gray-500 font-mono",children:_.transactionId})]})]},_.id))})]})}),r.jsx(Fs,{page:f,totalPages:O,total:N,pageSize:g,onPageChange:m,onPageSizeChange:_=>{y(_),m(1)}})]})})}),r.jsx(It,{open:!!C,onOpenChange:_=>!_&&ce(),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"拒绝提现"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),r.jsx("div",{className:"form-input",children:r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:M,onChange:_=>P(_.target.value)})})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ce,disabled:H,children:"取消"}),r.jsx(X,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:z,disabled:H||!M.trim(),children:H?"提交中...":"确认拒绝"})]})]})})]})}var sg={exports:{}},rg={};/** * @license React * use-sync-external-store-shim.production.js * @@ -600,19 +600,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var v1;function $P(){if(v1)return rg;v1=1;var t=Fd();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),N=s({inst:{value:y,getSnapshot:g}}),j=N[0].inst,v=N[1];return i(function(){j.value=y,j.getSnapshot=g,u(j)&&v({inst:j})},[m,y,g]),a(function(){return u(j)&&v({inst:j}),m(function(){u(j)&&v({inst:j})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return rg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,rg}var N1;function Jk(){return N1||(N1=1,sg.exports=$P()),sg.exports}var Yk=Jk();function Jn(t){this.content=t}Jn.prototype={constructor:Jn,find:function(t){for(var e=0;e>1}};Jn.from=function(t){if(t instanceof Jn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Jn(e)};function Qk(t,e,n){for(let s=0;;s++){if(s==t.childCount||s==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(s),i=e.child(s);if(a==i){n+=a.nodeSize;continue}if(!a.sameMarkup(i))return n;if(a.isText&&a.text!=i.text){for(let o=0;a.text[o]==i.text[o];o++)n++;return n}if(a.content.size||i.content.size){let o=Qk(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function Xk(t,e,n,s){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:s};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,s-=u;continue}if(!o.sameMarkup(c))return{a:n,b:s};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&s(u,a+c,i||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),s,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,s,a){let i="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&s&&(o?o=!1:i+=s),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,s=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),i=1);ie)for(let i=0,o=0;oe&&((on)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),s.push(c),a+=c.nodeSize),o=u}return new Ne(s,a)}cutByIndex(e,n){return e==n?Ne.empty:e==0&&n==this.content.length?this:new Ne(this.content.slice(e,n))}replaceChild(e,n){let s=this.content[e];if(s==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-s.nodeSize;return a[e]=n,new Ne(a,i)}addToStart(e){return new Ne([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ne(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),i=s+a.nodeSize;if(i>=e)return i==e?nh(n+1,i):nh(n,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Ne.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ne(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ne.empty;let n,s=0;for(let a=0;athis.type.rank&&(n||(n=e.slice(0,a)),n.push(this),s=!0),n&&n.push(i)}}return n||(n=e.slice()),s||n.push(this),n}removeFromSet(e){for(let n=0;ns.type.rank-a.type.rank),n}};$t.none=[];class zh extends Error{}class Oe{constructor(e,n,s){this.content=e,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let s=eS(this.content,e+this.openStart,n);return s&&new Oe(s,this.openStart,this.openEnd)}removeBetween(e,n){return new Oe(Zk(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Oe.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Oe(Ne.fromJSON(e,n.content),s,a)}static maxOpen(e,n=!0){let s=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new Oe(e,s,a)}}Oe.empty=new Oe(Ne.empty,0,0);function Zk(t,e,n){let{index:s,offset:a}=t.findIndex(e),i=t.maybeChild(s),{index:o,offset:c}=t.findIndex(n);if(a==e||i.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(s!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(s,i.copy(Zk(i.content,e-a-1,n-a-1)))}function eS(t,e,n,s){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return s&&!s.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=eS(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function FP(t,e,n){if(n.openStart>t.depth)throw new zh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zh("Inconsistent open depths");return tS(t,e,n,0)}function tS(t,e,n,s){let a=t.index(s),i=t.node(s);if(a==e.index(s)&&s=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function ud(t,e,n,s){let a=(e||t).node(n),i=0,o=e?e.index(n):a.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Io(t.nodeAfter,s),i++));for(let c=i;ca&&ox(t,e,a+1),o=s.depth>a&&ox(n,s,a+1),c=[];return ud(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(nS(i,o),Io(Ro(i,sS(t,e,n,s,a+1)),c)):(i&&Io(Ro(i,$h(t,e,a+1)),c),ud(e,n,a,c),o&&Io(Ro(o,$h(n,s,a+1)),c)),ud(s,null,a,c),new Ne(c)}function $h(t,e,n){let s=[];if(ud(null,t,n,s),t.depth>n){let a=ox(t,e,n+1);Io(Ro(a,$h(t,e,n+1)),s)}return ud(e,null,n,s),new Ne(s)}function BP(t,e){let n=e.depth-t.openStart,a=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)a=e.node(i).copy(Ne.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Ed{constructor(e,n,s){this.pos=e,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=e.child(n);return s?e.child(n).cut(s):a}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;s--)if(e.pos<=this.end(s)&&(!n||n(this.node(s))))return new Fh(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(s.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new Ed(n,s,i)}static resolveCached(e,n){let s=w1.get(e);if(s)for(let i=0;ie&&this.nodesBetween(e,n,i=>(s.isInSet(i.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),rS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,s=Ne.empty,a=0,i=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,a,i),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=a;un.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,s)}let a=Ne.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,s);return i.type.checkAttrs(i.attrs),i}};Ba.prototype.text=void 0;class Bh extends Ba{constructor(e,n,s,a){if(super(e,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Bh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Bh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function rS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class $o{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let s=new UP(e,n);if(s.next==null)return $o.empty;let a=aS(s);s.next&&s.err("Unexpected trailing text");let i=XP(QP(a));return ZP(i,s),i}matchType(e){for(let n=0;nh.createAndFill()));for(let h=0;h=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(s){e.push(s);for(let a=0;a{let i=a+(s.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(s.next[o].next);return i}).join(` -`)}}$o.empty=new $o(!0);class UP{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function aS(t){let e=[];do e.push(KP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function KP(t){let e=[];do e.push(qP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qP(t){let e=YP(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=GP(t,e);else break;return e}function j1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function GP(t,e){let n=j1(t),s=n;return t.eat(",")&&(t.next!="}"?s=j1(t):s=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:e}}function JP(t,e){let n=t.nodeTypes,s=n[e];if(s)return[s];let a=[];for(let i in n){let o=n[i];o.isInGroup(e)&&a.push(o)}return a.length==0&&t.err("No node type or group '"+e+"' found"),a}function YP(t){if(t.eat("(")){let e=aS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=JP(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function QP(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function s(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function a(o,c){o.forEach(u=>u.to=c)}function i(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(i(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=i(o.exprs[u],c);if(u==o.exprs.length-1)return h;a(h,c=n())}else if(o.type=="star"){let u=n();return s(c,u),a(i(o.expr,u),u),[s(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[s(u)]}else{if(o.type=="opt")return[s(c)].concat(i(o.expr,c));if(o.type=="range"){let u=c;for(let h=0;h{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f{h||a.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let i=e[s.join(",")]=new $o(s.indexOf(t.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:lS(this.attrs,e)}create(e=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ba(this,this.computeAttrs(e),Ne.from(n),$t.setFrom(s))}createChecked(e=null,n,s){return n=Ne.from(n),this.checkContent(n),new Ba(this,this.computeAttrs(e),n,$t.setFrom(s))}createAndFill(e=null,n,s){if(e=this.computeAttrs(e),n=Ne.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let a=this.contentMatch.matchFragment(n),i=a&&a.fillBefore(Ne.empty,!0);return i?new Ba(this,e,n.append(i),$t.setFrom(s)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;ns[i]=new uS(i,n,o));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function eO(t,e,n){let s=n.split("|");return a=>{let i=a===null?"null":typeof a;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${t}, got ${i}`)}}class tO{constructor(e,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?eO(e,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Hf{constructor(e,n,s,a){this.name=e,this.rank=n,this.schema=s,this.spec=a,this.attrs=dS(e,a.attrs),this.excluded=null;let i=oS(this.attrs);this.instance=i?new $t(this,i):null}create(e=null){return!e&&this.instance?this.instance:new $t(this,lS(this.attrs,e))}static compile(e,n){let s=Object.create(null),a=0;return e.forEach((i,o)=>s[i]=new Hf(i,a++,n,o)),s}removeFromSet(e){for(var n=0;n-1}}class hS{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in e)n[a]=e[a];n.nodes=Jn.from(e.nodes),n.marks=Jn.from(e.marks||{}),this.nodes=S1.compile(this.spec.nodes,this),this.marks=Hf.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let i=this.nodes[a],o=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=s[o]||(s[o]=$o.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=c=="_"?null:c?C1(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let a in this.marks){let i=this.marks[a],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:C1(this,o.split(" "))}this.nodeFromJSON=a=>Ba.fromJSON(this,a),this.markFromJSON=a=>$t.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,s,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof S1){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,s,a)}text(e,n){let s=this.nodes.text;return new Bh(s,s.defaultAttrs,e,$t.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function C1(t,e){let n=[];for(let s=0;s-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return n}function nO(t){return t.tag!=null}function sO(t){return t.style!=null}class Oi{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(nO(a))this.tags.push(a);else if(sO(a)){let i=/[^=]*/.exec(a.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let i=e.nodes[a.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let s=new T1(this,n,!1);return s.addAll(e,$t.none,n.from,n.to),s.finish()}parseSlice(e,n={}){let s=new T1(this,n,!0);return s.addAll(e,$t.none,n.from,n.to),Oe.maxOpen(s.finish())}matchTag(e,n,s){for(let a=s?this.tags.indexOf(s)+1:0;ae.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function s(a){let i=a.priority==null?50:a.priority,o=0;for(;o{s(o=M1(o)),o.mark||o.ignore||o.clearMark||(o.mark=a)})}for(let a in e.nodes){let i=e.nodes[a].spec.parseDOM;i&&i.forEach(o=>{s(o=M1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Oi(e,Oi.schemaRules(e)))}}const fS={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},rO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},pS={ol:!0,ul:!0},Td=1,cx=2,hd=4;function E1(t,e,n){return e!=null?(e?Td:0)|(e==="full"?cx:0):t&&t.whitespace=="pre"?Td|cx:n&~hd}class sh{constructor(e,n,s,a,i,o){this.type=e,this.attrs=n,this.marks=s,this.solid=a,this.options=o,this.content=[],this.activeMarks=$t.none,this.match=i||(o&hd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ne.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(e.type))?(this.match=s,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Td)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-a[0].length))}}let n=Ne.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ne.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!fS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class T1{constructor(e,n,s){this.parser=e,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=E1(null,n.preserveWhitespace,0)|(s?hd:0);a?i=new sh(a.type,a.attrs,$t.none,!0,n.topMatch||a.type.contentMatch,o):s?i=new sh(null,null,$t.none,!0,null,o):i=new sh(e.schema.topNodeType,null,$t.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let s=e.nodeValue,a=this.top,i=a.options&cx?"full":this.localPreserveWS||(a.options&Td)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(i)if(i==="full")s=s.replace(/\r\n?/g,` + */var v1;function FP(){if(v1)return rg;v1=1;var t=$d();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),N=s({inst:{value:y,getSnapshot:g}}),j=N[0].inst,v=N[1];return i(function(){j.value=y,j.getSnapshot=g,u(j)&&v({inst:j})},[m,y,g]),a(function(){return u(j)&&v({inst:j}),m(function(){u(j)&&v({inst:j})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return rg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,rg}var N1;function Jk(){return N1||(N1=1,sg.exports=FP()),sg.exports}var Yk=Jk();function Xn(t){this.content=t}Xn.prototype={constructor:Xn,find:function(t){for(var e=0;e>1}};Xn.from=function(t){if(t instanceof Xn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Xn(e)};function Qk(t,e,n){for(let s=0;;s++){if(s==t.childCount||s==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(s),i=e.child(s);if(a==i){n+=a.nodeSize;continue}if(!a.sameMarkup(i))return n;if(a.isText&&a.text!=i.text){for(let o=0;a.text[o]==i.text[o];o++)n++;return n}if(a.content.size||i.content.size){let o=Qk(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function Xk(t,e,n,s){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:s};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,s-=u;continue}if(!o.sameMarkup(c))return{a:n,b:s};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&s(u,a+c,i||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),s,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,s,a){let i="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&s&&(o?o=!1:i+=s),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,s=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),i=1);ie)for(let i=0,o=0;oe&&((on)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),s.push(c),a+=c.nodeSize),o=u}return new Ne(s,a)}cutByIndex(e,n){return e==n?Ne.empty:e==0&&n==this.content.length?this:new Ne(this.content.slice(e,n))}replaceChild(e,n){let s=this.content[e];if(s==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-s.nodeSize;return a[e]=n,new Ne(a,i)}addToStart(e){return new Ne([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ne(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),i=s+a.nodeSize;if(i>=e)return i==e?nh(n+1,i):nh(n,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Ne.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ne(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ne.empty;let n,s=0;for(let a=0;athis.type.rank&&(n||(n=e.slice(0,a)),n.push(this),s=!0),n&&n.push(i)}}return n||(n=e.slice()),s||n.push(this),n}removeFromSet(e){for(let n=0;ns.type.rank-a.type.rank),n}};Vt.none=[];class zh extends Error{}class Oe{constructor(e,n,s){this.content=e,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let s=eS(this.content,e+this.openStart,n);return s&&new Oe(s,this.openStart,this.openEnd)}removeBetween(e,n){return new Oe(Zk(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Oe.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Oe(Ne.fromJSON(e,n.content),s,a)}static maxOpen(e,n=!0){let s=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new Oe(e,s,a)}}Oe.empty=new Oe(Ne.empty,0,0);function Zk(t,e,n){let{index:s,offset:a}=t.findIndex(e),i=t.maybeChild(s),{index:o,offset:c}=t.findIndex(n);if(a==e||i.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(s!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(s,i.copy(Zk(i.content,e-a-1,n-a-1)))}function eS(t,e,n,s){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return s&&!s.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=eS(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function $P(t,e,n){if(n.openStart>t.depth)throw new zh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zh("Inconsistent open depths");return tS(t,e,n,0)}function tS(t,e,n,s){let a=t.index(s),i=t.node(s);if(a==e.index(s)&&s=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function ud(t,e,n,s){let a=(e||t).node(n),i=0,o=e?e.index(n):a.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Io(t.nodeAfter,s),i++));for(let c=i;ca&&ox(t,e,a+1),o=s.depth>a&&ox(n,s,a+1),c=[];return ud(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(nS(i,o),Io(Ro(i,sS(t,e,n,s,a+1)),c)):(i&&Io(Ro(i,Fh(t,e,a+1)),c),ud(e,n,a,c),o&&Io(Ro(o,Fh(n,s,a+1)),c)),ud(s,null,a,c),new Ne(c)}function Fh(t,e,n){let s=[];if(ud(null,t,n,s),t.depth>n){let a=ox(t,e,n+1);Io(Ro(a,Fh(t,e,n+1)),s)}return ud(e,null,n,s),new Ne(s)}function BP(t,e){let n=e.depth-t.openStart,a=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)a=e.node(i).copy(Ne.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class Ed{constructor(e,n,s){this.pos=e,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=e.child(n);return s?e.child(n).cut(s):a}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;s--)if(e.pos<=this.end(s)&&(!n||n(this.node(s))))return new $h(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(s.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new Ed(n,s,i)}static resolveCached(e,n){let s=w1.get(e);if(s)for(let i=0;ie&&this.nodesBetween(e,n,i=>(s.isInSet(i.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),rS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,s=Ne.empty,a=0,i=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,a,i),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=a;un.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,s)}let a=Ne.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,s);return i.type.checkAttrs(i.attrs),i}};Va.prototype.text=void 0;class Bh extends Va{constructor(e,n,s,a){if(super(e,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Bh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Bh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function rS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Fo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let s=new UP(e,n);if(s.next==null)return Fo.empty;let a=aS(s);s.next&&s.err("Unexpected trailing text");let i=XP(QP(a));return ZP(i,s),i}matchType(e){for(let n=0;nh.createAndFill()));for(let h=0;h=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(s){e.push(s);for(let a=0;a{let i=a+(s.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(s.next[o].next);return i}).join(` +`)}}Fo.empty=new Fo(!0);class UP{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function aS(t){let e=[];do e.push(KP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function KP(t){let e=[];do e.push(qP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qP(t){let e=YP(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=GP(t,e);else break;return e}function j1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function GP(t,e){let n=j1(t),s=n;return t.eat(",")&&(t.next!="}"?s=j1(t):s=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:e}}function JP(t,e){let n=t.nodeTypes,s=n[e];if(s)return[s];let a=[];for(let i in n){let o=n[i];o.isInGroup(e)&&a.push(o)}return a.length==0&&t.err("No node type or group '"+e+"' found"),a}function YP(t){if(t.eat("(")){let e=aS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=JP(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function QP(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function s(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function a(o,c){o.forEach(u=>u.to=c)}function i(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(i(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=i(o.exprs[u],c);if(u==o.exprs.length-1)return h;a(h,c=n())}else if(o.type=="star"){let u=n();return s(c,u),a(i(o.expr,u),u),[s(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[s(u)]}else{if(o.type=="opt")return[s(c)].concat(i(o.expr,c));if(o.type=="range"){let u=c;for(let h=0;h{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f{h||a.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let i=e[s.join(",")]=new Fo(s.indexOf(t.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:lS(this.attrs,e)}create(e=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Va(this,this.computeAttrs(e),Ne.from(n),Vt.setFrom(s))}createChecked(e=null,n,s){return n=Ne.from(n),this.checkContent(n),new Va(this,this.computeAttrs(e),n,Vt.setFrom(s))}createAndFill(e=null,n,s){if(e=this.computeAttrs(e),n=Ne.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let a=this.contentMatch.matchFragment(n),i=a&&a.fillBefore(Ne.empty,!0);return i?new Va(this,e,n.append(i),Vt.setFrom(s)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;ns[i]=new uS(i,n,o));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function eO(t,e,n){let s=n.split("|");return a=>{let i=a===null?"null":typeof a;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${t}, got ${i}`)}}class tO{constructor(e,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?eO(e,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Hf{constructor(e,n,s,a){this.name=e,this.rank=n,this.schema=s,this.spec=a,this.attrs=dS(e,a.attrs),this.excluded=null;let i=oS(this.attrs);this.instance=i?new Vt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Vt(this,lS(this.attrs,e))}static compile(e,n){let s=Object.create(null),a=0;return e.forEach((i,o)=>s[i]=new Hf(i,a++,n,o)),s}removeFromSet(e){for(var n=0;n-1}}class hS{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in e)n[a]=e[a];n.nodes=Xn.from(e.nodes),n.marks=Xn.from(e.marks||{}),this.nodes=S1.compile(this.spec.nodes,this),this.marks=Hf.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let i=this.nodes[a],o=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=s[o]||(s[o]=Fo.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=c=="_"?null:c?C1(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let a in this.marks){let i=this.marks[a],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:C1(this,o.split(" "))}this.nodeFromJSON=a=>Va.fromJSON(this,a),this.markFromJSON=a=>Vt.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,s,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof S1){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,s,a)}text(e,n){let s=this.nodes.text;return new Bh(s,s.defaultAttrs,e,Vt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function C1(t,e){let n=[];for(let s=0;s-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return n}function nO(t){return t.tag!=null}function sO(t){return t.style!=null}class Oi{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(nO(a))this.tags.push(a);else if(sO(a)){let i=/[^=]*/.exec(a.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let i=e.nodes[a.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let s=new T1(this,n,!1);return s.addAll(e,Vt.none,n.from,n.to),s.finish()}parseSlice(e,n={}){let s=new T1(this,n,!0);return s.addAll(e,Vt.none,n.from,n.to),Oe.maxOpen(s.finish())}matchTag(e,n,s){for(let a=s?this.tags.indexOf(s)+1:0;ae.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function s(a){let i=a.priority==null?50:a.priority,o=0;for(;o{s(o=M1(o)),o.mark||o.ignore||o.clearMark||(o.mark=a)})}for(let a in e.nodes){let i=e.nodes[a].spec.parseDOM;i&&i.forEach(o=>{s(o=M1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Oi(e,Oi.schemaRules(e)))}}const fS={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},rO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},pS={ol:!0,ul:!0},Td=1,cx=2,hd=4;function E1(t,e,n){return e!=null?(e?Td:0)|(e==="full"?cx:0):t&&t.whitespace=="pre"?Td|cx:n&~hd}class sh{constructor(e,n,s,a,i,o){this.type=e,this.attrs=n,this.marks=s,this.solid=a,this.options=o,this.content=[],this.activeMarks=Vt.none,this.match=i||(o&hd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ne.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(e.type))?(this.match=s,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Td)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-a[0].length))}}let n=Ne.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ne.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!fS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class T1{constructor(e,n,s){this.parser=e,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=E1(null,n.preserveWhitespace,0)|(s?hd:0);a?i=new sh(a.type,a.attrs,Vt.none,!0,n.topMatch||a.type.contentMatch,o):s?i=new sh(null,null,Vt.none,!0,null,o):i=new sh(e.schema.topNodeType,null,Vt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let s=e.nodeValue,a=this.top,i=a.options&cx?"full":this.localPreserveWS||(a.options&Td)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(i)if(i==="full")s=s.replace(/\r\n?/g,` `);else if(o.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=s.split(/\r?\n|\r/);for(let u=0;u!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,s,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let u=this.enter(o,n.attrs||null,s,n.preserveWhitespace);u&&(i=!0,s=u)}else{let u=this.parser.schema.marks[n.mark];s=s.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,s,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,s,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,s),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,s,a){let i=s||0;for(let o=s?e.childNodes[s]:e.firstChild,c=a==null?null:e.childNodes[a];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,s){let a,i;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!a||a.length>h.length+c)&&(a=h,i=u,!h.length))break;if(u.solid){if(s)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):A1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new sh(e,n,u,a,null,c)),this.open++,s}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Td)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)e+=s[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let s=0;s-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(a?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:s&&u>=i?s.node(u-i).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function aO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&pS.hasOwnProperty(s)&&n?(n.appendChild(e),e=n):s=="li"?n=e:s&&(n=null)}}function iO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function M1(t){let e={};for(let n in t)e[n]=t[n];return e}function A1(t,e){let n=e.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let u=0;u{if(i.length||o.marks.length){let c=0,u=0;for(;c=0;a--){let i=this.serializeMark(e.marks[a],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,n,s={}){let a=this.marks[e.type.name];return a&&Nh(ig(s),a(e,n),null,e.attrs)}static renderSpec(e,n,s=null,a){return Nh(e,n,s,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Jo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=I1(e.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(e){return I1(e.marks)}}function I1(t){let e={};for(let n in t){let s=t[n].spec.toDOM;s&&(e[n]=s)}return e}function ig(t){return t.document||window.document}const R1=new WeakMap;function oO(t){let e=R1.get(t);return e===void 0&&R1.set(t,e=lO(t)),e}function lO(t){let e=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=a.indexOf(" ");o>0&&(n=a.slice(0,o),a=a.slice(o+1));let c,u=n?t.createElementNS(n,a):t.createElement(a),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:N}=Nh(t,g,n,s);if(u.appendChild(y),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const mS=65535,gS=Math.pow(2,16);function cO(t,e){return t+e*gS}function P1(t){return t&mS}function dO(t){return(t-(t&mS))/gS}const xS=1,yS=2,wh=4,bS=8;class dx{constructor(e,n,s){this.pos=e,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&bS)>0}get deletedBefore(){return(this.delInfo&(xS|wh))>0}get deletedAfter(){return(this.delInfo&(yS|wh))>0}get deletedAcross(){return(this.delInfo&wh)>0}}class Ks{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ks.empty)return Ks.empty}recover(e){let n=0,s=P1(e);if(!this.inverted)for(let a=0;ae)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+a+(g<0?0:f);if(s)return y;let N=e==(n<0?u:m)?null:cO(c/3,e-u),j=e==u?yS:e==m?xS:wh;return(n<0?e!=u:e!=m)&&(j|=bS),new dx(y,j,N)}a+=f-h}return s?e+a:new dx(e+a,0,null)}touches(e,n){let s=0,a=P1(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+i],f=u+h;if(e<=f&&c==a*3)return!0;s+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,i=0;a=0;n--){let a=e.getMirror(n);this.appendMap(e._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let e=new Md;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let s=this.from;si&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return En.fromReplace(e,this.from,this.to,i)}invert(){return new Ar(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Mi(n.pos,s.pos,this.mark)}merge(e){return e instanceof Mi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Mi(n.from,n.to,e.markFromJSON(n.mark))}}gs.jsonID("addMark",Mi);class Ar extends gs{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=new Oe(N0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return En.fromReplace(e,this.from,this.to,s)}invert(){return new Mi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Ar(n.pos,s.pos,this.mark)}merge(e){return e instanceof Ar&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ar(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ar(n.from,n.to,e.markFromJSON(n.mark))}}gs.jsonID("removeMark",Ar);class Ai extends gs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return En.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return En.fromReplace(e,this.pos,this.pos+1,new Oe(Ne.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;as.pos?null:new Vn(n.pos,s.pos,a,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Vn(n.from,n.to,n.gapFrom,n.gapTo,Oe.fromJSON(e,n.slice),n.insert,!!n.structure)}}gs.jsonID("replaceAround",Vn);function ux(t,e,n){let s=t.resolve(e),a=n-e,i=s.depth;for(;a>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,a--;if(a>0){let o=s.node(i).maybeChild(s.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function uO(t,e,n,s){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!s.isInSet(m)&&f.type.allowsMarkType(s.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),N=s.addToSet(m);for(let j=0;jt.step(u)),i.forEach(u=>t.step(u))}function hO(t,e,n,s){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(s instanceof Hf){let h=o.marks,f;for(;f=s.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else s?s.isInSet(o.marks)&&(u=[s]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new Ar(o.from,o.to,o.style)))}function w0(t,e,n,s=n.contentMatch,a=!0){let i=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function fO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ic(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let s=t.depth,a=0,i=0;;--s){let o=t.$from.node(s),c=t.$from.index(s)+a,u=t.$to.indexAfter(s)-i;if(sn;N--)j||s.index(N)>0?(j=!0,f=Ne.from(s.node(N).copy(f)),m++):u--;let g=Ne.empty,y=0;for(let N=i,j=!1;N>n;N--)j||a.after(N+1)=0;o--){if(s.size){let c=n[o].type.contentMatch.matchFragment(s);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=Ne.from(n[o].type.create(n[o].attrs,s))}let a=e.start,i=e.end;t.step(new Vn(a,i,a,i,new Oe(s,0,0),n.length,!0))}function yO(t,e,n,s,a){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof a=="function"?a(o):a;if(o.isTextblock&&!o.hasMarkup(s,u)&&bO(t.doc,t.mapping.slice(i).map(c),s)){let h=null;if(s.schema.linebreakReplacement){let y=s.whitespace=="pre",N=!!s.contentMatch.matchType(s.schema.linebreakReplacement);y&&!N?h=!1:!y&&N&&(h=!0)}h===!1&&NS(t,o,c,i),w0(t,t.mapping.slice(i).map(c,1),s,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),g=f.map(c+o.nodeSize,1);return t.step(new Vn(m,g,m+1,g-1,new Oe(Ne.from(s.create(u,null,o.marks)),0,0),1,!0)),h===!0&&vS(t,o,c,i),!1}})}function vS(t,e,n,s){e.forEach((a,i)=>{if(a.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(a.text);){let u=t.mapping.slice(s).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function NS(t,e,n,s){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(s).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(` -`))}})}function bO(t,e,n){let s=t.resolve(e),a=s.index();return s.parent.canReplaceWith(a,a+1,n)}function vO(t,e,n,s,a){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(s,null,a||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Vn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Oe(Ne.from(o),0,0),1,!0))}function Va(t,e,n=1,s){let a=t.resolve(e),i=a.depth-n,o=s&&s[s.length-1]||a.parent;if(i<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!o.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let h=a.depth-1,f=n-2;h>i;h--,f--){let m=a.node(h),g=a.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),N=s&&s[f+1];N&&(y=y.replaceChild(0,N.type.create(N.attrs)));let j=s&&s[f]||m;if(!m.canReplace(g+1,m.childCount)||!j.type.validContent(y))return!1}let c=a.indexAfter(i),u=s&&s[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function NO(t,e,n=1,s){let a=t.doc.resolve(e),i=Ne.empty,o=Ne.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ne.from(a.node(c).copy(i));let f=s&&s[h];o=Ne.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new Bn(e,e,new Oe(i.append(o),n,n),!0))}function Gi(t,e){let n=t.resolve(e),s=n.index();return wS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function wO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:s}=t.type.schema;for(let a=0;a0?(i=s.node(a+1),c++,o=s.node(a).maybeChild(c)):(i=s.node(a).maybeChild(c-1),o=s.node(a+1)),i&&!i.isTextblock&&wS(i,o)&&s.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?s.before(a):s.after(a)}}function jO(t,e,n){let s=null,{linebreakReplacement:a}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(a&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(a);f&&!m?s=!1:!f&&m&&(s=!0)}let c=t.steps.length;if(s===!1){let f=t.doc.resolve(e+n);NS(t,f.node(),f.before(),c)}o.inlineContent&&w0(t,e+n-1,o,i.node().contentMatchAt(i.index()),s==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new Bn(h,u.map(e+n,-1),Oe.empty,!0)),s===!0){let f=t.doc.resolve(h);vS(t,f.node(),f.before(),t.steps.length)}return t}function kO(t,e,n){let s=t.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),n))return e;if(s.parentOffset==0)for(let a=s.depth-1;a>=0;a--){let i=s.index(a);if(s.node(a).canReplaceWith(i,i,n))return s.before(a+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let a=s.depth-1;a>=0;a--){let i=s.indexAfter(a);if(s.node(a).canReplaceWith(i,i,n))return s.after(a+1);if(i=0;o--){let c=o==s.depth?0:s.pos<=(s.start(o+1)+s.end(o+1))/2?-1:1,u=s.index(o)+(c>0?1:0),h=s.node(o),f=!1;if(i==1)f=h.canReplace(u,u,a);else{let m=h.contentMatchAt(u).findWrapping(a.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?s.pos:c<0?s.before(o+1):s.after(o+1)}return null}function Uf(t,e,n=e,s=Oe.empty){if(e==n&&!s.size)return null;let a=t.resolve(e),i=t.resolve(n);return kS(a,i,s)?new Bn(e,n,s):new SO(a,i,s).fit()}function kS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class SO{constructor(e,n,s){this.$from=e,this.$to=n,this.unplaced=s,this.frontier=[],this.placed=Ne.empty;for(let a=0;a<=e.depth;a++){let i=e.node(a);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(a))})}for(let a=e.depth;a>0;a--)this.placed=Ne.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,s=this.$from,a=this.close(e<0?this.$to:s.doc.resolve(e));if(!a)return null;let i=this.placed,o=s.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new Oe(i,o,c);return e>-1?new Vn(s.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||s.pos!=this.$to.pos?new Bn(s.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,s=0,a=this.unplaced.openEnd;s1&&(a=0),i.type.spec.isolating&&a<=s){e=s;break}n=i.content}for(let n=1;n<=2;n++)for(let s=n==1?e:this.unplaced.openStart;s>=0;s--){let a,i=null;s?(i=lg(this.unplaced.content,s-1).firstChild,a=i.content):a=this.unplaced.content;let o=a.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:h}=this.frontier[c],f,m=null;if(n==1&&(o?h.matchType(o.type)||(m=h.fillBefore(Ne.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:s,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=lg(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Oe(e,n+1,Math.max(s,a.size+n>=e.size-s?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=lg(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new Oe(ed(e,n-1,1),n-1,i?n-1:s)}else this.unplaced=new Oe(ed(e,n,1),n,s)}placeNodes({sliceDepth:e,frontierDepth:n,parent:s,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let j=0;j1||u==0||j.content.size)&&(m=v,f.push(SS(j.mark(g.allowedMarks(j.marks)),h==1?u:0,h==c.childCount?y:-1)))}let N=h==c.childCount;N||(y=-1),this.placed=td(this.placed,n,Ne.from(f)),this.frontier[n].match=m,N&&y<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,v=c;j1&&a==this.$to.end(--s);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:s,type:a}=this.frontier[n],i=n=0;c--){let{match:u,type:h}=this.frontier[c],f=cg(e,c,h,u,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=td(this.placed,n.depth,n.fit)),e=n.move;for(let s=n.depth+1;s<=e.depth;s++){let a=e.node(s),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(s));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,s){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=td(this.placed,this.depth,Ne.from(e.create(n,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ne.empty,!0);n.childCount&&(this.placed=td(this.placed,this.frontier.length,n))}}function ed(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ed(t.firstChild.content,e-1,n)))}function td(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(td(t.lastChild.content,e-1,n)))}function lg(t,e){for(let n=0;n1&&(s=s.replaceChild(0,SS(s.firstChild,e-1,s.childCount==1?n-1:0))),e>0&&(s=t.type.contentMatch.fillBefore(s).append(s),n<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(Ne.empty,!0)))),t.copy(s)}function cg(t,e,n,s,a){let i=t.node(e),o=a?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let c=s.fillBefore(i.content,!0,o);return c&&!CO(n,i.content,o)?c:null}function CO(t,e,n){for(let s=n;s0;g--,y--){let N=a.node(g).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(g)>-1?c=g:a.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=s.openStart;for(let g=s.content,y=0;;y++){let N=g.firstChild;if(h.push(N),y==s.openStart)break;g=N.content}for(let g=f-1;g>=0;g--){let y=h[g],N=EO(y.type);if(N&&!y.sameMarkup(a.node(Math.abs(c)-1)))f=g;else if(N||!y.type.isTextblock)break}for(let g=s.openStart;g>=0;g--){let y=(g+f+1)%(s.openStart+1),N=h[y];if(N)for(let j=0;j=0&&(t.replace(e,n,s),!(t.steps.length>m));g--){let y=o[g];y<0||(e=a.before(y),n=i.after(y))}}function CS(t,e,n,s,a){if(es){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(Ne.empty,!0))}return t}function MO(t,e,n,s){if(!s.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=kO(t.doc,e,s.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new Oe(Ne.from(s),0,0))}function AO(t,e,n){let s=t.doc.resolve(e),a=t.doc.resolve(n),i=ES(s,a);for(let o=0;o0&&(u||s.node(c-1).canReplace(s.index(c-1),a.indexAfter(c-1))))return t.delete(s.before(c),a.after(c))}for(let o=1;o<=s.depth&&o<=a.depth;o++)if(e-s.start(o)==s.depth-o&&n>s.end(o)&&a.end(o)-n!=a.depth-o&&s.start(o-1)==a.start(o-1)&&s.node(o-1).canReplace(s.index(o-1),a.index(o-1)))return t.delete(s.before(o),n);t.delete(e,n)}function ES(t,e){let n=[],s=Math.min(t.depth,e.depth);for(let a=s;a>=0;a--){let i=t.start(a);if(ie.pos+(e.depth-a)||t.node(a).type.spec.isolating||e.node(a).type.spec.isolating)break;(i==e.start(a)||a==t.depth&&a==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&a&&e.start(a-1)==i-1)&&n.push(a)}return n}class Bl extends gs{constructor(e,n,s){super(),this.pos=e,this.attr=n,this.value=s}apply(e){let n=e.nodeAt(this.pos);if(!n)return En.fail("No node at attribute step's position");let s=Object.create(null);for(let i in n.attrs)s[i]=n.attrs[i];s[this.attr]=this.value;let a=n.type.create(s,null,n.marks);return En.fromReplace(e,this.pos,this.pos+1,new Oe(Ne.from(a),0,n.isLeaf?0:1))}getMap(){return Ks.empty}invert(e){return new Bl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Bl(n.pos,n.attr,n.value)}}gs.jsonID("attr",Bl);class Ad extends gs{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let a in e.attrs)n[a]=e.attrs[a];n[this.attr]=this.value;let s=e.type.create(n,e.content,e.marks);return En.ok(s)}getMap(){return Ks.empty}invert(e){return new Ad(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ad(n.attr,n.value)}}gs.jsonID("docAttr",Ad);let Ul=class extends Error{};Ul=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ul.prototype=Object.create(Error.prototype);Ul.prototype.constructor=Ul;Ul.prototype.name="TransformError";class k0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Md}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ul(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let s=0;s{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,s=Oe.empty){let a=Uf(this.doc,e,n,s);return a&&this.step(a),this}replaceWith(e,n,s){return this.replace(e,n,new Oe(Ne.from(s),0,0))}delete(e,n){return this.replace(e,n,Oe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,s){return TO(this,e,n,s),this}replaceRangeWith(e,n,s){return MO(this,e,n,s),this}deleteRange(e,n){return AO(this,e,n),this}lift(e,n){return pO(this,e,n),this}join(e,n=1){return jO(this,e,n),this}wrap(e,n){return xO(this,e,n),this}setBlockType(e,n=e,s,a=null){return yO(this,e,n,s,a),this}setNodeMarkup(e,n,s=null,a){return vO(this,e,n,s,a),this}setNodeAttribute(e,n,s){return this.step(new Bl(e,n,s)),this}setDocAttribute(e,n){return this.step(new Ad(e,n)),this}addNodeMark(e,n){return this.step(new Ai(e,n)),this}removeNodeMark(e,n){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(n instanceof $t)n.isInSet(s.marks)&&this.step(new Fo(e,n));else{let a=s.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new Fo(e,i)),a=i.removeFromSet(a);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,s){return NO(this,e,n,s),this}addMark(e,n,s){return uO(this,e,n,s),this}removeMark(e,n,s){return hO(this,e,n,s),this}clearIncompatible(e,n,s){return w0(this,e,n,s),this}}const dg=Object.create(null);class rt{constructor(e,n,s){this.$anchor=e,this.$head=n,this.ranges=s||[new TS(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let o=n<0?Al(e.node(0),e.node(i),e.before(i+1),e.index(i),n,s):Al(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,s);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Js(e.node(0))}static atStart(e){return Al(e,e,0,0,1)||new Js(e)}static atEnd(e){return Al(e,e,e.content.size,e.childCount,-1)||new Js(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=dg[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in dg)throw new RangeError("Duplicate use of selection JSON ID "+e);return dg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Ze.between(this.$anchor,this.$head).getBookmark()}}rt.prototype.visible=!0;class TS{constructor(e,n){this.$from=e,this.$to=n}}let D1=!1;function L1(t){!D1&&!t.parent.inlineContent&&(D1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ze extends rt{constructor(e,n=e){L1(e),L1(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let s=e.resolve(n.map(this.head));if(!s.parent.inlineContent)return rt.near(s);let a=e.resolve(n.map(this.anchor));return new Ze(a.parent.inlineContent?a:s,s)}replace(e,n=Oe.empty){if(super.replace(e,n),n==Oe.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof Ze&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Kf(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ze(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,s=n){let a=e.resolve(n);return new this(a,s==n?a:e.resolve(s))}static between(e,n,s){let a=e.pos-n.pos;if((!s||a)&&(s=a>=0?1:-1),!n.parent.inlineContent){let i=rt.findFrom(n,s,!0)||rt.findFrom(n,-s,!0);if(i)n=i.$head;else return rt.near(n,s)}return e.parent.inlineContent||(a==0?e=n:(e=(rt.findFrom(e,-s,!0)||rt.findFrom(e,s,!0)).$anchor,e.pos0?0:1);a>0?o=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&Xe.isSelectable(c))return Xe.create(t,n-(a<0?c.nodeSize:0))}else{let u=Al(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function _1(t,e,n){let s=t.steps.length-1;if(s{o==null&&(o=f)}),t.setSelection(rt.near(t.doc.resolve(o),n))}const z1=1,rh=2,$1=4;class RO extends k0{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=rh,this}ensureMarks(e){return $t.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&rh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~rh,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let s=this.selection;return n&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||$t.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,s){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(s==null&&(s=n),!e)return this.deleteRange(n,s);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=s==n?o.marks():o.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(n,s,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(rt.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=$1,this}get scrolledIntoView(){return(this.updated&$1)>0}}function F1(t,e){return!e||!t?t:t.bind(e)}class nd{constructor(e,n,s){this.name=e,this.init=F1(n.init,s),this.apply=F1(n.apply,s)}}const PO=[new nd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new nd("selection",{init(t,e){return t.selection||rt.atStart(e.doc)},apply(t){return t.selection}}),new nd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,s){return s.selection.$cursor?t.storedMarks:null}}),new nd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ug{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=PO.slice(),n&&n.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new nd(s.key,s.spec.state,s))})}}class zl{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let s=0;ss.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[s],i=a.spec.state;i&&i.toJSON&&(n[s]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,s){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new ug(e.schema,e.plugins),i=new zl(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=Ba.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=rt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let c in s){let u=s[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[o.name]=h.fromJSON.call(u,e,n[c],i);return}}i[o.name]=o.init(e,i)}}),i}}function MS(t,e,n){for(let s in t){let a=t[s];a instanceof Function?a=a.bind(e):s=="handleDOMEvents"&&(a=MS(a,e,{})),n[s]=a}return n}class Wt{constructor(e){this.spec=e,this.props={},e.props&&MS(e.props,this,this.props),this.key=e.key?e.key.key:AS("plugin")}getState(e){return e[this.key]}}const hg=Object.create(null);function AS(t){return t in hg?t+"$"+ ++hg[t]:(hg[t]=0,t+"$")}class nn{constructor(e="key"){this.key=AS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const C0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function IS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const RS=(t,e,n)=>{let s=IS(t,n);if(!s)return!1;let a=E0(s);if(!a){let o=s.blockRange(),c=o&&ic(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(BS(t,a,e,-1))return!0;if(s.parent.content.size==0&&(Kl(i,"end")||Xe.isSelectable(i)))for(let o=s.depth;;o--){let c=Uf(t.doc,s.before(o),s.after(o),Oe.empty);if(c&&c.slice.size1)break}return i.isAtom&&a.depth==s.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},OO=(t,e,n)=>{let s=IS(t,n);if(!s)return!1;let a=E0(s);return a?PS(t,a,e):!1},DO=(t,e,n)=>{let s=DS(t,n);if(!s)return!1;let a=T0(s);return a?PS(t,a,e):!1};function PS(t,e,n){let s=e.nodeBefore,a=s,i=e.pos-1;for(;!a.isTextblock;i--){if(a.type.spec.isolating)return!1;let f=a.lastChild;if(!f)return!1;a=f}let o=e.nodeAfter,c=o,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let f=c.firstChild;if(!f)return!1;c=f}let h=Uf(t.doc,i,u,Oe.empty);if(!h||h.from!=i||h instanceof Bn&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(Ze.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Kl(t,e,n=!1){for(let s=t;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(n&&s.childCount!=1)return!1}return!1}const OS=(t,e,n)=>{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):s.parentOffset>0)return!1;i=E0(s)}let o=i&&i.nodeBefore;return!o||!Xe.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Xe.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function E0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function DS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let s=DS(t,n);if(!s)return!1;let a=T0(s);if(!a)return!1;let i=a.nodeAfter;if(BS(t,a,e,1))return!0;if(s.parent.content.size==0&&(Kl(i,"start")||Xe.isSelectable(i))){let o=Uf(t.doc,s.before(),s.after(),Oe.empty);if(o&&o.slice.size{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):s.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,s=n instanceof Xe,a;if(s){if(n.node.isTextblock||!Gi(t.doc,n.from))return!1;a=n.from}else if(a=Wf(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);s&&i.setSelection(Xe.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},_O=(t,e)=>{let n=t.selection,s;if(n instanceof Xe){if(n.node.isTextblock||!Gi(t.doc,n.to))return!1;s=n.to}else if(s=Wf(t.doc,n.to,1),s==null)return!1;return e&&e(t.tr.join(s).scrollIntoView()),!0},zO=(t,e)=>{let{$from:n,$to:s}=t.selection,a=n.blockRange(s),i=a&&ic(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},zS=(t,e)=>{let{$head:n,$anchor:s}=t.selection;return!n.parent.type.spec.code||!n.sameParent(s)?!1:(e&&e(t.tr.insertText(` -`).scrollIntoView()),!0)};function M0(t){for(let e=0;e{let{$head:n,$anchor:s}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(s))return!1;let a=n.node(-1),i=n.indexAfter(-1),o=M0(a.contentMatchAt(i));if(!o||!a.canReplaceWith(i,i,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(rt.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},$S=(t,e)=>{let n=t.selection,{$from:s,$to:a}=n;if(n instanceof Js||s.parent.inlineContent||a.parent.inlineContent)return!1;let i=M0(a.parent.contentMatchAt(a.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!s.parentOffset&&a.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Va(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let s=n.blockRange(),a=s&&ic(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)};function FO(t){return(e,n)=>{let{$from:s,$to:a}=e.selection;if(e.selection instanceof Xe&&e.selection.node.isBlock)return!s.parentOffset||!Va(e.doc,s.pos)?!1:(n&&n(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let y=s.depth;;y--)if(s.node(y).isBlock){u=s.end(y)==s.pos+(s.depth-y),h=s.start(y)==s.pos-(s.depth-y),c=M0(s.node(y-1).contentMatchAt(s.indexAfter(y-1))),i.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof Ze||e.selection instanceof Js)&&f.deleteSelection();let m=f.mapping.map(s.pos),g=Va(f.doc,m,i.length,i);if(g||(i[0]=c?{type:c}:null,g=Va(f.doc,m,i.length,i)),!g)return!1;if(f.split(m,i.length,i),!u&&h&&s.node(o).type!=c){let y=f.mapping.map(s.before(o)),N=f.doc.resolve(y);c&&s.node(o-1).canReplaceWith(N.index(),N.index()+1,c)&&f.setNodeMarkup(f.mapping.map(s.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const BO=FO(),VO=(t,e)=>{let{$from:n,to:s}=t.selection,a,i=n.sharedDepth(s);return i==0?!1:(a=n.before(i),e&&e(t.tr.setSelection(Xe.create(t.doc,a))),!0)};function HO(t,e,n){let s=e.nodeBefore,a=e.nodeAfter,i=e.index();return!s||!a||!s.type.compatibleContent(a.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||Gi(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function BS(t,e,n,s){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&HO(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=a.contentMatchAt(a.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let y=e.pos+i.nodeSize,N=Ne.empty;for(let k=o.length-1;k>=0;k--)N=Ne.from(o[k].create(null,N));N=Ne.from(a.copy(N));let j=t.tr.step(new Vn(e.pos-1,y,e.pos,y,new Oe(N,1,0),o.length,!0)),v=j.doc.resolve(y+2*o.length);v.nodeAfter&&v.nodeAfter.type==a.type&&Gi(j.doc,v.pos)&&j.join(v.pos),n(j.scrollIntoView())}return!0}let f=i.type.spec.isolating||s>0&&u?null:rt.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&ic(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Kl(i,"start",!0)&&Kl(a,"end")){let y=a,N=[];for(;N.push(y),!y.isTextblock;)y=y.lastChild;let j=i,v=1;for(;!j.isTextblock;j=j.firstChild)v++;if(y.canReplace(y.childCount,y.childCount,j.content)){if(n){let k=Ne.empty;for(let E=N.length-1;E>=0;E--)k=Ne.from(N[E].copy(k));let C=t.tr.step(new Vn(e.pos-N.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new Oe(k,N.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function VS(t){return function(e,n){let s=e.selection,a=t<0?s.$from:s.$to,i=a.depth;for(;a.node(i).isInline;){if(!i)return!1;i--}return a.node(i).isTextblock?(n&&n(e.tr.setSelection(Ze.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const WO=VS(-1),UO=VS(1);function KO(t,e=null){return function(n,s){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&j0(o,t,e);return c?(s&&s(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function B1(t,e=null){return function(n,s){let a=!1;for(let i=0;i{if(a)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)a=!0;else{let f=n.doc.resolve(h),m=f.index();a=f.parent.canReplaceWith(m,m+1,t)}})}if(!a)return!1;if(s){let i=n.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=o.resolve(e.start-2);i=new Fh(u,u,e.depth),e.endIndex=0;f--)i=Ne.from(n[f].type.create(n[f].attrs,i));t.step(new Vn(e.start-(s?2:0),e.end,e.start,e.end,new Oe(i,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return i?n?s.node(i.depth-1).type==t?QO(e,n,t,i):XO(e,n,i):!0:!1}}function QO(t,e,n,s){let a=t.tr,i=s.end,o=s.$to.end(s.depth);ij;N--)y-=a.child(N).nodeSize,s.delete(y-1,y+1);let i=s.doc.resolve(n.start),o=i.nodeAfter;if(s.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==a.childCount,h=i.node(-1),f=i.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?Ne.empty:Ne.from(a))))return!1;let m=i.pos,g=m+o.nodeSize;return s.step(new Vn(m-(c?1:0),g+(u?1:0),m+1,g-1,new Oe((c?Ne.empty:Ne.from(a.copy(Ne.empty))).append(u?Ne.empty:Ne.from(a.copy(Ne.empty))),c?0:1,u?0:1),c?0:1)),e(s.scrollIntoView()),!0}function ZO(t){return function(e,n){let{$from:s,$to:a}=e.selection,i=s.blockRange(a,h=>h.childCount>0&&h.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let c=i.parent,u=c.child(o-1);if(u.type!=t)return!1;if(n){let h=u.lastChild&&u.lastChild.type==c.type,f=Ne.from(h?t.create():null),m=new Oe(Ne.from(t.create(null,Ne.from(c.type.create(null,f)))),h?3:1,0),g=i.start,y=i.end;n(e.tr.step(new Vn(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Qn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ql=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let hx=null;const _a=function(t,e,n){let s=hx||(hx=document.createRange());return s.setEnd(t,n??t.nodeValue.length),s.setStart(t,e||0),s},eD=function(){hx=null},Bo=function(t,e,n,s){return n&&(V1(t,e,n,s,-1)||V1(t,e,n,s,1))},tD=/^(img|br|input|textarea|hr)$/i;function V1(t,e,n,s,a){for(var i;;){if(t==n&&e==s)return!0;if(e==(a<0?0:dr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ud(t)||tD.test(t.nodeName)||t.contentEditable=="false")return!1;e=Qn(t)+(a<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(a<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=a;else return!1;else t=o,e=a<0?dr(t):0}else return!1}}function dr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function nD(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=dr(t)}else if(t.parentNode&&!Ud(t))e=Qn(t),t=t.parentNode;else return null}}function sD(t,e){for(;;){if(t.nodeType==3&&e2),cr=Gl||(aa?/Mac/.test(aa.platform):!1),US=aa?/Win/.test(aa.platform):!1,$a=/Android \d/.test(Ji),Kd=!!H1&&"webkitFontSmoothing"in H1.documentElement.style,oD=Kd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function lD(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ra(t,e){return typeof t=="number"?t:t[e]}function cD(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,s=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*s}}function W1(t,e,n){let s=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=ql(o);continue}let c=o,u=c==i.body,h=u?lD(i):cD(c),f=0,m=0;if(e.toph.bottom-Ra(s,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+Ra(a,"top")-h.top:e.bottom-h.bottom+Ra(a,"bottom")),e.lefth.right-Ra(s,"right")&&(f=e.right-h.right+Ra(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let j=c.scrollLeft-y,v=c.scrollTop-N;e={left:e.left-j,top:e.top-v,right:e.right-j,bottom:e.bottom-v}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:ql(o)}}function dD(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),s,a;for(let i=(e.left+e.right)/2,o=n+1;o=n-20){s=c,a=u.top;break}}return{refDOM:s,refTop:a,stack:KS(t.dom)}}function KS(t){let e=[],n=t.ownerDocument;for(let s=t;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),t!=n);s=ql(s));return e}function uD({refDOM:t,refTop:e,stack:n}){let s=t?t.getBoundingClientRect().top:0;qS(n,s==0?0:s-e)}function qS(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let j=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,s=0),n&&n.nodeType==3?fD(n,a):!n||s&&n.nodeType==1?{node:t,offset:i}:GS(n,a)}function fD(t,e){let n=t.nodeValue.length,s=document.createRange(),a;for(let i=0;i=(o.left+o.right)/2?1:0)};break}}return s.detach(),a||{node:t,offset:0}}function I0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pD(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(s,a,i)}function gD(t,e,n,s){let a=-1;for(let i=e,o=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!o&&u.left>s.left||u.top>s.top?a=c.posBefore:(!o&&u.right-1?a:t.docView.posFromDOM(e,n,-1)}function JS(t,e,n){let s=t.childNodes.length;if(s&&n.tope.top&&a++}let h;Kd&&a&&s.nodeType==1&&(h=s.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&a--,s==t.dom&&a==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(a==0||s.nodeType!=1||s.childNodes[a-1].nodeName!="BR")&&(c=gD(t,s,a,e))}c==null&&(c=mD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function U1(t){return t.top=0&&a==s.nodeValue.length?(u--,f=1):n<0?u--:h++,Yc(vi(_a(s,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==dr(s))){let u=s.childNodes[a-1];if(u.nodeType==1)return fg(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==dr(s))){let u=s.childNodes[a-1],h=u.nodeType==3?_a(u,dr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return Yc(vi(h,1),!1)}if(i==null&&a=0)}function Yc(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function fg(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function QS(t,e,n){let s=t.state,a=t.root.activeElement;s!=e&&t.updateState(e),a!=t.dom&&t.focus();try{return n()}finally{s!=e&&t.updateState(s),a!=t.dom&&a&&a.focus()}}function bD(t,e,n){let s=e.selection,a=n=="up"?s.$from:s.$to;return QS(t,e,()=>{let{node:i}=t.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let o=YS(t,a.pos,1);for(let c=i.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=_a(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;hf.top+1&&(n=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}const vD=/[\u0590-\u08ac]/;function ND(t,e,n){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let a=s.parentOffset,i=!a,o=a==s.parent.content.size,c=t.domSelection();return c?!vD.test(s.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:QS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=s.depth?t.docView.domAfterPos(s.before()):t.dom,{focusNode:N,focusOffset:j}=t.domSelectionRange(),v=N&&!y.contains(N.nodeType==1?N:N.parentNode)||u==N&&h==j;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return g!=null&&(c.caretBidiLevel=g),v}):s.pos==s.start()||s.pos==s.end()}let K1=null,q1=null,G1=!1;function wD(t,e,n){return K1==e&&q1==n?G1:(K1=e,q1=n,G1=n=="up"||n=="down"?bD(t,e,n):ND(t,e,n))}const hr=0,J1=1,So=2,ia=3;class qd{constructor(e,n,s,a){this.parent=e,this.children=n,this.dom=s,this.contentDOM=a,this.dirty=hr,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,s){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nQn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!1;break}if(i.previousSibling)break}if(a==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!0;break}if(i.nextSibling)break}}return a??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let s=!0,a=e;a;a=a.parentNode){let i=this.getDesc(a),o;if(i&&(!n||i.node))if(s&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))s=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let s=n;s;s=s.parent)if(s==this)return n}posFromDOM(e,n,s){for(let a=e;a;a=a.parentNode){let i=this.getDesc(a);if(i)return i.localPosFromDOM(e,n,s)}return-1}descAt(e){for(let n=0,s=0;ne||o instanceof ZS){a=e-i;break}i=c}if(a)return this.children[s].domFromPos(a-this.children[s].border,n);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof XS&&i.side>=0;s--);if(n<=0){let i,o=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Qn(i.dom)+1:0}}else{let i,o=!0;for(;i=s=f&&n<=h-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,f);e=o;for(let m=c;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){a=Qn(g.dom)+1;break}e-=g.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fN&&on){let N=c;c=u,u=N}let y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let s=0,a=0;a=s:es){let c=s+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==s||n==o?So:J1,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ia:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?So:ia}s=o}this.dirty=So}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let s=e==1?So:J1;n.dirty{if(!i)return a;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==hr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class jD extends qd{constructor(e,n,s,a){super(e,[],n,null),this.textDOM=s,this.text=a}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Vo extends qd{constructor(e,n,s,a,i){super(e,[],s,a),this.mark=n,this.spec=i}static create(e,n,s,a){let i=a.nodeViews[n.type.name],o=i&&i(n,a,s);return(!o||!o.dom)&&(o=Jo.renderSpec(document,n.type.spec.toDOM(n,s),null,n.attrs)),new Vo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ia||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ia&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=hr){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty0&&(i=xx(i,0,e,s));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},s,a),f=h&&h.dom,m=h&&h.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:m}=Jo.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let g=f;return f=n2(f,s,n),h?u=new kD(e,n,s,a,f,m||null,g,h,i,o+1):n.isText?new Gf(e,n,s,a,f,g,i):new Li(e,n,s,a,f,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ne.empty)}return e}matchesNode(e,n,s){return this.dirty==hr&&e.eq(this.node)&&Vh(n,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let s=this.node.inlineContent,a=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,c=i&&i.pos<0,u=new CD(this,o&&o.node,e);MD(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,s,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?$t.none:this.node.child(f).marks,s,e,f),u.placeWidget(h,e,a)},(h,f,m,g)=>{u.syncToMarks(h.marks,s,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,a)||u.addNode(h,f,m,e,a),a+=h.nodeSize}),u.syncToMarks([],s,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==So)&&(o&&this.protectLocalComposition(e,o),e2(this.contentDOM,this.children,e),Gl&&AD(this.dom))}localCompositionInfo(e,n){let{from:s,to:a}=e.state.selection;if(!(e.state.selection instanceof Ze)||sn+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,c=ID(this.node.content,o,s-n,a-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:s,text:a}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new jD(this,i,n,a);e.input.compositionNodes.push(o),this.children=xx(this.children,s,s+a.length,e,o)}update(e,n,s,a){return this.dirty==ia||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,s,a),!0)}updateInner(e,n,s,a){this.updateOuterDeco(n),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=hr}updateOuterDeco(e){if(Vh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=t2(this.dom,this.nodeDOM,gx(this.outerDeco,this.node,n),gx(e,this.node,n)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Y1(t,e,n,s,a){n2(s,e,t);let i=new Li(void 0,t,e,n,s,s,s,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Gf extends Li{constructor(e,n,s,a,i,o,c){super(e,n,s,a,i,null,o,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,s,a){return this.dirty==ia||this.dirty!=hr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=hr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=e,this.dirty=hr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,s){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,s){let a=this.node.cut(e,n),i=document.createTextNode(a.text);return new Gf(this.parent,a,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ia)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ZS extends qd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==hr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class kD extends Li{constructor(e,n,s,a,i,o,c,u,h,f){super(e,n,s,a,i,o,c,h,f),this.spec=u}update(e,n,s,a){if(this.dirty==ia)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,s);return i&&this.updateInner(e,n,s,a),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,s,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,s,a){this.spec.setSelection?this.spec.setSelection(e,n,s.root):super.setSelection(e,n,s,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function e2(t,e,n){let s=t.firstChild,a=!1;for(let i=0;i>1,c=Math.min(o,e.length);for(;i-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=Vo.create(this.top,e[o],n,s);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,s,a){let i=-1,o;if(a>=this.preMatch.index&&(o=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,s))i=this.top.children.indexOf(o,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c0;){let c;for(;;)if(s){let h=n.children[s-1];if(h instanceof Vo)n=h,s=h.children.length;else{c=h,s--;break}}else{if(n==e)break e;s=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(a-1))break;--a,i.set(c,a),o.push(c)}}return{index:a,matched:i,matches:o.reverse()}}function TD(t,e){return t.type.side-e.type.side}function MD(t,e,n,s){let a=e.locals(t),i=0;if(a.length==0){for(let h=0;hi;)c.push(a[o++]);let N=i+g.nodeSize;if(g.isText){let v=N;o!v.inline):c.slice();s(g,j,e.forChild(i,g),y),i=N}}function AD(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function ID(t,e,n,s){for(let a=0,i=0;a=n){if(i>=s&&u.slice(s-e.length-c,s-c)==e)return s-e.length;let h=c=0&&h+e.length+c>=n)return c+h;if(n==s&&u.length>=s+e.length-c&&u.slice(s-c,s-c+e.length)==e)return s}}return-1}function xx(t,e,n,s,a){let i=[];for(let o=0,c=0;o=n||f<=e?i.push(u):(hn&&i.push(u.slice(n-h,u.size,s)))}return i}function R0(t,e=null){let n=t.domSelectionRange(),s=t.state.doc;if(!n.focusNode)return null;let a=t.docView.nearestDesc(n.focusNode),i=a&&a.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=s.resolve(o),u,h;if(qf(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&Xe.isSelectable(m)&&a.parent&&!(m.isInline&&rD(n.focusNode,n.focusOffset,a.dom))){let g=a.posBefore;h=new Xe(o==g?c:s.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y{(n.anchorNode!=s||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!s2(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function PD(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,s=n.nodeName=="IMG";s?e.collapse(n.parentNode,Qn(n)+1):e.collapse(n,0),!s&&!t.state.selection.visible&&$s&&Di<=11&&(n.disabled=!0,n.disabled=!1)}function r2(t,e){if(e instanceof Xe){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(tN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else tN(t)}function tN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function P0(t,e,n,s){return t.someProp("createSelectionBetween",a=>a(t,e,n))||Ze.between(e,n,s)}function nN(t){return t.editable&&!t.hasFocus()?!1:a2(t)}function a2(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function OD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Bo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function yx(t,e){let{$anchor:n,$head:s}=t.selection,a=e>0?n.max(s):n.min(s),i=a.parent.inlineContent?a.depth?t.doc.resolve(e>0?a.after():a.before()):null:a;return i&&rt.findFrom(i,e)}function Ni(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function sN(t,e,n){let s=t.state.selection;if(s instanceof Ze)if(n.indexOf("s")>-1){let{$head:a}=s,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(a.pos+i.nodeSize*(e<0?-1:1));return Ni(t,new Ze(s.$anchor,o))}else if(s.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=yx(t.state,e);return a&&a instanceof Xe?Ni(t,a):!1}else if(!(cr&&n.indexOf("m")>-1)){let a=s.$head,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter,o;if(!i||i.isText)return!1;let c=e<0?a.pos-i.nodeSize:a.pos;return i.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?Xe.isSelectable(i)?Ni(t,new Xe(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Kd?Ni(t,new Ze(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof Xe&&s.node.isInline)return Ni(t,new Ze(e>0?s.$to:s.$from));{let a=yx(t.state,e);return a?Ni(t,a):!1}}}function Hh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function pd(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ml(t,e){return e<0?DD(t):LD(t)}function DD(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a,i,o=!1;for(ur&&n.nodeType==1&&s0){if(n.nodeType!=1)break;{let c=n.childNodes[s-1];if(pd(c,-1))a=n,i=--s;else if(c.nodeType==3)n=c,s=n.nodeValue.length;else break}}else{if(i2(n))break;{let c=n.previousSibling;for(;c&&pd(c,-1);)a=n.parentNode,i=Qn(c),c=c.previousSibling;if(c)n=c,s=Hh(n);else{if(n=n.parentNode,n==t.dom)break;s=0}}}o?bx(t,n,s):a&&bx(t,a,i)}function LD(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a=Hh(n),i,o;for(;;)if(s{t.state==a&&Ha(t)},50)}function rN(t,e){let n=t.state.doc.resolve(e);if(!(Zn||US)&&n.parent.inlineContent){let a=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>a.top&&o1)return i.lefta.top&&o1)return i.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function aN(t,e,n){let s=t.state.selection;if(s instanceof Ze&&!s.empty||n.indexOf("s")>-1||cr&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=s;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=yx(t.state,e);if(o&&o instanceof Xe)return Ni(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=s instanceof Js?rt.near(o,e):rt.findFrom(o,e);return c?Ni(t,c):!1}return!1}function iN(t,e){if(!(t.state.selection instanceof Ze))return!0;let{$head:n,$anchor:s,empty:a}=t.state.selection;if(!n.sameParent(s))return!0;if(!a)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function oN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function $D(t){if(!ps||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let s=e.firstChild;oN(t,s,"true"),setTimeout(()=>oN(t,s,"false"),20)}return!1}function FD(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function BD(t,e){let n=e.keyCode,s=FD(e);if(n==8||cr&&n==72&&s=="c")return iN(t,-1)||Ml(t,-1);if(n==46&&!e.shiftKey||cr&&n==68&&s=="c")return iN(t,1)||Ml(t,1);if(n==13||n==27)return!0;if(n==37||cr&&n==66&&s=="c"){let a=n==37?rN(t,t.state.selection.from)=="ltr"?-1:1:-1;return sN(t,a,s)||Ml(t,a)}else if(n==39||cr&&n==70&&s=="c"){let a=n==39?rN(t,t.state.selection.from)=="ltr"?1:-1:1;return sN(t,a,s)||Ml(t,a)}else{if(n==38||cr&&n==80&&s=="c")return aN(t,-1,s)||Ml(t,-1);if(n==40||cr&&n==78&&s=="c")return $D(t)||aN(t,1,s)||Ml(t,1);if(s==(cr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function O0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:s,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){a--,i--;let y=s.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),s=y.content}let o=t.someProp("clipboardSerializer")||Jo.fromSchema(t.state.schema),c=h2(),u=c.createElement("div");u.appendChild(o.serializeFragment(s,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=u2[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let N=c.createElement(f[y]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,` +`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let s=e.style;if(s&&s.length)for(let a=0;a!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,s,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let u=this.enter(o,n.attrs||null,s,n.preserveWhitespace);u&&(i=!0,s=u)}else{let u=this.parser.schema.marks[n.mark];s=s.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,s,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,s,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,s),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,s,a){let i=s||0;for(let o=s?e.childNodes[s]:e.firstChild,c=a==null?null:e.childNodes[a];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,s){let a,i;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!a||a.length>h.length+c)&&(a=h,i=u,!h.length))break;if(u.solid){if(s)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):A1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new sh(e,n,u,a,null,c)),this.open++,s}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Td)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)e+=s[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let s=0;s-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(a?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:s&&u>=i?s.node(u-i).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function aO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&pS.hasOwnProperty(s)&&n?(n.appendChild(e),e=n):s=="li"?n=e:s&&(n=null)}}function iO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function M1(t){let e={};for(let n in t)e[n]=t[n];return e}function A1(t,e){let n=e.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let u=0;u{if(i.length||o.marks.length){let c=0,u=0;for(;c=0;a--){let i=this.serializeMark(e.marks[a],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,n,s={}){let a=this.marks[e.type.name];return a&&Nh(ig(s),a(e,n),null,e.attrs)}static renderSpec(e,n,s=null,a){return Nh(e,n,s,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Jo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=I1(e.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(e){return I1(e.marks)}}function I1(t){let e={};for(let n in t){let s=t[n].spec.toDOM;s&&(e[n]=s)}return e}function ig(t){return t.document||window.document}const R1=new WeakMap;function oO(t){let e=R1.get(t);return e===void 0&&R1.set(t,e=lO(t)),e}function lO(t){let e=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=a.indexOf(" ");o>0&&(n=a.slice(0,o),a=a.slice(o+1));let c,u=n?t.createElementNS(n,a):t.createElement(a),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:N}=Nh(t,g,n,s);if(u.appendChild(y),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const mS=65535,gS=Math.pow(2,16);function cO(t,e){return t+e*gS}function P1(t){return t&mS}function dO(t){return(t-(t&mS))/gS}const xS=1,yS=2,wh=4,bS=8;class dx{constructor(e,n,s){this.pos=e,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&bS)>0}get deletedBefore(){return(this.delInfo&(xS|wh))>0}get deletedAfter(){return(this.delInfo&(yS|wh))>0}get deletedAcross(){return(this.delInfo&wh)>0}}class Gs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Gs.empty)return Gs.empty}recover(e){let n=0,s=P1(e);if(!this.inverted)for(let a=0;ae)break;let h=this.ranges[c+i],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+a+(g<0?0:f);if(s)return y;let N=e==(n<0?u:m)?null:cO(c/3,e-u),j=e==u?yS:e==m?xS:wh;return(n<0?e!=u:e!=m)&&(j|=bS),new dx(y,j,N)}a+=f-h}return s?e+a:new dx(e+a,0,null)}touches(e,n){let s=0,a=P1(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+i],f=u+h;if(e<=f&&c==a*3)return!0;s+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,i=0;a=0;n--){let a=e.getMirror(n);this.appendMap(e._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let e=new Md;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let s=this.from;si&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return Tn.fromReplace(e,this.from,this.to,i)}invert(){return new Ir(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Mi(n.pos,s.pos,this.mark)}merge(e){return e instanceof Mi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Mi(n.from,n.to,e.markFromJSON(n.mark))}}vs.jsonID("addMark",Mi);class Ir extends vs{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=new Oe(N0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Tn.fromReplace(e,this.from,this.to,s)}invert(){return new Mi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Ir(n.pos,s.pos,this.mark)}merge(e){return e instanceof Ir&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ir(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ir(n.from,n.to,e.markFromJSON(n.mark))}}vs.jsonID("removeMark",Ir);class Ai extends vs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Tn.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Tn.fromReplace(e,this.pos,this.pos+1,new Oe(Ne.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;as.pos?null:new Hn(n.pos,s.pos,a,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Hn(n.from,n.to,n.gapFrom,n.gapTo,Oe.fromJSON(e,n.slice),n.insert,!!n.structure)}}vs.jsonID("replaceAround",Hn);function ux(t,e,n){let s=t.resolve(e),a=n-e,i=s.depth;for(;a>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,a--;if(a>0){let o=s.node(i).maybeChild(s.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function uO(t,e,n,s){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!s.isInSet(m)&&f.type.allowsMarkType(s.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),N=s.addToSet(m);for(let j=0;jt.step(u)),i.forEach(u=>t.step(u))}function hO(t,e,n,s){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(s instanceof Hf){let h=o.marks,f;for(;f=s.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else s?s.isInSet(o.marks)&&(u=[s]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new Ir(o.from,o.to,o.style)))}function w0(t,e,n,s=n.contentMatch,a=!0){let i=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function fO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ic(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let s=t.depth,a=0,i=0;;--s){let o=t.$from.node(s),c=t.$from.index(s)+a,u=t.$to.indexAfter(s)-i;if(sn;N--)j||s.index(N)>0?(j=!0,f=Ne.from(s.node(N).copy(f)),m++):u--;let g=Ne.empty,y=0;for(let N=i,j=!1;N>n;N--)j||a.after(N+1)=0;o--){if(s.size){let c=n[o].type.contentMatch.matchFragment(s);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=Ne.from(n[o].type.create(n[o].attrs,s))}let a=e.start,i=e.end;t.step(new Hn(a,i,a,i,new Oe(s,0,0),n.length,!0))}function yO(t,e,n,s,a){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof a=="function"?a(o):a;if(o.isTextblock&&!o.hasMarkup(s,u)&&bO(t.doc,t.mapping.slice(i).map(c),s)){let h=null;if(s.schema.linebreakReplacement){let y=s.whitespace=="pre",N=!!s.contentMatch.matchType(s.schema.linebreakReplacement);y&&!N?h=!1:!y&&N&&(h=!0)}h===!1&&NS(t,o,c,i),w0(t,t.mapping.slice(i).map(c,1),s,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),g=f.map(c+o.nodeSize,1);return t.step(new Hn(m,g,m+1,g-1,new Oe(Ne.from(s.create(u,null,o.marks)),0,0),1,!0)),h===!0&&vS(t,o,c,i),!1}})}function vS(t,e,n,s){e.forEach((a,i)=>{if(a.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(a.text);){let u=t.mapping.slice(s).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function NS(t,e,n,s){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(s).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(` +`))}})}function bO(t,e,n){let s=t.resolve(e),a=s.index();return s.parent.canReplaceWith(a,a+1,n)}function vO(t,e,n,s,a){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(s,null,a||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Hn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Oe(Ne.from(o),0,0),1,!0))}function Ha(t,e,n=1,s){let a=t.resolve(e),i=a.depth-n,o=s&&s[s.length-1]||a.parent;if(i<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!o.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let h=a.depth-1,f=n-2;h>i;h--,f--){let m=a.node(h),g=a.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),N=s&&s[f+1];N&&(y=y.replaceChild(0,N.type.create(N.attrs)));let j=s&&s[f]||m;if(!m.canReplace(g+1,m.childCount)||!j.type.validContent(y))return!1}let c=a.indexAfter(i),u=s&&s[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function NO(t,e,n=1,s){let a=t.doc.resolve(e),i=Ne.empty,o=Ne.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ne.from(a.node(c).copy(i));let f=s&&s[h];o=Ne.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new Vn(e,e,new Oe(i.append(o),n,n),!0))}function Gi(t,e){let n=t.resolve(e),s=n.index();return wS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function wO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:s}=t.type.schema;for(let a=0;a0?(i=s.node(a+1),c++,o=s.node(a).maybeChild(c)):(i=s.node(a).maybeChild(c-1),o=s.node(a+1)),i&&!i.isTextblock&&wS(i,o)&&s.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?s.before(a):s.after(a)}}function jO(t,e,n){let s=null,{linebreakReplacement:a}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(a&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(a);f&&!m?s=!1:!f&&m&&(s=!0)}let c=t.steps.length;if(s===!1){let f=t.doc.resolve(e+n);NS(t,f.node(),f.before(),c)}o.inlineContent&&w0(t,e+n-1,o,i.node().contentMatchAt(i.index()),s==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new Vn(h,u.map(e+n,-1),Oe.empty,!0)),s===!0){let f=t.doc.resolve(h);vS(t,f.node(),f.before(),t.steps.length)}return t}function kO(t,e,n){let s=t.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),n))return e;if(s.parentOffset==0)for(let a=s.depth-1;a>=0;a--){let i=s.index(a);if(s.node(a).canReplaceWith(i,i,n))return s.before(a+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let a=s.depth-1;a>=0;a--){let i=s.indexAfter(a);if(s.node(a).canReplaceWith(i,i,n))return s.after(a+1);if(i=0;o--){let c=o==s.depth?0:s.pos<=(s.start(o+1)+s.end(o+1))/2?-1:1,u=s.index(o)+(c>0?1:0),h=s.node(o),f=!1;if(i==1)f=h.canReplace(u,u,a);else{let m=h.contentMatchAt(u).findWrapping(a.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?s.pos:c<0?s.before(o+1):s.after(o+1)}return null}function Uf(t,e,n=e,s=Oe.empty){if(e==n&&!s.size)return null;let a=t.resolve(e),i=t.resolve(n);return kS(a,i,s)?new Vn(e,n,s):new SO(a,i,s).fit()}function kS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class SO{constructor(e,n,s){this.$from=e,this.$to=n,this.unplaced=s,this.frontier=[],this.placed=Ne.empty;for(let a=0;a<=e.depth;a++){let i=e.node(a);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(a))})}for(let a=e.depth;a>0;a--)this.placed=Ne.from(e.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,s=this.$from,a=this.close(e<0?this.$to:s.doc.resolve(e));if(!a)return null;let i=this.placed,o=s.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new Oe(i,o,c);return e>-1?new Hn(s.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||s.pos!=this.$to.pos?new Vn(s.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,s=0,a=this.unplaced.openEnd;s1&&(a=0),i.type.spec.isolating&&a<=s){e=s;break}n=i.content}for(let n=1;n<=2;n++)for(let s=n==1?e:this.unplaced.openStart;s>=0;s--){let a,i=null;s?(i=lg(this.unplaced.content,s-1).firstChild,a=i.content):a=this.unplaced.content;let o=a.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:h}=this.frontier[c],f,m=null;if(n==1&&(o?h.matchType(o.type)||(m=h.fillBefore(Ne.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:s,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=lg(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Oe(e,n+1,Math.max(s,a.size+n>=e.size-s?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:s}=this.unplaced,a=lg(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new Oe(ed(e,n-1,1),n-1,i?n-1:s)}else this.unplaced=new Oe(ed(e,n,1),n,s)}placeNodes({sliceDepth:e,frontierDepth:n,parent:s,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let j=0;j1||u==0||j.content.size)&&(m=v,f.push(SS(j.mark(g.allowedMarks(j.marks)),h==1?u:0,h==c.childCount?y:-1)))}let N=h==c.childCount;N||(y=-1),this.placed=td(this.placed,n,Ne.from(f)),this.frontier[n].match=m,N&&y<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,v=c;j1&&a==this.$to.end(--s);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:s,type:a}=this.frontier[n],i=n=0;c--){let{match:u,type:h}=this.frontier[c],f=cg(e,c,h,u,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=td(this.placed,n.depth,n.fit)),e=n.move;for(let s=n.depth+1;s<=e.depth;s++){let a=e.node(s),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(s));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,s){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=td(this.placed,this.depth,Ne.from(e.create(n,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ne.empty,!0);n.childCount&&(this.placed=td(this.placed,this.frontier.length,n))}}function ed(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ed(t.firstChild.content,e-1,n)))}function td(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(td(t.lastChild.content,e-1,n)))}function lg(t,e){for(let n=0;n1&&(s=s.replaceChild(0,SS(s.firstChild,e-1,s.childCount==1?n-1:0))),e>0&&(s=t.type.contentMatch.fillBefore(s).append(s),n<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(Ne.empty,!0)))),t.copy(s)}function cg(t,e,n,s,a){let i=t.node(e),o=a?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let c=s.fillBefore(i.content,!0,o);return c&&!CO(n,i.content,o)?c:null}function CO(t,e,n){for(let s=n;s0;g--,y--){let N=a.node(g).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(g)>-1?c=g:a.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=s.openStart;for(let g=s.content,y=0;;y++){let N=g.firstChild;if(h.push(N),y==s.openStart)break;g=N.content}for(let g=f-1;g>=0;g--){let y=h[g],N=EO(y.type);if(N&&!y.sameMarkup(a.node(Math.abs(c)-1)))f=g;else if(N||!y.type.isTextblock)break}for(let g=s.openStart;g>=0;g--){let y=(g+f+1)%(s.openStart+1),N=h[y];if(N)for(let j=0;j=0&&(t.replace(e,n,s),!(t.steps.length>m));g--){let y=o[g];y<0||(e=a.before(y),n=i.after(y))}}function CS(t,e,n,s,a){if(es){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(Ne.empty,!0))}return t}function MO(t,e,n,s){if(!s.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=kO(t.doc,e,s.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new Oe(Ne.from(s),0,0))}function AO(t,e,n){let s=t.doc.resolve(e),a=t.doc.resolve(n),i=ES(s,a);for(let o=0;o0&&(u||s.node(c-1).canReplace(s.index(c-1),a.indexAfter(c-1))))return t.delete(s.before(c),a.after(c))}for(let o=1;o<=s.depth&&o<=a.depth;o++)if(e-s.start(o)==s.depth-o&&n>s.end(o)&&a.end(o)-n!=a.depth-o&&s.start(o-1)==a.start(o-1)&&s.node(o-1).canReplace(s.index(o-1),a.index(o-1)))return t.delete(s.before(o),n);t.delete(e,n)}function ES(t,e){let n=[],s=Math.min(t.depth,e.depth);for(let a=s;a>=0;a--){let i=t.start(a);if(ie.pos+(e.depth-a)||t.node(a).type.spec.isolating||e.node(a).type.spec.isolating)break;(i==e.start(a)||a==t.depth&&a==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&a&&e.start(a-1)==i-1)&&n.push(a)}return n}class Bl extends vs{constructor(e,n,s){super(),this.pos=e,this.attr=n,this.value=s}apply(e){let n=e.nodeAt(this.pos);if(!n)return Tn.fail("No node at attribute step's position");let s=Object.create(null);for(let i in n.attrs)s[i]=n.attrs[i];s[this.attr]=this.value;let a=n.type.create(s,null,n.marks);return Tn.fromReplace(e,this.pos,this.pos+1,new Oe(Ne.from(a),0,n.isLeaf?0:1))}getMap(){return Gs.empty}invert(e){return new Bl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Bl(n.pos,n.attr,n.value)}}vs.jsonID("attr",Bl);class Ad extends vs{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let a in e.attrs)n[a]=e.attrs[a];n[this.attr]=this.value;let s=e.type.create(n,e.content,e.marks);return Tn.ok(s)}getMap(){return Gs.empty}invert(e){return new Ad(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ad(n.attr,n.value)}}vs.jsonID("docAttr",Ad);let Ul=class extends Error{};Ul=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ul.prototype=Object.create(Error.prototype);Ul.prototype.constructor=Ul;Ul.prototype.name="TransformError";class k0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Md}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ul(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let s=0;s{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,s=Oe.empty){let a=Uf(this.doc,e,n,s);return a&&this.step(a),this}replaceWith(e,n,s){return this.replace(e,n,new Oe(Ne.from(s),0,0))}delete(e,n){return this.replace(e,n,Oe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,s){return TO(this,e,n,s),this}replaceRangeWith(e,n,s){return MO(this,e,n,s),this}deleteRange(e,n){return AO(this,e,n),this}lift(e,n){return pO(this,e,n),this}join(e,n=1){return jO(this,e,n),this}wrap(e,n){return xO(this,e,n),this}setBlockType(e,n=e,s,a=null){return yO(this,e,n,s,a),this}setNodeMarkup(e,n,s=null,a){return vO(this,e,n,s,a),this}setNodeAttribute(e,n,s){return this.step(new Bl(e,n,s)),this}setDocAttribute(e,n){return this.step(new Ad(e,n)),this}addNodeMark(e,n){return this.step(new Ai(e,n)),this}removeNodeMark(e,n){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(n instanceof Vt)n.isInSet(s.marks)&&this.step(new $o(e,n));else{let a=s.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new $o(e,i)),a=i.removeFromSet(a);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,s){return NO(this,e,n,s),this}addMark(e,n,s){return uO(this,e,n,s),this}removeMark(e,n,s){return hO(this,e,n,s),this}clearIncompatible(e,n,s){return w0(this,e,n,s),this}}const dg=Object.create(null);class nt{constructor(e,n,s){this.$anchor=e,this.$head=n,this.ranges=s||[new TS(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let o=n<0?Al(e.node(0),e.node(i),e.before(i+1),e.index(i),n,s):Al(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,s);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Qs(e.node(0))}static atStart(e){return Al(e,e,0,0,1)||new Qs(e)}static atEnd(e){return Al(e,e,e.content.size,e.childCount,-1)||new Qs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=dg[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in dg)throw new RangeError("Duplicate use of selection JSON ID "+e);return dg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Xe.between(this.$anchor,this.$head).getBookmark()}}nt.prototype.visible=!0;class TS{constructor(e,n){this.$from=e,this.$to=n}}let D1=!1;function L1(t){!D1&&!t.parent.inlineContent&&(D1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Xe extends nt{constructor(e,n=e){L1(e),L1(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let s=e.resolve(n.map(this.head));if(!s.parent.inlineContent)return nt.near(s);let a=e.resolve(n.map(this.anchor));return new Xe(a.parent.inlineContent?a:s,s)}replace(e,n=Oe.empty){if(super.replace(e,n),n==Oe.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof Xe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Kf(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Xe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,s=n){let a=e.resolve(n);return new this(a,s==n?a:e.resolve(s))}static between(e,n,s){let a=e.pos-n.pos;if((!s||a)&&(s=a>=0?1:-1),!n.parent.inlineContent){let i=nt.findFrom(n,s,!0)||nt.findFrom(n,-s,!0);if(i)n=i.$head;else return nt.near(n,s)}return e.parent.inlineContent||(a==0?e=n:(e=(nt.findFrom(e,-s,!0)||nt.findFrom(e,s,!0)).$anchor,e.pos0?0:1);a>0?o=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&Qe.isSelectable(c))return Qe.create(t,n-(a<0?c.nodeSize:0))}else{let u=Al(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function _1(t,e,n){let s=t.steps.length-1;if(s{o==null&&(o=f)}),t.setSelection(nt.near(t.doc.resolve(o),n))}const z1=1,rh=2,F1=4;class RO extends k0{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=rh,this}ensureMarks(e){return Vt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&rh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~rh,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let s=this.selection;return n&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||Vt.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,s){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(s==null&&(s=n),!e)return this.deleteRange(n,s);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=s==n?o.marks():o.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(n,s,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(nt.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=F1,this}get scrolledIntoView(){return(this.updated&F1)>0}}function $1(t,e){return!e||!t?t:t.bind(e)}class nd{constructor(e,n,s){this.name=e,this.init=$1(n.init,s),this.apply=$1(n.apply,s)}}const PO=[new nd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new nd("selection",{init(t,e){return t.selection||nt.atStart(e.doc)},apply(t){return t.selection}}),new nd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,s){return s.selection.$cursor?t.storedMarks:null}}),new nd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ug{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=PO.slice(),n&&n.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new nd(s.key,s.spec.state,s))})}}class zl{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let s=0;ss.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[s],i=a.spec.state;i&&i.toJSON&&(n[s]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,s){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new ug(e.schema,e.plugins),i=new zl(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=Va.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=nt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let c in s){let u=s[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[o.name]=h.fromJSON.call(u,e,n[c],i);return}}i[o.name]=o.init(e,i)}}),i}}function MS(t,e,n){for(let s in t){let a=t[s];a instanceof Function?a=a.bind(e):s=="handleDOMEvents"&&(a=MS(a,e,{})),n[s]=a}return n}class qt{constructor(e){this.spec=e,this.props={},e.props&&MS(e.props,this,this.props),this.key=e.key?e.key.key:AS("plugin")}getState(e){return e[this.key]}}const hg=Object.create(null);function AS(t){return t in hg?t+"$"+ ++hg[t]:(hg[t]=0,t+"$")}class rn{constructor(e="key"){this.key=AS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const C0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function IS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const RS=(t,e,n)=>{let s=IS(t,n);if(!s)return!1;let a=E0(s);if(!a){let o=s.blockRange(),c=o&&ic(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(BS(t,a,e,-1))return!0;if(s.parent.content.size==0&&(Kl(i,"end")||Qe.isSelectable(i)))for(let o=s.depth;;o--){let c=Uf(t.doc,s.before(o),s.after(o),Oe.empty);if(c&&c.slice.size1)break}return i.isAtom&&a.depth==s.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},OO=(t,e,n)=>{let s=IS(t,n);if(!s)return!1;let a=E0(s);return a?PS(t,a,e):!1},DO=(t,e,n)=>{let s=DS(t,n);if(!s)return!1;let a=T0(s);return a?PS(t,a,e):!1};function PS(t,e,n){let s=e.nodeBefore,a=s,i=e.pos-1;for(;!a.isTextblock;i--){if(a.type.spec.isolating)return!1;let f=a.lastChild;if(!f)return!1;a=f}let o=e.nodeAfter,c=o,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let f=c.firstChild;if(!f)return!1;c=f}let h=Uf(t.doc,i,u,Oe.empty);if(!h||h.from!=i||h instanceof Vn&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(Xe.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Kl(t,e,n=!1){for(let s=t;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(n&&s.childCount!=1)return!1}return!1}const OS=(t,e,n)=>{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):s.parentOffset>0)return!1;i=E0(s)}let o=i&&i.nodeBefore;return!o||!Qe.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qe.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function E0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function DS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let s=DS(t,n);if(!s)return!1;let a=T0(s);if(!a)return!1;let i=a.nodeAfter;if(BS(t,a,e,1))return!0;if(s.parent.content.size==0&&(Kl(i,"start")||Qe.isSelectable(i))){let o=Uf(t.doc,s.before(),s.after(),Oe.empty);if(o&&o.slice.size{let{$head:s,empty:a}=t.selection,i=s;if(!a)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):s.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,s=n instanceof Qe,a;if(s){if(n.node.isTextblock||!Gi(t.doc,n.from))return!1;a=n.from}else if(a=Wf(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);s&&i.setSelection(Qe.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},_O=(t,e)=>{let n=t.selection,s;if(n instanceof Qe){if(n.node.isTextblock||!Gi(t.doc,n.to))return!1;s=n.to}else if(s=Wf(t.doc,n.to,1),s==null)return!1;return e&&e(t.tr.join(s).scrollIntoView()),!0},zO=(t,e)=>{let{$from:n,$to:s}=t.selection,a=n.blockRange(s),i=a&&ic(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},zS=(t,e)=>{let{$head:n,$anchor:s}=t.selection;return!n.parent.type.spec.code||!n.sameParent(s)?!1:(e&&e(t.tr.insertText(` +`).scrollIntoView()),!0)};function M0(t){for(let e=0;e{let{$head:n,$anchor:s}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(s))return!1;let a=n.node(-1),i=n.indexAfter(-1),o=M0(a.contentMatchAt(i));if(!o||!a.canReplaceWith(i,i,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(nt.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},FS=(t,e)=>{let n=t.selection,{$from:s,$to:a}=n;if(n instanceof Qs||s.parent.inlineContent||a.parent.inlineContent)return!1;let i=M0(a.parent.contentMatchAt(a.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!s.parentOffset&&a.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ha(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let s=n.blockRange(),a=s&&ic(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)};function $O(t){return(e,n)=>{let{$from:s,$to:a}=e.selection;if(e.selection instanceof Qe&&e.selection.node.isBlock)return!s.parentOffset||!Ha(e.doc,s.pos)?!1:(n&&n(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let y=s.depth;;y--)if(s.node(y).isBlock){u=s.end(y)==s.pos+(s.depth-y),h=s.start(y)==s.pos-(s.depth-y),c=M0(s.node(y-1).contentMatchAt(s.indexAfter(y-1))),i.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof Xe||e.selection instanceof Qs)&&f.deleteSelection();let m=f.mapping.map(s.pos),g=Ha(f.doc,m,i.length,i);if(g||(i[0]=c?{type:c}:null,g=Ha(f.doc,m,i.length,i)),!g)return!1;if(f.split(m,i.length,i),!u&&h&&s.node(o).type!=c){let y=f.mapping.map(s.before(o)),N=f.doc.resolve(y);c&&s.node(o-1).canReplaceWith(N.index(),N.index()+1,c)&&f.setNodeMarkup(f.mapping.map(s.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const BO=$O(),VO=(t,e)=>{let{$from:n,to:s}=t.selection,a,i=n.sharedDepth(s);return i==0?!1:(a=n.before(i),e&&e(t.tr.setSelection(Qe.create(t.doc,a))),!0)};function HO(t,e,n){let s=e.nodeBefore,a=e.nodeAfter,i=e.index();return!s||!a||!s.type.compatibleContent(a.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||Gi(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function BS(t,e,n,s){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&HO(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=a.contentMatchAt(a.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let y=e.pos+i.nodeSize,N=Ne.empty;for(let k=o.length-1;k>=0;k--)N=Ne.from(o[k].create(null,N));N=Ne.from(a.copy(N));let j=t.tr.step(new Hn(e.pos-1,y,e.pos,y,new Oe(N,1,0),o.length,!0)),v=j.doc.resolve(y+2*o.length);v.nodeAfter&&v.nodeAfter.type==a.type&&Gi(j.doc,v.pos)&&j.join(v.pos),n(j.scrollIntoView())}return!0}let f=i.type.spec.isolating||s>0&&u?null:nt.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&ic(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Kl(i,"start",!0)&&Kl(a,"end")){let y=a,N=[];for(;N.push(y),!y.isTextblock;)y=y.lastChild;let j=i,v=1;for(;!j.isTextblock;j=j.firstChild)v++;if(y.canReplace(y.childCount,y.childCount,j.content)){if(n){let k=Ne.empty;for(let E=N.length-1;E>=0;E--)k=Ne.from(N[E].copy(k));let C=t.tr.step(new Hn(e.pos-N.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new Oe(k,N.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function VS(t){return function(e,n){let s=e.selection,a=t<0?s.$from:s.$to,i=a.depth;for(;a.node(i).isInline;){if(!i)return!1;i--}return a.node(i).isTextblock?(n&&n(e.tr.setSelection(Xe.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const WO=VS(-1),UO=VS(1);function KO(t,e=null){return function(n,s){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&j0(o,t,e);return c?(s&&s(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function B1(t,e=null){return function(n,s){let a=!1;for(let i=0;i{if(a)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)a=!0;else{let f=n.doc.resolve(h),m=f.index();a=f.parent.canReplaceWith(m,m+1,t)}})}if(!a)return!1;if(s){let i=n.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=o.resolve(e.start-2);i=new $h(u,u,e.depth),e.endIndex=0;f--)i=Ne.from(n[f].type.create(n[f].attrs,i));t.step(new Hn(e.start-(s?2:0),e.end,e.start,e.end,new Oe(i,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return i?n?s.node(i.depth-1).type==t?QO(e,n,t,i):XO(e,n,i):!0:!1}}function QO(t,e,n,s){let a=t.tr,i=s.end,o=s.$to.end(s.depth);ij;N--)y-=a.child(N).nodeSize,s.delete(y-1,y+1);let i=s.doc.resolve(n.start),o=i.nodeAfter;if(s.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==a.childCount,h=i.node(-1),f=i.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?Ne.empty:Ne.from(a))))return!1;let m=i.pos,g=m+o.nodeSize;return s.step(new Hn(m-(c?1:0),g+(u?1:0),m+1,g-1,new Oe((c?Ne.empty:Ne.from(a.copy(Ne.empty))).append(u?Ne.empty:Ne.from(a.copy(Ne.empty))),c?0:1,u?0:1),c?0:1)),e(s.scrollIntoView()),!0}function ZO(t){return function(e,n){let{$from:s,$to:a}=e.selection,i=s.blockRange(a,h=>h.childCount>0&&h.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let c=i.parent,u=c.child(o-1);if(u.type!=t)return!1;if(n){let h=u.lastChild&&u.lastChild.type==c.type,f=Ne.from(h?t.create():null),m=new Oe(Ne.from(t.create(null,Ne.from(c.type.create(null,f)))),h?3:1,0),g=i.start,y=i.end;n(e.tr.step(new Hn(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const es=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ql=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let hx=null;const _a=function(t,e,n){let s=hx||(hx=document.createRange());return s.setEnd(t,n??t.nodeValue.length),s.setStart(t,e||0),s},eD=function(){hx=null},Bo=function(t,e,n,s){return n&&(V1(t,e,n,s,-1)||V1(t,e,n,s,1))},tD=/^(img|br|input|textarea|hr)$/i;function V1(t,e,n,s,a){for(var i;;){if(t==n&&e==s)return!0;if(e==(a<0?0:hr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ud(t)||tD.test(t.nodeName)||t.contentEditable=="false")return!1;e=es(t)+(a<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(a<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=a;else return!1;else t=o,e=a<0?hr(t):0}else return!1}}function hr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function nD(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=hr(t)}else if(t.parentNode&&!Ud(t))e=es(t),t=t.parentNode;else return null}}function sD(t,e){for(;;){if(t.nodeType==3&&e2),ur=Gl||(aa?/Mac/.test(aa.platform):!1),US=aa?/Win/.test(aa.platform):!1,$a=/Android \d/.test(Ji),Kd=!!H1&&"webkitFontSmoothing"in H1.documentElement.style,oD=Kd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function lD(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ra(t,e){return typeof t=="number"?t:t[e]}function cD(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,s=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*s}}function W1(t,e,n){let s=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=ql(o);continue}let c=o,u=c==i.body,h=u?lD(i):cD(c),f=0,m=0;if(e.toph.bottom-Ra(s,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+Ra(a,"top")-h.top:e.bottom-h.bottom+Ra(a,"bottom")),e.lefth.right-Ra(s,"right")&&(f=e.right-h.right+Ra(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let j=c.scrollLeft-y,v=c.scrollTop-N;e={left:e.left-j,top:e.top-v,right:e.right-j,bottom:e.bottom-v}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:ql(o)}}function dD(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),s,a;for(let i=(e.left+e.right)/2,o=n+1;o=n-20){s=c,a=u.top;break}}return{refDOM:s,refTop:a,stack:KS(t.dom)}}function KS(t){let e=[],n=t.ownerDocument;for(let s=t;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),t!=n);s=ql(s));return e}function uD({refDOM:t,refTop:e,stack:n}){let s=t?t.getBoundingClientRect().top:0;qS(n,s==0?0:s-e)}function qS(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let j=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,s=0),n&&n.nodeType==3?fD(n,a):!n||s&&n.nodeType==1?{node:t,offset:i}:GS(n,a)}function fD(t,e){let n=t.nodeValue.length,s=document.createRange(),a;for(let i=0;i=(o.left+o.right)/2?1:0)};break}}return s.detach(),a||{node:t,offset:0}}function I0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pD(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(s,a,i)}function gD(t,e,n,s){let a=-1;for(let i=e,o=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!o&&u.left>s.left||u.top>s.top?a=c.posBefore:(!o&&u.right-1?a:t.docView.posFromDOM(e,n,-1)}function JS(t,e,n){let s=t.childNodes.length;if(s&&n.tope.top&&a++}let h;Kd&&a&&s.nodeType==1&&(h=s.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&a--,s==t.dom&&a==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(a==0||s.nodeType!=1||s.childNodes[a-1].nodeName!="BR")&&(c=gD(t,s,a,e))}c==null&&(c=mD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function U1(t){return t.top=0&&a==s.nodeValue.length?(u--,f=1):n<0?u--:h++,Yc(Ni(_a(s,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==hr(s))){let u=s.childNodes[a-1];if(u.nodeType==1)return fg(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==hr(s))){let u=s.childNodes[a-1],h=u.nodeType==3?_a(u,hr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return Yc(Ni(h,1),!1)}if(i==null&&a=0)}function Yc(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function fg(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function QS(t,e,n){let s=t.state,a=t.root.activeElement;s!=e&&t.updateState(e),a!=t.dom&&t.focus();try{return n()}finally{s!=e&&t.updateState(s),a!=t.dom&&a&&a.focus()}}function bD(t,e,n){let s=e.selection,a=n=="up"?s.$from:s.$to;return QS(t,e,()=>{let{node:i}=t.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let o=YS(t,a.pos,1);for(let c=i.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=_a(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;hf.top+1&&(n=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}const vD=/[\u0590-\u08ac]/;function ND(t,e,n){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let a=s.parentOffset,i=!a,o=a==s.parent.content.size,c=t.domSelection();return c?!vD.test(s.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:QS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=s.depth?t.docView.domAfterPos(s.before()):t.dom,{focusNode:N,focusOffset:j}=t.domSelectionRange(),v=N&&!y.contains(N.nodeType==1?N:N.parentNode)||u==N&&h==j;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return g!=null&&(c.caretBidiLevel=g),v}):s.pos==s.start()||s.pos==s.end()}let K1=null,q1=null,G1=!1;function wD(t,e,n){return K1==e&&q1==n?G1:(K1=e,q1=n,G1=n=="up"||n=="down"?bD(t,e,n):ND(t,e,n))}const pr=0,J1=1,So=2,ia=3;class qd{constructor(e,n,s,a){this.parent=e,this.children=n,this.dom=s,this.contentDOM=a,this.dirty=pr,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,s){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nes(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!1;break}if(i.previousSibling)break}if(a==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){a=!0;break}if(i.nextSibling)break}}return a??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let s=!0,a=e;a;a=a.parentNode){let i=this.getDesc(a),o;if(i&&(!n||i.node))if(s&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))s=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let s=n;s;s=s.parent)if(s==this)return n}posFromDOM(e,n,s){for(let a=e;a;a=a.parentNode){let i=this.getDesc(a);if(i)return i.localPosFromDOM(e,n,s)}return-1}descAt(e){for(let n=0,s=0;ne||o instanceof ZS){a=e-i;break}i=c}if(a)return this.children[s].domFromPos(a-this.children[s].border,n);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof XS&&i.side>=0;s--);if(n<=0){let i,o=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?es(i.dom)+1:0}}else{let i,o=!0;for(;i=s=f&&n<=h-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,f);e=o;for(let m=c;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){a=es(g.dom)+1;break}e-=g.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fN&&on){let N=c;c=u,u=N}let y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let s=0,a=0;a=s:es){let c=s+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==s||n==o?So:J1,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ia:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?So:ia}s=o}this.dirty=So}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let s=e==1?So:J1;n.dirty{if(!i)return a;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==pr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class jD extends qd{constructor(e,n,s,a){super(e,[],n,null),this.textDOM=s,this.text=a}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Vo extends qd{constructor(e,n,s,a,i){super(e,[],s,a),this.mark=n,this.spec=i}static create(e,n,s,a){let i=a.nodeViews[n.type.name],o=i&&i(n,a,s);return(!o||!o.dom)&&(o=Jo.renderSpec(document,n.type.spec.toDOM(n,s),null,n.attrs)),new Vo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ia||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ia&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=pr){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty0&&(i=xx(i,0,e,s));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},s,a),f=h&&h.dom,m=h&&h.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:m}=Jo.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let g=f;return f=n2(f,s,n),h?u=new kD(e,n,s,a,f,m||null,g,h,i,o+1):n.isText?new Gf(e,n,s,a,f,g,i):new Li(e,n,s,a,f,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ne.empty)}return e}matchesNode(e,n,s){return this.dirty==pr&&e.eq(this.node)&&Vh(n,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let s=this.node.inlineContent,a=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,c=i&&i.pos<0,u=new CD(this,o&&o.node,e);MD(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,s,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?Vt.none:this.node.child(f).marks,s,e,f),u.placeWidget(h,e,a)},(h,f,m,g)=>{u.syncToMarks(h.marks,s,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,a)||u.addNode(h,f,m,e,a),a+=h.nodeSize}),u.syncToMarks([],s,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==So)&&(o&&this.protectLocalComposition(e,o),e2(this.contentDOM,this.children,e),Gl&&AD(this.dom))}localCompositionInfo(e,n){let{from:s,to:a}=e.state.selection;if(!(e.state.selection instanceof Xe)||sn+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,c=ID(this.node.content,o,s-n,a-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:s,text:a}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new jD(this,i,n,a);e.input.compositionNodes.push(o),this.children=xx(this.children,s,s+a.length,e,o)}update(e,n,s,a){return this.dirty==ia||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,s,a),!0)}updateInner(e,n,s,a){this.updateOuterDeco(n),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=pr}updateOuterDeco(e){if(Vh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=t2(this.dom,this.nodeDOM,gx(this.outerDeco,this.node,n),gx(e,this.node,n)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Y1(t,e,n,s,a){n2(s,e,t);let i=new Li(void 0,t,e,n,s,s,s,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Gf extends Li{constructor(e,n,s,a,i,o,c){super(e,n,s,a,i,null,o,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,s,a){return this.dirty==ia||this.dirty!=pr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=pr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=e,this.dirty=pr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,s){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,s){let a=this.node.cut(e,n),i=document.createTextNode(a.text);return new Gf(this.parent,a,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ia)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ZS extends qd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class kD extends Li{constructor(e,n,s,a,i,o,c,u,h,f){super(e,n,s,a,i,o,c,h,f),this.spec=u}update(e,n,s,a){if(this.dirty==ia)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,s);return i&&this.updateInner(e,n,s,a),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,s,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,s,a){this.spec.setSelection?this.spec.setSelection(e,n,s.root):super.setSelection(e,n,s,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function e2(t,e,n){let s=t.firstChild,a=!1;for(let i=0;i>1,c=Math.min(o,e.length);for(;i-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=Vo.create(this.top,e[o],n,s);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,s,a){let i=-1,o;if(a>=this.preMatch.index&&(o=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,s))i=this.top.children.indexOf(o,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c0;){let c;for(;;)if(s){let h=n.children[s-1];if(h instanceof Vo)n=h,s=h.children.length;else{c=h,s--;break}}else{if(n==e)break e;s=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(a-1))break;--a,i.set(c,a),o.push(c)}}return{index:a,matched:i,matches:o.reverse()}}function TD(t,e){return t.type.side-e.type.side}function MD(t,e,n,s){let a=e.locals(t),i=0;if(a.length==0){for(let h=0;hi;)c.push(a[o++]);let N=i+g.nodeSize;if(g.isText){let v=N;o!v.inline):c.slice();s(g,j,e.forChild(i,g),y),i=N}}function AD(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function ID(t,e,n,s){for(let a=0,i=0;a=n){if(i>=s&&u.slice(s-e.length-c,s-c)==e)return s-e.length;let h=c=0&&h+e.length+c>=n)return c+h;if(n==s&&u.length>=s+e.length-c&&u.slice(s-c,s-c+e.length)==e)return s}}return-1}function xx(t,e,n,s,a){let i=[];for(let o=0,c=0;o=n||f<=e?i.push(u):(hn&&i.push(u.slice(n-h,u.size,s)))}return i}function R0(t,e=null){let n=t.domSelectionRange(),s=t.state.doc;if(!n.focusNode)return null;let a=t.docView.nearestDesc(n.focusNode),i=a&&a.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=s.resolve(o),u,h;if(qf(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&Qe.isSelectable(m)&&a.parent&&!(m.isInline&&rD(n.focusNode,n.focusOffset,a.dom))){let g=a.posBefore;h=new Qe(o==g?c:s.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y{(n.anchorNode!=s||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!s2(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function PD(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,s=n.nodeName=="IMG";s?e.collapse(n.parentNode,es(n)+1):e.collapse(n,0),!s&&!t.state.selection.visible&&$s&&Di<=11&&(n.disabled=!0,n.disabled=!1)}function r2(t,e){if(e instanceof Qe){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(tN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else tN(t)}function tN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function P0(t,e,n,s){return t.someProp("createSelectionBetween",a=>a(t,e,n))||Xe.between(e,n,s)}function nN(t){return t.editable&&!t.hasFocus()?!1:a2(t)}function a2(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function OD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Bo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function yx(t,e){let{$anchor:n,$head:s}=t.selection,a=e>0?n.max(s):n.min(s),i=a.parent.inlineContent?a.depth?t.doc.resolve(e>0?a.after():a.before()):null:a;return i&&nt.findFrom(i,e)}function wi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function sN(t,e,n){let s=t.state.selection;if(s instanceof Xe)if(n.indexOf("s")>-1){let{$head:a}=s,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(a.pos+i.nodeSize*(e<0?-1:1));return wi(t,new Xe(s.$anchor,o))}else if(s.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=yx(t.state,e);return a&&a instanceof Qe?wi(t,a):!1}else if(!(ur&&n.indexOf("m")>-1)){let a=s.$head,i=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter,o;if(!i||i.isText)return!1;let c=e<0?a.pos-i.nodeSize:a.pos;return i.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?Qe.isSelectable(i)?wi(t,new Qe(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Kd?wi(t,new Xe(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof Qe&&s.node.isInline)return wi(t,new Xe(e>0?s.$to:s.$from));{let a=yx(t.state,e);return a?wi(t,a):!1}}}function Hh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function pd(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ml(t,e){return e<0?DD(t):LD(t)}function DD(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a,i,o=!1;for(fr&&n.nodeType==1&&s0){if(n.nodeType!=1)break;{let c=n.childNodes[s-1];if(pd(c,-1))a=n,i=--s;else if(c.nodeType==3)n=c,s=n.nodeValue.length;else break}}else{if(i2(n))break;{let c=n.previousSibling;for(;c&&pd(c,-1);)a=n.parentNode,i=es(c),c=c.previousSibling;if(c)n=c,s=Hh(n);else{if(n=n.parentNode,n==t.dom)break;s=0}}}o?bx(t,n,s):a&&bx(t,a,i)}function LD(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let a=Hh(n),i,o;for(;;)if(s{t.state==a&&Wa(t)},50)}function rN(t,e){let n=t.state.doc.resolve(e);if(!(ns||US)&&n.parent.inlineContent){let a=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>a.top&&o1)return i.lefta.top&&o1)return i.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function aN(t,e,n){let s=t.state.selection;if(s instanceof Xe&&!s.empty||n.indexOf("s")>-1||ur&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=s;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=yx(t.state,e);if(o&&o instanceof Qe)return wi(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=s instanceof Qs?nt.near(o,e):nt.findFrom(o,e);return c?wi(t,c):!1}return!1}function iN(t,e){if(!(t.state.selection instanceof Xe))return!0;let{$head:n,$anchor:s,empty:a}=t.state.selection;if(!n.sameParent(s))return!0;if(!a)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function oN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function FD(t){if(!ys||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let s=e.firstChild;oN(t,s,"true"),setTimeout(()=>oN(t,s,"false"),20)}return!1}function $D(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function BD(t,e){let n=e.keyCode,s=$D(e);if(n==8||ur&&n==72&&s=="c")return iN(t,-1)||Ml(t,-1);if(n==46&&!e.shiftKey||ur&&n==68&&s=="c")return iN(t,1)||Ml(t,1);if(n==13||n==27)return!0;if(n==37||ur&&n==66&&s=="c"){let a=n==37?rN(t,t.state.selection.from)=="ltr"?-1:1:-1;return sN(t,a,s)||Ml(t,a)}else if(n==39||ur&&n==70&&s=="c"){let a=n==39?rN(t,t.state.selection.from)=="ltr"?1:-1:1;return sN(t,a,s)||Ml(t,a)}else{if(n==38||ur&&n==80&&s=="c")return aN(t,-1,s)||Ml(t,-1);if(n==40||ur&&n==78&&s=="c")return FD(t)||aN(t,1,s)||Ml(t,1);if(s==(ur?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function O0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:s,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){a--,i--;let y=s.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),s=y.content}let o=t.someProp("clipboardSerializer")||Jo.fromSchema(t.state.schema),c=h2(),u=c.createElement("div");u.appendChild(o.serializeFragment(s,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=u2[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let N=c.createElement(f[y]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,` `);return{dom:u,text:g,slice:e}}function o2(t,e,n,s,a){let i=a.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(s||i||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,i||s,t)}),i)return c=new Oe(Ne.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,a,s,t));if(m)c=m;else{let g=a.marks(),{schema:y}=t.state,N=Jo.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(j=>{let v=o.appendChild(document.createElement("p"));j&&v.appendChild(N.serializeNode(y.text(j,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=UD(n),Kd&&KD(o);let h=o&&o.querySelector("[data-pm-slice]"),f=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let m=+f[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||Oi.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!VD.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=qD(lN(c,+f[1],+f[2]),f[4]);else if(c=Oe.maxOpen(HD(c.content,a),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,u)}),c}const VD=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function HD(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let a=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(c=>{if(!o)return;let u=a.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&i.length&&c2(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=d2(o[o.length-1],i.length));let f=l2(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ne.from(o)}return t}function l2(t,e,n=0){for(let s=e.length-1;s>=n;s--)t=e[s].create(null,Ne.from(t));return t}function c2(t,e,n,s,a){if(a1&&(i=0),a=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,i<=a).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(Ne.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function lN(t,e,n){return en})),mg.createHTML(t)):t}function UD(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=h2().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(t),a;if((a=s&&u2[s[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=WD(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[s[c]];if(!u||u.hasRequiredAttrs())break;a=Ne.from(u.create(s[c+1],a)),i++,o++}return new Oe(a,i,o)}const Ss={},Cs={},GD={touchstart:!0,touchmove:!0};class JD{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function YD(t){for(let e in Ss){let n=Ss[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=s=>{XD(t,s)&&!D0(t,s)&&(t.editable||!(s.type in Cs))&&n(t,s)},GD[e]?{passive:!0}:void 0)}ps&&t.dom.addEventListener("input",()=>null),Nx(t)}function Ii(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function QD(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Nx(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=s=>D0(t,s))})}function D0(t,e){return t.someProp("handleDOMEvents",n=>{let s=n[e.type];return s?s(t,e)||e.defaultPrevented:!1})}function XD(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ZD(t,e){!D0(t,e)&&Ss[e.type]&&(t.editable||!(e.type in Cs))&&Ss[e.type](t,e)}Cs.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!p2(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!($a&&Zn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Gl&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let s=Date.now();t.input.lastIOSEnter=s,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==s&&(t.someProp("handleKeyDown",a=>a(t,wo(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",s=>s(t,n))||BD(t,n)?n.preventDefault():Ii(t,"key")};Cs.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Cs.keypress=(t,e)=>{let n=e;if(p2(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||cr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let s=t.state.selection;if(!(s instanceof Ze)||!s.$from.sameParent(s.$to)){let a=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",o=>o(t,s.$from.pos,s.$to.pos,a,i))&&t.dispatch(i()),n.preventDefault()}};function Jf(t){return{left:t.clientX,top:t.clientY}}function eL(t,e){let n=e.x-t.clientX,s=e.y-t.clientY;return n*n+s*s<100}function L0(t,e,n,s,a){if(s==-1)return!1;let i=t.state.doc.resolve(s);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,c=>o>i.depth?c(t,n,i.nodeAfter,i.before(o),a,!0):c(t,n,i.node(o),i.before(o),a,!1)))return!0;return!1}function Vl(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let s=t.state.tr.setSelection(e);s.setMeta("pointer",!0),t.dispatch(s)}function tL(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),s=n.nodeAfter;return s&&s.isAtom&&Xe.isSelectable(s)?(Vl(t,new Xe(n)),!0):!1}function nL(t,e){if(e==-1)return!1;let n=t.state.selection,s,a;n instanceof Xe&&(s=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let c=o>i.depth?i.nodeAfter:i.node(o);if(Xe.isSelectable(c)){s&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?a=i.before(n.$from.depth):a=i.before(o);break}}return a!=null?(Vl(t,Xe.create(t.state.doc,a)),!0):!1}function sL(t,e,n,s,a){return L0(t,"handleClickOn",e,n,s)||t.someProp("handleClick",i=>i(t,e,s))||(a?nL(t,n):tL(t,n))}function rL(t,e,n,s){return L0(t,"handleDoubleClickOn",e,n,s)||t.someProp("handleDoubleClick",a=>a(t,e,s))}function aL(t,e,n,s){return L0(t,"handleTripleClickOn",e,n,s)||t.someProp("handleTripleClick",a=>a(t,e,s))||iL(t,n,s)}function iL(t,e,n){if(n.button!=0)return!1;let s=t.state.doc;if(e==-1)return s.inlineContent?(Vl(t,Ze.create(s,0,s.content.size)),!0):!1;let a=s.resolve(e);for(let i=a.depth+1;i>0;i--){let o=i>a.depth?a.nodeAfter:a.node(i),c=a.before(i);if(o.inlineContent)Vl(t,Ze.create(s,c+1,c+1+o.content.size));else if(Xe.isSelectable(o))Vl(t,Xe.create(s,c));else continue;return!0}}function _0(t){return Wh(t)}const f2=cr?"metaKey":"ctrlKey";Ss.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let s=_0(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&eL(n,t.input.lastClick)&&!n[f2]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:a,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(Jf(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new oL(t,o,n,!!s)):(i=="doubleClick"?rL:aL)(t,o.pos,o.inside,n)?n.preventDefault():Ii(t,"pointer"))};class oL{constructor(e,n,s,a){this.view=e,this.pos=n,this.event=s,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[f2],this.allowDefault=s.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);i=f.parent,o=f.depth?f.before():0}const c=a?null:s.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(s.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||h instanceof Xe&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ur&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ii(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ha(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Jf(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ii(this.view,"pointer"):sL(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ps&&this.mightDrag&&!this.mightDrag.node.isAtom||Zn&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Vl(this.view,rt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ii(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ii(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ss.touchstart=t=>{t.input.lastTouch=Date.now(),_0(t),Ii(t,"pointer")};Ss.touchmove=t=>{t.input.lastTouch=Date.now(),Ii(t,"pointer")};Ss.contextmenu=t=>_0(t);function p2(t,e){return t.composing?!0:ps&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const lL=$a?5e3:-1;Cs.compositionstart=Cs.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Ze&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)||Zn&&US&&cL(t)))t.markCursor=t.state.storedMarks||n.marks(),Wh(t,!0),t.markCursor=null;else if(Wh(t,!e.selection.empty),ur&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let s=t.domSelectionRange();for(let a=s.focusNode,i=s.focusOffset;a&&a.nodeType==1&&i!=0;){let o=i<0?a.lastChild:a.childNodes[i-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else a=o,i=-1}}t.input.composing=!0}m2(t,lL)};function cL(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let s=e.childNodes[n];return s.nodeType==1&&s.contentEditable=="false"}Cs.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,m2(t,20))};function m2(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Wh(t),e))}function g2(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=uL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function dL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=nD(e.focusNode,e.focusOffset),s=sD(e.focusNode,e.focusOffset);if(n&&s&&n!=s){let a=s.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||s==i)return i;if(!a||!a.isText(s.nodeValue))return s;if(t.input.compositionNode==s){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return s}}return n||s}function uL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Wh(t,e=!1){if(!($a&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),g2(t),e||t.docView&&t.docView.dirty){let n=R0(t),s=t.state.selection;return n&&!n.eq(s)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function hL(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),a=document.createRange();a.selectNodeContents(e),t.dom.blur(),s.removeAllRanges(),s.addRange(a),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Id=$s&&Di<15||Gl&&oD<604;Ss.copy=Cs.cut=(t,e)=>{let n=e,s=t.state.selection,a=n.type=="cut";if(s.empty)return;let i=Id?null:n.clipboardData,o=s.content(),{dom:c,text:u}=O0(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):hL(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function fL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function pL(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,s=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),s.parentNode&&s.parentNode.removeChild(s),n?Rd(t,s.value,null,a,e):Rd(t,s.textContent,s.innerHTML,a,e)},50)}function Rd(t,e,n,s,a){let i=o2(t,e,n,s,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||Oe.empty)))return!0;if(!i)return!1;let o=fL(i),c=o?t.state.tr.replaceSelectionWith(o,s):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function x2(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Cs.paste=(t,e)=>{let n=e;if(t.composing&&!$a)return;let s=Id?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;s&&Rd(t,x2(s),s.getData("text/html"),a,n)?n.preventDefault():pL(t,n)};class y2{constructor(e,n,s){this.slice=e,this.move=n,this.node=s}}const mL=cr?"altKey":"ctrlKey";function b2(t,e){let n=t.someProp("dragCopies",s=>!s(e));return n??!e[mL]}Ss.dragstart=(t,e)=>{let n=e,s=t.input.mouseDown;if(s&&s.done(),!n.dataTransfer)return;let a=t.state.selection,i=a.empty?null:t.posAtCoords(Jf(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof Xe?a.to-1:a.to))){if(s&&s.mightDrag)o=Xe.create(t.state.doc,s.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=Xe.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=O0(t,c);(!n.dataTransfer.files.length||!Zn||WS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Id?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Id||n.dataTransfer.setData("text/plain",h),t.dragging=new y2(f,b2(t,n),o)};Ss.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Cs.dragover=Cs.dragenter=(t,e)=>e.preventDefault();Cs.drop=(t,e)=>{try{gL(t,e,t.dragging)}finally{t.dragging=null}};function gL(t,e,n){if(!e.dataTransfer)return;let s=t.posAtCoords(Jf(e));if(!s)return;let a=t.state.doc.resolve(s.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=o2(t,x2(e.dataTransfer),Id?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&b2(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||Oe.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?jS(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:y}=n;y?y.replace(u):u.deleteSelection()}let h=u.mapping.map(c),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,i.content.firstChild):u.replaceRange(h,h,i),u.doc.eq(m))return;let g=u.doc.resolve(h);if(f&&Xe.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new Xe(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((N,j,v,k)=>y=k),u.setSelection(P0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Ss.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ha(t)},20))};Ss.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ss.beforeinput=(t,e)=>{if(Zn&&$a&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:s}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=s||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,wo(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in Cs)Ss[t]=Cs[t];function Pd(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Uh{constructor(e,n){this.toDOM=e,this.spec=n||Po,this.side=this.spec.side||0}map(e,n,s,a){let{pos:i,deleted:o}=e.mapResult(n.from+a,this.side<0?-1:1);return o?null:new Ln(i-s,i-s,this)}valid(){return!0}eq(e){return this==e||e instanceof Uh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class _i{constructor(e,n){this.attrs=e,this.spec=n||Po}map(e,n,s,a){let i=e.map(n.from+a,this.spec.inclusiveStart?-1:1)-s,o=e.map(n.to+a,this.spec.inclusiveEnd?1:-1)-s;return i>=o?null:new Ln(i,o,this)}valid(e,n){return n.from=e&&(!i||i(c.spec))&&s.push(c.copy(c.from+a,c.to+a))}for(let o=0;oe){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,s,a+c,i)}}map(e,n,s){return this==us||e.maps.length==0?this:this.mapInner(e,n,0,0,s||Po)}mapInner(e,n,s,a,i){let o;for(let c=0;c{let h=u+s,f;if(f=N2(n,c,h)){for(a||(a=this.children.slice());ic&&m.to=e){this.children[c]==e&&(s=this.children[c+2]);break}let i=e+1,o=i+n.content.size;for(let c=0;ci&&u.type instanceof _i){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,Po));return ki.from(s)}forChild(e,n){if(n.isLeaf)return zt.empty;let s=[];for(let a=0;an instanceof zt)?e:e.reduce((n,s)=>n.concat(s instanceof zt?s:s.members),[]))}}forEachSet(e){for(let n=0;n{let v=j-N-(y-g);for(let k=0;kC+f-m)continue;let E=c[k]+f-m;y>=E?c[k+1]=g<=E?-2:-1:g>=f&&v&&(c[k]+=v,c[k+1]+=v)}m+=v}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=s.content.size){u=!0;continue}let g=n.map(t[h+1]+i,-1),y=g-a,{index:N,offset:j}=s.content.findIndex(m),v=s.maybeChild(N);if(v&&j==m&&j+v.nodeSize==y){let k=c[h+2].mapInner(n,v,f+1,t[h]+i+1,o);k!=us?(c[h]=m,c[h+1]=y,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=yL(c,t,e,n,a,i,o),f=Kh(h,s,0,o);e=f.local;for(let m=0;mn&&o.to{let h=N2(t,c,u+n);if(h){i=!0;let f=Kh(h,c,n+u+1,s);f!=us&&a.push(u,u+c.nodeSize,f)}});let o=v2(i?w2(t):t,-n).sort(Oo);for(let c=0;c0;)e++;t.splice(e,0,n)}function gg(t){let e=[];return t.someProp("decorations",n=>{let s=n(t.state);s&&s!=us&&e.push(s)}),t.cursorWrapper&&e.push(zt.create(t.state.doc,[t.cursorWrapper.deco])),ki.from(e)}const bL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vL=$s&&Di<=11;class NL{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class wL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new NL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let a=0;aa.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():ps&&e.composing&&s.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),vL&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,bL)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(nN(this.view)){if(this.suppressingSelectionUpdates)return Ha(this.view);if($s&&Di<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Bo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,s;for(let i=e.focusNode;i;i=ql(i))n.add(i);for(let i=e.anchorNode;i;i=ql(i))if(n.has(i)){s=i;break}let a=s&&this.view.docView.nearestDesc(s);if(a&&a.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let s=e.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&nN(e)&&!this.ignoreSelectionChange(s),i=-1,o=-1,c=!1,u=[];if(e.editable)for(let f=0;ff.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let f of u)if(f.nodeName=="BR"&&f.parentNode){let m=f.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&f.parentNode.removeChild(f)}}else if(ur&&u.length){let f=u.filter(m=>m.nodeName=="BR");if(f.length==2){let[m,g]=f;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of f){let y=g.parentNode;y&&y.nodeName=="LI"&&(!m||SL(e,m)!=y)&&g.remove()}}}let h=null;i<0&&a&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||a)&&(i>-1&&(e.docView.markDirty(i,o),jL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,CL(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||Ha(e),this.currentSelection.set(s))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fa;v--){let k=s.childNodes[v-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){i=v;break}if(!C||C.size)break}let m=t.state.doc,g=t.someProp("domParser")||Oi.fromSchema(t.state.schema),y=m.resolve(o),N=null,j=g.parse(s,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:a,to:i,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:TL,context:y});if(h&&h[0].pos!=null){let v=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=v),N={anchor:v+o,head:k+o}}return{doc:j,sel:N,from:o,to:c}}function TL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ps&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ps&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ML=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function AL(t,e,n,s,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let L=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,R=R0(t,L);if(R&&!t.state.selection.eq(R)){if(Zn&&$a&&t.input.lastKeyCode===13&&Date.now()-100ne(t,wo(13,"Enter"))))return;let O=t.state.tr.setSelection(R);L=="pointer"?O.setMeta("pointer",!0):L=="key"&&O.scrollIntoView(),i&&O.setMeta("composition",i),t.dispatch(O)}return}let o=t.state.doc.resolve(e),c=o.sharedDepth(n);e=o.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,h=EL(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||$a)&&a.some(L=>L.nodeType==1&&!ML.test(L.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",L=>L(t,wo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(s&&u instanceof Ze&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))N={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let L=pN(t,t.state.doc,h.sel);if(L&&!L.eq(t.state.selection)){let R=t.state.tr.setSelection(L);i&&R.setMeta("composition",i),t.dispatch(R)}}return}t.state.selection.fromt.state.selection.from&&N.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?N.start=t.state.selection.from:N.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(N.endB+=t.state.selection.to-N.endA,N.endA=t.state.selection.to)),$s&&Di<=11&&N.endB==N.start+1&&N.endA==N.start&&N.start>h.from&&h.doc.textBetween(N.start-h.from-1,N.start-h.from+1)=="  "&&(N.start--,N.endA--,N.endB--);let j=h.doc.resolveNoCache(N.start-h.from),v=h.doc.resolveNoCache(N.endB-h.from),k=f.resolve(N.start),C=j.sameParent(v)&&j.parent.inlineContent&&k.end()>=N.endA;if((Gl&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some(L=>L.nodeName=="DIV"||L.nodeName=="P"))||!C&&j.posL(t,wo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&RL(f,N.start,N.endA,j,v)&&t.someProp("handleKeyDown",L=>L(t,wo(8,"Backspace")))){$a&&Zn&&t.domObserver.suppressSelectionUpdates();return}Zn&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),$a&&!C&&j.start()!=v.start()&&v.parentOffset==0&&j.depth==v.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==N.endA&&(N.endB-=2,v=h.doc.resolveNoCache(N.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(L){return L(t,wo(13,"Enter"))})},20));let E=N.start,M=N.endA,P=L=>{let R=L||t.state.tr.replace(E,M,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let O=pN(t,R.doc,h.sel);O&&!(Zn&&t.composing&&O.empty&&(N.start!=N.endB||t.input.lastChromeDeleteHa(t),20));let L=P(t.state.tr.delete(E,M)),R=f.resolve(N.start).marksAcross(f.resolve(N.endA));R&&L.ensureMarks(R),t.dispatch(L)}else if(N.endA==N.endB&&(H=IL(j.parent.content.cut(j.parentOffset,v.parentOffset),k.parent.content.cut(k.parentOffset,N.endA-k.start())))){let L=P(t.state.tr);H.type=="add"?L.addMark(E,M,H.mark):L.removeMark(E,M,H.mark),t.dispatch(L)}else if(j.parent.child(j.index()).isText&&j.index()==v.index()-(v.textOffset?0:1)){let L=j.parent.textBetween(j.parentOffset,v.parentOffset),R=()=>P(t.state.tr.insertText(L,E,M));t.someProp("handleTextInput",O=>O(t,E,M,L,R))||t.dispatch(R())}else t.dispatch(P());else t.dispatch(P())}function pN(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:P0(t,e.resolve(n.anchor),e.resolve(n.head))}function IL(t,e){let n=t.firstChild.marks,s=e.firstChild.marks,a=n,i=s,o,c,u;for(let f=0;ff.mark(c.addToSet(f.marks));else if(a.length==0&&i.length==1)c=i[0],o="remove",u=f=>f.mark(c.removeFromSet(f.marks));else return null;let h=[];for(let f=0;fn||xg(o,!0,!1)0&&(e||t.indexAfter(s)==t.node(s).childCount);)s--,a++,e=!1;if(n){let i=t.node(s).maybeChild(t.indexAfter(s));for(;i&&!i.isLeaf;)i=i.firstChild,a++}return a}function PL(t,e,n,s,a){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(a=="end"){let u=Math.max(0,i-Math.min(o,c));s-=o+u-i}if(o=o?i-s:0;i-=u,i&&i=c?i-s:0;i-=u,i&&i=56320&&e<=57343&&n>=55296&&n<=56319}class j2{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new JD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(vN),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=yN(this),xN(this),this.nodeViews=bN(this),this.docView=Y1(this.state.doc,gN(this),gg(this),this.dom,this),this.domObserver=new wL(this,(s,a,i,o)=>AL(this,s,a,i,o)),this.domObserver.start(),YD(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Nx(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vN),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let s in this._props)n[s]=this._props[s];n.state=this.state;for(let s in e)n[s]=e[s];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var s;let a=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(g2(this),o=!0),this.state=e;let c=a.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=bN(this);DL(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Nx(this),this.editable=yN(this),xN(this);let u=gg(this),h=gN(this),f=a.plugins!=e.plugins&&!a.doc.eq(e.doc)?"reset":e.scrollToSelection>a.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(a.selection))&&(o=!0);let g=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&dD(this);if(o){this.domObserver.stop();let y=m&&($s||Zn)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&OL(a.selection,e.selection);if(m){let N=Zn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=dL(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=Y1(e.doc,h,u,this.dom,this)),N&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&OD(this))?Ha(this,y):(r2(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((s=this.dragging)===null||s===void 0)&&s.node&&!a.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,a),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&uD(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Xe){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&W1(this,n.getBoundingClientRect(),e)}else W1(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(i))==s.node&&(a=i)}this.dragging=new y2(e.slice,e.move,a<0?void 0:Xe.create(this.state.doc,a))}someProp(e,n){let s=this._props&&this._props[e],a;if(s!=null&&(a=n?n(s):s))return a;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return xD(this,e)}coordsAtPos(e,n=1){return YS(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,s=-1){let a=this.docView.posFromDOM(e,n,s);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(e,n){return wD(this,n||this.state,e)}pasteHTML(e,n){return Rd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Rd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return O0(this,e)}destroy(){this.docView&&(QD(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gg(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,eD())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ZD(this,e)}domSelectionRange(){let e=this.domSelection();return e?ps&&this.root.nodeType===11&&aD(this.dom.ownerDocument)==this.dom&&kL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}j2.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function gN(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let s in n)s=="class"?e.class+=" "+n[s]:s=="style"?e.style=(e.style?e.style+";":"")+n[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(n[s]))}),e.translate||(e.translate="no"),[Ln.node(0,t.state.doc.content.size,e)]}function xN(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ln.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function yN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function OL(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function bN(t){let e=Object.create(null);function n(s){for(let a in s)Object.prototype.hasOwnProperty.call(e,a)||(e[a]=s[a])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function DL(t,e){let n=0,s=0;for(let a in t){if(t[a]!=e[a])return!0;n++}for(let a in e)s++;return n!=s}function vN(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Fi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},qh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},LL=typeof navigator<"u"&&/Mac/.test(navigator.platform),_L=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Xn=0;Xn<10;Xn++)Fi[48+Xn]=Fi[96+Xn]=String(Xn);for(var Xn=1;Xn<=24;Xn++)Fi[Xn+111]="F"+Xn;for(var Xn=65;Xn<=90;Xn++)Fi[Xn]=String.fromCharCode(Xn+32),qh[Xn]=String.fromCharCode(Xn);for(var yg in Fi)qh.hasOwnProperty(yg)||(qh[yg]=Fi[yg]);function zL(t){var e=LL&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||_L&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?qh:Fi)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const $L=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),FL=typeof navigator<"u"&&/Win/.test(navigator.platform);function BL(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let s,a,i,o;for(let c=0;c{for(var n in e)WL(t,n,{get:e[n],enumerable:!0})};function Yf(t){const{state:e,transaction:n}=t;let{selection:s}=n,{doc:a}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return s},get doc(){return a},get tr(){return s=n.selection,a=n.doc,i=n.storedMarks,n}}}var Qf=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:s}=e,{tr:a}=n,i=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(i);return!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:s,state:a}=this,{view:i}=s,o=[],c=!!t,u=t||a.tr,h=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),o.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...N)=>{const j=this.buildProps(u,e),v=g(...N)(j);return o.push(v),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,s=!1,a=t||n.tr,i=this.buildProps(a,s);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...i,dispatch:void 0})])),chain:()=>this.createChain(a,s)}}buildProps(t,e=!0){const{rawCommands:n,editor:s,state:a}=this,{view:i}=s,o={tr:t,editor:s,view:i,state:Yf({state:a,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...h)=>u(...h)(o)]))}};return o}},k2={};B0(k2,{blur:()=>UL,clearContent:()=>KL,clearNodes:()=>qL,command:()=>GL,createParagraphNear:()=>JL,cut:()=>YL,deleteCurrentNode:()=>QL,deleteNode:()=>XL,deleteRange:()=>ZL,deleteSelection:()=>e8,enter:()=>t8,exitCode:()=>n8,extendMarkRange:()=>s8,first:()=>r8,focus:()=>i8,forEach:()=>o8,insertContent:()=>l8,insertContentAt:()=>u8,joinBackward:()=>p8,joinDown:()=>f8,joinForward:()=>m8,joinItemBackward:()=>g8,joinItemForward:()=>x8,joinTextblockBackward:()=>y8,joinTextblockForward:()=>b8,joinUp:()=>h8,keyboardShortcut:()=>N8,lift:()=>w8,liftEmptyBlock:()=>j8,liftListItem:()=>k8,newlineInCode:()=>S8,resetAttributes:()=>C8,scrollIntoView:()=>E8,selectAll:()=>T8,selectNodeBackward:()=>M8,selectNodeForward:()=>A8,selectParentNode:()=>I8,selectTextblockEnd:()=>R8,selectTextblockStart:()=>P8,setContent:()=>O8,setMark:()=>e6,setMeta:()=>t6,setNode:()=>n6,setNodeSelection:()=>s6,setTextDirection:()=>r6,setTextSelection:()=>a6,sinkListItem:()=>i6,splitBlock:()=>o6,splitListItem:()=>l6,toggleList:()=>c6,toggleMark:()=>d6,toggleNode:()=>u6,toggleWrap:()=>h6,undoInputRule:()=>f6,unsetAllMarks:()=>p6,unsetMark:()=>m6,unsetTextDirection:()=>g6,updateAttributes:()=>x6,wrapIn:()=>y6,wrapInList:()=>b6});var UL=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),KL=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),qL=()=>({state:t,tr:e,dispatch:n})=>{const{selection:s}=e,{ranges:a}=s;return n&&a.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(c,u)=>{if(c.type.isText)return;const{doc:h,mapping:f}=e,m=h.resolve(f.map(u)),g=h.resolve(f.map(u+c.nodeSize)),y=m.blockRange(g);if(!y)return;const N=ic(y);if(c.type.isTextblock){const{defaultType:j}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,j)}(N||N===0)&&e.lift(y,N)})}),!0},GL=t=>e=>t(e),JL=()=>({state:t,dispatch:e})=>$S(t,e),YL=(t,e)=>({editor:n,tr:s})=>{const{state:a}=n,i=a.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const o=s.mapping.map(e);return s.insert(o,i.content),s.setSelection(new Ze(s.doc.resolve(Math.max(o-1,0)))),!0},QL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,s=n.$anchor.node();if(s.content.size>0)return!1;const a=t.selection.$anchor;for(let i=a.depth;i>0;i-=1)if(a.node(i).type===s.type){if(e){const c=a.before(i),u=a.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1};function Tn(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var XL=t=>({tr:e,state:n,dispatch:s})=>{const a=Tn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===a){if(s){const u=i.before(o),h=i.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},ZL=t=>({tr:e,dispatch:n})=>{const{from:s,to:a}=t;return n&&e.delete(s,a),!0},e8=()=>({state:t,dispatch:e})=>C0(t,e),t8=()=>({commands:t})=>t.keyboardShortcut("Enter"),n8=()=>({state:t,dispatch:e})=>$O(t,e);function V0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Gh(t,e,n={strict:!0}){const s=Object.keys(e);return s.length?s.every(a=>n.strict?e[a]===t[a]:V0(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function S2(t,e,n={}){return t.find(s=>s.type===e&&Gh(Object.fromEntries(Object.keys(n).map(a=>[a,s.attrs[a]])),n))}function NN(t,e,n={}){return!!S2(t,e,n)}function H0(t,e,n){var s;if(!t||!e)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(f=>f.type===e))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(f=>f.type===e)||(n=n||((s=a.node.marks[0])==null?void 0:s.attrs),!S2([...a.node.marks],e,n)))return;let o=a.index,c=t.start()+a.offset,u=o+1,h=c+a.node.nodeSize;for(;o>0&&NN([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u({tr:n,state:s,dispatch:a})=>{const i=qa(t,s.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=H0(u,i,e);if(m&&m.from<=h&&m.to>=f){const g=Ze.create(o,m.from,m.to);n.setSelection(g)}}return!0},r8=t=>e=>{const n=typeof t=="function"?t(e):t;for(let s=0;s({editor:n,view:s,tr:a,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Jh()||wN())&&s.dom.focus(),a8()&&!Jh()&&!wN()&&s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(s.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!C2(n.state.selection))return o(),!0;const c=E2(a.doc,t)||n.state.selection,u=n.state.selection.eq(c);return i&&(u||a.setSelection(c),u&&a.storedMarks&&a.setStoredMarks(a.storedMarks),o()),!0},o8=(t,e)=>n=>t.every((s,a)=>e(s,{...n,index:a})),l8=(t,e)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),T2=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const s=e[n];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?t.removeChild(s):s.nodeType===1&&T2(s)}return t};function ah(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return T2(n)}function Od(t,e,n){if(t instanceof Ba||t instanceof Ne)return t;n={slice:!0,parseOptions:{},...n};const s=typeof t=="object"&&t!==null,a=typeof t=="string";if(s)try{if(Array.isArray(t)&&t.length>0)return Ne.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Od("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new hS({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:h=>(o=!0,c=typeof h=="string"?h:h.outerHTML,null)}]}})});if(n.slice?Oi.fromSchema(u).parseSlice(ah(t),n.parseOptions):Oi.fromSchema(u).parse(ah(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=Oi.fromSchema(e);return n.slice?i.parseSlice(ah(t),n.parseOptions).content:i.parse(ah(t),n.parseOptions)}return Od("",e,n)}function c8(t,e,n){const s=t.steps.length-1;if(s{o===0&&(o=f)}),t.setSelection(rt.near(t.doc.resolve(o),n))}var d8=t=>!("type"in t),u8=(t,e,n)=>({tr:s,dispatch:a,editor:i})=>{var o;if(a){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=v=>{i.emit("contentError",{editor:i,error:v,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Od(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(v){u(v)}try{c=Od(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(v){return u(v),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((d8(c)?c:[c]).forEach(v=>{v.check(),g=g?v.isText&&v.marks.length===0:!1,y=y?v.isBlock:!1}),f===m&&y){const{parent:v}=s.doc.resolve(f);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(f-=1,m+=1)}let j;if(g){if(Array.isArray(e))j=e.map(v=>v.text||"").join("");else if(e instanceof Ne){let v="";e.forEach(k=>{k.text&&(v+=k.text)}),j=v}else typeof e=="object"&&e&&e.text?j=e.text:j=e;s.insertText(j,f,m)}else{j=c;const v=s.doc.resolve(f),k=v.node(),C=v.parentOffset===0,E=k.isText||k.isTextblock,M=k.content.size>0;C&&E&&M&&(f=Math.max(0,f-1)),s.replaceWith(f,m,j)}n.updateSelection&&c8(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:f,text:j}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:f,text:j})}return!0},h8=()=>({state:t,dispatch:e})=>LO(t,e),f8=()=>({state:t,dispatch:e})=>_O(t,e),p8=()=>({state:t,dispatch:e})=>RS(t,e),m8=()=>({state:t,dispatch:e})=>LS(t,e),g8=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Wf(t.doc,t.selection.$from.pos,-1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},x8=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Wf(t.doc,t.selection.$from.pos,1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},y8=()=>({state:t,dispatch:e})=>OO(t,e),b8=()=>({state:t,dispatch:e})=>DO(t,e);function M2(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function v8(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let s,a,i,o;for(let c=0;c({editor:e,view:n,tr:s,dispatch:a})=>{const i=v8(t).split(/-(?!$)/),o=i.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),c=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",h=>h(n,c))});return u==null||u.steps.forEach(h=>{const f=h.map(s.mapping);f&&a&&s.maybeStep(f)}),!0};function Bi(t,e,n={}){const{from:s,to:a,empty:i}=t.selection,o=e?Tn(e,t.schema):null,c=[];t.doc.nodesBetween(s,a,(m,g)=>{if(m.isText)return;const y=Math.max(s,g),N=Math.min(a,g+m.nodeSize);c.push({node:m,from:y,to:N})});const u=a-s,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Gh(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var w8=(t,e={})=>({state:n,dispatch:s})=>{const a=Tn(t,n.schema);return Bi(n,a,e)?zO(n,s):!1},j8=()=>({state:t,dispatch:e})=>FS(t,e),k8=t=>({state:e,dispatch:n})=>{const s=Tn(t,e.schema);return YO(s)(e,n)},S8=()=>({state:t,dispatch:e})=>zS(t,e);function Xf(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function jN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((s,a)=>(n.includes(a)||(s[a]=t[a]),s),{})}var C8=(t,e)=>({tr:n,state:s,dispatch:a})=>{let i=null,o=null;const c=Xf(typeof t=="string"?t:t.name,s.schema);if(!c)return!1;c==="node"&&(i=Tn(t,s.schema)),c==="mark"&&(o=qa(t,s.schema));let u=!1;return n.selection.ranges.forEach(h=>{s.doc.nodesBetween(h.$from.pos,h.$to.pos,(f,m)=>{i&&i===f.type&&(u=!0,a&&n.setNodeMarkup(m,void 0,jN(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&(u=!0,a&&n.addMark(m,m+f.nodeSize,o.create(jN(g.attrs,e))))})})}),u},E8=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),T8=()=>({tr:t,dispatch:e})=>{if(e){const n=new Js(t.doc);t.setSelection(n)}return!0},M8=()=>({state:t,dispatch:e})=>OS(t,e),A8=()=>({state:t,dispatch:e})=>_S(t,e),I8=()=>({state:t,dispatch:e})=>VO(t,e),R8=()=>({state:t,dispatch:e})=>UO(t,e),P8=()=>({state:t,dispatch:e})=>WO(t,e);function wx(t,e,n={},s={}){return Od(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:s.errorOnInvalidContent})}var O8=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:s={}}={})=>({editor:a,tr:i,dispatch:o,commands:c})=>{const{doc:u}=i;if(s.preserveWhitespace!=="full"){const h=wx(t,a.schema,s,{errorOnInvalidContent:e??a.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:s,errorOnInvalidContent:e??a.options.enableContentCheck})};function A2(t,e){const n=qa(e,t.schema),{from:s,to:a,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(s,a,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function I2(t,e){const n=new k0(t);return e.forEach(s=>{s.steps.forEach(a=>{n.step(a)})}),n}function D8(t){for(let e=0;e{n(a)&&s.push({node:a,pos:i})}),s}function R2(t,e){for(let n=t.depth;n>0;n-=1){const s=t.node(n);if(e(s))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:s}}}function Zf(t){return e=>R2(e.$from,t)}function Ge(t,e,n){return t.config[e]===void 0&&t.parent?Ge(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ge(t.parent,e,n):null}):t.config[e]}function W0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},s=Ge(e,"addExtensions",n);return s?[e,...W0(s())]:e}).flat(10)}function U0(t,e){const n=Jo.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function P2(t){return typeof t=="function"}function kt(t,e=void 0,...n){return P2(t)?e?t.bind(e)(...n):t(...n):t}function _8(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Jl(t){const e=t.filter(a=>a.type==="extension"),n=t.filter(a=>a.type==="node"),s=t.filter(a=>a.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:s}}function O2(t){const e=[],{nodeExtensions:n,markExtensions:s}=Jl(t),a=[...n,...s],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(h=>h.name!=="text").map(h=>h.name),c=s.map(h=>h.name),u=[...o,...c];return t.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage,extensions:a},m=Ge(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let N;Array.isArray(y.types)?N=y.types:y.types==="*"?N=u:y.types==="nodes"?N=o:y.types==="marks"?N=c:N=[],N.forEach(j=>{Object.entries(y.attributes).forEach(([v,k])=>{e.push({type:j,name:v,attribute:{...i,...k}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=Ge(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,N])=>{const j={...i,...N};typeof(j==null?void 0:j.default)=="function"&&(j.default=j.default()),j!=null&&j.isRequired&&(j==null?void 0:j.default)===void 0&&delete j.default,e.push({type:h.name,name:y,attribute:j})})}),e}function z8(t){const e=[];let n="",s=!1,a=!1,i=0;const o=t.length;for(let c=0;c0){i-=1,n+=u;continue}if(u===";"&&i===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function kN(t){const e=[],n=z8(t||""),s=n.length;for(let a=0;a!!e).reduce((e,n)=>{const s={...e};return Object.entries(n).forEach(([a,i])=>{if(!s[a]){s[a]=i;return}if(a==="class"){const c=i?String(i).split(" "):[],u=s[a]?s[a].split(" "):[],h=c.filter(f=>!u.includes(f));s[a]=[...u,...h].join(" ")}else if(a==="style"){const c=new Map([...kN(s[a]),...kN(i)]);s[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else s[a]=i}),s},{})}function Dd(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,s)=>Et(n,s),{})}function $8(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function SN(t,e){return"style"in t?t:{...t,getAttrs:n=>{const s=t.getAttrs?t.getAttrs(n):t.attrs;if(s===!1)return!1;const a=e.reduce((i,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):$8(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...s,...a}}}}function CN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&_8(n)?!1:n!=null))}function EN(t){var e,n;const s={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(s.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(s.validate=t.attribute.validate),[t.name,s]}function F8(t,e){var n;const s=O2(t),{nodeExtensions:a,markExtensions:i}=Jl(t),o=(n=a.find(h=>Ge(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(a.map(h=>{const f=s.filter(k=>k.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((k,C)=>{const E=Ge(C,"extendNodeSchema",m);return{...k,...E?E(h):{}}},{}),y=CN({...g,content:kt(Ge(h,"content",m)),marks:kt(Ge(h,"marks",m)),group:kt(Ge(h,"group",m)),inline:kt(Ge(h,"inline",m)),atom:kt(Ge(h,"atom",m)),selectable:kt(Ge(h,"selectable",m)),draggable:kt(Ge(h,"draggable",m)),code:kt(Ge(h,"code",m)),whitespace:kt(Ge(h,"whitespace",m)),linebreakReplacement:kt(Ge(h,"linebreakReplacement",m)),defining:kt(Ge(h,"defining",m)),isolating:kt(Ge(h,"isolating",m)),attrs:Object.fromEntries(f.map(EN))}),N=kt(Ge(h,"parseHTML",m));N&&(y.parseDOM=N.map(k=>SN(k,f)));const j=Ge(h,"renderHTML",m);j&&(y.toDOM=k=>j({node:k,HTMLAttributes:Dd(k,f)}));const v=Ge(h,"renderText",m);return v&&(y.toText=v),[h.name,y]})),u=Object.fromEntries(i.map(h=>{const f=s.filter(v=>v.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((v,k)=>{const C=Ge(k,"extendMarkSchema",m);return{...v,...C?C(h):{}}},{}),y=CN({...g,inclusive:kt(Ge(h,"inclusive",m)),excludes:kt(Ge(h,"excludes",m)),group:kt(Ge(h,"group",m)),spanning:kt(Ge(h,"spanning",m)),code:kt(Ge(h,"code",m)),attrs:Object.fromEntries(f.map(EN))}),N=kt(Ge(h,"parseHTML",m));N&&(y.parseDOM=N.map(v=>SN(v,f)));const j=Ge(h,"renderHTML",m);return j&&(y.toDOM=v=>j({mark:v,HTMLAttributes:Dd(v,f)})),[h.name,y]}));return new hS({topNode:o,nodes:c,marks:u})}function B8(t){const e=t.filter((n,s)=>t.indexOf(n)!==s);return Array.from(new Set(e))}function md(t){return t.sort((n,s)=>{const a=Ge(n,"priority")||100,i=Ge(s,"priority")||100;return a>i?-1:as.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),e}function L2(t,e,n){const{from:s,to:a}=e,{blockSeparator:i=` +`))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,a,s,t));if(m)c=m;else{let g=a.marks(),{schema:y}=t.state,N=Jo.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(j=>{let v=o.appendChild(document.createElement("p"));j&&v.appendChild(N.serializeNode(y.text(j,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=UD(n),Kd&&KD(o);let h=o&&o.querySelector("[data-pm-slice]"),f=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let m=+f[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||Oi.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!VD.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=qD(lN(c,+f[1],+f[2]),f[4]);else if(c=Oe.maxOpen(HD(c.content,a),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,u)}),c}const VD=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function HD(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let a=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(c=>{if(!o)return;let u=a.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&i.length&&c2(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=d2(o[o.length-1],i.length));let f=l2(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ne.from(o)}return t}function l2(t,e,n=0){for(let s=e.length-1;s>=n;s--)t=e[s].create(null,Ne.from(t));return t}function c2(t,e,n,s,a){if(a1&&(i=0),a=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,i<=a).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(Ne.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function lN(t,e,n){return en})),mg.createHTML(t)):t}function UD(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=h2().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(t),a;if((a=s&&u2[s[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=WD(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[s[c]];if(!u||u.hasRequiredAttrs())break;a=Ne.from(u.create(s[c+1],a)),i++,o++}return new Oe(a,i,o)}const Es={},Ts={},GD={touchstart:!0,touchmove:!0};class JD{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function YD(t){for(let e in Es){let n=Es[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=s=>{XD(t,s)&&!D0(t,s)&&(t.editable||!(s.type in Ts))&&n(t,s)},GD[e]?{passive:!0}:void 0)}ys&&t.dom.addEventListener("input",()=>null),Nx(t)}function Ii(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function QD(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Nx(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=s=>D0(t,s))})}function D0(t,e){return t.someProp("handleDOMEvents",n=>{let s=n[e.type];return s?s(t,e)||e.defaultPrevented:!1})}function XD(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ZD(t,e){!D0(t,e)&&Es[e.type]&&(t.editable||!(e.type in Ts))&&Es[e.type](t,e)}Ts.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!p2(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!($a&&ns&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Gl&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let s=Date.now();t.input.lastIOSEnter=s,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==s&&(t.someProp("handleKeyDown",a=>a(t,wo(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",s=>s(t,n))||BD(t,n)?n.preventDefault():Ii(t,"key")};Ts.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ts.keypress=(t,e)=>{let n=e;if(p2(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ur&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let s=t.state.selection;if(!(s instanceof Xe)||!s.$from.sameParent(s.$to)){let a=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",o=>o(t,s.$from.pos,s.$to.pos,a,i))&&t.dispatch(i()),n.preventDefault()}};function Jf(t){return{left:t.clientX,top:t.clientY}}function eL(t,e){let n=e.x-t.clientX,s=e.y-t.clientY;return n*n+s*s<100}function L0(t,e,n,s,a){if(s==-1)return!1;let i=t.state.doc.resolve(s);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,c=>o>i.depth?c(t,n,i.nodeAfter,i.before(o),a,!0):c(t,n,i.node(o),i.before(o),a,!1)))return!0;return!1}function Vl(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let s=t.state.tr.setSelection(e);s.setMeta("pointer",!0),t.dispatch(s)}function tL(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),s=n.nodeAfter;return s&&s.isAtom&&Qe.isSelectable(s)?(Vl(t,new Qe(n)),!0):!1}function nL(t,e){if(e==-1)return!1;let n=t.state.selection,s,a;n instanceof Qe&&(s=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let c=o>i.depth?i.nodeAfter:i.node(o);if(Qe.isSelectable(c)){s&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?a=i.before(n.$from.depth):a=i.before(o);break}}return a!=null?(Vl(t,Qe.create(t.state.doc,a)),!0):!1}function sL(t,e,n,s,a){return L0(t,"handleClickOn",e,n,s)||t.someProp("handleClick",i=>i(t,e,s))||(a?nL(t,n):tL(t,n))}function rL(t,e,n,s){return L0(t,"handleDoubleClickOn",e,n,s)||t.someProp("handleDoubleClick",a=>a(t,e,s))}function aL(t,e,n,s){return L0(t,"handleTripleClickOn",e,n,s)||t.someProp("handleTripleClick",a=>a(t,e,s))||iL(t,n,s)}function iL(t,e,n){if(n.button!=0)return!1;let s=t.state.doc;if(e==-1)return s.inlineContent?(Vl(t,Xe.create(s,0,s.content.size)),!0):!1;let a=s.resolve(e);for(let i=a.depth+1;i>0;i--){let o=i>a.depth?a.nodeAfter:a.node(i),c=a.before(i);if(o.inlineContent)Vl(t,Xe.create(s,c+1,c+1+o.content.size));else if(Qe.isSelectable(o))Vl(t,Qe.create(s,c));else continue;return!0}}function _0(t){return Wh(t)}const f2=ur?"metaKey":"ctrlKey";Es.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let s=_0(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&eL(n,t.input.lastClick)&&!n[f2]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:a,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(Jf(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new oL(t,o,n,!!s)):(i=="doubleClick"?rL:aL)(t,o.pos,o.inside,n)?n.preventDefault():Ii(t,"pointer"))};class oL{constructor(e,n,s,a){this.view=e,this.pos=n,this.event=s,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[f2],this.allowDefault=s.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);i=f.parent,o=f.depth?f.before():0}const c=a?null:s.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(s.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||h instanceof Qe&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&fr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ii(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Wa(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Jf(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ii(this.view,"pointer"):sL(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ys&&this.mightDrag&&!this.mightDrag.node.isAtom||ns&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Vl(this.view,nt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ii(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ii(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Es.touchstart=t=>{t.input.lastTouch=Date.now(),_0(t),Ii(t,"pointer")};Es.touchmove=t=>{t.input.lastTouch=Date.now(),Ii(t,"pointer")};Es.contextmenu=t=>_0(t);function p2(t,e){return t.composing?!0:ys&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const lL=$a?5e3:-1;Ts.compositionstart=Ts.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Xe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)||ns&&US&&cL(t)))t.markCursor=t.state.storedMarks||n.marks(),Wh(t,!0),t.markCursor=null;else if(Wh(t,!e.selection.empty),fr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let s=t.domSelectionRange();for(let a=s.focusNode,i=s.focusOffset;a&&a.nodeType==1&&i!=0;){let o=i<0?a.lastChild:a.childNodes[i-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else a=o,i=-1}}t.input.composing=!0}m2(t,lL)};function cL(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let s=e.childNodes[n];return s.nodeType==1&&s.contentEditable=="false"}Ts.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,m2(t,20))};function m2(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Wh(t),e))}function g2(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=uL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function dL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=nD(e.focusNode,e.focusOffset),s=sD(e.focusNode,e.focusOffset);if(n&&s&&n!=s){let a=s.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||s==i)return i;if(!a||!a.isText(s.nodeValue))return s;if(t.input.compositionNode==s){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return s}}return n||s}function uL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Wh(t,e=!1){if(!($a&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),g2(t),e||t.docView&&t.docView.dirty){let n=R0(t),s=t.state.selection;return n&&!n.eq(s)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function hL(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),a=document.createRange();a.selectNodeContents(e),t.dom.blur(),s.removeAllRanges(),s.addRange(a),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Id=$s&&Di<15||Gl&&oD<604;Es.copy=Ts.cut=(t,e)=>{let n=e,s=t.state.selection,a=n.type=="cut";if(s.empty)return;let i=Id?null:n.clipboardData,o=s.content(),{dom:c,text:u}=O0(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):hL(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function fL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function pL(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,s=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),s.parentNode&&s.parentNode.removeChild(s),n?Rd(t,s.value,null,a,e):Rd(t,s.textContent,s.innerHTML,a,e)},50)}function Rd(t,e,n,s,a){let i=o2(t,e,n,s,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||Oe.empty)))return!0;if(!i)return!1;let o=fL(i),c=o?t.state.tr.replaceSelectionWith(o,s):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function x2(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ts.paste=(t,e)=>{let n=e;if(t.composing&&!$a)return;let s=Id?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;s&&Rd(t,x2(s),s.getData("text/html"),a,n)?n.preventDefault():pL(t,n)};class y2{constructor(e,n,s){this.slice=e,this.move=n,this.node=s}}const mL=ur?"altKey":"ctrlKey";function b2(t,e){let n=t.someProp("dragCopies",s=>!s(e));return n??!e[mL]}Es.dragstart=(t,e)=>{let n=e,s=t.input.mouseDown;if(s&&s.done(),!n.dataTransfer)return;let a=t.state.selection,i=a.empty?null:t.posAtCoords(Jf(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof Qe?a.to-1:a.to))){if(s&&s.mightDrag)o=Qe.create(t.state.doc,s.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=Qe.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=O0(t,c);(!n.dataTransfer.files.length||!ns||WS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Id?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Id||n.dataTransfer.setData("text/plain",h),t.dragging=new y2(f,b2(t,n),o)};Es.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ts.dragover=Ts.dragenter=(t,e)=>e.preventDefault();Ts.drop=(t,e)=>{try{gL(t,e,t.dragging)}finally{t.dragging=null}};function gL(t,e,n){if(!e.dataTransfer)return;let s=t.posAtCoords(Jf(e));if(!s)return;let a=t.state.doc.resolve(s.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=o2(t,x2(e.dataTransfer),Id?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&b2(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||Oe.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?jS(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:y}=n;y?y.replace(u):u.deleteSelection()}let h=u.mapping.map(c),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,i.content.firstChild):u.replaceRange(h,h,i),u.doc.eq(m))return;let g=u.doc.resolve(h);if(f&&Qe.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new Qe(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((N,j,v,k)=>y=k),u.setSelection(P0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Es.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Wa(t)},20))};Es.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Es.beforeinput=(t,e)=>{if(ns&&$a&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:s}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=s||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,wo(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in Ts)Es[t]=Ts[t];function Pd(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Uh{constructor(e,n){this.toDOM=e,this.spec=n||Po,this.side=this.spec.side||0}map(e,n,s,a){let{pos:i,deleted:o}=e.mapResult(n.from+a,this.side<0?-1:1);return o?null:new Ln(i-s,i-s,this)}valid(){return!0}eq(e){return this==e||e instanceof Uh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class _i{constructor(e,n){this.attrs=e,this.spec=n||Po}map(e,n,s,a){let i=e.map(n.from+a,this.spec.inclusiveStart?-1:1)-s,o=e.map(n.to+a,this.spec.inclusiveEnd?1:-1)-s;return i>=o?null:new Ln(i,o,this)}valid(e,n){return n.from=e&&(!i||i(c.spec))&&s.push(c.copy(c.from+a,c.to+a))}for(let o=0;oe){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,s,a+c,i)}}map(e,n,s){return this==ms||e.maps.length==0?this:this.mapInner(e,n,0,0,s||Po)}mapInner(e,n,s,a,i){let o;for(let c=0;c{let h=u+s,f;if(f=N2(n,c,h)){for(a||(a=this.children.slice());ic&&m.to=e){this.children[c]==e&&(s=this.children[c+2]);break}let i=e+1,o=i+n.content.size;for(let c=0;ci&&u.type instanceof _i){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,Po));return Si.from(s)}forChild(e,n){if(n.isLeaf)return Bt.empty;let s=[];for(let a=0;an instanceof Bt)?e:e.reduce((n,s)=>n.concat(s instanceof Bt?s:s.members),[]))}}forEachSet(e){for(let n=0;n{let v=j-N-(y-g);for(let k=0;kC+f-m)continue;let E=c[k]+f-m;y>=E?c[k+1]=g<=E?-2:-1:g>=f&&v&&(c[k]+=v,c[k+1]+=v)}m+=v}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=s.content.size){u=!0;continue}let g=n.map(t[h+1]+i,-1),y=g-a,{index:N,offset:j}=s.content.findIndex(m),v=s.maybeChild(N);if(v&&j==m&&j+v.nodeSize==y){let k=c[h+2].mapInner(n,v,f+1,t[h]+i+1,o);k!=ms?(c[h]=m,c[h+1]=y,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=yL(c,t,e,n,a,i,o),f=Kh(h,s,0,o);e=f.local;for(let m=0;mn&&o.to{let h=N2(t,c,u+n);if(h){i=!0;let f=Kh(h,c,n+u+1,s);f!=ms&&a.push(u,u+c.nodeSize,f)}});let o=v2(i?w2(t):t,-n).sort(Oo);for(let c=0;c0;)e++;t.splice(e,0,n)}function gg(t){let e=[];return t.someProp("decorations",n=>{let s=n(t.state);s&&s!=ms&&e.push(s)}),t.cursorWrapper&&e.push(Bt.create(t.state.doc,[t.cursorWrapper.deco])),Si.from(e)}const bL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vL=$s&&Di<=11;class NL{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class wL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new NL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let a=0;aa.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():ys&&e.composing&&s.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),vL&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,bL)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(nN(this.view)){if(this.suppressingSelectionUpdates)return Wa(this.view);if($s&&Di<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Bo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,s;for(let i=e.focusNode;i;i=ql(i))n.add(i);for(let i=e.anchorNode;i;i=ql(i))if(n.has(i)){s=i;break}let a=s&&this.view.docView.nearestDesc(s);if(a&&a.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let s=e.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&nN(e)&&!this.ignoreSelectionChange(s),i=-1,o=-1,c=!1,u=[];if(e.editable)for(let f=0;ff.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let f of u)if(f.nodeName=="BR"&&f.parentNode){let m=f.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&f.parentNode.removeChild(f)}}else if(fr&&u.length){let f=u.filter(m=>m.nodeName=="BR");if(f.length==2){let[m,g]=f;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of f){let y=g.parentNode;y&&y.nodeName=="LI"&&(!m||SL(e,m)!=y)&&g.remove()}}}let h=null;i<0&&a&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||a)&&(i>-1&&(e.docView.markDirty(i,o),jL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,CL(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||Wa(e),this.currentSelection.set(s))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fa;v--){let k=s.childNodes[v-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){i=v;break}if(!C||C.size)break}let m=t.state.doc,g=t.someProp("domParser")||Oi.fromSchema(t.state.schema),y=m.resolve(o),N=null,j=g.parse(s,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:a,to:i,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:TL,context:y});if(h&&h[0].pos!=null){let v=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=v),N={anchor:v+o,head:k+o}}return{doc:j,sel:N,from:o,to:c}}function TL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ys&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ys&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ML=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function AL(t,e,n,s,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let L=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,R=R0(t,L);if(R&&!t.state.selection.eq(R)){if(ns&&$a&&t.input.lastKeyCode===13&&Date.now()-100se(t,wo(13,"Enter"))))return;let O=t.state.tr.setSelection(R);L=="pointer"?O.setMeta("pointer",!0):L=="key"&&O.scrollIntoView(),i&&O.setMeta("composition",i),t.dispatch(O)}return}let o=t.state.doc.resolve(e),c=o.sharedDepth(n);e=o.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,h=EL(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||$a)&&a.some(L=>L.nodeType==1&&!ML.test(L.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",L=>L(t,wo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(s&&u instanceof Xe&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))N={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let L=pN(t,t.state.doc,h.sel);if(L&&!L.eq(t.state.selection)){let R=t.state.tr.setSelection(L);i&&R.setMeta("composition",i),t.dispatch(R)}}return}t.state.selection.fromt.state.selection.from&&N.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?N.start=t.state.selection.from:N.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(N.endB+=t.state.selection.to-N.endA,N.endA=t.state.selection.to)),$s&&Di<=11&&N.endB==N.start+1&&N.endA==N.start&&N.start>h.from&&h.doc.textBetween(N.start-h.from-1,N.start-h.from+1)=="  "&&(N.start--,N.endA--,N.endB--);let j=h.doc.resolveNoCache(N.start-h.from),v=h.doc.resolveNoCache(N.endB-h.from),k=f.resolve(N.start),C=j.sameParent(v)&&j.parent.inlineContent&&k.end()>=N.endA;if((Gl&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some(L=>L.nodeName=="DIV"||L.nodeName=="P"))||!C&&j.posL(t,wo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&RL(f,N.start,N.endA,j,v)&&t.someProp("handleKeyDown",L=>L(t,wo(8,"Backspace")))){$a&&ns&&t.domObserver.suppressSelectionUpdates();return}ns&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),$a&&!C&&j.start()!=v.start()&&v.parentOffset==0&&j.depth==v.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==N.endA&&(N.endB-=2,v=h.doc.resolveNoCache(N.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(L){return L(t,wo(13,"Enter"))})},20));let E=N.start,M=N.endA,P=L=>{let R=L||t.state.tr.replace(E,M,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let O=pN(t,R.doc,h.sel);O&&!(ns&&t.composing&&O.empty&&(N.start!=N.endB||t.input.lastChromeDeleteWa(t),20));let L=P(t.state.tr.delete(E,M)),R=f.resolve(N.start).marksAcross(f.resolve(N.endA));R&&L.ensureMarks(R),t.dispatch(L)}else if(N.endA==N.endB&&(H=IL(j.parent.content.cut(j.parentOffset,v.parentOffset),k.parent.content.cut(k.parentOffset,N.endA-k.start())))){let L=P(t.state.tr);H.type=="add"?L.addMark(E,M,H.mark):L.removeMark(E,M,H.mark),t.dispatch(L)}else if(j.parent.child(j.index()).isText&&j.index()==v.index()-(v.textOffset?0:1)){let L=j.parent.textBetween(j.parentOffset,v.parentOffset),R=()=>P(t.state.tr.insertText(L,E,M));t.someProp("handleTextInput",O=>O(t,E,M,L,R))||t.dispatch(R())}else t.dispatch(P());else t.dispatch(P())}function pN(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:P0(t,e.resolve(n.anchor),e.resolve(n.head))}function IL(t,e){let n=t.firstChild.marks,s=e.firstChild.marks,a=n,i=s,o,c,u;for(let f=0;ff.mark(c.addToSet(f.marks));else if(a.length==0&&i.length==1)c=i[0],o="remove",u=f=>f.mark(c.removeFromSet(f.marks));else return null;let h=[];for(let f=0;fn||xg(o,!0,!1)0&&(e||t.indexAfter(s)==t.node(s).childCount);)s--,a++,e=!1;if(n){let i=t.node(s).maybeChild(t.indexAfter(s));for(;i&&!i.isLeaf;)i=i.firstChild,a++}return a}function PL(t,e,n,s,a){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(a=="end"){let u=Math.max(0,i-Math.min(o,c));s-=o+u-i}if(o=o?i-s:0;i-=u,i&&i=c?i-s:0;i-=u,i&&i=56320&&e<=57343&&n>=55296&&n<=56319}class j2{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new JD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(vN),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=yN(this),xN(this),this.nodeViews=bN(this),this.docView=Y1(this.state.doc,gN(this),gg(this),this.dom,this),this.domObserver=new wL(this,(s,a,i,o)=>AL(this,s,a,i,o)),this.domObserver.start(),YD(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Nx(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vN),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let s in this._props)n[s]=this._props[s];n.state=this.state;for(let s in e)n[s]=e[s];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var s;let a=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(g2(this),o=!0),this.state=e;let c=a.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=bN(this);DL(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Nx(this),this.editable=yN(this),xN(this);let u=gg(this),h=gN(this),f=a.plugins!=e.plugins&&!a.doc.eq(e.doc)?"reset":e.scrollToSelection>a.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(a.selection))&&(o=!0);let g=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&dD(this);if(o){this.domObserver.stop();let y=m&&($s||ns)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&OL(a.selection,e.selection);if(m){let N=ns?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=dL(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=Y1(e.doc,h,u,this.dom,this)),N&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&OD(this))?Wa(this,y):(r2(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((s=this.dragging)===null||s===void 0)&&s.node&&!a.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,a),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&uD(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Qe){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&W1(this,n.getBoundingClientRect(),e)}else W1(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(i))==s.node&&(a=i)}this.dragging=new y2(e.slice,e.move,a<0?void 0:Qe.create(this.state.doc,a))}someProp(e,n){let s=this._props&&this._props[e],a;if(s!=null&&(a=n?n(s):s))return a;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return xD(this,e)}coordsAtPos(e,n=1){return YS(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,s=-1){let a=this.docView.posFromDOM(e,n,s);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(e,n){return wD(this,n||this.state,e)}pasteHTML(e,n){return Rd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Rd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return O0(this,e)}destroy(){this.docView&&(QD(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gg(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,eD())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ZD(this,e)}domSelectionRange(){let e=this.domSelection();return e?ys&&this.root.nodeType===11&&aD(this.dom.ownerDocument)==this.dom&&kL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}j2.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function gN(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let s in n)s=="class"?e.class+=" "+n[s]:s=="style"?e.style=(e.style?e.style+";":"")+n[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(n[s]))}),e.translate||(e.translate="no"),[Ln.node(0,t.state.doc.content.size,e)]}function xN(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ln.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function yN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function OL(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function bN(t){let e=Object.create(null);function n(s){for(let a in s)Object.prototype.hasOwnProperty.call(e,a)||(e[a]=s[a])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function DL(t,e){let n=0,s=0;for(let a in t){if(t[a]!=e[a])return!0;n++}for(let a in e)s++;return n!=s}function vN(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var $i={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},qh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},LL=typeof navigator<"u"&&/Mac/.test(navigator.platform),_L=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ts=0;ts<10;ts++)$i[48+ts]=$i[96+ts]=String(ts);for(var ts=1;ts<=24;ts++)$i[ts+111]="F"+ts;for(var ts=65;ts<=90;ts++)$i[ts]=String.fromCharCode(ts+32),qh[ts]=String.fromCharCode(ts);for(var yg in $i)qh.hasOwnProperty(yg)||(qh[yg]=$i[yg]);function zL(t){var e=LL&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||_L&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?qh:$i)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const FL=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),$L=typeof navigator<"u"&&/Win/.test(navigator.platform);function BL(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let s,a,i,o;for(let c=0;c{for(var n in e)WL(t,n,{get:e[n],enumerable:!0})};function Yf(t){const{state:e,transaction:n}=t;let{selection:s}=n,{doc:a}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return s},get doc(){return a},get tr(){return s=n.selection,a=n.doc,i=n.storedMarks,n}}}var Qf=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:s}=e,{tr:a}=n,i=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(i);return!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:s,state:a}=this,{view:i}=s,o=[],c=!!t,u=t||a.tr,h=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),o.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...N)=>{const j=this.buildProps(u,e),v=g(...N)(j);return o.push(v),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,s=!1,a=t||n.tr,i=this.buildProps(a,s);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...i,dispatch:void 0})])),chain:()=>this.createChain(a,s)}}buildProps(t,e=!0){const{rawCommands:n,editor:s,state:a}=this,{view:i}=s,o={tr:t,editor:s,view:i,state:Yf({state:a,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...h)=>u(...h)(o)]))}};return o}},k2={};B0(k2,{blur:()=>UL,clearContent:()=>KL,clearNodes:()=>qL,command:()=>GL,createParagraphNear:()=>JL,cut:()=>YL,deleteCurrentNode:()=>QL,deleteNode:()=>XL,deleteRange:()=>ZL,deleteSelection:()=>e8,enter:()=>t8,exitCode:()=>n8,extendMarkRange:()=>s8,first:()=>r8,focus:()=>i8,forEach:()=>o8,insertContent:()=>l8,insertContentAt:()=>u8,joinBackward:()=>p8,joinDown:()=>f8,joinForward:()=>m8,joinItemBackward:()=>g8,joinItemForward:()=>x8,joinTextblockBackward:()=>y8,joinTextblockForward:()=>b8,joinUp:()=>h8,keyboardShortcut:()=>N8,lift:()=>w8,liftEmptyBlock:()=>j8,liftListItem:()=>k8,newlineInCode:()=>S8,resetAttributes:()=>C8,scrollIntoView:()=>E8,selectAll:()=>T8,selectNodeBackward:()=>M8,selectNodeForward:()=>A8,selectParentNode:()=>I8,selectTextblockEnd:()=>R8,selectTextblockStart:()=>P8,setContent:()=>O8,setMark:()=>e6,setMeta:()=>t6,setNode:()=>n6,setNodeSelection:()=>s6,setTextDirection:()=>r6,setTextSelection:()=>a6,sinkListItem:()=>i6,splitBlock:()=>o6,splitListItem:()=>l6,toggleList:()=>c6,toggleMark:()=>d6,toggleNode:()=>u6,toggleWrap:()=>h6,undoInputRule:()=>f6,unsetAllMarks:()=>p6,unsetMark:()=>m6,unsetTextDirection:()=>g6,updateAttributes:()=>x6,wrapIn:()=>y6,wrapInList:()=>b6});var UL=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),KL=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),qL=()=>({state:t,tr:e,dispatch:n})=>{const{selection:s}=e,{ranges:a}=s;return n&&a.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(c,u)=>{if(c.type.isText)return;const{doc:h,mapping:f}=e,m=h.resolve(f.map(u)),g=h.resolve(f.map(u+c.nodeSize)),y=m.blockRange(g);if(!y)return;const N=ic(y);if(c.type.isTextblock){const{defaultType:j}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,j)}(N||N===0)&&e.lift(y,N)})}),!0},GL=t=>e=>t(e),JL=()=>({state:t,dispatch:e})=>FS(t,e),YL=(t,e)=>({editor:n,tr:s})=>{const{state:a}=n,i=a.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const o=s.mapping.map(e);return s.insert(o,i.content),s.setSelection(new Xe(s.doc.resolve(Math.max(o-1,0)))),!0},QL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,s=n.$anchor.node();if(s.content.size>0)return!1;const a=t.selection.$anchor;for(let i=a.depth;i>0;i-=1)if(a.node(i).type===s.type){if(e){const c=a.before(i),u=a.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1};function Mn(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var XL=t=>({tr:e,state:n,dispatch:s})=>{const a=Mn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===a){if(s){const u=i.before(o),h=i.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},ZL=t=>({tr:e,dispatch:n})=>{const{from:s,to:a}=t;return n&&e.delete(s,a),!0},e8=()=>({state:t,dispatch:e})=>C0(t,e),t8=()=>({commands:t})=>t.keyboardShortcut("Enter"),n8=()=>({state:t,dispatch:e})=>FO(t,e);function V0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Gh(t,e,n={strict:!0}){const s=Object.keys(e);return s.length?s.every(a=>n.strict?e[a]===t[a]:V0(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function S2(t,e,n={}){return t.find(s=>s.type===e&&Gh(Object.fromEntries(Object.keys(n).map(a=>[a,s.attrs[a]])),n))}function NN(t,e,n={}){return!!S2(t,e,n)}function H0(t,e,n){var s;if(!t||!e)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(f=>f.type===e))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(f=>f.type===e)||(n=n||((s=a.node.marks[0])==null?void 0:s.attrs),!S2([...a.node.marks],e,n)))return;let o=a.index,c=t.start()+a.offset,u=o+1,h=c+a.node.nodeSize;for(;o>0&&NN([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u({tr:n,state:s,dispatch:a})=>{const i=Ga(t,s.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=H0(u,i,e);if(m&&m.from<=h&&m.to>=f){const g=Xe.create(o,m.from,m.to);n.setSelection(g)}}return!0},r8=t=>e=>{const n=typeof t=="function"?t(e):t;for(let s=0;s({editor:n,view:s,tr:a,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Jh()||wN())&&s.dom.focus(),a8()&&!Jh()&&!wN()&&s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(s.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!C2(n.state.selection))return o(),!0;const c=E2(a.doc,t)||n.state.selection,u=n.state.selection.eq(c);return i&&(u||a.setSelection(c),u&&a.storedMarks&&a.setStoredMarks(a.storedMarks),o()),!0},o8=(t,e)=>n=>t.every((s,a)=>e(s,{...n,index:a})),l8=(t,e)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),T2=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const s=e[n];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?t.removeChild(s):s.nodeType===1&&T2(s)}return t};function ah(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return T2(n)}function Od(t,e,n){if(t instanceof Va||t instanceof Ne)return t;n={slice:!0,parseOptions:{},...n};const s=typeof t=="object"&&t!==null,a=typeof t=="string";if(s)try{if(Array.isArray(t)&&t.length>0)return Ne.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Od("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new hS({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:h=>(o=!0,c=typeof h=="string"?h:h.outerHTML,null)}]}})});if(n.slice?Oi.fromSchema(u).parseSlice(ah(t),n.parseOptions):Oi.fromSchema(u).parse(ah(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=Oi.fromSchema(e);return n.slice?i.parseSlice(ah(t),n.parseOptions).content:i.parse(ah(t),n.parseOptions)}return Od("",e,n)}function c8(t,e,n){const s=t.steps.length-1;if(s{o===0&&(o=f)}),t.setSelection(nt.near(t.doc.resolve(o),n))}var d8=t=>!("type"in t),u8=(t,e,n)=>({tr:s,dispatch:a,editor:i})=>{var o;if(a){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=v=>{i.emit("contentError",{editor:i,error:v,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Od(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(v){u(v)}try{c=Od(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(v){return u(v),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((d8(c)?c:[c]).forEach(v=>{v.check(),g=g?v.isText&&v.marks.length===0:!1,y=y?v.isBlock:!1}),f===m&&y){const{parent:v}=s.doc.resolve(f);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(f-=1,m+=1)}let j;if(g){if(Array.isArray(e))j=e.map(v=>v.text||"").join("");else if(e instanceof Ne){let v="";e.forEach(k=>{k.text&&(v+=k.text)}),j=v}else typeof e=="object"&&e&&e.text?j=e.text:j=e;s.insertText(j,f,m)}else{j=c;const v=s.doc.resolve(f),k=v.node(),C=v.parentOffset===0,E=k.isText||k.isTextblock,M=k.content.size>0;C&&E&&M&&(f=Math.max(0,f-1)),s.replaceWith(f,m,j)}n.updateSelection&&c8(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:f,text:j}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:f,text:j})}return!0},h8=()=>({state:t,dispatch:e})=>LO(t,e),f8=()=>({state:t,dispatch:e})=>_O(t,e),p8=()=>({state:t,dispatch:e})=>RS(t,e),m8=()=>({state:t,dispatch:e})=>LS(t,e),g8=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Wf(t.doc,t.selection.$from.pos,-1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},x8=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Wf(t.doc,t.selection.$from.pos,1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},y8=()=>({state:t,dispatch:e})=>OO(t,e),b8=()=>({state:t,dispatch:e})=>DO(t,e);function M2(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function v8(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let s,a,i,o;for(let c=0;c({editor:e,view:n,tr:s,dispatch:a})=>{const i=v8(t).split(/-(?!$)/),o=i.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),c=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",h=>h(n,c))});return u==null||u.steps.forEach(h=>{const f=h.map(s.mapping);f&&a&&s.maybeStep(f)}),!0};function Bi(t,e,n={}){const{from:s,to:a,empty:i}=t.selection,o=e?Mn(e,t.schema):null,c=[];t.doc.nodesBetween(s,a,(m,g)=>{if(m.isText)return;const y=Math.max(s,g),N=Math.min(a,g+m.nodeSize);c.push({node:m,from:y,to:N})});const u=a-s,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Gh(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var w8=(t,e={})=>({state:n,dispatch:s})=>{const a=Mn(t,n.schema);return Bi(n,a,e)?zO(n,s):!1},j8=()=>({state:t,dispatch:e})=>$S(t,e),k8=t=>({state:e,dispatch:n})=>{const s=Mn(t,e.schema);return YO(s)(e,n)},S8=()=>({state:t,dispatch:e})=>zS(t,e);function Xf(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function jN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((s,a)=>(n.includes(a)||(s[a]=t[a]),s),{})}var C8=(t,e)=>({tr:n,state:s,dispatch:a})=>{let i=null,o=null;const c=Xf(typeof t=="string"?t:t.name,s.schema);if(!c)return!1;c==="node"&&(i=Mn(t,s.schema)),c==="mark"&&(o=Ga(t,s.schema));let u=!1;return n.selection.ranges.forEach(h=>{s.doc.nodesBetween(h.$from.pos,h.$to.pos,(f,m)=>{i&&i===f.type&&(u=!0,a&&n.setNodeMarkup(m,void 0,jN(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&(u=!0,a&&n.addMark(m,m+f.nodeSize,o.create(jN(g.attrs,e))))})})}),u},E8=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),T8=()=>({tr:t,dispatch:e})=>{if(e){const n=new Qs(t.doc);t.setSelection(n)}return!0},M8=()=>({state:t,dispatch:e})=>OS(t,e),A8=()=>({state:t,dispatch:e})=>_S(t,e),I8=()=>({state:t,dispatch:e})=>VO(t,e),R8=()=>({state:t,dispatch:e})=>UO(t,e),P8=()=>({state:t,dispatch:e})=>WO(t,e);function wx(t,e,n={},s={}){return Od(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:s.errorOnInvalidContent})}var O8=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:s={}}={})=>({editor:a,tr:i,dispatch:o,commands:c})=>{const{doc:u}=i;if(s.preserveWhitespace!=="full"){const h=wx(t,a.schema,s,{errorOnInvalidContent:e??a.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:s,errorOnInvalidContent:e??a.options.enableContentCheck})};function A2(t,e){const n=Ga(e,t.schema),{from:s,to:a,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(s,a,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function I2(t,e){const n=new k0(t);return e.forEach(s=>{s.steps.forEach(a=>{n.step(a)})}),n}function D8(t){for(let e=0;e{n(a)&&s.push({node:a,pos:i})}),s}function R2(t,e){for(let n=t.depth;n>0;n-=1){const s=t.node(n);if(e(s))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:s}}}function Zf(t){return e=>R2(e.$from,t)}function Ge(t,e,n){return t.config[e]===void 0&&t.parent?Ge(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ge(t.parent,e,n):null}):t.config[e]}function W0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},s=Ge(e,"addExtensions",n);return s?[e,...W0(s())]:e}).flat(10)}function U0(t,e){const n=Jo.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function P2(t){return typeof t=="function"}function St(t,e=void 0,...n){return P2(t)?e?t.bind(e)(...n):t(...n):t}function _8(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Jl(t){const e=t.filter(a=>a.type==="extension"),n=t.filter(a=>a.type==="node"),s=t.filter(a=>a.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:s}}function O2(t){const e=[],{nodeExtensions:n,markExtensions:s}=Jl(t),a=[...n,...s],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(h=>h.name!=="text").map(h=>h.name),c=s.map(h=>h.name),u=[...o,...c];return t.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage,extensions:a},m=Ge(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let N;Array.isArray(y.types)?N=y.types:y.types==="*"?N=u:y.types==="nodes"?N=o:y.types==="marks"?N=c:N=[],N.forEach(j=>{Object.entries(y.attributes).forEach(([v,k])=>{e.push({type:j,name:v,attribute:{...i,...k}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=Ge(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,N])=>{const j={...i,...N};typeof(j==null?void 0:j.default)=="function"&&(j.default=j.default()),j!=null&&j.isRequired&&(j==null?void 0:j.default)===void 0&&delete j.default,e.push({type:h.name,name:y,attribute:j})})}),e}function z8(t){const e=[];let n="",s=!1,a=!1,i=0;const o=t.length;for(let c=0;c0){i-=1,n+=u;continue}if(u===";"&&i===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function kN(t){const e=[],n=z8(t||""),s=n.length;for(let a=0;a!!e).reduce((e,n)=>{const s={...e};return Object.entries(n).forEach(([a,i])=>{if(!s[a]){s[a]=i;return}if(a==="class"){const c=i?String(i).split(" "):[],u=s[a]?s[a].split(" "):[],h=c.filter(f=>!u.includes(f));s[a]=[...u,...h].join(" ")}else if(a==="style"){const c=new Map([...kN(s[a]),...kN(i)]);s[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else s[a]=i}),s},{})}function Dd(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,s)=>Et(n,s),{})}function F8(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function SN(t,e){return"style"in t?t:{...t,getAttrs:n=>{const s=t.getAttrs?t.getAttrs(n):t.attrs;if(s===!1)return!1;const a=e.reduce((i,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):F8(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...s,...a}}}}function CN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&_8(n)?!1:n!=null))}function EN(t){var e,n;const s={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(s.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(s.validate=t.attribute.validate),[t.name,s]}function $8(t,e){var n;const s=O2(t),{nodeExtensions:a,markExtensions:i}=Jl(t),o=(n=a.find(h=>Ge(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(a.map(h=>{const f=s.filter(k=>k.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((k,C)=>{const E=Ge(C,"extendNodeSchema",m);return{...k,...E?E(h):{}}},{}),y=CN({...g,content:St(Ge(h,"content",m)),marks:St(Ge(h,"marks",m)),group:St(Ge(h,"group",m)),inline:St(Ge(h,"inline",m)),atom:St(Ge(h,"atom",m)),selectable:St(Ge(h,"selectable",m)),draggable:St(Ge(h,"draggable",m)),code:St(Ge(h,"code",m)),whitespace:St(Ge(h,"whitespace",m)),linebreakReplacement:St(Ge(h,"linebreakReplacement",m)),defining:St(Ge(h,"defining",m)),isolating:St(Ge(h,"isolating",m)),attrs:Object.fromEntries(f.map(EN))}),N=St(Ge(h,"parseHTML",m));N&&(y.parseDOM=N.map(k=>SN(k,f)));const j=Ge(h,"renderHTML",m);j&&(y.toDOM=k=>j({node:k,HTMLAttributes:Dd(k,f)}));const v=Ge(h,"renderText",m);return v&&(y.toText=v),[h.name,y]})),u=Object.fromEntries(i.map(h=>{const f=s.filter(v=>v.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((v,k)=>{const C=Ge(k,"extendMarkSchema",m);return{...v,...C?C(h):{}}},{}),y=CN({...g,inclusive:St(Ge(h,"inclusive",m)),excludes:St(Ge(h,"excludes",m)),group:St(Ge(h,"group",m)),spanning:St(Ge(h,"spanning",m)),code:St(Ge(h,"code",m)),attrs:Object.fromEntries(f.map(EN))}),N=St(Ge(h,"parseHTML",m));N&&(y.parseDOM=N.map(v=>SN(v,f)));const j=Ge(h,"renderHTML",m);return j&&(y.toDOM=v=>j({mark:v,HTMLAttributes:Dd(v,f)})),[h.name,y]}));return new hS({topNode:o,nodes:c,marks:u})}function B8(t){const e=t.filter((n,s)=>t.indexOf(n)!==s);return Array.from(new Set(e))}function md(t){return t.sort((n,s)=>{const a=Ge(n,"priority")||100,i=Ge(s,"priority")||100;return a>i?-1:as.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),e}function L2(t,e,n){const{from:s,to:a}=e,{blockSeparator:i=` -`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(s,a,(u,h,f,m)=>{var g;u.isBlock&&h>s&&(c+=i);const y=o==null?void 0:o[u.type.name];if(y)return f&&(c+=y({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(g=u==null?void 0:u.text)==null?void 0:g.slice(Math.max(s,h)-h,a-h))}),c}function V8(t,e){const n={from:0,to:t.content.size};return L2(t,n,e)}function _2(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function H8(t,e){const n=Tn(e,t.schema),{from:s,to:a}=t.selection,i=[];t.doc.nodesBetween(s,a,c=>{i.push(c)});const o=i.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function z2(t,e){const n=Xf(typeof e=="string"?e:e.name,t.schema);return n==="node"?H8(t,e):n==="mark"?A2(t,e):{}}function W8(t,e=JSON.stringify){const n={};return t.filter(s=>{const a=e(s);return Object.prototype.hasOwnProperty.call(n,a)?!1:n[a]=!0})}function U8(t){const e=W8(t);return e.length===1?e:e.filter((n,s)=>!e.filter((i,o)=>o!==s).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function $2(t){const{mapping:e,steps:n}=t,s=[];return e.maps.forEach((a,i)=>{const o=[];if(a.ranges.length)a.forEach((c,u)=>{o.push({from:c,to:u})});else{const{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;o.push({from:c,to:u})}o.forEach(({from:c,to:u})=>{const h=e.slice(i).map(c,-1),f=e.slice(i).map(u),m=e.invert().map(h,-1),g=e.invert().map(f);s.push({oldRange:{from:m,to:g},newRange:{from:h,to:f}})})}),U8(s)}function K0(t,e,n){const s=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=H0(i,a.type);o&&s.push({mark:a,...o})}):n.nodesBetween(t,e,(a,i)=>{!a||(a==null?void 0:a.nodeSize)===void 0||s.push(...a.marks.map(o=>({from:i,to:i+a.nodeSize,mark:o})))}),s}var K8=(t,e,n,s=20)=>{const a=t.doc.resolve(n);let i=s,o=null;for(;i>0&&o===null;){const c=a.node(i);(c==null?void 0:c.type.name)===e?o=c:i-=1}return[o,i]};function Qc(t,e){return e.nodes[t]||e.marks[t]||null}function jh(t,e,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const a=t.find(i=>i.type===e&&i.name===s);return a?a.attribute.keepOnSplit:!1}))}var q8=(t,e=500)=>{let n="";const s=t.parentOffset;return t.parent.nodesBetween(Math.max(0,s-e),s,(a,i,o,c)=>{var u,h;const f=((h=(u=a.type.spec).toText)==null?void 0:h.call(u,{node:a,pos:i,parent:o,index:c}))||a.textContent||"%leaf%";n+=a.isAtom&&!a.isText?f:f.slice(0,Math.max(0,s-i))}),n};function jx(t,e,n={}){const{empty:s,ranges:a}=t.selection,i=e?qa(e,t.schema):null;if(s)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Gh(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:g})=>{const y=m.pos,N=g.pos;t.doc.nodesBetween(y,N,(j,v)=>{if(i&&j.inlineContent&&!j.type.allowsMarkType(i))return!1;if(!j.isText&&!j.marks.length)return;const k=Math.max(y,v),C=Math.min(N,v+j.nodeSize),E=C-k;o+=E,c.push(...j.marks.map(M=>({mark:M,from:k,to:C})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Gh(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),h=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,g)=>m+g.to-g.from,0);return(u>0?u+h:u)>=o}function G8(t,e,n={}){if(!e)return Bi(t,null,n)||jx(t,null,n);const s=Xf(e,t.schema);return s==="node"?Bi(t,e,n):s==="mark"?jx(t,e,n):!1}var J8=(t,e)=>{const{$from:n,$to:s,$anchor:a}=t.selection;if(e){const i=Zf(c=>c.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return a.pos+1===o.end()}return!(s.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function TN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function MN(t,e){const{nodeExtensions:n}=Jl(e),s=n.find(o=>o.name===t);if(!s)return!1;const a={name:s.name,options:s.options,storage:s.storage},i=kt(Ge(s,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function ep(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var s;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((s=t.text)!=null?s:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let a=!0;return t.content.forEach(i=>{a!==!1&&(ep(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function F2(t){return t instanceof Xe}var B2=class V2{constructor(e){this.position=e}static fromJSON(e){return new V2(e.position)}toJSON(){return{position:this.position}}};function Q8(t,e){const n=e.mapping.mapResult(t.position);return{position:new B2(n.pos),mapResult:n}}function X8(t){return new B2(t)}function Z8(t,e,n){var s;const{selection:a}=e;let i=null;if(C2(a)&&(i=a.$cursor),i){const c=(s=t.storedMarks)!=null?s:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(h=>h.type.excludes(n)))}const{ranges:o}=a;return o.some(({$from:c,$to:u})=>{let h=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(f,m,g)=>{if(h)return!1;if(f.isInline){const y=!g||g.type.allowsMarkType(n),N=!!n.isInSet(f.marks)||!f.marks.some(j=>j.type.excludes(n));h=y&&N}return!h}),h})}var e6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=qa(t,s.schema);if(a)if(o){const h=A2(s,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;s.doc.nodesBetween(f,m,(g,y)=>{const N=Math.max(y,f),j=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===u)?g.marks.forEach(k=>{u===k.type&&n.addMark(N,j,u.create({...k.attrs,...e}))}):n.addMark(N,j,u.create(e))})});return Z8(s,n,u)},t6=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),n6=(t,e={})=>({state:n,dispatch:s,chain:a})=>{const i=Tn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?a().command(({commands:c})=>B1(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>B1(i,{...o,...e})(c,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},s6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,a=Eo(t,0,s.content.size),i=Xe.create(s,a);e.setSelection(i)}return!0},r6=(t,e)=>({tr:n,state:s,dispatch:a})=>{const{selection:i}=s;let o,c;return typeof e=="number"?(o=e,c=e):e&&"from"in e&&"to"in e?(o=e.from,c=e.to):(o=i.from,c=i.to),a&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},a6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=Ze.atStart(s).from,c=Ze.atEnd(s).to,u=Eo(a,o,c),h=Eo(i,o,c),f=Ze.create(s,u,h);e.setSelection(f)}return!0},i6=t=>({state:e,dispatch:n})=>{const s=Tn(t,e.schema);return ZO(s)(e,n)};function AN(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const s=n.filter(a=>e==null?void 0:e.includes(a.type.name));t.tr.ensureMarks(s)}}var o6=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:s,editor:a})=>{const{selection:i,doc:o}=e,{$from:c,$to:u}=i,h=a.extensionManager.attributes,f=jh(h,c.node().type.name,c.node().attrs);if(i instanceof Xe&&i.node.isBlock)return!c.parentOffset||!Va(o,c.pos)?!1:(s&&(t&&AN(n,a.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,g=c.depth===0?void 0:D8(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,N=Va(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!N&&Va(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(N=!0,y=g?[{type:g,attrs:f}]:void 0),s){if(N&&(i instanceof Ze&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const j=e.mapping.map(c.before()),v=e.doc.resolve(j);c.node(-1).canReplaceWith(v.index(),v.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&AN(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},l6=(t,e={})=>({tr:n,state:s,dispatch:a,editor:i})=>{var o;const c=Tn(t,s.schema),{$from:u,$to:h}=s.selection,f=s.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;const m=u.node(-1);if(m.type!==c)return!1;const g=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(a){let k=Ne.empty;const C=u.index(-1)?1:u.index(-2)?2:3;for(let R=u.depth-C;R>=u.depth-3;R-=1)k=Ne.from(u.node(R).copy(k));const E=u.indexAfter(-1){if(L>-1)return!1;R.isTextblock&&R.content.size===0&&(L=O+1)}),L>-1&&n.setSelection(Ze.near(n.doc.resolve(L))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...jh(g,m.type.name,m.attrs),...e},j={...jh(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const v=y?[{type:c,attrs:N},{type:y,attrs:j}]:[{type:c,attrs:N}];if(!Va(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:C}=s,{splittableMarks:E}=i.extensionManager,M=C||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,v).scrollIntoView(),!M||!a)return!0;const P=M.filter(H=>E.includes(H.type.name));n.ensureMarks(P)}return!0},vg=(t,e)=>{const n=Zf(o=>o.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const a=t.doc.nodeAt(s);return n.node.type===(a==null?void 0:a.type)&&Gi(t.doc,n.pos)&&t.join(n.pos),!0},Ng=(t,e)=>{const n=Zf(o=>o.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const a=t.doc.nodeAt(s);return n.node.type===(a==null?void 0:a.type)&&Gi(t.doc,s)&&t.join(s),!0},c6=(t,e,n,s={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=a.extensionManager,y=Tn(t,o.schema),N=Tn(e,o.schema),{selection:j,storedMarks:v}=o,{$from:k,$to:C}=j,E=k.blockRange(C),M=v||j.$to.parentOffset&&j.$from.marks();if(!E)return!1;const P=Zf(H=>MN(H.type.name,m))(j);if(E.depth>=1&&P&&E.depth-P.depth<=1){if(P.node.type===y)return h.liftListItem(N);if(MN(P.node.type.name,m)&&y.validContent(P.node.content)&&c)return u().command(()=>(i.setNodeMarkup(P.pos,y),!0)).command(()=>vg(i,y)).command(()=>Ng(i,y)).run()}return!n||!M||!c?u().command(()=>f().wrapInList(y,s)?!0:h.clearNodes()).wrapInList(y,s).command(()=>vg(i,y)).command(()=>Ng(i,y)).run():u().command(()=>{const H=f().wrapInList(y,s),L=M.filter(R=>g.includes(R.type.name));return i.ensureMarks(L),H?!0:h.clearNodes()}).wrapInList(y,s).command(()=>vg(i,y)).command(()=>Ng(i,y)).run()},d6=(t,e={},n={})=>({state:s,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=qa(t,s.schema);return jx(s,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},u6=(t,e,n={})=>({state:s,commands:a})=>{const i=Tn(t,s.schema),o=Tn(e,s.schema),c=Bi(s,i,n);let u;return s.selection.$anchor.sameParent(s.selection.$head)&&(u=s.selection.$anchor.parent.attrs),c?a.setNode(o,u):a.setNode(i,{...u,...n})},h6=(t,e={})=>({state:n,commands:s})=>{const a=Tn(t,n.schema);return Bi(n,a,e)?s.lift(a):s.wrapIn(a,e)},f6=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let s=0;s=0;u-=1)o.step(c.steps[u].invert(c.docs[u]));if(i.text){const u=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,u))}else o.delete(i.from,i.to)}return!0}}return!1},p6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:s,ranges:a}=n;return s||e&&a.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},m6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=qa(t,s.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:g,to:y}=c;const N=(i=h.marks().find(v=>v.type===u))==null?void 0:i.attrs,j=H0(h,u,N);j&&(g=j.from,y=j.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},g6=t=>({tr:e,state:n,dispatch:s})=>{const{selection:a}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=a.from,o=a.to),s&&e.doc.nodesBetween(i,o,(c,u)=>{if(c.isText)return;const h={...c.attrs};delete h.dir,e.setNodeMarkup(u,void 0,h)}),!0},x6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{let i=null,o=null;const c=Xf(typeof t=="string"?t:t.name,s.schema);if(!c)return!1;c==="node"&&(i=Tn(t,s.schema)),c==="mark"&&(o=qa(t,s.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,N,j;n.selection.empty?s.doc.nodesBetween(f,m,(v,k)=>{i&&i===v.type&&(u=!0,N=Math.max(k,f),j=Math.min(k+v.nodeSize,m),g=k,y=v)}):s.doc.nodesBetween(f,m,(v,k)=>{k=f&&k<=m&&(i&&i===v.type&&(u=!0,a&&n.setNodeMarkup(k,void 0,{...v.attrs,...e})),o&&v.marks.length&&v.marks.forEach(C=>{if(o===C.type&&(u=!0,a)){const E=Math.max(k,f),M=Math.min(k+v.nodeSize,m);n.addMark(E,M,o.create({...C.attrs,...e}))}}))}),y&&(g!==void 0&&a&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(v=>{o===v.type&&a&&n.addMark(N,j,o.create({...v.attrs,...e}))}))}),u},y6=(t,e={})=>({state:n,dispatch:s})=>{const a=Tn(t,n.schema);return KO(a,e)(n,s)},b6=(t,e={})=>({state:n,dispatch:s})=>{const a=Tn(t,n.schema);return qO(a,e)(n,s)},v6=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(s=>s.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(s=>s!==e):delete this.callbacks[t]),this}once(t,e){const n=(...s)=>{this.off(t,n),e.apply(this,s)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},tp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},N6=(t,e)=>{if(V0(e))return e.exec(t);const n=e(t);if(!n)return null;const s=[n.text];return s.index=n.index,s.input=t,s.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),s.push(n.replaceWith)),s};function ih(t){var e;const{editor:n,from:s,to:a,text:i,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(s);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let f=!1;const m=q8(h)+i;return o.forEach(g=>{if(f)return;const y=N6(m,g.find);if(!y)return;const N=u.state.tr,j=Yf({state:u.state,transaction:N}),v={from:s-(y[0].length-i.length),to:a},{commands:k,chain:C,can:E}=new Qf({editor:n,state:j});g.handler({state:j,range:v,match:y,commands:k,chain:C,can:E})===null||!N.steps.length||(g.undoable&&N.setMeta(c,{transform:N,from:s,to:a,text:i}),u.dispatch(N),f=!0)}),f}function w6(t){const{editor:e,rules:n}=t,s=new Wt({state:{init(){return null},apply(a,i,o){const c=a.getMeta(s);if(c)return c;const u=a.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=U0(Ne.from(f),o.schema);const{from:m}=u,g=m+f.length;ih({editor:e,from:m,to:g,text:f,rules:n,plugin:s})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return ih({editor:e,from:i,to:o,text:c,rules:n,plugin:s})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&ih({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:s})}),!1)},handleKeyDown(a,i){if(i.key!=="Enter")return!1;const{$cursor:o}=a.state.selection;return o?ih({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:s}):!1}},isInputRules:!0});return s}function j6(t){return Object.prototype.toString.call(t).slice(8,-1)}function oh(t){return j6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function H2(t,e){const n={...t};return oh(t)&&oh(e)&&Object.keys(e).forEach(s=>{oh(e[s])&&oh(t[s])?n[s]=H2(t[s],e[s]):n[s]=e[s]}),n}var q0=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...kt(Ge(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...kt(Ge(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>H2(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Yo=class W2 extends q0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new W2(n)}static handleExit({editor:e,mark:n}){const{tr:s}=e.state,a=e.state.selection.$from;if(a.pos===a.end()){const o=a.marks();if(!!!o.find(h=>(h==null?void 0:h.type.name)===n.name))return!1;const u=o.find(h=>(h==null?void 0:h.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",a.pos),e.view.dispatch(s),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function k6(t){return typeof t=="number"}var S6=class{constructor(t){this.find=t.find,this.handler=t.handler}},C6=(t,e,n)=>{if(V0(e))return[...t.matchAll(e)];const s=e(t,n);return s?s.map(a=>{const i=[a.text];return i.index=a.index,i.input=t,i.data=a.data,a.replaceWith&&(a.text.includes(a.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(a.replaceWith)),i}):[]};function E6(t){const{editor:e,state:n,from:s,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Qf({editor:e,state:n}),m=[];return n.doc.nodesBetween(s,a,(y,N)=>{var j,v,k,C,E;if((v=(j=y.type)==null?void 0:j.spec)!=null&&v.code||!(y.isText||y.isTextblock||y.isInline))return;const M=(E=(C=(k=y.content)==null?void 0:k.size)!=null?C:y.nodeSize)!=null?E:0,P=Math.max(s,N),H=Math.min(a,N+M);if(P>=H)return;const L=y.isText?y.text||"":y.textBetween(P-N,H-N,void 0,"");C6(L,i.find,o).forEach(O=>{if(O.index===void 0)return;const ne=P+O.index+1,ie=ne+O[0].length,_={from:n.tr.mapping.map(ne),to:n.tr.mapping.map(ie)},ce=i.handler({state:n,range:_,match:O,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(ce)})}),m.every(y=>y!==null)}var lh=null,T6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function M6(t){const{editor:e,rules:n}=t;let s=null,a=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:f,from:m,to:g,rule:y,pasteEvt:N})=>{const j=f.tr,v=Yf({state:f,transaction:j});if(!(!E6({editor:e,state:v,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:N,dropEvent:c})||!j.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return n.map(f=>new Wt({view(m){const g=N=>{var j;s=(j=m.dom.parentElement)!=null&&j.contains(N.target)?m.dom.parentElement:null,s&&(lh=e)},y=()=>{lh&&(lh=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=s===m.dom.parentElement,c=g,!i){const y=lh;y!=null&&y.isEditable&&setTimeout(()=>{const N=y.state.selection;N&&y.commands.deleteRange({from:N.from,to:N.to})},10)}return!1},paste:(m,g)=>{var y;const N=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,a=!!(N!=null&&N.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const N=m[0],j=N.getMeta("uiEvent")==="paste"&&!a,v=N.getMeta("uiEvent")==="drop"&&!i,k=N.getMeta("applyPasteRules"),C=!!k;if(!j&&!v&&!C)return;if(C){let{text:P}=k;typeof P=="string"?P=P:P=U0(Ne.from(P),y.schema);const{from:H}=k,L=H+P.length,R=T6(P);return u({rule:f,state:y,from:H,to:{b:L},pasteEvt:R})}const E=g.doc.content.findDiffStart(y.doc.content),M=g.doc.content.findDiffEnd(y.doc.content);if(!(!k6(E)||!M||E===M.b))return u({rule:f,state:y,from:E,to:M,pasteEvt:o})}}))}var np=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=D2(t),this.schema=F8(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Qc(e.name,this.schema)},s=Ge(e,"addCommands",n);return s?{...t,...s()}:t},{})}get plugins(){const{editor:t}=this;return md([...this.extensions].reverse()).flatMap(s=>{const a={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:t,type:Qc(s.name,this.schema)},i=[],o=Ge(s,"addKeyboardShortcuts",a);let c={};if(s.type==="mark"&&Ge(s,"exitable",a)&&(c.ArrowRight=()=>Yo.handleExit({editor:t,mark:s})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,N])=>[y,()=>N({editor:t})]));c={...c,...g}}const u=HL(c);i.push(u);const h=Ge(s,"addInputRules",a);if(TN(s,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=w6({editor:t,rules:g}),N=Array.isArray(y)?y:[y];i.push(...N)}}const f=Ge(s,"addPasteRules",a);if(TN(s,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=M6({editor:t,rules:g});i.push(...y)}}const m=Ge(s,"addProseMirrorPlugins",a);if(m){const g=m();i.push(...g)}return i})}get attributes(){return O2(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Jl(this.extensions);return Object.fromEntries(e.filter(n=>!!Ge(n,"addNodeView")).map(n=>{const s=this.attributes.filter(u=>u.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Tn(n.name,this.schema)},i=Ge(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,g)=>{const y=Dd(u,s);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return md([...this.extensions].reverse()).reduceRight((s,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Qc(a.name,this.schema)},o=Ge(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:s})}:s},t)}transformPastedHTML(t){const{editor:e}=this;return md([...this.extensions]).reduce((s,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Qc(a.name,this.schema)},o=Ge(a,"transformPastedHTML",i);return o?(c,u)=>{const h=s(c,u);return o.call(i,h)}:s},t||(s=>s))}get markViews(){const{editor:t}=this,{markExtensions:e}=Jl(this.extensions);return Object.fromEntries(e.filter(n=>!!Ge(n,"addMarkView")).map(n=>{const s=this.attributes.filter(c=>c.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:qa(n.name,this.schema)},i=Ge(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Dd(c,s);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{W6(c,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Qc(e.name,this.schema)};e.type==="mark"&&((n=kt(Ge(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name);const a=Ge(e,"onBeforeCreate",s),i=Ge(e,"onCreate",s),o=Ge(e,"onUpdate",s),c=Ge(e,"onSelectionUpdate",s),u=Ge(e,"onTransaction",s),h=Ge(e,"onFocus",s),f=Ge(e,"onBlur",s),m=Ge(e,"onDestroy",s);a&&this.editor.on("beforeCreate",a),i&&this.editor.on("create",i),o&&this.editor.on("update",o),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),h&&this.editor.on("focus",h),f&&this.editor.on("blur",f),m&&this.editor.on("destroy",m)})}};np.resolve=D2;np.sort=md;np.flatten=W0;var A6={};B0(A6,{ClipboardTextSerializer:()=>K2,Commands:()=>q2,Delete:()=>G2,Drop:()=>J2,Editable:()=>Y2,FocusEvents:()=>X2,Keymap:()=>Z2,Paste:()=>eC,Tabindex:()=>tC,TextDirection:()=>nC,focusEventsPluginKey:()=>Q2});var gn=class U2 extends q0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new U2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},K2=gn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Wt({key:new nn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:s,selection:a}=e,{ranges:i}=a,o=Math.min(...i.map(f=>f.$from.pos)),c=Math.max(...i.map(f=>f.$to.pos)),u=_2(n);return L2(s,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),q2=gn.create({name:"commands",addCommands(){return{...k2}}}),G2=gn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,s,a;const i=()=>{var o,c,u,h;if((h=(u=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?h:t.getMeta("y-sync$"))return;const f=I2(t.before,[t,...e]);$2(f).forEach(y=>{f.mapping.mapResult(y.oldRange.from).deletedAfter&&f.mapping.mapResult(y.oldRange.to).deletedBefore&&f.before.nodesBetween(y.oldRange.from,y.oldRange.to,(N,j)=>{const v=j+N.nodeSize-2,k=y.oldRange.from<=j&&v<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:N,from:j,to:v,newFrom:f.mapping.map(j),newTo:f.mapping.map(v),deletedRange:y.oldRange,newRange:y.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,N)=>{var j,v;if(y instanceof Ar){const k=g.slice(N).map(y.from,-1),C=g.slice(N).map(y.to),E=g.invert().map(k,-1),M=g.invert().map(C),P=(j=f.doc.nodeAt(k-1))==null?void 0:j.marks.some(L=>L.eq(y.mark)),H=(v=f.doc.nodeAt(C))==null?void 0:v.marks.some(L=>L.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:E,to:M},newRange:{from:k,to:C},partial:!!(H||P),editor:this.editor,transaction:t,combinedTransform:f})}})};(a=(s=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:s.async)==null||a?setTimeout(i,0):i()}}),J2=gn.create({name:"drop",addProseMirrorPlugins(){return[new Wt({key:new nn("tiptapDrop"),props:{handleDrop:(t,e,n,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:s})}}})]}}),Y2=gn.create({name:"editable",addProseMirrorPlugins(){return[new Wt({key:new nn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Q2=new nn("focusEvents"),X2=gn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Wt({key:Q2,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const s=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,n)=>{t.isFocused=!1;const s=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}}),Z2=gn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos:g,parent:y}=m,N=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,j=N.parent.type.spec.isolating,v=m.pos-m.parentOffset,k=j&&N.parent.childCount===1?v===m.pos:rt.atStart(h).from===g;return!f||!y.type.isTextblock||y.textContent.length||!k||k&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},a={...s},i={...s,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Jh()||M2()?i:a},addProseMirrorPlugins(){return[new Wt({key:new nn("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(j=>j.getMeta("composition")))return;const s=t.some(j=>j.docChanged)&&!e.doc.eq(n.doc),a=t.some(j=>j.getMeta("preventClearDocument"));if(!s||a)return;const{empty:i,from:o,to:c}=e.selection,u=rt.atStart(e.doc).from,h=rt.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!ep(n.doc))return;const g=n.tr,y=Yf({state:n,transaction:g}),{commands:N}=new Qf({editor:this.editor,state:y});if(N.clearNodes(),!!g.steps.length)return g}})]}}),eC=gn.create({name:"paste",addProseMirrorPlugins(){return[new Wt({key:new nn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),tC=gn.create({name:"tabindex",addProseMirrorPlugins(){return[new Wt({key:new nn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),nC=gn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Jl(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Wt({key:new nn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),I6=class sd{constructor(e,n,s=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=s,this.resolvedPos=e,this.editor=n,this.currentNode=a}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,s=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,s=this.to-1}this.editor.commands.insertContentAt({from:n,to:s},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new sd(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new sd(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new sd(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,s)=>{const a=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+s+(i?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!a&&!o&&u.depth<=this.depth)return;const h=new sd(u,this.editor,a,a||o?n:null);a&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let s=null,a=this.parent;for(;a&&!s;){if(a.node.type.name===e)if(Object.keys(n).length>0){const i=a.node.attrs,o=Object.keys(n);for(let c=0;c{s&&a.length>0||(o.node.type.name===e&&i.every(u=>n[u]===o.node.attrs[u])&&a.push(o),!(s&&a.length>0)&&(a=a.concat(o.querySelectorAll(e,n,s))))}),a}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},R6=`.ProseMirror { +`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(s,a,(u,h,f,m)=>{var g;u.isBlock&&h>s&&(c+=i);const y=o==null?void 0:o[u.type.name];if(y)return f&&(c+=y({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(g=u==null?void 0:u.text)==null?void 0:g.slice(Math.max(s,h)-h,a-h))}),c}function V8(t,e){const n={from:0,to:t.content.size};return L2(t,n,e)}function _2(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function H8(t,e){const n=Mn(e,t.schema),{from:s,to:a}=t.selection,i=[];t.doc.nodesBetween(s,a,c=>{i.push(c)});const o=i.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function z2(t,e){const n=Xf(typeof e=="string"?e:e.name,t.schema);return n==="node"?H8(t,e):n==="mark"?A2(t,e):{}}function W8(t,e=JSON.stringify){const n={};return t.filter(s=>{const a=e(s);return Object.prototype.hasOwnProperty.call(n,a)?!1:n[a]=!0})}function U8(t){const e=W8(t);return e.length===1?e:e.filter((n,s)=>!e.filter((i,o)=>o!==s).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function F2(t){const{mapping:e,steps:n}=t,s=[];return e.maps.forEach((a,i)=>{const o=[];if(a.ranges.length)a.forEach((c,u)=>{o.push({from:c,to:u})});else{const{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;o.push({from:c,to:u})}o.forEach(({from:c,to:u})=>{const h=e.slice(i).map(c,-1),f=e.slice(i).map(u),m=e.invert().map(h,-1),g=e.invert().map(f);s.push({oldRange:{from:m,to:g},newRange:{from:h,to:f}})})}),U8(s)}function K0(t,e,n){const s=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=H0(i,a.type);o&&s.push({mark:a,...o})}):n.nodesBetween(t,e,(a,i)=>{!a||(a==null?void 0:a.nodeSize)===void 0||s.push(...a.marks.map(o=>({from:i,to:i+a.nodeSize,mark:o})))}),s}var K8=(t,e,n,s=20)=>{const a=t.doc.resolve(n);let i=s,o=null;for(;i>0&&o===null;){const c=a.node(i);(c==null?void 0:c.type.name)===e?o=c:i-=1}return[o,i]};function Qc(t,e){return e.nodes[t]||e.marks[t]||null}function jh(t,e,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const a=t.find(i=>i.type===e&&i.name===s);return a?a.attribute.keepOnSplit:!1}))}var q8=(t,e=500)=>{let n="";const s=t.parentOffset;return t.parent.nodesBetween(Math.max(0,s-e),s,(a,i,o,c)=>{var u,h;const f=((h=(u=a.type.spec).toText)==null?void 0:h.call(u,{node:a,pos:i,parent:o,index:c}))||a.textContent||"%leaf%";n+=a.isAtom&&!a.isText?f:f.slice(0,Math.max(0,s-i))}),n};function jx(t,e,n={}){const{empty:s,ranges:a}=t.selection,i=e?Ga(e,t.schema):null;if(s)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Gh(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:g})=>{const y=m.pos,N=g.pos;t.doc.nodesBetween(y,N,(j,v)=>{if(i&&j.inlineContent&&!j.type.allowsMarkType(i))return!1;if(!j.isText&&!j.marks.length)return;const k=Math.max(y,v),C=Math.min(N,v+j.nodeSize),E=C-k;o+=E,c.push(...j.marks.map(M=>({mark:M,from:k,to:C})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Gh(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),h=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,g)=>m+g.to-g.from,0);return(u>0?u+h:u)>=o}function G8(t,e,n={}){if(!e)return Bi(t,null,n)||jx(t,null,n);const s=Xf(e,t.schema);return s==="node"?Bi(t,e,n):s==="mark"?jx(t,e,n):!1}var J8=(t,e)=>{const{$from:n,$to:s,$anchor:a}=t.selection;if(e){const i=Zf(c=>c.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return a.pos+1===o.end()}return!(s.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function TN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function MN(t,e){const{nodeExtensions:n}=Jl(e),s=n.find(o=>o.name===t);if(!s)return!1;const a={name:s.name,options:s.options,storage:s.storage},i=St(Ge(s,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function ep(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var s;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((s=t.text)!=null?s:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let a=!0;return t.content.forEach(i=>{a!==!1&&(ep(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function $2(t){return t instanceof Qe}var B2=class V2{constructor(e){this.position=e}static fromJSON(e){return new V2(e.position)}toJSON(){return{position:this.position}}};function Q8(t,e){const n=e.mapping.mapResult(t.position);return{position:new B2(n.pos),mapResult:n}}function X8(t){return new B2(t)}function Z8(t,e,n){var s;const{selection:a}=e;let i=null;if(C2(a)&&(i=a.$cursor),i){const c=(s=t.storedMarks)!=null?s:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(h=>h.type.excludes(n)))}const{ranges:o}=a;return o.some(({$from:c,$to:u})=>{let h=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(f,m,g)=>{if(h)return!1;if(f.isInline){const y=!g||g.type.allowsMarkType(n),N=!!n.isInSet(f.marks)||!f.marks.some(j=>j.type.excludes(n));h=y&&N}return!h}),h})}var e6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=Ga(t,s.schema);if(a)if(o){const h=A2(s,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;s.doc.nodesBetween(f,m,(g,y)=>{const N=Math.max(y,f),j=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===u)?g.marks.forEach(k=>{u===k.type&&n.addMark(N,j,u.create({...k.attrs,...e}))}):n.addMark(N,j,u.create(e))})});return Z8(s,n,u)},t6=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),n6=(t,e={})=>({state:n,dispatch:s,chain:a})=>{const i=Mn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?a().command(({commands:c})=>B1(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>B1(i,{...o,...e})(c,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},s6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,a=Eo(t,0,s.content.size),i=Qe.create(s,a);e.setSelection(i)}return!0},r6=(t,e)=>({tr:n,state:s,dispatch:a})=>{const{selection:i}=s;let o,c;return typeof e=="number"?(o=e,c=e):e&&"from"in e&&"to"in e?(o=e.from,c=e.to):(o=i.from,c=i.to),a&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},a6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=Xe.atStart(s).from,c=Xe.atEnd(s).to,u=Eo(a,o,c),h=Eo(i,o,c),f=Xe.create(s,u,h);e.setSelection(f)}return!0},i6=t=>({state:e,dispatch:n})=>{const s=Mn(t,e.schema);return ZO(s)(e,n)};function AN(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const s=n.filter(a=>e==null?void 0:e.includes(a.type.name));t.tr.ensureMarks(s)}}var o6=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:s,editor:a})=>{const{selection:i,doc:o}=e,{$from:c,$to:u}=i,h=a.extensionManager.attributes,f=jh(h,c.node().type.name,c.node().attrs);if(i instanceof Qe&&i.node.isBlock)return!c.parentOffset||!Ha(o,c.pos)?!1:(s&&(t&&AN(n,a.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,g=c.depth===0?void 0:D8(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,N=Ha(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!N&&Ha(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(N=!0,y=g?[{type:g,attrs:f}]:void 0),s){if(N&&(i instanceof Xe&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const j=e.mapping.map(c.before()),v=e.doc.resolve(j);c.node(-1).canReplaceWith(v.index(),v.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&AN(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},l6=(t,e={})=>({tr:n,state:s,dispatch:a,editor:i})=>{var o;const c=Mn(t,s.schema),{$from:u,$to:h}=s.selection,f=s.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;const m=u.node(-1);if(m.type!==c)return!1;const g=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(a){let k=Ne.empty;const C=u.index(-1)?1:u.index(-2)?2:3;for(let R=u.depth-C;R>=u.depth-3;R-=1)k=Ne.from(u.node(R).copy(k));const E=u.indexAfter(-1){if(L>-1)return!1;R.isTextblock&&R.content.size===0&&(L=O+1)}),L>-1&&n.setSelection(Xe.near(n.doc.resolve(L))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...jh(g,m.type.name,m.attrs),...e},j={...jh(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const v=y?[{type:c,attrs:N},{type:y,attrs:j}]:[{type:c,attrs:N}];if(!Ha(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:C}=s,{splittableMarks:E}=i.extensionManager,M=C||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,v).scrollIntoView(),!M||!a)return!0;const P=M.filter(H=>E.includes(H.type.name));n.ensureMarks(P)}return!0},vg=(t,e)=>{const n=Zf(o=>o.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const a=t.doc.nodeAt(s);return n.node.type===(a==null?void 0:a.type)&&Gi(t.doc,n.pos)&&t.join(n.pos),!0},Ng=(t,e)=>{const n=Zf(o=>o.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const a=t.doc.nodeAt(s);return n.node.type===(a==null?void 0:a.type)&&Gi(t.doc,s)&&t.join(s),!0},c6=(t,e,n,s={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=a.extensionManager,y=Mn(t,o.schema),N=Mn(e,o.schema),{selection:j,storedMarks:v}=o,{$from:k,$to:C}=j,E=k.blockRange(C),M=v||j.$to.parentOffset&&j.$from.marks();if(!E)return!1;const P=Zf(H=>MN(H.type.name,m))(j);if(E.depth>=1&&P&&E.depth-P.depth<=1){if(P.node.type===y)return h.liftListItem(N);if(MN(P.node.type.name,m)&&y.validContent(P.node.content)&&c)return u().command(()=>(i.setNodeMarkup(P.pos,y),!0)).command(()=>vg(i,y)).command(()=>Ng(i,y)).run()}return!n||!M||!c?u().command(()=>f().wrapInList(y,s)?!0:h.clearNodes()).wrapInList(y,s).command(()=>vg(i,y)).command(()=>Ng(i,y)).run():u().command(()=>{const H=f().wrapInList(y,s),L=M.filter(R=>g.includes(R.type.name));return i.ensureMarks(L),H?!0:h.clearNodes()}).wrapInList(y,s).command(()=>vg(i,y)).command(()=>Ng(i,y)).run()},d6=(t,e={},n={})=>({state:s,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=Ga(t,s.schema);return jx(s,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},u6=(t,e,n={})=>({state:s,commands:a})=>{const i=Mn(t,s.schema),o=Mn(e,s.schema),c=Bi(s,i,n);let u;return s.selection.$anchor.sameParent(s.selection.$head)&&(u=s.selection.$anchor.parent.attrs),c?a.setNode(o,u):a.setNode(i,{...u,...n})},h6=(t,e={})=>({state:n,commands:s})=>{const a=Mn(t,n.schema);return Bi(n,a,e)?s.lift(a):s.wrapIn(a,e)},f6=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let s=0;s=0;u-=1)o.step(c.steps[u].invert(c.docs[u]));if(i.text){const u=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,u))}else o.delete(i.from,i.to)}return!0}}return!1},p6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:s,ranges:a}=n;return s||e&&a.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},m6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=Ga(t,s.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:g,to:y}=c;const N=(i=h.marks().find(v=>v.type===u))==null?void 0:i.attrs,j=H0(h,u,N);j&&(g=j.from,y=j.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},g6=t=>({tr:e,state:n,dispatch:s})=>{const{selection:a}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=a.from,o=a.to),s&&e.doc.nodesBetween(i,o,(c,u)=>{if(c.isText)return;const h={...c.attrs};delete h.dir,e.setNodeMarkup(u,void 0,h)}),!0},x6=(t,e={})=>({tr:n,state:s,dispatch:a})=>{let i=null,o=null;const c=Xf(typeof t=="string"?t:t.name,s.schema);if(!c)return!1;c==="node"&&(i=Mn(t,s.schema)),c==="mark"&&(o=Ga(t,s.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,N,j;n.selection.empty?s.doc.nodesBetween(f,m,(v,k)=>{i&&i===v.type&&(u=!0,N=Math.max(k,f),j=Math.min(k+v.nodeSize,m),g=k,y=v)}):s.doc.nodesBetween(f,m,(v,k)=>{k=f&&k<=m&&(i&&i===v.type&&(u=!0,a&&n.setNodeMarkup(k,void 0,{...v.attrs,...e})),o&&v.marks.length&&v.marks.forEach(C=>{if(o===C.type&&(u=!0,a)){const E=Math.max(k,f),M=Math.min(k+v.nodeSize,m);n.addMark(E,M,o.create({...C.attrs,...e}))}}))}),y&&(g!==void 0&&a&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(v=>{o===v.type&&a&&n.addMark(N,j,o.create({...v.attrs,...e}))}))}),u},y6=(t,e={})=>({state:n,dispatch:s})=>{const a=Mn(t,n.schema);return KO(a,e)(n,s)},b6=(t,e={})=>({state:n,dispatch:s})=>{const a=Mn(t,n.schema);return qO(a,e)(n,s)},v6=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(s=>s.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(s=>s!==e):delete this.callbacks[t]),this}once(t,e){const n=(...s)=>{this.off(t,n),e.apply(this,s)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},tp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},N6=(t,e)=>{if(V0(e))return e.exec(t);const n=e(t);if(!n)return null;const s=[n.text];return s.index=n.index,s.input=t,s.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),s.push(n.replaceWith)),s};function ih(t){var e;const{editor:n,from:s,to:a,text:i,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(s);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let f=!1;const m=q8(h)+i;return o.forEach(g=>{if(f)return;const y=N6(m,g.find);if(!y)return;const N=u.state.tr,j=Yf({state:u.state,transaction:N}),v={from:s-(y[0].length-i.length),to:a},{commands:k,chain:C,can:E}=new Qf({editor:n,state:j});g.handler({state:j,range:v,match:y,commands:k,chain:C,can:E})===null||!N.steps.length||(g.undoable&&N.setMeta(c,{transform:N,from:s,to:a,text:i}),u.dispatch(N),f=!0)}),f}function w6(t){const{editor:e,rules:n}=t,s=new qt({state:{init(){return null},apply(a,i,o){const c=a.getMeta(s);if(c)return c;const u=a.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=U0(Ne.from(f),o.schema);const{from:m}=u,g=m+f.length;ih({editor:e,from:m,to:g,text:f,rules:n,plugin:s})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return ih({editor:e,from:i,to:o,text:c,rules:n,plugin:s})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&ih({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:s})}),!1)},handleKeyDown(a,i){if(i.key!=="Enter")return!1;const{$cursor:o}=a.state.selection;return o?ih({editor:e,from:o.pos,to:o.pos,text:` +`,rules:n,plugin:s}):!1}},isInputRules:!0});return s}function j6(t){return Object.prototype.toString.call(t).slice(8,-1)}function oh(t){return j6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function H2(t,e){const n={...t};return oh(t)&&oh(e)&&Object.keys(e).forEach(s=>{oh(e[s])&&oh(t[s])?n[s]=H2(t[s],e[s]):n[s]=e[s]}),n}var q0=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...St(Ge(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...St(Ge(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>H2(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Yo=class W2 extends q0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new W2(n)}static handleExit({editor:e,mark:n}){const{tr:s}=e.state,a=e.state.selection.$from;if(a.pos===a.end()){const o=a.marks();if(!!!o.find(h=>(h==null?void 0:h.type.name)===n.name))return!1;const u=o.find(h=>(h==null?void 0:h.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",a.pos),e.view.dispatch(s),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function k6(t){return typeof t=="number"}var S6=class{constructor(t){this.find=t.find,this.handler=t.handler}},C6=(t,e,n)=>{if(V0(e))return[...t.matchAll(e)];const s=e(t,n);return s?s.map(a=>{const i=[a.text];return i.index=a.index,i.input=t,i.data=a.data,a.replaceWith&&(a.text.includes(a.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(a.replaceWith)),i}):[]};function E6(t){const{editor:e,state:n,from:s,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Qf({editor:e,state:n}),m=[];return n.doc.nodesBetween(s,a,(y,N)=>{var j,v,k,C,E;if((v=(j=y.type)==null?void 0:j.spec)!=null&&v.code||!(y.isText||y.isTextblock||y.isInline))return;const M=(E=(C=(k=y.content)==null?void 0:k.size)!=null?C:y.nodeSize)!=null?E:0,P=Math.max(s,N),H=Math.min(a,N+M);if(P>=H)return;const L=y.isText?y.text||"":y.textBetween(P-N,H-N,void 0,"");C6(L,i.find,o).forEach(O=>{if(O.index===void 0)return;const se=P+O.index+1,ie=se+O[0].length,z={from:n.tr.mapping.map(se),to:n.tr.mapping.map(ie)},ce=i.handler({state:n,range:z,match:O,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(ce)})}),m.every(y=>y!==null)}var lh=null,T6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function M6(t){const{editor:e,rules:n}=t;let s=null,a=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:f,from:m,to:g,rule:y,pasteEvt:N})=>{const j=f.tr,v=Yf({state:f,transaction:j});if(!(!E6({editor:e,state:v,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:N,dropEvent:c})||!j.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return n.map(f=>new qt({view(m){const g=N=>{var j;s=(j=m.dom.parentElement)!=null&&j.contains(N.target)?m.dom.parentElement:null,s&&(lh=e)},y=()=>{lh&&(lh=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=s===m.dom.parentElement,c=g,!i){const y=lh;y!=null&&y.isEditable&&setTimeout(()=>{const N=y.state.selection;N&&y.commands.deleteRange({from:N.from,to:N.to})},10)}return!1},paste:(m,g)=>{var y;const N=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,a=!!(N!=null&&N.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const N=m[0],j=N.getMeta("uiEvent")==="paste"&&!a,v=N.getMeta("uiEvent")==="drop"&&!i,k=N.getMeta("applyPasteRules"),C=!!k;if(!j&&!v&&!C)return;if(C){let{text:P}=k;typeof P=="string"?P=P:P=U0(Ne.from(P),y.schema);const{from:H}=k,L=H+P.length,R=T6(P);return u({rule:f,state:y,from:H,to:{b:L},pasteEvt:R})}const E=g.doc.content.findDiffStart(y.doc.content),M=g.doc.content.findDiffEnd(y.doc.content);if(!(!k6(E)||!M||E===M.b))return u({rule:f,state:y,from:E,to:M,pasteEvt:o})}}))}var np=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=D2(t),this.schema=$8(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Qc(e.name,this.schema)},s=Ge(e,"addCommands",n);return s?{...t,...s()}:t},{})}get plugins(){const{editor:t}=this;return md([...this.extensions].reverse()).flatMap(s=>{const a={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:t,type:Qc(s.name,this.schema)},i=[],o=Ge(s,"addKeyboardShortcuts",a);let c={};if(s.type==="mark"&&Ge(s,"exitable",a)&&(c.ArrowRight=()=>Yo.handleExit({editor:t,mark:s})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,N])=>[y,()=>N({editor:t})]));c={...c,...g}}const u=HL(c);i.push(u);const h=Ge(s,"addInputRules",a);if(TN(s,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=w6({editor:t,rules:g}),N=Array.isArray(y)?y:[y];i.push(...N)}}const f=Ge(s,"addPasteRules",a);if(TN(s,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=M6({editor:t,rules:g});i.push(...y)}}const m=Ge(s,"addProseMirrorPlugins",a);if(m){const g=m();i.push(...g)}return i})}get attributes(){return O2(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Jl(this.extensions);return Object.fromEntries(e.filter(n=>!!Ge(n,"addNodeView")).map(n=>{const s=this.attributes.filter(u=>u.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Mn(n.name,this.schema)},i=Ge(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,g)=>{const y=Dd(u,s);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return md([...this.extensions].reverse()).reduceRight((s,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Qc(a.name,this.schema)},o=Ge(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:s})}:s},t)}transformPastedHTML(t){const{editor:e}=this;return md([...this.extensions]).reduce((s,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Qc(a.name,this.schema)},o=Ge(a,"transformPastedHTML",i);return o?(c,u)=>{const h=s(c,u);return o.call(i,h)}:s},t||(s=>s))}get markViews(){const{editor:t}=this,{markExtensions:e}=Jl(this.extensions);return Object.fromEntries(e.filter(n=>!!Ge(n,"addMarkView")).map(n=>{const s=this.attributes.filter(c=>c.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ga(n.name,this.schema)},i=Ge(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Dd(c,s);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{W6(c,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Qc(e.name,this.schema)};e.type==="mark"&&((n=St(Ge(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name);const a=Ge(e,"onBeforeCreate",s),i=Ge(e,"onCreate",s),o=Ge(e,"onUpdate",s),c=Ge(e,"onSelectionUpdate",s),u=Ge(e,"onTransaction",s),h=Ge(e,"onFocus",s),f=Ge(e,"onBlur",s),m=Ge(e,"onDestroy",s);a&&this.editor.on("beforeCreate",a),i&&this.editor.on("create",i),o&&this.editor.on("update",o),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),h&&this.editor.on("focus",h),f&&this.editor.on("blur",f),m&&this.editor.on("destroy",m)})}};np.resolve=D2;np.sort=md;np.flatten=W0;var A6={};B0(A6,{ClipboardTextSerializer:()=>K2,Commands:()=>q2,Delete:()=>G2,Drop:()=>J2,Editable:()=>Y2,FocusEvents:()=>X2,Keymap:()=>Z2,Paste:()=>eC,Tabindex:()=>tC,TextDirection:()=>nC,focusEventsPluginKey:()=>Q2});var gn=class U2 extends q0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new U2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},K2=gn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new qt({key:new rn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:s,selection:a}=e,{ranges:i}=a,o=Math.min(...i.map(f=>f.$from.pos)),c=Math.max(...i.map(f=>f.$to.pos)),u=_2(n);return L2(s,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),q2=gn.create({name:"commands",addCommands(){return{...k2}}}),G2=gn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,s,a;const i=()=>{var o,c,u,h;if((h=(u=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?h:t.getMeta("y-sync$"))return;const f=I2(t.before,[t,...e]);F2(f).forEach(y=>{f.mapping.mapResult(y.oldRange.from).deletedAfter&&f.mapping.mapResult(y.oldRange.to).deletedBefore&&f.before.nodesBetween(y.oldRange.from,y.oldRange.to,(N,j)=>{const v=j+N.nodeSize-2,k=y.oldRange.from<=j&&v<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:N,from:j,to:v,newFrom:f.mapping.map(j),newTo:f.mapping.map(v),deletedRange:y.oldRange,newRange:y.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,N)=>{var j,v;if(y instanceof Ir){const k=g.slice(N).map(y.from,-1),C=g.slice(N).map(y.to),E=g.invert().map(k,-1),M=g.invert().map(C),P=(j=f.doc.nodeAt(k-1))==null?void 0:j.marks.some(L=>L.eq(y.mark)),H=(v=f.doc.nodeAt(C))==null?void 0:v.marks.some(L=>L.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:E,to:M},newRange:{from:k,to:C},partial:!!(H||P),editor:this.editor,transaction:t,combinedTransform:f})}})};(a=(s=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:s.async)==null||a?setTimeout(i,0):i()}}),J2=gn.create({name:"drop",addProseMirrorPlugins(){return[new qt({key:new rn("tiptapDrop"),props:{handleDrop:(t,e,n,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:s})}}})]}}),Y2=gn.create({name:"editable",addProseMirrorPlugins(){return[new qt({key:new rn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Q2=new rn("focusEvents"),X2=gn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new qt({key:Q2,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const s=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,n)=>{t.isFocused=!1;const s=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}}),Z2=gn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos:g,parent:y}=m,N=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,j=N.parent.type.spec.isolating,v=m.pos-m.parentOffset,k=j&&N.parent.childCount===1?v===m.pos:nt.atStart(h).from===g;return!f||!y.type.isTextblock||y.textContent.length||!k||k&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},a={...s},i={...s,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Jh()||M2()?i:a},addProseMirrorPlugins(){return[new qt({key:new rn("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(j=>j.getMeta("composition")))return;const s=t.some(j=>j.docChanged)&&!e.doc.eq(n.doc),a=t.some(j=>j.getMeta("preventClearDocument"));if(!s||a)return;const{empty:i,from:o,to:c}=e.selection,u=nt.atStart(e.doc).from,h=nt.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!ep(n.doc))return;const g=n.tr,y=Yf({state:n,transaction:g}),{commands:N}=new Qf({editor:this.editor,state:y});if(N.clearNodes(),!!g.steps.length)return g}})]}}),eC=gn.create({name:"paste",addProseMirrorPlugins(){return[new qt({key:new rn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),tC=gn.create({name:"tabindex",addProseMirrorPlugins(){return[new qt({key:new rn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),nC=gn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Jl(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new qt({key:new rn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),I6=class sd{constructor(e,n,s=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=s,this.resolvedPos=e,this.editor=n,this.currentNode=a}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,s=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,s=this.to-1}this.editor.commands.insertContentAt({from:n,to:s},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new sd(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new sd(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new sd(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,s)=>{const a=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+s+(i?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!a&&!o&&u.depth<=this.depth)return;const h=new sd(u,this.editor,a,a||o?n:null);a&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let s=null,a=this.parent;for(;a&&!s;){if(a.node.type.name===e)if(Object.keys(n).length>0){const i=a.node.attrs,o=Object.keys(n);for(let c=0;c{s&&a.length>0||(o.node.type.name===e&&i.every(u=>n[u]===o.node.attrs[u])&&a.push(o),!(s&&a.length>0)&&(a=a.concat(o.querySelectorAll(e,n,s))))}),a}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},R6=`.ProseMirror { position: relative; } @@ -684,7 +684,7 @@ img.ProseMirror-separator { display: block; }`;function P6(t,e,n){const s=document.querySelector("style[data-tiptap-style]");if(s!==null)return s;const a=document.createElement("style");return e&&a.setAttribute("nonce",e),a.setAttribute("data-tiptap-style",""),a.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(a),a}var O6=class extends v6{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Q8,createMappablePosition:X8},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:a,moved:i})=>this.options.onDrop(s,a,i)),this.on("paste",({event:s,slice:a})=>this.options.onPaste(s,a)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=E2(e,this.options.autofocus);this.editorState=zl.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=P6(R6,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=P2(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(a=>{const i=typeof a=="string"?`${a}$`:a.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}createExtensionManager(){var t,e;const s=[...this.options.enableCoreExtensions?[Y2,K2.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),q2,X2,Z2,tC,J2,eC,G2,nC.configure({direction:this.options.textDirection})].filter(a=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[a.name]!==!1:!0):[],...this.options.extensions].filter(a=>["extension","node","mark"].includes(a==null?void 0:a.type));this.extensionManager=new np(s,this)}createCommandManager(){this.commandManager=new Qf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=wx(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=wx(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,s=e.dispatchTransaction||this.dispatchTransaction.bind(this),a=n?this.extensionManager.dispatchTransaction(s):s,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new j2(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:a,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();const u=this.view.dom;u.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(h=>{var f;return(f=this.capturedTransaction)==null?void 0:f.step(h)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),s=!this.state.selection.eq(e.selection),a=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!a)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(h=>h.getMeta("focus")||h.getMeta("blur")),c=o==null?void 0:o.getMeta("focus"),u=o==null?void 0:o.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:o}),u&&this.emit("blur",{editor:this,event:u.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(h=>h.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return z2(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,s=typeof t=="string"?e:t;return G8(this.state,n,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return U0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` -`,textSerializers:n={}}=t||{};return V8(this.state.doc,{blockSeparator:e,textSerializers:{..._2(this.schema),...n}})}get isEmpty(){return ep(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new I6(e,this)}get $doc(){return this.$pos(0)}};function Yl(t){return new tp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=kt(t.getAttributes,void 0,s);if(a===!1||a===null)return null;const{tr:i}=e,o=s[s.length-1],c=s[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(K0(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(j=>j===t.type&&j!==y.mark.type)).filter(y=>y.to>h).length)return null;fn.from&&i.delete(n.from+u,h);const g=n.from+u+o.length;i.addMark(n.from+u,g,t.type.create(a||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function sC(t){return new tp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=kt(t.getAttributes,void 0,s)||{},{tr:i}=e,o=n.from;let c=n.to;const u=t.type.create(a);if(s[1]){const h=s[0].lastIndexOf(s[1]);let f=o+h;f>c?f=c:c=f+s[1].length;const m=s[0][s[0].length-1];i.insertText(m,o+s[0].length-1),i.replaceWith(f,c,u)}else if(s[0]){const h=t.type.isInline?o:o-1;i.insert(h,t.type.create(a)).delete(i.mapping.map(o),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function kx(t){return new tp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=e.doc.resolve(n.from),i=kt(t.getAttributes,void 0,s)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Ql(t){return new tp({find:t.find,handler:({state:e,range:n,match:s,chain:a})=>{const i=kt(t.getAttributes,void 0,s)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&j0(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,N=g||m.$to.parentOffset&&m.$from.marks();if(N){const j=N.filter(v=>y.includes(v.type.name));o.ensureMarks(j)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(m,i).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&Gi(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(s,f))&&o.join(n.from-1)},undoable:t.undoable})}var D6=t=>"touches"in t,L6=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,h=c.clientY-this.startY;this.handleResize(u,h)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const h=u.clientX-this.startX,f=u.clientY-this.startY;this.handleResize(h,f)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,s,a,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(s=t==null?void 0:t.options)!=null&&s.directions&&(this.directions=t.options.directions),(a=t.options)!=null&&a.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),s=e.includes("bottom"),a=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),s&&(t.style.bottom="0"),a&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,D6(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:s,height:a}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(s,a,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let s=this.startWidth,a=this.startHeight;const i=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return i?s=this.startWidth+e:o&&(s=this.startWidth-e),c?a=this.startHeight+n:u&&(a=this.startHeight-n),(t==="right"||t==="left")&&(s=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(a=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(s,a,t):{width:s,height:a}}applyConstraints(t,e,n){var s,a,i,o;if(!n){let h=Math.max(this.minSize.width,t),f=Math.max(this.minSize.height,e);return(s=this.maxSize)!=null&&s.width&&(h=Math.min(this.maxSize.width,h)),(a=this.maxSize)!=null&&a.height&&(f=Math.min(this.maxSize.height,f)),{width:h,height:f}}let c=t,u=e;return cthis.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,height:u}}applyAspectRatio(t,e,n){const s=n==="left"||n==="right",a=n==="top"||n==="bottom";return s?{width:t,height:t/this.aspectRatio}:a?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function _6(t,e){const{selection:n}=t,{$from:s}=n;if(n instanceof Xe){const i=s.index();return s.parent.canReplaceWith(i,i+1,e)}let a=s.depth;for(;a>=0;){const i=s.index(a);if(s.node(a).contentMatchAt(i).matchType(e))return!0;a-=1}return!1}function z6(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var $6={};B0($6,{createAtomBlockMarkdownSpec:()=>F6,createBlockMarkdownSpec:()=>B6,createInlineMarkdownSpec:()=>rC,parseAttributes:()=>G0,parseIndentedBlocks:()=>Sx,renderNestedMarkdownContent:()=>Y0,serializeAttributes:()=>J0});function G0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],s=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),a=s.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(a){const h=a.map(f=>f.trim().slice(1));e.class=h.join(" ")}const i=s.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(s.matchAll(o)).forEach(([,h,f])=>{var m;const g=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[h]=y.slice(1,-1))});const u=s.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function J0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(s=>e.push(`.${s}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,s])=>{n==="class"||n==="id"||(s===!0?e.push(n):s!==!1&&s!=null&&e.push(`${n}="${String(s)}"`))}),e.join(" ")}function F6(t){const{nodeName:e,name:n,parseAttributes:s=G0,serializeAttributes:a=J0,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{const g={...i,...f.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${u}(?:\\s|$)`,"m"),y=(m=f.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(f,m,g){const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),N=f.match(y);if(!N)return;const j=N[1]||"",v=s(j);if(!o.find(C=>!(C in v)))return{type:e,raw:N[0],attributes:v}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=a(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function B6(t){const{nodeName:e,name:n,getContent:s,parseAttributes:a=G0,serializeAttributes:i=J0,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const g={};return u.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(s){const j=s(m);y=typeof j=="string"?[{type:"text",text:j}]:j}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const N={...o,...m.attributes};return g.createNode(e,N,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),N=(g=m.match(y))==null?void 0:g.index;return N!==void 0?N:-1},tokenize(m,g,y){var N;const j=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=m.match(j);if(!v)return;const[k,C=""]=v,E=a(C);let M=1;const P=k.length;let H="";const L=/^:::([\w-]*)(\s.*)?/gm,R=m.slice(P);for(L.lastIndex=0;;){const O=L.exec(R);if(O===null)break;const ne=O.index,ie=O[1];if(!((N=O[2])!=null&&N.endsWith(":::"))){if(ie)M+=1;else if(M-=1,M===0){const _=R.slice(0,ne);H=_.trim();const ce=m.slice(0,P+ne+O[0].length);let pe=[];if(H)if(c==="block")for(pe=y.blockTokens(_),pe.forEach(z=>{z.text&&(!z.tokens||z.tokens.length===0)&&(z.tokens=y.inlineTokens(z.text))});pe.length>0;){const z=pe[pe.length-1];if(z.type==="paragraph"&&(!z.text||z.text.trim()===""))pe.pop();else break}else pe=y.inlineTokens(H);return{type:e,raw:ce,attributes:E,content:H,tokens:pe}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),N=i(y),j=N?` {${N}}`:"",v=g.renderChildren(m.content||[],` +`,textSerializers:n={}}=t||{};return V8(this.state.doc,{blockSeparator:e,textSerializers:{..._2(this.schema),...n}})}get isEmpty(){return ep(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new I6(e,this)}get $doc(){return this.$pos(0)}};function Yl(t){return new tp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=St(t.getAttributes,void 0,s);if(a===!1||a===null)return null;const{tr:i}=e,o=s[s.length-1],c=s[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(K0(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(j=>j===t.type&&j!==y.mark.type)).filter(y=>y.to>h).length)return null;fn.from&&i.delete(n.from+u,h);const g=n.from+u+o.length;i.addMark(n.from+u,g,t.type.create(a||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function sC(t){return new tp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=St(t.getAttributes,void 0,s)||{},{tr:i}=e,o=n.from;let c=n.to;const u=t.type.create(a);if(s[1]){const h=s[0].lastIndexOf(s[1]);let f=o+h;f>c?f=c:c=f+s[1].length;const m=s[0][s[0].length-1];i.insertText(m,o+s[0].length-1),i.replaceWith(f,c,u)}else if(s[0]){const h=t.type.isInline?o:o-1;i.insert(h,t.type.create(a)).delete(i.mapping.map(o),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function kx(t){return new tp({find:t.find,handler:({state:e,range:n,match:s})=>{const a=e.doc.resolve(n.from),i=St(t.getAttributes,void 0,s)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Ql(t){return new tp({find:t.find,handler:({state:e,range:n,match:s,chain:a})=>{const i=St(t.getAttributes,void 0,s)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&j0(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,N=g||m.$to.parentOffset&&m.$from.marks();if(N){const j=N.filter(v=>y.includes(v.type.name));o.ensureMarks(j)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(m,i).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&Gi(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(s,f))&&o.join(n.from-1)},undoable:t.undoable})}var D6=t=>"touches"in t,L6=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,h=c.clientY-this.startY;this.handleResize(u,h)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const h=u.clientX-this.startX,f=u.clientY-this.startY;this.handleResize(h,f)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,s,a,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(s=t==null?void 0:t.options)!=null&&s.directions&&(this.directions=t.options.directions),(a=t.options)!=null&&a.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),s=e.includes("bottom"),a=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),s&&(t.style.bottom="0"),a&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,D6(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:s,height:a}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(s,a,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let s=this.startWidth,a=this.startHeight;const i=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return i?s=this.startWidth+e:o&&(s=this.startWidth-e),c?a=this.startHeight+n:u&&(a=this.startHeight-n),(t==="right"||t==="left")&&(s=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(a=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(s,a,t):{width:s,height:a}}applyConstraints(t,e,n){var s,a,i,o;if(!n){let h=Math.max(this.minSize.width,t),f=Math.max(this.minSize.height,e);return(s=this.maxSize)!=null&&s.width&&(h=Math.min(this.maxSize.width,h)),(a=this.maxSize)!=null&&a.height&&(f=Math.min(this.maxSize.height,f)),{width:h,height:f}}let c=t,u=e;return cthis.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,height:u}}applyAspectRatio(t,e,n){const s=n==="left"||n==="right",a=n==="top"||n==="bottom";return s?{width:t,height:t/this.aspectRatio}:a?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function _6(t,e){const{selection:n}=t,{$from:s}=n;if(n instanceof Qe){const i=s.index();return s.parent.canReplaceWith(i,i+1,e)}let a=s.depth;for(;a>=0;){const i=s.index(a);if(s.node(a).contentMatchAt(i).matchType(e))return!0;a-=1}return!1}function z6(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var F6={};B0(F6,{createAtomBlockMarkdownSpec:()=>$6,createBlockMarkdownSpec:()=>B6,createInlineMarkdownSpec:()=>rC,parseAttributes:()=>G0,parseIndentedBlocks:()=>Sx,renderNestedMarkdownContent:()=>Y0,serializeAttributes:()=>J0});function G0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],s=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),a=s.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(a){const h=a.map(f=>f.trim().slice(1));e.class=h.join(" ")}const i=s.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(s.matchAll(o)).forEach(([,h,f])=>{var m;const g=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[h]=y.slice(1,-1))});const u=s.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function J0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(s=>e.push(`.${s}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,s])=>{n==="class"||n==="id"||(s===!0?e.push(n):s!==!1&&s!=null&&e.push(`${n}="${String(s)}"`))}),e.join(" ")}function $6(t){const{nodeName:e,name:n,parseAttributes:s=G0,serializeAttributes:a=J0,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{const g={...i,...f.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${u}(?:\\s|$)`,"m"),y=(m=f.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(f,m,g){const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),N=f.match(y);if(!N)return;const j=N[1]||"",v=s(j);if(!o.find(C=>!(C in v)))return{type:e,raw:N[0],attributes:v}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=a(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function B6(t){const{nodeName:e,name:n,getContent:s,parseAttributes:a=G0,serializeAttributes:i=J0,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const g={};return u.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(s){const j=s(m);y=typeof j=="string"?[{type:"text",text:j}]:j}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const N={...o,...m.attributes};return g.createNode(e,N,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),N=(g=m.match(y))==null?void 0:g.index;return N!==void 0?N:-1},tokenize(m,g,y){var N;const j=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=m.match(j);if(!v)return;const[k,C=""]=v,E=a(C);let M=1;const P=k.length;let H="";const L=/^:::([\w-]*)(\s.*)?/gm,R=m.slice(P);for(L.lastIndex=0;;){const O=L.exec(R);if(O===null)break;const se=O.index,ie=O[1];if(!((N=O[2])!=null&&N.endsWith(":::"))){if(ie)M+=1;else if(M-=1,M===0){const z=R.slice(0,se);H=z.trim();const ce=m.slice(0,P+se+O[0].length);let me=[];if(H)if(c==="block")for(me=y.blockTokens(z),me.forEach(_=>{_.text&&(!_.tokens||_.tokens.length===0)&&(_.tokens=y.inlineTokens(_.text))});me.length>0;){const _=me[me.length-1];if(_.type==="paragraph"&&(!_.text||_.text.trim()===""))me.pop();else break}else me=y.inlineTokens(H);return{type:e,raw:ce,attributes:E,content:H,tokens:me}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),N=i(y),j=N?` {${N}}`:"",v=g.renderChildren(m.content||[],` `);return`:::${h}${j} @@ -693,13 +693,13 @@ ${v} :::`}}}function V6(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let s=n.exec(t);for(;s!==null;){const[,a,i,o]=s;e[a]=i||o,s=n.exec(t)}return e}function H6(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function rC(t){const{nodeName:e,name:n,getContent:s,parseAttributes:a=V6,serializeAttributes:i=H6,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(N=>{const j=typeof N=="string"?N:N.name,v=typeof N=="string"?void 0:N.skipIfDefault;if(j in g){const k=g[j];if(v!==void 0&&k===v)return;y[j]=k}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const N={...o,...g.attributes};if(c)return y.createNode(e,N);const j=s?s(g):g.content||"";return j?y.createNode(e,N,[y.createTextNode(j)]):y.createNode(e,N,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),N=g.match(y),j=N==null?void 0:N.index;return j!==void 0?j:-1},tokenize(g,y,N){const j=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),v=g.match(j);if(!v)return;let k="",C="";if(c){const[,M]=v;C=M}else{const[,M,P]=v;C=M,k=P||""}const E=a(C.trim());return{type:e,raw:v[0],content:k.trim(),attributes:E}}},renderMarkdown:g=>{let y="";s?y=s(g):g.content&&g.content.length>0&&(y=g.content.filter(k=>k.type==="text").map(k=>k.text).join(""));const N=f(g.attrs||{}),j=i(N),v=j?` ${j}`:"";return c?`[${h}${v}]`:`[${h}${v}]${y}[/${h}]`}}}function Sx(t,e,n){var s,a,i,o;const c=t.split(` `),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f0)break;if(g.trim()===""){f+=1,h=`${h}${g} `;continue}else return}const N=e.extractItemData(y),{indentLevel:j,mainContent:v}=N;h=`${h}${g} -`;const k=[v];for(f+=1;fne.trim()!=="");if(L===-1)break;if((((a=(s=c[f+1+L].match(/^(\s*)/))==null?void 0:s[1])==null?void 0:a.length)||0)>j){k.push(P),h=`${h}${P} +`;const k=[v];for(f+=1;fse.trim()!=="");if(L===-1)break;if((((a=(s=c[f+1+L].match(/^(\s*)/))==null?void 0:s[1])==null?void 0:a.length)||0)>j){k.push(P),h=`${h}${P} `,f+=1;continue}else break}if((((o=(i=P.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>j)k.push(P),h=`${h}${P} `,f+=1;else break}let C;const E=k.slice(1);if(E.length>0){const P=E.map(H=>H.slice(j+m)).join(` `);P.trim()&&(e.customNestedParser?C=e.customNestedParser(P):C=n.blockTokens(P))}const M=e.createToken(N,C);u.push(M)}if(u.length!==0)return{items:u,raw:h}}function Y0(t,e,n,s){if(!t||!Array.isArray(t.content))return"";const a=typeof n=="function"?n(s):n,[i,...o]=t.content,c=e.renderChildren([i]),u=[`${a}${c}`];return o&&o.length>0&&o.forEach(h=>{const f=e.renderChildren([h]);if(f){const m=f.split(` `).map(g=>g?e.indent(g):"").join(` `);u.push(m)}}),u.join(` -`)}function W6(t,e,n={}){const{state:s}=e,{doc:a,tr:i}=s,o=t;a.descendants((c,u)=>{const h=i.mapping.map(u),f=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==o)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,y)}}),i.docChanged&&e.view.dispatch(i)}var Mn=class aC extends q0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new aC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Ho(t){return new S6({find:t.find,handler:({state:e,range:n,match:s,pasteEvent:a})=>{const i=kt(t.getAttributes,void 0,s,a);if(i===!1||i===null)return null;const{tr:o}=e,c=s[s.length-1],u=s[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),g=m+c.length;if(K0(n.from,n.to,e.doc).filter(N=>N.mark.type.excluded.find(v=>v===t.type&&v!==N.mark.type)).filter(N=>N.to>m).length)return null;gn.from&&o.delete(n.from+f,m),h=n.from+f+c.length,o.addMark(n.from+f,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:U6,getOwnPropertySymbols:K6}=Object,{hasOwnProperty:q6}=Object.prototype;function wg(t,e){return function(s,a,i){return t(s,a,i)&&e(s,a,i)}}function ch(t){return function(n,s,a){if(!n||!s||typeof n!="object"||typeof s!="object")return t(n,s,a);const{cache:i}=a,o=i.get(n),c=i.get(s);if(o&&c)return o===s&&c===n;i.set(n,s),i.set(s,n);const u=t(n,s,a);return i.delete(n),i.delete(s),u}}function G6(t){return t!=null?t[Symbol.toStringTag]:void 0}function IN(t){return U6(t).concat(K6(t))}const J6=Object.hasOwn||((t,e)=>q6.call(t,e));function Qo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Y6="__v",Q6="__o",X6="_owner",{getOwnPropertyDescriptor:RN,keys:PN}=Object;function Z6(t,e){return t.byteLength===e.byteLength&&Yh(new Uint8Array(t),new Uint8Array(e))}function e_(t,e,n){let s=t.length;if(e.length!==s)return!1;for(;s-- >0;)if(!n.equals(t[s],e[s],s,s,t,e,n))return!1;return!0}function t_(t,e){return t.byteLength===e.byteLength&&Yh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function n_(t,e){return Qo(t.getTime(),e.getTime())}function s_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function r_(t,e){return t===e}function ON(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const a=new Array(s),i=t.entries();let o,c,u=0;for(;(o=i.next())&&!o.done;){const h=e.entries();let f=!1,m=0;for(;(c=h.next())&&!c.done;){if(a[m]){m++;continue}const g=o.value,y=c.value;if(n.equals(g[0],y[0],u,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){f=a[m]=!0;break}m++}if(!f)return!1;u++}return!0}const a_=Qo;function i_(t,e,n){const s=PN(t);let a=s.length;if(PN(e).length!==a)return!1;for(;a-- >0;)if(!iC(t,e,n,s[a]))return!1;return!0}function Xc(t,e,n){const s=IN(t);let a=s.length;if(IN(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=s[a],!iC(t,e,n,i)||(o=RN(t,i),c=RN(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function o_(t,e){return Qo(t.valueOf(),e.valueOf())}function l_(t,e){return t.source===e.source&&t.flags===e.flags}function DN(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const a=new Array(s),i=t.values();let o,c;for(;(o=i.next())&&!o.done;){const u=e.values();let h=!1,f=0;for(;(c=u.next())&&!c.done;){if(!a[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=a[f]=!0;break}f++}if(!h)return!1}return!0}function Yh(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function c_(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function iC(t,e,n,s){return(s===X6||s===Q6||s===Y6)&&(t.$$typeof||e.$$typeof)?!0:J6(e,s)&&n.equals(t[s],e[s],s,s,t,e,n)}const d_="[object ArrayBuffer]",u_="[object Arguments]",h_="[object Boolean]",f_="[object DataView]",p_="[object Date]",m_="[object Error]",g_="[object Map]",x_="[object Number]",y_="[object Object]",b_="[object RegExp]",v_="[object Set]",N_="[object String]",w_={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},j_="[object URL]",k_=Object.prototype.toString;function S_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:s,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:N}){return function(v,k,C){if(v===k)return!0;if(v==null||k==null)return!1;const E=typeof v;if(E!==typeof k)return!1;if(E!=="object")return E==="number"?c(v,k,C):E==="function"?i(v,k,C):!1;const M=v.constructor;if(M!==k.constructor)return!1;if(M===Object)return u(v,k,C);if(Array.isArray(v))return e(v,k,C);if(M===Date)return s(v,k,C);if(M===RegExp)return f(v,k,C);if(M===Map)return o(v,k,C);if(M===Set)return m(v,k,C);const P=k_.call(v);if(P===p_)return s(v,k,C);if(P===b_)return f(v,k,C);if(P===g_)return o(v,k,C);if(P===v_)return m(v,k,C);if(P===y_)return typeof v.then!="function"&&typeof k.then!="function"&&u(v,k,C);if(P===j_)return y(v,k,C);if(P===m_)return a(v,k,C);if(P===u_)return u(v,k,C);if(w_[P])return g(v,k,C);if(P===d_)return t(v,k,C);if(P===f_)return n(v,k,C);if(P===h_||P===x_||P===N_)return h(v,k,C);if(N){let H=N[P];if(!H){const L=G6(v);L&&(H=N[L])}if(H)return H(v,k,C)}return!1}}function C_({circular:t,createCustomConfig:e,strict:n}){let s={areArrayBuffersEqual:Z6,areArraysEqual:n?Xc:e_,areDataViewsEqual:t_,areDatesEqual:n_,areErrorsEqual:s_,areFunctionsEqual:r_,areMapsEqual:n?wg(ON,Xc):ON,areNumbersEqual:a_,areObjectsEqual:n?Xc:i_,arePrimitiveWrappersEqual:o_,areRegExpsEqual:l_,areSetsEqual:n?wg(DN,Xc):DN,areTypedArraysEqual:n?wg(Yh,Xc):Yh,areUrlsEqual:c_,unknownTagComparators:void 0};if(e&&(s=Object.assign({},s,e(s))),t){const a=ch(s.areArraysEqual),i=ch(s.areMapsEqual),o=ch(s.areObjectsEqual),c=ch(s.areSetsEqual);s=Object.assign({},s,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return s}function E_(t){return function(e,n,s,a,i,o,c){return t(e,n,c)}}function T_({circular:t,comparator:e,createState:n,equals:s,strict:a}){if(n)return function(c,u){const{cache:h=t?new WeakMap:void 0,meta:f}=n();return e(c,u,{cache:h,equals:s,meta:f,strict:a})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:s,meta:void 0,strict:a})};const i={cache:void 0,equals:s,meta:void 0,strict:a};return function(c,u){return e(c,u,i)}}const M_=Yi();Yi({strict:!0});Yi({circular:!0});Yi({circular:!0,strict:!0});Yi({createInternalComparator:()=>Qo});Yi({strict:!0,createInternalComparator:()=>Qo});Yi({circular:!0,createInternalComparator:()=>Qo});Yi({circular:!0,createInternalComparator:()=>Qo,strict:!0});function Yi(t={}){const{circular:e=!1,createInternalComparator:n,createState:s,strict:a=!1}=t,i=C_(t),o=S_(i),c=n?n(o):E_(o);return T_({circular:e,comparator:o,createState:s,equals:c,strict:a})}var jg={exports:{}},kg={};/** +`)}function W6(t,e,n={}){const{state:s}=e,{doc:a,tr:i}=s,o=t;a.descendants((c,u)=>{const h=i.mapping.map(u),f=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==o)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,y)}}),i.docChanged&&e.view.dispatch(i)}var An=class aC extends q0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new aC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Ho(t){return new S6({find:t.find,handler:({state:e,range:n,match:s,pasteEvent:a})=>{const i=St(t.getAttributes,void 0,s,a);if(i===!1||i===null)return null;const{tr:o}=e,c=s[s.length-1],u=s[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),g=m+c.length;if(K0(n.from,n.to,e.doc).filter(N=>N.mark.type.excluded.find(v=>v===t.type&&v!==N.mark.type)).filter(N=>N.to>m).length)return null;gn.from&&o.delete(n.from+f,m),h=n.from+f+c.length,o.addMark(n.from+f,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:U6,getOwnPropertySymbols:K6}=Object,{hasOwnProperty:q6}=Object.prototype;function wg(t,e){return function(s,a,i){return t(s,a,i)&&e(s,a,i)}}function ch(t){return function(n,s,a){if(!n||!s||typeof n!="object"||typeof s!="object")return t(n,s,a);const{cache:i}=a,o=i.get(n),c=i.get(s);if(o&&c)return o===s&&c===n;i.set(n,s),i.set(s,n);const u=t(n,s,a);return i.delete(n),i.delete(s),u}}function G6(t){return t!=null?t[Symbol.toStringTag]:void 0}function IN(t){return U6(t).concat(K6(t))}const J6=Object.hasOwn||((t,e)=>q6.call(t,e));function Qo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Y6="__v",Q6="__o",X6="_owner",{getOwnPropertyDescriptor:RN,keys:PN}=Object;function Z6(t,e){return t.byteLength===e.byteLength&&Yh(new Uint8Array(t),new Uint8Array(e))}function e_(t,e,n){let s=t.length;if(e.length!==s)return!1;for(;s-- >0;)if(!n.equals(t[s],e[s],s,s,t,e,n))return!1;return!0}function t_(t,e){return t.byteLength===e.byteLength&&Yh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function n_(t,e){return Qo(t.getTime(),e.getTime())}function s_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function r_(t,e){return t===e}function ON(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const a=new Array(s),i=t.entries();let o,c,u=0;for(;(o=i.next())&&!o.done;){const h=e.entries();let f=!1,m=0;for(;(c=h.next())&&!c.done;){if(a[m]){m++;continue}const g=o.value,y=c.value;if(n.equals(g[0],y[0],u,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){f=a[m]=!0;break}m++}if(!f)return!1;u++}return!0}const a_=Qo;function i_(t,e,n){const s=PN(t);let a=s.length;if(PN(e).length!==a)return!1;for(;a-- >0;)if(!iC(t,e,n,s[a]))return!1;return!0}function Xc(t,e,n){const s=IN(t);let a=s.length;if(IN(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=s[a],!iC(t,e,n,i)||(o=RN(t,i),c=RN(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function o_(t,e){return Qo(t.valueOf(),e.valueOf())}function l_(t,e){return t.source===e.source&&t.flags===e.flags}function DN(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const a=new Array(s),i=t.values();let o,c;for(;(o=i.next())&&!o.done;){const u=e.values();let h=!1,f=0;for(;(c=u.next())&&!c.done;){if(!a[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=a[f]=!0;break}f++}if(!h)return!1}return!0}function Yh(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function c_(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function iC(t,e,n,s){return(s===X6||s===Q6||s===Y6)&&(t.$$typeof||e.$$typeof)?!0:J6(e,s)&&n.equals(t[s],e[s],s,s,t,e,n)}const d_="[object ArrayBuffer]",u_="[object Arguments]",h_="[object Boolean]",f_="[object DataView]",p_="[object Date]",m_="[object Error]",g_="[object Map]",x_="[object Number]",y_="[object Object]",b_="[object RegExp]",v_="[object Set]",N_="[object String]",w_={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},j_="[object URL]",k_=Object.prototype.toString;function S_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:s,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:N}){return function(v,k,C){if(v===k)return!0;if(v==null||k==null)return!1;const E=typeof v;if(E!==typeof k)return!1;if(E!=="object")return E==="number"?c(v,k,C):E==="function"?i(v,k,C):!1;const M=v.constructor;if(M!==k.constructor)return!1;if(M===Object)return u(v,k,C);if(Array.isArray(v))return e(v,k,C);if(M===Date)return s(v,k,C);if(M===RegExp)return f(v,k,C);if(M===Map)return o(v,k,C);if(M===Set)return m(v,k,C);const P=k_.call(v);if(P===p_)return s(v,k,C);if(P===b_)return f(v,k,C);if(P===g_)return o(v,k,C);if(P===v_)return m(v,k,C);if(P===y_)return typeof v.then!="function"&&typeof k.then!="function"&&u(v,k,C);if(P===j_)return y(v,k,C);if(P===m_)return a(v,k,C);if(P===u_)return u(v,k,C);if(w_[P])return g(v,k,C);if(P===d_)return t(v,k,C);if(P===f_)return n(v,k,C);if(P===h_||P===x_||P===N_)return h(v,k,C);if(N){let H=N[P];if(!H){const L=G6(v);L&&(H=N[L])}if(H)return H(v,k,C)}return!1}}function C_({circular:t,createCustomConfig:e,strict:n}){let s={areArrayBuffersEqual:Z6,areArraysEqual:n?Xc:e_,areDataViewsEqual:t_,areDatesEqual:n_,areErrorsEqual:s_,areFunctionsEqual:r_,areMapsEqual:n?wg(ON,Xc):ON,areNumbersEqual:a_,areObjectsEqual:n?Xc:i_,arePrimitiveWrappersEqual:o_,areRegExpsEqual:l_,areSetsEqual:n?wg(DN,Xc):DN,areTypedArraysEqual:n?wg(Yh,Xc):Yh,areUrlsEqual:c_,unknownTagComparators:void 0};if(e&&(s=Object.assign({},s,e(s))),t){const a=ch(s.areArraysEqual),i=ch(s.areMapsEqual),o=ch(s.areObjectsEqual),c=ch(s.areSetsEqual);s=Object.assign({},s,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return s}function E_(t){return function(e,n,s,a,i,o,c){return t(e,n,c)}}function T_({circular:t,comparator:e,createState:n,equals:s,strict:a}){if(n)return function(c,u){const{cache:h=t?new WeakMap:void 0,meta:f}=n();return e(c,u,{cache:h,equals:s,meta:f,strict:a})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:s,meta:void 0,strict:a})};const i={cache:void 0,equals:s,meta:void 0,strict:a};return function(c,u){return e(c,u,i)}}const M_=Yi();Yi({strict:!0});Yi({circular:!0});Yi({circular:!0,strict:!0});Yi({createInternalComparator:()=>Qo});Yi({strict:!0,createInternalComparator:()=>Qo});Yi({circular:!0,createInternalComparator:()=>Qo});Yi({circular:!0,createInternalComparator:()=>Qo,strict:!0});function Yi(t={}){const{circular:e=!1,createInternalComparator:n,createState:s,strict:a=!1}=t,i=C_(t),o=S_(i),c=n?n(o):E_(o);return T_({circular:e,comparator:o,createState:s,equals:c,strict:a})}var jg={exports:{}},kg={};/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -707,11 +707,11 @@ ${v} * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var LN;function A_(){if(LN)return kg;LN=1;var t=Fd(),e=Jk();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:n,a=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return kg.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var N=i(null);if(N.current===null){var j={hasValue:!1,value:null};N.current=j}else j=N.current;N=c(function(){function k(H){if(!C){if(C=!0,E=H,H=g(H),y!==void 0&&j.hasValue){var L=j.value;if(y(L,H))return M=L}return M=H}if(L=M,s(E,H))return L;var R=g(H);return y!==void 0&&y(L,R)?(E=H,L):(E=H,M=R)}var C=!1,E,M,P=m===void 0?null:m;return[function(){return k(f())},P===null?void 0:function(){return k(P())}]},[f,m,g,y]);var v=a(h,N[0],N[1]);return o(function(){j.hasValue=!0,j.value=v},[v]),u(v),v},kg}var _N;function I_(){return _N||(_N=1,jg.exports=A_()),jg.exports}var R_=I_(),P_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},O_=({contentComponent:t})=>{const e=Yk.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return r.jsx(r.Fragment,{children:Object.values(e)})};function D_(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,s){e={...e,[n]:Uw.createPortal(s.reactElement,s.element,n)},t.forEach(a=>a())},removeRenderer(n){const s={...e};delete s[n],e=s,t.forEach(a=>a())}}}var L_=class extends ks.Component{constructor(t){var e;super(t),this.editorContentRef=ks.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=D_(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(s=>s.hasContentComponentInitialized?s:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:P_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&r.jsx(O_,{contentComponent:t.contentComponent})]})}},__=b.forwardRef((t,e)=>{const n=ks.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ks.createElement(L_,{key:n,innerRef:e,...t})}),oC=ks.memo(__),z_=typeof window<"u"?b.useLayoutEffect:b.useEffect,$_=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function F_(t){var e;const[n]=b.useState(()=>new $_(t.editor)),s=R_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:M_);return z_(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(s),s}var B_=!1,Cx=typeof window>"u",V_=Cx||!!(typeof window<"u"&&window.next),H_=class lC{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Cx||V_?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...s)=>{var a,i;return(i=(a=this.options.current).onBeforeCreate)==null?void 0:i.call(a,...s)},onBlur:(...s)=>{var a,i;return(i=(a=this.options.current).onBlur)==null?void 0:i.call(a,...s)},onCreate:(...s)=>{var a,i;return(i=(a=this.options.current).onCreate)==null?void 0:i.call(a,...s)},onDestroy:(...s)=>{var a,i;return(i=(a=this.options.current).onDestroy)==null?void 0:i.call(a,...s)},onFocus:(...s)=>{var a,i;return(i=(a=this.options.current).onFocus)==null?void 0:i.call(a,...s)},onSelectionUpdate:(...s)=>{var a,i;return(i=(a=this.options.current).onSelectionUpdate)==null?void 0:i.call(a,...s)},onTransaction:(...s)=>{var a,i;return(i=(a=this.options.current).onTransaction)==null?void 0:i.call(a,...s)},onUpdate:(...s)=>{var a,i;return(i=(a=this.options.current).onUpdate)==null?void 0:i.call(a,...s)},onContentError:(...s)=>{var a,i;return(i=(a=this.options.current).onContentError)==null?void 0:i.call(a,...s)},onDrop:(...s)=>{var a,i;return(i=(a=this.options.current).onDrop)==null?void 0:i.call(a,...s)},onPaste:(...s)=>{var a,i;return(i=(a=this.options.current).onPaste)==null?void 0:i.call(a,...s)},onDelete:(...s)=>{var a,i;return(i=(a=this.options.current).onDelete)==null?void 0:i.call(a,...s)}};return new O6(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(s=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(s)?!0:s==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((a,i)=>{var o;return a===((o=n.extensions)==null?void 0:o[i])}):e[s]===n[s])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?lC.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((s,a)=>s===e[a]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function W_(t={},e=[]){const n=b.useRef(t);n.current=t;const[s]=b.useState(()=>new H_(n)),a=Yk.useSyncExternalStore(s.subscribe,s.getEditor,s.getServerSnapshot);return b.useDebugValue(a),b.useEffect(s.onRender(e)),F_({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var cC=b.createContext({editor:null});cC.Consumer;var U_=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),K_=()=>b.useContext(U_);ks.forwardRef((t,e)=>{const{onDragStart:n}=K_(),s=t.as||"div";return r.jsx(s,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ks.createContext({markViewContentRef:()=>{}});var Q0=b.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});Q0.displayName="TiptapContext";var q_=()=>b.useContext(Q0);function dC({editor:t,instance:e,children:n}){const s=t??e;if(!s)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const a=b.useMemo(()=>({editor:s}),[s]),i=b.useMemo(()=>({editor:s}),[s]);return r.jsx(cC.Provider,{value:i,children:r.jsx(Q0.Provider,{value:a,children:n})})}dC.displayName="Tiptap";function uC({...t}){const{editor:e}=q_();return r.jsx(oC,{editor:e,...t})}uC.displayName="Tiptap.Content";Object.assign(dC,{Content:uC});var Qh=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...s}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,s,n]},G_=/^\s*>\s$/,J_=Mn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Qh("blockquote",{...Et(this.options.HTMLAttributes,t),children:Qh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",s=[];return t.content.forEach(a=>{const c=e.renderChildren([a]).split(` + */var LN;function A_(){if(LN)return kg;LN=1;var t=$d(),e=Jk();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:n,a=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return kg.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var N=i(null);if(N.current===null){var j={hasValue:!1,value:null};N.current=j}else j=N.current;N=c(function(){function k(H){if(!C){if(C=!0,E=H,H=g(H),y!==void 0&&j.hasValue){var L=j.value;if(y(L,H))return M=L}return M=H}if(L=M,s(E,H))return L;var R=g(H);return y!==void 0&&y(L,R)?(E=H,L):(E=H,M=R)}var C=!1,E,M,P=m===void 0?null:m;return[function(){return k(f())},P===null?void 0:function(){return k(P())}]},[f,m,g,y]);var v=a(h,N[0],N[1]);return o(function(){j.hasValue=!0,j.value=v},[v]),u(v),v},kg}var _N;function I_(){return _N||(_N=1,jg.exports=A_()),jg.exports}var R_=I_(),P_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},O_=({contentComponent:t})=>{const e=Yk.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return r.jsx(r.Fragment,{children:Object.values(e)})};function D_(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,s){e={...e,[n]:Uw.createPortal(s.reactElement,s.element,n)},t.forEach(a=>a())},removeRenderer(n){const s={...e};delete s[n],e=s,t.forEach(a=>a())}}}var L_=class extends Cs.Component{constructor(t){var e;super(t),this.editorContentRef=Cs.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=D_(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(s=>s.hasContentComponentInitialized?s:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:P_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&r.jsx(O_,{contentComponent:t.contentComponent})]})}},__=b.forwardRef((t,e)=>{const n=Cs.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Cs.createElement(L_,{key:n,innerRef:e,...t})}),oC=Cs.memo(__),z_=typeof window<"u"?b.useLayoutEffect:b.useEffect,F_=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function $_(t){var e;const[n]=b.useState(()=>new F_(t.editor)),s=R_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:M_);return z_(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(s),s}var B_=!1,Cx=typeof window>"u",V_=Cx||!!(typeof window<"u"&&window.next),H_=class lC{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Cx||V_?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...s)=>{var a,i;return(i=(a=this.options.current).onBeforeCreate)==null?void 0:i.call(a,...s)},onBlur:(...s)=>{var a,i;return(i=(a=this.options.current).onBlur)==null?void 0:i.call(a,...s)},onCreate:(...s)=>{var a,i;return(i=(a=this.options.current).onCreate)==null?void 0:i.call(a,...s)},onDestroy:(...s)=>{var a,i;return(i=(a=this.options.current).onDestroy)==null?void 0:i.call(a,...s)},onFocus:(...s)=>{var a,i;return(i=(a=this.options.current).onFocus)==null?void 0:i.call(a,...s)},onSelectionUpdate:(...s)=>{var a,i;return(i=(a=this.options.current).onSelectionUpdate)==null?void 0:i.call(a,...s)},onTransaction:(...s)=>{var a,i;return(i=(a=this.options.current).onTransaction)==null?void 0:i.call(a,...s)},onUpdate:(...s)=>{var a,i;return(i=(a=this.options.current).onUpdate)==null?void 0:i.call(a,...s)},onContentError:(...s)=>{var a,i;return(i=(a=this.options.current).onContentError)==null?void 0:i.call(a,...s)},onDrop:(...s)=>{var a,i;return(i=(a=this.options.current).onDrop)==null?void 0:i.call(a,...s)},onPaste:(...s)=>{var a,i;return(i=(a=this.options.current).onPaste)==null?void 0:i.call(a,...s)},onDelete:(...s)=>{var a,i;return(i=(a=this.options.current).onDelete)==null?void 0:i.call(a,...s)}};return new O6(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(s=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(s)?!0:s==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((a,i)=>{var o;return a===((o=n.extensions)==null?void 0:o[i])}):e[s]===n[s])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?lC.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((s,a)=>s===e[a]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function W_(t={},e=[]){const n=b.useRef(t);n.current=t;const[s]=b.useState(()=>new H_(n)),a=Yk.useSyncExternalStore(s.subscribe,s.getEditor,s.getServerSnapshot);return b.useDebugValue(a),b.useEffect(s.onRender(e)),$_({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var cC=b.createContext({editor:null});cC.Consumer;var U_=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),K_=()=>b.useContext(U_);Cs.forwardRef((t,e)=>{const{onDragStart:n}=K_(),s=t.as||"div";return r.jsx(s,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Cs.createContext({markViewContentRef:()=>{}});var Q0=b.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});Q0.displayName="TiptapContext";var q_=()=>b.useContext(Q0);function dC({editor:t,instance:e,children:n}){const s=t??e;if(!s)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const a=b.useMemo(()=>({editor:s}),[s]),i=b.useMemo(()=>({editor:s}),[s]);return r.jsx(cC.Provider,{value:i,children:r.jsx(Q0.Provider,{value:a,children:n})})}dC.displayName="Tiptap";function uC({...t}){const{editor:e}=q_();return r.jsx(oC,{editor:e,...t})}uC.displayName="Tiptap.Content";Object.assign(dC,{Content:uC});var Qh=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...s}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,s,n]},G_=/^\s*>\s$/,J_=An.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Qh("blockquote",{...Et(this.options.HTMLAttributes,t),children:Qh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",s=[];return t.content.forEach(a=>{const c=e.renderChildren([a]).split(` `).map(u=>u.trim()===""?n:`${n} ${u}`);s.push(c.join(` `))}),s.join(` ${n} -`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ql({find:G_,type:this.type})]}}),Y_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Q_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,X_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Z_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,e7=Yo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Qh("strong",{...Et(this.options.HTMLAttributes,t),children:Qh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Yl({find:Y_,type:this.type}),Yl({find:X_,type:this.type})]},addPasteRules(){return[Ho({find:Q_,type:this.type}),Ho({find:Z_,type:this.type})]}}),t7=/(^|[^`])`([^`]+)`(?!`)$/,n7=/(^|[^`])`([^`]+)`(?!`)/g,s7=Yo.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Yl({find:t7,type:this.type})]},addPasteRules(){return[Ho({find:n7,type:this.type})]}}),Sg=4,r7=/^```([a-z]+)?[\s\n]$/,a7=/^~~~([a-z]+)?[\s\n]$/,i7=Mn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Sg,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Et(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,s;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((s=t.raw)==null?void 0:s.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let s="";const a=((n=t.attrs)==null?void 0:n.language)||"";return t.content?s=[`\`\`\`${a}`,e.renderChildren(t.content),"```"].join(` +`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ql({find:G_,type:this.type})]}}),Y_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Q_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,X_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Z_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,e7=Yo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Qh("strong",{...Et(this.options.HTMLAttributes,t),children:Qh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Yl({find:Y_,type:this.type}),Yl({find:X_,type:this.type})]},addPasteRules(){return[Ho({find:Q_,type:this.type}),Ho({find:Z_,type:this.type})]}}),t7=/(^|[^`])`([^`]+)`(?!`)$/,n7=/(^|[^`])`([^`]+)`(?!`)/g,s7=Yo.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Yl({find:t7,type:this.type})]},addPasteRules(){return[Ho({find:n7,type:this.type})]}}),Sg=4,r7=/^```([a-z]+)?[\s\n]$/,a7=/^~~~([a-z]+)?[\s\n]$/,i7=An.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Sg,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Et(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,s;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((s=t.raw)==null?void 0:s.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let s="";const a=((n=t.attrs)==null?void 0:n.language)||"";return t.content?s=[`\`\`\`${a}`,e.renderChildren(t.content),"```"].join(` `):s=`\`\`\`${a} \`\`\``,s},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Sg,{state:s}=t,{selection:a}=s,{$from:i,empty:o}=a;if(i.parent.type!==this.type)return!1;const c=" ".repeat(n);return o?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:h,to:f}=a,y=s.doc.textBetween(h,f,` @@ -721,37 +721,37 @@ ${n} `);return u.replaceWith(h,f,s.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Sg,{state:s}=t,{selection:a}=s,{$from:i,empty:o}=a;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:c})=>{var u;const{pos:h}=i,f=i.start(),m=i.end(),y=s.doc.textBetween(f,m,` `,` `).split(` -`);let N=0,j=0;const v=h-f;for(let H=0;H=v){N=H;break}j+=y[H].length+1}const C=((u=y[N].match(/^ */))==null?void 0:u[0])||"",E=Math.min(C.length,n);if(E===0)return!0;let M=f;for(let H=0;H{const{from:u,to:h}=a,g=s.doc.textBetween(u,h,` +`);let N=0,j=0;const v=h-f;for(let H=0;H=v){N=H;break}j+=y[H].length+1}const C=((u=y[N].match(/^ */))==null?void 0:u[0])||"",E=Math.min(C.length,n);if(E===0)return!0;let M=f;for(let H=0;H{const{from:u,to:h}=a,g=s.doc.textBetween(u,h,` `,` `).split(` `).map(y=>{var N;const j=((N=y.match(/^ */))==null?void 0:N[0])||"",v=Math.min(j.length,n);return y.slice(v)}).join(` `);return c.replaceWith(u,h,s.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:s,empty:a}=n;if(!a||s.parent.type!==this.type)return!1;const i=s.parentOffset===s.parent.nodeSize-2,o=s.parent.textContent.endsWith(` -`);return!i||!o?!1:t.chain().command(({tr:c})=>(c.delete(s.pos-2,s.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:s}=e,{$from:a,empty:i}=n;if(!i||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const c=a.after();return c===void 0?!1:s.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(rt.near(s.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[kx({find:r7,type:this.type,getAttributes:t=>({language:t[1]})}),kx({find:a7,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Wt({key:new nn("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),s=e.clipboardData.getData("vscode-editor-data"),a=s?JSON.parse(s):void 0,i=a==null?void 0:a.mode;if(!n||!i)return!1;const{tr:o,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,` -`));return o.replaceSelectionWith(this.type.create({language:i},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(Ze.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),o7=Mn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +`);return!i||!o?!1:t.chain().command(({tr:c})=>(c.delete(s.pos-2,s.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:s}=e,{$from:a,empty:i}=n;if(!i||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const c=a.after();return c===void 0?!1:s.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(nt.near(s.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[kx({find:r7,type:this.type,getAttributes:t=>({language:t[1]})}),kx({find:a7,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new qt({key:new rn("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),s=e.clipboardData.getData("vscode-editor-data"),a=s?JSON.parse(s):void 0,i=a==null?void 0:a.mode;if(!n||!i)return!1;const{tr:o,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,` +`));return o.replaceSelectionWith(this.type.create({language:i},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(Xe.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),o7=An.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):""}),l7=Mn.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Et(this.options.HTMLAttributes,t)]},renderText(){return` +`):""}),l7=An.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Et(this.options.HTMLAttributes,t)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:s})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:i}=n;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=s.extensionManager,u=i||a.$to.parentOffset&&a.$from.marks();return e().insertContent({type:this.name}).command(({tr:h,dispatch:f})=>{if(f&&u&&o){const m=u.filter(g=>c.includes(g.type.name));h.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),c7=Mn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Et(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const s=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,a="#".repeat(s);return t.content?`${a} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>kx({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),d7=Mn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Et(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!_6(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:s}=n,a=t();return F2(n)?a.insertContentAt(s.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({state:i,tr:o,dispatch:c})=>{if(c){const{$to:u}=o.selection,h=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(Ze.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Xe.create(o.doc,u.pos)):o.setSelection(Ze.create(o.doc,u.pos));else{const f=i.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=f==null?void 0:f.create();m&&(o.insert(h,m),o.setSelection(Ze.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[sC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),u7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,h7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,f7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,p7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,m7=Yo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Et(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Yl({find:u7,type:this.type}),Yl({find:f7,type:this.type})]},addPasteRules(){return[Ho({find:h7,type:this.type}),Ho({find:p7,type:this.type})]}});const g7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",x7="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ex="numeric",Tx="ascii",Mx="alpha",gd="asciinumeric",rd="alphanumeric",Ax="domain",hC="emoji",y7="scheme",b7="slashscheme",Cg="whitespace";function v7(t,e){return t in e||(e[t]=[]),e[t]}function To(t,e,n){e[Ex]&&(e[gd]=!0,e[rd]=!0),e[Tx]&&(e[gd]=!0,e[Mx]=!0),e[gd]&&(e[rd]=!0),e[Mx]&&(e[rd]=!0),e[rd]&&(e[Ax]=!0),e[hC]&&(e[Ax]=!0);for(const s in e){const a=v7(s,n);a.indexOf(t)<0&&a.push(t)}}function N7(t,e){const n={};for(const s in e)e[s].indexOf(t)>=0&&(n[s]=!0);return n}function _s(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}_s.groups={};_s.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let s=0;st.ta(e,n,s,a),hn=(t,e,n,s,a)=>t.tr(e,n,s,a),zN=(t,e,n,s,a)=>t.ts(e,n,s,a),Ae=(t,e,n,s,a)=>t.tt(e,n,s,a),Da="WORD",Ix="UWORD",fC="ASCIINUMERICAL",pC="ALPHANUMERICAL",Ld="LOCALHOST",Rx="TLD",Px="UTLD",kh="SCHEME",Rl="SLASH_SCHEME",X0="NUM",Ox="WS",Z0="NL",xd="OPENBRACE",yd="CLOSEBRACE",Xh="OPENBRACKET",Zh="CLOSEBRACKET",ef="OPENPAREN",tf="CLOSEPAREN",nf="OPENANGLEBRACKET",sf="CLOSEANGLEBRACKET",rf="FULLWIDTHLEFTPAREN",af="FULLWIDTHRIGHTPAREN",of="LEFTCORNERBRACKET",lf="RIGHTCORNERBRACKET",cf="LEFTWHITECORNERBRACKET",df="RIGHTWHITECORNERBRACKET",uf="FULLWIDTHLESSTHAN",hf="FULLWIDTHGREATERTHAN",ff="AMPERSAND",pf="APOSTROPHE",mf="ASTERISK",wi="AT",gf="BACKSLASH",xf="BACKTICK",yf="CARET",Si="COLON",ey="COMMA",bf="DOLLAR",Xr="DOT",vf="EQUALS",ty="EXCLAMATION",lr="HYPHEN",bd="PERCENT",Nf="PIPE",wf="PLUS",jf="POUND",vd="QUERY",ny="QUOTE",mC="FULLWIDTHMIDDLEDOT",sy="SEMI",Zr="SLASH",Nd="TILDE",kf="UNDERSCORE",gC="EMOJI",Sf="SYM";var xC=Object.freeze({__proto__:null,ALPHANUMERICAL:pC,AMPERSAND:ff,APOSTROPHE:pf,ASCIINUMERICAL:fC,ASTERISK:mf,AT:wi,BACKSLASH:gf,BACKTICK:xf,CARET:yf,CLOSEANGLEBRACKET:sf,CLOSEBRACE:yd,CLOSEBRACKET:Zh,CLOSEPAREN:tf,COLON:Si,COMMA:ey,DOLLAR:bf,DOT:Xr,EMOJI:gC,EQUALS:vf,EXCLAMATION:ty,FULLWIDTHGREATERTHAN:hf,FULLWIDTHLEFTPAREN:rf,FULLWIDTHLESSTHAN:uf,FULLWIDTHMIDDLEDOT:mC,FULLWIDTHRIGHTPAREN:af,HYPHEN:lr,LEFTCORNERBRACKET:of,LEFTWHITECORNERBRACKET:cf,LOCALHOST:Ld,NL:Z0,NUM:X0,OPENANGLEBRACKET:nf,OPENBRACE:xd,OPENBRACKET:Xh,OPENPAREN:ef,PERCENT:bd,PIPE:Nf,PLUS:wf,POUND:jf,QUERY:vd,QUOTE:ny,RIGHTCORNERBRACKET:lf,RIGHTWHITECORNERBRACKET:df,SCHEME:kh,SEMI:sy,SLASH:Zr,SLASH_SCHEME:Rl,SYM:Sf,TILDE:Nd,TLD:Rx,UNDERSCORE:kf,UTLD:Px,UWORD:Ix,WORD:Da,WS:Ox});const Pa=/[a-z]/,Zc=new RegExp("\\p{L}","u"),Eg=new RegExp("\\p{Emoji}","u"),Oa=/\d/,Tg=/\s/,$N="\r",Mg=` -`,w7="️",j7="‍",Ag="";let dh=null,uh=null;function k7(t=[]){const e={};_s.groups=e;const n=new _s;dh==null&&(dh=FN(g7)),uh==null&&(uh=FN(x7)),Ae(n,"'",pf),Ae(n,"{",xd),Ae(n,"}",yd),Ae(n,"[",Xh),Ae(n,"]",Zh),Ae(n,"(",ef),Ae(n,")",tf),Ae(n,"<",nf),Ae(n,">",sf),Ae(n,"(",rf),Ae(n,")",af),Ae(n,"「",of),Ae(n,"」",lf),Ae(n,"『",cf),Ae(n,"』",df),Ae(n,"<",uf),Ae(n,">",hf),Ae(n,"&",ff),Ae(n,"*",mf),Ae(n,"@",wi),Ae(n,"`",xf),Ae(n,"^",yf),Ae(n,":",Si),Ae(n,",",ey),Ae(n,"$",bf),Ae(n,".",Xr),Ae(n,"=",vf),Ae(n,"!",ty),Ae(n,"-",lr),Ae(n,"%",bd),Ae(n,"|",Nf),Ae(n,"+",wf),Ae(n,"#",jf),Ae(n,"?",vd),Ae(n,'"',ny),Ae(n,"/",Zr),Ae(n,";",sy),Ae(n,"~",Nd),Ae(n,"_",kf),Ae(n,"\\",gf),Ae(n,"・",mC);const s=hn(n,Oa,X0,{[Ex]:!0});hn(s,Oa,s);const a=hn(s,Pa,fC,{[gd]:!0}),i=hn(s,Zc,pC,{[rd]:!0}),o=hn(n,Pa,Da,{[Tx]:!0});hn(o,Oa,a),hn(o,Pa,o),hn(a,Oa,a),hn(a,Pa,a);const c=hn(n,Zc,Ix,{[Mx]:!0});hn(c,Pa),hn(c,Oa,i),hn(c,Zc,c),hn(i,Oa,i),hn(i,Pa),hn(i,Zc,i);const u=Ae(n,Mg,Z0,{[Cg]:!0}),h=Ae(n,$N,Ox,{[Cg]:!0}),f=hn(n,Tg,Ox,{[Cg]:!0});Ae(n,Ag,f),Ae(h,Mg,u),Ae(h,Ag,f),hn(h,Tg,f),Ae(f,$N),Ae(f,Mg),hn(f,Tg,f),Ae(f,Ag,f);const m=hn(n,Eg,gC,{[hC]:!0});Ae(m,"#"),hn(m,Eg,m),Ae(m,w7,m);const g=Ae(m,j7);Ae(g,"#"),hn(g,Eg,m);const y=[[Pa,o],[Oa,a]],N=[[Pa,null],[Zc,c],[Oa,i]];for(let j=0;jj[0]>v[0]?1:-1);for(let j=0;j=0?C[Ax]=!0:Pa.test(v)?Oa.test(v)?C[gd]=!0:C[Tx]=!0:C[Ex]=!0,zN(n,v,v,C)}return zN(n,"localhost",Ld,{ascii:!0}),n.jd=new _s(Sf),{start:n,tokens:Object.assign({groups:e},xC)}}function yC(t,e){const n=S7(e.replace(/[A-Z]/g,c=>c.toLowerCase())),s=n.length,a=[];let i=0,o=0;for(;o=0&&(m+=n[o].length,g++),h+=n[o].length,i+=n[o].length,o++;i-=m,o-=g,h-=m,a.push({t:f.t,v:e.slice(i-h,i),s:i-h,e:i})}return a}function S7(t){const e=[],n=t.length;let s=0;for(;s56319||s+1===n||(i=t.charCodeAt(s+1))<56320||i>57343?t[s]:t.slice(s,s+2);e.push(o),s+=o.length}return e}function xi(t,e,n,s,a){let i;const o=e.length;for(let c=0;c=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(s,s+i),10);o>0;o--)n.pop();s+=i}else n.push(t[s]),s++}return e}const _d={defaultProtocol:"http",events:null,format:BN,formatHref:BN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ry(t,e=null){let n=Object.assign({},_d);t&&(n=Object.assign(n,t instanceof ry?t.o:t));const s=n.ignoreTags,a=[];for(let i=0;in?s.substring(0,n)+"…":s},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=_d.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),s=t.get("formatHref",n,this),a=t.get("tagName",n,e),i=this.toFormattedString(t),o={},c=t.get("className",n,e),u=t.get("target",n,e),h=t.get("rel",n,e),f=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=s,c&&(o.class=c),u&&(o.target=u),h&&(o.rel=h),f&&Object.assign(o,f),{tagName:a,attributes:o,content:i,eventListeners:m}}};function sp(t,e){class n extends bC{constructor(a,i){super(a,i),this.t=t}}for(const s in e)n.prototype[s]=e[s];return n.t=t,n}const VN=sp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),HN=sp("text"),C7=sp("nl"),hh=sp("url",{isLink:!0,toHref(t=_d.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ld&&t[1].t===Si}}),or=t=>new _s(t);function E7({groups:t}){const e=t.domain.concat([ff,mf,wi,gf,xf,yf,bf,vf,lr,X0,bd,Nf,wf,jf,Zr,Sf,Nd,kf]),n=[pf,Si,ey,Xr,ty,bd,vd,ny,sy,nf,sf,xd,yd,Zh,Xh,ef,tf,rf,af,of,lf,cf,df,uf,hf],s=[ff,pf,mf,gf,xf,yf,bf,vf,lr,xd,yd,bd,Nf,wf,jf,vd,Zr,Sf,Nd,kf],a=or(),i=Ae(a,Nd);ft(i,s,i),ft(i,t.domain,i);const o=or(),c=or(),u=or();ft(a,t.domain,o),ft(a,t.scheme,c),ft(a,t.slashscheme,u),ft(o,s,i),ft(o,t.domain,o);const h=Ae(o,wi);Ae(i,wi,h),Ae(c,wi,h),Ae(u,wi,h);const f=Ae(i,Xr);ft(f,s,i),ft(f,t.domain,i);const m=or();ft(h,t.domain,m),ft(m,t.domain,m);const g=Ae(m,Xr);ft(g,t.domain,m);const y=or(VN);ft(g,t.tld,y),ft(g,t.utld,y),Ae(h,Ld,y);const N=Ae(m,lr);Ae(N,lr,N),ft(N,t.domain,m),ft(y,t.domain,m),Ae(y,Xr,g),Ae(y,lr,N);const j=Ae(y,Si);ft(j,t.numeric,VN);const v=Ae(o,lr),k=Ae(o,Xr);Ae(v,lr,v),ft(v,t.domain,o),ft(k,s,i),ft(k,t.domain,o);const C=or(hh);ft(k,t.tld,C),ft(k,t.utld,C),ft(C,t.domain,o),ft(C,s,i),Ae(C,Xr,k),Ae(C,lr,v),Ae(C,wi,h);const E=Ae(C,Si),M=or(hh);ft(E,t.numeric,M);const P=or(hh),H=or();ft(P,e,P),ft(P,n,H),ft(H,e,P),ft(H,n,H),Ae(C,Zr,P),Ae(M,Zr,P);const L=Ae(c,Si),R=Ae(u,Si),O=Ae(R,Zr),ne=Ae(O,Zr);ft(c,t.domain,o),Ae(c,Xr,k),Ae(c,lr,v),ft(u,t.domain,o),Ae(u,Xr,k),Ae(u,lr,v),ft(L,t.domain,P),Ae(L,Zr,P),Ae(L,vd,P),ft(ne,t.domain,P),ft(ne,e,P),Ae(ne,Zr,P);const ie=[[xd,yd],[Xh,Zh],[ef,tf],[nf,sf],[rf,af],[of,lf],[cf,df],[uf,hf]];for(let _=0;_=0&&g++,a++,f++;if(g<0)a-=f,a0&&(i.push(Ig(HN,e,o)),o=[]),a-=g,f-=g;const y=m.t,N=n.slice(a-f,a);i.push(Ig(y,e,N))}}return o.length>0&&i.push(Ig(HN,e,o)),i}function Ig(t,e,n){const s=n[0].s,a=n[n.length-1].e,i=e.slice(s,a);return new t(i,n)}const M7=typeof console<"u"&&console&&console.warn||(()=>{}),A7="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Jt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function I7(){return _s.groups={},Jt.scanner=null,Jt.parser=null,Jt.tokenQueue=[],Jt.pluginQueue=[],Jt.customSchemes=[],Jt.initialized=!1,Jt}function WN(t,e=!1){if(Jt.initialized&&M7(`linkifyjs: already initialized - will not register custom scheme "${t}" ${A7}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:s})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:i}=n;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=s.extensionManager,u=i||a.$to.parentOffset&&a.$from.marks();return e().insertContent({type:this.name}).command(({tr:h,dispatch:f})=>{if(f&&u&&o){const m=u.filter(g=>c.includes(g.type.name));h.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),c7=An.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Et(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const s=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,a="#".repeat(s);return t.content?`${a} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>kx({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),d7=An.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Et(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!_6(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:s}=n,a=t();return $2(n)?a.insertContentAt(s.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({state:i,tr:o,dispatch:c})=>{if(c){const{$to:u}=o.selection,h=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(Xe.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Qe.create(o.doc,u.pos)):o.setSelection(Xe.create(o.doc,u.pos));else{const f=i.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=f==null?void 0:f.create();m&&(o.insert(h,m),o.setSelection(Xe.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[sC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),u7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,h7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,f7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,p7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,m7=Yo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Et(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Yl({find:u7,type:this.type}),Yl({find:f7,type:this.type})]},addPasteRules(){return[Ho({find:h7,type:this.type}),Ho({find:p7,type:this.type})]}});const g7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",x7="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ex="numeric",Tx="ascii",Mx="alpha",gd="asciinumeric",rd="alphanumeric",Ax="domain",hC="emoji",y7="scheme",b7="slashscheme",Cg="whitespace";function v7(t,e){return t in e||(e[t]=[]),e[t]}function To(t,e,n){e[Ex]&&(e[gd]=!0,e[rd]=!0),e[Tx]&&(e[gd]=!0,e[Mx]=!0),e[gd]&&(e[rd]=!0),e[Mx]&&(e[rd]=!0),e[rd]&&(e[Ax]=!0),e[hC]&&(e[Ax]=!0);for(const s in e){const a=v7(s,n);a.indexOf(t)<0&&a.push(t)}}function N7(t,e){const n={};for(const s in e)e[s].indexOf(t)>=0&&(n[s]=!0);return n}function zs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}zs.groups={};zs.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let s=0;st.ta(e,n,s,a),hn=(t,e,n,s,a)=>t.tr(e,n,s,a),zN=(t,e,n,s,a)=>t.ts(e,n,s,a),Me=(t,e,n,s,a)=>t.tt(e,n,s,a),Da="WORD",Ix="UWORD",fC="ASCIINUMERICAL",pC="ALPHANUMERICAL",Ld="LOCALHOST",Rx="TLD",Px="UTLD",kh="SCHEME",Rl="SLASH_SCHEME",X0="NUM",Ox="WS",Z0="NL",xd="OPENBRACE",yd="CLOSEBRACE",Xh="OPENBRACKET",Zh="CLOSEBRACKET",ef="OPENPAREN",tf="CLOSEPAREN",nf="OPENANGLEBRACKET",sf="CLOSEANGLEBRACKET",rf="FULLWIDTHLEFTPAREN",af="FULLWIDTHRIGHTPAREN",of="LEFTCORNERBRACKET",lf="RIGHTCORNERBRACKET",cf="LEFTWHITECORNERBRACKET",df="RIGHTWHITECORNERBRACKET",uf="FULLWIDTHLESSTHAN",hf="FULLWIDTHGREATERTHAN",ff="AMPERSAND",pf="APOSTROPHE",mf="ASTERISK",ji="AT",gf="BACKSLASH",xf="BACKTICK",yf="CARET",Ci="COLON",ey="COMMA",bf="DOLLAR",Xr="DOT",vf="EQUALS",ty="EXCLAMATION",dr="HYPHEN",bd="PERCENT",Nf="PIPE",wf="PLUS",jf="POUND",vd="QUERY",ny="QUOTE",mC="FULLWIDTHMIDDLEDOT",sy="SEMI",Zr="SLASH",Nd="TILDE",kf="UNDERSCORE",gC="EMOJI",Sf="SYM";var xC=Object.freeze({__proto__:null,ALPHANUMERICAL:pC,AMPERSAND:ff,APOSTROPHE:pf,ASCIINUMERICAL:fC,ASTERISK:mf,AT:ji,BACKSLASH:gf,BACKTICK:xf,CARET:yf,CLOSEANGLEBRACKET:sf,CLOSEBRACE:yd,CLOSEBRACKET:Zh,CLOSEPAREN:tf,COLON:Ci,COMMA:ey,DOLLAR:bf,DOT:Xr,EMOJI:gC,EQUALS:vf,EXCLAMATION:ty,FULLWIDTHGREATERTHAN:hf,FULLWIDTHLEFTPAREN:rf,FULLWIDTHLESSTHAN:uf,FULLWIDTHMIDDLEDOT:mC,FULLWIDTHRIGHTPAREN:af,HYPHEN:dr,LEFTCORNERBRACKET:of,LEFTWHITECORNERBRACKET:cf,LOCALHOST:Ld,NL:Z0,NUM:X0,OPENANGLEBRACKET:nf,OPENBRACE:xd,OPENBRACKET:Xh,OPENPAREN:ef,PERCENT:bd,PIPE:Nf,PLUS:wf,POUND:jf,QUERY:vd,QUOTE:ny,RIGHTCORNERBRACKET:lf,RIGHTWHITECORNERBRACKET:df,SCHEME:kh,SEMI:sy,SLASH:Zr,SLASH_SCHEME:Rl,SYM:Sf,TILDE:Nd,TLD:Rx,UNDERSCORE:kf,UTLD:Px,UWORD:Ix,WORD:Da,WS:Ox});const Pa=/[a-z]/,Zc=new RegExp("\\p{L}","u"),Eg=new RegExp("\\p{Emoji}","u"),Oa=/\d/,Tg=/\s/,FN="\r",Mg=` +`,w7="️",j7="‍",Ag="";let dh=null,uh=null;function k7(t=[]){const e={};zs.groups=e;const n=new zs;dh==null&&(dh=$N(g7)),uh==null&&(uh=$N(x7)),Me(n,"'",pf),Me(n,"{",xd),Me(n,"}",yd),Me(n,"[",Xh),Me(n,"]",Zh),Me(n,"(",ef),Me(n,")",tf),Me(n,"<",nf),Me(n,">",sf),Me(n,"(",rf),Me(n,")",af),Me(n,"「",of),Me(n,"」",lf),Me(n,"『",cf),Me(n,"』",df),Me(n,"<",uf),Me(n,">",hf),Me(n,"&",ff),Me(n,"*",mf),Me(n,"@",ji),Me(n,"`",xf),Me(n,"^",yf),Me(n,":",Ci),Me(n,",",ey),Me(n,"$",bf),Me(n,".",Xr),Me(n,"=",vf),Me(n,"!",ty),Me(n,"-",dr),Me(n,"%",bd),Me(n,"|",Nf),Me(n,"+",wf),Me(n,"#",jf),Me(n,"?",vd),Me(n,'"',ny),Me(n,"/",Zr),Me(n,";",sy),Me(n,"~",Nd),Me(n,"_",kf),Me(n,"\\",gf),Me(n,"・",mC);const s=hn(n,Oa,X0,{[Ex]:!0});hn(s,Oa,s);const a=hn(s,Pa,fC,{[gd]:!0}),i=hn(s,Zc,pC,{[rd]:!0}),o=hn(n,Pa,Da,{[Tx]:!0});hn(o,Oa,a),hn(o,Pa,o),hn(a,Oa,a),hn(a,Pa,a);const c=hn(n,Zc,Ix,{[Mx]:!0});hn(c,Pa),hn(c,Oa,i),hn(c,Zc,c),hn(i,Oa,i),hn(i,Pa),hn(i,Zc,i);const u=Me(n,Mg,Z0,{[Cg]:!0}),h=Me(n,FN,Ox,{[Cg]:!0}),f=hn(n,Tg,Ox,{[Cg]:!0});Me(n,Ag,f),Me(h,Mg,u),Me(h,Ag,f),hn(h,Tg,f),Me(f,FN),Me(f,Mg),hn(f,Tg,f),Me(f,Ag,f);const m=hn(n,Eg,gC,{[hC]:!0});Me(m,"#"),hn(m,Eg,m),Me(m,w7,m);const g=Me(m,j7);Me(g,"#"),hn(g,Eg,m);const y=[[Pa,o],[Oa,a]],N=[[Pa,null],[Zc,c],[Oa,i]];for(let j=0;jj[0]>v[0]?1:-1);for(let j=0;j=0?C[Ax]=!0:Pa.test(v)?Oa.test(v)?C[gd]=!0:C[Tx]=!0:C[Ex]=!0,zN(n,v,v,C)}return zN(n,"localhost",Ld,{ascii:!0}),n.jd=new zs(Sf),{start:n,tokens:Object.assign({groups:e},xC)}}function yC(t,e){const n=S7(e.replace(/[A-Z]/g,c=>c.toLowerCase())),s=n.length,a=[];let i=0,o=0;for(;o=0&&(m+=n[o].length,g++),h+=n[o].length,i+=n[o].length,o++;i-=m,o-=g,h-=m,a.push({t:f.t,v:e.slice(i-h,i),s:i-h,e:i})}return a}function S7(t){const e=[],n=t.length;let s=0;for(;s56319||s+1===n||(i=t.charCodeAt(s+1))<56320||i>57343?t[s]:t.slice(s,s+2);e.push(o),s+=o.length}return e}function yi(t,e,n,s,a){let i;const o=e.length;for(let c=0;c=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(s,s+i),10);o>0;o--)n.pop();s+=i}else n.push(t[s]),s++}return e}const _d={defaultProtocol:"http",events:null,format:BN,formatHref:BN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ry(t,e=null){let n=Object.assign({},_d);t&&(n=Object.assign(n,t instanceof ry?t.o:t));const s=n.ignoreTags,a=[];for(let i=0;in?s.substring(0,n)+"…":s},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=_d.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),s=t.get("formatHref",n,this),a=t.get("tagName",n,e),i=this.toFormattedString(t),o={},c=t.get("className",n,e),u=t.get("target",n,e),h=t.get("rel",n,e),f=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=s,c&&(o.class=c),u&&(o.target=u),h&&(o.rel=h),f&&Object.assign(o,f),{tagName:a,attributes:o,content:i,eventListeners:m}}};function sp(t,e){class n extends bC{constructor(a,i){super(a,i),this.t=t}}for(const s in e)n.prototype[s]=e[s];return n.t=t,n}const VN=sp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),HN=sp("text"),C7=sp("nl"),hh=sp("url",{isLink:!0,toHref(t=_d.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ld&&t[1].t===Ci}}),cr=t=>new zs(t);function E7({groups:t}){const e=t.domain.concat([ff,mf,ji,gf,xf,yf,bf,vf,dr,X0,bd,Nf,wf,jf,Zr,Sf,Nd,kf]),n=[pf,Ci,ey,Xr,ty,bd,vd,ny,sy,nf,sf,xd,yd,Zh,Xh,ef,tf,rf,af,of,lf,cf,df,uf,hf],s=[ff,pf,mf,gf,xf,yf,bf,vf,dr,xd,yd,bd,Nf,wf,jf,vd,Zr,Sf,Nd,kf],a=cr(),i=Me(a,Nd);ht(i,s,i),ht(i,t.domain,i);const o=cr(),c=cr(),u=cr();ht(a,t.domain,o),ht(a,t.scheme,c),ht(a,t.slashscheme,u),ht(o,s,i),ht(o,t.domain,o);const h=Me(o,ji);Me(i,ji,h),Me(c,ji,h),Me(u,ji,h);const f=Me(i,Xr);ht(f,s,i),ht(f,t.domain,i);const m=cr();ht(h,t.domain,m),ht(m,t.domain,m);const g=Me(m,Xr);ht(g,t.domain,m);const y=cr(VN);ht(g,t.tld,y),ht(g,t.utld,y),Me(h,Ld,y);const N=Me(m,dr);Me(N,dr,N),ht(N,t.domain,m),ht(y,t.domain,m),Me(y,Xr,g),Me(y,dr,N);const j=Me(y,Ci);ht(j,t.numeric,VN);const v=Me(o,dr),k=Me(o,Xr);Me(v,dr,v),ht(v,t.domain,o),ht(k,s,i),ht(k,t.domain,o);const C=cr(hh);ht(k,t.tld,C),ht(k,t.utld,C),ht(C,t.domain,o),ht(C,s,i),Me(C,Xr,k),Me(C,dr,v),Me(C,ji,h);const E=Me(C,Ci),M=cr(hh);ht(E,t.numeric,M);const P=cr(hh),H=cr();ht(P,e,P),ht(P,n,H),ht(H,e,P),ht(H,n,H),Me(C,Zr,P),Me(M,Zr,P);const L=Me(c,Ci),R=Me(u,Ci),O=Me(R,Zr),se=Me(O,Zr);ht(c,t.domain,o),Me(c,Xr,k),Me(c,dr,v),ht(u,t.domain,o),Me(u,Xr,k),Me(u,dr,v),ht(L,t.domain,P),Me(L,Zr,P),Me(L,vd,P),ht(se,t.domain,P),ht(se,e,P),Me(se,Zr,P);const ie=[[xd,yd],[Xh,Zh],[ef,tf],[nf,sf],[rf,af],[of,lf],[cf,df],[uf,hf]];for(let z=0;z=0&&g++,a++,f++;if(g<0)a-=f,a0&&(i.push(Ig(HN,e,o)),o=[]),a-=g,f-=g;const y=m.t,N=n.slice(a-f,a);i.push(Ig(y,e,N))}}return o.length>0&&i.push(Ig(HN,e,o)),i}function Ig(t,e,n){const s=n[0].s,a=n[n.length-1].e,i=e.slice(s,a);return new t(i,n)}const M7=typeof console<"u"&&console&&console.warn||(()=>{}),A7="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Xt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function I7(){return zs.groups={},Xt.scanner=null,Xt.parser=null,Xt.tokenQueue=[],Xt.pluginQueue=[],Xt.customSchemes=[],Xt.initialized=!1,Xt}function WN(t,e=!1){if(Xt.initialized&&M7(`linkifyjs: already initialized - will not register custom scheme "${t}" ${A7}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);Jt.customSchemes.push([t,e])}function R7(){Jt.scanner=k7(Jt.customSchemes);for(let t=0;t{const a=e.some(h=>h.docChanged)&&!n.doc.eq(s.doc),i=e.some(h=>h.getMeta("preventAutolink"));if(!a||i)return;const{tr:o}=s,c=I2(n.doc,[...e]);if($2(c).forEach(({newRange:h})=>{const f=L8(s.doc,h,y=>y.isTextblock);let m,g;if(f.length>1)m=f[0],g=s.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const y=s.doc.textBetween(h.from,h.to," "," ");if(!O7.test(y))return;m=f[0],g=s.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(P7).filter(Boolean);if(y.length<=0)return!1;const N=y[y.length-1],j=m.pos+g.lastIndexOf(N);if(!N)return!1;const v=ay(N).map(k=>k.toObject(t.defaultProtocol));if(!L7(v))return!1;v.filter(k=>k.isLink).map(k=>({...k,from:j+k.start+1,to:j+k.end+1})).filter(k=>s.schema.marks.code?!s.doc.rangeHasMark(k.from,k.to,s.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{K0(k.from,k.to,s.doc).some(C=>C.mark.type===t.type)||o.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!o.steps.length)return o}})}function z7(t){return new Wt({key:new nn("handleClickLink"),props:{handleClick:(e,n,s)=>{var a,i;if(s.button!==0||!e.editable)return!1;let o=null;if(s.target instanceof HTMLAnchorElement)o=s.target;else{const u=s.target;if(!u)return!1;const h=t.editor.view.dom;o=u.closest("a"),o&&!h.contains(o)&&(o=null)}if(!o)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=z2(e.state,t.type.name),h=(a=o.href)!=null?a:u.href,f=(i=o.target)!=null?i:u.target;h&&(window.open(h,f),c=!0)}return c}}})}function $7(t){return new Wt({key:new nn("handlePasteLink"),props:{handlePaste:(e,n,s)=>{const{shouldAutoLink:a}=t,{state:i}=e,{selection:o}=i,{empty:c}=o;if(c)return!1;let u="";s.content.forEach(f=>{u+=f.textContent});const h=vC(u,{defaultProtocol:t.defaultProtocol}).find(f=>f.isLink&&f.value===u);return!u||!h||a!==void 0&&!a(h.value)?!1:t.editor.commands.setMark(t.type,{href:h.href})}}})}function No(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(s=>{const a=typeof s=="string"?s:s.scheme;a&&n.push(a)}),!t||t.replace(D7,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var F7=Yo.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){WN(t);return}WN(t.scheme,t.optionalSlashes)})},onDestroy(){I7()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!No(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const a=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(a)||!/\./.test(a))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!No(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!No(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Et(this.options.HTMLAttributes,t),0]:["a",Et(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,s,a,i;const o=(s=(n=t.attrs)==null?void 0:n.href)!=null?s:"",c=(i=(a=t.attrs)==null?void 0:a.title)!=null?i:"",u=e.renderChildren(t);return c?`[${u}](${o} "${c}")`:`[${u}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:s=>!!No(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:s=>!!No(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ho({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:s}=this.options,a=vC(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!No(o,n),protocols:n,defaultProtocol:s}));a.length&&a.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(_7({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:s=>this.options.isAllowedUri(s,{defaultValidate:a=>!!No(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(z7({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push($7({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),B7=Object.defineProperty,V7=(t,e)=>{for(var n in e)B7(t,n,{get:e[n],enumerable:!0})},H7="listItem",UN="textStyle",KN=/^\s*([-+*])\s$/,NC=Mn.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(H7,this.editor.getAttributes(UN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ql({find:KN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ql({find:KN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(UN),editor:this.editor})),[t]}}),wC=Mn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(a=>a.type==="paragraph"))n=e.parseChildren(t.tokens);else{const a=t.tokens[0];if(a&&a.type==="text"&&a.tokens&&a.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(a.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),c=e.parseChildren(o);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Y0(t,e,s=>{var a,i;return s.parentType==="bulletList"?"- ":s.parentType==="orderedList"?`${(((i=(a=s.meta)==null?void 0:a.parentAttrs)==null?void 0:i.start)||1)+s.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),W7={};V7(W7,{findListItemPos:()=>Gd,getNextListDepth:()=>oy,handleBackspace:()=>Dx,handleDelete:()=>Lx,hasListBefore:()=>jC,hasListItemAfter:()=>U7,hasListItemBefore:()=>kC,listItemHasSubList:()=>SC,nextListIsDeeper:()=>CC,nextListIsHigher:()=>EC});var Gd=(t,e)=>{const{$from:n}=e.selection,s=Tn(t,e.schema);let a=null,i=n.depth,o=n.pos,c=null;for(;i>0&&c===null;)a=n.node(i),a.type===s?c=i:(i-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},oy=(t,e)=>{const n=Gd(t,e);if(!n)return!1;const[,s]=K8(e,t,n.$pos.pos+4);return s},jC=(t,e,n)=>{const{$anchor:s}=t.selection,a=Math.max(0,s.pos-2),i=t.doc.resolve(a).node();return!(!i||!n.includes(i.type.name))},kC=(t,e)=>{var n;const{$anchor:s}=e.selection,a=e.doc.resolve(s.pos-2);return!(a.index()===0||((n=a.nodeBefore)==null?void 0:n.type.name)!==t)},SC=(t,e,n)=>{if(!n)return!1;const s=Tn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===s&&(a=!0)}),a},Dx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Bi(t.state,e)&&jC(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),h=[];u.node().descendants((g,y)=>{g.type.name===e&&h.push({node:g,pos:y})});const f=h.at(-1);if(!f)return!1;const m=t.state.doc.resolve(u.start()+f.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Bi(t.state,e)||!Y8(t.state))return!1;const s=Gd(e,t.state);if(!s)return!1;const i=t.state.doc.resolve(s.$pos.pos-2).node(s.depth),o=SC(e,t.state,i);return kC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},CC=(t,e)=>{const n=oy(t,e),s=Gd(t,e);return!s||!n?!1:n>s.depth},EC=(t,e)=>{const n=oy(t,e),s=Gd(t,e);return!s||!n?!1:n{if(!Bi(t.state,e)||!J8(t.state,e))return!1;const{selection:n}=t.state,{$from:s,$to:a}=n;return!n.empty&&s.sameParent(a)?!1:CC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():EC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},U7=(t,e)=>{var n;const{$anchor:s}=e.selection,a=e.doc.resolve(s.pos-s.parentOffset-2);return!(a.index()===a.parent.childCount-1||((n=a.nodeAfter)==null?void 0:n.type.name)!==t)},TC=gn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Lx(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Lx(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&Dx(t,n,s)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&Dx(t,n,s)&&(e=!0)}),e}}}}),qN=/^(\s*)(\d+)\.\s+(.*)$/,K7=/^\s/;function q7(t){const e=[];let n=0,s=0;for(;n{const a=e.some(h=>h.docChanged)&&!n.doc.eq(s.doc),i=e.some(h=>h.getMeta("preventAutolink"));if(!a||i)return;const{tr:o}=s,c=I2(n.doc,[...e]);if(F2(c).forEach(({newRange:h})=>{const f=L8(s.doc,h,y=>y.isTextblock);let m,g;if(f.length>1)m=f[0],g=s.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const y=s.doc.textBetween(h.from,h.to," "," ");if(!O7.test(y))return;m=f[0],g=s.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(P7).filter(Boolean);if(y.length<=0)return!1;const N=y[y.length-1],j=m.pos+g.lastIndexOf(N);if(!N)return!1;const v=ay(N).map(k=>k.toObject(t.defaultProtocol));if(!L7(v))return!1;v.filter(k=>k.isLink).map(k=>({...k,from:j+k.start+1,to:j+k.end+1})).filter(k=>s.schema.marks.code?!s.doc.rangeHasMark(k.from,k.to,s.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{K0(k.from,k.to,s.doc).some(C=>C.mark.type===t.type)||o.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!o.steps.length)return o}})}function z7(t){return new qt({key:new rn("handleClickLink"),props:{handleClick:(e,n,s)=>{var a,i;if(s.button!==0||!e.editable)return!1;let o=null;if(s.target instanceof HTMLAnchorElement)o=s.target;else{const u=s.target;if(!u)return!1;const h=t.editor.view.dom;o=u.closest("a"),o&&!h.contains(o)&&(o=null)}if(!o)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=z2(e.state,t.type.name),h=(a=o.href)!=null?a:u.href,f=(i=o.target)!=null?i:u.target;h&&(window.open(h,f),c=!0)}return c}}})}function F7(t){return new qt({key:new rn("handlePasteLink"),props:{handlePaste:(e,n,s)=>{const{shouldAutoLink:a}=t,{state:i}=e,{selection:o}=i,{empty:c}=o;if(c)return!1;let u="";s.content.forEach(f=>{u+=f.textContent});const h=vC(u,{defaultProtocol:t.defaultProtocol}).find(f=>f.isLink&&f.value===u);return!u||!h||a!==void 0&&!a(h.value)?!1:t.editor.commands.setMark(t.type,{href:h.href})}}})}function No(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(s=>{const a=typeof s=="string"?s:s.scheme;a&&n.push(a)}),!t||t.replace(D7,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var $7=Yo.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){WN(t);return}WN(t.scheme,t.optionalSlashes)})},onDestroy(){I7()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!No(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const a=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(a)||!/\./.test(a))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!No(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!No(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Et(this.options.HTMLAttributes,t),0]:["a",Et(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,s,a,i;const o=(s=(n=t.attrs)==null?void 0:n.href)!=null?s:"",c=(i=(a=t.attrs)==null?void 0:a.title)!=null?i:"",u=e.renderChildren(t);return c?`[${u}](${o} "${c}")`:`[${u}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:s=>!!No(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:s=>!!No(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ho({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:s}=this.options,a=vC(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!No(o,n),protocols:n,defaultProtocol:s}));a.length&&a.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(_7({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:s=>this.options.isAllowedUri(s,{defaultValidate:a=>!!No(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(z7({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(F7({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),B7=Object.defineProperty,V7=(t,e)=>{for(var n in e)B7(t,n,{get:e[n],enumerable:!0})},H7="listItem",UN="textStyle",KN=/^\s*([-+*])\s$/,NC=An.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(H7,this.editor.getAttributes(UN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ql({find:KN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ql({find:KN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(UN),editor:this.editor})),[t]}}),wC=An.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(a=>a.type==="paragraph"))n=e.parseChildren(t.tokens);else{const a=t.tokens[0];if(a&&a.type==="text"&&a.tokens&&a.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(a.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),c=e.parseChildren(o);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Y0(t,e,s=>{var a,i;return s.parentType==="bulletList"?"- ":s.parentType==="orderedList"?`${(((i=(a=s.meta)==null?void 0:a.parentAttrs)==null?void 0:i.start)||1)+s.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),W7={};V7(W7,{findListItemPos:()=>Gd,getNextListDepth:()=>oy,handleBackspace:()=>Dx,handleDelete:()=>Lx,hasListBefore:()=>jC,hasListItemAfter:()=>U7,hasListItemBefore:()=>kC,listItemHasSubList:()=>SC,nextListIsDeeper:()=>CC,nextListIsHigher:()=>EC});var Gd=(t,e)=>{const{$from:n}=e.selection,s=Mn(t,e.schema);let a=null,i=n.depth,o=n.pos,c=null;for(;i>0&&c===null;)a=n.node(i),a.type===s?c=i:(i-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},oy=(t,e)=>{const n=Gd(t,e);if(!n)return!1;const[,s]=K8(e,t,n.$pos.pos+4);return s},jC=(t,e,n)=>{const{$anchor:s}=t.selection,a=Math.max(0,s.pos-2),i=t.doc.resolve(a).node();return!(!i||!n.includes(i.type.name))},kC=(t,e)=>{var n;const{$anchor:s}=e.selection,a=e.doc.resolve(s.pos-2);return!(a.index()===0||((n=a.nodeBefore)==null?void 0:n.type.name)!==t)},SC=(t,e,n)=>{if(!n)return!1;const s=Mn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===s&&(a=!0)}),a},Dx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Bi(t.state,e)&&jC(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),h=[];u.node().descendants((g,y)=>{g.type.name===e&&h.push({node:g,pos:y})});const f=h.at(-1);if(!f)return!1;const m=t.state.doc.resolve(u.start()+f.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Bi(t.state,e)||!Y8(t.state))return!1;const s=Gd(e,t.state);if(!s)return!1;const i=t.state.doc.resolve(s.$pos.pos-2).node(s.depth),o=SC(e,t.state,i);return kC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},CC=(t,e)=>{const n=oy(t,e),s=Gd(t,e);return!s||!n?!1:n>s.depth},EC=(t,e)=>{const n=oy(t,e),s=Gd(t,e);return!s||!n?!1:n{if(!Bi(t.state,e)||!J8(t.state,e))return!1;const{selection:n}=t.state,{$from:s,$to:a}=n;return!n.empty&&s.sameParent(a)?!1:CC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():EC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},U7=(t,e)=>{var n;const{$anchor:s}=e.selection,a=e.doc.resolve(s.pos-s.parentOffset-2);return!(a.index()===a.parent.childCount-1||((n=a.nodeAfter)==null?void 0:n.type.name)!==t)},TC=gn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Lx(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Lx(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&Dx(t,n,s)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&Dx(t,n,s)&&(e=!0)}),e}}}}),qN=/^(\s*)(\d+)\.\s+(.*)$/,K7=/^\s/;function q7(t){const e=[];let n=0,s=0;for(;ne;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(j=>j.indent)),N=MC(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:N,raw:g.map(j=>j.raw).join(` -`)})}a.push({type:"list_item",raw:o.raw,tokens:h}),i=m}else i+=1}return a}function G7(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const s=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(a=>{if(a.type==="paragraph"||a.type==="list"||a.type==="blockquote"||a.type==="code")s.push(...e.parseChildren([a]));else if(a.type==="text"&&a.tokens){const i=e.parseChildren([a]);s.push({type:"paragraph",content:i})}else{const i=e.parseChildren([a]);i.length>0&&s.push(...i)}}),{type:"listItem",content:s}})}var J7="listItem",GN="textStyle",JN=/^(\d+)\.\s$/,AC=Mn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Et(this.options.HTMLAttributes,n),0]:["ol",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,s=t.items?G7(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +`)})}a.push({type:"list_item",raw:o.raw,tokens:h}),i=m}else i+=1}return a}function G7(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const s=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(a=>{if(a.type==="paragraph"||a.type==="list"||a.type==="blockquote"||a.type==="code")s.push(...e.parseChildren([a]));else if(a.type==="text"&&a.tokens){const i=e.parseChildren([a]);s.push({type:"paragraph",content:i})}else{const i=e.parseChildren([a]);i.length>0&&s.push(...i)}}),{type:"listItem",content:s}})}var J7="listItem",GN="textStyle",JN=/^(\d+)\.\s$/,AC=An.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Et(this.options.HTMLAttributes,n),0]:["ol",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,s=t.items?G7(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var s;const a=t.split(` `),[i,o]=q7(a);if(i.length===0)return;const c=MC(i,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((s=i[0])==null?void 0:s.number)||1,items:c,raw:a.slice(0,o).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(J7,this.editor.getAttributes(GN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ql({find:JN,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ql({find:JN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(GN)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Y7=/^\s*(\[([( |x])?\])\s$/,Q7=Mn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Et(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const s=e.parseChildren(t.nestedTokens);n.push(...s)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const a=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Y0(t,e,a)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:s})=>{const a=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),h=m=>{var g,y;c.ariaLabel=((y=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:y.call(g,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};h(t),i.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!s.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;s.isEditable&&typeof n=="function"&&s.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const N=n();if(typeof N!="number")return!1;const j=y.doc.nodeAt(N);return y.setNodeMarkup(N,void 0,{...j==null?void 0:j.attrs,checked:g}),!0}).run(),!s.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{a.setAttribute(m,g)}),a.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,o),a.append(i,u),Object.entries(e).forEach(([m,g])=>{a.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:a,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;a.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=s.extensionManager.attributes,y=Dd(m,g),N=new Set(Object.keys(y)),j=this.options.HTMLAttributes;return f.forEach(v=>{N.has(v)||(v in j?a.setAttribute(v,j[v]):a.removeAttribute(v))}),Object.entries(y).forEach(([v,k])=>{k==null?v in j?a.setAttribute(v,j[v]):a.removeAttribute(v):a.setAttribute(v,k)}),f=N,!0}}}},addInputRules(){return[Ql({find:Y7,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),X7=Mn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Et(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const s=i=>{const o=Sx(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,u)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:u}),customNestedParser:s},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},a=Sx(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:s},n);if(a)return{type:"taskList",raw:a.raw,items:a.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});gn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(NC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(wC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(TC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(AC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Q7.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(X7.configure(this.options.taskList)),t}});var YN=" ",Z7=" ",ez=Mn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Et(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const s=e.parseInline(n);return s.length===1&&s[0].type==="text"&&(s[0].text===YN||s[0].text===Z7)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,s)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?YN:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),tz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,nz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,sz=Yo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Yl({find:tz,type:this.type})]},addPasteRules(){return[Ho({find:nz,type:this.type})]}}),rz=Mn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),az=Yo.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Et(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const a=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!a)return;const i=a[2].trim();return{type:"underline",raw:a[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function iz(t={}){return new Wt({view(e){return new oz(e,t)}})}class oz{constructor(e,n){var s;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(s=n.width)!==null&&s!==void 0?s:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let i=o=>{this[a](o)};return e.dom.addEventListener(a,i),{name:a,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,s,a=this.editorView.dom,i=a.getBoundingClientRect(),o=i.width/a.offsetWidth,c=i.height/a.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let N=y.getBoundingClientRect(),j=m?N.bottom:N.top;m&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*c;s={left:N.left,right:N.right,top:j-v,bottom:j+v}}}}if(!s){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;s={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let h,f;if(!u||u==document.body&&getComputedStyle(u).position=="static")h=-pageXOffset,f=-pageYOffset;else{let m=u.getBoundingClientRect(),g=m.width/u.offsetWidth,y=m.height/u.offsetHeight;h=m.left-u.scrollLeft*g,f=m.top-u.scrollTop*y}this.element.style.left=(s.left-h)/o+"px",this.element.style.top=(s.top-f)/c+"px",this.element.style.width=(s.right-s.left)/o+"px",this.element.style.height=(s.bottom-s.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),s=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),a=s&&s.type.spec.disableDropCursor,i=typeof a=="function"?a(this.editorView,n,e):a;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=jS(this.editorView.state.doc,o,this.editorView.dragging.slice);c!=null&&(o=c)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class pn extends rt{constructor(e){super(e,e)}map(e,n){let s=e.resolve(n.map(this.head));return pn.valid(s)?new pn(s):rt.near(s)}content(){return Oe.empty}eq(e){return e instanceof pn&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new pn(e.resolve(n.pos))}getBookmark(){return new ly(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!lz(e)||!cz(e))return!1;let s=n.type.spec.allowGapCursor;if(s!=null)return s;let a=n.contentMatchAt(e.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(e,n,s=!1){e:for(;;){if(!s&&pn.valid(e))return e;let a=e.pos,i=null;for(let o=e.depth;;o--){let c=e.node(o);if(n>0?e.indexAfter(o)0){i=c.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;a+=n;let u=e.doc.resolve(a);if(pn.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Xe.isSelectable(i)){e=e.doc.resolve(a+i.nodeSize*n),s=!1;continue e}break}i=o,a+=n;let c=e.doc.resolve(a);if(pn.valid(c))return c}return null}}}pn.prototype.visible=!1;pn.findFrom=pn.findGapCursorFrom;rt.jsonID("gapcursor",pn);class ly{constructor(e){this.pos=e}map(e){return new ly(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return pn.valid(n)?new pn(n):rt.near(n)}}function IC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function lz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),s=t.node(e);if(n==0){if(s.type.spec.isolating)return!0;continue}for(let a=s.child(n-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||IC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function cz(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),s=t.node(e);if(n==s.childCount){if(s.type.spec.isolating)return!0;continue}for(let a=s.child(n);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||IC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function dz(){return new Wt({props:{decorations:pz,createSelectionBetween(t,e,n){return e.pos==n.pos&&pn.valid(n)?new pn(n):null},handleClick:hz,handleKeyDown:uz,handleDOMEvents:{beforeinput:fz}}})}const uz=F0({ArrowLeft:fh("horiz",-1),ArrowRight:fh("horiz",1),ArrowUp:fh("vert",-1),ArrowDown:fh("vert",1)});function fh(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(s,a,i){let o=s.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof Ze){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=s.doc.resolve(e>0?c.after():c.before())}let h=pn.findGapCursorFrom(c,e,u);return h?(a&&a(s.tr.setSelection(new pn(h))),!0):!1}}function hz(t,e,n){if(!t||!t.editable)return!1;let s=t.state.doc.resolve(e);if(!pn.valid(s))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&Xe.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new pn(s))),!0)}function fz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof pn))return!1;let{$from:n}=t.state.selection,s=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!s)return!1;let a=Ne.empty;for(let o=s.length-1;o>=0;o--)a=Ne.from(s[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new Oe(a,0,0));return i.setSelection(Ze.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function pz(t){if(!(t.selection instanceof pn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",zt.create(t.doc,[Ln.widget(t.selection.head,e,{key:"gapcursor"})])}var Cf=200,Hn=function(){};Hn.prototype.append=function(e){return e.length?(e=Hn.from(e),!this.length&&e||e.length=n?Hn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Hn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Hn.prototype.forEach=function(e,n,s){n===void 0&&(n=0),s===void 0&&(s=this.length),n<=s?this.forEachInner(e,n,s,0):this.forEachInvertedInner(e,n,s,0)};Hn.prototype.map=function(e,n,s){n===void 0&&(n=0),s===void 0&&(s=this.length);var a=[];return this.forEach(function(i,o){return a.push(e(i,o))},n,s),a};Hn.from=function(e){return e instanceof Hn?e:e&&e.length?new RC(e):Hn.empty};var RC=(function(t){function e(s){t.call(this),this.values=s}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(a,i){return a==0&&i==this.length?this:new e(this.values.slice(a,i))},e.prototype.getInner=function(a){return this.values[a]},e.prototype.forEachInner=function(a,i,o,c){for(var u=i;u=o;u--)if(a(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(a){if(this.length+a.length<=Cf)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=Cf)return new e(a.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Hn);Hn.empty=new RC([]);var mz=(function(t){function e(n,s){t.call(this),this.left=n,this.right=s,this.length=n.length+s.length,this.depth=Math.max(n.depth,s.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return sc&&this.right.forEachInner(s,Math.max(a-c,0),Math.min(this.length,i)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(s,a,i,o){var c=this.left.length;if(a>c&&this.right.forEachInvertedInner(s,a-c,Math.max(i,c)-c,o+c)===!1||i=i?this.right.slice(s-i,a-i):this.left.slice(s,i).append(this.right.slice(0,a-i))},e.prototype.leafAppend=function(s){var a=this.right.leafAppend(s);if(a)return new e(this.left,a)},e.prototype.leafPrepend=function(s){var a=this.left.leafPrepend(s);if(a)return new e(a,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e})(Hn);const gz=500;class Mr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let a,i;n&&(a=this.remapping(s,this.items.length),i=a.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){a||(a=this.remapping(s,g+1),i=a.maps.length),i--,f.push(m);return}if(a){f.push(new yi(m.map));let y=m.step.map(a.slice(i)),N;y&&o.maybeStep(y).doc&&(N=o.mapping.maps[o.mapping.maps.length-1],h.push(new yi(N,void 0,void 0,h.length+f.length))),i--,N&&a.appendMap(N,i)}else o.maybeStep(m.step);if(m.selection)return c=a?m.selection.map(a.slice(i)):m.selection,u=new Mr(this.items.slice(0,s).append(f.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:c}}addTransform(e,n,s,a){let i=[],o=this.eventCount,c=this.items,u=!a&&c.length?c.get(c.length-1):null;for(let f=0;fyz&&(c=xz(c,h),o-=h),new Mr(c.append(i),o)}remapping(e,n){let s=new Md;return this.items.forEach((a,i)=>{let o=a.mirrorOffset!=null&&i-a.mirrorOffset>=e?s.maps.length-a.mirrorOffset:void 0;s.appendMap(a.map,o)},e,n),s}addMaps(e){return this.eventCount==0?this:new Mr(this.items.append(e.map(n=>new yi(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let s=[],a=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},a);let u=n;this.items.forEach(g=>{let y=i.getMirror(--u);if(y==null)return;o=Math.min(o,y);let N=i.maps[y];if(g.step){let j=e.steps[y].invert(e.docs[y]),v=g.selection&&g.selection.map(i.slice(u+1,y));v&&c++,s.push(new yi(N,j,v))}else s.push(new yi(N))},a);let h=[];for(let g=n;ggz&&(m=m.compress(this.items.length-s.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),s=n.maps.length,a=[],i=0;return this.items.forEach((o,c)=>{if(c>=e)a.push(o),o.selection&&i++;else if(o.step){let u=o.step.map(n.slice(s)),h=u&&u.getMap();if(s--,h&&n.appendMap(h,s),u){let f=o.selection&&o.selection.map(n.slice(s));f&&i++;let m=new yi(h.invert(),u,f),g,y=a.length-1;(g=a.length&&a[y].merge(m))?a[y]=g:a.push(m)}}else o.map&&s--},this.items.length,0),new Mr(Hn.from(a.reverse()),i)}}Mr.empty=new Mr(Hn.empty,0);function xz(t,e){let n;return t.forEach((s,a)=>{if(s.selection&&e--==0)return n=a,!1}),t.slice(n)}let yi=class PC{constructor(e,n,s,a){this.map=e,this.step=n,this.selection=s,this.mirrorOffset=a}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new PC(n.getMap().invert(),n,this.selection)}}};class ji{constructor(e,n,s,a,i){this.done=e,this.undone=n,this.prevRanges=s,this.prevTime=a,this.prevComposition=i}}const yz=20;function bz(t,e,n,s){let a=n.getMeta(Do),i;if(a)return a.historyState;n.getMeta(wz)&&(t=new ji(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Do))return o.getMeta(Do).redo?new ji(t.done.addTransform(n,void 0,s,Sh(e)),t.undone,QN(n.mapping.maps),t.prevTime,t.prevComposition):new ji(t.done,t.undone.addTransform(n,void 0,s,Sh(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),u=t.prevTime==0||!o&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-s.newGroupDelay||!vz(n,t.prevRanges)),h=o?Rg(t.prevRanges,n.mapping):QN(n.mapping.maps);return new ji(t.done.addTransform(n,u?e.selection.getBookmark():void 0,s,Sh(e)),Mr.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new ji(t.done.rebased(n,i),t.undone.rebased(n,i),Rg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ji(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Rg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function vz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((s,a)=>{for(let i=0;i=e[i]&&(n=!0)}),n}function QN(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((s,a,i,o)=>e.push(i,o));return e}function Rg(t,e){if(!t)return null;let n=[];for(let s=0;s{let a=Do.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(s){let i=Nz(a,n,t);i&&s(e?i.scrollIntoView():i)}return!0}}const DC=OC(!1,!0),LC=OC(!0,!0);gn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const s=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(s)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Wt({key:new nn("characterCount"),appendTransaction:(e,n,s)=>{if(t)return;const a=this.options.limit;if(a==null||a===0){t=!0;return}const i=this.storage.characters({node:s.doc});if(i>a){const o=i-a,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${a} characters. Content was automatically trimmed.`);const h=s.tr.deleteRange(c,u);return t=!0,h}t=!0},filterTransaction:(e,n)=>{const s=this.options.limit;if(!e.docChanged||s===0||s===null||s===void 0)return!0;const a=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=s||a>s&&i>s&&i<=a)return!0;if(a>s&&i>s&&i>a||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=i-s,h=c-u,f=c;return e.deleteRange(h,f),!(this.storage.characters({node:e.doc})>s)}})]}});var kz=gn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[iz(this.options)]}});gn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Wt({key:new nn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:s}=this.editor,{anchor:a}=e,i=[];if(!n||!s)return zt.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,h)=>{if(u.isText)return;if(!(a>=h&&a<=h+u.nodeSize-1))return!1;o+=1});let c=0;return t.descendants((u,h)=>{if(u.isText||!(a>=h&&a<=h+u.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&o-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";i.push(Ln.node(h,h+u.nodeSize,{class:this.options.className}))}),zt.create(t,i)}}})]}});var Sz=gn.create({name:"gapCursor",addProseMirrorPlugins(){return[dz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=kt(Ge(t,"allowGapCursor",n)))!=null?e:null}}}),ZN="placeholder";function Cz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Ez=gn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:ZN,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Cz(this.options.dataAttribute)}`:`data-${ZN}`;return[new Wt({key:new nn("placeholder"),props:{decorations:({doc:e,selection:n})=>{const s=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:a}=n,i=[];if(!s)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=a>=u&&a<=u+c.nodeSize,f=!c.isLeaf&&ep(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=Ln.node(u,u+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:u,hasAnchor:h}):this.options.placeholder});i.push(g)}return this.options.includeChildren}),zt.create(e,i)}}})]}});gn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Wt({key:new nn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||F2(n.selection)||t.view.dragging?null:zt.create(n.doc,[Ln.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function ew({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Tz=gn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new nn(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",s=Object.entries(this.editor.schema.nodes).map(([,a])=>a).filter(a=>(this.options.notAfter||[]).concat(n).includes(a.name));return[new Wt({key:e,appendTransaction:(a,i,o)=>{const{doc:c,tr:u,schema:h}=o,f=e.getState(o),m=c.content.size,g=h.nodes[n];if(f)return u.insert(m,g.create())},state:{init:(a,i)=>{const o=i.tr.doc.lastChild;return!ew({node:o,types:s})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!ew({node:o,types:s})}}})]}}),Mz=gn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>DC(t,e),redo:()=>({state:t,dispatch:e})=>LC(t,e)}},addProseMirrorPlugins(){return[jz(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Az=gn.create({name:"starterKit",addExtensions(){var t,e,n,s;const a=[];return this.options.bold!==!1&&a.push(e7.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(J_.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(NC.configure(this.options.bulletList)),this.options.code!==!1&&a.push(s7.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(i7.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(o7.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(kz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Sz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(l7.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(c7.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(Mz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(d7.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(m7.configure(this.options.italic)),this.options.listItem!==!1&&a.push(wC.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(TC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(F7.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(AC.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(ez.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(sz.configure(this.options.strike)),this.options.text!==!1&&a.push(rz.configure(this.options.text)),this.options.underline!==!1&&a.push(az.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push(Tz.configure((s=this.options)==null?void 0:s.trailingNode)),a}}),Iz=Az,Rz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Pz=Mn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Et(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,s,a,i,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(a=(s=t.attrs)==null?void 0:s.alt)!=null?a:"",h=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return h?`![${u}](${c} "${h}")`:`![${u}](${c})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:s}=this.options.resize;return({node:a,getPos:i,HTMLAttributes:o,editor:c})=>{const u=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,g);break}}),u.src=o.src;const h=new L6({element:u,editor:c,node:a,getPos:i,onResize:(m,g)=>{u.style.width=`${m}px`,u.style.height=`${g}px`},onCommit:(m,g)=>{const y=i();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===a.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:s===!0}}),f=h.dom;return f.style.visibility="hidden",f.style.pointerEvents="none",u.onload=()=>{f.style.visibility="",f.style.pointerEvents=""},h}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[sC({find:Rz,type:this.type,getAttributes:t=>{const[,,e,n,s]=t;return{src:n,alt:e,title:s}}})]}}),Oz=Pz;function Dz(t){var e;const{char:n,allowSpaces:s,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=s&&!a,h=z6(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=a?"":h,y=u?new RegExp(`${m}${h}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${g}]*`,"gm"),N=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!N)return null;const j=c.pos-N.length,v=Array.from(N.matchAll(y)).pop();if(!v||v.input===void 0||v.index===void 0)return null;const k=v.input.slice(Math.max(0,v.index-1),v.index),C=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!C)return null;const E=j+v.index;let M=E+v[0].length;return u&&f.test(N.slice(M-1,M+1))&&(v[0]+=" ",M+=1),E=c.pos?{range:{from:E,to:M},query:v[0].slice(n.length),text:v[0]}:null}var Lz=new nn("suggestion");function _z({pluginKey:t=Lz,editor:e,char:n="@",allowSpaces:s=!1,allowToIncludeChar:a=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:c="span",decorationClass:u="suggestion",decorationContent:h="",decorationEmptyClass:f="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:N=()=>!0,findSuggestionMatch:j=Dz,shouldShow:v}){let k;const C=y==null?void 0:y(),E=()=>{const L=e.state.selection.$anchor.pos,R=e.view.coordsAtPos(L),{top:O,right:ne,bottom:ie,left:_}=R;try{return new DOMRect(_,O,ne-_,ie-O)}catch{return null}},M=(L,R)=>R?()=>{const O=t.getState(e.state),ne=O==null?void 0:O.decorationId,ie=L.dom.querySelector(`[data-decoration-id="${ne}"]`);return(ie==null?void 0:ie.getBoundingClientRect())||null}:E;function P(L,R){var O;try{const ie=t.getState(L.state),_=ie!=null&&ie.decorationId?L.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`):null,ce={editor:e,range:(ie==null?void 0:ie.range)||{from:0,to:0},query:(ie==null?void 0:ie.query)||null,text:(ie==null?void 0:ie.text)||null,items:[],command:pe=>m({editor:e,range:(ie==null?void 0:ie.range)||{from:0,to:0},props:pe}),decorationNode:_,clientRect:M(L,_)};(O=C==null?void 0:C.onExit)==null||O.call(C,ce)}catch{}const ne=L.state.tr.setMeta(R,{exit:!0});L.dispatch(ne)}const H=new Wt({key:t,view(){return{update:async(L,R)=>{var O,ne,ie,_,ce,pe,z;const q=(O=this.key)==null?void 0:O.getState(R),F=(ne=this.key)==null?void 0:ne.getState(L.state),A=q.active&&F.active&&q.range.from!==F.range.from,J=!q.active&&F.active,U=q.active&&!F.active,D=!J&&!U&&q.query!==F.query,W=J||A&&D,le=D||A,xe=U||A&&D;if(!W&&!le&&!xe)return;const Me=xe&&!W?q:F,te=L.dom.querySelector(`[data-decoration-id="${Me.decorationId}"]`);k={editor:e,range:Me.range,query:Me.query,text:Me.text,items:[],command:K=>m({editor:e,range:Me.range,props:K}),decorationNode:te,clientRect:M(L,te)},W&&((ie=C==null?void 0:C.onBeforeStart)==null||ie.call(C,k)),le&&((_=C==null?void 0:C.onBeforeUpdate)==null||_.call(C,k)),(le||W)&&(k.items=await g({editor:e,query:Me.query})),xe&&((ce=C==null?void 0:C.onExit)==null||ce.call(C,k)),le&&((pe=C==null?void 0:C.onUpdate)==null||pe.call(C,k)),W&&((z=C==null?void 0:C.onStart)==null||z.call(C,k))},destroy:()=>{var L;k&&((L=C==null?void 0:C.onExit)==null||L.call(C,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(L,R,O,ne){const{isEditable:ie}=e,{composing:_}=e.view,{selection:ce}=L,{empty:pe,from:z}=ce,q={...R},F=L.getMeta(t);if(F&&F.exit)return q.active=!1,q.decorationId=null,q.range={from:0,to:0},q.query=null,q.text=null,q;if(q.composing=_,ie&&(pe||e.view.composing)){(zR.range.to)&&!_&&!R.composing&&(q.active=!1);const A=j({char:n,allowSpaces:s,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:ce.$from}),J=`id_${Math.floor(Math.random()*4294967295)}`;A&&N({editor:e,state:ne,range:A.range,isActive:R.active})&&(!v||v({editor:e,range:A.range,query:A.query,text:A.text,transaction:L}))?(q.active=!0,q.decorationId=R.decorationId?R.decorationId:J,q.range=A.range,q.query=A.query,q.text=A.text):q.active=!1}else q.active=!1;return q.active||(q.decorationId=null,q.range={from:0,to:0},q.query=null,q.text=null),q}},props:{handleKeyDown(L,R){var O,ne,ie,_;const{active:ce,range:pe}=H.getState(L.state);if(!ce)return!1;if(R.key==="Escape"||R.key==="Esc"){const q=H.getState(L.state),F=(O=k==null?void 0:k.decorationNode)!=null?O:null,A=F??(q!=null&&q.decorationId?L.dom.querySelector(`[data-decoration-id="${q.decorationId}"]`):null);if(((ne=C==null?void 0:C.onKeyDown)==null?void 0:ne.call(C,{view:L,event:R,range:q.range}))||!1)return!0;const U={editor:e,range:q.range,query:q.query,text:q.text,items:[],command:D=>m({editor:e,range:q.range,props:D}),decorationNode:A,clientRect:A?()=>A.getBoundingClientRect()||null:null};return(ie=C==null?void 0:C.onExit)==null||ie.call(C,U),P(L,t),!0}return((_=C==null?void 0:C.onKeyDown)==null?void 0:_.call(C,{view:L,event:R,range:pe}))||!1},decorations(L){const{active:R,range:O,decorationId:ne,query:ie}=H.getState(L);if(!R)return null;const _=!(ie!=null&&ie.length),ce=[u];return _&&ce.push(f),zt.create(L.doc,[Ln.inline(O.from,O.to,{nodeName:c,class:ce.join(" "),"data-decoration-id":ne,"data-decoration-content":h})])}}});return H}function zz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:s="@"}){const a=new nn;return{editor:t,char:s,pluginKey:a,command:({editor:i,range:o,props:c})=>{var u,h,f;const m=i.view.state.selection.$to.nodeAfter;((u=m==null?void 0:m.text)==null?void 0:u.startsWith(" "))&&(o.to+=1),i.chain().focus().insertContentAt(o,[{type:n,attrs:{...c,mentionSuggestionChar:s}},{type:"text",text:" "}]).run(),(f=(h=i.view.dom.ownerDocument.defaultView)==null?void 0:h.getSelection())==null||f.collapseToEnd()},allow:({state:i,range:o})=>{const c=i.doc.resolve(o.from),u=i.schema.nodes[n];return!!c.parent.type.contentMatch.matchType(u)},...e}}function _C(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>zz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function tw(t,e){const n=_C(t),s=n.find(a=>a.char===e);return s||(n.length?n[0]:null)}var $z=Mn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,s;return`${(n=e==null?void 0:e.char)!=null?n:"@"}${(s=t.attrs.label)!=null?s:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var s,a;return["span",Et(this.HTMLAttributes,t.HTMLAttributes),`${(s=n==null?void 0:n.char)!=null?s:"@"}${(a=e.attrs.label)!=null?a:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=tw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Et({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const s={...this.options};s.HTMLAttributes=Et({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:s,node:t,suggestion:n});return typeof a=="string"?["span",Et({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...rC({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let s=n.exec(t);for(;s!==null;){const[,a,i,o]=s,c=i??o;e[a==="char"?"mentionSuggestionChar":a]=c,s=n.exec(t)}return e},serializeAttributes:t=>Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e==="mentionSuggestionChar"?"char":e}="${n}"`).join(" ")}),renderText({node:t}){const e={options:this.options,node:t,suggestion:tw(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:s}=e,{empty:a,anchor:i}=s;if(!a)return!1;let o=new Ba,c=0;return e.doc.nodesBetween(i-1,i,(u,h)=>{if(u.type.name===this.name)return n=!0,o=u,c=h,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":o.attrs.mentionSuggestionChar,c,c+o.nodeSize),n})}},addProseMirrorPlugins(){return _C(this).map(_z)}}),Fz=$z,Bz=Ez;let _x,zx;if(typeof WeakMap<"u"){let t=new WeakMap;_x=e=>t.get(e),zx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;_x=s=>{for(let a=0;a(n==10&&(n=0),t[n++]=s,t[n++]=a)}var mn=class{constructor(t,e,n,s){this.width=t,this.height=e,this.map=n,this.problems=s}findCell(t){for(let e=0;e=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:k-E});break}const M=a+E*e;for(let P=0;Ps&&(i+=h.attrs.colspan)}}for(let o=0;o1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Wz(t,e,n){t.problems||(t.problems=[]);const s={};for(let a=0;a0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Kz(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Dr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function rp(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Wo(e.$head)||qz(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function qz(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function $x(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Gz(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function cy(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function zC(t,e,n){const s=t.node(-1),a=mn.get(s),i=t.start(-1),o=a.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Uo(t,e,n=1){const s={...t,colspan:t.colspan-n};return s.colwidth&&(s.colwidth=s.colwidth.slice(),s.colwidth.splice(e,n),s.colwidth.some(a=>a>0)||(s.colwidth=null)),s}function $C(t,e,n=1){const s={...t,colspan:t.colspan+n};if(s.colwidth){s.colwidth=s.colwidth.slice();for(let a=0;af!=n.pos-i);u.unshift(n.pos-i);const h=u.map(f=>{const m=s.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=i+f+1;return new TS(c.resolve(g),c.resolve(g+m.content.size))});super(h[0].$from,h[0].$to,h),this.$anchorCell=e,this.$headCell=n}map(e,n){const s=e.resolve(n.map(this.$anchorCell.pos)),a=e.resolve(n.map(this.$headCell.pos));if($x(s)&&$x(a)&&cy(s,a)){const i=this.$anchorCell.node(-1)!=s.node(-1);return i&&this.isRowSelection()?La.rowSelection(s,a):i&&this.isColSelection()?La.colSelection(s,a):new La(s,a)}return Ze.between(s,a)}content(){const e=this.$anchorCell.node(-1),n=mn.get(e),s=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s),i={},o=[];for(let u=a.top;u0||v>0){let k=N.attrs;if(j>0&&(k=Uo(k,0,j)),v>0&&(k=Uo(k,k.colspan-v,v)),y.lefta.bottom){const k={...N.attrs,rowspan:Math.min(y.bottom,a.bottom)-Math.max(y.top,a.top)};y.top0)return!1;const s=e+this.$anchorCell.nodeAfter.attrs.rowspan,a=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(s,a)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const s=e.node(-1),a=mn.get(s),i=e.start(-1),o=a.findCell(e.pos-i),c=a.findCell(n.pos-i),u=e.node(0);return o.top<=c.top?(o.top>0&&(e=u.resolve(i+a.map[o.left])),c.bottom0&&(n=u.resolve(i+a.map[c.left])),o.bottom0)return!1;const o=a+this.$anchorCell.nodeAfter.attrs.colspan,c=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,c)==n.width}eq(e){return e instanceof La&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const s=e.node(-1),a=mn.get(s),i=e.start(-1),o=a.findCell(e.pos-i),c=a.findCell(n.pos-i),u=e.node(0);return o.left<=c.left?(o.left>0&&(e=u.resolve(i+a.map[o.top*a.width])),c.right0&&(n=u.resolve(i+a.map[c.top*a.width])),o.right{e.push(Ln.node(s,s+n.nodeSize,{class:"selectedCell"}))}),zt.create(t.doc,e)}function Xz({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(a+1)=0&&!(e.before(i+1)>e.start(i));i--,s--);return n==s&&/row|table/.test(t.node(a).type.spec.tableRole)}function Zz({$from:t,$to:e}){let n,s;for(let a=t.depth;a>0;a--){const i=t.node(a);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let a=e.depth;a>0;a--){const i=e.node(a);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){s=i;break}}return n!==s&&e.parentOffset===0}function e$(t,e,n){const s=(e||t).selection,a=(e||t).doc;let i,o;if(s instanceof Xe&&(o=s.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Ht.create(a,s.from);else if(o=="row"){const c=a.resolve(s.from+1);i=Ht.rowSelection(c,c)}else if(!n){const c=mn.get(s.node),u=s.from+1,h=u+c.map[c.width*c.height-1];i=Ht.create(a,u+1,h)}}else s instanceof Ze&&Xz(s)?i=Ze.create(a,s.from):s instanceof Ze&&Zz(s)&&(i=Ze.create(a,s.$from.start(),s.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const t$=new nn("fix-tables");function BC(t,e,n,s){const a=t.childCount,i=e.childCount;e:for(let o=0,c=0;o{a.type.spec.tableRole=="table"&&(n=n$(t,a,i,n))};return e?e.doc!=t.doc&&BC(e.doc,t.doc,0,s):t.doc.descendants(s),n}function n$(t,e,n,s){const a=mn.get(e);if(!a.problems)return s;s||(s=t.tr);const i=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const N=[];for(let v=0;v0?-1:0;Jz(e,s,a+i)&&(i=a==0||a==e.width?null:0);for(let o=0;o0&&a0&&e.map[c-1]==u||a0?-1:0;o$(e,s,a+c)&&(c=a==0||a==e.height?null:0);for(let h=0,f=e.width*a;h0&&a0&&m==e.map[f-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+s),null,{...g,rowspan:g.rowspan-1}),h+=g.colspan-1}else if(a0&&n[i]==n[i-1]||s.right0&&n[a]==n[a-t]||s.bottom0){const f=u+1+h.content.size,m=nw(h)?u+1:f;i.replaceWith(m+s.tableStart,f+s.tableStart,c)}i.setSelection(new Ht(i.doc.resolve(u+s.tableStart))),e(i)}return!0}function rw(t,e){const n=ms(t.schema);return f$(({node:s})=>n[s.type.spec.tableRole])(t,e)}function f$(t){return(e,n)=>{const s=e.selection;let a,i;if(s instanceof Ht){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;a=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{var o;if(a=Kz(s.$from),!a)return!1;i=(o=Wo(s.$from))===null||o===void 0?void 0:o.pos}if(a==null||i==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(n){let c=a.attrs;const u=[],h=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const f=la(e),m=e.tr;for(let y=0;y{o.attrs[t]!==e&&i.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:e}),s(i)}return!0}}function m$(t){return function(e,n){if(!Dr(e))return!1;if(n){const s=ms(e.schema),a=la(e),i=e.tr,o=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),c=o.map(u=>a.table.nodeAt(u));for(let u=0;u{const y=g+i.tableStart,N=o.doc.nodeAt(y);N&&o.setNodeMarkup(y,m,N.attrs)}),s(o)}return!0}}zd("row",{useDeprecatedLogic:!0});zd("column",{useDeprecatedLogic:!0});const g$=zd("cell",{useDeprecatedLogic:!0});function x$(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let s=t.index(-1)-1,a=t.before();s>=0;s--){const i=t.node(-1).child(s),o=i.lastChild;if(o)return a-1-o.nodeSize;a-=i.nodeSize}}else{if(t.index()0;s--)if(n.node(s).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(s),n.after(s)).scrollIntoView()),!0;return!1}function ph(t,e){const n=t.selection;if(!(n instanceof Ht))return!1;if(e){const s=t.tr,a=ms(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(a)||s.replace(s.mapping.map(o+1),s.mapping.map(o+i.nodeSize-1),new Oe(a,0,0))}),s.docChanged&&e(s)}return!0}function b$(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:s}=t;for(;e.childCount==1&&(n>0&&s>0||e.child(0).type.spec.tableRole=="table");)n--,s--,e=e.child(0).content;const a=e.child(0),i=a.type.spec.tableRole,o=a.type.schema,c=[];if(i=="row")for(let u=0;u=0;o--){const{rowspan:c,colspan:u}=i.child(o).attrs;for(let h=a;h=e.length&&e.push(Ne.empty),n[a]s&&(g=g.type.createChecked(Uo(g.attrs,g.attrs.colspan,f+g.attrs.colspan-s),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;ya&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,a-m.attrs.rowspan)},m.content)),u.push(m)}i.push(Ne.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function w$(t,e,n,s,a,i,o){const c=t.doc.type.schema,u=ms(c);let h,f;if(a>e.width)for(let m=0,g=0;me.height){const m=[];for(let N=0,j=(e.height-1)*e.width;N=e.width?!1:n.nodeAt(e.map[j+N]).type==u.header_cell;m.push(v?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,Ne.from(m)),y=[];for(let N=e.height;N{if(!a)return!1;const i=n.selection;if(i instanceof Ht)return Ch(n,s,rt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=UC(a,t,e);if(o==null)return!1;if(t=="horiz")return Ch(n,s,rt.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=zC(c,t,e);let h;return u?h=rt.near(u,1):e<0?h=rt.near(n.doc.resolve(c.before(-1)),-1):h=rt.near(n.doc.resolve(c.after(-1)),1),Ch(n,s,h)}}}function gh(t,e){return(n,s,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof Ht)o=i;else{const u=UC(a,t,e);if(u==null)return!1;o=new Ht(n.doc.resolve(u))}const c=zC(o.$headCell,t,e);return c?Ch(n,s,new Ht(o.$anchorCell,c)):!1}}function k$(t,e){const n=t.state.doc,s=Wo(n.resolve(e));return s?(t.dispatch(t.state.tr.setSelection(new Ht(s))),!0):!1}function S$(t,e,n){if(!Dr(t.state))return!1;let s=b$(n);const a=t.state.selection;if(a instanceof Ht){s||(s={width:1,height:1,rows:[Ne.from(Fx(ms(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=mn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return s=N$(s,c.right-c.left,c.bottom-c.top),cw(t.state,t.dispatch,o,c,s),!0}else if(s){const i=rp(t.state),o=i.start(-1);return cw(t.state,t.dispatch,o,mn.get(i.node(-1)).findCell(i.pos-o),s),!0}else return!1}function C$(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const s=dw(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof Ht)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&s&&(a=Wo(t.state.selection.$anchor))!=null&&((n=Og(t,e))===null||n===void 0?void 0:n.pos)!=a.pos)i(a,e),e.preventDefault();else if(!s)return;function i(u,h){let f=Og(t,h);const m=Ci.getState(t.state)==null;if(!f||!cy(u,f))if(m)f=u;else return;const g=new Ht(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(Ci,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),Ci.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Ci,-1))}function c(u){const h=u,f=Ci.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(dw(t,h.target)!=s&&(m=Og(t,e),!m))return o();m&&i(m,h)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",c)}function UC(t,e,n){if(!(t.state.selection instanceof Ze))return null;const{$head:s}=t.state.selection;for(let a=s.depth-1;a>=0;a--){const i=s.node(a);if((n<0?s.index(a):s.indexAfter(a))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=s.before(a),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function dw(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Og(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:s,pos:a}=n;return s>=0&&Wo(t.state.doc.resolve(s))||Wo(t.state.doc.resolve(a))}var E$=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Bx(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Bx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Bx(t,e,n,s,a,i){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;mnew s(m,n,g)),new M$(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=qs.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{A$(o,c,t,a)},mouseleave:o=>{I$(o)},mousedown:(o,c)=>{R$(o,c,e,n)}},decorations:o=>{const c=qs.getState(o);if(c&&c.activeHandle>-1)return _$(o,c.activeHandle)},nodeViews:{}}});return i}var M$=class Eh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,s=e.getMeta(qs);if(s&&s.setHandle!=null)return new Eh(s.setHandle,!1);if(s&&s.setDragging!==void 0)return new Eh(n.activeHandle,s.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return $x(e.doc.resolve(a))||(a=-1),new Eh(a,n.dragging)}return n}};function A$(t,e,n,s){if(!t.editable)return;const a=qs.getState(t.state);if(a&&!a.dragging){const i=O$(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=uw(t,e,"left",n):u-e.clientX<=n&&(o=uw(t,e,"right",n))}if(o!=a.activeHandle){if(!s&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=mn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}KC(t,o)}}}function I$(t){if(!t.editable)return;const e=qs.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&KC(t,-1)}function R$(t,e,n,s){var a;if(!t.editable)return!1;const i=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,o=qs.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=P$(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(qs,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const g=qs.getState(t.state);g!=null&&g.dragging&&(D$(t,g.activeHandle,hw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(qs,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=qs.getState(t.state);if(g&&g.dragging){const y=hw(g.dragging,m,n);fw(t,g.activeHandle,y,s)}}return fw(t,o.activeHandle,u,s),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function P$(t,e,{colspan:n,colwidth:s}){const a=s&&s[s.length-1];if(a)return a;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,c=n;if(s)for(let u=0;u{var e,n;const s=t.getAttribute("colwidth"),a=s?s.split(",").map(i=>parseInt(i,10)):null;if(!a){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const c=i[o].getAttribute("width");return c?[parseInt(c,10)]:null}}return a}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Et(this.options.HTMLAttributes,t),0]}}),GC=Mn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(s=>parseInt(s,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Et(this.options.HTMLAttributes,t),0]}}),JC=Mn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Et(this.options.HTMLAttributes,t),0]}});function Vx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function pw(t,e,n,s,a,i){var o;let c=0,u=!0,h=e.firstChild;const f=t.firstChild;if(f!==null)for(let g=0,y=0;g{const s=t.nodes[n];s.spec.tableRole&&(e[s.spec.tableRole]=s)}),t.cached.tableNodeTypes=e,e}function V$(t,e,n,s,a){const i=B$(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!H$(e))return!1;let n=0;const s=R2(e.ranges[0].$from,i=>i.type.name==="table");return s==null||s.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},W$="";function U$(t){return(t||"").replace(/\s+/g," ").trim()}function K$(t,e,n={}){var s;const a=(s=n.cellLineSeparator)!=null?s:W$;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(N=>{const j=[];N.content&&N.content.forEach(v=>{let k="";v.content&&Array.isArray(v.content)&&v.content.length>1?k=v.content.map(P=>e.renderChildren(P)).join(a):k=v.content?e.renderChildren(v.content):"";const C=U$(k),E=v.type==="tableHeader";j.push({text:C,isHeader:E})}),i.push(j)});const o=i.reduce((N,j)=>Math.max(N,j.length),0);if(o===0)return"";const c=new Array(o).fill(0);i.forEach(N=>{var j;for(let v=0;vc[v]&&(c[v]=C),c[v]<3&&(c[v]=3)}});const u=(N,j)=>N+" ".repeat(Math.max(0,j-N.length)),h=i[0],f=h.some(N=>N.isHeader);let m=` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(J7,this.editor.getAttributes(GN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ql({find:JN,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ql({find:JN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(GN)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Y7=/^\s*(\[([( |x])?\])\s$/,Q7=An.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Et(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const s=e.parseChildren(t.nestedTokens);n.push(...s)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const a=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Y0(t,e,a)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:s})=>{const a=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),h=m=>{var g,y;c.ariaLabel=((y=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:y.call(g,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};h(t),i.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!s.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;s.isEditable&&typeof n=="function"&&s.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const N=n();if(typeof N!="number")return!1;const j=y.doc.nodeAt(N);return y.setNodeMarkup(N,void 0,{...j==null?void 0:j.attrs,checked:g}),!0}).run(),!s.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{a.setAttribute(m,g)}),a.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,o),a.append(i,u),Object.entries(e).forEach(([m,g])=>{a.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:a,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;a.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=s.extensionManager.attributes,y=Dd(m,g),N=new Set(Object.keys(y)),j=this.options.HTMLAttributes;return f.forEach(v=>{N.has(v)||(v in j?a.setAttribute(v,j[v]):a.removeAttribute(v))}),Object.entries(y).forEach(([v,k])=>{k==null?v in j?a.setAttribute(v,j[v]):a.removeAttribute(v):a.setAttribute(v,k)}),f=N,!0}}}},addInputRules(){return[Ql({find:Y7,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),X7=An.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Et(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const s=i=>{const o=Sx(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,u)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:u}),customNestedParser:s},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},a=Sx(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:s},n);if(a)return{type:"taskList",raw:a.raw,items:a.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});gn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(NC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(wC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(TC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(AC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Q7.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(X7.configure(this.options.taskList)),t}});var YN=" ",Z7=" ",ez=An.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Et(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const s=e.parseInline(n);return s.length===1&&s[0].type==="text"&&(s[0].text===YN||s[0].text===Z7)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,s)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?YN:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),tz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,nz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,sz=Yo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Et(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Yl({find:tz,type:this.type})]},addPasteRules(){return[Ho({find:nz,type:this.type})]}}),rz=An.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),az=Yo.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Et(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const a=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!a)return;const i=a[2].trim();return{type:"underline",raw:a[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function iz(t={}){return new qt({view(e){return new oz(e,t)}})}class oz{constructor(e,n){var s;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(s=n.width)!==null&&s!==void 0?s:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let i=o=>{this[a](o)};return e.dom.addEventListener(a,i),{name:a,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,s,a=this.editorView.dom,i=a.getBoundingClientRect(),o=i.width/a.offsetWidth,c=i.height/a.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let N=y.getBoundingClientRect(),j=m?N.bottom:N.top;m&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*c;s={left:N.left,right:N.right,top:j-v,bottom:j+v}}}}if(!s){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;s={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let h,f;if(!u||u==document.body&&getComputedStyle(u).position=="static")h=-pageXOffset,f=-pageYOffset;else{let m=u.getBoundingClientRect(),g=m.width/u.offsetWidth,y=m.height/u.offsetHeight;h=m.left-u.scrollLeft*g,f=m.top-u.scrollTop*y}this.element.style.left=(s.left-h)/o+"px",this.element.style.top=(s.top-f)/c+"px",this.element.style.width=(s.right-s.left)/o+"px",this.element.style.height=(s.bottom-s.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),s=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),a=s&&s.type.spec.disableDropCursor,i=typeof a=="function"?a(this.editorView,n,e):a;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=jS(this.editorView.state.doc,o,this.editorView.dragging.slice);c!=null&&(o=c)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class pn extends nt{constructor(e){super(e,e)}map(e,n){let s=e.resolve(n.map(this.head));return pn.valid(s)?new pn(s):nt.near(s)}content(){return Oe.empty}eq(e){return e instanceof pn&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new pn(e.resolve(n.pos))}getBookmark(){return new ly(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!lz(e)||!cz(e))return!1;let s=n.type.spec.allowGapCursor;if(s!=null)return s;let a=n.contentMatchAt(e.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(e,n,s=!1){e:for(;;){if(!s&&pn.valid(e))return e;let a=e.pos,i=null;for(let o=e.depth;;o--){let c=e.node(o);if(n>0?e.indexAfter(o)0){i=c.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;a+=n;let u=e.doc.resolve(a);if(pn.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Qe.isSelectable(i)){e=e.doc.resolve(a+i.nodeSize*n),s=!1;continue e}break}i=o,a+=n;let c=e.doc.resolve(a);if(pn.valid(c))return c}return null}}}pn.prototype.visible=!1;pn.findFrom=pn.findGapCursorFrom;nt.jsonID("gapcursor",pn);class ly{constructor(e){this.pos=e}map(e){return new ly(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return pn.valid(n)?new pn(n):nt.near(n)}}function IC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function lz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),s=t.node(e);if(n==0){if(s.type.spec.isolating)return!0;continue}for(let a=s.child(n-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||IC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function cz(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),s=t.node(e);if(n==s.childCount){if(s.type.spec.isolating)return!0;continue}for(let a=s.child(n);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||IC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function dz(){return new qt({props:{decorations:pz,createSelectionBetween(t,e,n){return e.pos==n.pos&&pn.valid(n)?new pn(n):null},handleClick:hz,handleKeyDown:uz,handleDOMEvents:{beforeinput:fz}}})}const uz=$0({ArrowLeft:fh("horiz",-1),ArrowRight:fh("horiz",1),ArrowUp:fh("vert",-1),ArrowDown:fh("vert",1)});function fh(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(s,a,i){let o=s.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof Xe){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=s.doc.resolve(e>0?c.after():c.before())}let h=pn.findGapCursorFrom(c,e,u);return h?(a&&a(s.tr.setSelection(new pn(h))),!0):!1}}function hz(t,e,n){if(!t||!t.editable)return!1;let s=t.state.doc.resolve(e);if(!pn.valid(s))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&Qe.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new pn(s))),!0)}function fz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof pn))return!1;let{$from:n}=t.state.selection,s=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!s)return!1;let a=Ne.empty;for(let o=s.length-1;o>=0;o--)a=Ne.from(s[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new Oe(a,0,0));return i.setSelection(Xe.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function pz(t){if(!(t.selection instanceof pn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Bt.create(t.doc,[Ln.widget(t.selection.head,e,{key:"gapcursor"})])}var Cf=200,Wn=function(){};Wn.prototype.append=function(e){return e.length?(e=Wn.from(e),!this.length&&e||e.length=n?Wn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Wn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Wn.prototype.forEach=function(e,n,s){n===void 0&&(n=0),s===void 0&&(s=this.length),n<=s?this.forEachInner(e,n,s,0):this.forEachInvertedInner(e,n,s,0)};Wn.prototype.map=function(e,n,s){n===void 0&&(n=0),s===void 0&&(s=this.length);var a=[];return this.forEach(function(i,o){return a.push(e(i,o))},n,s),a};Wn.from=function(e){return e instanceof Wn?e:e&&e.length?new RC(e):Wn.empty};var RC=(function(t){function e(s){t.call(this),this.values=s}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(a,i){return a==0&&i==this.length?this:new e(this.values.slice(a,i))},e.prototype.getInner=function(a){return this.values[a]},e.prototype.forEachInner=function(a,i,o,c){for(var u=i;u=o;u--)if(a(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(a){if(this.length+a.length<=Cf)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=Cf)return new e(a.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Wn);Wn.empty=new RC([]);var mz=(function(t){function e(n,s){t.call(this),this.left=n,this.right=s,this.length=n.length+s.length,this.depth=Math.max(n.depth,s.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return sc&&this.right.forEachInner(s,Math.max(a-c,0),Math.min(this.length,i)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(s,a,i,o){var c=this.left.length;if(a>c&&this.right.forEachInvertedInner(s,a-c,Math.max(i,c)-c,o+c)===!1||i=i?this.right.slice(s-i,a-i):this.left.slice(s,i).append(this.right.slice(0,a-i))},e.prototype.leafAppend=function(s){var a=this.right.leafAppend(s);if(a)return new e(this.left,a)},e.prototype.leafPrepend=function(s){var a=this.left.leafPrepend(s);if(a)return new e(a,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e})(Wn);const gz=500;class Ar{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let a,i;n&&(a=this.remapping(s,this.items.length),i=a.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){a||(a=this.remapping(s,g+1),i=a.maps.length),i--,f.push(m);return}if(a){f.push(new bi(m.map));let y=m.step.map(a.slice(i)),N;y&&o.maybeStep(y).doc&&(N=o.mapping.maps[o.mapping.maps.length-1],h.push(new bi(N,void 0,void 0,h.length+f.length))),i--,N&&a.appendMap(N,i)}else o.maybeStep(m.step);if(m.selection)return c=a?m.selection.map(a.slice(i)):m.selection,u=new Ar(this.items.slice(0,s).append(f.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:c}}addTransform(e,n,s,a){let i=[],o=this.eventCount,c=this.items,u=!a&&c.length?c.get(c.length-1):null;for(let f=0;fyz&&(c=xz(c,h),o-=h),new Ar(c.append(i),o)}remapping(e,n){let s=new Md;return this.items.forEach((a,i)=>{let o=a.mirrorOffset!=null&&i-a.mirrorOffset>=e?s.maps.length-a.mirrorOffset:void 0;s.appendMap(a.map,o)},e,n),s}addMaps(e){return this.eventCount==0?this:new Ar(this.items.append(e.map(n=>new bi(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let s=[],a=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},a);let u=n;this.items.forEach(g=>{let y=i.getMirror(--u);if(y==null)return;o=Math.min(o,y);let N=i.maps[y];if(g.step){let j=e.steps[y].invert(e.docs[y]),v=g.selection&&g.selection.map(i.slice(u+1,y));v&&c++,s.push(new bi(N,j,v))}else s.push(new bi(N))},a);let h=[];for(let g=n;ggz&&(m=m.compress(this.items.length-s.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),s=n.maps.length,a=[],i=0;return this.items.forEach((o,c)=>{if(c>=e)a.push(o),o.selection&&i++;else if(o.step){let u=o.step.map(n.slice(s)),h=u&&u.getMap();if(s--,h&&n.appendMap(h,s),u){let f=o.selection&&o.selection.map(n.slice(s));f&&i++;let m=new bi(h.invert(),u,f),g,y=a.length-1;(g=a.length&&a[y].merge(m))?a[y]=g:a.push(m)}}else o.map&&s--},this.items.length,0),new Ar(Wn.from(a.reverse()),i)}}Ar.empty=new Ar(Wn.empty,0);function xz(t,e){let n;return t.forEach((s,a)=>{if(s.selection&&e--==0)return n=a,!1}),t.slice(n)}let bi=class PC{constructor(e,n,s,a){this.map=e,this.step=n,this.selection=s,this.mirrorOffset=a}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new PC(n.getMap().invert(),n,this.selection)}}};class ki{constructor(e,n,s,a,i){this.done=e,this.undone=n,this.prevRanges=s,this.prevTime=a,this.prevComposition=i}}const yz=20;function bz(t,e,n,s){let a=n.getMeta(Do),i;if(a)return a.historyState;n.getMeta(wz)&&(t=new ki(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Do))return o.getMeta(Do).redo?new ki(t.done.addTransform(n,void 0,s,Sh(e)),t.undone,QN(n.mapping.maps),t.prevTime,t.prevComposition):new ki(t.done,t.undone.addTransform(n,void 0,s,Sh(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),u=t.prevTime==0||!o&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-s.newGroupDelay||!vz(n,t.prevRanges)),h=o?Rg(t.prevRanges,n.mapping):QN(n.mapping.maps);return new ki(t.done.addTransform(n,u?e.selection.getBookmark():void 0,s,Sh(e)),Ar.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new ki(t.done.rebased(n,i),t.undone.rebased(n,i),Rg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ki(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Rg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function vz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((s,a)=>{for(let i=0;i=e[i]&&(n=!0)}),n}function QN(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((s,a,i,o)=>e.push(i,o));return e}function Rg(t,e){if(!t)return null;let n=[];for(let s=0;s{let a=Do.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(s){let i=Nz(a,n,t);i&&s(e?i.scrollIntoView():i)}return!0}}const DC=OC(!1,!0),LC=OC(!0,!0);gn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const s=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(s)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new qt({key:new rn("characterCount"),appendTransaction:(e,n,s)=>{if(t)return;const a=this.options.limit;if(a==null||a===0){t=!0;return}const i=this.storage.characters({node:s.doc});if(i>a){const o=i-a,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${a} characters. Content was automatically trimmed.`);const h=s.tr.deleteRange(c,u);return t=!0,h}t=!0},filterTransaction:(e,n)=>{const s=this.options.limit;if(!e.docChanged||s===0||s===null||s===void 0)return!0;const a=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=s||a>s&&i>s&&i<=a)return!0;if(a>s&&i>s&&i>a||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=i-s,h=c-u,f=c;return e.deleteRange(h,f),!(this.storage.characters({node:e.doc})>s)}})]}});var kz=gn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[iz(this.options)]}});gn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new qt({key:new rn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:s}=this.editor,{anchor:a}=e,i=[];if(!n||!s)return Bt.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,h)=>{if(u.isText)return;if(!(a>=h&&a<=h+u.nodeSize-1))return!1;o+=1});let c=0;return t.descendants((u,h)=>{if(u.isText||!(a>=h&&a<=h+u.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&o-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";i.push(Ln.node(h,h+u.nodeSize,{class:this.options.className}))}),Bt.create(t,i)}}})]}});var Sz=gn.create({name:"gapCursor",addProseMirrorPlugins(){return[dz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=St(Ge(t,"allowGapCursor",n)))!=null?e:null}}}),ZN="placeholder";function Cz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Ez=gn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:ZN,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Cz(this.options.dataAttribute)}`:`data-${ZN}`;return[new qt({key:new rn("placeholder"),props:{decorations:({doc:e,selection:n})=>{const s=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:a}=n,i=[];if(!s)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=a>=u&&a<=u+c.nodeSize,f=!c.isLeaf&&ep(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=Ln.node(u,u+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:u,hasAnchor:h}):this.options.placeholder});i.push(g)}return this.options.includeChildren}),Bt.create(e,i)}}})]}});gn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new qt({key:new rn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||$2(n.selection)||t.view.dragging?null:Bt.create(n.doc,[Ln.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function ew({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Tz=gn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new rn(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",s=Object.entries(this.editor.schema.nodes).map(([,a])=>a).filter(a=>(this.options.notAfter||[]).concat(n).includes(a.name));return[new qt({key:e,appendTransaction:(a,i,o)=>{const{doc:c,tr:u,schema:h}=o,f=e.getState(o),m=c.content.size,g=h.nodes[n];if(f)return u.insert(m,g.create())},state:{init:(a,i)=>{const o=i.tr.doc.lastChild;return!ew({node:o,types:s})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!ew({node:o,types:s})}}})]}}),Mz=gn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>DC(t,e),redo:()=>({state:t,dispatch:e})=>LC(t,e)}},addProseMirrorPlugins(){return[jz(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Az=gn.create({name:"starterKit",addExtensions(){var t,e,n,s;const a=[];return this.options.bold!==!1&&a.push(e7.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(J_.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(NC.configure(this.options.bulletList)),this.options.code!==!1&&a.push(s7.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(i7.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(o7.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(kz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Sz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(l7.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(c7.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(Mz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(d7.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(m7.configure(this.options.italic)),this.options.listItem!==!1&&a.push(wC.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(TC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push($7.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(AC.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(ez.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(sz.configure(this.options.strike)),this.options.text!==!1&&a.push(rz.configure(this.options.text)),this.options.underline!==!1&&a.push(az.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push(Tz.configure((s=this.options)==null?void 0:s.trailingNode)),a}}),Iz=Az,Rz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Pz=An.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Et(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,s,a,i,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(a=(s=t.attrs)==null?void 0:s.alt)!=null?a:"",h=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return h?`![${u}](${c} "${h}")`:`![${u}](${c})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:s}=this.options.resize;return({node:a,getPos:i,HTMLAttributes:o,editor:c})=>{const u=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,g);break}}),u.src=o.src;const h=new L6({element:u,editor:c,node:a,getPos:i,onResize:(m,g)=>{u.style.width=`${m}px`,u.style.height=`${g}px`},onCommit:(m,g)=>{const y=i();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===a.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:s===!0}}),f=h.dom;return f.style.visibility="hidden",f.style.pointerEvents="none",u.onload=()=>{f.style.visibility="",f.style.pointerEvents=""},h}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[sC({find:Rz,type:this.type,getAttributes:t=>{const[,,e,n,s]=t;return{src:n,alt:e,title:s}}})]}}),Oz=Pz;function Dz(t){var e;const{char:n,allowSpaces:s,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=s&&!a,h=z6(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=a?"":h,y=u?new RegExp(`${m}${h}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${g}]*`,"gm"),N=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!N)return null;const j=c.pos-N.length,v=Array.from(N.matchAll(y)).pop();if(!v||v.input===void 0||v.index===void 0)return null;const k=v.input.slice(Math.max(0,v.index-1),v.index),C=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!C)return null;const E=j+v.index;let M=E+v[0].length;return u&&f.test(N.slice(M-1,M+1))&&(v[0]+=" ",M+=1),E=c.pos?{range:{from:E,to:M},query:v[0].slice(n.length),text:v[0]}:null}var Lz=new rn("suggestion");function _z({pluginKey:t=Lz,editor:e,char:n="@",allowSpaces:s=!1,allowToIncludeChar:a=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:c="span",decorationClass:u="suggestion",decorationContent:h="",decorationEmptyClass:f="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:N=()=>!0,findSuggestionMatch:j=Dz,shouldShow:v}){let k;const C=y==null?void 0:y(),E=()=>{const L=e.state.selection.$anchor.pos,R=e.view.coordsAtPos(L),{top:O,right:se,bottom:ie,left:z}=R;try{return new DOMRect(z,O,se-z,ie-O)}catch{return null}},M=(L,R)=>R?()=>{const O=t.getState(e.state),se=O==null?void 0:O.decorationId,ie=L.dom.querySelector(`[data-decoration-id="${se}"]`);return(ie==null?void 0:ie.getBoundingClientRect())||null}:E;function P(L,R){var O;try{const ie=t.getState(L.state),z=ie!=null&&ie.decorationId?L.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`):null,ce={editor:e,range:(ie==null?void 0:ie.range)||{from:0,to:0},query:(ie==null?void 0:ie.query)||null,text:(ie==null?void 0:ie.text)||null,items:[],command:me=>m({editor:e,range:(ie==null?void 0:ie.range)||{from:0,to:0},props:me}),decorationNode:z,clientRect:M(L,z)};(O=C==null?void 0:C.onExit)==null||O.call(C,ce)}catch{}const se=L.state.tr.setMeta(R,{exit:!0});L.dispatch(se)}const H=new qt({key:t,view(){return{update:async(L,R)=>{var O,se,ie,z,ce,me,_;const G=(O=this.key)==null?void 0:O.getState(R),$=(se=this.key)==null?void 0:se.getState(L.state),A=G.active&&$.active&&G.range.from!==$.range.from,Y=!G.active&&$.active,U=G.active&&!$.active,D=!Y&&!U&&G.query!==$.query,W=Y||A&&D,le=D||A,ye=U||A&&D;if(!W&&!le&&!ye)return;const Ae=ye&&!W?G:$,ne=L.dom.querySelector(`[data-decoration-id="${Ae.decorationId}"]`);k={editor:e,range:Ae.range,query:Ae.query,text:Ae.text,items:[],command:K=>m({editor:e,range:Ae.range,props:K}),decorationNode:ne,clientRect:M(L,ne)},W&&((ie=C==null?void 0:C.onBeforeStart)==null||ie.call(C,k)),le&&((z=C==null?void 0:C.onBeforeUpdate)==null||z.call(C,k)),(le||W)&&(k.items=await g({editor:e,query:Ae.query})),ye&&((ce=C==null?void 0:C.onExit)==null||ce.call(C,k)),le&&((me=C==null?void 0:C.onUpdate)==null||me.call(C,k)),W&&((_=C==null?void 0:C.onStart)==null||_.call(C,k))},destroy:()=>{var L;k&&((L=C==null?void 0:C.onExit)==null||L.call(C,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(L,R,O,se){const{isEditable:ie}=e,{composing:z}=e.view,{selection:ce}=L,{empty:me,from:_}=ce,G={...R},$=L.getMeta(t);if($&&$.exit)return G.active=!1,G.decorationId=null,G.range={from:0,to:0},G.query=null,G.text=null,G;if(G.composing=z,ie&&(me||e.view.composing)){(_R.range.to)&&!z&&!R.composing&&(G.active=!1);const A=j({char:n,allowSpaces:s,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:ce.$from}),Y=`id_${Math.floor(Math.random()*4294967295)}`;A&&N({editor:e,state:se,range:A.range,isActive:R.active})&&(!v||v({editor:e,range:A.range,query:A.query,text:A.text,transaction:L}))?(G.active=!0,G.decorationId=R.decorationId?R.decorationId:Y,G.range=A.range,G.query=A.query,G.text=A.text):G.active=!1}else G.active=!1;return G.active||(G.decorationId=null,G.range={from:0,to:0},G.query=null,G.text=null),G}},props:{handleKeyDown(L,R){var O,se,ie,z;const{active:ce,range:me}=H.getState(L.state);if(!ce)return!1;if(R.key==="Escape"||R.key==="Esc"){const G=H.getState(L.state),$=(O=k==null?void 0:k.decorationNode)!=null?O:null,A=$??(G!=null&&G.decorationId?L.dom.querySelector(`[data-decoration-id="${G.decorationId}"]`):null);if(((se=C==null?void 0:C.onKeyDown)==null?void 0:se.call(C,{view:L,event:R,range:G.range}))||!1)return!0;const U={editor:e,range:G.range,query:G.query,text:G.text,items:[],command:D=>m({editor:e,range:G.range,props:D}),decorationNode:A,clientRect:A?()=>A.getBoundingClientRect()||null:null};return(ie=C==null?void 0:C.onExit)==null||ie.call(C,U),P(L,t),!0}return((z=C==null?void 0:C.onKeyDown)==null?void 0:z.call(C,{view:L,event:R,range:me}))||!1},decorations(L){const{active:R,range:O,decorationId:se,query:ie}=H.getState(L);if(!R)return null;const z=!(ie!=null&&ie.length),ce=[u];return z&&ce.push(f),Bt.create(L.doc,[Ln.inline(O.from,O.to,{nodeName:c,class:ce.join(" "),"data-decoration-id":se,"data-decoration-content":h})])}}});return H}function zz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:s="@"}){const a=new rn;return{editor:t,char:s,pluginKey:a,command:({editor:i,range:o,props:c})=>{var u,h,f;const m=i.view.state.selection.$to.nodeAfter;((u=m==null?void 0:m.text)==null?void 0:u.startsWith(" "))&&(o.to+=1),i.chain().focus().insertContentAt(o,[{type:n,attrs:{...c,mentionSuggestionChar:s}},{type:"text",text:" "}]).run(),(f=(h=i.view.dom.ownerDocument.defaultView)==null?void 0:h.getSelection())==null||f.collapseToEnd()},allow:({state:i,range:o})=>{const c=i.doc.resolve(o.from),u=i.schema.nodes[n];return!!c.parent.type.contentMatch.matchType(u)},...e}}function _C(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>zz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function tw(t,e){const n=_C(t),s=n.find(a=>a.char===e);return s||(n.length?n[0]:null)}var Fz=An.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,s;return`${(n=e==null?void 0:e.char)!=null?n:"@"}${(s=t.attrs.label)!=null?s:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var s,a;return["span",Et(this.HTMLAttributes,t.HTMLAttributes),`${(s=n==null?void 0:n.char)!=null?s:"@"}${(a=e.attrs.label)!=null?a:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=tw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Et({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const s={...this.options};s.HTMLAttributes=Et({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:s,node:t,suggestion:n});return typeof a=="string"?["span",Et({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...rC({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let s=n.exec(t);for(;s!==null;){const[,a,i,o]=s,c=i??o;e[a==="char"?"mentionSuggestionChar":a]=c,s=n.exec(t)}return e},serializeAttributes:t=>Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e==="mentionSuggestionChar"?"char":e}="${n}"`).join(" ")}),renderText({node:t}){const e={options:this.options,node:t,suggestion:tw(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:s}=e,{empty:a,anchor:i}=s;if(!a)return!1;let o=new Va,c=0;return e.doc.nodesBetween(i-1,i,(u,h)=>{if(u.type.name===this.name)return n=!0,o=u,c=h,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":o.attrs.mentionSuggestionChar,c,c+o.nodeSize),n})}},addProseMirrorPlugins(){return _C(this).map(_z)}}),$z=Fz,Bz=Ez;let _x,zx;if(typeof WeakMap<"u"){let t=new WeakMap;_x=e=>t.get(e),zx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;_x=s=>{for(let a=0;a(n==10&&(n=0),t[n++]=s,t[n++]=a)}var mn=class{constructor(t,e,n,s){this.width=t,this.height=e,this.map=n,this.problems=s}findCell(t){for(let e=0;e=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:k-E});break}const M=a+E*e;for(let P=0;Ps&&(i+=h.attrs.colspan)}}for(let o=0;o1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Wz(t,e,n){t.problems||(t.problems=[]);const s={};for(let a=0;a0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Kz(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Lr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function rp(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Wo(e.$head)||qz(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function qz(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Fx(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Gz(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function cy(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function zC(t,e,n){const s=t.node(-1),a=mn.get(s),i=t.start(-1),o=a.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Uo(t,e,n=1){const s={...t,colspan:t.colspan-n};return s.colwidth&&(s.colwidth=s.colwidth.slice(),s.colwidth.splice(e,n),s.colwidth.some(a=>a>0)||(s.colwidth=null)),s}function FC(t,e,n=1){const s={...t,colspan:t.colspan+n};if(s.colwidth){s.colwidth=s.colwidth.slice();for(let a=0;af!=n.pos-i);u.unshift(n.pos-i);const h=u.map(f=>{const m=s.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=i+f+1;return new TS(c.resolve(g),c.resolve(g+m.content.size))});super(h[0].$from,h[0].$to,h),this.$anchorCell=e,this.$headCell=n}map(e,n){const s=e.resolve(n.map(this.$anchorCell.pos)),a=e.resolve(n.map(this.$headCell.pos));if(Fx(s)&&Fx(a)&&cy(s,a)){const i=this.$anchorCell.node(-1)!=s.node(-1);return i&&this.isRowSelection()?La.rowSelection(s,a):i&&this.isColSelection()?La.colSelection(s,a):new La(s,a)}return Xe.between(s,a)}content(){const e=this.$anchorCell.node(-1),n=mn.get(e),s=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s),i={},o=[];for(let u=a.top;u0||v>0){let k=N.attrs;if(j>0&&(k=Uo(k,0,j)),v>0&&(k=Uo(k,k.colspan-v,v)),y.lefta.bottom){const k={...N.attrs,rowspan:Math.min(y.bottom,a.bottom)-Math.max(y.top,a.top)};y.top0)return!1;const s=e+this.$anchorCell.nodeAfter.attrs.rowspan,a=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(s,a)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const s=e.node(-1),a=mn.get(s),i=e.start(-1),o=a.findCell(e.pos-i),c=a.findCell(n.pos-i),u=e.node(0);return o.top<=c.top?(o.top>0&&(e=u.resolve(i+a.map[o.left])),c.bottom0&&(n=u.resolve(i+a.map[c.left])),o.bottom0)return!1;const o=a+this.$anchorCell.nodeAfter.attrs.colspan,c=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,c)==n.width}eq(e){return e instanceof La&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const s=e.node(-1),a=mn.get(s),i=e.start(-1),o=a.findCell(e.pos-i),c=a.findCell(n.pos-i),u=e.node(0);return o.left<=c.left?(o.left>0&&(e=u.resolve(i+a.map[o.top*a.width])),c.right0&&(n=u.resolve(i+a.map[c.top*a.width])),o.right{e.push(Ln.node(s,s+n.nodeSize,{class:"selectedCell"}))}),Bt.create(t.doc,e)}function Xz({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(a+1)=0&&!(e.before(i+1)>e.start(i));i--,s--);return n==s&&/row|table/.test(t.node(a).type.spec.tableRole)}function Zz({$from:t,$to:e}){let n,s;for(let a=t.depth;a>0;a--){const i=t.node(a);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let a=e.depth;a>0;a--){const i=e.node(a);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){s=i;break}}return n!==s&&e.parentOffset===0}function eF(t,e,n){const s=(e||t).selection,a=(e||t).doc;let i,o;if(s instanceof Qe&&(o=s.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Kt.create(a,s.from);else if(o=="row"){const c=a.resolve(s.from+1);i=Kt.rowSelection(c,c)}else if(!n){const c=mn.get(s.node),u=s.from+1,h=u+c.map[c.width*c.height-1];i=Kt.create(a,u+1,h)}}else s instanceof Xe&&Xz(s)?i=Xe.create(a,s.from):s instanceof Xe&&Zz(s)&&(i=Xe.create(a,s.$from.start(),s.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const tF=new rn("fix-tables");function BC(t,e,n,s){const a=t.childCount,i=e.childCount;e:for(let o=0,c=0;o{a.type.spec.tableRole=="table"&&(n=nF(t,a,i,n))};return e?e.doc!=t.doc&&BC(e.doc,t.doc,0,s):t.doc.descendants(s),n}function nF(t,e,n,s){const a=mn.get(e);if(!a.problems)return s;s||(s=t.tr);const i=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const N=[];for(let v=0;v0?-1:0;Jz(e,s,a+i)&&(i=a==0||a==e.width?null:0);for(let o=0;o0&&a0&&e.map[c-1]==u||a0?-1:0;oF(e,s,a+c)&&(c=a==0||a==e.height?null:0);for(let h=0,f=e.width*a;h0&&a0&&m==e.map[f-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+s),null,{...g,rowspan:g.rowspan-1}),h+=g.colspan-1}else if(a0&&n[i]==n[i-1]||s.right0&&n[a]==n[a-t]||s.bottom0){const f=u+1+h.content.size,m=nw(h)?u+1:f;i.replaceWith(m+s.tableStart,f+s.tableStart,c)}i.setSelection(new Kt(i.doc.resolve(u+s.tableStart))),e(i)}return!0}function rw(t,e){const n=bs(t.schema);return fF(({node:s})=>n[s.type.spec.tableRole])(t,e)}function fF(t){return(e,n)=>{const s=e.selection;let a,i;if(s instanceof Kt){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;a=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{var o;if(a=Kz(s.$from),!a)return!1;i=(o=Wo(s.$from))===null||o===void 0?void 0:o.pos}if(a==null||i==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(n){let c=a.attrs;const u=[],h=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const f=la(e),m=e.tr;for(let y=0;y{o.attrs[t]!==e&&i.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:e}),s(i)}return!0}}function mF(t){return function(e,n){if(!Lr(e))return!1;if(n){const s=bs(e.schema),a=la(e),i=e.tr,o=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),c=o.map(u=>a.table.nodeAt(u));for(let u=0;u{const y=g+i.tableStart,N=o.doc.nodeAt(y);N&&o.setNodeMarkup(y,m,N.attrs)}),s(o)}return!0}}zd("row",{useDeprecatedLogic:!0});zd("column",{useDeprecatedLogic:!0});const gF=zd("cell",{useDeprecatedLogic:!0});function xF(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let s=t.index(-1)-1,a=t.before();s>=0;s--){const i=t.node(-1).child(s),o=i.lastChild;if(o)return a-1-o.nodeSize;a-=i.nodeSize}}else{if(t.index()0;s--)if(n.node(s).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(s),n.after(s)).scrollIntoView()),!0;return!1}function ph(t,e){const n=t.selection;if(!(n instanceof Kt))return!1;if(e){const s=t.tr,a=bs(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(a)||s.replace(s.mapping.map(o+1),s.mapping.map(o+i.nodeSize-1),new Oe(a,0,0))}),s.docChanged&&e(s)}return!0}function bF(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:s}=t;for(;e.childCount==1&&(n>0&&s>0||e.child(0).type.spec.tableRole=="table");)n--,s--,e=e.child(0).content;const a=e.child(0),i=a.type.spec.tableRole,o=a.type.schema,c=[];if(i=="row")for(let u=0;u=0;o--){const{rowspan:c,colspan:u}=i.child(o).attrs;for(let h=a;h=e.length&&e.push(Ne.empty),n[a]s&&(g=g.type.createChecked(Uo(g.attrs,g.attrs.colspan,f+g.attrs.colspan-s),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;ya&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,a-m.attrs.rowspan)},m.content)),u.push(m)}i.push(Ne.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function wF(t,e,n,s,a,i,o){const c=t.doc.type.schema,u=bs(c);let h,f;if(a>e.width)for(let m=0,g=0;me.height){const m=[];for(let N=0,j=(e.height-1)*e.width;N=e.width?!1:n.nodeAt(e.map[j+N]).type==u.header_cell;m.push(v?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,Ne.from(m)),y=[];for(let N=e.height;N{if(!a)return!1;const i=n.selection;if(i instanceof Kt)return Ch(n,s,nt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=UC(a,t,e);if(o==null)return!1;if(t=="horiz")return Ch(n,s,nt.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=zC(c,t,e);let h;return u?h=nt.near(u,1):e<0?h=nt.near(n.doc.resolve(c.before(-1)),-1):h=nt.near(n.doc.resolve(c.after(-1)),1),Ch(n,s,h)}}}function gh(t,e){return(n,s,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof Kt)o=i;else{const u=UC(a,t,e);if(u==null)return!1;o=new Kt(n.doc.resolve(u))}const c=zC(o.$headCell,t,e);return c?Ch(n,s,new Kt(o.$anchorCell,c)):!1}}function kF(t,e){const n=t.state.doc,s=Wo(n.resolve(e));return s?(t.dispatch(t.state.tr.setSelection(new Kt(s))),!0):!1}function SF(t,e,n){if(!Lr(t.state))return!1;let s=bF(n);const a=t.state.selection;if(a instanceof Kt){s||(s={width:1,height:1,rows:[Ne.from($x(bs(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=mn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return s=NF(s,c.right-c.left,c.bottom-c.top),cw(t.state,t.dispatch,o,c,s),!0}else if(s){const i=rp(t.state),o=i.start(-1);return cw(t.state,t.dispatch,o,mn.get(i.node(-1)).findCell(i.pos-o),s),!0}else return!1}function CF(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const s=dw(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof Kt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&s&&(a=Wo(t.state.selection.$anchor))!=null&&((n=Og(t,e))===null||n===void 0?void 0:n.pos)!=a.pos)i(a,e),e.preventDefault();else if(!s)return;function i(u,h){let f=Og(t,h);const m=Ei.getState(t.state)==null;if(!f||!cy(u,f))if(m)f=u;else return;const g=new Kt(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(Ei,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),Ei.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Ei,-1))}function c(u){const h=u,f=Ei.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(dw(t,h.target)!=s&&(m=Og(t,e),!m))return o();m&&i(m,h)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",c)}function UC(t,e,n){if(!(t.state.selection instanceof Xe))return null;const{$head:s}=t.state.selection;for(let a=s.depth-1;a>=0;a--){const i=s.node(a);if((n<0?s.index(a):s.indexAfter(a))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=s.before(a),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function dw(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Og(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:s,pos:a}=n;return s>=0&&Wo(t.state.doc.resolve(s))||Wo(t.state.doc.resolve(a))}var EF=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Bx(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Bx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Bx(t,e,n,s,a,i){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;mnew s(m,n,g)),new MF(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=Js.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{AF(o,c,t,a)},mouseleave:o=>{IF(o)},mousedown:(o,c)=>{RF(o,c,e,n)}},decorations:o=>{const c=Js.getState(o);if(c&&c.activeHandle>-1)return _F(o,c.activeHandle)},nodeViews:{}}});return i}var MF=class Eh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,s=e.getMeta(Js);if(s&&s.setHandle!=null)return new Eh(s.setHandle,!1);if(s&&s.setDragging!==void 0)return new Eh(n.activeHandle,s.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return Fx(e.doc.resolve(a))||(a=-1),new Eh(a,n.dragging)}return n}};function AF(t,e,n,s){if(!t.editable)return;const a=Js.getState(t.state);if(a&&!a.dragging){const i=OF(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=uw(t,e,"left",n):u-e.clientX<=n&&(o=uw(t,e,"right",n))}if(o!=a.activeHandle){if(!s&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=mn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}KC(t,o)}}}function IF(t){if(!t.editable)return;const e=Js.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&KC(t,-1)}function RF(t,e,n,s){var a;if(!t.editable)return!1;const i=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,o=Js.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=PF(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Js,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const g=Js.getState(t.state);g!=null&&g.dragging&&(DF(t,g.activeHandle,hw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Js,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=Js.getState(t.state);if(g&&g.dragging){const y=hw(g.dragging,m,n);fw(t,g.activeHandle,y,s)}}return fw(t,o.activeHandle,u,s),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function PF(t,e,{colspan:n,colwidth:s}){const a=s&&s[s.length-1];if(a)return a;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,c=n;if(s)for(let u=0;u{var e,n;const s=t.getAttribute("colwidth"),a=s?s.split(",").map(i=>parseInt(i,10)):null;if(!a){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const c=i[o].getAttribute("width");return c?[parseInt(c,10)]:null}}return a}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Et(this.options.HTMLAttributes,t),0]}}),GC=An.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(s=>parseInt(s,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Et(this.options.HTMLAttributes,t),0]}}),JC=An.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Et(this.options.HTMLAttributes,t),0]}});function Vx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function pw(t,e,n,s,a,i){var o;let c=0,u=!0,h=e.firstChild;const f=t.firstChild;if(f!==null)for(let g=0,y=0;g{const s=t.nodes[n];s.spec.tableRole&&(e[s.spec.tableRole]=s)}),t.cached.tableNodeTypes=e,e}function VF(t,e,n,s,a){const i=BF(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!HF(e))return!1;let n=0;const s=R2(e.ranges[0].$from,i=>i.type.name==="table");return s==null||s.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},WF="";function UF(t){return(t||"").replace(/\s+/g," ").trim()}function KF(t,e,n={}){var s;const a=(s=n.cellLineSeparator)!=null?s:WF;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(N=>{const j=[];N.content&&N.content.forEach(v=>{let k="";v.content&&Array.isArray(v.content)&&v.content.length>1?k=v.content.map(P=>e.renderChildren(P)).join(a):k=v.content?e.renderChildren(v.content):"";const C=UF(k),E=v.type==="tableHeader";j.push({text:C,isHeader:E})}),i.push(j)});const o=i.reduce((N,j)=>Math.max(N,j.length),0);if(o===0)return"";const c=new Array(o).fill(0);i.forEach(N=>{var j;for(let v=0;vc[v]&&(c[v]=C),c[v]<3&&(c[v]=3)}});const u=(N,j)=>N+" ".repeat(Math.max(0,j-N.length)),h=i[0],f=h.some(N=>N.isHeader);let m=` `;const g=new Array(o).fill(0).map((N,j)=>f&&h[j]&&h[j].text||"");return m+=`| ${g.map((N,j)=>u(N,c[j])).join(" | ")} | `,m+=`| ${c.map(N=>"-".repeat(Math.max(3,N))).join(" | ")} | `,(f?i.slice(1):i).forEach(N=>{m+=`| ${new Array(o).fill(0).map((j,v)=>u(N[v]&&N[v].text||"",c[v])).join(" | ")} | -`}),m}var q$=K$,YC=Mn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:$$,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:s,tableMinWidth:a}=F$(t,this.options.cellMinWidth),i=e.style;function o(){return i||(s?`width: ${s}`:`min-width: ${a}`)}const c=["table",Et(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const s=[];t.header.forEach(a=>{s.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const a=[];s.forEach(i=>{a.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},a))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>q$(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:s,dispatch:a,editor:i})=>{const o=V$(i.schema,t,e,n);if(a){const c=s.selection.from+1;s.replaceSelectionWith(o).scrollIntoView().setSelection(Ze.near(s.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>s$(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>r$(t,e),deleteColumn:()=>({state:t,dispatch:e})=>i$(t,e),addRowBefore:()=>({state:t,dispatch:e})=>l$(t,e),addRowAfter:()=>({state:t,dispatch:e})=>c$(t,e),deleteRow:()=>({state:t,dispatch:e})=>u$(t,e),deleteTable:()=>({state:t,dispatch:e})=>y$(t,e),mergeCells:()=>({state:t,dispatch:e})=>sw(t,e),splitCell:()=>({state:t,dispatch:e})=>rw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>zd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>zd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>g$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>sw(t,e)?!0:rw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:s})=>p$(t,e)(n,s),goToNextCell:()=>({state:t,dispatch:e})=>iw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>iw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&VC(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const s=Ht.create(e.doc,t.anchorCell,t.headCell);e.setSelection(s)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:xh,"Mod-Backspace":xh,Delete:xh,"Mod-Delete":xh}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[T$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],z$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:kt(Ge(t,"tableRole",e))}}});gn.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(YC.configure(this.options.table)),this.options.tableCell!==!1&&t.push(qC.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(GC.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(JC.configure(this.options.tableRow)),t}});function G$(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 +`}),m}var qF=KF,YC=An.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:FF,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:s,tableMinWidth:a}=$F(t,this.options.cellMinWidth),i=e.style;function o(){return i||(s?`width: ${s}`:`min-width: ${a}`)}const c=["table",Et(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const s=[];t.header.forEach(a=>{s.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const a=[];s.forEach(i=>{a.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},a))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>qF(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:s,dispatch:a,editor:i})=>{const o=VF(i.schema,t,e,n);if(a){const c=s.selection.from+1;s.replaceSelectionWith(o).scrollIntoView().setSelection(Xe.near(s.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>sF(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>rF(t,e),deleteColumn:()=>({state:t,dispatch:e})=>iF(t,e),addRowBefore:()=>({state:t,dispatch:e})=>lF(t,e),addRowAfter:()=>({state:t,dispatch:e})=>cF(t,e),deleteRow:()=>({state:t,dispatch:e})=>uF(t,e),deleteTable:()=>({state:t,dispatch:e})=>yF(t,e),mergeCells:()=>({state:t,dispatch:e})=>sw(t,e),splitCell:()=>({state:t,dispatch:e})=>rw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>zd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>zd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>gF(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>sw(t,e)?!0:rw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:s})=>pF(t,e)(n,s),goToNextCell:()=>({state:t,dispatch:e})=>iw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>iw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&VC(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const s=Kt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(s)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:xh,"Mod-Backspace":xh,Delete:xh,"Mod-Delete":xh}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[TF({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],zF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:St(Ge(t,"tableRole",e))}}});gn.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(YC.configure(this.options.table)),this.options.tableCell!==!1&&t.push(qC.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(GC.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(JC.configure(this.options.tableRow)),t}});function GF(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 `),e=e.replace(/]*>(.*?)<\/h2>/gi,`## $1 @@ -769,24 +769,24 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: `),e=e.replace(/]*data-type="mention"[^>]*data-id="([^"]*)"[^>]*>@([^<]*)<\/span>/gi,"@$2"),e=e.replace(/]*data-type="linkTag"[^>]*data-url="([^"]*)"[^>]*>#([^<]*)<\/span>/gi,"#[$2]($1)"),e=e.replace(/<[^>]+>/g,""),e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'"),e=e.replace(/\n{3,}/g,` `),e.trim()}function gw(t){if(!t)return"";if(t.startsWith("<")&&t.includes("$1"),e=e.replace(/^## (.+)$/gm,"

$1

"),e=e.replace(/^# (.+)$/gm,"

$1

"),e=e.replace(/\*\*(.+?)\*\*/g,"$1"),e=e.replace(/\*(.+?)\*/g,"$1"),e=e.replace(/~~(.+?)~~/g,"$1"),e=e.replace(/`([^`]+)`/g,"$1"),e=e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'$1'),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'$1'),e=e.replace(/^> (.+)$/gm,"

$1

"),e=e.replace(/^---$/gm,"
"),e=e.replace(/^- (.+)$/gm,"
  • $1
  • ");const n=e.split(` -`),s=[];for(const a of n){const i=a.trim();i&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(i)?s.push(i):s.push(`

    ${i}

    `))}return s.join("")}const J$=Mn.create({name:"linkTag",group:"inline",inline:!0,selectable:!0,atom:!0,addAttributes(){return{label:{default:""},url:{default:""},tagType:{default:"url",parseHTML:t=>t.getAttribute("data-tag-type")||"url"},tagId:{default:"",parseHTML:t=>t.getAttribute("data-tag-id")||""},pagePath:{default:"",parseHTML:t=>t.getAttribute("data-page-path")||""},appId:{default:"",parseHTML:t=>t.getAttribute("data-app-id")||""},mpKey:{default:"",parseHTML:t=>t.getAttribute("data-mp-key")||""}}},parseHTML(){return[{tag:'span[data-type="linkTag"]',getAttrs:t=>{var e;return{label:((e=t.textContent)==null?void 0:e.replace(/^#/,"").trim())||"",url:t.getAttribute("data-url")||"",tagType:t.getAttribute("data-tag-type")||"url",tagId:t.getAttribute("data-tag-id")||"",pagePath:t.getAttribute("data-page-path")||"",appId:t.getAttribute("data-app-id")||"",mpKey:t.getAttribute("data-mp-key")||""}}}]},renderHTML({node:t,HTMLAttributes:e}){return["span",Et(e,{"data-type":"linkTag","data-url":t.attrs.url,"data-tag-type":t.attrs.tagType,"data-tag-id":t.attrs.tagId,"data-page-path":t.attrs.pagePath,"data-app-id":t.attrs.appId||"","data-mp-key":t.attrs.mpKey||t.attrs.appId||"",class:"link-tag-node"}),`#${t.attrs.label}`]}});function xw(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}const Y$=t=>({items:({query:e})=>t.filter(n=>n.name.toLowerCase().includes(e.toLowerCase())||n.id.includes(e)).slice(0,8),render:()=>{let e=null,n=0,s=[],a=null;const i=()=>{e&&(e.innerHTML=s.map((o,c)=>`
    +`),s=[];for(const a of n){const i=a.trim();i&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(i)?s.push(i):s.push(`

    ${i}

    `))}return s.join("")}const JF=An.create({name:"linkTag",group:"inline",inline:!0,selectable:!0,atom:!0,addAttributes(){return{label:{default:""},url:{default:""},tagType:{default:"url",parseHTML:t=>t.getAttribute("data-tag-type")||"url"},tagId:{default:"",parseHTML:t=>t.getAttribute("data-tag-id")||""},pagePath:{default:"",parseHTML:t=>t.getAttribute("data-page-path")||""},appId:{default:"",parseHTML:t=>t.getAttribute("data-app-id")||""},mpKey:{default:"",parseHTML:t=>t.getAttribute("data-mp-key")||""}}},parseHTML(){return[{tag:'span[data-type="linkTag"]',getAttrs:t=>{var e;return{label:((e=t.textContent)==null?void 0:e.replace(/^#/,"").trim())||"",url:t.getAttribute("data-url")||"",tagType:t.getAttribute("data-tag-type")||"url",tagId:t.getAttribute("data-tag-id")||"",pagePath:t.getAttribute("data-page-path")||"",appId:t.getAttribute("data-app-id")||"",mpKey:t.getAttribute("data-mp-key")||""}}}]},renderHTML({node:t,HTMLAttributes:e}){return["span",Et(e,{"data-type":"linkTag","data-url":t.attrs.url,"data-tag-type":t.attrs.tagType,"data-tag-id":t.attrs.tagId,"data-page-path":t.attrs.pagePath,"data-app-id":t.attrs.appId||"","data-mp-key":t.attrs.mpKey||t.attrs.appId||"",class:"link-tag-node"}),`#${t.attrs.label}`]}});function xw(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}const YF=t=>({items:({query:e})=>t.filter(n=>n.name.toLowerCase().includes(e.toLowerCase())||n.id.includes(e)).slice(0,8),render:()=>{let e=null,n=0,s=[],a=null;const i=()=>{e&&(e.innerHTML=s.map((o,c)=>`
    @${xw(o.name)} ${xw(o.label||o.id)} -
    `).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");a&&s[c]&&a({id:s[c].id,label:s[c].name})})}))};return{onStart:o=>{if(e=document.createElement("div"),e.className="mention-popup",document.body.appendChild(e),s=o.items,a=o.command,n=0,i(),o.clientRect){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onUpdate:o=>{if(s=o.items,a=o.command,n=0,i(),o.clientRect&&e){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onKeyDown:o=>o.event.key==="ArrowUp"?(n=Math.max(0,n-1),i(),!0):o.event.key==="ArrowDown"?(n=Math.min(s.length-1,n+1),i(),!0):o.event.key==="Enter"?(a&&s[n]&&a({id:s[n].id,label:s[n].name}),!0):o.event.key==="Escape"?(e==null||e.remove(),e=null,!0):!1,onExit:()=>{e==null||e.remove(),e=null}}}});function Q$(t){var s;const e=[],n=(s=t.clipboardData)==null?void 0:s.items;if(!n)return e;for(let a=0;a{const u=b.useRef(null),h=b.useRef(null),[f,m]=b.useState(""),[g,y]=b.useState(!1),N=b.useRef(gw(t)),j=b.useCallback((M,P)=>{var O;const H=h.current;if(!H||!n)return!1;const L=Q$(P);if(L.length>0)return P.preventDefault(),(async()=>{for(const ne of L)try{const ie=await n(ne);ie&&H.chain().focus().setImage({src:ie}).run()}catch(ie){console.error("粘贴图片上传失败",ie)}})(),!0;const R=(O=P.clipboardData)==null?void 0:O.getData("text/html");if(R&&/data:image\/[^;"']+;base64,/i.test(R)){P.preventDefault();const{from:ne,to:ie}=H.state.selection;return(async()=>{try{const _=await eF(R,n);H.chain().focus().insertContentAt({from:ne,to:ie},_).run()}catch(_){console.error("粘贴 HTML 内 base64 转换失败",_)}})(),!0}return!1},[n]),v=W_({extensions:[Iz.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),Oz.configure({inline:!0,allowBase64:!0}),Fz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:Y$(s)}),J$,Bz.configure({placeholder:i}),YC.configure({resizable:!0}),JC,qC,GC],content:N.current,onUpdate:({editor:M})=>{e(M.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:j}});b.useEffect(()=>{h.current=v??null},[v]),b.useImperativeHandle(c,()=>({getHTML:()=>(v==null?void 0:v.getHTML())||"",getMarkdown:()=>G$((v==null?void 0:v.getHTML())||"")})),b.useEffect(()=>{if(v&&t!==v.getHTML()){const M=gw(t);M!==v.getHTML()&&v.commands.setContent(M)}},[t]);const k=b.useCallback(async M=>{var H;const P=(H=M.target.files)==null?void 0:H[0];if(!(!P||!v)){if(n){const L=await n(P);L&&v.chain().focus().setImage({src:L}).run()}else{const L=new FileReader;L.onload=()=>{typeof L.result=="string"&&v.chain().focus().setImage({src:L.result}).run()},L.readAsDataURL(P)}M.target.value=""}},[v,n]),C=b.useCallback(M=>{v&&v.chain().focus().insertContent({type:"linkTag",attrs:{label:M.label,url:M.url||"",tagType:M.type||"url",tagId:M.id||"",pagePath:M.pagePath||"",appId:M.appId||"",mpKey:M.type==="miniprogram"&&M.appId||""}}).run()},[v]),E=b.useCallback(()=>{!v||!f||(v.chain().focus().setLink({href:f}).run(),m(""),y(!1))},[v,f]);return v?r.jsxs("div",{className:`rich-editor-wrapper ${o||""}`,children:[r.jsxs("div",{className:"rich-editor-toolbar",children:[r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().toggleBold().run(),className:v.isActive("bold")?"is-active":"",type:"button",children:r.jsx(HT,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleItalic().run(),className:v.isActive("italic")?"is-active":"",type:"button",children:r.jsx(BM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleStrike().run(),className:v.isActive("strike")?"is-active":"",type:"button",children:r.jsx(_5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleCode().run(),className:v.isActive("code")?"is-active":"",type:"button",children:r.jsx(cM,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:1}).run(),className:v.isActive("heading",{level:1})?"is-active":"",type:"button",children:r.jsx(IM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:2}).run(),className:v.isActive("heading",{level:2})?"is-active":"",type:"button",children:r.jsx(PM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:3}).run(),className:v.isActive("heading",{level:3})?"is-active":"",type:"button",children:r.jsx(DM,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().toggleBulletList().run(),className:v.isActive("bulletList")?"is-active":"",type:"button",children:r.jsx(YM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleOrderedList().run(),className:v.isActive("orderedList")?"is-active":"",type:"button",children:r.jsx(GM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleBlockquote().run(),className:v.isActive("blockquote")?"is-active":"",type:"button",children:r.jsx(w5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().setHorizontalRule().run(),type:"button",children:r.jsx(o5,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:k,className:"hidden"}),r.jsx("button",{onClick:()=>{var M;return(M=u.current)==null?void 0:M.click()},type:"button",children:r.jsx(dj,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>y(!g),className:v.isActive("link")?"is-active":"",type:"button",children:r.jsx(Jg,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",children:r.jsx($5,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().undo().run(),disabled:!v.can().undo(),type:"button",children:r.jsx(K5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().redo().run(),disabled:!v.can().redo(),type:"button",children:r.jsx(k5,{className:"w-4 h-4"})})]}),a.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{className:"toolbar-group",children:r.jsxs("select",{className:"link-tag-select",onChange:M=>{const P=a.find(H=>H.id===M.target.value);P&&C(P),M.target.value=""},defaultValue:"",children:[r.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),a.map(M=>r.jsx("option",{value:M.id,children:M.label},M.id))]})})]})]}),g&&r.jsxs("div",{className:"link-input-bar",children:[r.jsx("input",{type:"url",placeholder:"输入链接地址...",value:f,onChange:M=>m(M.target.value),onKeyDown:M=>M.key==="Enter"&&E(),className:"link-input"}),r.jsx("button",{onClick:E,className:"link-confirm",type:"button",children:"确定"}),r.jsx("button",{onClick:()=>{v.chain().focus().unsetLink().run(),y(!1)},className:"link-remove",type:"button",children:"移除"})]}),r.jsx(oC,{editor:v})]}):null});Hx.displayName="RichEditor";const tF=["top","right","bottom","left"],Vi=Math.min,Us=Math.max,Ef=Math.round,yh=Math.floor,sa=t=>({x:t,y:t}),nF={left:"right",right:"left",bottom:"top",top:"bottom"},sF={start:"end",end:"start"};function Wx(t,e,n){return Us(t,Vi(e,n))}function Wa(t,e){return typeof t=="function"?t(e):t}function Ua(t){return t.split("-")[0]}function oc(t){return t.split("-")[1]}function dy(t){return t==="x"?"y":"x"}function uy(t){return t==="y"?"height":"width"}const rF=new Set(["top","bottom"]);function na(t){return rF.has(Ua(t))?"y":"x"}function hy(t){return dy(na(t))}function aF(t,e,n){n===void 0&&(n=!1);const s=oc(t),a=hy(t),i=uy(a);let o=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Tf(o)),[o,Tf(o)]}function iF(t){const e=Tf(t);return[Ux(t),e,Ux(e)]}function Ux(t){return t.replace(/start|end/g,e=>sF[e])}const yw=["left","right"],bw=["right","left"],oF=["top","bottom"],lF=["bottom","top"];function cF(t,e,n){switch(t){case"top":case"bottom":return n?e?bw:yw:e?yw:bw;case"left":case"right":return e?oF:lF;default:return[]}}function dF(t,e,n,s){const a=oc(t);let i=cF(Ua(t),n==="start",s);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(Ux)))),i}function Tf(t){return t.replace(/left|right|bottom|top/g,e=>nF[e])}function uF(t){return{top:0,right:0,bottom:0,left:0,...t}}function QC(t){return typeof t!="number"?uF(t):{top:t,right:t,bottom:t,left:t}}function Mf(t){const{x:e,y:n,width:s,height:a}=t;return{width:s,height:a,top:n,left:e,right:e+s,bottom:n+a,x:e,y:n}}function vw(t,e,n){let{reference:s,floating:a}=t;const i=na(e),o=hy(e),c=uy(o),u=Ua(e),h=i==="y",f=s.x+s.width/2-a.width/2,m=s.y+s.height/2-a.height/2,g=s[c]/2-a[c]/2;let y;switch(u){case"top":y={x:f,y:s.y-a.height};break;case"bottom":y={x:f,y:s.y+s.height};break;case"right":y={x:s.x+s.width,y:m};break;case"left":y={x:s.x-a.width,y:m};break;default:y={x:s.x,y:s.y}}switch(oc(e)){case"start":y[o]-=g*(n&&h?-1:1);break;case"end":y[o]+=g*(n&&h?-1:1);break}return y}async function hF(t,e){var n;e===void 0&&(e={});const{x:s,y:a,platform:i,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=Wa(e,t),N=QC(y),v=c[g?m==="floating"?"reference":"floating":m],k=Mf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),C=m==="floating"?{x:s,y:a,width:o.floating.width,height:o.floating.height}:o.reference,E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),M=await(i.isElement==null?void 0:i.isElement(E))?await(i.getScale==null?void 0:i.getScale(E))||{x:1,y:1}:{x:1,y:1},P=Mf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:C,offsetParent:E,strategy:u}):C);return{top:(k.top-P.top+N.top)/M.y,bottom:(P.bottom-k.bottom+N.bottom)/M.y,left:(k.left-P.left+N.left)/M.x,right:(P.right-k.right+N.right)/M.x}}const fF=async(t,e,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:i=[],platform:o}=n,c=i.filter(Boolean),u=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:t,floating:e,strategy:a}),{x:f,y:m}=vw(h,s,u),g=s,y={},N=0;for(let v=0;v({name:"arrow",options:t,async fn(e){const{x:n,y:s,placement:a,rects:i,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=Wa(t,e)||{};if(h==null)return{};const m=QC(f),g={x:n,y:s},y=hy(a),N=uy(y),j=await o.getDimensions(h),v=y==="y",k=v?"top":"left",C=v?"bottom":"right",E=v?"clientHeight":"clientWidth",M=i.reference[N]+i.reference[y]-g[y]-i.floating[N],P=g[y]-i.reference[y],H=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let L=H?H[E]:0;(!L||!await(o.isElement==null?void 0:o.isElement(H)))&&(L=c.floating[E]||i.floating[N]);const R=M/2-P/2,O=L/2-j[N]/2-1,ne=Vi(m[k],O),ie=Vi(m[C],O),_=ne,ce=L-j[N]-ie,pe=L/2-j[N]/2+R,z=Wx(_,pe,ce),q=!u.arrow&&oc(a)!=null&&pe!==z&&i.reference[N]/2-(pe<_?ne:ie)-j[N]/2<0,F=q?pe<_?pe-_:pe-ce:0;return{[y]:g[y]+F,data:{[y]:z,centerOffset:pe-z-F,...q&&{alignmentOffset:F}},reset:q}}}),mF=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,s;const{placement:a,middlewareData:i,rects:o,initialPlacement:c,platform:u,elements:h}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:N="none",flipAlignment:j=!0,...v}=Wa(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const k=Ua(a),C=na(c),E=Ua(c)===c,M=await(u.isRTL==null?void 0:u.isRTL(h.floating)),P=g||(E||!j?[Tf(c)]:iF(c)),H=N!=="none";!g&&H&&P.push(...dF(c,j,N,M));const L=[c,...P],R=await u.detectOverflow(e,v),O=[];let ne=((s=i.flip)==null?void 0:s.overflows)||[];if(f&&O.push(R[k]),m){const pe=aF(a,o,M);O.push(R[pe[0]],R[pe[1]])}if(ne=[...ne,{placement:a,overflows:O}],!O.every(pe=>pe<=0)){var ie,_;const pe=(((ie=i.flip)==null?void 0:ie.index)||0)+1,z=L[pe];if(z&&(!(m==="alignment"?C!==na(z):!1)||ne.every(A=>na(A.placement)===C?A.overflows[0]>0:!0)))return{data:{index:pe,overflows:ne},reset:{placement:z}};let q=(_=ne.filter(F=>F.overflows[0]<=0).sort((F,A)=>F.overflows[1]-A.overflows[1])[0])==null?void 0:_.placement;if(!q)switch(y){case"bestFit":{var ce;const F=(ce=ne.filter(A=>{if(H){const J=na(A.placement);return J===C||J==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(J=>J>0).reduce((J,U)=>J+U,0)]).sort((A,J)=>A[1]-J[1])[0])==null?void 0:ce[0];F&&(q=F);break}case"initialPlacement":q=c;break}if(a!==q)return{reset:{placement:q}}}return{}}}};function Nw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function ww(t){return tF.some(e=>t[e]>=0)}const gF=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:s}=e,{strategy:a="referenceHidden",...i}=Wa(t,e);switch(a){case"referenceHidden":{const o=await s.detectOverflow(e,{...i,elementContext:"reference"}),c=Nw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:ww(c)}}}case"escaped":{const o=await s.detectOverflow(e,{...i,altBoundary:!0}),c=Nw(o,n.floating);return{data:{escapedOffsets:c,escaped:ww(c)}}}default:return{}}}}},XC=new Set(["left","top"]);async function xF(t,e){const{placement:n,platform:s,elements:a}=t,i=await(s.isRTL==null?void 0:s.isRTL(a.floating)),o=Ua(n),c=oc(n),u=na(n)==="y",h=XC.has(o)?-1:1,f=i&&u?-1:1,m=Wa(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:N}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof N=="number"&&(y=c==="end"?N*-1:N),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const yF=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:a,y:i,placement:o,middlewareData:c}=e,u=await xF(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:a+u.x,y:i+u.y,data:{...u,placement:o}}}}},bF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:s,placement:a,platform:i}=e,{mainAxis:o=!0,crossAxis:c=!1,limiter:u={fn:k=>{let{x:C,y:E}=k;return{x:C,y:E}}},...h}=Wa(t,e),f={x:n,y:s},m=await i.detectOverflow(e,h),g=na(Ua(a)),y=dy(g);let N=f[y],j=f[g];if(o){const k=y==="y"?"top":"left",C=y==="y"?"bottom":"right",E=N+m[k],M=N-m[C];N=Wx(E,N,M)}if(c){const k=g==="y"?"top":"left",C=g==="y"?"bottom":"right",E=j+m[k],M=j-m[C];j=Wx(E,j,M)}const v=u.fn({...e,[y]:N,[g]:j});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[y]:o,[g]:c}}}}}},vF=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:s,placement:a,rects:i,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=Wa(t,e),f={x:n,y:s},m=na(a),g=dy(m);let y=f[g],N=f[m];const j=Wa(c,e),v=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(u){const E=g==="y"?"height":"width",M=i.reference[g]-i.floating[E]+v.mainAxis,P=i.reference[g]+i.reference[E]-v.mainAxis;yP&&(y=P)}if(h){var k,C;const E=g==="y"?"width":"height",M=XC.has(Ua(a)),P=i.reference[m]-i.floating[E]+(M&&((k=o.offset)==null?void 0:k[m])||0)+(M?0:v.crossAxis),H=i.reference[m]+i.reference[E]+(M?0:((C=o.offset)==null?void 0:C[m])||0)-(M?v.crossAxis:0);NH&&(N=H)}return{[g]:y,[m]:N}}}},NF=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,s;const{placement:a,rects:i,platform:o,elements:c}=e,{apply:u=()=>{},...h}=Wa(t,e),f=await o.detectOverflow(e,h),m=Ua(a),g=oc(a),y=na(a)==="y",{width:N,height:j}=i.floating;let v,k;m==="top"||m==="bottom"?(v=m,k=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,v=g==="end"?"top":"bottom");const C=j-f.top-f.bottom,E=N-f.left-f.right,M=Vi(j-f[v],C),P=Vi(N-f[k],E),H=!e.middlewareData.shift;let L=M,R=P;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(R=E),(s=e.middlewareData.shift)!=null&&s.enabled.y&&(L=C),H&&!g){const ne=Us(f.left,0),ie=Us(f.right,0),_=Us(f.top,0),ce=Us(f.bottom,0);y?R=N-2*(ne!==0||ie!==0?ne+ie:Us(f.left,f.right)):L=j-2*(_!==0||ce!==0?_+ce:Us(f.top,f.bottom))}await u({...e,availableWidth:R,availableHeight:L});const O=await o.getDimensions(c.floating);return N!==O.width||j!==O.height?{reset:{rects:!0}}:{}}}};function ap(){return typeof window<"u"}function lc(t){return ZC(t)?(t.nodeName||"").toLowerCase():"#document"}function Ys(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ca(t){var e;return(e=(ZC(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function ZC(t){return ap()?t instanceof Node||t instanceof Ys(t).Node:!1}function Rr(t){return ap()?t instanceof Element||t instanceof Ys(t).Element:!1}function oa(t){return ap()?t instanceof HTMLElement||t instanceof Ys(t).HTMLElement:!1}function jw(t){return!ap()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ys(t).ShadowRoot}const wF=new Set(["inline","contents"]);function Jd(t){const{overflow:e,overflowX:n,overflowY:s,display:a}=Pr(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!wF.has(a)}const jF=new Set(["table","td","th"]);function kF(t){return jF.has(lc(t))}const SF=[":popover-open",":modal"];function ip(t){return SF.some(e=>{try{return t.matches(e)}catch{return!1}})}const CF=["transform","translate","scale","rotate","perspective"],EF=["transform","translate","scale","rotate","perspective","filter"],TF=["paint","layout","strict","content"];function fy(t){const e=py(),n=Rr(t)?Pr(t):t;return CF.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||EF.some(s=>(n.willChange||"").includes(s))||TF.some(s=>(n.contain||"").includes(s))}function MF(t){let e=Hi(t);for(;oa(e)&&!Xl(e);){if(fy(e))return e;if(ip(e))return null;e=Hi(e)}return null}function py(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const AF=new Set(["html","body","#document"]);function Xl(t){return AF.has(lc(t))}function Pr(t){return Ys(t).getComputedStyle(t)}function op(t){return Rr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Hi(t){if(lc(t)==="html")return t;const e=t.assignedSlot||t.parentNode||jw(t)&&t.host||ca(t);return jw(e)?e.host:e}function e4(t){const e=Hi(t);return Xl(e)?t.ownerDocument?t.ownerDocument.body:t.body:oa(e)&&Jd(e)?e:e4(e)}function $d(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=e4(t),i=a===((s=t.ownerDocument)==null?void 0:s.body),o=Ys(a);if(i){const c=Kx(o);return e.concat(o,o.visualViewport||[],Jd(a)?a:[],c&&n?$d(c):[])}return e.concat(a,$d(a,[],n))}function Kx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function t4(t){const e=Pr(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const a=oa(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:s,c=Ef(n)!==i||Ef(s)!==o;return c&&(n=i,s=o),{width:n,height:s,$:c}}function my(t){return Rr(t)?t:t.contextElement}function Hl(t){const e=my(t);if(!oa(e))return sa(1);const n=e.getBoundingClientRect(),{width:s,height:a,$:i}=t4(e);let o=(i?Ef(n.width):n.width)/s,c=(i?Ef(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const IF=sa(0);function n4(t){const e=Ys(t);return!py()||!e.visualViewport?IF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function RF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ys(t)?!1:e}function Ko(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=my(t);let o=sa(1);e&&(s?Rr(s)&&(o=Hl(s)):o=Hl(t));const c=RF(i,n,s)?n4(i):sa(0);let u=(a.left+c.x)/o.x,h=(a.top+c.y)/o.y,f=a.width/o.x,m=a.height/o.y;if(i){const g=Ys(i),y=s&&Rr(s)?Ys(s):s;let N=g,j=Kx(N);for(;j&&s&&y!==N;){const v=Hl(j),k=j.getBoundingClientRect(),C=Pr(j),E=k.left+(j.clientLeft+parseFloat(C.paddingLeft))*v.x,M=k.top+(j.clientTop+parseFloat(C.paddingTop))*v.y;u*=v.x,h*=v.y,f*=v.x,m*=v.y,u+=E,h+=M,N=Ys(j),j=Kx(N)}}return Mf({width:f,height:m,x:u,y:h})}function lp(t,e){const n=op(t).scrollLeft;return e?e.left+n:Ko(ca(t)).left+n}function s4(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-lp(t,n),a=n.top+e.scrollTop;return{x:s,y:a}}function PF(t){let{elements:e,rect:n,offsetParent:s,strategy:a}=t;const i=a==="fixed",o=ca(s),c=e?ip(e.floating):!1;if(s===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=sa(1);const f=sa(0),m=oa(s);if((m||!m&&!i)&&((lc(s)!=="body"||Jd(o))&&(u=op(s)),oa(s))){const y=Ko(s);h=Hl(s),f.x=y.x+s.clientLeft,f.y=y.y+s.clientTop}const g=o&&!m&&!i?s4(o,u):sa(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+f.x+g.x,y:n.y*h.y-u.scrollTop*h.y+f.y+g.y}}function OF(t){return Array.from(t.getClientRects())}function DF(t){const e=ca(t),n=op(t),s=t.ownerDocument.body,a=Us(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=Us(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let o=-n.scrollLeft+lp(t);const c=-n.scrollTop;return Pr(s).direction==="rtl"&&(o+=Us(e.clientWidth,s.clientWidth)-a),{width:a,height:i,x:o,y:c}}const kw=25;function LF(t,e){const n=Ys(t),s=ca(t),a=n.visualViewport;let i=s.clientWidth,o=s.clientHeight,c=0,u=0;if(a){i=a.width,o=a.height;const f=py();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=lp(s);if(h<=0){const f=s.ownerDocument,m=f.body,g=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,N=Math.abs(s.clientWidth-m.clientWidth-y);N<=kw&&(i-=N)}else h<=kw&&(i+=h);return{width:i,height:o,x:c,y:u}}const _F=new Set(["absolute","fixed"]);function zF(t,e){const n=Ko(t,!0,e==="fixed"),s=n.top+t.clientTop,a=n.left+t.clientLeft,i=oa(t)?Hl(t):sa(1),o=t.clientWidth*i.x,c=t.clientHeight*i.y,u=a*i.x,h=s*i.y;return{width:o,height:c,x:u,y:h}}function Sw(t,e,n){let s;if(e==="viewport")s=LF(t,n);else if(e==="document")s=DF(ca(t));else if(Rr(e))s=zF(e,n);else{const a=n4(t);s={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Mf(s)}function r4(t,e){const n=Hi(t);return n===e||!Rr(n)||Xl(n)?!1:Pr(n).position==="fixed"||r4(n,e)}function $F(t,e){const n=e.get(t);if(n)return n;let s=$d(t,[],!1).filter(c=>Rr(c)&&lc(c)!=="body"),a=null;const i=Pr(t).position==="fixed";let o=i?Hi(t):t;for(;Rr(o)&&!Xl(o);){const c=Pr(o),u=fy(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&_F.has(a.position)||Jd(o)&&!u&&r4(t,o))?s=s.filter(f=>f!==o):a=c,o=Hi(o)}return e.set(t,s),s}function FF(t){let{element:e,boundary:n,rootBoundary:s,strategy:a}=t;const o=[...n==="clippingAncestors"?ip(e)?[]:$F(e,this._c):[].concat(n),s],c=o[0],u=o.reduce((h,f)=>{const m=Sw(e,f,a);return h.top=Us(m.top,h.top),h.right=Vi(m.right,h.right),h.bottom=Vi(m.bottom,h.bottom),h.left=Us(m.left,h.left),h},Sw(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function BF(t){const{width:e,height:n}=t4(t);return{width:e,height:n}}function VF(t,e,n){const s=oa(e),a=ca(e),i=n==="fixed",o=Ko(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=sa(0);function h(){u.x=lp(a)}if(s||!s&&!i)if((lc(e)!=="body"||Jd(a))&&(c=op(e)),s){const y=Ko(e,!0,i,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else a&&h();i&&!s&&a&&h();const f=a&&!s&&!i?s4(a,c):sa(0),m=o.left+c.scrollLeft-u.x-f.x,g=o.top+c.scrollTop-u.y-f.y;return{x:m,y:g,width:o.width,height:o.height}}function Dg(t){return Pr(t).position==="static"}function Cw(t,e){if(!oa(t)||Pr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ca(t)===n&&(n=n.ownerDocument.body),n}function a4(t,e){const n=Ys(t);if(ip(t))return n;if(!oa(t)){let a=Hi(t);for(;a&&!Xl(a);){if(Rr(a)&&!Dg(a))return a;a=Hi(a)}return n}let s=Cw(t,e);for(;s&&kF(s)&&Dg(s);)s=Cw(s,e);return s&&Xl(s)&&Dg(s)&&!fy(s)?n:s||MF(t)||n}const HF=async function(t){const e=this.getOffsetParent||a4,n=this.getDimensions,s=await n(t.floating);return{reference:VF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function WF(t){return Pr(t).direction==="rtl"}const UF={convertOffsetParentRelativeRectToViewportRelativeRect:PF,getDocumentElement:ca,getClippingRect:FF,getOffsetParent:a4,getElementRects:HF,getClientRects:OF,getDimensions:BF,getScale:Hl,isElement:Rr,isRTL:WF};function i4(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function KF(t,e){let n=null,s;const a=ca(t);function i(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function o(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),i();const h=t.getBoundingClientRect(),{left:f,top:m,width:g,height:y}=h;if(c||e(),!g||!y)return;const N=yh(m),j=yh(a.clientWidth-(f+g)),v=yh(a.clientHeight-(m+y)),k=yh(f),E={rootMargin:-N+"px "+-j+"px "+-v+"px "+-k+"px",threshold:Us(0,Vi(1,u))||1};let M=!0;function P(H){const L=H[0].intersectionRatio;if(L!==u){if(!M)return o();L?o(!1,L):s=setTimeout(()=>{o(!1,1e-7)},1e3)}L===1&&!i4(h,t.getBoundingClientRect())&&o(),M=!1}try{n=new IntersectionObserver(P,{...E,root:a.ownerDocument})}catch{n=new IntersectionObserver(P,E)}n.observe(t)}return o(!0),i}function qF(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,h=my(t),f=a||i?[...h?$d(h):[],...$d(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?KF(h,n):null;let g=-1,y=null;o&&(y=new ResizeObserver(k=>{let[C]=k;C&&C.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var E;(E=y)==null||E.observe(e)})),n()}),h&&!u&&y.observe(h),y.observe(e));let N,j=u?Ko(t):null;u&&v();function v(){const k=Ko(t);j&&!i4(j,k)&&n(),j=k,N=requestAnimationFrame(v)}return n(),()=>{var k;f.forEach(C=>{a&&C.removeEventListener("scroll",n),i&&C.removeEventListener("resize",n)}),m==null||m(),(k=y)==null||k.disconnect(),y=null,u&&cancelAnimationFrame(N)}}const GF=yF,JF=bF,YF=mF,QF=NF,XF=gF,Ew=pF,ZF=vF,eB=(t,e,n)=>{const s=new Map,a={platform:UF,...n},i={...a.platform,_c:s};return fF(t,e,{...a,platform:i})};var tB=typeof document<"u",nB=function(){},Th=tB?b.useLayoutEffect:nB;function Af(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,s,a;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(s=n;s--!==0;)if(!Af(t[s],e[s]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(e).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(e,a[s]))return!1;for(s=n;s--!==0;){const i=a[s];if(!(i==="_owner"&&t.$$typeof)&&!Af(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function o4(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Tw(t,e){const n=o4(t);return Math.round(e*n)/n}function Lg(t){const e=b.useRef(t);return Th(()=>{e.current=t}),e}function sB(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:i,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=b.useState(s);Af(g,s)||y(s);const[N,j]=b.useState(null),[v,k]=b.useState(null),C=b.useCallback(A=>{A!==H.current&&(H.current=A,j(A))},[]),E=b.useCallback(A=>{A!==L.current&&(L.current=A,k(A))},[]),M=i||N,P=o||v,H=b.useRef(null),L=b.useRef(null),R=b.useRef(f),O=u!=null,ne=Lg(u),ie=Lg(a),_=Lg(h),ce=b.useCallback(()=>{if(!H.current||!L.current)return;const A={placement:e,strategy:n,middleware:g};ie.current&&(A.platform=ie.current),eB(H.current,L.current,A).then(J=>{const U={...J,isPositioned:_.current!==!1};pe.current&&!Af(R.current,U)&&(R.current=U,Bd.flushSync(()=>{m(U)}))})},[g,e,n,ie,_]);Th(()=>{h===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,m(A=>({...A,isPositioned:!1})))},[h]);const pe=b.useRef(!1);Th(()=>(pe.current=!0,()=>{pe.current=!1}),[]),Th(()=>{if(M&&(H.current=M),P&&(L.current=P),M&&P){if(ne.current)return ne.current(M,P,ce);ce()}},[M,P,ce,ne,O]);const z=b.useMemo(()=>({reference:H,floating:L,setReference:C,setFloating:E}),[C,E]),q=b.useMemo(()=>({reference:M,floating:P}),[M,P]),F=b.useMemo(()=>{const A={position:n,left:0,top:0};if(!q.floating)return A;const J=Tw(q.floating,f.x),U=Tw(q.floating,f.y);return c?{...A,transform:"translate("+J+"px, "+U+"px)",...o4(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:J,top:U}},[n,c,q.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:ce,refs:z,elements:q,floatingStyles:F}),[f,ce,z,q,F])}const rB=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:s,padding:a}=typeof t=="function"?t(n):t;return s&&e(s)?s.current!=null?Ew({element:s.current,padding:a}).fn(n):{}:s?Ew({element:s,padding:a}).fn(n):{}}}},aB=(t,e)=>({...GF(t),options:[t,e]}),iB=(t,e)=>({...JF(t),options:[t,e]}),oB=(t,e)=>({...ZF(t),options:[t,e]}),lB=(t,e)=>({...YF(t),options:[t,e]}),cB=(t,e)=>({...QF(t),options:[t,e]}),dB=(t,e)=>({...XF(t),options:[t,e]}),uB=(t,e)=>({...rB(t),options:[t,e]});var hB="Arrow",l4=b.forwardRef((t,e)=>{const{children:n,width:s=10,height:a=5,...i}=t;return r.jsx(mt.svg,{...i,ref:e,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});l4.displayName=hB;var fB=l4,gy="Popper",[c4,d4]=qi(gy),[pB,u4]=c4(gy),h4=t=>{const{__scopePopper:e,children:n}=t,[s,a]=b.useState(null);return r.jsx(pB,{scope:e,anchor:s,onAnchorChange:a,children:n})};h4.displayName=gy;var f4="PopperAnchor",p4=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:s,...a}=t,i=u4(f4,n),o=b.useRef(null),c=Tt(e,o),u=b.useRef(null);return b.useEffect(()=>{const h=u.current;u.current=(s==null?void 0:s.current)||o.current,h!==u.current&&i.onAnchorChange(u.current)}),s?null:r.jsx(mt.div,{...a,ref:c})});p4.displayName=f4;var xy="PopperContent",[mB,gB]=c4(xy),m4=b.forwardRef((t,e)=>{var K,G,ge,ae,fe,Se;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:N,...j}=t,v=u4(xy,n),[k,C]=b.useState(null),E=Tt(e,et=>C(et)),[M,P]=b.useState(null),H=x0(M),L=(H==null?void 0:H.width)??0,R=(H==null?void 0:H.height)??0,O=s+(i!=="center"?"-"+i:""),ne=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},ie=Array.isArray(h)?h:[h],_=ie.length>0,ce={padding:ne,boundary:ie.filter(yB),altBoundary:_},{refs:pe,floatingStyles:z,placement:q,isPositioned:F,middlewareData:A}=sB({strategy:"fixed",placement:O,whileElementsMounted:(...et)=>qF(...et,{animationFrame:y==="always"}),elements:{reference:v.anchor},middleware:[aB({mainAxis:a+R,alignmentAxis:o}),u&&iB({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?oB():void 0,...ce}),u&&lB({...ce}),cB({...ce,apply:({elements:et,rects:st,availableWidth:_t,availableHeight:At})=>{const{width:Ut,height:An}=st.reference,In=et.floating.style;In.setProperty("--radix-popper-available-width",`${_t}px`),In.setProperty("--radix-popper-available-height",`${At}px`),In.setProperty("--radix-popper-anchor-width",`${Ut}px`),In.setProperty("--radix-popper-anchor-height",`${An}px`)}}),M&&uB({element:M,padding:c}),bB({arrowWidth:L,arrowHeight:R}),g&&dB({strategy:"referenceHidden",...ce})]}),[J,U]=y4(q),D=$i(N);fs(()=>{F&&(D==null||D())},[F,D]);const W=(K=A.arrow)==null?void 0:K.x,le=(G=A.arrow)==null?void 0:G.y,xe=((ge=A.arrow)==null?void 0:ge.centerOffset)!==0,[Me,te]=b.useState();return fs(()=>{k&&te(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:pe.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:F?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Me,"--radix-popper-transform-origin":[(ae=A.transformOrigin)==null?void 0:ae.x,(fe=A.transformOrigin)==null?void 0:fe.y].join(" "),...((Se=A.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:r.jsx(mB,{scope:n,placedSide:J,onArrowChange:P,arrowX:W,arrowY:le,shouldHideArrow:xe,children:r.jsx(mt.div,{"data-side":J,"data-align":U,...j,ref:E,style:{...j.style,animation:F?void 0:"none"}})})})});m4.displayName=xy;var g4="PopperArrow",xB={top:"bottom",right:"left",bottom:"top",left:"right"},x4=b.forwardRef(function(e,n){const{__scopePopper:s,...a}=e,i=gB(g4,s),o=xB[i.placedSide];return r.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:r.jsx(fB,{...a,ref:n,style:{...a.style,display:"block"}})})});x4.displayName=g4;function yB(t){return t!==null}var bB=t=>({name:"transformOrigin",options:t,fn(e){var v,k,C;const{placement:n,rects:s,middlewareData:a}=e,o=((v=a.arrow)==null?void 0:v.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=y4(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((k=a.arrow)==null?void 0:k.x)??0)+c/2,y=(((C=a.arrow)==null?void 0:C.y)??0)+u/2;let N="",j="";return h==="bottom"?(N=o?m:`${g}px`,j=`${-u}px`):h==="top"?(N=o?m:`${g}px`,j=`${s.floating.height+u}px`):h==="right"?(N=`${-u}px`,j=o?m:`${y}px`):h==="left"&&(N=`${s.floating.width+u}px`,j=o?m:`${y}px`),{data:{x:N,y:j}}}});function y4(t){const[e,n="center"]=t.split("-");return[e,n]}var vB=h4,NB=p4,wB=m4,jB=x4,b4=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),kB="VisuallyHidden",SB=b.forwardRef((t,e)=>r.jsx(mt.span,{...t,ref:e,style:{...b4,...t.style}}));SB.displayName=kB;var CB=[" ","Enter","ArrowUp","ArrowDown"],EB=[" ","Enter"],qo="Select",[cp,dp,TB]=p0(qo),[cc]=qi(qo,[TB,d4]),up=d4(),[MB,Qi]=cc(qo),[AB,IB]=cc(qo),v4=t=>{const{__scopeSelect:e,children:n,open:s,defaultOpen:a,onOpenChange:i,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:N}=t,j=up(e),[v,k]=b.useState(null),[C,E]=b.useState(null),[M,P]=b.useState(!1),H=$f(h),[L,R]=_o({prop:s,defaultProp:a??!1,onChange:i,caller:qo}),[O,ne]=_o({prop:o,defaultProp:c,onChange:u,caller:qo}),ie=b.useRef(null),_=v?N||!!v.closest("form"):!0,[ce,pe]=b.useState(new Set),z=Array.from(ce).map(q=>q.props.value).join(";");return r.jsx(vB,{...j,children:r.jsxs(MB,{required:y,scope:e,trigger:v,onTriggerChange:k,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:M,onValueNodeHasChildrenChange:P,contentId:Pi(),value:O,onValueChange:ne,open:L,onOpenChange:R,dir:H,triggerPointerDownPosRef:ie,disabled:g,children:[r.jsx(cp.Provider,{scope:e,children:r.jsx(AB,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback(q=>{pe(F=>new Set(F).add(q))},[]),onNativeOptionRemove:b.useCallback(q=>{pe(F=>{const A=new Set(F);return A.delete(q),A})},[]),children:n})}),_?r.jsxs(V4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:O,onChange:q=>ne(q.target.value),disabled:g,form:N,children:[O===void 0?r.jsx("option",{value:""}):null,Array.from(ce)]},z):null]})})};v4.displayName=qo;var N4="SelectTrigger",w4=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:s=!1,...a}=t,i=up(n),o=Qi(N4,n),c=o.disabled||s,u=Tt(e,o.onTriggerChange),h=dp(n),f=b.useRef("touch"),[m,g,y]=W4(j=>{const v=h().filter(E=>!E.disabled),k=v.find(E=>E.value===o.value),C=U4(v,j,k);C!==void 0&&o.onValueChange(C.value)}),N=j=>{c||(o.onOpenChange(!0),y()),j&&(o.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return r.jsx(NB,{asChild:!0,...i,children:r.jsx(mt.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":H4(o.value)?"":void 0,...a,ref:u,onClick:ht(a.onClick,j=>{j.currentTarget.focus(),f.current!=="mouse"&&N(j)}),onPointerDown:ht(a.onPointerDown,j=>{f.current=j.pointerType;const v=j.target;v.hasPointerCapture(j.pointerId)&&v.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(N(j),j.preventDefault())}),onKeyDown:ht(a.onKeyDown,j=>{const v=m.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(v&&j.key===" ")&&CB.includes(j.key)&&(N(),j.preventDefault())})})})});w4.displayName=N4;var j4="SelectValue",k4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:a,children:i,placeholder:o="",...c}=t,u=Qi(j4,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Tt(e,u.onValueNodeChange);return fs(()=>{h(f)},[h,f]),r.jsx(mt.span,{...c,ref:m,style:{pointerEvents:"none"},children:H4(u.value)?r.jsx(r.Fragment,{children:o}):i})});k4.displayName=j4;var RB="SelectIcon",S4=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:s,...a}=t;return r.jsx(mt.span,{"aria-hidden":!0,...a,ref:e,children:s||"▼"})});S4.displayName=RB;var PB="SelectPortal",C4=t=>r.jsx(c0,{asChild:!0,...t});C4.displayName=PB;var Go="SelectContent",E4=b.forwardRef((t,e)=>{const n=Qi(Go,t.__scopeSelect),[s,a]=b.useState();if(fs(()=>{a(new DocumentFragment)},[]),!n.open){const i=s;return i?Bd.createPortal(r.jsx(T4,{scope:t.__scopeSelect,children:r.jsx(cp.Slot,{scope:t.__scopeSelect,children:r.jsx("div",{children:t.children})})}),i):null}return r.jsx(M4,{...t,ref:e})});E4.displayName=Go;var Tr=10,[T4,Xi]=cc(Go),OB="SelectContentImpl",DB=Sd("SelectContent.RemoveScroll"),M4=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:N,hideWhenDetached:j,avoidCollisions:v,...k}=t,C=Qi(Go,n),[E,M]=b.useState(null),[P,H]=b.useState(null),L=Tt(e,K=>M(K)),[R,O]=b.useState(null),[ne,ie]=b.useState(null),_=dp(n),[ce,pe]=b.useState(!1),z=b.useRef(!1);b.useEffect(()=>{if(E)return Wj(E)},[E]),Dj();const q=b.useCallback(K=>{const[G,...ge]=_().map(Se=>Se.ref.current),[ae]=ge.slice(-1),fe=document.activeElement;for(const Se of K)if(Se===fe||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===G&&P&&(P.scrollTop=0),Se===ae&&P&&(P.scrollTop=P.scrollHeight),Se==null||Se.focus(),document.activeElement!==fe))return},[_,P]),F=b.useCallback(()=>q([R,E]),[q,R,E]);b.useEffect(()=>{ce&&F()},[ce,F]);const{onOpenChange:A,triggerPointerDownPosRef:J}=C;b.useEffect(()=>{if(E){let K={x:0,y:0};const G=ae=>{var fe,Se;K={x:Math.abs(Math.round(ae.pageX)-(((fe=J.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((Se=J.current)==null?void 0:Se.y)??0))}},ge=ae=>{K.x<=10&&K.y<=10?ae.preventDefault():E.contains(ae.target)||A(!1),document.removeEventListener("pointermove",G),J.current=null};return J.current!==null&&(document.addEventListener("pointermove",G),document.addEventListener("pointerup",ge,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",ge,{capture:!0})}}},[E,A,J]),b.useEffect(()=>{const K=()=>A(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[A]);const[U,D]=W4(K=>{const G=_().filter(fe=>!fe.disabled),ge=G.find(fe=>fe.ref.current===document.activeElement),ae=U4(G,K,ge);ae&&setTimeout(()=>ae.ref.current.focus())}),W=b.useCallback((K,G,ge)=>{const ae=!z.current&&!ge;(C.value!==void 0&&C.value===G||ae)&&(O(K),ae&&(z.current=!0))},[C.value]),le=b.useCallback(()=>E==null?void 0:E.focus(),[E]),xe=b.useCallback((K,G,ge)=>{const ae=!z.current&&!ge;(C.value!==void 0&&C.value===G||ae)&&ie(K)},[C.value]),Me=s==="popper"?qx:A4,te=Me===qx?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:N,hideWhenDetached:j,avoidCollisions:v}:{};return r.jsx(T4,{scope:n,content:E,viewport:P,onViewportChange:H,itemRefCallback:W,selectedItem:R,onItemLeave:le,itemTextRefCallback:xe,focusSelectedItem:F,selectedItemText:ne,position:s,isPositioned:ce,searchRef:U,children:r.jsx(d0,{as:DB,allowPinchZoom:!0,children:r.jsx(l0,{asChild:!0,trapped:C.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:ht(a,K=>{var G;(G=C.trigger)==null||G.focus({preventScroll:!0}),K.preventDefault()}),children:r.jsx(o0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:r.jsx(Me,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:K=>K.preventDefault(),...k,...te,onPlaced:()=>pe(!0),ref:L,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:ht(k.onKeyDown,K=>{const G=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!G&&K.key.length===1&&D(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let ae=_().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(K.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const fe=K.target,Se=ae.indexOf(fe);ae=ae.slice(Se+1)}setTimeout(()=>q(ae)),K.preventDefault()}})})})})})})});M4.displayName=OB;var LB="SelectItemAlignedPosition",A4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:s,...a}=t,i=Qi(Go,n),o=Xi(Go,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=Tt(e,L=>f(L)),g=dp(n),y=b.useRef(!1),N=b.useRef(!0),{viewport:j,selectedItem:v,selectedItemText:k,focusSelectedItem:C}=o,E=b.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&j&&v&&k){const L=i.trigger.getBoundingClientRect(),R=h.getBoundingClientRect(),O=i.valueNode.getBoundingClientRect(),ne=k.getBoundingClientRect();if(i.dir!=="rtl"){const fe=ne.left-R.left,Se=O.left-fe,et=L.left-Se,st=L.width+et,_t=Math.max(st,R.width),At=window.innerWidth-Tr,Ut=Lh(Se,[Tr,Math.max(Tr,At-_t)]);c.style.minWidth=st+"px",c.style.left=Ut+"px"}else{const fe=R.right-ne.right,Se=window.innerWidth-O.right-fe,et=window.innerWidth-L.right-Se,st=L.width+et,_t=Math.max(st,R.width),At=window.innerWidth-Tr,Ut=Lh(Se,[Tr,Math.max(Tr,At-_t)]);c.style.minWidth=st+"px",c.style.right=Ut+"px"}const ie=g(),_=window.innerHeight-Tr*2,ce=j.scrollHeight,pe=window.getComputedStyle(h),z=parseInt(pe.borderTopWidth,10),q=parseInt(pe.paddingTop,10),F=parseInt(pe.borderBottomWidth,10),A=parseInt(pe.paddingBottom,10),J=z+q+ce+A+F,U=Math.min(v.offsetHeight*5,J),D=window.getComputedStyle(j),W=parseInt(D.paddingTop,10),le=parseInt(D.paddingBottom,10),xe=L.top+L.height/2-Tr,Me=_-xe,te=v.offsetHeight/2,K=v.offsetTop+te,G=z+q+K,ge=J-G;if(G<=xe){const fe=ie.length>0&&v===ie[ie.length-1].ref.current;c.style.bottom="0px";const Se=h.clientHeight-j.offsetTop-j.offsetHeight,et=Math.max(Me,te+(fe?le:0)+Se+F),st=G+et;c.style.height=st+"px"}else{const fe=ie.length>0&&v===ie[0].ref.current;c.style.top="0px";const et=Math.max(xe,z+j.offsetTop+(fe?W:0)+te)+ge;c.style.height=et+"px",j.scrollTop=G-xe+j.offsetTop}c.style.margin=`${Tr}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=_+"px",s==null||s(),requestAnimationFrame(()=>y.current=!0)}},[g,i.trigger,i.valueNode,c,h,j,v,k,i.dir,s]);fs(()=>E(),[E]);const[M,P]=b.useState();fs(()=>{h&&P(window.getComputedStyle(h).zIndex)},[h]);const H=b.useCallback(L=>{L&&N.current===!0&&(E(),C==null||C(),N.current=!1)},[E,C]);return r.jsx(zB,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:H,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:r.jsx(mt.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});A4.displayName=LB;var _B="SelectPopperPosition",qx=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=Tr,...i}=t,o=up(n);return r.jsx(wB,{...o,...i,ref:e,align:s,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});qx.displayName=_B;var[zB,yy]=cc(Go,{}),Gx="SelectViewport",I4=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:s,...a}=t,i=Xi(Gx,n),o=yy(Gx,n),c=Tt(e,i.onViewportChange),u=b.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(cp.Slot,{scope:n,children:r.jsx(mt.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:ht(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:g}=o;if(g!=null&&g.current&&m){const y=Math.abs(u.current-f.scrollTop);if(y>0){const N=window.innerHeight-Tr*2,j=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),k=Math.max(j,v);if(k0?M:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});I4.displayName=Gx;var R4="SelectGroup",[$B,FB]=cc(R4),BB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=Pi();return r.jsx($B,{scope:n,id:a,children:r.jsx(mt.div,{role:"group","aria-labelledby":a,...s,ref:e})})});BB.displayName=R4;var P4="SelectLabel",VB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=FB(P4,n);return r.jsx(mt.div,{id:a.id,...s,ref:e})});VB.displayName=P4;var If="SelectItem",[HB,O4]=cc(If),D4=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:i,...o}=t,c=Qi(If,n),u=Xi(If,n),h=c.value===s,[f,m]=b.useState(i??""),[g,y]=b.useState(!1),N=Tt(e,C=>{var E;return(E=u.itemRefCallback)==null?void 0:E.call(u,C,s,a)}),j=Pi(),v=b.useRef("touch"),k=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(HB,{scope:n,value:s,disabled:a,textId:j,isSelected:h,onItemTextChange:b.useCallback(C=>{m(E=>E||((C==null?void 0:C.textContent)??"").trim())},[]),children:r.jsx(cp.ItemSlot,{scope:n,value:s,disabled:a,textValue:f,children:r.jsx(mt.div,{role:"option","aria-labelledby":j,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:ht(o.onFocus,()=>y(!0)),onBlur:ht(o.onBlur,()=>y(!1)),onClick:ht(o.onClick,()=>{v.current!=="mouse"&&k()}),onPointerUp:ht(o.onPointerUp,()=>{v.current==="mouse"&&k()}),onPointerDown:ht(o.onPointerDown,C=>{v.current=C.pointerType}),onPointerMove:ht(o.onPointerMove,C=>{var E;v.current=C.pointerType,a?(E=u.onItemLeave)==null||E.call(u):v.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ht(o.onPointerLeave,C=>{var E;C.currentTarget===document.activeElement&&((E=u.onItemLeave)==null||E.call(u))}),onKeyDown:ht(o.onKeyDown,C=>{var M;((M=u.searchRef)==null?void 0:M.current)!==""&&C.key===" "||(EB.includes(C.key)&&k(),C.key===" "&&C.preventDefault())})})})})});D4.displayName=If;var ad="SelectItemText",L4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:a,...i}=t,o=Qi(ad,n),c=Xi(ad,n),u=O4(ad,n),h=IB(ad,n),[f,m]=b.useState(null),g=Tt(e,k=>m(k),u.onItemTextChange,k=>{var C;return(C=c.itemTextRefCallback)==null?void 0:C.call(c,k,u.value,u.disabled)}),y=f==null?void 0:f.textContent,N=b.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:j,onNativeOptionRemove:v}=h;return fs(()=>(j(N),()=>v(N)),[j,v,N]),r.jsxs(r.Fragment,{children:[r.jsx(mt.span,{id:u.textId,...i,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Bd.createPortal(i.children,o.valueNode):null]})});L4.displayName=ad;var _4="SelectItemIndicator",z4=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return O4(_4,n).isSelected?r.jsx(mt.span,{"aria-hidden":!0,...s,ref:e}):null});z4.displayName=_4;var Jx="SelectScrollUpButton",$4=b.forwardRef((t,e)=>{const n=Xi(Jx,t.__scopeSelect),s=yy(Jx,t.__scopeSelect),[a,i]=b.useState(!1),o=Tt(e,s.onScrollButtonChange);return fs(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollTop>0;i(h)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?r.jsx(B4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});$4.displayName=Jx;var Yx="SelectScrollDownButton",F4=b.forwardRef((t,e)=>{const n=Xi(Yx,t.__scopeSelect),s=yy(Yx,t.__scopeSelect),[a,i]=b.useState(!1),o=Tt(e,s.onScrollButtonChange);return fs(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?r.jsx(B4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});F4.displayName=Yx;var B4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=t,i=Xi("SelectScrollButton",n),o=b.useRef(null),c=dp(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),fs(()=>{var f;const h=c().find(m=>m.ref.current===document.activeElement);(f=h==null?void 0:h.ref.current)==null||f.scrollIntoView({block:"nearest"})},[c]),r.jsx(mt.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:ht(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(s,50))}),onPointerMove:ht(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(s,50))}),onPointerLeave:ht(a.onPointerLeave,()=>{u()})})}),WB="SelectSeparator",UB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return r.jsx(mt.div,{"aria-hidden":!0,...s,ref:e})});UB.displayName=WB;var Qx="SelectArrow",KB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=up(n),i=Qi(Qx,n),o=Xi(Qx,n);return i.open&&o.position==="popper"?r.jsx(jB,{...a,...s,ref:e}):null});KB.displayName=Qx;var qB="SelectBubbleInput",V4=b.forwardRef(({__scopeSelect:t,value:e,...n},s)=>{const a=b.useRef(null),i=Tt(s,a),o=g0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("change",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(mt.select,{...n,style:{...b4,...n.style},ref:i,defaultValue:e})});V4.displayName=qB;function H4(t){return t===""||t===void 0}function W4(t){const e=$i(t),n=b.useRef(""),s=b.useRef(0),a=b.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(s.current),h!==""&&(s.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),i=b.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,i]}function U4(t,e,n){const a=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let o=GB(t,Math.max(i,0));a.length===1&&(o=o.filter(h=>h!==n));const u=o.find(h=>h.textValue.toLowerCase().startsWith(a.toLowerCase()));return u!==n?u:void 0}function GB(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var JB=v4,K4=w4,YB=k4,QB=S4,XB=C4,q4=E4,ZB=I4,G4=D4,eV=L4,tV=z4,nV=$4,sV=F4;const Pl=JB,Ol=YB,jo=b.forwardRef(({className:t,children:e,...n},s)=>r.jsxs(K4,{ref:s,className:Mt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,r.jsx(QB,{asChild:!0,children:r.jsx(kd,{className:"h-4 w-4 opacity-50"})})]}));jo.displayName=K4.displayName;const ko=b.forwardRef(({className:t,children:e,position:n="popper",...s},a)=>r.jsx(XB,{children:r.jsxs(q4,{ref:a,className:Mt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1",t),position:n,...s,children:[r.jsx(nV,{className:"flex cursor-default items-center justify-center py-1",children:r.jsx(sj,{className:"h-4 w-4"})}),r.jsx(ZB,{className:"p-1",children:e}),r.jsx(sV,{className:"flex cursor-default items-center justify-center py-1",children:r.jsx(kd,{className:"h-4 w-4"})})]})}));ko.displayName=q4.displayName;const Ws=b.forwardRef(({className:t,children:e,...n},s)=>r.jsxs(G4,{ref:s,className:Mt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(tV,{children:r.jsx(Of,{className:"h-4 w-4"})})}),r.jsx(eV,{children:e})]}));Ws.displayName=G4.displayName;function rV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(null),[u,h]=b.useState({name:"",appId:"",path:"",sort:0}),[f,m]=b.useState(!1);async function g(){s(!0);try{const k=await De("/api/admin/linked-miniprograms");if(k!=null&&k.success&&Array.isArray(k.data)){const C=[...k.data].sort((E,M)=>(E.sort??0)-(M.sort??0));e(C)}}catch(k){console.error("Load linked miniprograms error:",k),se.error("加载失败")}finally{s(!1)}}b.useEffect(()=>{g()},[]);function y(){c(null),h({name:"",appId:"",path:"",sort:t.length}),i(!0)}function N(k){c(k),h({name:k.name,appId:k.appId,path:k.path??"",sort:k.sort??0}),i(!0)}async function j(){const k=u.name.trim(),C=u.appId.trim();if(!k||!C){se.error("请填写小程序名称和 AppID");return}m(!0);try{if(o){const E=await Dt("/api/admin/linked-miniprograms",{key:o.key,name:k,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(se.success("已更新"),i(!1),g()):se.error((E==null?void 0:E.error)??"更新失败")}else{const E=await Nt("/api/admin/linked-miniprograms",{name:k,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(se.success("已添加"),i(!1),g()):se.error((E==null?void 0:E.error)??"添加失败")}}catch{se.error("操作失败")}finally{m(!1)}}async function v(k){if(confirm(`确定要删除「${k.name}」吗?`))try{const C=await ea(`/api/admin/linked-miniprograms/${k.key}`);C!=null&&C.success?(se.success("已删除"),g()):se.error((C==null?void 0:C.error)??"删除失败")}catch{se.error("删除失败")}}return r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5 text-[#38bdac]"}),"关联小程序管理"]}),r.jsx(Lt,{className:"text-gray-400",children:"添加后生成 32 位密钥,链接标签选择小程序时存密钥;小程序端点击 #标签 时用密钥查 appId 再跳转。需在 app.json 的 navigateToMiniProgramAppIdList 中配置目标 AppID。"})]}),r.jsxs(Te,{children:[r.jsxs("div",{className:"flex justify-end gap-2 mb-4",children:[r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>g(),title:"刷新",children:r.jsx($e,{className:"w-4 h-4"})}),r.jsxs(X,{onClick:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加关联小程序"]})]}),n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"名称"}),r.jsx(we,{className:"text-gray-400",children:"密钥"}),r.jsx(we,{className:"text-gray-400",children:"AppID"}),r.jsx(we,{className:"text-gray-400",children:"路径"}),r.jsx(we,{className:"text-gray-400 w-24",children:"排序"}),r.jsx(we,{className:"text-gray-400 w-32",children:"操作"})]})}),r.jsxs(ns,{children:[t.map(k=>r.jsxs(lt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-white",children:k.name}),r.jsx(ve,{className:"text-gray-300 font-mono text-xs",children:k.key}),r.jsx(ve,{className:"text-gray-300 font-mono text-sm",children:k.appId}),r.jsx(ve,{className:"text-gray-400 text-sm",children:k.path||"—"}),r.jsx(ve,{className:"text-gray-300",children:k.sort??0}),r.jsx(ve,{children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/20",onClick:()=>N(k),children:r.jsx(Yg,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:bg-red-500/20",onClick:()=>v(k),children:r.jsx(Yn,{className:"w-4 h-4"})})]})})]},k.key)),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无关联小程序,点击「添加关联小程序」开始配置"})})]})]})]})]}),r.jsx(Rt,{open:a,onOpenChange:i,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[r.jsxs(Pt,{className:"gap-1",children:[r.jsx(Ot,{className:"text-base",children:o?"编辑关联小程序":"添加关联小程序"}),r.jsx(Cd,{className:"text-gray-400 text-xs",children:"填写目标小程序的名称和 AppID,路径可选(为空则打开首页)"})]}),r.jsxs("div",{className:"space-y-3 py-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"小程序名称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:Soul 创业派对",value:u.name,onChange:k=>h(C=>({...C,name:k.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"AppID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono h-8 text-sm",placeholder:"例如:wxb8bbb2b10dec74aa",value:u.appId,onChange:k=>h(C=>({...C,appId:k.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"路径(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:pages/index/index",value:u.path,onChange:k=>h(C=>({...C,path:k.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"排序"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm w-20",value:u.sort,onChange:k=>h(C=>({...C,sort:parseInt(k.target.value,10)||0}))})]})]}),r.jsxs(tn,{className:"gap-2 pt-1",children:[r.jsx(X,{variant:"outline",onClick:()=>i(!1),className:"border-gray-600",children:"取消"}),r.jsx(X,{onClick:j,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:f?"保存中...":"保存"})]})]})})]})}const aV=["一","二","三","四","五","六","七","八","九","十"];function iV(t){return t.title==="序言"||t.title.includes("序言")}function Mw(t){const e=[];for(const n of t.chapters)for(const s of n.sections)e.push(s.id);return e.length===0?"暂无章节":e.length===1?e[0]:`${e[0]}~${e[e.length-1]}`}function _g(t){return t.startsWith("part:")?{type:"part",id:t.slice(5)}:t.startsWith("chapter:")?{type:"chapter",id:t.slice(8)}:t.startsWith("section:")?{type:"section",id:t.slice(8)}:null}function oV({parts:t,expandedParts:e,onTogglePart:n,onReorder:s,onReadSection:a,onDeleteSection:i,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:N,pinnedSectionIds:j=[]}){const[v,k]=b.useState(null),[C,E]=b.useState(null),M=(_,ce)=>(v==null?void 0:v.type)===_&&(v==null?void 0:v.id)===ce,P=(_,ce)=>(C==null?void 0:C.type)===_&&(C==null?void 0:C.id)===ce,H=b.useCallback(()=>{const _=[];for(const ce of t)for(const pe of ce.chapters)for(const z of pe.sections)_.push({id:z.id,partId:ce.id,partTitle:ce.title,chapterId:pe.id,chapterTitle:pe.title});return _},[t]),L=b.useCallback(async(_,ce,pe,z)=>{var U;_.preventDefault(),_.stopPropagation();const q=_.dataTransfer.getData("text/plain"),F=_g(q);if(!F||F.type===ce&&F.id===pe)return;const A=H(),J=new Map(A.map(D=>[D.id,D]));if(F.type==="part"&&ce==="part"){const D=t.map(te=>te.id),W=D.indexOf(F.id),le=D.indexOf(pe);if(W===-1||le===-1)return;const xe=[...D];xe.splice(W,1),xe.splice(WG.id===te);if(K)for(const G of K.chapters)for(const ge of G.sections){const ae=J.get(ge.id);ae&&Me.push(ae)}}await s(Me);return}if(F.type==="chapter"&&(ce==="chapter"||ce==="section"||ce==="part")){const D=t.find(ae=>ae.chapters.some(fe=>fe.id===F.id)),W=D==null?void 0:D.chapters.find(ae=>ae.id===F.id);if(!D||!W)return;let le,xe,Me=null;if(ce==="section"){const ae=J.get(pe);if(!ae)return;le=ae.partId,xe=ae.partTitle,Me=pe}else if(ce==="chapter"){const ae=t.find(et=>et.chapters.some(st=>st.id===pe)),fe=ae==null?void 0:ae.chapters.find(et=>et.id===pe);if(!ae||!fe)return;le=ae.id,xe=ae.title;const Se=A.filter(et=>et.chapterId===pe).pop();Me=(Se==null?void 0:Se.id)??null}else{const ae=t.find(Se=>Se.id===pe);if(!ae||!ae.chapters[0])return;le=ae.id,xe=ae.title;const fe=A.filter(Se=>Se.partId===ae.id&&Se.chapterId===ae.chapters[0].id);Me=((U=fe[fe.length-1])==null?void 0:U.id)??null}const te=W.sections.map(ae=>ae.id),K=A.filter(ae=>!te.includes(ae.id));let G=K.length;if(Me){const ae=K.findIndex(fe=>fe.id===Me);ae>=0&&(G=ae+1)}const ge=te.map(ae=>({...J.get(ae),partId:le,partTitle:xe,chapterId:W.id,chapterTitle:W.title}));await s([...K.slice(0,G),...ge,...K.slice(G)]);return}if(F.type==="section"&&(ce==="section"||ce==="chapter"||ce==="part")){if(!z)return;const{partId:D,partTitle:W,chapterId:le,chapterTitle:xe}=z;let Me;if(ce==="section")Me=A.findIndex(fe=>fe.id===pe);else if(ce==="chapter"){const fe=A.filter(Se=>Se.chapterId===pe).pop();Me=fe?A.findIndex(Se=>Se.id===fe.id)+1:A.length}else{const fe=t.find(st=>st.id===pe);if(!(fe!=null&&fe.chapters[0]))return;const Se=A.filter(st=>st.partId===fe.id&&st.chapterId===fe.chapters[0].id),et=Se[Se.length-1];Me=et?A.findIndex(st=>st.id===et.id)+1:0}const te=A.findIndex(fe=>fe.id===F.id);if(te===-1)return;const K=A.filter(fe=>fe.id!==F.id),G=te({onDragEnter:z=>{z.preventDefault(),z.stopPropagation(),z.dataTransfer.dropEffect="move",E({type:_,id:ce})},onDragOver:z=>{z.preventDefault(),z.stopPropagation(),z.dataTransfer.dropEffect="move",E({type:_,id:ce})},onDragLeave:()=>E(null),onDrop:z=>{E(null);const q=_g(z.dataTransfer.getData("text/plain"));if(q&&!(_==="section"&&q.type==="section"&&q.id===ce))if(_==="part")if(q.type==="part")L(z,"part",ce);else{const F=t.find(J=>J.id===ce);(F==null?void 0:F.chapters[0])&&pe&&L(z,"part",ce,pe)}else _==="chapter"&&pe?(q.type==="section"||q.type==="chapter")&&L(z,"chapter",ce,pe):_==="section"&&pe&&L(z,"section",ce,pe)}}),O=_=>aV[_]??String(_+1),ne=_=>t.slice(0,_).filter(ce=>!iV(ce)).length,ie=_=>r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-gray-500 font-mono text-xs tabular-nums shrink-0 mr-1.5 max-w-[72px] truncate",title:`章节ID: ${_.id}`,children:_.id}),r.jsx("span",{className:"truncate",children:_.title})]});return r.jsx("div",{className:"space-y-3",children:t.map((_,ce)=>{var W,le,xe,Me;const pe=_.title==="序言"||_.title.includes("序言"),z=_.title==="尾声"||_.title.includes("尾声"),q=_.title==="附录"||_.title.includes("附录"),F=P("part",_.id),A=e.includes(_.id),J=_.chapters.length,U=_.chapters.reduce((te,K)=>te+K.sections.length,0);if(pe&&_.chapters.length===1&&_.chapters[0].sections.length===1){const te=_.chapters[0].sections[0],K=P("section",te.id),G={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return r.jsxs("div",{draggable:!0,onDragStart:ge=>{ge.stopPropagation(),ge.dataTransfer.setData("text/plain","section:"+te.id),ge.dataTransfer.effectAllowed="move",k({type:"section",id:te.id})},onDragEnd:()=>{k(null),E(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${K?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",te.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",te.id,G),children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ge=>ge.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(te.id),onChange:()=>y(te.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:r.jsx(Gs,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",te.title]}),j.includes(te.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>ge.stopPropagation(),children:[te.price===0||te.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",te.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",te.clickCount??0," · 付款 ",te.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(te.hotScore??0).toFixed(1)," · 第",te.hotRank&&te.hotRank>0?te.hotRank:"-","名"]}),N&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(te),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(te),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(te),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}if(_.id==="part-2026-daily"){const te=P("part",_.id);return r.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${te?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...R("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((W=_.chapters[0])==null?void 0:W.id)??"",chapterTitle:((le=_.chapters[0])==null?void 0:le.title)??""}),children:[r.jsxs("div",{draggable:!0,onDragStart:K=>{K.stopPropagation(),K.dataTransfer.setData("text/plain","part:"+_.id),K.dataTransfer.effectAllowed="move",k({type:"part",id:_.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,onClick:()=>n(_.id),children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),r.jsxs("div",{children:[r.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Mw(_)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:K=>K.stopPropagation(),onClick:K=>K.stopPropagation(),children:[o&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),h&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),f&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})}),r.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[J," 章 · ",U," 节"]}),A?r.jsx(kd,{className:"w-5 h-5 text-gray-500"}):r.jsx(Dl,{className:"w-5 h-5 text-gray-500"})]})]}),A&&_.chapters.length>0&&r.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map(K=>r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:K.title}),r.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:G=>G.stopPropagation(),children:[m&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(_,K),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),c&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),u&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(_,K),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]}),r.jsx("div",{className:"space-y-1 pl-2",children:K.sections.map(G=>{const ge=P("section",G.id);return r.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+G.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:G.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${ge?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",G.id,{partId:_.id,partTitle:_.title,chapterId:K.id,chapterTitle:K.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(G.id),onChange:()=>y(G.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ie(G)}),j.includes(G.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),N&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]},G.id)})})]},K.id))})]},_.id)}if(q)return r.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),r.jsx("div",{className:"space-y-3",children:_.chapters.map((te,K)=>te.sections.length>0?te.sections.map(G=>{const ge=P("section",G.id);return r.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+G.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:G.id})},onDragEnd:()=>{k(null),E(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 group cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${ge?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",G.id,{partId:_.id,partTitle:_.title,chapterId:te.id,chapterTitle:te.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(G.id),onChange:()=>y(G.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",K+1," | ",te.title," | ",G.title]}),j.includes(G.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),N&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]}),r.jsx(Dl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},G.id)}):r.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[r.jsxs("span",{className:"text-sm text-gray-500",children:["附录",K+1," | ",te.title,"(空)"]}),r.jsx(Dl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},te.id))})]},_.id);if(z&&_.chapters.length===1&&_.chapters[0].sections.length===1){const te=_.chapters[0].sections[0],K=P("section",te.id),G={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return r.jsxs("div",{draggable:!0,onDragStart:ge=>{ge.stopPropagation(),ge.dataTransfer.setData("text/plain","section:"+te.id),ge.dataTransfer.effectAllowed="move",k({type:"section",id:te.id})},onDragEnd:()=>{k(null),E(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${K?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",te.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",te.id,G),children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ge=>ge.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(te.id),onChange:()=>y(te.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:r.jsx(Gs,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",te.title]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>ge.stopPropagation(),children:[te.price===0||te.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",te.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",te.clickCount??0," · 付款 ",te.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(te.hotScore??0).toFixed(1)," · 第",te.hotRank&&te.hotRank>0?te.hotRank:"-","名"]}),N&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(te),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(te),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(te),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}return z?r.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),r.jsx("div",{className:"space-y-3",children:_.chapters.map(te=>te.sections.map(K=>{const G=P("section",K.id);return r.jsxs("div",{draggable:!0,onDragStart:ge=>{ge.stopPropagation(),ge.dataTransfer.setData("text/plain","section:"+K.id),ge.dataTransfer.effectAllowed="move",k({type:"section",id:K.id})},onDragEnd:()=>{k(null),E(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${G?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",K.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",K.id,{partId:_.id,partTitle:_.title,chapterId:te.id,chapterTitle:te.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ge=>ge.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(K.id),onChange:()=>y(K.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsxs("span",{className:"text-sm text-gray-300",children:[te.title," | ",K.title]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",K.clickCount??0," · 付款 ",K.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(K.hotScore??0).toFixed(1)," · 第",K.hotRank&&K.hotRank>0?K.hotRank:"-","名"]}),N&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(K),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(K),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(K),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]})]},K.id)}))})]},_.id):r.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${F?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...R("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((xe=_.chapters[0])==null?void 0:xe.id)??"",chapterTitle:((Me=_.chapters[0])==null?void 0:Me.title)??""}),children:[r.jsxs("div",{draggable:!0,onDragStart:te=>{te.stopPropagation(),te.dataTransfer.setData("text/plain","part:"+_.id),te.dataTransfer.effectAllowed="move",k({type:"part",id:_.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,onClick:()=>n(_.id),children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac] flex items-center justify-center text-white font-bold shadow-lg shadow-[#38bdac]/30 shrink-0",children:O(ne(ce))}),r.jsxs("div",{children:[r.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Mw(_)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),children:[o&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),h&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),f&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})}),r.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[J," 章 · ",U," 节"]}),A?r.jsx(kd,{className:"w-5 h-5 text-gray-500"}):r.jsx(Dl,{className:"w-5 h-5 text-gray-500"})]})]}),A&&r.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map(te=>{const K=P("chapter",te.id);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsxs("div",{draggable:!0,onDragStart:G=>{G.stopPropagation(),G.dataTransfer.setData("text/plain","chapter:"+te.id),G.dataTransfer.effectAllowed="move",k({type:"chapter",id:te.id})},onDragEnd:()=>{k(null),E(null)},onDragEnter:G=>{G.preventDefault(),G.stopPropagation(),G.dataTransfer.dropEffect="move",E({type:"chapter",id:te.id})},onDragOver:G=>{G.preventDefault(),G.stopPropagation(),G.dataTransfer.dropEffect="move",E({type:"chapter",id:te.id})},onDragLeave:()=>E(null),onDrop:G=>{E(null);const ge=_g(G.dataTransfer.getData("text/plain"));if(!ge)return;const ae={partId:_.id,partTitle:_.title,chapterId:te.id,chapterTitle:te.title};(ge.type==="section"||ge.type==="chapter")&&L(G,"chapter",te.id,ae)},className:`flex-1 min-w-0 py-2 px-2 rounded cursor-grab active:cursor-grabbing select-none -mx-2 transition-all duration-200 flex items-center gap-2 ${K?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${M("chapter",te.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),r.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:te.title})]}),r.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:G=>G.stopPropagation(),children:[m&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(_,te),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),c&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),u&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(_,te),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]}),r.jsx("div",{className:"space-y-1 pl-2",children:te.sections.map(G=>{const ge=P("section",G.id);return r.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+G.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:G.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between py-2 px-3 rounded-lg group cursor-grab active:cursor-grabbing select-none min-h-[40px] transition-all duration-200 ${ge?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...R("section",G.id,{partId:_.id,partTitle:_.title,chapterId:te.id,chapterTitle:te.title}),children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(G.id),onChange:()=>y(G.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),r.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${G.price===0||G.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),r.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ie(G)}),j.includes(G.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ae=>ae.stopPropagation(),onClick:ae=>ae.stopPropagation(),children:[G.isNew&&r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),G.price===0||G.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",G.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),N&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),r.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(Vt,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(Yn,{className:"w-3.5 h-3.5"})})]})]})]},G.id)})})]},te.id)})})]},_.id)})})}function lV(t){var a;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(a=t==null?void 0:t.keyword)!=null&&a.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString(),s=n?`/api/admin/ckb/devices?${n}`:"/api/admin/ckb/devices";return De(s)}function cV(t){return De(`/api/db/person?personId=${encodeURIComponent(t)}`)}function dV(t){var s;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(s=t==null?void 0:t.keyword)!=null&&s.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString();return De(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const J4=11,Aw={personId:"",name:"",aliases:"",label:"",sceneId:J4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"09:00",endTime:"18:00",deviceGroups:""};function uV({open:t,onOpenChange:e,editingPerson:n,onSubmit:s}){var q;const a=!!n,[i,o]=b.useState(Aw),[c,u]=b.useState(!1),[h,f]=b.useState(!1),[m,g]=b.useState([]),[y,N]=b.useState(!1),[j,v]=b.useState(""),[k,C]=b.useState([]),[E,M]=b.useState(!1),[P,H]=b.useState(""),[L,R]=b.useState(!1),[O,ne]=b.useState({});b.useEffect(()=>{t&&(v(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",aliases:n.aliases??"",label:n.label??"",sceneId:J4,ckbApiKey:n.ckbApiKey??"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:n.remarkType??"phone",remarkFormat:n.remarkFormat??"",addFriendInterval:n.addFriendInterval??1,startTime:n.startTime??"09:00",endTime:n.endTime??"18:00",deviceGroups:n.deviceGroups??""}:{...Aw}),ne({}),m.length===0&&ie(""),k.length===0&&_(""))},[t,n]);const ie=async F=>{N(!0);try{const A=await lV({page:1,limit:50,keyword:F});A!=null&&A.success&&Array.isArray(A.devices)?g(A.devices):A!=null&&A.error&&se.error(A.error)}catch(A){se.error(A instanceof Error?A.message:"加载设备列表失败")}finally{N(!1)}},_=async F=>{M(!0);try{const A=await dV({page:1,limit:100,keyword:F});A!=null&&A.success&&Array.isArray(A.plans)?C(A.plans):A!=null&&A.error&&se.error(A.error)}catch{se.error("加载计划列表失败")}finally{M(!1)}},ce=F=>{const A=Array.isArray(F.deviceGroups)?F.deviceGroups.map(String).join(","):"";o(J=>({...J,ckbApiKey:F.apiKey||"",greeting:F.greeting||J.greeting,tips:F.tips||J.tips,remarkType:F.remarkType||J.remarkType,remarkFormat:F.remarkFormat||J.remarkFormat,addFriendInterval:F.addInterval||J.addFriendInterval,startTime:F.startTime||J.startTime,endTime:F.endTime||J.endTime,deviceGroups:A||J.deviceGroups})),R(!1),se.success(`已选择计划「${F.name}」,参数已覆盖`)},pe=P.trim()?k.filter(F=>(F.name||"").includes(P.trim())||String(F.id).includes(P.trim())):k,z=async()=>{var U;const F={};(!i.name||!String(i.name).trim())&&(F.name="请填写名称");const A=i.addFriendInterval;if((typeof A!="number"||A<1)&&(F.addFriendInterval="添加间隔至少为 1 分钟"),(((U=i.deviceGroups)==null?void 0:U.split(",").map(D=>D.trim()).filter(Boolean))??[]).length===0&&(F.deviceGroups="请至少选择 1 台设备"),ne(F),Object.keys(F).length>0){se.error(F.name||F.addFriendInterval||F.deviceGroups||"请完善必填项");return}u(!0);try{await s(i),e(!1)}catch(D){se.error(D instanceof Error?D.message:"保存失败")}finally{u(!1)}};return r.jsx(Rt,{open:t,onOpenChange:e,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs(Pt,{children:[r.jsx(Ot,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),r.jsx(Cd,{className:"text-gray-400 text-sm",children:a?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),r.jsxs("div",{className:"space-y-6 py-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Z,{className:"text-gray-400 text-xs",children:["名称 ",r.jsx("span",{className:"text-red-400",children:"*"})]}),r.jsx(re,{className:`bg-[#0a1628] text-white ${O.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:i.name,onChange:F=>{o(A=>({...A,name:F.target.value})),O.name&&ne(A=>({...A,name:void 0}))}}),O.name&&r.jsx("p",{className:"text-xs text-red-400",children:O.name})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:i.personId,onChange:F=>o(A=>({...A,personId:F.target.value})),disabled:a})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:i.label,onChange:F=>o(A=>({...A,label:F.target.value}))})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 卡卡, 若若",value:i.aliases,onChange:F=>o(A=>({...A,aliases:F.target.value}))})]})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[r.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),r.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5 relative",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"选择存客宝获客计划"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("div",{className:"flex-1 flex items-center bg-[#0a1628] border border-gray-700 rounded-md px-3 py-2 cursor-pointer hover:border-[#38bdac]/60 text-sm",onClick:()=>R(!L),children:i.ckbApiKey?r.jsx("span",{className:"text-white truncate",children:((q=k.find(F=>F.apiKey===i.ckbApiKey))==null?void 0:q.name)||`密钥: ${i.ckbApiKey.slice(0,20)}...`}):r.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),r.jsx(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{_(P),R(!0)},disabled:E,children:E?"加载...":"刷新"})]}),L&&r.jsxs("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-[#0b1828] border border-gray-700 rounded-lg shadow-xl max-h-64 flex flex-col",children:[r.jsx("div",{className:"p-2 border-b border-gray-700/60",children:r.jsx(re,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:P,onChange:F=>H(F.target.value),onKeyDown:F=>{F.key==="Enter"&&_(P)},autoFocus:!0})}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:pe.length===0?r.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:E?"加载中...":"暂无计划"}):pe.map(F=>r.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${i.ckbApiKey===F.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>ce(F),children:[r.jsxs("div",{className:"truncate",children:[r.jsx("span",{className:"font-medium",children:F.name}),r.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String(F.id)]})]}),F.enabled?r.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 rounded shrink-0 ml-2",children:"启用"}):r.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 rounded shrink-0 ml-2",children:"停用"})]},String(F.id)))}),r.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:r.jsx(X,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>R(!1),children:"关闭"})})]}),r.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Z,{className:"text-gray-400 text-xs",children:["选择设备 ",r.jsx("span",{className:"text-red-400",children:"*"})]}),r.jsxs("div",{className:`flex gap-2 rounded-md border ${O.deviceGroups?"border-red-500":"border-gray-700"}`,children:[r.jsx(re,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:i.deviceGroups?`已选择 ${i.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>f(!0)}),r.jsx(X,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),O.deviceGroups?r.jsx("p",{className:"text-xs text-red-400",children:O.deviceGroups}):r.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"好友备注"}),r.jsxs(Pl,{value:i.remarkType,onValueChange:F=>o(A=>({...A,remarkType:F})),children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{placeholder:"选择备注类型"})}),r.jsxs(ko,{children:[r.jsx(Ws,{value:"phone",children:"手机号"}),r.jsx(Ws,{value:"nickname",children:"昵称"}),r.jsx(Ws,{value:"source",children:"来源"})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"备注格式"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 手机号+SOUL链接人与事-{名称},留空用默认",value:i.remarkFormat,onChange:F=>o(A=>({...A,remarkFormat:F.target.value}))})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"打招呼语"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:i.greeting,onChange:F=>o(A=>({...A,greeting:F.target.value}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),r.jsx(re,{type:"number",min:1,className:`bg-[#0a1628] text-white ${O.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:i.addFriendInterval,onChange:F=>{o(A=>({...A,addFriendInterval:Number(F.target.value)||1})),O.addFriendInterval&&ne(A=>({...A,addFriendInterval:void 0}))}}),O.addFriendInterval&&r.jsx("p",{className:"text-xs text-red-400",children:O.addFriendInterval})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(re,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.startTime,onChange:F=>o(A=>({...A,startTime:F.target.value}))}),r.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),r.jsx(re,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.endTime,onChange:F=>o(A=>({...A,endTime:F.target.value}))})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"获客成功提示"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:i.tips,onChange:F=>o(A=>({...A,tips:F.target.value}))})]})]})]})]})]}),r.jsxs(tn,{className:"gap-3 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(X,{onClick:z,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":a?"保存":"添加"})]}),h&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:r.jsxs("div",{className:"w-full max-w-3xl max-h-[80vh] bg-[#0b1828] border border-gray-700 rounded-xl shadow-xl flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),r.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(re,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:j,onChange:F=>v(F.target.value),onKeyDown:F=>{F.key==="Enter"&&ie(j)}}),r.jsx(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>ie(j),disabled:y,children:"刷新"}),r.jsx(X,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:y?r.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?r.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):r.jsx("div",{className:"p-4 space-y-2",children:m.map(F=>{const A=String(F.id??""),J=i.deviceGroups?i.deviceGroups.split(",").map(W=>W.trim()).filter(Boolean):[],U=J.includes(A),D=()=>{let W;U?W=J.filter(le=>le!==A):W=[...J,A],o(le=>({...le,deviceGroups:W.join(",")})),W.length>0&&ne(le=>({...le,deviceGroups:void 0}))};return r.jsxs("label",{className:"flex items-center gap-3 rounded-lg border border-gray-700/60 bg-[#050c18] px-3 py-2 cursor-pointer hover:border-[#38bdac]/70",children:[r.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-[#38bdac]",checked:U,onChange:D}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white truncate max-w-xs",children:F.memo||F.wechatId||`设备 ${A}`}),F.status==="online"&&r.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),F.status==="offline"&&r.jsx("span",{className:"rounded-full bg-gray-600/20 text-gray-400 text-[11px] px-2 py-0.5",children:"离线"})]}),r.jsxs("div",{className:"text-[11px] text-gray-400 mt-0.5",children:[r.jsxs("span",{className:"mr-3",children:["ID: ",A]}),F.wechatId&&r.jsxs("span",{className:"mr-3",children:["微信号: ",F.wechatId]}),typeof F.totalFriend=="number"&&r.jsxs("span",{children:["好友数: ",F.totalFriend]})]})]})]},A)})})}),r.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[r.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",i.deviceGroups?i.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),r.jsx(X,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function hV(t,e){const n=new Map;for(const i of t){const o=i.partId||"part-1",c=i.partTitle||"未分类",u=i.chapterId||"chapter-1",h=i.chapterTitle||"未分类";n.has(o)||n.set(o,{id:o,title:c,chapters:new Map});const f=n.get(o);f.chapters.has(u)||f.chapters.set(u,{id:u,title:h,sections:[]}),f.chapters.get(u).sections.push({id:i.id,mid:i.mid,title:i.title,price:i.price??1,filePath:i.filePath,isFree:i.isFree,isNew:i.isNew,clickCount:i.clickCount??0,payCount:i.payCount??0,hotScore:i.hotScore??0,hotRank:e.get(i.id)??0})}const s=Array.from(n.values()).map(i=>({...i,chapters:Array.from(i.chapters.values())})),a=i=>i.title.includes("序言")?0:i.id==="part-2026-daily"?1.5:i.title.includes("附录")?2:i.title.includes("尾声")?3:1;return s.sort((i,o)=>{const c=a(i),u=a(o);return c!==u?c-u:0})}function fV(){var jc,as,Na;const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState([]),[o,c]=b.useState(null),[u,h]=b.useState(!1),[f,m]=b.useState(!1),[g,y]=b.useState(!1),[N,j]=b.useState(""),[v,k]=b.useState([]),[C,E]=b.useState(!1),[M,P]=b.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[H,L]=b.useState(null),[R,O]=b.useState(!1),[ne,ie]=b.useState(!1),[_,ce]=b.useState(null),[pe,z]=b.useState(!1),[q,F]=b.useState([]),[A,J]=b.useState(!1),[U,D]=b.useState(""),[W,le]=b.useState(""),[xe,Me]=b.useState(!1),[te,K]=b.useState(""),[G,ge]=b.useState(!1),[ae,fe]=b.useState(null),[Se,et]=b.useState(!1),[st,_t]=b.useState(!1),[At,Ut]=b.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[An,In]=b.useState(!1),[It,sn]=b.useState(!1),[on,Es]=b.useState(1),[xn,Wn]=b.useState([]),[Y,Ue]=b.useState(!1),[Qe,wt]=b.useState([]),[dt,at]=b.useState(!1),[xt,Xt]=b.useState(20),[ln,ss]=b.useState(!1),[xs,fr]=b.useState(!1),[ys,Lr]=b.useState([]),[me,ye]=b.useState([]),[Zt,Rn]=b.useState([]),[da,ua]=b.useState(!1),[_r,Qs]=b.useState(1),[ha,Xo]=b.useState(20),[fa,Zi]=b.useState(0),[pa,dc]=b.useState(1),[pr,ma]=b.useState(""),[Fs,mr]=b.useState(!1),[eo,Zo]=b.useState(null),[yt,jn]=b.useState({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),[zr,gr]=b.useState(!1),[to,xr]=b.useState(!1),[ga,$r]=b.useState(null),[Xs,Ga]=b.useState(null),[uc,Kt]=b.useState({}),[hc,yr]=b.useState(!1),[br,Fr]=b.useState(""),[Ja,no]=b.useState(""),[Br,bs]=b.useState([]),[Ya,vs]=b.useState(0),[Vr,fc]=b.useState(1),[pc,xa]=b.useState(!1),ya=b.useRef(null),Hr=b.useMemo(()=>{const T=new Map;return xn.forEach((B,de)=>{T.set(B.id,de+1)}),T},[xn]),yn=hV(t,Hr),so=t.length,ba=10,Wr=Math.max(1,Math.ceil(xn.length/ba)),$=xn.slice((on-1)*ba,on*ba),Pe=async()=>{s(!0);try{const T=await De("/api/db/book?action=list",{cache:"no-store"});e(Array.isArray(T==null?void 0:T.sections)?T.sections:[])}catch(T){console.error(T),e([])}finally{s(!1)}},_e=async()=>{Ue(!0);try{const T=await De("/api/db/book?action=ranking",{cache:"no-store"}),B=Array.isArray(T==null?void 0:T.sections)?T.sections:[];Wn(B);const de=B.filter(be=>be.isPinned).map(be=>be.id);wt(de)}catch(T){console.error(T),Wn([])}finally{Ue(!1)}};b.useEffect(()=>{Pe(),_e()},[]);const ct=T=>{i(B=>B.includes(T)?B.filter(de=>de!==T):[...B,T])},cn=b.useCallback(T=>{const B=t,de=T.flatMap(be=>{const qe=B.find(it=>it.id===be.id);return qe?[{...qe,partId:be.partId,partTitle:be.partTitle,chapterId:be.chapterId,chapterTitle:be.chapterTitle}]:[]});return e(de),Dt("/api/db/book",{action:"reorder",items:T}).then(be=>{be&&be.success===!1&&(e(B),se.error("排序失败: "+(be&&typeof be=="object"&&"error"in be?be.error:"未知错误")))}).catch(be=>{e(B),console.error("排序失败:",be),se.error("排序失败: "+(be instanceof Error?be.message:"网络或服务异常"))}),Promise.resolve()},[t]),ut=async T=>{if(confirm(`确定要删除章节「${T.title}」吗?此操作不可恢复。`))try{const B=await ea(`/api/db/book?id=${encodeURIComponent(T.id)}`);B&&B.success!==!1?(se.success("已删除"),Pe(),_e()):se.error("删除失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(B){console.error(B),se.error("删除失败")}},Qa=b.useCallback(async()=>{In(!0);try{const T=await De("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),B=T&&T.data;B&&typeof B.readWeight=="number"&&typeof B.recencyWeight=="number"&&typeof B.payWeight=="number"&&Ut({readWeight:Math.max(0,Math.min(1,B.readWeight)),recencyWeight:Math.max(0,Math.min(1,B.recencyWeight)),payWeight:Math.max(0,Math.min(1,B.payWeight))})}catch{}finally{In(!1)}},[]);b.useEffect(()=>{st&&Qa()},[st,Qa]);const dn=async()=>{const{readWeight:T,recencyWeight:B,payWeight:de}=At,be=T+B+de;if(Math.abs(be-1)>.001){se.error("三个权重之和必须等于 1");return}sn(!0);try{const qe=await Nt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:T,recencyWeight:B,payWeight:de},description:"文章排名算法权重"});qe&&qe.success!==!1?(se.success("排名权重已保存"),_t(!1),Pe(),_e()):se.error("保存失败: "+(qe&&typeof qe=="object"&&"error"in qe?qe.error:""))}catch(qe){console.error(qe),se.error("保存失败")}finally{sn(!1)}},Un=b.useCallback(async()=>{at(!0);try{const T=await De("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),B=T&&T.data;Array.isArray(B)&&wt(B)}catch{}finally{at(!1)}},[]),Ts=b.useCallback(async()=>{try{const T=await De("/api/db/persons");T!=null&&T.success&&T.persons&&Lr(T.persons.map(B=>{const de=B.deviceGroups,be=Array.isArray(de)?de.join(","):de??"";return{id:B.token??B.personId??"",personId:B.personId,name:B.name,aliases:B.aliases??"",label:B.label??"",ckbApiKey:B.ckbApiKey??"",ckbPlanId:B.ckbPlanId,remarkType:B.remarkType,remarkFormat:B.remarkFormat,addFriendInterval:B.addFriendInterval,startTime:B.startTime,endTime:B.endTime,deviceGroups:be}}))}catch{}},[]),Ms=b.useCallback(async()=>{try{const T=await De("/api/db/link-tags");T!=null&&T.success&&T.linkTags&&ye(T.linkTags.map(B=>({id:B.tagId,label:B.label,url:B.url,type:B.type||"url",appId:B.appId||"",pagePath:B.pagePath||""})))}catch{}},[]),vr=b.useCallback(async()=>{try{const T=await De("/api/db/ckb-person-leads");if(T!=null&&T.success&&T.byPerson){const B={};for(const de of T.byPerson)B[de.token]=de.total;Kt(B)}}catch{}},[]),va=b.useCallback(async(T,B,de=1)=>{Fr(T),no(B),yr(!0),fc(de),xa(!0);try{const be=await De(`/api/db/ckb-person-leads?token=${encodeURIComponent(T)}&page=${de}&pageSize=20`);be!=null&&be.success?(bs(be.records||[]),vs(be.total||0)):se.error((be==null?void 0:be.error)||"加载获客详情失败")}catch(be){se.error(be instanceof Error?be.message:"加载获客详情失败")}finally{xa(!1)}},[]),Zs=b.useCallback(async()=>{ua(!0);try{const T=new URLSearchParams({page:String(_r),pageSize:String(ha)}),B=pr.trim();B&&T.set("search",B);const de=await De(`/api/db/link-tags?${T.toString()}`);if(de!=null&&de.success){const be=Array.isArray(de.linkTags)?de.linkTags:[];Rn(be.map(qe=>({id:qe.tagId,label:qe.label,url:qe.url,type:qe.type||"url",appId:qe.appId||"",pagePath:qe.pagePath||""}))),Zi(typeof de.total=="number"?de.total:0),dc(typeof de.totalPages=="number"&&de.totalPages>0?de.totalPages:1)}}catch(T){console.error(T),se.error("加载链接标签失败")}finally{ua(!1)}},[_r,ha,pr]),[rs,Ur]=b.useState([]),[As,Nr]=b.useState(""),[Xa,Ns]=b.useState(!1),hp=b.useRef(null),mc=b.useCallback(async()=>{try{const T=await De("/api/admin/linked-miniprograms");T!=null&&T.success&&Array.isArray(T.data)&&Ur(T.data.map(B=>({...B,key:B.key})))}catch{}},[]),Za=rs.filter(T=>!As.trim()||T.name.toLowerCase().includes(As.toLowerCase())||T.key&&T.key.toLowerCase().includes(As.toLowerCase())||T.appId.toLowerCase().includes(As.toLowerCase())),Yd=async T=>{const B=Qe.includes(T)?Qe.filter(de=>de!==T):[...Qe,T];wt(B);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:B,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),_e()}catch{wt(Qe)}},gc=b.useCallback(async()=>{ss(!0);try{const T=await De("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),B=T&&T.data;typeof B=="number"&&B>0&&B<=100&&Xt(B)}catch{}finally{ss(!1)}},[]),el=async()=>{if(xt<1||xt>100){se.error("预览比例需在 1~100 之间");return}fr(!0);try{const T=await Nt("/api/db/config",{key:"unpaid_preview_percent",value:xt,description:"小程序未付费内容默认预览比例(%)"});T&&T.success!==!1?se.success("预览比例已保存"):se.error("保存失败: "+(T.error||""))}catch{se.error("保存失败")}finally{fr(!1)}};b.useEffect(()=>{Un(),gc(),Ts(),Ms(),vr(),mc()},[Un,gc,Ts,Ms,vr,mc]),b.useEffect(()=>{Zs()},[Zs]);const xc=async T=>{fe({section:T,orders:[]}),et(!0);try{const B=await De(`/api/db/book?action=section-orders&id=${encodeURIComponent(T.id)}`),de=B!=null&&B.success&&Array.isArray(B.orders)?B.orders:[];fe(be=>be?{...be,orders:de}:null)}catch(B){console.error(B),fe(de=>de?{...de,orders:[]}:null)}finally{et(!1)}},yc=async T=>{m(!0);try{const B=T.mid!=null&&T.mid>0?`/api/db/book?action=read&mid=${T.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(T.id)}`,de=await De(B);if(de!=null&&de.success&&de.section){const be=de.section,qe=be.editionPremium===!0;c({id:T.id,originalId:T.id,title:de.section.title??T.title,price:de.section.price??T.price,content:de.section.content??"",filePath:T.filePath,isFree:T.isFree||T.price===0,isNew:be.isNew??T.isNew,isPinned:Qe.includes(T.id),hotScore:T.hotScore??0,editionStandard:qe?!1:be.editionStandard??!0,editionPremium:qe})}else c({id:T.id,originalId:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree,isNew:T.isNew,isPinned:Qe.includes(T.id),hotScore:T.hotScore??0,editionStandard:!0,editionPremium:!1}),de&&!de.success&&se.error("无法读取文件内容: "+(de.error||"未知错误"))}catch(B){console.error(B),c({id:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree})}finally{m(!1)}},ro=async()=>{var T;if(o){y(!0);try{let B=o.content||"";const de=[new RegExp(`^#+\\s*${o.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${o.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(T=o.title)==null?void 0:T.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const Kn of de)B=B.replace(Kn,"");B=B.replace(/^\s*\n+/,"").trim();const be=o.originalId||o.id,qe=o.id!==be,it=await Dt("/api/db/book",{id:be,...qe?{newId:o.id}:{},title:o.title,price:o.isFree?0:o.price,content:B,isFree:o.isFree||o.price===0,isNew:o.isNew,hotScore:o.hotScore,editionStandard:o.editionPremium?!1:o.editionStandard??!0,editionPremium:o.editionPremium??!1,saveToFile:!0},{timeout:Zv}),bt=qe?o.id:be;o.isPinned!==Qe.includes(bt)&&await Yd(bt),it&&it.success!==!1?(se.success(`已保存:${o.title}`),c(null),Pe(),Ts(),Ms()):se.error("保存失败: "+(it&&typeof it=="object"&&"error"in it?it.error:"未知错误"))}catch(B){console.error(B);const de=B instanceof Error&&B.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";se.error(de)}finally{y(!1)}}},ao=async()=>{if(!M.id||!M.title){se.error("请填写章节ID和标题");return}y(!0);try{const T=yn.find(be=>be.id===M.partId),B=T==null?void 0:T.chapters.find(be=>be.id===M.chapterId),de=await Dt("/api/db/book",{id:M.id,title:M.title,price:M.isFree?0:M.price,content:M.content||"",partId:M.partId,partTitle:(T==null?void 0:T.title)??"",chapterId:M.chapterId,chapterTitle:(B==null?void 0:B.title)??"",isFree:M.isFree,isNew:M.isNew,editionStandard:M.editionPremium?!1:M.editionStandard??!0,editionPremium:M.editionPremium??!1,hotScore:M.hotScore??0,saveToFile:!1},{timeout:Zv});if(de&&de.success!==!1){if(M.isPinned){const be=[...Qe,M.id];wt(be);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:be,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}se.success(`章节创建成功:${M.title}`),h(!1),P({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),Pe(),Ts(),Ms()}else se.error("创建失败: "+(de&&typeof de=="object"&&"error"in de?de.error:"未知错误"))}catch(T){console.error(T),se.error("创建失败")}finally{y(!1)}},ei=T=>{P(B=>{var de;return{...B,partId:T.id,chapterId:((de=T.chapters[0])==null?void 0:de.id)??"chapter-1"}}),h(!0)},tl=T=>{L({id:T.id,title:T.title})},fp=async()=>{var T;if((T=H==null?void 0:H.title)!=null&&T.trim()){O(!0);try{const B=t.map(be=>({id:be.id,partId:be.partId||"part-1",partTitle:be.partId===H.id?H.title.trim():be.partTitle||"",chapterId:be.chapterId||"chapter-1",chapterTitle:be.chapterTitle||""})),de=await Dt("/api/db/book",{action:"reorder",items:B});if(de&&de.success!==!1){const be=H.title.trim();e(qe=>qe.map(it=>it.partId===H.id?{...it,partTitle:be}:it)),L(null),Pe()}else se.error("更新篇名失败: "+(de&&typeof de=="object"&&"error"in de?de.error:"未知错误"))}catch(B){console.error(B),se.error("更新篇名失败")}finally{O(!1)}}},pp=T=>{const B=T.chapters.length+1,de=`chapter-${T.id}-${B}-${Date.now()}`;P({id:`${B}.1`,title:"新章节",price:1,partId:T.id,chapterId:de,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),h(!0)},bc=(T,B)=>{const de=B.sections;let be=1,qe=!1,it=!1;if(de.length>0){const bt=typeof de[0].price=="number"?de[0].price:Number(de[0].price)||1,Kn=!!(de[0].isFree||bt===0);it=de.some(qr=>{const bn=typeof qr.price=="number"?qr.price:Number(qr.price)||1,er=!!(qr.isFree||bn===0);return bn!==bt||er!==Kn}),be=Kn?0:bt,qe=Kn}ce({part:T,chapter:B,title:B.title,price:be,isFree:qe,priceMixed:it,initialTitle:B.title,initialPrice:be,initialIsFree:qe})},nl=async()=>{var qe;if(!((qe=_==null?void 0:_.title)!=null&&qe.trim()))return;const T=_,B=T.title.trim(),de=B!==T.initialTitle,be=T.isFree!==T.initialIsFree||!T.isFree&&Number(T.price)!==Number(T.initialPrice);if(!de&&!be){se.info("未修改任何内容"),ce(null);return}if(T.priceMixed&&be){const it=T.chapter.sections.length,bt=T.isFree?"全部设为免费":`全部设为 ¥${T.price}`;if(!confirm(`本章 ${it} 节当前定价不一致,保存后将${bt},确定?`))return}z(!0);try{if(de){const it=t.map(bn=>({id:bn.id,partId:bn.partId||T.part.id,partTitle:bn.partId===T.part.id?T.part.title:bn.partTitle||"",chapterId:bn.chapterId||T.chapter.id,chapterTitle:bn.partId===T.part.id&&bn.chapterId===T.chapter.id?B:bn.chapterTitle||""})),bt=await Dt("/api/db/book",{action:"reorder",items:it});if(bt&&bt.success===!1){se.error("保存章节名失败: "+(bt&&typeof bt=="object"&&"error"in bt?bt.error:"未知错误"));return}const Kn=T.part.id,qr=T.chapter.id;e(bn=>bn.map(er=>er.partId===Kn&&er.chapterId===qr?{...er,chapterTitle:B}:er))}if(be){const it=await Dt("/api/db/book",{action:"update-chapter-pricing",partId:T.part.id,chapterId:T.chapter.id,price:T.isFree?0:Number(T.price)||0,isFree:T.isFree});if(it&&it.success===!1){se.error("保存定价失败: "+(it&&typeof it=="object"&&"error"in it?it.error:"未知错误")),de&&Pe();return}}ce(null),Pe(),se.success("已保存")}catch(it){console.error(it),se.error("保存失败")}finally{z(!1)}},vc=async(T,B)=>{const de=B.sections.map(be=>be.id);if(de.length===0){se.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${T.chapters.indexOf(B)+1}章 | ${B.title}」吗?将删除共 ${de.length} 节,此操作不可恢复。`))try{for(const be of de)await ea(`/api/db/book?id=${encodeURIComponent(be)}`);Pe()}catch(be){console.error(be),se.error("删除失败")}},Qd=async()=>{if(!te.trim()){se.error("请输入篇名");return}ge(!0);try{const T=`part-new-${Date.now()}`,B="chapter-1",de=`part-placeholder-${Date.now()}`,be=await Dt("/api/db/book",{id:de,title:"占位节(可编辑)",price:0,content:"",partId:T,partTitle:te.trim(),chapterId:B,chapterTitle:"第1章 | 待编辑",saveToFile:!1});be&&be.success!==!1?(se.success(`篇「${te}」创建成功`),ie(!1),K(""),Pe()):se.error("创建失败: "+(be&&typeof be=="object"&&"error"in be?be.error:"未知错误"))}catch(T){console.error(T),se.error("创建失败")}finally{ge(!1)}},Kr=async()=>{if(q.length===0){se.error("请先勾选要移动的章节");return}const T=yn.find(de=>de.id===U),B=T==null?void 0:T.chapters.find(de=>de.id===W);if(!T||!B||!U||!W){se.error("请选择目标篇和章");return}Me(!0);try{const de=()=>{const bt=new Set(q),Kn=t.map(kn=>({id:kn.id,partId:kn.partId||"",partTitle:kn.partTitle||"",chapterId:kn.chapterId||"",chapterTitle:kn.chapterTitle||""})),qr=Kn.filter(kn=>bt.has(kn.id)).map(kn=>({...kn,partId:U,partTitle:T.title||U,chapterId:W,chapterTitle:B.title||W})),bn=Kn.filter(kn=>!bt.has(kn.id));let er=bn.length;for(let kn=bn.length-1;kn>=0;kn-=1){const Xd=bn[kn];if(Xd.partId===U&&Xd.chapterId===W){er=kn+1;break}}return[...bn.slice(0,er),...qr,...bn.slice(er)]},be=async()=>{const bt=de(),Kn=await Dt("/api/db/book",{action:"reorder",items:bt});return Kn&&Kn.success!==!1?(se.success(`已移动 ${q.length} 节到「${T.title}」-「${B.title}」`),J(!1),F([]),await Pe(),!0):!1},qe={action:"move-sections",sectionIds:q,targetPartId:U,targetChapterId:W,targetPartTitle:T.title||U,targetChapterTitle:B.title||W},it=await Dt("/api/db/book",qe);if(it&&it.success!==!1)se.success(`已移动 ${it.count??q.length} 节到「${T.title}」-「${B.title}」`),J(!1),F([]),await Pe();else{const bt=it&&typeof it=="object"&&"error"in it?it.error||"":"未知错误";if((bt.includes("缺少 id")||bt.includes("无效的 action"))&&await be())return;se.error("移动失败: "+bt)}}catch(de){console.error(de),se.error("移动失败: "+(de instanceof Error?de.message:"网络或服务异常"))}finally{Me(!1)}},Nc=T=>{F(B=>B.includes(T)?B.filter(de=>de!==T):[...B,T])},sl=async T=>{const B=t.filter(de=>de.partId===T.id).map(de=>de.id);if(B.length===0){se.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${T.title}」整篇吗?将删除共 ${B.length} 节内容,此操作不可恢复。`))try{for(const de of B)await ea(`/api/db/book?id=${encodeURIComponent(de)}`);Pe()}catch(de){console.error(de),se.error("删除失败")}},wc=async()=>{var T;if(N.trim()){E(!0);try{const B=await De(`/api/search?q=${encodeURIComponent(N)}`);B!=null&&B.success&&((T=B.data)!=null&&T.results)?k(B.data.results):(k([]),B&&!B.success&&se.error("搜索失败: "+B.error))}catch(B){console.error(B),k([]),se.error("搜索失败")}finally{E(!1)}}},ti=yn.find(T=>T.id===M.partId),io=(ti==null?void 0:ti.chapters)??[];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",yn.length," 篇 · ",so," 节内容"]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{onClick:()=>_t(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[r.jsx(qu,{className:"w-4 h-4 mr-2"}),"排名算法"]}),r.jsxs(X,{onClick:()=>{const T=typeof window<"u"?`${window.location.origin}/api-doc`:"";T&&window.open(T,"_blank","noopener,noreferrer")},variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Ir,{className:"w-4 h-4 mr-2"}),"API 接口"]})]})]}),r.jsx(Rt,{open:u,onOpenChange:h,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[r.jsx(Pt,{className:"shrink-0 px-6 pt-6 pb-2",children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(fn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节ID *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:M.id,onChange:T=>P({...M,id:T.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:M.isFree?0:M.price,onChange:T=>P({...M,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:M.isFree})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"免费"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:M.isFree,onChange:T=>P({...M,isFree:T.target.checked,price:T.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最新新增"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:M.isNew,onChange:T=>P({...M,isNew:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:M.isPinned,onChange:T=>P({...M,isPinned:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"文章类型"}),r.jsxs("div",{className:"flex items-center gap-4 h-10",children:[r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium!==!0,onChange:()=>P({...M,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium===!0,onChange:()=>P({...M,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"热度分"}),r.jsx(re,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:M.hotScore??0,onChange:T=>P({...M,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节标题 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:M.title,onChange:T=>P({...M,title:T.target.value})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"所属篇"}),r.jsxs(Pl,{value:M.partId,onValueChange:T=>{var de;const B=yn.find(be=>be.id===T);P({...M,partId:T,chapterId:((de=B==null?void 0:B.chapters[0])==null?void 0:de.id)??"chapter-1"})},children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{})}),r.jsxs(ko,{className:"bg-[#0f2137] border-gray-700",children:[yn.map(T=>r.jsx(Ws,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),yn.length===0&&r.jsx(Ws,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"所属章"}),r.jsxs(Pl,{value:M.chapterId,onValueChange:T=>P({...M,chapterId:T}),children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{})}),r.jsxs(ko,{className:"bg-[#0f2137] border-gray-700",children:[io.map(T=>r.jsx(Ws,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),io.length===0&&r.jsx(Ws,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),r.jsx(Hx,{content:M.content||"",onChange:T=>P({...M,content:T}),onImageUpload:async T=>{var qe;const B=new FormData;B.append("file",T),B.append("folder","book-images");const be=await(await fetch(Lo("/api/upload"),{method:"POST",body:B,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((qe=be==null?void 0:be.data)==null?void 0:qe.url)||(be==null?void 0:be.url)||""},persons:ys,linkTags:me,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),r.jsxs(tn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[r.jsx(X,{variant:"outline",onClick:()=>h(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:ao,disabled:g||!M.id||!M.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),r.jsx(Rt,{open:!!H,onOpenChange:T=>!T&&L(null),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Vt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),H&&r.jsx("div",{className:"space-y-4 py-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"篇名"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:H.title,onChange:T=>L({...H,title:T.target.value}),placeholder:"输入篇名"})]})}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",onClick:()=>L(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:fp,disabled:R||!((jc=H==null?void 0:H.title)!=null&&jc.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:R?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),r.jsx(Rt,{open:!!_,onOpenChange:T=>!T&&ce(null),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsxs(Pt,{children:[r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Vt,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),r.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),_&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:_.title,onChange:T=>ce({..._,title:T.target.value}),placeholder:"输入章节名称"})]}),r.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[r.jsxs(Z,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",_.chapter.sections.length," 节)"]}),_.priceMixed&&r.jsx("p",{className:"text-amber-400/90 text-xs",children:"当前各节定价不一致,保存后将按下方设置全部统一。"}),r.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[r.jsxs("div",{className:"space-y-1 flex-1 min-w-[120px]",children:[r.jsx("span",{className:"text-gray-500 text-xs",children:"价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:_.isFree?0:_.price,onChange:T=>ce({..._,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:_.isFree,min:0,step:.01})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pb-2",children:[r.jsx("input",{type:"checkbox",checked:_.isFree||_.price===0,onChange:T=>ce({..._,isFree:T.target.checked,price:T.target.checked?0:_.initialPrice>0?_.initialPrice:1}),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac]"}),r.jsx("span",{className:"text-gray-400 text-sm",children:"本章全部免费"})]})]})]})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",onClick:()=>ce(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:nl,disabled:pe||!((as=_==null?void 0:_.title)!=null&&as.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:pe?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),r.jsx(Rt,{open:A,onOpenChange:T=>{var B;if(J(T),T&&yn.length>0){const de=yn[0];D(de.id),le(((B=de.chapters[0])==null?void 0:B.id)??"")}},children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsx(Ot,{className:"text-white",children:"批量移动至指定目录"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",r.jsx("span",{className:"text-[#38bdac] font-medium",children:q.length})," 节,请选择目标篇与章。"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"目标篇"}),r.jsxs(Pl,{value:U,onValueChange:T=>{var de;D(T);const B=yn.find(be=>be.id===T);le(((de=B==null?void 0:B.chapters[0])==null?void 0:de.id)??"")},children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{placeholder:"选择篇"})}),r.jsx(ko,{className:"bg-[#0f2137] border-gray-700",children:yn.map(T=>r.jsx(Ws,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"目标章"}),r.jsxs(Pl,{value:W,onValueChange:le,children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{placeholder:"选择章"})}),r.jsx(ko,{className:"bg-[#0f2137] border-gray-700",children:(((Na=yn.find(T=>T.id===U))==null?void 0:Na.chapters)??[]).map(T=>r.jsx(Ws,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",onClick:()=>J(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:Kr,disabled:xe||q.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:xe?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),r.jsx(Rt,{open:!!ae,onOpenChange:T=>!T&&fe(null),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white",children:["付款记录 — ",(ae==null?void 0:ae.section.title)??""]})}),r.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:Se?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ae&&ae.orders.length===0?r.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):ae?r.jsxs("table",{className:"w-full text-sm border-collapse",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[r.jsx("th",{className:"py-2 pr-2",children:"订单号"}),r.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),r.jsx("th",{className:"py-2 pr-2",children:"金额"}),r.jsx("th",{className:"py-2 pr-2",children:"状态"}),r.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),r.jsx("tbody",{children:ae.orders.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("td",{className:"py-2 pr-2",children:r.jsx("button",{className:"text-blue-400 hover:text-blue-300 hover:underline text-left truncate max-w-[180px] block",title:`查看订单 ${T.orderSn}`,onClick:()=>window.open(`/orders?search=${T.orderSn??T.id??""}`,"_blank"),children:T.orderSn?T.orderSn.length>16?T.orderSn.slice(0,8)+"..."+T.orderSn.slice(-6):T.orderSn:"-"})}),r.jsx("td",{className:"py-2 pr-2",children:r.jsx("button",{className:"text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[140px] block",title:`查看用户 ${T.userId??T.openId??""}`,onClick:()=>window.open(`/users?search=${T.userId??T.openId??""}`,"_blank"),children:(()=>{const B=T.userId??T.openId??"-";return B.length>12?B.slice(0,6)+"..."+B.slice(-4):B})()})}),r.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",T.amount??0]}),r.jsx("td",{className:"py-2 pr-2 text-gray-300",children:T.status??"-"}),r.jsx("td",{className:"py-2 pr-2 text-gray-500",children:T.payTime??T.createdAt??"-"})]},T.id??T.orderSn??""))})]}):null})]})}),r.jsx(Rt,{open:st,onOpenChange:_t,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(qu,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsx("p",{className:"text-sm text-gray-400",children:"热度积分 = 阅读权重×阅读排名分 + 新度权重×新度排名分 + 付款权重×付款排名分(三权重之和须为 1)"}),An?r.jsx("p",{className:"text-gray-500",children:"加载中..."}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"阅读权重"}),r.jsx(re,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.readWeight,onChange:T=>Ut(B=>({...B,readWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"新度权重"}),r.jsx(re,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.recencyWeight,onChange:T=>Ut(B=>({...B,recencyWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"付款权重"}),r.jsx(re,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.payWeight,onChange:T=>Ut(B=>({...B,payWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(At.readWeight+At.recencyWeight+At.payWeight).toFixed(1)]}),r.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[r.jsx("li",{children:"阅读量前 20 名:第1名=20分、第2名=19分...第20名=1分"}),r.jsx("li",{children:"最近更新前 30 篇:第1名=30分、第2名=29分...第30名=1分"}),r.jsx("li",{children:"付款数前 20 名:第1名=20分、第2名=19分...第20名=1分"}),r.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),r.jsx(X,{onClick:dn,disabled:It||Math.abs(At.readWeight+At.recencyWeight+At.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:It?"保存中...":"保存权重"})]})]})]})}),r.jsx(Rt,{open:ne,onOpenChange:ie,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(fn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),r.jsx("div",{className:"space-y-4 py-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:te,onChange:T=>K(T.target.value),placeholder:"输入篇名"})]})}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",onClick:()=>{ie(!1),K("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:Qd,disabled:G||!te.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:G?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),r.jsx(Rt,{open:!!o,onOpenChange:()=>c(null),children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[r.jsx(Pt,{className:"shrink-0 px-6 pt-6 pb-2",children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(Vt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),o&&r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.id,onChange:T=>c({...o,id:T.target.value}),placeholder:"如: 9.15"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.isFree?0:o.price,onChange:T=>c({...o,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:o.isFree})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"免费"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.isFree||o.price===0,onChange:T=>c({...o,isFree:T.target.checked,price:T.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最新新增"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.isNew??!1,onChange:T=>c({...o,isNew:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.isPinned??!1,onChange:T=>c({...o,isPinned:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"文章类型"}),r.jsxs("div",{className:"flex items-center gap-4 h-10",children:[r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium!==!0,onChange:()=>c({...o,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium===!0,onChange:()=>c({...o,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"热度分"}),r.jsx(re,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:o.hotScore??0,onChange:T=>c({...o,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.title,onChange:T=>c({...o,title:T.target.value})})]}),o.filePath&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"文件路径"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:o.filePath,disabled:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),f?r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsx(Hx,{ref:ya,content:o.content||"",onChange:T=>c({...o,content:T}),onImageUpload:async T=>{var qe;const B=new FormData;B.append("file",T),B.append("folder","book-images");const be=await(await fetch(Lo("/api/upload"),{method:"POST",body:B,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((qe=be==null?void 0:be.data)==null?void 0:qe.url)||(be==null?void 0:be.url)||""},persons:ys,linkTags:me,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),r.jsxs(tn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[o&&r.jsxs(X,{variant:"outline",onClick:()=>xc({id:o.id,title:o.title,price:o.price}),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent mr-auto",children:[r.jsx(Gs,{className:"w-4 h-4 mr-2"}),"付款记录"]}),r.jsxs(X,{variant:"outline",onClick:()=>c(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsx(X,{onClick:ro,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?r.jsxs(r.Fragment,{children:[r.jsx($e,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),r.jsxs(Wd,{defaultValue:"chapters",className:"space-y-6",children:[r.jsxs(sc,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[r.jsxs(Yt,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(Gs,{className:"w-4 h-4 mr-2"}),"章节管理"]}),r.jsxs(Yt,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[r.jsx(Xg,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),r.jsxs(Yt,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(Fa,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),r.jsxs(Yt,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[r.jsx(Ir,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),r.jsxs(Yt,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[r.jsx(Qv,{className:"w-4 h-4 mr-2"}),"链接标签"]}),r.jsxs(Yt,{value:"linkedmp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(zi,{className:"w-4 h-4 mr-2"}),"关联小程序"]})]}),r.jsxs(Qt,{value:"chapters",className:"space-y-4",children:[r.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac] flex items-center justify-center text-white shadow-lg shadow-[#38bdac]/20 shrink-0",children:r.jsx(Gs,{className:"w-6 h-6"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),r.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),r.jsxs("div",{className:"text-center shrink-0",children:[r.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:so}),r.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(X,{onClick:()=>h(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),r.jsxs(X,{onClick:()=>ie(!0),className:"flex-1 min-w-[120px] bg-amber-500/10 hover:bg-amber-500/20 text-amber-400 border border-amber-500/30",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),r.jsxs(X,{variant:"outline",onClick:()=>J(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",q.length," 节)"]})]}),n?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsx(oV,{parts:yn,expandedParts:a,onTogglePart:ct,onReorder:cn,onReadSection:yc,onDeleteSection:ut,onAddSectionInPart:ei,onAddChapterInPart:pp,onDeleteChapter:vc,onEditPart:tl,onDeletePart:sl,onEditChapter:bc,selectedSectionIds:q,onToggleSectionSelect:Nc,onShowSectionOrders:xc,pinnedSectionIds:Qe})]}),r.jsx(Qt,{value:"search",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"内容搜索"})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:N,onChange:T=>j(T.target.value),onKeyDown:T=>T.key==="Enter"&&wc()}),r.jsx(X,{onClick:wc,disabled:C||!N.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?r.jsx($e,{className:"w-4 h-4 animate-spin"}):r.jsx(Fa,{className:"w-4 h-4"})})]}),v.length>0&&r.jsxs("div",{className:"space-y-2 mt-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",v.length," 个结果"]}),v.map(T=>r.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>yc({id:T.id,mid:T.mid,title:T.title,price:T.price??1,filePath:""}),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:T.id}),r.jsx("span",{className:"text-white",children:T.title}),Qe.includes(T.id)&&r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),r.jsx(Ke,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:T.matchType==="title"?"标题匹配":"内容匹配"})]}),T.snippet&&r.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:T.snippet}),(T.partTitle||T.chapterTitle)&&r.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[T.partTitle," · ",T.chapterTitle]})]},T.id))]})]})]})}),r.jsxs(Qt,{value:"ranking",className:"space-y-4",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(qu,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Z,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),r.jsx(re,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:xt,onChange:T=>Xt(Math.max(1,Math.min(100,Number(T.target.value)||20))),disabled:ln}),r.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),r.jsx(X,{size:"sm",onClick:el,disabled:xs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:xs?"保存中...":"保存"}),r.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",xt,"% 内容"]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(Xg,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",r.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",xn.length," 节"]})]}),r.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>_e(),disabled:Y,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:r.jsx($e,{className:`w-4 h-4 ${Y?"animate-spin":""}`})}),r.jsx(X,{variant:"ghost",size:"sm",disabled:on<=1||Y,onClick:()=>Es(T=>Math.max(1,T-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:r.jsx(YT,{className:"w-4 h-4"})}),r.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[on," / ",Wr]}),r.jsx(X,{variant:"ghost",size:"sm",disabled:on>=Wr||Y,onClick:()=>Es(T=>Math.min(Wr,T+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:r.jsx(Dl,{className:"w-4 h-4"})})]})]})}),r.jsx(Te,{children:r.jsxs("div",{className:"space-y-0",children:[r.jsxs("div",{className:"grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2 text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("span",{children:"排名"}),r.jsx("span",{children:"置顶"}),r.jsx("span",{children:"标题"}),r.jsx("span",{className:"text-right",children:"点击量"}),r.jsx("span",{className:"text-right",children:"付款数"}),r.jsx("span",{className:"text-right",children:"热度"}),r.jsx("span",{className:"text-right",children:"编辑"})]}),$.map((T,B)=>{const de=(on-1)*ba+B+1,be=T.isPinned??Qe.includes(T.id);return r.jsxs("div",{className:`grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2.5 items-center border-b border-gray-700/30 hover:bg-[#162840] transition-colors ${be?"bg-amber-500/5":""}`,children:[r.jsx("span",{className:`text-sm font-bold ${de<=3?"text-amber-400":"text-gray-500"}`,children:de<=3?["🥇","🥈","🥉"][de-1]:`#${de}`}),r.jsx(X,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${be?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>Yd(T.id),disabled:dt,title:be?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:be?r.jsx(_l,{className:"w-3.5 h-3.5 fill-current"}):r.jsx(y5,{className:"w-3.5 h-3.5"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-white text-sm truncate block",children:T.title}),r.jsxs("span",{className:"text-gray-600 text-xs",children:[T.partTitle," · ",T.chapterTitle]})]}),r.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:T.clickCount??0}),r.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:T.payCount??0}),r.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(T.hotScore??0).toFixed(1)}),r.jsx("div",{className:"text-right",children:r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>yc({id:T.id,mid:T.mid,title:T.title,price:T.price,filePath:""}),title:"编辑文章",children:r.jsx(Vt,{className:"w-3 h-3"})})})]},T.id)}),$.length===0&&r.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),r.jsxs(Qt,{value:"link-person",className:"space-y-4",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"pb-3",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — 链接人与事(编辑器内输入 @ 可链接)"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"添加时自动生成 32 位 token,文章 @ 时存 token;小程序点击 @ 时用 token 兑换真实密钥后加好友"})]}),r.jsxs(Te,{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx("p",{className:"text-xs text-gray-500",children:"添加人物时同步创建存客宝场景获客计划,配置与存客宝 API 获客一致"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>Ts(),title:"刷新",children:r.jsx($e,{className:"w-4 h-4"})}),r.jsxs(X,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{$r(null),xr(!0)},children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),r.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:ys.length>0?r.jsxs("table",{className:"w-full text-sm border-collapse",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("th",{className:"text-left py-1.5 px-3 w-[280px] font-normal",children:"token"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-24 font-normal",children:"@的人"}),r.jsx("th",{className:"py-1.5 px-3 w-16 font-normal text-center",children:"获客数"}),r.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"获客计划活动名"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-20 font-normal",children:"planId"}),r.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"apiKey"}),r.jsx("th",{className:"text-left py-1.5 px-2 w-24 font-normal",children:"操作"})]})}),r.jsx("tbody",{children:ys.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono",title:"32位token",children:T.id}),r.jsx("td",{className:"py-2 px-3 text-amber-400 truncate max-w-[96px]",title:"@的人",children:T.name}),(()=>{const B=uc[T.id]||0;return r.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold ${B>0?"text-green-400":"text-gray-600"}`,title:"获客数",children:B})})(),r.jsxs("td",{className:"py-2 px-3 text-white truncate max-w-[200px]",title:"获客计划活动名",children:["SOUL链接人与事-",T.name]}),r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono",title:"存客宝计划ID",children:T.ckbPlanId??"-"}),r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono whitespace-nowrap",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[T.ckbApiKey?r.jsx(X,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-gray-500 hover:text-[#38bdac] shrink-0",title:"复制 apiKey",onClick:async()=>{await navigator.clipboard.writeText(T.ckbApiKey??""),se.success("已复制到剪贴板")},children:r.jsx(s0,{className:"w-3.5 h-3.5"})}):null,r.jsx("span",{title:T.ckbApiKey??"",children:T.ckbApiKey??"-"})]})}),r.jsx("td",{className:"py-2 px-2",children:r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const B=await cV(T.personId||"");if(B!=null&&B.success&&B.person){const de=B.person;$r({id:de.token??de.personId,personId:de.personId,name:de.name,label:de.label??"",ckbApiKey:de.ckbApiKey??"",remarkType:de.remarkType,remarkFormat:de.remarkFormat,addFriendInterval:de.addFriendInterval,startTime:de.startTime,endTime:de.endTime,deviceGroups:de.deviceGroups})}else $r(T),B!=null&&B.error&&se.error(B.error)}catch(B){console.error(B),$r(T),se.error(B instanceof Error?B.message:"加载人物详情失败")}xr(!0)},children:r.jsx(Yg,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>va(T.id,T.name),children:r.jsx(_n,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-amber-400 h-6 px-2",title:"编辑计划(跳转存客宝)",onClick:()=>{const B=T.ckbPlanId;B?window.open(`https://h5.ckb.quwanzhi.com/#/scenarios/edit/${B}`,"_blank"):se.info("该人物尚未同步存客宝计划,请先保存后等待同步完成")},children:r.jsx(ra,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:"删除(同时删除存客宝对应获客计划)",onClick:()=>Ga(T),children:r.jsx(hs,{className:"w-3 h-3"})})]})})]},T.id))})]}):r.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"pb-3",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(qu,{className:"w-4 h-4 text-green-400"}),"存客宝绑定"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),r.jsxs(Te,{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"绑定计划"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",r.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]})]}),r.jsxs(Qt,{value:"link-tag",className:"space-y-4",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"pb-3",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(Qv,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),r.jsxs(Te,{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-end justify-between gap-3 flex-wrap",children:[r.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"搜索"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:pr,onChange:T=>{ma(T.target.value),Qs(1)}})]}),r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{Ms(),Zs()},title:"刷新",children:r.jsx($e,{className:"w-4 h-4"})})]}),r.jsxs(X,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{Zo(null),jn({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),Nr(""),Ns(!1),mr(!0)},children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加标签"]})]}),r.jsxs("div",{className:"rounded-md border border-gray-700/50 overflow-hidden",children:[r.jsx("div",{className:"max-h-[420px] overflow-y-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-[#0a1628] border-b border-gray-700/50",children:r.jsxs("tr",{children:[r.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-40",children:"标签"}),r.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-20",children:"类型"}),r.jsx("th",{className:"text-left px-3 py-2 text-gray-400",children:"目标"}),r.jsx("th",{className:"text-right px-3 py-2 text-gray-400 w-28",children:"操作"})]})}),r.jsx("tbody",{children:da?r.jsx("tr",{children:r.jsx("td",{colSpan:4,className:"text-center py-10 text-gray-500",children:"加载中..."})}):Zt.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:4,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):Zt.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-white/5",children:[r.jsxs("td",{className:"px-3 py-2",children:[r.jsxs("div",{className:"text-amber-400 font-semibold",children:["#",T.label]}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:["tagId: ",T.id]})]}),r.jsx("td",{className:"px-3 py-2",children:r.jsx(Ke,{variant:"secondary",className:`text-[10px] ${T.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":T.type==="miniprogram"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:T.type==="url"?"网页":T.type==="ckb"?"存客宝":"小程序"})}),r.jsx("td",{className:"px-3 py-2 text-gray-300",children:T.type==="miniprogram"?r.jsxs("span",{className:"text-xs font-mono",children:[T.appId||"—"," ",T.pagePath?`· ${T.pagePath}`:""]}):T.url?r.jsxs("a",{href:T.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[T.url," ",r.jsx(ra,{className:"w-3 h-3 shrink-0"})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"—"})}),r.jsx("td",{className:"px-3 py-2",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{Zo(T),jn({tagId:T.id,label:T.label,url:T.url,type:T.type,appId:T.appId??"",pagePath:T.pagePath??""}),Nr(T.appId??""),Ns(!1),mr(!0)},title:"编辑",children:r.jsx(Yg,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${T.label}」吗?`))try{const B=await ea(`/api/db/link-tags?tagId=${encodeURIComponent(T.id)}`);B!=null&&B.success?(se.success("已删除"),Ms(),Zs()):se.error((B==null?void 0:B.error)??"删除失败")}catch(B){console.error(B),se.error("删除失败")}},title:"删除",children:r.jsx(hs,{className:"w-3 h-3"})})]})})]},T.id))})]})}),r.jsx(zs,{page:_r,pageSize:ha,total:fa,totalPages:pa,onPageChange:T=>Qs(T),onPageSizeChange:T=>{Xo(T),Qs(1)}})]})]})]}),r.jsx(Rt,{open:Fs,onOpenChange:mr,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[r.jsxs(Pt,{className:"gap-1",children:[r.jsx(Ot,{className:"text-base",children:eo?"编辑链接标签":"添加链接标签"}),r.jsx(Cd,{className:"text-gray-400 text-xs",children:"配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转"})]}),r.jsxs("div",{className:"space-y-3 py-2",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"标签ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或填 12位数字 / z开头12位",value:yt.tagId,disabled:!!eo,onChange:T=>jn(B=>({...B,tagId:T.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"显示文字"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:yt.label,onChange:T=>jn(B=>({...B,label:T.target.value}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"类型"}),r.jsxs(Pl,{value:yt.type,onValueChange:T=>jn(B=>({...B,type:T})),children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:r.jsx(Ol,{})}),r.jsxs(ko,{children:[r.jsx(Ws,{value:"url",children:"网页链接"}),r.jsx(Ws,{value:"miniprogram",children:"小程序"}),r.jsx(Ws,{value:"ckb",children:"存客宝"})]})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:yt.type==="url"?"URL地址":yt.type==="ckb"?"存客宝计划URL":"小程序(选密钥)"}),yt.type==="miniprogram"&&rs.length>0?r.jsxs("div",{ref:hp,className:"relative",children:[r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Xa?As:yt.appId,onChange:T=>{const B=T.target.value;Nr(B),Ns(!0),rs.some(de=>de.key===B)||jn(de=>({...de,appId:B}))},onFocus:()=>{Nr(yt.appId),Ns(!0)},onBlur:()=>setTimeout(()=>Ns(!1),150)}),Xa&&r.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-gray-700 bg-[#0a1628] shadow-lg z-50",children:Za.length===0?r.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Za.map(T=>r.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-[#38bdac]/20 flex flex-col gap-0.5",onMouseDown:B=>{B.preventDefault(),jn(de=>({...de,appId:T.key,pagePath:T.path||""})),Nr(""),Ns(!1)},children:[r.jsx("span",{children:T.name}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:T.key})]},T.key))})]}):r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:yt.type==="url"?"https://...":yt.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联小程序的32位密钥",value:yt.type==="url"||yt.type==="ckb"?yt.url:yt.appId,onChange:T=>{yt.type==="url"||yt.type==="ckb"?jn(B=>({...B,url:T.target.value})):jn(B=>({...B,appId:T.target.value}))}})]})]}),yt.type==="miniprogram"&&r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:yt.pagePath,onChange:T=>jn(B=>({...B,pagePath:T.target.value}))})]})]}),r.jsxs(tn,{className:"gap-2 pt-1",children:[r.jsx(X,{variant:"outline",onClick:()=>mr(!1),className:"border-gray-600",children:"取消"}),r.jsx(X,{onClick:async()=>{const T={tagId:yt.tagId.trim(),label:yt.label.trim(),url:yt.url.trim(),type:yt.type,appId:yt.appId.trim(),pagePath:yt.pagePath.trim()};if(T.tagId&&!(/^\d{12}$/.test(T.tagId)||/^z[a-z0-9]{11}$/.test(T.tagId))){se.error("标签ID需为12位数字,或 z 开头的12位(z+11位小写字母数字)");return}if(!T.label){se.error("显示文字必填");return}T.type==="miniprogram"&&(T.url=""),gr(!0);try{const B=await Nt("/api/db/link-tags",T);B!=null&&B.success?(se.success(eo?"已更新":"已添加"),mr(!1),Ms(),Zs()):se.error((B==null?void 0:B.error)??"保存失败")}catch(B){console.error(B),se.error("保存失败")}finally{gr(!1)}},disabled:zr,className:"bg-amber-500 hover:bg-amber-600 text-white",children:zr?"保存中...":"保存"})]})]})})]}),r.jsx(Qt,{value:"linkedmp",className:"space-y-4",children:r.jsx(rV,{})})]}),r.jsx(uV,{open:to,onOpenChange:xr,editingPerson:ga,onSubmit:async T=>{var be;const B={personId:T.personId||T.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:T.name,aliases:T.aliases||void 0,label:T.label,ckbApiKey:T.ckbApiKey||void 0,greeting:T.greeting||void 0,tips:T.tips||void 0,remarkType:T.remarkType||void 0,remarkFormat:T.remarkFormat||void 0,addFriendInterval:T.addFriendInterval,startTime:T.startTime||void 0,endTime:T.endTime||void 0,deviceGroups:(be=T.deviceGroups)!=null&&be.trim()?T.deviceGroups.split(",").map(qe=>parseInt(qe.trim(),10)).filter(qe=>!Number.isNaN(qe)):void 0},de=await Nt("/api/db/persons",B);if(de&&de.success===!1){const qe=de;qe.ckbResponse&&console.log("存客宝返回",qe.ckbResponse);const it=qe.error||"操作失败";throw new Error(it)}if(Ts(),se.success(ga?"已保存":"已添加"),de!=null&&de.ckbCreateResult&&Object.keys(de.ckbCreateResult).length>0){const qe=de.ckbCreateResult;console.log("存客宝创建结果",qe);const it=qe.planId??qe.id,bt=it!=null?[`planId: ${it}`]:[];qe.apiKey!=null&&bt.push("apiKey: ***"),se.info(bt.length?`存客宝创建结果:${bt.join(",")}`:"存客宝创建结果见控制台")}}}),r.jsx(Rt,{open:!!Xs,onOpenChange:T=>{T||Ga(null)},children:r.jsxs(St,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[r.jsxs(Pt,{className:"gap-1",children:[r.jsx(Ot,{className:"text-white text-base",children:"确认删除"}),r.jsx(Cd,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:Xs&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:["确定删除「SOUL链接人与事-",Xs.name,"」?将同时删除存客宝对应获客计划。"]}),r.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",Xs.name," 将无法正常跳转。"]})]})})]}),r.jsxs(tn,{className:"gap-2 sm:gap-2 pt-1",children:[r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>Ga(null),children:"取消"}),r.jsx(X,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{Xs&&(await ea(`/api/db/persons?personId=${Xs.personId}`),Ga(null),Ts(),se.success("已删除"))},children:"确定删除"})]})]})}),r.jsx(Rt,{open:hc,onOpenChange:yr,children:r.jsxs(St,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-green-400"}),Ja," — 获客详情(共 ",Ya," 条)"]})}),r.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:pc?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx($e,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Br.length===0?r.jsx("div",{className:"text-gray-500 text-sm py-8 text-center",children:"暂无获客记录"}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-[60px_1fr_100px_100px_80px_120px] gap-2 px-3 py-1.5 text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("span",{children:"#"}),r.jsx("span",{children:"昵称/姓名"}),r.jsx("span",{children:"手机"}),r.jsx("span",{children:"微信"}),r.jsx("span",{children:"来源"}),r.jsx("span",{children:"时间"})]}),Br.map((T,B)=>r.jsxs("div",{className:"grid grid-cols-[60px_1fr_100px_100px_80px_120px] gap-2 px-3 py-2 bg-[#0a1628] rounded text-sm",children:[r.jsx("span",{className:"text-gray-500 text-xs",children:(Vr-1)*20+B+1}),r.jsx("span",{className:"text-white truncate",children:T.nickname||T.name||T.userId||"-"}),r.jsx("span",{className:"text-gray-300 text-xs",children:T.phone||"-"}),r.jsx("span",{className:"text-gray-300 text-xs truncate",children:T.wechatId||"-"}),r.jsx("span",{className:"text-gray-500 text-xs",children:T.source==="article_mention"?"文章@":T.source==="index_lead"?"首页":T.source||"-"}),r.jsx("span",{className:"text-gray-500 text-xs",children:T.createdAt?new Date(T.createdAt).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"})]},T.id))]})}),Ya>20&&r.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[r.jsx(X,{size:"sm",variant:"outline",disabled:Vr<=1,onClick:()=>va(br,Ja,Vr-1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"上一页"}),r.jsxs("span",{className:"text-gray-400 text-xs",children:[Vr," / ",Math.ceil(Ya/20)]}),r.jsx(X,{size:"sm",variant:"outline",disabled:Vr>=Math.ceil(Ya/20),onClick:()=>va(br,Ja,Vr+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const za={name:"卡若",avatar:"K",avatarImg:"",title:"Soul派对房主理人 · 私域运营专家",bio:'每天早上6点到9点,在Soul派对房分享真实的创业故事。专注私域运营与项目变现,用"云阿米巴"模式帮助创业者构建可持续的商业体系。',stats:[{label:"商业案例",value:"62"},{label:"连续直播",value:"365天"},{label:"派对分享",value:"1000+"}],highlights:["5年私域运营经验","帮助100+品牌从0到1增长","连续创业者,擅长商业模式设计"]};function Iw(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&"label"in e&&"value"in e?{label:String(e.label),value:String(e.value)}:{label:"",value:""}).filter(e=>e.label||e.value):za.stats}function Rw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):za.highlights}function pV(){const[t,e]=b.useState(za),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{De("/api/admin/author-settings").then(k=>{const C=k==null?void 0:k.data;C&&typeof C=="object"&&e({name:String(C.name??za.name),avatar:String(C.avatar??za.avatar),avatarImg:String(C.avatarImg??""),title:String(C.title??za.title),bio:String(C.bio??za.bio),stats:Iw(C.stats).length?Iw(C.stats):za.stats,highlights:Rw(C.highlights).length?Rw(C.highlights):za.highlights})}).catch(console.error).finally(()=>s(!1))},[]);const h=async()=>{i(!0);try{const k={name:t.name,avatar:t.avatar||"K",avatarImg:t.avatarImg,title:t.title,bio:t.bio,stats:t.stats.filter(M=>M.label||M.value),highlights:t.highlights.filter(Boolean)},C=await Nt("/api/admin/author-settings",k);if(!C||C.success===!1){se.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:""));return}i(!1);const E=document.createElement("div");E.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",E.textContent="作者设置已保存",document.body.appendChild(E),setTimeout(()=>E.remove(),2e3)}catch(k){console.error(k),se.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{i(!1)}},f=async k=>{var E;const C=(E=k.target.files)==null?void 0:E[0];if(C){c(!0);try{const M=new FormData;M.append("file",C),M.append("folder","avatars");const P=Df(),H={};P&&(H.Authorization=`Bearer ${P}`);const R=await(await fetch(Lo("/api/upload"),{method:"POST",body:M,credentials:"include",headers:H})).json();R!=null&&R.success&&(R!=null&&R.url)?e(O=>({...O,avatarImg:R.url})):se.error("上传失败: "+((R==null?void 0:R.error)||"未知错误"))}catch(M){console.error(M),se.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),g=k=>e(C=>({...C,stats:C.stats.filter((E,M)=>M!==k)})),y=(k,C,E)=>e(M=>({...M,stats:M.stats.map((P,H)=>H===k?{...P,[C]:E}:P)})),N=()=>e(k=>({...k,highlights:[...k.highlights,""]})),j=k=>e(C=>({...C,highlights:C.highlights.filter((E,M)=>M!==k)})),v=(k,C)=>e(E=>({...E,highlights:E.highlights.map((M,P)=>P===k?C:M)}));return n?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),r.jsxs(X,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(Ao,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),r.jsx(Lt,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"姓名"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(C=>({...C,name:k.target.value})),placeholder:"卡若"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(C=>({...C,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(dj,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(C=>({...C,avatarImg:k.target.value})),placeholder:"上传或粘贴 URL,如 /uploads/avatars/xxx.png"}),r.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var k;return(k=u.current)==null?void 0:k.click()},children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&r.jsx("div",{className:"mt-2",children:r.jsx("img",{src:t.avatarImg.startsWith("http")?t.avatarImg:Lo(t.avatarImg),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"头衔"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(C=>({...C,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"个人简介"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(C=>({...C,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsx(Ye,{className:"text-white",children:"统计数据"}),r.jsx(Lt,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),r.jsxs(Te,{className:"space-y-3",children:[t.stats.map((k,C)=>r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:E=>y(C,"label",E.target.value),placeholder:"标签"}),r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:E=>y(C,"value",E.target.value),placeholder:"数值"}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(C),children:r.jsx(hs,{className:"w-4 h-4"})})]},C)),r.jsxs(X,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsx(Ye,{className:"text-white",children:"亮点标签"}),r.jsx(Lt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),r.jsxs(Te,{className:"space-y-3",children:[t.highlights.map((k,C)=>r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:E=>v(C,E.target.value),placeholder:"5年私域运营经验"}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>j(C),children:r.jsx(hs,{className:"w-4 h-4"})})]},C)),r.jsxs(X,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function mV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=b0(h,300),[g,y]=b.useState(!0),[N,j]=b.useState(null),[v,k]=b.useState(!1),[C,E]=b.useState(null),[M,P]=b.useState(""),[H,L]=b.useState(""),[R,O]=b.useState(""),[ne,ie]=b.useState("admin"),[_,ce]=b.useState("active"),[pe,z]=b.useState(!1);async function q(){var W;y(!0),j(null);try{const le=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&le.set("search",m.trim());const xe=await De(`/api/admin/users?${le}`);xe!=null&&xe.success?(e(xe.records||[]),s(xe.total??0),u(xe.totalPages??0)):j(xe.error||"加载失败")}catch(le){const xe=le;j(xe.status===403?"无权限访问":((W=xe==null?void 0:xe.data)==null?void 0:W.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{q()},[a,o,m]);const F=()=>{E(null),P(""),L(""),O(""),ie("admin"),ce("active"),k(!0)},A=W=>{E(W),P(W.username),L(""),O(W.name||""),ie(W.role==="super_admin"?"super_admin":"admin"),ce(W.status==="disabled"?"disabled":"active"),k(!0)},J=async()=>{var W;if(!M.trim()){j("用户名不能为空");return}if(!C&&!H){j("新建时密码必填,至少 6 位");return}if(H&&H.length<6){j("密码至少 6 位");return}j(null),z(!0);try{if(C){const le=await Dt("/api/admin/users",{id:C.id,password:H||void 0,name:R.trim(),role:ne,status:_});le!=null&&le.success?(k(!1),q()):j((le==null?void 0:le.error)||"保存失败")}else{const le=await Nt("/api/admin/users",{username:M.trim(),password:H,name:R.trim(),role:ne});le!=null&&le.success?(k(!1),q()):j((le==null?void 0:le.error)||"保存失败")}}catch(le){const xe=le;j(((W=xe==null?void 0:xe.data)==null?void 0:W.error)||"保存失败")}finally{z(!1)}},U=async W=>{var le;if(confirm("确定删除该管理员?"))try{const xe=await ea(`/api/admin/users?id=${W}`);xe!=null&&xe.success?q():j((xe==null?void 0:xe.error)||"删除失败")}catch(xe){const Me=xe;j(((le=Me==null?void 0:Me.data)==null?void 0:le.error)||"删除失败")}},D=W=>{if(!W)return"-";try{const le=new Date(W);return isNaN(le.getTime())?W:le.toLocaleString("zh-CN")}catch{return W}};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-6",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(od,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(re,{placeholder:"搜索用户名/昵称",value:h,onChange:W=>f(W.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),r.jsx(X,{variant:"outline",size:"sm",onClick:q,disabled:g,className:"border-gray-600 text-gray-300",children:r.jsx($e,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),r.jsxs(X,{onClick:F,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),N&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm flex justify-between items-center",children:[r.jsx("span",{children:N}),r.jsx("button",{type:"button",onClick:()=>j(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:g?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(r.Fragment,{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"用户名"}),r.jsx(we,{className:"text-gray-400",children:"昵称"}),r.jsx(we,{className:"text-gray-400",children:"角色"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"创建时间"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(ns,{children:[t.map(W=>r.jsxs(lt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:W.id}),r.jsx(ve,{className:"text-white font-medium",children:W.username}),r.jsx(ve,{className:"text-gray-400",children:W.name||"-"}),r.jsx(ve,{children:r.jsx(Ke,{variant:"outline",className:W.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:W.role==="super_admin"?"超级管理员":"管理员"})}),r.jsx(ve,{children:r.jsx(Ke,{variant:"outline",className:W.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:W.status==="active"?"正常":"已禁用"})}),r.jsx(ve,{className:"text-gray-500 text-sm",children:D(W.createdAt)}),r.jsxs(ve,{className:"text-right",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>A(W),className:"text-gray-400 hover:text-[#38bdac]",children:r.jsx(Vt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>U(W.id),className:"text-gray-400 hover:text-red-400",children:r.jsx(Yn,{className:"w-4 h-4"})})]})]},W.id)),t.length===0&&!g&&r.jsx(lt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:N==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&r.jsx("div",{className:"p-4 border-t border-gray-700/50",children:r.jsx(zs,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),r.jsx(Rt,{open:v,onOpenChange:k,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Pt,{children:r.jsx(Ot,{className:"text-white",children:C?"编辑管理员":"新增管理员"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"用户名"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:M,onChange:W=>P(W.target.value),disabled:!!C}),C&&r.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:C?"新密码(留空不改)":"密码"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:C?"留空表示不修改":"至少 6 位",value:H,onChange:W=>L(W.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:R,onChange:W=>O(W.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"角色"}),r.jsxs("select",{value:ne,onChange:W=>ie(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[r.jsx("option",{value:"admin",children:"管理员"}),r.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),C&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"状态"}),r.jsxs("select",{value:_,onChange:W=>ce(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[r.jsx("option",{value:"active",children:"正常"}),r.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),r.jsxs(tn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:J,disabled:pe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),pe?"保存中...":"保存"]})]})]})})]})}function Cn({method:t,url:e,desc:n,headers:s,body:a,response:i}){const o=t==="GET"?"text-emerald-400":t==="POST"?"text-amber-400":t==="PUT"?"text-blue-400":t==="DELETE"?"text-rose-400":"text-gray-400";return r.jsxs("div",{className:"rounded-lg bg-[#0a1628]/60 border border-gray-700/50 p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`font-mono font-semibold ${o}`,children:t}),r.jsx("code",{className:"text-sm text-[#38bdac] break-all",children:e})]}),n&&r.jsx("p",{className:"text-gray-400 text-sm",children:n}),s&&s.length>0&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Headers"}),r.jsx("pre",{className:"text-xs text-gray-300 font-mono overflow-x-auto p-2 rounded bg-black/30",children:s.join(` -`)})]}),a&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Request Body (JSON)"}),r.jsx("pre",{className:"text-xs text-green-400/90 font-mono overflow-x-auto p-2 rounded bg-black/30 whitespace-pre-wrap",children:a})]}),i&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Response Example"}),r.jsx("pre",{className:"text-xs text-amber-200/80 font-mono overflow-x-auto p-2 rounded bg-black/30 whitespace-pre-wrap",children:i})]})]})}function Y4(){const t=["Authorization: Bearer {token}","Content-Type: application/json"];return r.jsxs("div",{className:"p-8 w-full bg-[#0a1628] text-white",children:[r.jsxs("div",{className:"mb-8",children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"内容管理相关接口 · RESTful · 基础路径 /api · 管理端需 Bearer Token"})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(uj,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),r.jsx(Te,{className:"space-y-4",children:r.jsx(Cn,{method:"POST",url:"/api/admin",desc:"登录,返回 JWT token",headers:["Content-Type: application/json"],body:`{ +
    `).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");a&&s[c]&&a({id:s[c].id,label:s[c].name})})}))};return{onStart:o=>{if(e=document.createElement("div"),e.className="mention-popup",document.body.appendChild(e),s=o.items,a=o.command,n=0,i(),o.clientRect){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onUpdate:o=>{if(s=o.items,a=o.command,n=0,i(),o.clientRect&&e){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onKeyDown:o=>o.event.key==="ArrowUp"?(n=Math.max(0,n-1),i(),!0):o.event.key==="ArrowDown"?(n=Math.min(s.length-1,n+1),i(),!0):o.event.key==="Enter"?(a&&s[n]&&a({id:s[n].id,label:s[n].name}),!0):o.event.key==="Escape"?(e==null||e.remove(),e=null,!0):!1,onExit:()=>{e==null||e.remove(),e=null}}}});function QF(t){var s;const e=[],n=(s=t.clipboardData)==null?void 0:s.items;if(!n)return e;for(let a=0;a{const u=b.useRef(null),h=b.useRef(null),[f,m]=b.useState(""),[g,y]=b.useState(!1),N=b.useRef(gw(t)),j=b.useCallback((M,P)=>{var O;const H=h.current;if(!H||!n)return!1;const L=QF(P);if(L.length>0)return P.preventDefault(),(async()=>{for(const se of L)try{const ie=await n(se);ie&&H.chain().focus().setImage({src:ie}).run()}catch(ie){console.error("粘贴图片上传失败",ie)}})(),!0;const R=(O=P.clipboardData)==null?void 0:O.getData("text/html");if(R&&/data:image\/[^;"']+;base64,/i.test(R)){P.preventDefault();const{from:se,to:ie}=H.state.selection;return(async()=>{try{const z=await e$(R,n);H.chain().focus().insertContentAt({from:se,to:ie},z).run()}catch(z){console.error("粘贴 HTML 内 base64 转换失败",z)}})(),!0}return!1},[n]),v=W_({extensions:[Iz.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),Oz.configure({inline:!0,allowBase64:!0}),$z.configure({HTMLAttributes:{class:"mention-tag"},suggestion:YF(s)}),JF,Bz.configure({placeholder:i}),YC.configure({resizable:!0}),JC,qC,GC],content:N.current,onUpdate:({editor:M})=>{e(M.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:j}});b.useEffect(()=>{h.current=v??null},[v]),b.useImperativeHandle(c,()=>({getHTML:()=>(v==null?void 0:v.getHTML())||"",getMarkdown:()=>GF((v==null?void 0:v.getHTML())||"")})),b.useEffect(()=>{if(v&&t!==v.getHTML()){const M=gw(t);M!==v.getHTML()&&v.commands.setContent(M)}},[t]);const k=b.useCallback(async M=>{var H;const P=(H=M.target.files)==null?void 0:H[0];if(!(!P||!v)){if(n){const L=await n(P);L&&v.chain().focus().setImage({src:L}).run()}else{const L=new FileReader;L.onload=()=>{typeof L.result=="string"&&v.chain().focus().setImage({src:L.result}).run()},L.readAsDataURL(P)}M.target.value=""}},[v,n]),C=b.useCallback(M=>{v&&v.chain().focus().insertContent({type:"linkTag",attrs:{label:M.label,url:M.url||"",tagType:M.type||"url",tagId:M.id||"",pagePath:M.pagePath||"",appId:M.appId||"",mpKey:M.type==="miniprogram"&&M.appId||""}}).run()},[v]),E=b.useCallback(()=>{!v||!f||(v.chain().focus().setLink({href:f}).run(),m(""),y(!1))},[v,f]);return v?r.jsxs("div",{className:`rich-editor-wrapper ${o||""}`,children:[r.jsxs("div",{className:"rich-editor-toolbar",children:[r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().toggleBold().run(),className:v.isActive("bold")?"is-active":"",type:"button",children:r.jsx(HT,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleItalic().run(),className:v.isActive("italic")?"is-active":"",type:"button",children:r.jsx(BM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleStrike().run(),className:v.isActive("strike")?"is-active":"",type:"button",children:r.jsx(_5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleCode().run(),className:v.isActive("code")?"is-active":"",type:"button",children:r.jsx(cM,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:1}).run(),className:v.isActive("heading",{level:1})?"is-active":"",type:"button",children:r.jsx(IM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:2}).run(),className:v.isActive("heading",{level:2})?"is-active":"",type:"button",children:r.jsx(PM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:3}).run(),className:v.isActive("heading",{level:3})?"is-active":"",type:"button",children:r.jsx(DM,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().toggleBulletList().run(),className:v.isActive("bulletList")?"is-active":"",type:"button",children:r.jsx(YM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleOrderedList().run(),className:v.isActive("orderedList")?"is-active":"",type:"button",children:r.jsx(GM,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().toggleBlockquote().run(),className:v.isActive("blockquote")?"is-active":"",type:"button",children:r.jsx(w5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().setHorizontalRule().run(),type:"button",children:r.jsx(o5,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:k,className:"hidden"}),r.jsx("button",{onClick:()=>{var M;return(M=u.current)==null?void 0:M.click()},type:"button",children:r.jsx(dj,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>y(!g),className:v.isActive("link")?"is-active":"",type:"button",children:r.jsx(Jg,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",children:r.jsx(F5,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"toolbar-divider"}),r.jsxs("div",{className:"toolbar-group",children:[r.jsx("button",{onClick:()=>v.chain().focus().undo().run(),disabled:!v.can().undo(),type:"button",children:r.jsx(K5,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>v.chain().focus().redo().run(),disabled:!v.can().redo(),type:"button",children:r.jsx(k5,{className:"w-4 h-4"})})]}),a.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{className:"toolbar-group",children:r.jsxs("select",{className:"link-tag-select",onChange:M=>{const P=a.find(H=>H.id===M.target.value);P&&C(P),M.target.value=""},defaultValue:"",children:[r.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),a.map(M=>r.jsx("option",{value:M.id,children:M.label},M.id))]})})]})]}),g&&r.jsxs("div",{className:"link-input-bar",children:[r.jsx("input",{type:"url",placeholder:"输入链接地址...",value:f,onChange:M=>m(M.target.value),onKeyDown:M=>M.key==="Enter"&&E(),className:"link-input"}),r.jsx("button",{onClick:E,className:"link-confirm",type:"button",children:"确定"}),r.jsx("button",{onClick:()=>{v.chain().focus().unsetLink().run(),y(!1)},className:"link-remove",type:"button",children:"移除"})]}),r.jsx(oC,{editor:v})]}):null});Hx.displayName="RichEditor";const t$=["top","right","bottom","left"],Vi=Math.min,qs=Math.max,Ef=Math.round,yh=Math.floor,sa=t=>({x:t,y:t}),n$={left:"right",right:"left",bottom:"top",top:"bottom"},s$={start:"end",end:"start"};function Wx(t,e,n){return qs(t,Vi(e,n))}function Ua(t,e){return typeof t=="function"?t(e):t}function Ka(t){return t.split("-")[0]}function oc(t){return t.split("-")[1]}function dy(t){return t==="x"?"y":"x"}function uy(t){return t==="y"?"height":"width"}const r$=new Set(["top","bottom"]);function na(t){return r$.has(Ka(t))?"y":"x"}function hy(t){return dy(na(t))}function a$(t,e,n){n===void 0&&(n=!1);const s=oc(t),a=hy(t),i=uy(a);let o=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Tf(o)),[o,Tf(o)]}function i$(t){const e=Tf(t);return[Ux(t),e,Ux(e)]}function Ux(t){return t.replace(/start|end/g,e=>s$[e])}const yw=["left","right"],bw=["right","left"],o$=["top","bottom"],l$=["bottom","top"];function c$(t,e,n){switch(t){case"top":case"bottom":return n?e?bw:yw:e?yw:bw;case"left":case"right":return e?o$:l$;default:return[]}}function d$(t,e,n,s){const a=oc(t);let i=c$(Ka(t),n==="start",s);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(Ux)))),i}function Tf(t){return t.replace(/left|right|bottom|top/g,e=>n$[e])}function u$(t){return{top:0,right:0,bottom:0,left:0,...t}}function QC(t){return typeof t!="number"?u$(t):{top:t,right:t,bottom:t,left:t}}function Mf(t){const{x:e,y:n,width:s,height:a}=t;return{width:s,height:a,top:n,left:e,right:e+s,bottom:n+a,x:e,y:n}}function vw(t,e,n){let{reference:s,floating:a}=t;const i=na(e),o=hy(e),c=uy(o),u=Ka(e),h=i==="y",f=s.x+s.width/2-a.width/2,m=s.y+s.height/2-a.height/2,g=s[c]/2-a[c]/2;let y;switch(u){case"top":y={x:f,y:s.y-a.height};break;case"bottom":y={x:f,y:s.y+s.height};break;case"right":y={x:s.x+s.width,y:m};break;case"left":y={x:s.x-a.width,y:m};break;default:y={x:s.x,y:s.y}}switch(oc(e)){case"start":y[o]-=g*(n&&h?-1:1);break;case"end":y[o]+=g*(n&&h?-1:1);break}return y}async function h$(t,e){var n;e===void 0&&(e={});const{x:s,y:a,platform:i,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=Ua(e,t),N=QC(y),v=c[g?m==="floating"?"reference":"floating":m],k=Mf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),C=m==="floating"?{x:s,y:a,width:o.floating.width,height:o.floating.height}:o.reference,E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),M=await(i.isElement==null?void 0:i.isElement(E))?await(i.getScale==null?void 0:i.getScale(E))||{x:1,y:1}:{x:1,y:1},P=Mf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:C,offsetParent:E,strategy:u}):C);return{top:(k.top-P.top+N.top)/M.y,bottom:(P.bottom-k.bottom+N.bottom)/M.y,left:(k.left-P.left+N.left)/M.x,right:(P.right-k.right+N.right)/M.x}}const f$=async(t,e,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:i=[],platform:o}=n,c=i.filter(Boolean),u=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:t,floating:e,strategy:a}),{x:f,y:m}=vw(h,s,u),g=s,y={},N=0;for(let v=0;v({name:"arrow",options:t,async fn(e){const{x:n,y:s,placement:a,rects:i,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=Ua(t,e)||{};if(h==null)return{};const m=QC(f),g={x:n,y:s},y=hy(a),N=uy(y),j=await o.getDimensions(h),v=y==="y",k=v?"top":"left",C=v?"bottom":"right",E=v?"clientHeight":"clientWidth",M=i.reference[N]+i.reference[y]-g[y]-i.floating[N],P=g[y]-i.reference[y],H=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let L=H?H[E]:0;(!L||!await(o.isElement==null?void 0:o.isElement(H)))&&(L=c.floating[E]||i.floating[N]);const R=M/2-P/2,O=L/2-j[N]/2-1,se=Vi(m[k],O),ie=Vi(m[C],O),z=se,ce=L-j[N]-ie,me=L/2-j[N]/2+R,_=Wx(z,me,ce),G=!u.arrow&&oc(a)!=null&&me!==_&&i.reference[N]/2-(meme<=0)){var ie,z;const me=(((ie=i.flip)==null?void 0:ie.index)||0)+1,_=L[me];if(_&&(!(m==="alignment"?C!==na(_):!1)||se.every(A=>na(A.placement)===C?A.overflows[0]>0:!0)))return{data:{index:me,overflows:se},reset:{placement:_}};let G=(z=se.filter($=>$.overflows[0]<=0).sort(($,A)=>$.overflows[1]-A.overflows[1])[0])==null?void 0:z.placement;if(!G)switch(y){case"bestFit":{var ce;const $=(ce=se.filter(A=>{if(H){const Y=na(A.placement);return Y===C||Y==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(Y=>Y>0).reduce((Y,U)=>Y+U,0)]).sort((A,Y)=>A[1]-Y[1])[0])==null?void 0:ce[0];$&&(G=$);break}case"initialPlacement":G=c;break}if(a!==G)return{reset:{placement:G}}}return{}}}};function Nw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function ww(t){return t$.some(e=>t[e]>=0)}const g$=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:s}=e,{strategy:a="referenceHidden",...i}=Ua(t,e);switch(a){case"referenceHidden":{const o=await s.detectOverflow(e,{...i,elementContext:"reference"}),c=Nw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:ww(c)}}}case"escaped":{const o=await s.detectOverflow(e,{...i,altBoundary:!0}),c=Nw(o,n.floating);return{data:{escapedOffsets:c,escaped:ww(c)}}}default:return{}}}}},XC=new Set(["left","top"]);async function x$(t,e){const{placement:n,platform:s,elements:a}=t,i=await(s.isRTL==null?void 0:s.isRTL(a.floating)),o=Ka(n),c=oc(n),u=na(n)==="y",h=XC.has(o)?-1:1,f=i&&u?-1:1,m=Ua(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:N}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof N=="number"&&(y=c==="end"?N*-1:N),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const y$=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:a,y:i,placement:o,middlewareData:c}=e,u=await x$(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:a+u.x,y:i+u.y,data:{...u,placement:o}}}}},b$=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:s,placement:a,platform:i}=e,{mainAxis:o=!0,crossAxis:c=!1,limiter:u={fn:k=>{let{x:C,y:E}=k;return{x:C,y:E}}},...h}=Ua(t,e),f={x:n,y:s},m=await i.detectOverflow(e,h),g=na(Ka(a)),y=dy(g);let N=f[y],j=f[g];if(o){const k=y==="y"?"top":"left",C=y==="y"?"bottom":"right",E=N+m[k],M=N-m[C];N=Wx(E,N,M)}if(c){const k=g==="y"?"top":"left",C=g==="y"?"bottom":"right",E=j+m[k],M=j-m[C];j=Wx(E,j,M)}const v=u.fn({...e,[y]:N,[g]:j});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[y]:o,[g]:c}}}}}},v$=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:s,placement:a,rects:i,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=Ua(t,e),f={x:n,y:s},m=na(a),g=dy(m);let y=f[g],N=f[m];const j=Ua(c,e),v=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(u){const E=g==="y"?"height":"width",M=i.reference[g]-i.floating[E]+v.mainAxis,P=i.reference[g]+i.reference[E]-v.mainAxis;yP&&(y=P)}if(h){var k,C;const E=g==="y"?"width":"height",M=XC.has(Ka(a)),P=i.reference[m]-i.floating[E]+(M&&((k=o.offset)==null?void 0:k[m])||0)+(M?0:v.crossAxis),H=i.reference[m]+i.reference[E]+(M?0:((C=o.offset)==null?void 0:C[m])||0)-(M?v.crossAxis:0);NH&&(N=H)}return{[g]:y,[m]:N}}}},N$=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,s;const{placement:a,rects:i,platform:o,elements:c}=e,{apply:u=()=>{},...h}=Ua(t,e),f=await o.detectOverflow(e,h),m=Ka(a),g=oc(a),y=na(a)==="y",{width:N,height:j}=i.floating;let v,k;m==="top"||m==="bottom"?(v=m,k=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,v=g==="end"?"top":"bottom");const C=j-f.top-f.bottom,E=N-f.left-f.right,M=Vi(j-f[v],C),P=Vi(N-f[k],E),H=!e.middlewareData.shift;let L=M,R=P;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(R=E),(s=e.middlewareData.shift)!=null&&s.enabled.y&&(L=C),H&&!g){const se=qs(f.left,0),ie=qs(f.right,0),z=qs(f.top,0),ce=qs(f.bottom,0);y?R=N-2*(se!==0||ie!==0?se+ie:qs(f.left,f.right)):L=j-2*(z!==0||ce!==0?z+ce:qs(f.top,f.bottom))}await u({...e,availableWidth:R,availableHeight:L});const O=await o.getDimensions(c.floating);return N!==O.width||j!==O.height?{reset:{rects:!0}}:{}}}};function ap(){return typeof window<"u"}function lc(t){return ZC(t)?(t.nodeName||"").toLowerCase():"#document"}function Xs(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ca(t){var e;return(e=(ZC(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function ZC(t){return ap()?t instanceof Node||t instanceof Xs(t).Node:!1}function Pr(t){return ap()?t instanceof Element||t instanceof Xs(t).Element:!1}function oa(t){return ap()?t instanceof HTMLElement||t instanceof Xs(t).HTMLElement:!1}function jw(t){return!ap()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Xs(t).ShadowRoot}const w$=new Set(["inline","contents"]);function Jd(t){const{overflow:e,overflowX:n,overflowY:s,display:a}=Or(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!w$.has(a)}const j$=new Set(["table","td","th"]);function k$(t){return j$.has(lc(t))}const S$=[":popover-open",":modal"];function ip(t){return S$.some(e=>{try{return t.matches(e)}catch{return!1}})}const C$=["transform","translate","scale","rotate","perspective"],E$=["transform","translate","scale","rotate","perspective","filter"],T$=["paint","layout","strict","content"];function fy(t){const e=py(),n=Pr(t)?Or(t):t;return C$.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||E$.some(s=>(n.willChange||"").includes(s))||T$.some(s=>(n.contain||"").includes(s))}function M$(t){let e=Hi(t);for(;oa(e)&&!Xl(e);){if(fy(e))return e;if(ip(e))return null;e=Hi(e)}return null}function py(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const A$=new Set(["html","body","#document"]);function Xl(t){return A$.has(lc(t))}function Or(t){return Xs(t).getComputedStyle(t)}function op(t){return Pr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Hi(t){if(lc(t)==="html")return t;const e=t.assignedSlot||t.parentNode||jw(t)&&t.host||ca(t);return jw(e)?e.host:e}function e4(t){const e=Hi(t);return Xl(e)?t.ownerDocument?t.ownerDocument.body:t.body:oa(e)&&Jd(e)?e:e4(e)}function Fd(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=e4(t),i=a===((s=t.ownerDocument)==null?void 0:s.body),o=Xs(a);if(i){const c=Kx(o);return e.concat(o,o.visualViewport||[],Jd(a)?a:[],c&&n?Fd(c):[])}return e.concat(a,Fd(a,[],n))}function Kx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function t4(t){const e=Or(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const a=oa(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:s,c=Ef(n)!==i||Ef(s)!==o;return c&&(n=i,s=o),{width:n,height:s,$:c}}function my(t){return Pr(t)?t:t.contextElement}function Hl(t){const e=my(t);if(!oa(e))return sa(1);const n=e.getBoundingClientRect(),{width:s,height:a,$:i}=t4(e);let o=(i?Ef(n.width):n.width)/s,c=(i?Ef(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const I$=sa(0);function n4(t){const e=Xs(t);return!py()||!e.visualViewport?I$:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function R$(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Xs(t)?!1:e}function Ko(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=my(t);let o=sa(1);e&&(s?Pr(s)&&(o=Hl(s)):o=Hl(t));const c=R$(i,n,s)?n4(i):sa(0);let u=(a.left+c.x)/o.x,h=(a.top+c.y)/o.y,f=a.width/o.x,m=a.height/o.y;if(i){const g=Xs(i),y=s&&Pr(s)?Xs(s):s;let N=g,j=Kx(N);for(;j&&s&&y!==N;){const v=Hl(j),k=j.getBoundingClientRect(),C=Or(j),E=k.left+(j.clientLeft+parseFloat(C.paddingLeft))*v.x,M=k.top+(j.clientTop+parseFloat(C.paddingTop))*v.y;u*=v.x,h*=v.y,f*=v.x,m*=v.y,u+=E,h+=M,N=Xs(j),j=Kx(N)}}return Mf({width:f,height:m,x:u,y:h})}function lp(t,e){const n=op(t).scrollLeft;return e?e.left+n:Ko(ca(t)).left+n}function s4(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-lp(t,n),a=n.top+e.scrollTop;return{x:s,y:a}}function P$(t){let{elements:e,rect:n,offsetParent:s,strategy:a}=t;const i=a==="fixed",o=ca(s),c=e?ip(e.floating):!1;if(s===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=sa(1);const f=sa(0),m=oa(s);if((m||!m&&!i)&&((lc(s)!=="body"||Jd(o))&&(u=op(s)),oa(s))){const y=Ko(s);h=Hl(s),f.x=y.x+s.clientLeft,f.y=y.y+s.clientTop}const g=o&&!m&&!i?s4(o,u):sa(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+f.x+g.x,y:n.y*h.y-u.scrollTop*h.y+f.y+g.y}}function O$(t){return Array.from(t.getClientRects())}function D$(t){const e=ca(t),n=op(t),s=t.ownerDocument.body,a=qs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=qs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let o=-n.scrollLeft+lp(t);const c=-n.scrollTop;return Or(s).direction==="rtl"&&(o+=qs(e.clientWidth,s.clientWidth)-a),{width:a,height:i,x:o,y:c}}const kw=25;function L$(t,e){const n=Xs(t),s=ca(t),a=n.visualViewport;let i=s.clientWidth,o=s.clientHeight,c=0,u=0;if(a){i=a.width,o=a.height;const f=py();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=lp(s);if(h<=0){const f=s.ownerDocument,m=f.body,g=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,N=Math.abs(s.clientWidth-m.clientWidth-y);N<=kw&&(i-=N)}else h<=kw&&(i+=h);return{width:i,height:o,x:c,y:u}}const _$=new Set(["absolute","fixed"]);function z$(t,e){const n=Ko(t,!0,e==="fixed"),s=n.top+t.clientTop,a=n.left+t.clientLeft,i=oa(t)?Hl(t):sa(1),o=t.clientWidth*i.x,c=t.clientHeight*i.y,u=a*i.x,h=s*i.y;return{width:o,height:c,x:u,y:h}}function Sw(t,e,n){let s;if(e==="viewport")s=L$(t,n);else if(e==="document")s=D$(ca(t));else if(Pr(e))s=z$(e,n);else{const a=n4(t);s={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Mf(s)}function r4(t,e){const n=Hi(t);return n===e||!Pr(n)||Xl(n)?!1:Or(n).position==="fixed"||r4(n,e)}function F$(t,e){const n=e.get(t);if(n)return n;let s=Fd(t,[],!1).filter(c=>Pr(c)&&lc(c)!=="body"),a=null;const i=Or(t).position==="fixed";let o=i?Hi(t):t;for(;Pr(o)&&!Xl(o);){const c=Or(o),u=fy(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&_$.has(a.position)||Jd(o)&&!u&&r4(t,o))?s=s.filter(f=>f!==o):a=c,o=Hi(o)}return e.set(t,s),s}function $$(t){let{element:e,boundary:n,rootBoundary:s,strategy:a}=t;const o=[...n==="clippingAncestors"?ip(e)?[]:F$(e,this._c):[].concat(n),s],c=o[0],u=o.reduce((h,f)=>{const m=Sw(e,f,a);return h.top=qs(m.top,h.top),h.right=Vi(m.right,h.right),h.bottom=Vi(m.bottom,h.bottom),h.left=qs(m.left,h.left),h},Sw(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function B$(t){const{width:e,height:n}=t4(t);return{width:e,height:n}}function V$(t,e,n){const s=oa(e),a=ca(e),i=n==="fixed",o=Ko(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=sa(0);function h(){u.x=lp(a)}if(s||!s&&!i)if((lc(e)!=="body"||Jd(a))&&(c=op(e)),s){const y=Ko(e,!0,i,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else a&&h();i&&!s&&a&&h();const f=a&&!s&&!i?s4(a,c):sa(0),m=o.left+c.scrollLeft-u.x-f.x,g=o.top+c.scrollTop-u.y-f.y;return{x:m,y:g,width:o.width,height:o.height}}function Dg(t){return Or(t).position==="static"}function Cw(t,e){if(!oa(t)||Or(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ca(t)===n&&(n=n.ownerDocument.body),n}function a4(t,e){const n=Xs(t);if(ip(t))return n;if(!oa(t)){let a=Hi(t);for(;a&&!Xl(a);){if(Pr(a)&&!Dg(a))return a;a=Hi(a)}return n}let s=Cw(t,e);for(;s&&k$(s)&&Dg(s);)s=Cw(s,e);return s&&Xl(s)&&Dg(s)&&!fy(s)?n:s||M$(t)||n}const H$=async function(t){const e=this.getOffsetParent||a4,n=this.getDimensions,s=await n(t.floating);return{reference:V$(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function W$(t){return Or(t).direction==="rtl"}const U$={convertOffsetParentRelativeRectToViewportRelativeRect:P$,getDocumentElement:ca,getClippingRect:$$,getOffsetParent:a4,getElementRects:H$,getClientRects:O$,getDimensions:B$,getScale:Hl,isElement:Pr,isRTL:W$};function i4(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function K$(t,e){let n=null,s;const a=ca(t);function i(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function o(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),i();const h=t.getBoundingClientRect(),{left:f,top:m,width:g,height:y}=h;if(c||e(),!g||!y)return;const N=yh(m),j=yh(a.clientWidth-(f+g)),v=yh(a.clientHeight-(m+y)),k=yh(f),E={rootMargin:-N+"px "+-j+"px "+-v+"px "+-k+"px",threshold:qs(0,Vi(1,u))||1};let M=!0;function P(H){const L=H[0].intersectionRatio;if(L!==u){if(!M)return o();L?o(!1,L):s=setTimeout(()=>{o(!1,1e-7)},1e3)}L===1&&!i4(h,t.getBoundingClientRect())&&o(),M=!1}try{n=new IntersectionObserver(P,{...E,root:a.ownerDocument})}catch{n=new IntersectionObserver(P,E)}n.observe(t)}return o(!0),i}function q$(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,h=my(t),f=a||i?[...h?Fd(h):[],...Fd(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?K$(h,n):null;let g=-1,y=null;o&&(y=new ResizeObserver(k=>{let[C]=k;C&&C.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var E;(E=y)==null||E.observe(e)})),n()}),h&&!u&&y.observe(h),y.observe(e));let N,j=u?Ko(t):null;u&&v();function v(){const k=Ko(t);j&&!i4(j,k)&&n(),j=k,N=requestAnimationFrame(v)}return n(),()=>{var k;f.forEach(C=>{a&&C.removeEventListener("scroll",n),i&&C.removeEventListener("resize",n)}),m==null||m(),(k=y)==null||k.disconnect(),y=null,u&&cancelAnimationFrame(N)}}const G$=y$,J$=b$,Y$=m$,Q$=N$,X$=g$,Ew=p$,Z$=v$,eB=(t,e,n)=>{const s=new Map,a={platform:U$,...n},i={...a.platform,_c:s};return f$(t,e,{...a,platform:i})};var tB=typeof document<"u",nB=function(){},Th=tB?b.useLayoutEffect:nB;function Af(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,s,a;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(s=n;s--!==0;)if(!Af(t[s],e[s]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(e).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(e,a[s]))return!1;for(s=n;s--!==0;){const i=a[s];if(!(i==="_owner"&&t.$$typeof)&&!Af(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function o4(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Tw(t,e){const n=o4(t);return Math.round(e*n)/n}function Lg(t){const e=b.useRef(t);return Th(()=>{e.current=t}),e}function sB(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:i,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=b.useState(s);Af(g,s)||y(s);const[N,j]=b.useState(null),[v,k]=b.useState(null),C=b.useCallback(A=>{A!==H.current&&(H.current=A,j(A))},[]),E=b.useCallback(A=>{A!==L.current&&(L.current=A,k(A))},[]),M=i||N,P=o||v,H=b.useRef(null),L=b.useRef(null),R=b.useRef(f),O=u!=null,se=Lg(u),ie=Lg(a),z=Lg(h),ce=b.useCallback(()=>{if(!H.current||!L.current)return;const A={placement:e,strategy:n,middleware:g};ie.current&&(A.platform=ie.current),eB(H.current,L.current,A).then(Y=>{const U={...Y,isPositioned:z.current!==!1};me.current&&!Af(R.current,U)&&(R.current=U,Bd.flushSync(()=>{m(U)}))})},[g,e,n,ie,z]);Th(()=>{h===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,m(A=>({...A,isPositioned:!1})))},[h]);const me=b.useRef(!1);Th(()=>(me.current=!0,()=>{me.current=!1}),[]),Th(()=>{if(M&&(H.current=M),P&&(L.current=P),M&&P){if(se.current)return se.current(M,P,ce);ce()}},[M,P,ce,se,O]);const _=b.useMemo(()=>({reference:H,floating:L,setReference:C,setFloating:E}),[C,E]),G=b.useMemo(()=>({reference:M,floating:P}),[M,P]),$=b.useMemo(()=>{const A={position:n,left:0,top:0};if(!G.floating)return A;const Y=Tw(G.floating,f.x),U=Tw(G.floating,f.y);return c?{...A,transform:"translate("+Y+"px, "+U+"px)",...o4(G.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:U}},[n,c,G.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:ce,refs:_,elements:G,floatingStyles:$}),[f,ce,_,G,$])}const rB=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:s,padding:a}=typeof t=="function"?t(n):t;return s&&e(s)?s.current!=null?Ew({element:s.current,padding:a}).fn(n):{}:s?Ew({element:s,padding:a}).fn(n):{}}}},aB=(t,e)=>({...G$(t),options:[t,e]}),iB=(t,e)=>({...J$(t),options:[t,e]}),oB=(t,e)=>({...Z$(t),options:[t,e]}),lB=(t,e)=>({...Y$(t),options:[t,e]}),cB=(t,e)=>({...Q$(t),options:[t,e]}),dB=(t,e)=>({...X$(t),options:[t,e]}),uB=(t,e)=>({...rB(t),options:[t,e]});var hB="Arrow",l4=b.forwardRef((t,e)=>{const{children:n,width:s=10,height:a=5,...i}=t;return r.jsx(pt.svg,{...i,ref:e,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});l4.displayName=hB;var fB=l4,gy="Popper",[c4,d4]=qi(gy),[pB,u4]=c4(gy),h4=t=>{const{__scopePopper:e,children:n}=t,[s,a]=b.useState(null);return r.jsx(pB,{scope:e,anchor:s,onAnchorChange:a,children:n})};h4.displayName=gy;var f4="PopperAnchor",p4=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:s,...a}=t,i=u4(f4,n),o=b.useRef(null),c=Tt(e,o),u=b.useRef(null);return b.useEffect(()=>{const h=u.current;u.current=(s==null?void 0:s.current)||o.current,h!==u.current&&i.onAnchorChange(u.current)}),s?null:r.jsx(pt.div,{...a,ref:c})});p4.displayName=f4;var xy="PopperContent",[mB,gB]=c4(xy),m4=b.forwardRef((t,e)=>{var K,J,ge,ae,pe,Se;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:N,...j}=t,v=u4(xy,n),[k,C]=b.useState(null),E=Tt(e,tt=>C(tt)),[M,P]=b.useState(null),H=x0(M),L=(H==null?void 0:H.width)??0,R=(H==null?void 0:H.height)??0,O=s+(i!=="center"?"-"+i:""),se=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},ie=Array.isArray(h)?h:[h],z=ie.length>0,ce={padding:se,boundary:ie.filter(yB),altBoundary:z},{refs:me,floatingStyles:_,placement:G,isPositioned:$,middlewareData:A}=sB({strategy:"fixed",placement:O,whileElementsMounted:(...tt)=>q$(...tt,{animationFrame:y==="always"}),elements:{reference:v.anchor},middleware:[aB({mainAxis:a+R,alignmentAxis:o}),u&&iB({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?oB():void 0,...ce}),u&&lB({...ce}),cB({...ce,apply:({elements:tt,rects:at,availableWidth:Dt,availableHeight:kt})=>{const{width:At,height:Gt}=at.reference,In=tt.floating.style;In.setProperty("--radix-popper-available-width",`${Dt}px`),In.setProperty("--radix-popper-available-height",`${kt}px`),In.setProperty("--radix-popper-anchor-width",`${At}px`),In.setProperty("--radix-popper-anchor-height",`${Gt}px`)}}),M&&uB({element:M,padding:c}),bB({arrowWidth:L,arrowHeight:R}),g&&dB({strategy:"referenceHidden",...ce})]}),[Y,U]=y4(G),D=Fi(N);xs(()=>{$&&(D==null||D())},[$,D]);const W=(K=A.arrow)==null?void 0:K.x,le=(J=A.arrow)==null?void 0:J.y,ye=((ge=A.arrow)==null?void 0:ge.centerOffset)!==0,[Ae,ne]=b.useState();return xs(()=>{k&&ne(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:me.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:$?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(ae=A.transformOrigin)==null?void 0:ae.x,(pe=A.transformOrigin)==null?void 0:pe.y].join(" "),...((Se=A.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:r.jsx(mB,{scope:n,placedSide:Y,onArrowChange:P,arrowX:W,arrowY:le,shouldHideArrow:ye,children:r.jsx(pt.div,{"data-side":Y,"data-align":U,...j,ref:E,style:{...j.style,animation:$?void 0:"none"}})})})});m4.displayName=xy;var g4="PopperArrow",xB={top:"bottom",right:"left",bottom:"top",left:"right"},x4=b.forwardRef(function(e,n){const{__scopePopper:s,...a}=e,i=gB(g4,s),o=xB[i.placedSide];return r.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:r.jsx(fB,{...a,ref:n,style:{...a.style,display:"block"}})})});x4.displayName=g4;function yB(t){return t!==null}var bB=t=>({name:"transformOrigin",options:t,fn(e){var v,k,C;const{placement:n,rects:s,middlewareData:a}=e,o=((v=a.arrow)==null?void 0:v.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=y4(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((k=a.arrow)==null?void 0:k.x)??0)+c/2,y=(((C=a.arrow)==null?void 0:C.y)??0)+u/2;let N="",j="";return h==="bottom"?(N=o?m:`${g}px`,j=`${-u}px`):h==="top"?(N=o?m:`${g}px`,j=`${s.floating.height+u}px`):h==="right"?(N=`${-u}px`,j=o?m:`${y}px`):h==="left"&&(N=`${s.floating.width+u}px`,j=o?m:`${y}px`),{data:{x:N,y:j}}}});function y4(t){const[e,n="center"]=t.split("-");return[e,n]}var vB=h4,NB=p4,wB=m4,jB=x4,b4=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),kB="VisuallyHidden",SB=b.forwardRef((t,e)=>r.jsx(pt.span,{...t,ref:e,style:{...b4,...t.style}}));SB.displayName=kB;var CB=[" ","Enter","ArrowUp","ArrowDown"],EB=[" ","Enter"],qo="Select",[cp,dp,TB]=p0(qo),[cc]=qi(qo,[TB,d4]),up=d4(),[MB,Qi]=cc(qo),[AB,IB]=cc(qo),v4=t=>{const{__scopeSelect:e,children:n,open:s,defaultOpen:a,onOpenChange:i,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:N}=t,j=up(e),[v,k]=b.useState(null),[C,E]=b.useState(null),[M,P]=b.useState(!1),H=Ff(h),[L,R]=_o({prop:s,defaultProp:a??!1,onChange:i,caller:qo}),[O,se]=_o({prop:o,defaultProp:c,onChange:u,caller:qo}),ie=b.useRef(null),z=v?N||!!v.closest("form"):!0,[ce,me]=b.useState(new Set),_=Array.from(ce).map(G=>G.props.value).join(";");return r.jsx(vB,{...j,children:r.jsxs(MB,{required:y,scope:e,trigger:v,onTriggerChange:k,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:M,onValueNodeHasChildrenChange:P,contentId:Pi(),value:O,onValueChange:se,open:L,onOpenChange:R,dir:H,triggerPointerDownPosRef:ie,disabled:g,children:[r.jsx(cp.Provider,{scope:e,children:r.jsx(AB,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback(G=>{me($=>new Set($).add(G))},[]),onNativeOptionRemove:b.useCallback(G=>{me($=>{const A=new Set($);return A.delete(G),A})},[]),children:n})}),z?r.jsxs(V4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:O,onChange:G=>se(G.target.value),disabled:g,form:N,children:[O===void 0?r.jsx("option",{value:""}):null,Array.from(ce)]},_):null]})})};v4.displayName=qo;var N4="SelectTrigger",w4=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:s=!1,...a}=t,i=up(n),o=Qi(N4,n),c=o.disabled||s,u=Tt(e,o.onTriggerChange),h=dp(n),f=b.useRef("touch"),[m,g,y]=W4(j=>{const v=h().filter(E=>!E.disabled),k=v.find(E=>E.value===o.value),C=U4(v,j,k);C!==void 0&&o.onValueChange(C.value)}),N=j=>{c||(o.onOpenChange(!0),y()),j&&(o.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return r.jsx(NB,{asChild:!0,...i,children:r.jsx(pt.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":H4(o.value)?"":void 0,...a,ref:u,onClick:dt(a.onClick,j=>{j.currentTarget.focus(),f.current!=="mouse"&&N(j)}),onPointerDown:dt(a.onPointerDown,j=>{f.current=j.pointerType;const v=j.target;v.hasPointerCapture(j.pointerId)&&v.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(N(j),j.preventDefault())}),onKeyDown:dt(a.onKeyDown,j=>{const v=m.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(v&&j.key===" ")&&CB.includes(j.key)&&(N(),j.preventDefault())})})})});w4.displayName=N4;var j4="SelectValue",k4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:a,children:i,placeholder:o="",...c}=t,u=Qi(j4,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Tt(e,u.onValueNodeChange);return xs(()=>{h(f)},[h,f]),r.jsx(pt.span,{...c,ref:m,style:{pointerEvents:"none"},children:H4(u.value)?r.jsx(r.Fragment,{children:o}):i})});k4.displayName=j4;var RB="SelectIcon",S4=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:s,...a}=t;return r.jsx(pt.span,{"aria-hidden":!0,...a,ref:e,children:s||"▼"})});S4.displayName=RB;var PB="SelectPortal",C4=t=>r.jsx(c0,{asChild:!0,...t});C4.displayName=PB;var Go="SelectContent",E4=b.forwardRef((t,e)=>{const n=Qi(Go,t.__scopeSelect),[s,a]=b.useState();if(xs(()=>{a(new DocumentFragment)},[]),!n.open){const i=s;return i?Bd.createPortal(r.jsx(T4,{scope:t.__scopeSelect,children:r.jsx(cp.Slot,{scope:t.__scopeSelect,children:r.jsx("div",{children:t.children})})}),i):null}return r.jsx(M4,{...t,ref:e})});E4.displayName=Go;var Mr=10,[T4,Xi]=cc(Go),OB="SelectContentImpl",DB=Sd("SelectContent.RemoveScroll"),M4=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:N,hideWhenDetached:j,avoidCollisions:v,...k}=t,C=Qi(Go,n),[E,M]=b.useState(null),[P,H]=b.useState(null),L=Tt(e,K=>M(K)),[R,O]=b.useState(null),[se,ie]=b.useState(null),z=dp(n),[ce,me]=b.useState(!1),_=b.useRef(!1);b.useEffect(()=>{if(E)return Wj(E)},[E]),Dj();const G=b.useCallback(K=>{const[J,...ge]=z().map(Se=>Se.ref.current),[ae]=ge.slice(-1),pe=document.activeElement;for(const Se of K)if(Se===pe||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===J&&P&&(P.scrollTop=0),Se===ae&&P&&(P.scrollTop=P.scrollHeight),Se==null||Se.focus(),document.activeElement!==pe))return},[z,P]),$=b.useCallback(()=>G([R,E]),[G,R,E]);b.useEffect(()=>{ce&&$()},[ce,$]);const{onOpenChange:A,triggerPointerDownPosRef:Y}=C;b.useEffect(()=>{if(E){let K={x:0,y:0};const J=ae=>{var pe,Se;K={x:Math.abs(Math.round(ae.pageX)-(((pe=Y.current)==null?void 0:pe.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((Se=Y.current)==null?void 0:Se.y)??0))}},ge=ae=>{K.x<=10&&K.y<=10?ae.preventDefault():E.contains(ae.target)||A(!1),document.removeEventListener("pointermove",J),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",ge,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",ge,{capture:!0})}}},[E,A,Y]),b.useEffect(()=>{const K=()=>A(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[A]);const[U,D]=W4(K=>{const J=z().filter(pe=>!pe.disabled),ge=J.find(pe=>pe.ref.current===document.activeElement),ae=U4(J,K,ge);ae&&setTimeout(()=>ae.ref.current.focus())}),W=b.useCallback((K,J,ge)=>{const ae=!_.current&&!ge;(C.value!==void 0&&C.value===J||ae)&&(O(K),ae&&(_.current=!0))},[C.value]),le=b.useCallback(()=>E==null?void 0:E.focus(),[E]),ye=b.useCallback((K,J,ge)=>{const ae=!_.current&&!ge;(C.value!==void 0&&C.value===J||ae)&&ie(K)},[C.value]),Ae=s==="popper"?qx:A4,ne=Ae===qx?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:N,hideWhenDetached:j,avoidCollisions:v}:{};return r.jsx(T4,{scope:n,content:E,viewport:P,onViewportChange:H,itemRefCallback:W,selectedItem:R,onItemLeave:le,itemTextRefCallback:ye,focusSelectedItem:$,selectedItemText:se,position:s,isPositioned:ce,searchRef:U,children:r.jsx(d0,{as:DB,allowPinchZoom:!0,children:r.jsx(l0,{asChild:!0,trapped:C.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:dt(a,K=>{var J;(J=C.trigger)==null||J.focus({preventScroll:!0}),K.preventDefault()}),children:r.jsx(o0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:r.jsx(Ae,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:K=>K.preventDefault(),...k,...ne,onPlaced:()=>me(!0),ref:L,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:dt(k.onKeyDown,K=>{const J=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!J&&K.key.length===1&&D(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let ae=z().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);if(["ArrowUp","End"].includes(K.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const pe=K.target,Se=ae.indexOf(pe);ae=ae.slice(Se+1)}setTimeout(()=>G(ae)),K.preventDefault()}})})})})})})});M4.displayName=OB;var LB="SelectItemAlignedPosition",A4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:s,...a}=t,i=Qi(Go,n),o=Xi(Go,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=Tt(e,L=>f(L)),g=dp(n),y=b.useRef(!1),N=b.useRef(!0),{viewport:j,selectedItem:v,selectedItemText:k,focusSelectedItem:C}=o,E=b.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&j&&v&&k){const L=i.trigger.getBoundingClientRect(),R=h.getBoundingClientRect(),O=i.valueNode.getBoundingClientRect(),se=k.getBoundingClientRect();if(i.dir!=="rtl"){const pe=se.left-R.left,Se=O.left-pe,tt=L.left-Se,at=L.width+tt,Dt=Math.max(at,R.width),kt=window.innerWidth-Mr,At=Lh(Se,[Mr,Math.max(Mr,kt-Dt)]);c.style.minWidth=at+"px",c.style.left=At+"px"}else{const pe=R.right-se.right,Se=window.innerWidth-O.right-pe,tt=window.innerWidth-L.right-Se,at=L.width+tt,Dt=Math.max(at,R.width),kt=window.innerWidth-Mr,At=Lh(Se,[Mr,Math.max(Mr,kt-Dt)]);c.style.minWidth=at+"px",c.style.right=At+"px"}const ie=g(),z=window.innerHeight-Mr*2,ce=j.scrollHeight,me=window.getComputedStyle(h),_=parseInt(me.borderTopWidth,10),G=parseInt(me.paddingTop,10),$=parseInt(me.borderBottomWidth,10),A=parseInt(me.paddingBottom,10),Y=_+G+ce+A+$,U=Math.min(v.offsetHeight*5,Y),D=window.getComputedStyle(j),W=parseInt(D.paddingTop,10),le=parseInt(D.paddingBottom,10),ye=L.top+L.height/2-Mr,Ae=z-ye,ne=v.offsetHeight/2,K=v.offsetTop+ne,J=_+G+K,ge=Y-J;if(J<=ye){const pe=ie.length>0&&v===ie[ie.length-1].ref.current;c.style.bottom="0px";const Se=h.clientHeight-j.offsetTop-j.offsetHeight,tt=Math.max(Ae,ne+(pe?le:0)+Se+$),at=J+tt;c.style.height=at+"px"}else{const pe=ie.length>0&&v===ie[0].ref.current;c.style.top="0px";const tt=Math.max(ye,_+j.offsetTop+(pe?W:0)+ne)+ge;c.style.height=tt+"px",j.scrollTop=J-ye+j.offsetTop}c.style.margin=`${Mr}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=z+"px",s==null||s(),requestAnimationFrame(()=>y.current=!0)}},[g,i.trigger,i.valueNode,c,h,j,v,k,i.dir,s]);xs(()=>E(),[E]);const[M,P]=b.useState();xs(()=>{h&&P(window.getComputedStyle(h).zIndex)},[h]);const H=b.useCallback(L=>{L&&N.current===!0&&(E(),C==null||C(),N.current=!1)},[E,C]);return r.jsx(zB,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:H,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:r.jsx(pt.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});A4.displayName=LB;var _B="SelectPopperPosition",qx=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=Mr,...i}=t,o=up(n);return r.jsx(wB,{...o,...i,ref:e,align:s,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});qx.displayName=_B;var[zB,yy]=cc(Go,{}),Gx="SelectViewport",I4=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:s,...a}=t,i=Xi(Gx,n),o=yy(Gx,n),c=Tt(e,i.onViewportChange),u=b.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(cp.Slot,{scope:n,children:r.jsx(pt.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:dt(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:g}=o;if(g!=null&&g.current&&m){const y=Math.abs(u.current-f.scrollTop);if(y>0){const N=window.innerHeight-Mr*2,j=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),k=Math.max(j,v);if(k0?M:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});I4.displayName=Gx;var R4="SelectGroup",[FB,$B]=cc(R4),BB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=Pi();return r.jsx(FB,{scope:n,id:a,children:r.jsx(pt.div,{role:"group","aria-labelledby":a,...s,ref:e})})});BB.displayName=R4;var P4="SelectLabel",VB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=$B(P4,n);return r.jsx(pt.div,{id:a.id,...s,ref:e})});VB.displayName=P4;var If="SelectItem",[HB,O4]=cc(If),D4=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:i,...o}=t,c=Qi(If,n),u=Xi(If,n),h=c.value===s,[f,m]=b.useState(i??""),[g,y]=b.useState(!1),N=Tt(e,C=>{var E;return(E=u.itemRefCallback)==null?void 0:E.call(u,C,s,a)}),j=Pi(),v=b.useRef("touch"),k=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(HB,{scope:n,value:s,disabled:a,textId:j,isSelected:h,onItemTextChange:b.useCallback(C=>{m(E=>E||((C==null?void 0:C.textContent)??"").trim())},[]),children:r.jsx(cp.ItemSlot,{scope:n,value:s,disabled:a,textValue:f,children:r.jsx(pt.div,{role:"option","aria-labelledby":j,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:dt(o.onFocus,()=>y(!0)),onBlur:dt(o.onBlur,()=>y(!1)),onClick:dt(o.onClick,()=>{v.current!=="mouse"&&k()}),onPointerUp:dt(o.onPointerUp,()=>{v.current==="mouse"&&k()}),onPointerDown:dt(o.onPointerDown,C=>{v.current=C.pointerType}),onPointerMove:dt(o.onPointerMove,C=>{var E;v.current=C.pointerType,a?(E=u.onItemLeave)==null||E.call(u):v.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:dt(o.onPointerLeave,C=>{var E;C.currentTarget===document.activeElement&&((E=u.onItemLeave)==null||E.call(u))}),onKeyDown:dt(o.onKeyDown,C=>{var M;((M=u.searchRef)==null?void 0:M.current)!==""&&C.key===" "||(EB.includes(C.key)&&k(),C.key===" "&&C.preventDefault())})})})})});D4.displayName=If;var ad="SelectItemText",L4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:s,style:a,...i}=t,o=Qi(ad,n),c=Xi(ad,n),u=O4(ad,n),h=IB(ad,n),[f,m]=b.useState(null),g=Tt(e,k=>m(k),u.onItemTextChange,k=>{var C;return(C=c.itemTextRefCallback)==null?void 0:C.call(c,k,u.value,u.disabled)}),y=f==null?void 0:f.textContent,N=b.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:j,onNativeOptionRemove:v}=h;return xs(()=>(j(N),()=>v(N)),[j,v,N]),r.jsxs(r.Fragment,{children:[r.jsx(pt.span,{id:u.textId,...i,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Bd.createPortal(i.children,o.valueNode):null]})});L4.displayName=ad;var _4="SelectItemIndicator",z4=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return O4(_4,n).isSelected?r.jsx(pt.span,{"aria-hidden":!0,...s,ref:e}):null});z4.displayName=_4;var Jx="SelectScrollUpButton",F4=b.forwardRef((t,e)=>{const n=Xi(Jx,t.__scopeSelect),s=yy(Jx,t.__scopeSelect),[a,i]=b.useState(!1),o=Tt(e,s.onScrollButtonChange);return xs(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollTop>0;i(h)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?r.jsx(B4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});F4.displayName=Jx;var Yx="SelectScrollDownButton",$4=b.forwardRef((t,e)=>{const n=Xi(Yx,t.__scopeSelect),s=yy(Yx,t.__scopeSelect),[a,i]=b.useState(!1),o=Tt(e,s.onScrollButtonChange);return xs(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?r.jsx(B4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});$4.displayName=Yx;var B4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=t,i=Xi("SelectScrollButton",n),o=b.useRef(null),c=dp(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),xs(()=>{var f;const h=c().find(m=>m.ref.current===document.activeElement);(f=h==null?void 0:h.ref.current)==null||f.scrollIntoView({block:"nearest"})},[c]),r.jsx(pt.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:dt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(s,50))}),onPointerMove:dt(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(s,50))}),onPointerLeave:dt(a.onPointerLeave,()=>{u()})})}),WB="SelectSeparator",UB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t;return r.jsx(pt.div,{"aria-hidden":!0,...s,ref:e})});UB.displayName=WB;var Qx="SelectArrow",KB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...s}=t,a=up(n),i=Qi(Qx,n),o=Xi(Qx,n);return i.open&&o.position==="popper"?r.jsx(jB,{...a,...s,ref:e}):null});KB.displayName=Qx;var qB="SelectBubbleInput",V4=b.forwardRef(({__scopeSelect:t,value:e,...n},s)=>{const a=b.useRef(null),i=Tt(s,a),o=g0(e);return b.useEffect(()=>{const c=a.current;if(!c)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("change",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),r.jsx(pt.select,{...n,style:{...b4,...n.style},ref:i,defaultValue:e})});V4.displayName=qB;function H4(t){return t===""||t===void 0}function W4(t){const e=Fi(t),n=b.useRef(""),s=b.useRef(0),a=b.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(s.current),h!==""&&(s.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),i=b.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,i]}function U4(t,e,n){const a=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let o=GB(t,Math.max(i,0));a.length===1&&(o=o.filter(h=>h!==n));const u=o.find(h=>h.textValue.toLowerCase().startsWith(a.toLowerCase()));return u!==n?u:void 0}function GB(t,e){return t.map((n,s)=>t[(e+s)%t.length])}var JB=v4,K4=w4,YB=k4,QB=S4,XB=C4,q4=E4,ZB=I4,G4=D4,eV=L4,tV=z4,nV=F4,sV=$4;const Pl=JB,Ol=YB,jo=b.forwardRef(({className:t,children:e,...n},s)=>r.jsxs(K4,{ref:s,className:Mt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,r.jsx(QB,{asChild:!0,children:r.jsx(kd,{className:"h-4 w-4 opacity-50"})})]}));jo.displayName=K4.displayName;const ko=b.forwardRef(({className:t,children:e,position:n="popper",...s},a)=>r.jsx(XB,{children:r.jsxs(q4,{ref:a,className:Mt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1",t),position:n,...s,children:[r.jsx(nV,{className:"flex cursor-default items-center justify-center py-1",children:r.jsx(sj,{className:"h-4 w-4"})}),r.jsx(ZB,{className:"p-1",children:e}),r.jsx(sV,{className:"flex cursor-default items-center justify-center py-1",children:r.jsx(kd,{className:"h-4 w-4"})})]})}));ko.displayName=q4.displayName;const Ks=b.forwardRef(({className:t,children:e,...n},s)=>r.jsxs(G4,{ref:s,className:Mt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(tV,{children:r.jsx(Of,{className:"h-4 w-4"})})}),r.jsx(eV,{children:e})]}));Ks.displayName=G4.displayName;function rV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(null),[u,h]=b.useState({name:"",appId:"",path:"",sort:0}),[f,m]=b.useState(!1);async function g(){s(!0);try{const k=await De("/api/admin/linked-miniprograms");if(k!=null&&k.success&&Array.isArray(k.data)){const C=[...k.data].sort((E,M)=>(E.sort??0)-(M.sort??0));e(C)}}catch(k){console.error("Load linked miniprograms error:",k),te.error("加载失败")}finally{s(!1)}}b.useEffect(()=>{g()},[]);function y(){c(null),h({name:"",appId:"",path:"",sort:t.length}),i(!0)}function N(k){c(k),h({name:k.name,appId:k.appId,path:k.path??"",sort:k.sort??0}),i(!0)}async function j(){const k=u.name.trim(),C=u.appId.trim();if(!k||!C){te.error("请填写小程序名称和 AppID");return}m(!0);try{if(o){const E=await Ot("/api/admin/linked-miniprograms",{key:o.key,name:k,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(te.success("已更新"),i(!1),g()):te.error((E==null?void 0:E.error)??"更新失败")}else{const E=await Nt("/api/admin/linked-miniprograms",{name:k,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(te.success("已添加"),i(!1),g()):te.error((E==null?void 0:E.error)??"添加失败")}}catch{te.error("操作失败")}finally{m(!1)}}async function v(k){if(confirm(`确定要删除「${k.name}」吗?`))try{const C=await ea(`/api/admin/linked-miniprograms/${k.key}`);C!=null&&C.success?(te.success("已删除"),g()):te.error((C==null?void 0:C.error)??"删除失败")}catch{te.error("删除失败")}}return r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5 text-[#38bdac]"}),"关联小程序管理"]}),r.jsx(Ft,{className:"text-gray-400",children:"添加后生成 32 位密钥,链接标签选择小程序时存密钥;小程序端点击 #标签 时用密钥查 appId 再跳转。需在 app.json 的 navigateToMiniProgramAppIdList 中配置目标 AppID。"})]}),r.jsxs(Te,{children:[r.jsxs("div",{className:"flex justify-end gap-2 mb-4",children:[r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>g(),title:"刷新",children:r.jsx(Fe,{className:"w-4 h-4"})}),r.jsxs(X,{onClick:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加关联小程序"]})]}),n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"名称"}),r.jsx(we,{className:"text-gray-400",children:"密钥"}),r.jsx(we,{className:"text-gray-400",children:"AppID"}),r.jsx(we,{className:"text-gray-400",children:"路径"}),r.jsx(we,{className:"text-gray-400 w-24",children:"排序"}),r.jsx(we,{className:"text-gray-400 w-32",children:"操作"})]})}),r.jsxs(as,{children:[t.map(k=>r.jsxs(it,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-white",children:k.name}),r.jsx(ve,{className:"text-gray-300 font-mono text-xs",children:k.key}),r.jsx(ve,{className:"text-gray-300 font-mono text-sm",children:k.appId}),r.jsx(ve,{className:"text-gray-400 text-sm",children:k.path||"—"}),r.jsx(ve,{className:"text-gray-300",children:k.sort??0}),r.jsx(ve,{children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/20",onClick:()=>N(k),children:r.jsx(Yg,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:bg-red-500/20",onClick:()=>v(k),children:r.jsx(Zn,{className:"w-4 h-4"})})]})})]},k.key)),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无关联小程序,点击「添加关联小程序」开始配置"})})]})]})]})]}),r.jsx(It,{open:a,onOpenChange:i,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[r.jsxs(Rt,{className:"gap-1",children:[r.jsx(Pt,{className:"text-base",children:o?"编辑关联小程序":"添加关联小程序"}),r.jsx(Cd,{className:"text-gray-400 text-xs",children:"填写目标小程序的名称和 AppID,路径可选(为空则打开首页)"})]}),r.jsxs("div",{className:"space-y-3 py-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"小程序名称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:Soul 创业派对",value:u.name,onChange:k=>h(C=>({...C,name:k.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"AppID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono h-8 text-sm",placeholder:"例如:wxb8bbb2b10dec74aa",value:u.appId,onChange:k=>h(C=>({...C,appId:k.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"路径(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:pages/index/index",value:u.path,onChange:k=>h(C=>({...C,path:k.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"排序"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm w-20",value:u.sort,onChange:k=>h(C=>({...C,sort:parseInt(k.target.value,10)||0}))})]})]}),r.jsxs(sn,{className:"gap-2 pt-1",children:[r.jsx(X,{variant:"outline",onClick:()=>i(!1),className:"border-gray-600",children:"取消"}),r.jsx(X,{onClick:j,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:f?"保存中...":"保存"})]})]})})]})}const aV=["一","二","三","四","五","六","七","八","九","十"];function iV(t){return t.title==="序言"||t.title.includes("序言")}function Mw(t){const e=[];for(const n of t.chapters)for(const s of n.sections)e.push(s.id);return e.length===0?"暂无章节":e.length===1?e[0]:`${e[0]}~${e[e.length-1]}`}function _g(t){return t.startsWith("part:")?{type:"part",id:t.slice(5)}:t.startsWith("chapter:")?{type:"chapter",id:t.slice(8)}:t.startsWith("section:")?{type:"section",id:t.slice(8)}:null}function oV({parts:t,expandedParts:e,onTogglePart:n,onReorder:s,onReadSection:a,onDeleteSection:i,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:N,pinnedSectionIds:j=[]}){const[v,k]=b.useState(null),[C,E]=b.useState(null),M=(z,ce)=>(v==null?void 0:v.type)===z&&(v==null?void 0:v.id)===ce,P=(z,ce)=>(C==null?void 0:C.type)===z&&(C==null?void 0:C.id)===ce,H=b.useCallback(()=>{const z=[];for(const ce of t)for(const me of ce.chapters)for(const _ of me.sections)z.push({id:_.id,partId:ce.id,partTitle:ce.title,chapterId:me.id,chapterTitle:me.title});return z},[t]),L=b.useCallback(async(z,ce,me,_)=>{var U;z.preventDefault(),z.stopPropagation();const G=z.dataTransfer.getData("text/plain"),$=_g(G);if(!$||$.type===ce&&$.id===me)return;const A=H(),Y=new Map(A.map(D=>[D.id,D]));if($.type==="part"&&ce==="part"){const D=t.map(ne=>ne.id),W=D.indexOf($.id),le=D.indexOf(me);if(W===-1||le===-1)return;const ye=[...D];ye.splice(W,1),ye.splice(WJ.id===ne);if(K)for(const J of K.chapters)for(const ge of J.sections){const ae=Y.get(ge.id);ae&&Ae.push(ae)}}await s(Ae);return}if($.type==="chapter"&&(ce==="chapter"||ce==="section"||ce==="part")){const D=t.find(ae=>ae.chapters.some(pe=>pe.id===$.id)),W=D==null?void 0:D.chapters.find(ae=>ae.id===$.id);if(!D||!W)return;let le,ye,Ae=null;if(ce==="section"){const ae=Y.get(me);if(!ae)return;le=ae.partId,ye=ae.partTitle,Ae=me}else if(ce==="chapter"){const ae=t.find(tt=>tt.chapters.some(at=>at.id===me)),pe=ae==null?void 0:ae.chapters.find(tt=>tt.id===me);if(!ae||!pe)return;le=ae.id,ye=ae.title;const Se=A.filter(tt=>tt.chapterId===me).pop();Ae=(Se==null?void 0:Se.id)??null}else{const ae=t.find(Se=>Se.id===me);if(!ae||!ae.chapters[0])return;le=ae.id,ye=ae.title;const pe=A.filter(Se=>Se.partId===ae.id&&Se.chapterId===ae.chapters[0].id);Ae=((U=pe[pe.length-1])==null?void 0:U.id)??null}const ne=W.sections.map(ae=>ae.id),K=A.filter(ae=>!ne.includes(ae.id));let J=K.length;if(Ae){const ae=K.findIndex(pe=>pe.id===Ae);ae>=0&&(J=ae+1)}const ge=ne.map(ae=>({...Y.get(ae),partId:le,partTitle:ye,chapterId:W.id,chapterTitle:W.title}));await s([...K.slice(0,J),...ge,...K.slice(J)]);return}if($.type==="section"&&(ce==="section"||ce==="chapter"||ce==="part")){if(!_)return;const{partId:D,partTitle:W,chapterId:le,chapterTitle:ye}=_;let Ae;if(ce==="section")Ae=A.findIndex(pe=>pe.id===me);else if(ce==="chapter"){const pe=A.filter(Se=>Se.chapterId===me).pop();Ae=pe?A.findIndex(Se=>Se.id===pe.id)+1:A.length}else{const pe=t.find(at=>at.id===me);if(!(pe!=null&&pe.chapters[0]))return;const Se=A.filter(at=>at.partId===pe.id&&at.chapterId===pe.chapters[0].id),tt=Se[Se.length-1];Ae=tt?A.findIndex(at=>at.id===tt.id)+1:0}const ne=A.findIndex(pe=>pe.id===$.id);if(ne===-1)return;const K=A.filter(pe=>pe.id!==$.id),J=ne({onDragEnter:_=>{_.preventDefault(),_.stopPropagation(),_.dataTransfer.dropEffect="move",E({type:z,id:ce})},onDragOver:_=>{_.preventDefault(),_.stopPropagation(),_.dataTransfer.dropEffect="move",E({type:z,id:ce})},onDragLeave:()=>E(null),onDrop:_=>{E(null);const G=_g(_.dataTransfer.getData("text/plain"));if(G&&!(z==="section"&&G.type==="section"&&G.id===ce))if(z==="part")if(G.type==="part")L(_,"part",ce);else{const $=t.find(Y=>Y.id===ce);($==null?void 0:$.chapters[0])&&me&&L(_,"part",ce,me)}else z==="chapter"&&me?(G.type==="section"||G.type==="chapter")&&L(_,"chapter",ce,me):z==="section"&&me&&L(_,"section",ce,me)}}),O=z=>aV[z]??String(z+1),se=z=>t.slice(0,z).filter(ce=>!iV(ce)).length,ie=z=>r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-gray-500 font-mono text-xs tabular-nums shrink-0 mr-1.5 max-w-[72px] truncate",title:`章节ID: ${z.id}`,children:z.id}),r.jsx("span",{className:"truncate",children:z.title})]});return r.jsx("div",{className:"space-y-3",children:t.map((z,ce)=>{var W,le,ye,Ae;const me=z.title==="序言"||z.title.includes("序言"),_=z.title==="尾声"||z.title.includes("尾声"),G=z.title==="附录"||z.title.includes("附录"),$=P("part",z.id),A=e.includes(z.id),Y=z.chapters.length,U=z.chapters.reduce((ne,K)=>ne+K.sections.length,0);if(me&&z.chapters.length===1&&z.chapters[0].sections.length===1){const ne=z.chapters[0].sections[0],K=P("section",ne.id),J={partId:z.id,partTitle:z.title,chapterId:z.chapters[0].id,chapterTitle:z.chapters[0].title};return r.jsxs("div",{draggable:!0,onDragStart:ge=>{ge.stopPropagation(),ge.dataTransfer.setData("text/plain","section:"+ne.id),ge.dataTransfer.effectAllowed="move",k({type:"section",id:ne.id})},onDragEnd:()=>{k(null),E(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${K?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",ne.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",ne.id,J),children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ge=>ge.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(ne.id),onChange:()=>y(ne.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:r.jsx(Ys,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[z.chapters[0].title," | ",ne.title]}),j.includes(ne.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>ge.stopPropagation(),children:[ne.price===0||ne.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",ne.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",ne.clickCount??0," · 付款 ",ne.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ne.hotScore??0).toFixed(1)," · 第",ne.hotRank&&ne.hotRank>0?ne.hotRank:"-","名"]}),N&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(ne),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(ne),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(ne),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]})]},z.id)}if(z.id==="part-2026-daily"){const ne=P("part",z.id);return r.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${ne?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...R("part",z.id,{partId:z.id,partTitle:z.title,chapterId:((W=z.chapters[0])==null?void 0:W.id)??"",chapterTitle:((le=z.chapters[0])==null?void 0:le.title)??""}),children:[r.jsxs("div",{draggable:!0,onDragStart:K=>{K.stopPropagation(),K.dataTransfer.setData("text/plain","part:"+z.id),K.dataTransfer.effectAllowed="move",k({type:"part",id:z.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,onClick:()=>n(z.id),children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),r.jsxs("div",{children:[r.jsx("h3",{className:"font-bold text-white text-base",children:z.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Mw(z)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:K=>K.stopPropagation(),onClick:K=>K.stopPropagation(),children:[o&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),h&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),f&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(z),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})}),r.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[Y," 章 · ",U," 节"]}),A?r.jsx(kd,{className:"w-5 h-5 text-gray-500"}):r.jsx(Dl,{className:"w-5 h-5 text-gray-500"})]})]}),A&&z.chapters.length>0&&r.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:z.chapters.map(K=>r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:K.title}),r.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:J=>J.stopPropagation(),children:[m&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(z,K),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),c&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),u&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(z,K),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]}),r.jsx("div",{className:"space-y-1 pl-2",children:K.sections.map(J=>{const ge=P("section",J.id);return r.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+J.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:J.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${ge?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",J.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",J.id,{partId:z.id,partTitle:z.title,chapterId:K.id,chapterTitle:K.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(J.id),onChange:()=>y(J.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ie(J)}),j.includes(J.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",J.clickCount??0," · 付款 ",J.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(J.hotScore??0).toFixed(1)," · 第",J.hotRank&&J.hotRank>0?J.hotRank:"-","名"]}),N&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(J),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(J),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(J),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]},J.id)})})]},K.id))})]},z.id)}if(G)return r.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),r.jsx("div",{className:"space-y-3",children:z.chapters.map((ne,K)=>ne.sections.length>0?ne.sections.map(J=>{const ge=P("section",J.id);return r.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+J.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:J.id})},onDragEnd:()=>{k(null),E(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 group cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${ge?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",J.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",J.id,{partId:z.id,partTitle:z.title,chapterId:ne.id,chapterTitle:ne.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(J.id),onChange:()=>y(J.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",K+1," | ",ne.title," | ",J.title]}),j.includes(J.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",J.clickCount??0," · 付款 ",J.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(J.hotScore??0).toFixed(1)," · 第",J.hotRank&&J.hotRank>0?J.hotRank:"-","名"]}),N&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(J),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>a(J),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>i(J),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]}),r.jsx(Dl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},J.id)}):r.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[r.jsxs("span",{className:"text-sm text-gray-500",children:["附录",K+1," | ",ne.title,"(空)"]}),r.jsx(Dl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},ne.id))})]},z.id);if(_&&z.chapters.length===1&&z.chapters[0].sections.length===1){const ne=z.chapters[0].sections[0],K=P("section",ne.id),J={partId:z.id,partTitle:z.title,chapterId:z.chapters[0].id,chapterTitle:z.chapters[0].title};return r.jsxs("div",{draggable:!0,onDragStart:ge=>{ge.stopPropagation(),ge.dataTransfer.setData("text/plain","section:"+ne.id),ge.dataTransfer.effectAllowed="move",k({type:"section",id:ne.id})},onDragEnd:()=>{k(null),E(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${K?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",ne.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",ne.id,J),children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ge=>ge.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(ne.id),onChange:()=>y(ne.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:r.jsx(Ys,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[z.chapters[0].title," | ",ne.title]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>ge.stopPropagation(),children:[ne.price===0||ne.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",ne.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",ne.clickCount??0," · 付款 ",ne.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(ne.hotScore??0).toFixed(1)," · 第",ne.hotRank&&ne.hotRank>0?ne.hotRank:"-","名"]}),N&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(ne),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(ne),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(ne),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]})]},z.id)}return _?r.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),r.jsx("div",{className:"space-y-3",children:z.chapters.map(ne=>ne.sections.map(K=>{const J=P("section",K.id);return r.jsxs("div",{draggable:!0,onDragStart:ge=>{ge.stopPropagation(),ge.dataTransfer.setData("text/plain","section:"+K.id),ge.dataTransfer.effectAllowed="move",k({type:"section",id:K.id})},onDragEnd:()=>{k(null),E(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${J?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",K.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",K.id,{partId:z.id,partTitle:z.title,chapterId:ne.id,chapterTitle:ne.title}),children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ge=>ge.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(K.id),onChange:()=>y(K.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsxs("span",{className:"text-sm text-gray-300",children:[ne.title," | ",K.title]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",K.clickCount??0," · 付款 ",K.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(K.hotScore??0).toFixed(1)," · 第",K.hotRank&&K.hotRank>0?K.hotRank:"-","名"]}),N&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(K),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(K),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(K),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]})]},K.id)}))})]},z.id):r.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${$?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...R("part",z.id,{partId:z.id,partTitle:z.title,chapterId:((ye=z.chapters[0])==null?void 0:ye.id)??"",chapterTitle:((Ae=z.chapters[0])==null?void 0:Ae.title)??""}),children:[r.jsxs("div",{draggable:!0,onDragStart:ne=>{ne.stopPropagation(),ne.dataTransfer.setData("text/plain","part:"+z.id),ne.dataTransfer.effectAllowed="move",k({type:"part",id:z.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,onClick:()=>n(z.id),children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(Aa,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac] flex items-center justify-center text-white font-bold shadow-lg shadow-[#38bdac]/30 shrink-0",children:O(se(ce))}),r.jsxs("div",{children:[r.jsx("h3",{className:"font-bold text-white text-base",children:z.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Mw(z)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>ne.stopPropagation(),children:[o&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),h&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),f&&r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(z),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})}),r.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[Y," 章 · ",U," 节"]}),A?r.jsx(kd,{className:"w-5 h-5 text-gray-500"}):r.jsx(Dl,{className:"w-5 h-5 text-gray-500"})]})]}),A&&r.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:z.chapters.map(ne=>{const K=P("chapter",ne.id);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsxs("div",{draggable:!0,onDragStart:J=>{J.stopPropagation(),J.dataTransfer.setData("text/plain","chapter:"+ne.id),J.dataTransfer.effectAllowed="move",k({type:"chapter",id:ne.id})},onDragEnd:()=>{k(null),E(null)},onDragEnter:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",E({type:"chapter",id:ne.id})},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",E({type:"chapter",id:ne.id})},onDragLeave:()=>E(null),onDrop:J=>{E(null);const ge=_g(J.dataTransfer.getData("text/plain"));if(!ge)return;const ae={partId:z.id,partTitle:z.title,chapterId:ne.id,chapterTitle:ne.title};(ge.type==="section"||ge.type==="chapter")&&L(J,"chapter",ne.id,ae)},className:`flex-1 min-w-0 py-2 px-2 rounded cursor-grab active:cursor-grabbing select-none -mx-2 transition-all duration-200 flex items-center gap-2 ${K?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${M("chapter",ne.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),r.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:ne.title})]}),r.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:J=>J.stopPropagation(),children:[m&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>m(z,ne),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),c&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>c(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:r.jsx(fn,{className:"w-3.5 h-3.5"})}),u&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(z,ne),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]}),r.jsx("div",{className:"space-y-1 pl-2",children:ne.sections.map(J=>{const ge=P("section",J.id);return r.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+J.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:J.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between py-2 px-3 rounded-lg group cursor-grab active:cursor-grabbing select-none min-h-[40px] transition-all duration-200 ${ge?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",J.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...R("section",J.id,{partId:z.id,partTitle:z.title,chapterId:ne.id,chapterTitle:ne.title}),children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&r.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:g.includes(J.id),onChange:()=>y(J.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),r.jsx(Aa,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),r.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${J.price===0||J.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),r.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ie(J)}),j.includes(J.id)&&r.jsx("span",{title:"已置顶",children:r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ae=>ae.stopPropagation(),onClick:ae=>ae.stopPropagation(),children:[J.isNew&&r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),J.price===0||J.isFree?r.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):r.jsxs("span",{className:"text-xs text-gray-500",children:["¥",J.price]}),r.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",J.clickCount??0," · 付款 ",J.payCount??0]}),r.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(J.hotScore??0).toFixed(1)," · 第",J.hotRank&&J.hotRank>0?J.hotRank:"-","名"]}),N&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(J),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),r.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(J),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:r.jsx(Ut,{className:"w-3.5 h-3.5"})}),r.jsx(X,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(J),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:r.jsx(Zn,{className:"w-3.5 h-3.5"})})]})]})]},J.id)})})]},ne.id)})})]},z.id)})})}function lV(t){var a;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(a=t==null?void 0:t.keyword)!=null&&a.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString(),s=n?`/api/admin/ckb/devices?${n}`:"/api/admin/ckb/devices";return De(s)}function cV(t){return De(`/api/db/person?personId=${encodeURIComponent(t)}`)}function dV(t){var s;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(s=t==null?void 0:t.keyword)!=null&&s.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString();return De(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const J4=11,Aw={personId:"",name:"",aliases:"",label:"",sceneId:J4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"09:00",endTime:"18:00",deviceGroups:""};function uV({open:t,onOpenChange:e,editingPerson:n,onSubmit:s}){var G;const a=!!n,[i,o]=b.useState(Aw),[c,u]=b.useState(!1),[h,f]=b.useState(!1),[m,g]=b.useState([]),[y,N]=b.useState(!1),[j,v]=b.useState(""),[k,C]=b.useState([]),[E,M]=b.useState(!1),[P,H]=b.useState(""),[L,R]=b.useState(!1),[O,se]=b.useState({});b.useEffect(()=>{t&&(v(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",aliases:n.aliases??"",label:n.label??"",sceneId:J4,ckbApiKey:n.ckbApiKey??"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:n.remarkType??"phone",remarkFormat:n.remarkFormat??"",addFriendInterval:n.addFriendInterval??1,startTime:n.startTime??"09:00",endTime:n.endTime??"18:00",deviceGroups:n.deviceGroups??""}:{...Aw}),se({}),m.length===0&&ie(""),k.length===0&&z(""))},[t,n]);const ie=async $=>{N(!0);try{const A=await lV({page:1,limit:50,keyword:$});A!=null&&A.success&&Array.isArray(A.devices)?g(A.devices):A!=null&&A.error&&te.error(A.error)}catch(A){te.error(A instanceof Error?A.message:"加载设备列表失败")}finally{N(!1)}},z=async $=>{M(!0);try{const A=await dV({page:1,limit:100,keyword:$});A!=null&&A.success&&Array.isArray(A.plans)?C(A.plans):A!=null&&A.error&&te.error(A.error)}catch{te.error("加载计划列表失败")}finally{M(!1)}},ce=$=>{const A=Array.isArray($.deviceGroups)?$.deviceGroups.map(String).join(","):"";o(Y=>({...Y,ckbApiKey:$.apiKey||"",greeting:$.greeting||Y.greeting,tips:$.tips||Y.tips,remarkType:$.remarkType||Y.remarkType,remarkFormat:$.remarkFormat||Y.remarkFormat,addFriendInterval:$.addInterval||Y.addFriendInterval,startTime:$.startTime||Y.startTime,endTime:$.endTime||Y.endTime,deviceGroups:A||Y.deviceGroups})),R(!1),te.success(`已选择计划「${$.name}」,参数已覆盖`)},me=P.trim()?k.filter($=>($.name||"").includes(P.trim())||String($.id).includes(P.trim())):k,_=async()=>{var U;const $={};(!i.name||!String(i.name).trim())&&($.name="请填写名称");const A=i.addFriendInterval;if((typeof A!="number"||A<1)&&($.addFriendInterval="添加间隔至少为 1 分钟"),(((U=i.deviceGroups)==null?void 0:U.split(",").map(D=>D.trim()).filter(Boolean))??[]).length===0&&($.deviceGroups="请至少选择 1 台设备"),se($),Object.keys($).length>0){te.error($.name||$.addFriendInterval||$.deviceGroups||"请完善必填项");return}u(!0);try{await s(i),e(!1)}catch(D){te.error(D instanceof Error?D.message:"保存失败")}finally{u(!1)}};return r.jsx(It,{open:t,onOpenChange:e,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsxs(Rt,{children:[r.jsx(Pt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),r.jsx(Cd,{className:"text-gray-400 text-sm",children:a?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),r.jsxs("div",{className:"space-y-6 py-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Z,{className:"text-gray-400 text-xs",children:["名称 ",r.jsx("span",{className:"text-red-400",children:"*"})]}),r.jsx(re,{className:`bg-[#0a1628] text-white ${O.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:i.name,onChange:$=>{o(A=>({...A,name:$.target.value})),O.name&&se(A=>({...A,name:void 0}))}}),O.name&&r.jsx("p",{className:"text-xs text-red-400",children:O.name})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:i.personId,onChange:$=>o(A=>({...A,personId:$.target.value})),disabled:a})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:i.label,onChange:$=>o(A=>({...A,label:$.target.value}))})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 卡卡, 若若",value:i.aliases,onChange:$=>o(A=>({...A,aliases:$.target.value}))})]})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[r.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),r.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5 relative",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"选择存客宝获客计划"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("div",{className:"flex-1 flex items-center bg-[#0a1628] border border-gray-700 rounded-md px-3 py-2 cursor-pointer hover:border-[#38bdac]/60 text-sm",onClick:()=>R(!L),children:i.ckbApiKey?r.jsx("span",{className:"text-white truncate",children:((G=k.find($=>$.apiKey===i.ckbApiKey))==null?void 0:G.name)||`密钥: ${i.ckbApiKey.slice(0,20)}...`}):r.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),r.jsx(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{z(P),R(!0)},disabled:E,children:E?"加载...":"刷新"})]}),L&&r.jsxs("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-[#0b1828] border border-gray-700 rounded-lg shadow-xl max-h-64 flex flex-col",children:[r.jsx("div",{className:"p-2 border-b border-gray-700/60",children:r.jsx(re,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:P,onChange:$=>H($.target.value),onKeyDown:$=>{$.key==="Enter"&&z(P)},autoFocus:!0})}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:me.length===0?r.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:E?"加载中...":"暂无计划"}):me.map($=>r.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${i.ckbApiKey===$.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>ce($),children:[r.jsxs("div",{className:"truncate",children:[r.jsx("span",{className:"font-medium",children:$.name}),r.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String($.id)]})]}),$.enabled?r.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 rounded shrink-0 ml-2",children:"启用"}):r.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 rounded shrink-0 ml-2",children:"停用"})]},String($.id)))}),r.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:r.jsx(X,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>R(!1),children:"关闭"})})]}),r.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Z,{className:"text-gray-400 text-xs",children:["选择设备 ",r.jsx("span",{className:"text-red-400",children:"*"})]}),r.jsxs("div",{className:`flex gap-2 rounded-md border ${O.deviceGroups?"border-red-500":"border-gray-700"}`,children:[r.jsx(re,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:i.deviceGroups?`已选择 ${i.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>f(!0)}),r.jsx(X,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),O.deviceGroups?r.jsx("p",{className:"text-xs text-red-400",children:O.deviceGroups}):r.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"好友备注"}),r.jsxs(Pl,{value:i.remarkType,onValueChange:$=>o(A=>({...A,remarkType:$})),children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{placeholder:"选择备注类型"})}),r.jsxs(ko,{children:[r.jsx(Ks,{value:"phone",children:"手机号"}),r.jsx(Ks,{value:"nickname",children:"昵称"}),r.jsx(Ks,{value:"source",children:"来源"})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"备注格式"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 手机号+SOUL链接人与事-{名称},留空用默认",value:i.remarkFormat,onChange:$=>o(A=>({...A,remarkFormat:$.target.value}))})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"打招呼语"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:i.greeting,onChange:$=>o(A=>({...A,greeting:$.target.value}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),r.jsx(re,{type:"number",min:1,className:`bg-[#0a1628] text-white ${O.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:i.addFriendInterval,onChange:$=>{o(A=>({...A,addFriendInterval:Number($.target.value)||1})),O.addFriendInterval&&se(A=>({...A,addFriendInterval:void 0}))}}),O.addFriendInterval&&r.jsx("p",{className:"text-xs text-red-400",children:O.addFriendInterval})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(re,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.startTime,onChange:$=>o(A=>({...A,startTime:$.target.value}))}),r.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),r.jsx(re,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.endTime,onChange:$=>o(A=>({...A,endTime:$.target.value}))})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"获客成功提示"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:i.tips,onChange:$=>o(A=>({...A,tips:$.target.value}))})]})]})]})]})]}),r.jsxs(sn,{className:"gap-3 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),r.jsx(X,{onClick:_,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":a?"保存":"添加"})]}),h&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:r.jsxs("div",{className:"w-full max-w-3xl max-h-[80vh] bg-[#0b1828] border border-gray-700 rounded-xl shadow-xl flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),r.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(re,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:j,onChange:$=>v($.target.value),onKeyDown:$=>{$.key==="Enter"&&ie(j)}}),r.jsx(X,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>ie(j),disabled:y,children:"刷新"}),r.jsx(X,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:y?r.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?r.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):r.jsx("div",{className:"p-4 space-y-2",children:m.map($=>{const A=String($.id??""),Y=i.deviceGroups?i.deviceGroups.split(",").map(W=>W.trim()).filter(Boolean):[],U=Y.includes(A),D=()=>{let W;U?W=Y.filter(le=>le!==A):W=[...Y,A],o(le=>({...le,deviceGroups:W.join(",")})),W.length>0&&se(le=>({...le,deviceGroups:void 0}))};return r.jsxs("label",{className:"flex items-center gap-3 rounded-lg border border-gray-700/60 bg-[#050c18] px-3 py-2 cursor-pointer hover:border-[#38bdac]/70",children:[r.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-[#38bdac]",checked:U,onChange:D}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-white truncate max-w-xs",children:$.memo||$.wechatId||`设备 ${A}`}),$.status==="online"&&r.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),$.status==="offline"&&r.jsx("span",{className:"rounded-full bg-gray-600/20 text-gray-400 text-[11px] px-2 py-0.5",children:"离线"})]}),r.jsxs("div",{className:"text-[11px] text-gray-400 mt-0.5",children:[r.jsxs("span",{className:"mr-3",children:["ID: ",A]}),$.wechatId&&r.jsxs("span",{className:"mr-3",children:["微信号: ",$.wechatId]}),typeof $.totalFriend=="number"&&r.jsxs("span",{children:["好友数: ",$.totalFriend]})]})]})]},A)})})}),r.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[r.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",i.deviceGroups?i.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),r.jsx(X,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function hV(t,e){const n=new Map;for(const i of t){const o=i.partId||"part-1",c=i.partTitle||"未分类",u=i.chapterId||"chapter-1",h=i.chapterTitle||"未分类";n.has(o)||n.set(o,{id:o,title:c,chapters:new Map});const f=n.get(o);f.chapters.has(u)||f.chapters.set(u,{id:u,title:h,sections:[]}),f.chapters.get(u).sections.push({id:i.id,mid:i.mid,title:i.title,price:i.price??1,filePath:i.filePath,isFree:i.isFree,isNew:i.isNew,clickCount:i.clickCount??0,payCount:i.payCount??0,hotScore:i.hotScore??0,hotRank:e.get(i.id)??0})}const s=Array.from(n.values()).map(i=>({...i,chapters:Array.from(i.chapters.values())})),a=i=>i.title.includes("序言")?0:i.id==="part-2026-daily"?1.5:i.title.includes("附录")?2:i.title.includes("尾声")?3:1;return s.sort((i,o)=>{const c=a(i),u=a(o);return c!==u?c-u:0})}function fV(){var jc,ds,Na;const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState([]),[o,c]=b.useState(null),[u,h]=b.useState(!1),[f,m]=b.useState(!1),[g,y]=b.useState(!1),[N,j]=b.useState(""),[v,k]=b.useState([]),[C,E]=b.useState(!1),[M,P]=b.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[H,L]=b.useState(null),[R,O]=b.useState(!1),[se,ie]=b.useState(!1),[z,ce]=b.useState(null),[me,_]=b.useState(!1),[G,$]=b.useState([]),[A,Y]=b.useState(!1),[U,D]=b.useState(""),[W,le]=b.useState(""),[ye,Ae]=b.useState(!1),[ne,K]=b.useState(""),[J,ge]=b.useState(!1),[ae,pe]=b.useState(null),[Se,tt]=b.useState(!1),[at,Dt]=b.useState(!1),[kt,At]=b.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[Gt,In]=b.useState(!1),[Lt,xn]=b.useState(!1),[ln,Bs]=b.useState(1),[yn,is]=b.useState([]),[Un,Kn]=b.useState(!1),[_t,qn]=b.useState([]),[zn,ls]=b.useState(!1),[q,He]=b.useState(20),[mt,$t]=b.useState(!1),[ut,ot]=b.useState(!1),[xt,tn]=b.useState([]),[he,xe]=b.useState([]),[zt,Rn]=b.useState([]),[da,ua]=b.useState(!1),[_r,Zs]=b.useState(1),[ha,Xo]=b.useState(20),[fa,Zi]=b.useState(0),[pa,dc]=b.useState(1),[mr,ma]=b.useState(""),[Vs,gr]=b.useState(!1),[eo,Zo]=b.useState(null),[yt,kn]=b.useState({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),[zr,xr]=b.useState(!1),[to,yr]=b.useState(!1),[ga,Fr]=b.useState(null),[er,Ja]=b.useState(null),[uc,Jt]=b.useState({}),[hc,br]=b.useState(!1),[vr,$r]=b.useState(""),[Ya,no]=b.useState(""),[Br,Ns]=b.useState([]),[Qa,ws]=b.useState(0),[Vr,fc]=b.useState(1),[pc,xa]=b.useState(!1),ya=b.useRef(null),Hr=b.useMemo(()=>{const T=new Map;return yn.forEach((B,de)=>{T.set(B.id,de+1)}),T},[yn]),bn=hV(t,Hr),so=t.length,ba=10,Wr=Math.max(1,Math.ceil(yn.length/ba)),F=yn.slice((ln-1)*ba,ln*ba),Pe=async()=>{s(!0);try{const T=await De("/api/db/book?action=list",{cache:"no-store"});e(Array.isArray(T==null?void 0:T.sections)?T.sections:[])}catch(T){console.error(T),e([])}finally{s(!1)}},_e=async()=>{Kn(!0);try{const T=await De("/api/db/book?action=ranking",{cache:"no-store"}),B=Array.isArray(T==null?void 0:T.sections)?T.sections:[];is(B);const de=B.filter(be=>be.isPinned).map(be=>be.id);qn(de)}catch(T){console.error(T),is([])}finally{Kn(!1)}};b.useEffect(()=>{Pe(),_e()},[]);const lt=T=>{i(B=>B.includes(T)?B.filter(de=>de!==T):[...B,T])},cn=b.useCallback(T=>{const B=t,de=T.flatMap(be=>{const qe=B.find(st=>st.id===be.id);return qe?[{...qe,partId:be.partId,partTitle:be.partTitle,chapterId:be.chapterId,chapterTitle:be.chapterTitle}]:[]});return e(de),Ot("/api/db/book",{action:"reorder",items:T}).then(be=>{be&&be.success===!1&&(e(B),te.error("排序失败: "+(be&&typeof be=="object"&&"error"in be?be.error:"未知错误")))}).catch(be=>{e(B),console.error("排序失败:",be),te.error("排序失败: "+(be instanceof Error?be.message:"网络或服务异常"))}),Promise.resolve()},[t]),ct=async T=>{if(confirm(`确定要删除章节「${T.title}」吗?此操作不可恢复。`))try{const B=await ea(`/api/db/book?id=${encodeURIComponent(T.id)}`);B&&B.success!==!1?(te.success("已删除"),Pe(),_e()):te.error("删除失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(B){console.error(B),te.error("删除失败")}},Xa=b.useCallback(async()=>{In(!0);try{const T=await De("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),B=T&&T.data;B&&typeof B.readWeight=="number"&&typeof B.recencyWeight=="number"&&typeof B.payWeight=="number"&&At({readWeight:Math.max(0,Math.min(1,B.readWeight)),recencyWeight:Math.max(0,Math.min(1,B.recencyWeight)),payWeight:Math.max(0,Math.min(1,B.payWeight))})}catch{}finally{In(!1)}},[]);b.useEffect(()=>{at&&Xa()},[at,Xa]);const dn=async()=>{const{readWeight:T,recencyWeight:B,payWeight:de}=kt,be=T+B+de;if(Math.abs(be-1)>.001){te.error("三个权重之和必须等于 1");return}xn(!0);try{const qe=await Nt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:T,recencyWeight:B,payWeight:de},description:"文章排名算法权重"});qe&&qe.success!==!1?(te.success("排名权重已保存"),Dt(!1),Pe(),_e()):te.error("保存失败: "+(qe&&typeof qe=="object"&&"error"in qe?qe.error:""))}catch(qe){console.error(qe),te.error("保存失败")}finally{xn(!1)}},Gn=b.useCallback(async()=>{ls(!0);try{const T=await De("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),B=T&&T.data;Array.isArray(B)&&qn(B)}catch{}finally{ls(!1)}},[]),Ms=b.useCallback(async()=>{try{const T=await De("/api/db/persons");T!=null&&T.success&&T.persons&&tn(T.persons.map(B=>{const de=B.deviceGroups,be=Array.isArray(de)?de.join(","):de??"";return{id:B.token??B.personId??"",personId:B.personId,name:B.name,aliases:B.aliases??"",label:B.label??"",ckbApiKey:B.ckbApiKey??"",ckbPlanId:B.ckbPlanId,remarkType:B.remarkType,remarkFormat:B.remarkFormat,addFriendInterval:B.addFriendInterval,startTime:B.startTime,endTime:B.endTime,deviceGroups:be}}))}catch{}},[]),As=b.useCallback(async()=>{try{const T=await De("/api/db/link-tags");T!=null&&T.success&&T.linkTags&&xe(T.linkTags.map(B=>({id:B.tagId,label:B.label,url:B.url,type:B.type||"url",appId:B.appId||"",pagePath:B.pagePath||""})))}catch{}},[]),Nr=b.useCallback(async()=>{try{const T=await De("/api/db/ckb-person-leads");if(T!=null&&T.success&&T.byPerson){const B={};for(const de of T.byPerson)B[de.token]=de.total;Jt(B)}}catch{}},[]),va=b.useCallback(async(T,B,de=1)=>{$r(T),no(B),br(!0),fc(de),xa(!0);try{const be=await De(`/api/db/ckb-person-leads?token=${encodeURIComponent(T)}&page=${de}&pageSize=20`);be!=null&&be.success?(Ns(be.records||[]),ws(be.total||0)):te.error((be==null?void 0:be.error)||"加载获客详情失败")}catch(be){te.error(be instanceof Error?be.message:"加载获客详情失败")}finally{xa(!1)}},[]),tr=b.useCallback(async()=>{ua(!0);try{const T=new URLSearchParams({page:String(_r),pageSize:String(ha)}),B=mr.trim();B&&T.set("search",B);const de=await De(`/api/db/link-tags?${T.toString()}`);if(de!=null&&de.success){const be=Array.isArray(de.linkTags)?de.linkTags:[];Rn(be.map(qe=>({id:qe.tagId,label:qe.label,url:qe.url,type:qe.type||"url",appId:qe.appId||"",pagePath:qe.pagePath||""}))),Zi(typeof de.total=="number"?de.total:0),dc(typeof de.totalPages=="number"&&de.totalPages>0?de.totalPages:1)}}catch(T){console.error(T),te.error("加载链接标签失败")}finally{ua(!1)}},[_r,ha,mr]),[cs,Ur]=b.useState([]),[Is,wr]=b.useState(""),[Za,js]=b.useState(!1),hp=b.useRef(null),mc=b.useCallback(async()=>{try{const T=await De("/api/admin/linked-miniprograms");T!=null&&T.success&&Array.isArray(T.data)&&Ur(T.data.map(B=>({...B,key:B.key})))}catch{}},[]),ei=cs.filter(T=>!Is.trim()||T.name.toLowerCase().includes(Is.toLowerCase())||T.key&&T.key.toLowerCase().includes(Is.toLowerCase())||T.appId.toLowerCase().includes(Is.toLowerCase())),Yd=async T=>{const B=_t.includes(T)?_t.filter(de=>de!==T):[..._t,T];qn(B);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:B,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),_e()}catch{qn(_t)}},gc=b.useCallback(async()=>{$t(!0);try{const T=await De("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),B=T&&T.data;typeof B=="number"&&B>0&&B<=100&&He(B)}catch{}finally{$t(!1)}},[]),el=async()=>{if(q<1||q>100){te.error("预览比例需在 1~100 之间");return}ot(!0);try{const T=await Nt("/api/db/config",{key:"unpaid_preview_percent",value:q,description:"小程序未付费内容默认预览比例(%)"});T&&T.success!==!1?te.success("预览比例已保存"):te.error("保存失败: "+(T.error||""))}catch{te.error("保存失败")}finally{ot(!1)}};b.useEffect(()=>{Gn(),gc(),Ms(),As(),Nr(),mc()},[Gn,gc,Ms,As,Nr,mc]),b.useEffect(()=>{tr()},[tr]);const xc=async T=>{pe({section:T,orders:[]}),tt(!0);try{const B=await De(`/api/db/book?action=section-orders&id=${encodeURIComponent(T.id)}`),de=B!=null&&B.success&&Array.isArray(B.orders)?B.orders:[];pe(be=>be?{...be,orders:de}:null)}catch(B){console.error(B),pe(de=>de?{...de,orders:[]}:null)}finally{tt(!1)}},yc=async T=>{m(!0);try{const B=T.mid!=null&&T.mid>0?`/api/db/book?action=read&mid=${T.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(T.id)}`,de=await De(B);if(de!=null&&de.success&&de.section){const be=de.section,qe=be.editionPremium===!0;c({id:T.id,originalId:T.id,title:de.section.title??T.title,price:de.section.price??T.price,content:de.section.content??"",filePath:T.filePath,isFree:T.isFree||T.price===0,isNew:be.isNew??T.isNew,isPinned:_t.includes(T.id),hotScore:T.hotScore??0,editionStandard:qe?!1:be.editionStandard??!0,editionPremium:qe})}else c({id:T.id,originalId:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree,isNew:T.isNew,isPinned:_t.includes(T.id),hotScore:T.hotScore??0,editionStandard:!0,editionPremium:!1}),de&&!de.success&&te.error("无法读取文件内容: "+(de.error||"未知错误"))}catch(B){console.error(B),c({id:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree})}finally{m(!1)}},ro=async()=>{var T;if(o){y(!0);try{let B=o.content||"";const de=[new RegExp(`^#+\\s*${o.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${o.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(T=o.title)==null?void 0:T.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const Jn of de)B=B.replace(Jn,"");B=B.replace(/^\s*\n+/,"").trim();const be=o.originalId||o.id,qe=o.id!==be,st=await Ot("/api/db/book",{id:be,...qe?{newId:o.id}:{},title:o.title,price:o.isFree?0:o.price,content:B,isFree:o.isFree||o.price===0,isNew:o.isNew,hotScore:o.hotScore,editionStandard:o.editionPremium?!1:o.editionStandard??!0,editionPremium:o.editionPremium??!1,saveToFile:!0},{timeout:Zv}),bt=qe?o.id:be;o.isPinned!==_t.includes(bt)&&await Yd(bt),st&&st.success!==!1?(te.success(`已保存:${o.title}`),c(null),Pe(),Ms(),As()):te.error("保存失败: "+(st&&typeof st=="object"&&"error"in st?st.error:"未知错误"))}catch(B){console.error(B);const de=B instanceof Error&&B.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";te.error(de)}finally{y(!1)}}},ao=async()=>{if(!M.id||!M.title){te.error("请填写章节ID和标题");return}y(!0);try{const T=bn.find(be=>be.id===M.partId),B=T==null?void 0:T.chapters.find(be=>be.id===M.chapterId),de=await Ot("/api/db/book",{id:M.id,title:M.title,price:M.isFree?0:M.price,content:M.content||"",partId:M.partId,partTitle:(T==null?void 0:T.title)??"",chapterId:M.chapterId,chapterTitle:(B==null?void 0:B.title)??"",isFree:M.isFree,isNew:M.isNew,editionStandard:M.editionPremium?!1:M.editionStandard??!0,editionPremium:M.editionPremium??!1,hotScore:M.hotScore??0,saveToFile:!1},{timeout:Zv});if(de&&de.success!==!1){if(M.isPinned){const be=[..._t,M.id];qn(be);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:be,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}te.success(`章节创建成功:${M.title}`),h(!1),P({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),Pe(),Ms(),As()}else te.error("创建失败: "+(de&&typeof de=="object"&&"error"in de?de.error:"未知错误"))}catch(T){console.error(T),te.error("创建失败")}finally{y(!1)}},ti=T=>{P(B=>{var de;return{...B,partId:T.id,chapterId:((de=T.chapters[0])==null?void 0:de.id)??"chapter-1"}}),h(!0)},tl=T=>{L({id:T.id,title:T.title})},fp=async()=>{var T;if((T=H==null?void 0:H.title)!=null&&T.trim()){O(!0);try{const B=t.map(be=>({id:be.id,partId:be.partId||"part-1",partTitle:be.partId===H.id?H.title.trim():be.partTitle||"",chapterId:be.chapterId||"chapter-1",chapterTitle:be.chapterTitle||""})),de=await Ot("/api/db/book",{action:"reorder",items:B});if(de&&de.success!==!1){const be=H.title.trim();e(qe=>qe.map(st=>st.partId===H.id?{...st,partTitle:be}:st)),L(null),Pe()}else te.error("更新篇名失败: "+(de&&typeof de=="object"&&"error"in de?de.error:"未知错误"))}catch(B){console.error(B),te.error("更新篇名失败")}finally{O(!1)}}},pp=T=>{const B=T.chapters.length+1,de=`chapter-${T.id}-${B}-${Date.now()}`;P({id:`${B}.1`,title:"新章节",price:1,partId:T.id,chapterId:de,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),h(!0)},bc=(T,B)=>{const de=B.sections;let be=1,qe=!1,st=!1;if(de.length>0){const bt=typeof de[0].price=="number"?de[0].price:Number(de[0].price)||1,Jn=!!(de[0].isFree||bt===0);st=de.some(qr=>{const vn=typeof qr.price=="number"?qr.price:Number(qr.price)||1,nr=!!(qr.isFree||vn===0);return vn!==bt||nr!==Jn}),be=Jn?0:bt,qe=Jn}ce({part:T,chapter:B,title:B.title,price:be,isFree:qe,priceMixed:st,initialTitle:B.title,initialPrice:be,initialIsFree:qe})},nl=async()=>{var qe;if(!((qe=z==null?void 0:z.title)!=null&&qe.trim()))return;const T=z,B=T.title.trim(),de=B!==T.initialTitle,be=T.isFree!==T.initialIsFree||!T.isFree&&Number(T.price)!==Number(T.initialPrice);if(!de&&!be){te.info("未修改任何内容"),ce(null);return}if(T.priceMixed&&be){const st=T.chapter.sections.length,bt=T.isFree?"全部设为免费":`全部设为 ¥${T.price}`;if(!confirm(`本章 ${st} 节当前定价不一致,保存后将${bt},确定?`))return}_(!0);try{if(de){const st=t.map(vn=>({id:vn.id,partId:vn.partId||T.part.id,partTitle:vn.partId===T.part.id?T.part.title:vn.partTitle||"",chapterId:vn.chapterId||T.chapter.id,chapterTitle:vn.partId===T.part.id&&vn.chapterId===T.chapter.id?B:vn.chapterTitle||""})),bt=await Ot("/api/db/book",{action:"reorder",items:st});if(bt&&bt.success===!1){te.error("保存章节名失败: "+(bt&&typeof bt=="object"&&"error"in bt?bt.error:"未知错误"));return}const Jn=T.part.id,qr=T.chapter.id;e(vn=>vn.map(nr=>nr.partId===Jn&&nr.chapterId===qr?{...nr,chapterTitle:B}:nr))}if(be){const st=await Ot("/api/db/book",{action:"update-chapter-pricing",partId:T.part.id,chapterId:T.chapter.id,price:T.isFree?0:Number(T.price)||0,isFree:T.isFree});if(st&&st.success===!1){te.error("保存定价失败: "+(st&&typeof st=="object"&&"error"in st?st.error:"未知错误")),de&&Pe();return}}ce(null),Pe(),te.success("已保存")}catch(st){console.error(st),te.error("保存失败")}finally{_(!1)}},vc=async(T,B)=>{const de=B.sections.map(be=>be.id);if(de.length===0){te.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${T.chapters.indexOf(B)+1}章 | ${B.title}」吗?将删除共 ${de.length} 节,此操作不可恢复。`))try{for(const be of de)await ea(`/api/db/book?id=${encodeURIComponent(be)}`);Pe()}catch(be){console.error(be),te.error("删除失败")}},Qd=async()=>{if(!ne.trim()){te.error("请输入篇名");return}ge(!0);try{const T=`part-new-${Date.now()}`,B="chapter-1",de=`part-placeholder-${Date.now()}`,be=await Ot("/api/db/book",{id:de,title:"占位节(可编辑)",price:0,content:"",partId:T,partTitle:ne.trim(),chapterId:B,chapterTitle:"第1章 | 待编辑",saveToFile:!1});be&&be.success!==!1?(te.success(`篇「${ne}」创建成功`),ie(!1),K(""),Pe()):te.error("创建失败: "+(be&&typeof be=="object"&&"error"in be?be.error:"未知错误"))}catch(T){console.error(T),te.error("创建失败")}finally{ge(!1)}},Kr=async()=>{if(G.length===0){te.error("请先勾选要移动的章节");return}const T=bn.find(de=>de.id===U),B=T==null?void 0:T.chapters.find(de=>de.id===W);if(!T||!B||!U||!W){te.error("请选择目标篇和章");return}Ae(!0);try{const de=()=>{const bt=new Set(G),Jn=t.map(Sn=>({id:Sn.id,partId:Sn.partId||"",partTitle:Sn.partTitle||"",chapterId:Sn.chapterId||"",chapterTitle:Sn.chapterTitle||""})),qr=Jn.filter(Sn=>bt.has(Sn.id)).map(Sn=>({...Sn,partId:U,partTitle:T.title||U,chapterId:W,chapterTitle:B.title||W})),vn=Jn.filter(Sn=>!bt.has(Sn.id));let nr=vn.length;for(let Sn=vn.length-1;Sn>=0;Sn-=1){const Xd=vn[Sn];if(Xd.partId===U&&Xd.chapterId===W){nr=Sn+1;break}}return[...vn.slice(0,nr),...qr,...vn.slice(nr)]},be=async()=>{const bt=de(),Jn=await Ot("/api/db/book",{action:"reorder",items:bt});return Jn&&Jn.success!==!1?(te.success(`已移动 ${G.length} 节到「${T.title}」-「${B.title}」`),Y(!1),$([]),await Pe(),!0):!1},qe={action:"move-sections",sectionIds:G,targetPartId:U,targetChapterId:W,targetPartTitle:T.title||U,targetChapterTitle:B.title||W},st=await Ot("/api/db/book",qe);if(st&&st.success!==!1)te.success(`已移动 ${st.count??G.length} 节到「${T.title}」-「${B.title}」`),Y(!1),$([]),await Pe();else{const bt=st&&typeof st=="object"&&"error"in st?st.error||"":"未知错误";if((bt.includes("缺少 id")||bt.includes("无效的 action"))&&await be())return;te.error("移动失败: "+bt)}}catch(de){console.error(de),te.error("移动失败: "+(de instanceof Error?de.message:"网络或服务异常"))}finally{Ae(!1)}},Nc=T=>{$(B=>B.includes(T)?B.filter(de=>de!==T):[...B,T])},sl=async T=>{const B=t.filter(de=>de.partId===T.id).map(de=>de.id);if(B.length===0){te.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${T.title}」整篇吗?将删除共 ${B.length} 节内容,此操作不可恢复。`))try{for(const de of B)await ea(`/api/db/book?id=${encodeURIComponent(de)}`);Pe()}catch(de){console.error(de),te.error("删除失败")}},wc=async()=>{var T;if(N.trim()){E(!0);try{const B=await De(`/api/search?q=${encodeURIComponent(N)}`);B!=null&&B.success&&((T=B.data)!=null&&T.results)?k(B.data.results):(k([]),B&&!B.success&&te.error("搜索失败: "+B.error))}catch(B){console.error(B),k([]),te.error("搜索失败")}finally{E(!1)}}},ni=bn.find(T=>T.id===M.partId),io=(ni==null?void 0:ni.chapters)??[];return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",bn.length," 篇 · ",so," 节内容"]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{onClick:()=>Dt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[r.jsx(qu,{className:"w-4 h-4 mr-2"}),"排名算法"]}),r.jsxs(X,{onClick:()=>{const T=typeof window<"u"?`${window.location.origin}/api-doc`:"";T&&window.open(T,"_blank","noopener,noreferrer")},variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Rr,{className:"w-4 h-4 mr-2"}),"API 接口"]})]})]}),r.jsx(It,{open:u,onOpenChange:h,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[r.jsx(Rt,{className:"shrink-0 px-6 pt-6 pb-2",children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(fn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节ID *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:M.id,onChange:T=>P({...M,id:T.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:M.isFree?0:M.price,onChange:T=>P({...M,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:M.isFree})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"免费"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:M.isFree,onChange:T=>P({...M,isFree:T.target.checked,price:T.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最新新增"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:M.isNew,onChange:T=>P({...M,isNew:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:M.isPinned,onChange:T=>P({...M,isPinned:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"文章类型"}),r.jsxs("div",{className:"flex items-center gap-4 h-10",children:[r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium!==!0,onChange:()=>P({...M,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium===!0,onChange:()=>P({...M,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"热度分"}),r.jsx(re,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:M.hotScore??0,onChange:T=>P({...M,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节标题 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:M.title,onChange:T=>P({...M,title:T.target.value})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"所属篇"}),r.jsxs(Pl,{value:M.partId,onValueChange:T=>{var de;const B=bn.find(be=>be.id===T);P({...M,partId:T,chapterId:((de=B==null?void 0:B.chapters[0])==null?void 0:de.id)??"chapter-1"})},children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{})}),r.jsxs(ko,{className:"bg-[#0f2137] border-gray-700",children:[bn.map(T=>r.jsx(Ks,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),bn.length===0&&r.jsx(Ks,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"所属章"}),r.jsxs(Pl,{value:M.chapterId,onValueChange:T=>P({...M,chapterId:T}),children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{})}),r.jsxs(ko,{className:"bg-[#0f2137] border-gray-700",children:[io.map(T=>r.jsx(Ks,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),io.length===0&&r.jsx(Ks,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),r.jsx(Hx,{content:M.content||"",onChange:T=>P({...M,content:T}),onImageUpload:async T=>{var qe;const B=new FormData;B.append("file",T),B.append("folder","book-images");const be=await(await fetch(Lo("/api/upload"),{method:"POST",body:B,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((qe=be==null?void 0:be.data)==null?void 0:qe.url)||(be==null?void 0:be.url)||""},persons:xt,linkTags:he,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),r.jsxs(sn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[r.jsx(X,{variant:"outline",onClick:()=>h(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:ao,disabled:g||!M.id||!M.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),r.jsx(It,{open:!!H,onOpenChange:T=>!T&&L(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),H&&r.jsx("div",{className:"space-y-4 py-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"篇名"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:H.title,onChange:T=>L({...H,title:T.target.value}),placeholder:"输入篇名"})]})}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",onClick:()=>L(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:fp,disabled:R||!((jc=H==null?void 0:H.title)!=null&&jc.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:R?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),r.jsx(It,{open:!!z,onOpenChange:T=>!T&&ce(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsxs(Rt,{children:[r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),r.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),z&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:z.title,onChange:T=>ce({...z,title:T.target.value}),placeholder:"输入章节名称"})]}),r.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[r.jsxs(Z,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",z.chapter.sections.length," 节)"]}),z.priceMixed&&r.jsx("p",{className:"text-amber-400/90 text-xs",children:"当前各节定价不一致,保存后将按下方设置全部统一。"}),r.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[r.jsxs("div",{className:"space-y-1 flex-1 min-w-[120px]",children:[r.jsx("span",{className:"text-gray-500 text-xs",children:"价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:z.isFree?0:z.price,onChange:T=>ce({...z,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:z.isFree,min:0,step:.01})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pb-2",children:[r.jsx("input",{type:"checkbox",checked:z.isFree||z.price===0,onChange:T=>ce({...z,isFree:T.target.checked,price:T.target.checked?0:z.initialPrice>0?z.initialPrice:1}),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac]"}),r.jsx("span",{className:"text-gray-400 text-sm",children:"本章全部免费"})]})]})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",onClick:()=>ce(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:nl,disabled:me||!((ds=z==null?void 0:z.title)!=null&&ds.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),r.jsx(It,{open:A,onOpenChange:T=>{var B;if(Y(T),T&&bn.length>0){const de=bn[0];D(de.id),le(((B=de.chapters[0])==null?void 0:B.id)??"")}},children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:"批量移动至指定目录"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",r.jsx("span",{className:"text-[#38bdac] font-medium",children:G.length})," 节,请选择目标篇与章。"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"目标篇"}),r.jsxs(Pl,{value:U,onValueChange:T=>{var de;D(T);const B=bn.find(be=>be.id===T);le(((de=B==null?void 0:B.chapters[0])==null?void 0:de.id)??"")},children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{placeholder:"选择篇"})}),r.jsx(ko,{className:"bg-[#0f2137] border-gray-700",children:bn.map(T=>r.jsx(Ks,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"目标章"}),r.jsxs(Pl,{value:W,onValueChange:le,children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white",children:r.jsx(Ol,{placeholder:"选择章"})}),r.jsx(ko,{className:"bg-[#0f2137] border-gray-700",children:(((Na=bn.find(T=>T.id===U))==null?void 0:Na.chapters)??[]).map(T=>r.jsx(Ks,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:Kr,disabled:ye||G.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:ye?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),r.jsx(It,{open:!!ae,onOpenChange:T=>!T&&pe(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white",children:["付款记录 — ",(ae==null?void 0:ae.section.title)??""]})}),r.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:Se?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ae&&ae.orders.length===0?r.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):ae?r.jsxs("table",{className:"w-full text-sm border-collapse",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[r.jsx("th",{className:"py-2 pr-2",children:"订单号"}),r.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),r.jsx("th",{className:"py-2 pr-2",children:"金额"}),r.jsx("th",{className:"py-2 pr-2",children:"状态"}),r.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),r.jsx("tbody",{children:ae.orders.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/50",children:[r.jsx("td",{className:"py-2 pr-2",children:r.jsx("button",{className:"text-blue-400 hover:text-blue-300 hover:underline text-left truncate max-w-[180px] block",title:`查看订单 ${T.orderSn}`,onClick:()=>window.open(`/orders?search=${T.orderSn??T.id??""}`,"_blank"),children:T.orderSn?T.orderSn.length>16?T.orderSn.slice(0,8)+"..."+T.orderSn.slice(-6):T.orderSn:"-"})}),r.jsx("td",{className:"py-2 pr-2",children:r.jsx("button",{className:"text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[140px] block",title:`查看用户 ${T.userId??T.openId??""}`,onClick:()=>window.open(`/users?search=${T.userId??T.openId??""}`,"_blank"),children:(()=>{const B=T.userId??T.openId??"-";return B.length>12?B.slice(0,6)+"..."+B.slice(-4):B})()})}),r.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",T.amount??0]}),r.jsx("td",{className:"py-2 pr-2 text-gray-300",children:T.status??"-"}),r.jsx("td",{className:"py-2 pr-2 text-gray-500",children:T.payTime??T.createdAt??"-"})]},T.id??T.orderSn??""))})]}):null})]})}),r.jsx(It,{open:at,onOpenChange:Dt,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(qu,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsx("p",{className:"text-sm text-gray-400",children:"热度积分 = 阅读权重×阅读排名分 + 新度权重×新度排名分 + 付款权重×付款排名分(三权重之和须为 1)"}),Gt?r.jsx("p",{className:"text-gray-500",children:"加载中..."}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"阅读权重"}),r.jsx(re,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:kt.readWeight,onChange:T=>At(B=>({...B,readWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"新度权重"}),r.jsx(re,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:kt.recencyWeight,onChange:T=>At(B=>({...B,recencyWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"付款权重"}),r.jsx(re,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:kt.payWeight,onChange:T=>At(B=>({...B,payWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(kt.readWeight+kt.recencyWeight+kt.payWeight).toFixed(1)]}),r.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[r.jsx("li",{children:"阅读量前 20 名:第1名=20分、第2名=19分...第20名=1分"}),r.jsx("li",{children:"最近更新前 30 篇:第1名=30分、第2名=29分...第30名=1分"}),r.jsx("li",{children:"付款数前 20 名:第1名=20分、第2名=19分...第20名=1分"}),r.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),r.jsx(X,{onClick:dn,disabled:Lt||Math.abs(kt.readWeight+kt.recencyWeight+kt.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Lt?"保存中...":"保存权重"})]})]})]})}),r.jsx(It,{open:se,onOpenChange:ie,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(fn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),r.jsx("div",{className:"space-y-4 py-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:ne,onChange:T=>K(T.target.value),placeholder:"输入篇名"})]})}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",onClick:()=>{ie(!1),K("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsx(X,{onClick:Qd,disabled:J||!ne.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:J?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),r.jsx(It,{open:!!o,onOpenChange:()=>c(null),children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[r.jsx(Rt,{className:"shrink-0 px-6 pt-6 pb-2",children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),o&&r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.id,onChange:T=>c({...o,id:T.target.value}),placeholder:"如: 9.15"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.isFree?0:o.price,onChange:T=>c({...o,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:o.isFree})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"免费"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.isFree||o.price===0,onChange:T=>c({...o,isFree:T.target.checked,price:T.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最新新增"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.isNew??!1,onChange:T=>c({...o,isNew:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),r.jsx("div",{className:"flex items-center h-10",children:r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.isPinned??!1,onChange:T=>c({...o,isPinned:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"文章类型"}),r.jsxs("div",{className:"flex items-center gap-4 h-10",children:[r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium!==!0,onChange:()=>c({...o,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),r.jsxs("label",{className:"flex items-center cursor-pointer",children:[r.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium===!0,onChange:()=>c({...o,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),r.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"热度分"}),r.jsx(re,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:o.hotScore??0,onChange:T=>c({...o,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"章节标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.title,onChange:T=>c({...o,title:T.target.value})})]}),o.filePath&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"文件路径"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:o.filePath,disabled:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),f?r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsx(Hx,{ref:ya,content:o.content||"",onChange:T=>c({...o,content:T}),onImageUpload:async T=>{var qe;const B=new FormData;B.append("file",T),B.append("folder","book-images");const be=await(await fetch(Lo("/api/upload"),{method:"POST",body:B,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((qe=be==null?void 0:be.data)==null?void 0:qe.url)||(be==null?void 0:be.url)||""},persons:xt,linkTags:he,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),r.jsxs(sn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[o&&r.jsxs(X,{variant:"outline",onClick:()=>xc({id:o.id,title:o.title,price:o.price}),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent mr-auto",children:[r.jsx(Ys,{className:"w-4 h-4 mr-2"}),"付款记录"]}),r.jsxs(X,{variant:"outline",onClick:()=>c(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsx(X,{onClick:ro,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):r.jsxs(r.Fragment,{children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),r.jsxs(Wd,{defaultValue:"chapters",className:"space-y-6",children:[r.jsxs(sc,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[r.jsxs(Zt,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(Ys,{className:"w-4 h-4 mr-2"}),"章节管理"]}),r.jsxs(Zt,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[r.jsx(Xg,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),r.jsxs(Zt,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(Ba,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),r.jsxs(Zt,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[r.jsx(Rr,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),r.jsxs(Zt,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[r.jsx(Qv,{className:"w-4 h-4 mr-2"}),"链接标签"]}),r.jsxs(Zt,{value:"linkedmp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[r.jsx(zi,{className:"w-4 h-4 mr-2"}),"关联小程序"]})]}),r.jsxs(en,{value:"chapters",className:"space-y-4",children:[r.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac] flex items-center justify-center text-white shadow-lg shadow-[#38bdac]/20 shrink-0",children:r.jsx(Ys,{className:"w-6 h-6"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),r.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),r.jsxs("div",{className:"text-center shrink-0",children:[r.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:so}),r.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(X,{onClick:()=>h(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),r.jsxs(X,{onClick:()=>ie(!0),className:"flex-1 min-w-[120px] bg-amber-500/10 hover:bg-amber-500/20 text-amber-400 border border-amber-500/30",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),r.jsxs(X,{variant:"outline",onClick:()=>Y(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",G.length," 节)"]})]}),n?r.jsxs("div",{className:"flex items-center justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsx(oV,{parts:bn,expandedParts:a,onTogglePart:lt,onReorder:cn,onReadSection:yc,onDeleteSection:ct,onAddSectionInPart:ti,onAddChapterInPart:pp,onDeleteChapter:vc,onEditPart:tl,onDeletePart:sl,onEditChapter:bc,selectedSectionIds:G,onToggleSectionSelect:Nc,onShowSectionOrders:xc,pinnedSectionIds:_t})]}),r.jsx(en,{value:"search",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"内容搜索"})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:N,onChange:T=>j(T.target.value),onKeyDown:T=>T.key==="Enter"&&wc()}),r.jsx(X,{onClick:wc,disabled:C||!N.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?r.jsx(Fe,{className:"w-4 h-4 animate-spin"}):r.jsx(Ba,{className:"w-4 h-4"})})]}),v.length>0&&r.jsxs("div",{className:"space-y-2 mt-4",children:[r.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",v.length," 个结果"]}),v.map(T=>r.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>yc({id:T.id,mid:T.mid,title:T.title,price:T.price??1,filePath:""}),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:T.id}),r.jsx("span",{className:"text-white",children:T.title}),_t.includes(T.id)&&r.jsx(_l,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),r.jsx(Ke,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:T.matchType==="title"?"标题匹配":"内容匹配"})]}),T.snippet&&r.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:T.snippet}),(T.partTitle||T.chapterTitle)&&r.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[T.partTitle," · ",T.chapterTitle]})]},T.id))]})]})]})}),r.jsxs(en,{value:"ranking",className:"space-y-4",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(qu,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Z,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),r.jsx(re,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:q,onChange:T=>He(Math.max(1,Math.min(100,Number(T.target.value)||20))),disabled:mt}),r.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),r.jsx(X,{size:"sm",onClick:el,disabled:ut,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:ut?"保存中...":"保存"}),r.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",q,"% 内容"]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(Xg,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",r.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",yn.length," 节"]})]}),r.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>_e(),disabled:Un,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:r.jsx(Fe,{className:`w-4 h-4 ${Un?"animate-spin":""}`})}),r.jsx(X,{variant:"ghost",size:"sm",disabled:ln<=1||Un,onClick:()=>Bs(T=>Math.max(1,T-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:r.jsx(YT,{className:"w-4 h-4"})}),r.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[ln," / ",Wr]}),r.jsx(X,{variant:"ghost",size:"sm",disabled:ln>=Wr||Un,onClick:()=>Bs(T=>Math.min(Wr,T+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:r.jsx(Dl,{className:"w-4 h-4"})})]})]})}),r.jsx(Te,{children:r.jsxs("div",{className:"space-y-0",children:[r.jsxs("div",{className:"grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2 text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("span",{children:"排名"}),r.jsx("span",{children:"置顶"}),r.jsx("span",{children:"标题"}),r.jsx("span",{className:"text-right",children:"点击量"}),r.jsx("span",{className:"text-right",children:"付款数"}),r.jsx("span",{className:"text-right",children:"热度"}),r.jsx("span",{className:"text-right",children:"编辑"})]}),F.map((T,B)=>{const de=(ln-1)*ba+B+1,be=T.isPinned??_t.includes(T.id);return r.jsxs("div",{className:`grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2.5 items-center border-b border-gray-700/30 hover:bg-[#162840] transition-colors ${be?"bg-amber-500/5":""}`,children:[r.jsx("span",{className:`text-sm font-bold ${de<=3?"text-amber-400":"text-gray-500"}`,children:de<=3?["🥇","🥈","🥉"][de-1]:`#${de}`}),r.jsx(X,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${be?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>Yd(T.id),disabled:zn,title:be?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:be?r.jsx(_l,{className:"w-3.5 h-3.5 fill-current"}):r.jsx(y5,{className:"w-3.5 h-3.5"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-white text-sm truncate block",children:T.title}),r.jsxs("span",{className:"text-gray-600 text-xs",children:[T.partTitle," · ",T.chapterTitle]})]}),r.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:T.clickCount??0}),r.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:T.payCount??0}),r.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(T.hotScore??0).toFixed(1)}),r.jsx("div",{className:"text-right",children:r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>yc({id:T.id,mid:T.mid,title:T.title,price:T.price,filePath:""}),title:"编辑文章",children:r.jsx(Ut,{className:"w-3 h-3"})})})]},T.id)}),F.length===0&&r.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),r.jsxs(en,{value:"link-person",className:"space-y-4",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"pb-3",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — 链接人与事(编辑器内输入 @ 可链接)"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"添加时自动生成 32 位 token,文章 @ 时存 token;小程序点击 @ 时用 token 兑换真实密钥后加好友"})]}),r.jsxs(Te,{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx("p",{className:"text-xs text-gray-500",children:"添加人物时同步创建存客宝场景获客计划,配置与存客宝 API 获客一致"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>Ms(),title:"刷新",children:r.jsx(Fe,{className:"w-4 h-4"})}),r.jsxs(X,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Fr(null),yr(!0)},children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),r.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:xt.length>0?r.jsxs("table",{className:"w-full text-sm border-collapse",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("th",{className:"text-left py-1.5 px-3 w-[280px] font-normal",children:"token"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-24 font-normal",children:"@的人"}),r.jsx("th",{className:"py-1.5 px-3 w-16 font-normal text-center",children:"获客数"}),r.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"获客计划活动名"}),r.jsx("th",{className:"text-left py-1.5 px-3 w-20 font-normal",children:"planId"}),r.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"apiKey"}),r.jsx("th",{className:"text-left py-1.5 px-2 w-24 font-normal",children:"操作"})]})}),r.jsx("tbody",{children:xt.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono",title:"32位token",children:T.id}),r.jsx("td",{className:"py-2 px-3 text-amber-400 truncate max-w-[96px]",title:"@的人",children:T.name}),(()=>{const B=uc[T.id]||0;return r.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold ${B>0?"text-green-400":"text-gray-600"}`,title:"获客数",children:B})})(),r.jsxs("td",{className:"py-2 px-3 text-white truncate max-w-[200px]",title:"获客计划活动名",children:["SOUL链接人与事-",T.name]}),r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono",title:"存客宝计划ID",children:T.ckbPlanId??"-"}),r.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono whitespace-nowrap",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[T.ckbApiKey?r.jsx(X,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-gray-500 hover:text-[#38bdac] shrink-0",title:"复制 apiKey",onClick:async()=>{await navigator.clipboard.writeText(T.ckbApiKey??""),te.success("已复制到剪贴板")},children:r.jsx(s0,{className:"w-3.5 h-3.5"})}):null,r.jsx("span",{title:T.ckbApiKey??"",children:T.ckbApiKey??"-"})]})}),r.jsx("td",{className:"py-2 px-2",children:r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const B=await cV(T.personId||"");if(B!=null&&B.success&&B.person){const de=B.person;Fr({id:de.token??de.personId,personId:de.personId,name:de.name,label:de.label??"",ckbApiKey:de.ckbApiKey??"",remarkType:de.remarkType,remarkFormat:de.remarkFormat,addFriendInterval:de.addFriendInterval,startTime:de.startTime,endTime:de.endTime,deviceGroups:de.deviceGroups})}else Fr(T),B!=null&&B.error&&te.error(B.error)}catch(B){console.error(B),Fr(T),te.error(B instanceof Error?B.message:"加载人物详情失败")}yr(!0)},children:r.jsx(Yg,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>va(T.id,T.name),children:r.jsx(_n,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-amber-400 h-6 px-2",title:"编辑计划(跳转存客宝)",onClick:()=>{const B=T.ckbPlanId;B?window.open(`https://h5.ckb.quwanzhi.com/#/scenarios/edit/${B}`,"_blank"):te.info("该人物尚未同步存客宝计划,请先保存后等待同步完成")},children:r.jsx(ra,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:"删除(同时删除存客宝对应获客计划)",onClick:()=>Ja(T),children:r.jsx(gs,{className:"w-3 h-3"})})]})})]},T.id))})]}):r.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"pb-3",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(qu,{className:"w-4 h-4 text-green-400"}),"存客宝绑定"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),r.jsxs(Te,{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"绑定计划"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),r.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",r.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]})]}),r.jsxs(en,{value:"link-tag",className:"space-y-4",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"pb-3",children:[r.jsxs(Ye,{className:"text-white text-base flex items-center gap-2",children:[r.jsx(Qv,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),r.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),r.jsxs(Te,{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-end justify-between gap-3 flex-wrap",children:[r.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-400 text-xs",children:"搜索"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:mr,onChange:T=>{ma(T.target.value),Zs(1)}})]}),r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{As(),tr()},title:"刷新",children:r.jsx(Fe,{className:"w-4 h-4"})})]}),r.jsxs(X,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{Zo(null),kn({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),wr(""),js(!1),gr(!0)},children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加标签"]})]}),r.jsxs("div",{className:"rounded-md border border-gray-700/50 overflow-hidden",children:[r.jsx("div",{className:"max-h-[420px] overflow-y-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-[#0a1628] border-b border-gray-700/50",children:r.jsxs("tr",{children:[r.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-40",children:"标签"}),r.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-20",children:"类型"}),r.jsx("th",{className:"text-left px-3 py-2 text-gray-400",children:"目标"}),r.jsx("th",{className:"text-right px-3 py-2 text-gray-400 w-28",children:"操作"})]})}),r.jsx("tbody",{children:da?r.jsx("tr",{children:r.jsx("td",{colSpan:4,className:"text-center py-10 text-gray-500",children:"加载中..."})}):zt.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:4,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):zt.map(T=>r.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-white/5",children:[r.jsxs("td",{className:"px-3 py-2",children:[r.jsxs("div",{className:"text-amber-400 font-semibold",children:["#",T.label]}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:["tagId: ",T.id]})]}),r.jsx("td",{className:"px-3 py-2",children:r.jsx(Ke,{variant:"secondary",className:`text-[10px] ${T.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":T.type==="miniprogram"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:T.type==="url"?"网页":T.type==="ckb"?"存客宝":"小程序"})}),r.jsx("td",{className:"px-3 py-2 text-gray-300",children:T.type==="miniprogram"?r.jsxs("span",{className:"text-xs font-mono",children:[T.appId||"—"," ",T.pagePath?`· ${T.pagePath}`:""]}):T.url?r.jsxs("a",{href:T.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[T.url," ",r.jsx(ra,{className:"w-3 h-3 shrink-0"})]}):r.jsx("span",{className:"text-gray-500 text-xs",children:"—"})}),r.jsx("td",{className:"px-3 py-2",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{Zo(T),kn({tagId:T.id,label:T.label,url:T.url,type:T.type,appId:T.appId??"",pagePath:T.pagePath??""}),wr(T.appId??""),js(!1),gr(!0)},title:"编辑",children:r.jsx(Yg,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${T.label}」吗?`))try{const B=await ea(`/api/db/link-tags?tagId=${encodeURIComponent(T.id)}`);B!=null&&B.success?(te.success("已删除"),As(),tr()):te.error((B==null?void 0:B.error)??"删除失败")}catch(B){console.error(B),te.error("删除失败")}},title:"删除",children:r.jsx(gs,{className:"w-3 h-3"})})]})})]},T.id))})]})}),r.jsx(Fs,{page:_r,pageSize:ha,total:fa,totalPages:pa,onPageChange:T=>Zs(T),onPageSizeChange:T=>{Xo(T),Zs(1)}})]})]})]}),r.jsx(It,{open:Vs,onOpenChange:gr,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[r.jsxs(Rt,{className:"gap-1",children:[r.jsx(Pt,{className:"text-base",children:eo?"编辑链接标签":"添加链接标签"}),r.jsx(Cd,{className:"text-gray-400 text-xs",children:"配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转"})]}),r.jsxs("div",{className:"space-y-3 py-2",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"标签ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或填 12位数字 / z开头12位",value:yt.tagId,disabled:!!eo,onChange:T=>kn(B=>({...B,tagId:T.target.value}))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"显示文字"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:yt.label,onChange:T=>kn(B=>({...B,label:T.target.value}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"类型"}),r.jsxs(Pl,{value:yt.type,onValueChange:T=>kn(B=>({...B,type:T})),children:[r.jsx(jo,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:r.jsx(Ol,{})}),r.jsxs(ko,{children:[r.jsx(Ks,{value:"url",children:"网页链接"}),r.jsx(Ks,{value:"miniprogram",children:"小程序"}),r.jsx(Ks,{value:"ckb",children:"存客宝"})]})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:yt.type==="url"?"URL地址":yt.type==="ckb"?"存客宝计划URL":"小程序(选密钥)"}),yt.type==="miniprogram"&&cs.length>0?r.jsxs("div",{ref:hp,className:"relative",children:[r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Za?Is:yt.appId,onChange:T=>{const B=T.target.value;wr(B),js(!0),cs.some(de=>de.key===B)||kn(de=>({...de,appId:B}))},onFocus:()=>{wr(yt.appId),js(!0)},onBlur:()=>setTimeout(()=>js(!1),150)}),Za&&r.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-gray-700 bg-[#0a1628] shadow-lg z-50",children:ei.length===0?r.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):ei.map(T=>r.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-[#38bdac]/20 flex flex-col gap-0.5",onMouseDown:B=>{B.preventDefault(),kn(de=>({...de,appId:T.key,pagePath:T.path||""})),wr(""),js(!1)},children:[r.jsx("span",{children:T.name}),r.jsx("span",{className:"text-xs text-gray-400 font-mono",children:T.key})]},T.key))})]}):r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:yt.type==="url"?"https://...":yt.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联小程序的32位密钥",value:yt.type==="url"||yt.type==="ckb"?yt.url:yt.appId,onChange:T=>{yt.type==="url"||yt.type==="ckb"?kn(B=>({...B,url:T.target.value})):kn(B=>({...B,appId:T.target.value}))}})]})]}),yt.type==="miniprogram"&&r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:yt.pagePath,onChange:T=>kn(B=>({...B,pagePath:T.target.value}))})]})]}),r.jsxs(sn,{className:"gap-2 pt-1",children:[r.jsx(X,{variant:"outline",onClick:()=>gr(!1),className:"border-gray-600",children:"取消"}),r.jsx(X,{onClick:async()=>{const T={tagId:yt.tagId.trim(),label:yt.label.trim(),url:yt.url.trim(),type:yt.type,appId:yt.appId.trim(),pagePath:yt.pagePath.trim()};if(T.tagId&&!(/^\d{12}$/.test(T.tagId)||/^z[a-z0-9]{11}$/.test(T.tagId))){te.error("标签ID需为12位数字,或 z 开头的12位(z+11位小写字母数字)");return}if(!T.label){te.error("显示文字必填");return}T.type==="miniprogram"&&(T.url=""),xr(!0);try{const B=await Nt("/api/db/link-tags",T);B!=null&&B.success?(te.success(eo?"已更新":"已添加"),gr(!1),As(),tr()):te.error((B==null?void 0:B.error)??"保存失败")}catch(B){console.error(B),te.error("保存失败")}finally{xr(!1)}},disabled:zr,className:"bg-amber-500 hover:bg-amber-600 text-white",children:zr?"保存中...":"保存"})]})]})})]}),r.jsx(en,{value:"linkedmp",className:"space-y-4",children:r.jsx(rV,{})})]}),r.jsx(uV,{open:to,onOpenChange:yr,editingPerson:ga,onSubmit:async T=>{var be;const B={personId:T.personId||T.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:T.name,aliases:T.aliases||void 0,label:T.label,ckbApiKey:T.ckbApiKey||void 0,greeting:T.greeting||void 0,tips:T.tips||void 0,remarkType:T.remarkType||void 0,remarkFormat:T.remarkFormat||void 0,addFriendInterval:T.addFriendInterval,startTime:T.startTime||void 0,endTime:T.endTime||void 0,deviceGroups:(be=T.deviceGroups)!=null&&be.trim()?T.deviceGroups.split(",").map(qe=>parseInt(qe.trim(),10)).filter(qe=>!Number.isNaN(qe)):void 0},de=await Nt("/api/db/persons",B);if(de&&de.success===!1){const qe=de;qe.ckbResponse&&console.log("存客宝返回",qe.ckbResponse);const st=qe.error||"操作失败";throw new Error(st)}if(Ms(),te.success(ga?"已保存":"已添加"),de!=null&&de.ckbCreateResult&&Object.keys(de.ckbCreateResult).length>0){const qe=de.ckbCreateResult;console.log("存客宝创建结果",qe);const st=qe.planId??qe.id,bt=st!=null?[`planId: ${st}`]:[];qe.apiKey!=null&&bt.push("apiKey: ***"),te.info(bt.length?`存客宝创建结果:${bt.join(",")}`:"存客宝创建结果见控制台")}}}),r.jsx(It,{open:!!er,onOpenChange:T=>{T||Ja(null)},children:r.jsxs(Ct,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[r.jsxs(Rt,{className:"gap-1",children:[r.jsx(Pt,{className:"text-white text-base",children:"确认删除"}),r.jsx(Cd,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:er&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:["确定删除「SOUL链接人与事-",er.name,"」?将同时删除存客宝对应获客计划。"]}),r.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",er.name," 将无法正常跳转。"]})]})})]}),r.jsxs(sn,{className:"gap-2 sm:gap-2 pt-1",children:[r.jsx(X,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>Ja(null),children:"取消"}),r.jsx(X,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{er&&(await ea(`/api/db/persons?personId=${er.personId}`),Ja(null),Ms(),te.success("已删除"))},children:"确定删除"})]})]})}),r.jsx(It,{open:hc,onOpenChange:br,children:r.jsxs(Ct,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-green-400"}),Ya," — 获客详情(共 ",Qa," 条)"]})}),r.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:pc?r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(Fe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Br.length===0?r.jsx("div",{className:"text-gray-500 text-sm py-8 text-center",children:"暂无获客记录"}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-[60px_1fr_100px_100px_80px_120px] gap-2 px-3 py-1.5 text-xs text-gray-500 border-b border-gray-700/50",children:[r.jsx("span",{children:"#"}),r.jsx("span",{children:"昵称/姓名"}),r.jsx("span",{children:"手机"}),r.jsx("span",{children:"微信"}),r.jsx("span",{children:"来源"}),r.jsx("span",{children:"时间"})]}),Br.map((T,B)=>r.jsxs("div",{className:"grid grid-cols-[60px_1fr_100px_100px_80px_120px] gap-2 px-3 py-2 bg-[#0a1628] rounded text-sm",children:[r.jsx("span",{className:"text-gray-500 text-xs",children:(Vr-1)*20+B+1}),r.jsx("span",{className:"text-white truncate",children:T.nickname||T.name||T.userId||"-"}),r.jsx("span",{className:"text-gray-300 text-xs",children:T.phone||"-"}),r.jsx("span",{className:"text-gray-300 text-xs truncate",children:T.wechatId||"-"}),r.jsx("span",{className:"text-gray-500 text-xs",children:T.source==="article_mention"?"文章@":T.source==="index_lead"?"首页":T.source||"-"}),r.jsx("span",{className:"text-gray-500 text-xs",children:T.createdAt?new Date(T.createdAt).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"})]},T.id))]})}),Qa>20&&r.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[r.jsx(X,{size:"sm",variant:"outline",disabled:Vr<=1,onClick:()=>va(vr,Ya,Vr-1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"上一页"}),r.jsxs("span",{className:"text-gray-400 text-xs",children:[Vr," / ",Math.ceil(Qa/20)]}),r.jsx(X,{size:"sm",variant:"outline",disabled:Vr>=Math.ceil(Qa/20),onClick:()=>va(vr,Ya,Vr+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const za={name:"卡若",avatar:"K",avatarImg:"",title:"Soul派对房主理人 · 私域运营专家",bio:'每天早上6点到9点,在Soul派对房分享真实的创业故事。专注私域运营与项目变现,用"云阿米巴"模式帮助创业者构建可持续的商业体系。',stats:[{label:"商业案例",value:"62"},{label:"连续直播",value:"365天"},{label:"派对分享",value:"1000+"}],highlights:["5年私域运营经验","帮助100+品牌从0到1增长","连续创业者,擅长商业模式设计"]};function Iw(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&"label"in e&&"value"in e?{label:String(e.label),value:String(e.value)}:{label:"",value:""}).filter(e=>e.label||e.value):za.stats}function Rw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):za.highlights}function pV(){const[t,e]=b.useState(za),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{De("/api/admin/author-settings").then(k=>{const C=k==null?void 0:k.data;C&&typeof C=="object"&&e({name:String(C.name??za.name),avatar:String(C.avatar??za.avatar),avatarImg:String(C.avatarImg??""),title:String(C.title??za.title),bio:String(C.bio??za.bio),stats:Iw(C.stats).length?Iw(C.stats):za.stats,highlights:Rw(C.highlights).length?Rw(C.highlights):za.highlights})}).catch(console.error).finally(()=>s(!1))},[]);const h=async()=>{i(!0);try{const k={name:t.name,avatar:t.avatar||"K",avatarImg:t.avatarImg,title:t.title,bio:t.bio,stats:t.stats.filter(M=>M.label||M.value),highlights:t.highlights.filter(Boolean)},C=await Nt("/api/admin/author-settings",k);if(!C||C.success===!1){te.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:""));return}i(!1);const E=document.createElement("div");E.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",E.textContent="作者设置已保存",document.body.appendChild(E),setTimeout(()=>E.remove(),2e3)}catch(k){console.error(k),te.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{i(!1)}},f=async k=>{var E;const C=(E=k.target.files)==null?void 0:E[0];if(C){c(!0);try{const M=new FormData;M.append("file",C),M.append("folder","avatars");const P=Df(),H={};P&&(H.Authorization=`Bearer ${P}`);const R=await(await fetch(Lo("/api/upload"),{method:"POST",body:M,credentials:"include",headers:H})).json();R!=null&&R.success&&(R!=null&&R.url)?e(O=>({...O,avatarImg:R.url})):te.error("上传失败: "+((R==null?void 0:R.error)||"未知错误"))}catch(M){console.error(M),te.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),g=k=>e(C=>({...C,stats:C.stats.filter((E,M)=>M!==k)})),y=(k,C,E)=>e(M=>({...M,stats:M.stats.map((P,H)=>H===k?{...P,[C]:E}:P)})),N=()=>e(k=>({...k,highlights:[...k.highlights,""]})),j=k=>e(C=>({...C,highlights:C.highlights.filter((E,M)=>M!==k)})),v=(k,C)=>e(E=>({...E,highlights:E.highlights.map((M,P)=>P===k?C:M)}));return n?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),r.jsxs(X,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"flex items-center gap-2 text-white",children:[r.jsx(Ao,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),r.jsx(Ft,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"姓名"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(C=>({...C,name:k.target.value})),placeholder:"卡若"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(C=>({...C,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(dj,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(C=>({...C,avatarImg:k.target.value})),placeholder:"上传或粘贴 URL,如 /uploads/avatars/xxx.png"}),r.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var k;return(k=u.current)==null?void 0:k.click()},children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&r.jsx("div",{className:"mt-2",children:r.jsx("img",{src:t.avatarImg.startsWith("http")?t.avatarImg:Lo(t.avatarImg),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"头衔"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(C=>({...C,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"个人简介"}),r.jsx(rc,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(C=>({...C,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsx(Ye,{className:"text-white",children:"统计数据"}),r.jsx(Ft,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),r.jsxs(Te,{className:"space-y-3",children:[t.stats.map((k,C)=>r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:E=>y(C,"label",E.target.value),placeholder:"标签"}),r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:E=>y(C,"value",E.target.value),placeholder:"数值"}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(C),children:r.jsx(gs,{className:"w-4 h-4"})})]},C)),r.jsxs(X,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsx(Ye,{className:"text-white",children:"亮点标签"}),r.jsx(Ft,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),r.jsxs(Te,{className:"space-y-3",children:[t.highlights.map((k,C)=>r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:E=>v(C,E.target.value),placeholder:"5年私域运营经验"}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>j(C),children:r.jsx(gs,{className:"w-4 h-4"})})]},C)),r.jsxs(X,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function mV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=b0(h,300),[g,y]=b.useState(!0),[N,j]=b.useState(null),[v,k]=b.useState(!1),[C,E]=b.useState(null),[M,P]=b.useState(""),[H,L]=b.useState(""),[R,O]=b.useState(""),[se,ie]=b.useState("admin"),[z,ce]=b.useState("active"),[me,_]=b.useState(!1);async function G(){var W;y(!0),j(null);try{const le=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&le.set("search",m.trim());const ye=await De(`/api/admin/users?${le}`);ye!=null&&ye.success?(e(ye.records||[]),s(ye.total??0),u(ye.totalPages??0)):j(ye.error||"加载失败")}catch(le){const ye=le;j(ye.status===403?"无权限访问":((W=ye==null?void 0:ye.data)==null?void 0:W.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{G()},[a,o,m]);const $=()=>{E(null),P(""),L(""),O(""),ie("admin"),ce("active"),k(!0)},A=W=>{E(W),P(W.username),L(""),O(W.name||""),ie(W.role==="super_admin"?"super_admin":"admin"),ce(W.status==="disabled"?"disabled":"active"),k(!0)},Y=async()=>{var W;if(!M.trim()){j("用户名不能为空");return}if(!C&&!H){j("新建时密码必填,至少 6 位");return}if(H&&H.length<6){j("密码至少 6 位");return}j(null),_(!0);try{if(C){const le=await Ot("/api/admin/users",{id:C.id,password:H||void 0,name:R.trim(),role:se,status:z});le!=null&&le.success?(k(!1),G()):j((le==null?void 0:le.error)||"保存失败")}else{const le=await Nt("/api/admin/users",{username:M.trim(),password:H,name:R.trim(),role:se});le!=null&&le.success?(k(!1),G()):j((le==null?void 0:le.error)||"保存失败")}}catch(le){const ye=le;j(((W=ye==null?void 0:ye.data)==null?void 0:W.error)||"保存失败")}finally{_(!1)}},U=async W=>{var le;if(confirm("确定删除该管理员?"))try{const ye=await ea(`/api/admin/users?id=${W}`);ye!=null&&ye.success?G():j((ye==null?void 0:ye.error)||"删除失败")}catch(ye){const Ae=ye;j(((le=Ae==null?void 0:Ae.data)==null?void 0:le.error)||"删除失败")}},D=W=>{if(!W)return"-";try{const le=new Date(W);return isNaN(le.getTime())?W:le.toLocaleString("zh-CN")}catch{return W}};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-6",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(od,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(re,{placeholder:"搜索用户名/昵称",value:h,onChange:W=>f(W.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),r.jsx(X,{variant:"outline",size:"sm",onClick:G,disabled:g,className:"border-gray-600 text-gray-300",children:r.jsx(Fe,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),r.jsxs(X,{onClick:$,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),N&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm flex justify-between items-center",children:[r.jsx("span",{children:N}),r.jsx("button",{type:"button",onClick:()=>j(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:g?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(r.Fragment,{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"用户名"}),r.jsx(we,{className:"text-gray-400",children:"昵称"}),r.jsx(we,{className:"text-gray-400",children:"角色"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"创建时间"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(as,{children:[t.map(W=>r.jsxs(it,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:W.id}),r.jsx(ve,{className:"text-white font-medium",children:W.username}),r.jsx(ve,{className:"text-gray-400",children:W.name||"-"}),r.jsx(ve,{children:r.jsx(Ke,{variant:"outline",className:W.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:W.role==="super_admin"?"超级管理员":"管理员"})}),r.jsx(ve,{children:r.jsx(Ke,{variant:"outline",className:W.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:W.status==="active"?"正常":"已禁用"})}),r.jsx(ve,{className:"text-gray-500 text-sm",children:D(W.createdAt)}),r.jsxs(ve,{className:"text-right",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>A(W),className:"text-gray-400 hover:text-[#38bdac]",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>U(W.id),className:"text-gray-400 hover:text-red-400",children:r.jsx(Zn,{className:"w-4 h-4"})})]})]},W.id)),t.length===0&&!g&&r.jsx(it,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:N==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&r.jsx("div",{className:"p-4 border-t border-gray-700/50",children:r.jsx(Fs,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),r.jsx(It,{open:v,onOpenChange:k,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:C?"编辑管理员":"新增管理员"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"用户名"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:M,onChange:W=>P(W.target.value),disabled:!!C}),C&&r.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:C?"新密码(留空不改)":"密码"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:C?"留空表示不修改":"至少 6 位",value:H,onChange:W=>L(W.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"昵称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:R,onChange:W=>O(W.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"角色"}),r.jsxs("select",{value:se,onChange:W=>ie(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[r.jsx("option",{value:"admin",children:"管理员"}),r.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),C&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"状态"}),r.jsxs("select",{value:z,onChange:W=>ce(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[r.jsx("option",{value:"active",children:"正常"}),r.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:Y,disabled:me,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),me?"保存中...":"保存"]})]})]})})]})}function En({method:t,url:e,desc:n,headers:s,body:a,response:i}){const o=t==="GET"?"text-emerald-400":t==="POST"?"text-amber-400":t==="PUT"?"text-blue-400":t==="DELETE"?"text-rose-400":"text-gray-400";return r.jsxs("div",{className:"rounded-lg bg-[#0a1628]/60 border border-gray-700/50 p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`font-mono font-semibold ${o}`,children:t}),r.jsx("code",{className:"text-sm text-[#38bdac] break-all",children:e})]}),n&&r.jsx("p",{className:"text-gray-400 text-sm",children:n}),s&&s.length>0&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Headers"}),r.jsx("pre",{className:"text-xs text-gray-300 font-mono overflow-x-auto p-2 rounded bg-black/30",children:s.join(` +`)})]}),a&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Request Body (JSON)"}),r.jsx("pre",{className:"text-xs text-green-400/90 font-mono overflow-x-auto p-2 rounded bg-black/30 whitespace-pre-wrap",children:a})]}),i&&r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Response Example"}),r.jsx("pre",{className:"text-xs text-amber-200/80 font-mono overflow-x-auto p-2 rounded bg-black/30 whitespace-pre-wrap",children:i})]})]})}function Y4(){const t=["Authorization: Bearer {token}","Content-Type: application/json"];return r.jsxs("div",{className:"p-8 w-full bg-[#0a1628] text-white",children:[r.jsxs("div",{className:"mb-8",children:[r.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"内容管理相关接口 · RESTful · 基础路径 /api · 管理端需 Bearer Token"})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(uj,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),r.jsx(Te,{className:"space-y-4",children:r.jsx(En,{method:"POST",url:"/api/admin",desc:"登录,返回 JWT token",headers:["Content-Type: application/json"],body:`{ "username": "admin", "password": "your_password" }`,response:`{ "success": true, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "expires_at": "2026-03-16T12:00:00Z" -}`})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Gs,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(Cn,{method:"GET",url:"/api/db/book?action=chapters",desc:"获取章节树",headers:t,response:`{ +}`})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ys,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(En,{method:"GET",url:"/api/db/book?action=chapters",desc:"获取章节树",headers:t,response:`{ "success": true, "data": [ { "id": "part-1", "title": "第一篇", "children": [...] }, { "id": "section-1", "title": "第1节", "price": 1.0, "isFree": false } ] -}`}),r.jsx(Cn,{method:"GET",url:"/api/db/book?action=section&id={id}",desc:"获取单篇内容",headers:t,response:`{ +}`}),r.jsx(En,{method:"GET",url:"/api/db/book?action=section&id={id}",desc:"获取单篇内容",headers:t,response:`{ "success": true, "data": { "id": "section-1", @@ -797,7 +797,7 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: "partId": "part-1", "chapterId": "ch-1" } -}`}),r.jsx(Cn,{method:"POST",url:"/api/db/book",desc:"新建章节 (action=create-section)",headers:t,body:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/db/book",desc:"新建章节 (action=create-section)",headers:t,body:`{ "action": "create-section", "title": "新章节标题", "content": "正文内容", @@ -810,7 +810,7 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`,response:`{ "success": true, "data": { "id": "section-new-id", "title": "新章节标题", ... } -}`}),r.jsx(Cn,{method:"POST",url:"/api/db/book",desc:"更新章节内容 (action=update-section)",headers:t,body:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/db/book",desc:"更新章节内容 (action=update-section)",headers:t,body:`{ "action": "update-section", "id": "section-1", "title": "更新后的标题", @@ -820,22 +820,22 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`,response:`{ "success": true, "data": { "id": "section-1", "title": "更新后的标题", ... } -}`}),r.jsx(Cn,{method:"POST",url:"/api/db/book",desc:"删除章节 (action=delete-section)",headers:t,body:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/db/book",desc:"删除章节 (action=delete-section)",headers:t,body:`{ "action": "delete-section", "id": "section-1" }`,response:`{ "success": true, "message": "已删除" -}`}),r.jsx(Cn,{method:"POST",url:"/api/admin/content/upload",desc:"上传图片(管理端)",headers:t,body:"FormData: file (binary)",response:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/admin/content/upload",desc:"上传图片(管理端)",headers:t,body:"FormData: file (binary)",response:`{ "success": true, "url": "/uploads/images/xxx.jpg", "data": { "url", "fileName", "size", "type" } -}`})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"3. 人物管理 (@Mentions)"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(Cn,{method:"GET",url:"/api/db/persons",desc:"人物列表",headers:t,response:`{ +}`})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ao,{className:"w-5 h-5 text-[#38bdac]"}),"3. 人物管理 (@Mentions)"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(En,{method:"GET",url:"/api/db/persons",desc:"人物列表",headers:t,response:`{ "success": true, "data": [ { "personId": "p1", "label": "张三", "aliases": ["老张"], ... } ] -}`}),r.jsx(Cn,{method:"GET",url:"/api/db/person?personId={id}",desc:"人物详情",headers:t,response:`{ +}`}),r.jsx(En,{method:"GET",url:"/api/db/person?personId={id}",desc:"人物详情",headers:t,response:`{ "success": true, "data": { "personId": "p1", @@ -843,7 +843,7 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: "aliases": ["老张"], "description": "..." } -}`}),r.jsx(Cn,{method:"POST",url:"/api/db/persons",desc:"新增/更新人物(含 aliases 字段)",headers:t,body:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/db/persons",desc:"新增/更新人物(含 aliases 字段)",headers:t,body:`{ "personId": "p1", "label": "张三", "aliases": ["老张", "张三丰"], @@ -851,15 +851,15 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`,response:`{ "success": true, "data": { "personId": "p1", "label": "张三", ... } -}`}),r.jsx(Cn,{method:"DELETE",url:"/api/db/persons?personId={id}",desc:"删除人物",headers:t,response:`{ +}`}),r.jsx(En,{method:"DELETE",url:"/api/db/persons?personId={id}",desc:"删除人物",headers:t,response:`{ "success": true, "message": "已删除" -}`})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(ld,{className:"w-5 h-5 text-[#38bdac]"}),"4. 链接标签 (#LinkTags)"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(Cn,{method:"GET",url:"/api/db/link-tags",desc:"标签列表",headers:t,response:`{ +}`})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(ld,{className:"w-5 h-5 text-[#38bdac]"}),"4. 链接标签 (#LinkTags)"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(En,{method:"GET",url:"/api/db/link-tags",desc:"标签列表",headers:t,response:`{ "success": true, "data": [ { "tagId": "t1", "label": "官网", "aliases": [], "type": "url", "url": "https://..." } ] -}`}),r.jsx(Cn,{method:"POST",url:"/api/db/link-tags",desc:"新增/更新标签(含 aliases, type: url/miniprogram/ckb)",headers:t,body:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/db/link-tags",desc:"新增/更新标签(含 aliases, type: url/miniprogram/ckb)",headers:t,body:`{ "tagId": "t1", "label": "官网", "aliases": ["官方网站"], @@ -870,45 +870,45 @@ ${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: // type 可选: url | miniprogram | ckb`,response:`{ "success": true, "data": { "tagId": "t1", "label": "官网", "type": "url", ... } -}`}),r.jsx(Cn,{method:"DELETE",url:"/api/db/link-tags?tagId={id}",desc:"删除标签",headers:t,response:`{ +}`}),r.jsx(En,{method:"DELETE",url:"/api/db/link-tags?tagId={id}",desc:"删除标签",headers:t,response:`{ "success": true, "message": "已删除" -}`})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Fa,{className:"w-5 h-5 text-[#38bdac]"}),"5. 内容搜索"]})}),r.jsx(Te,{className:"space-y-4",children:r.jsx(Cn,{method:"GET",url:"/api/search?q={keyword}",desc:"搜索(标题优先 3 条 + 内容匹配)",headers:t,response:`{ +}`})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ba,{className:"w-5 h-5 text-[#38bdac]"}),"5. 内容搜索"]})}),r.jsx(Te,{className:"space-y-4",children:r.jsx(En,{method:"GET",url:"/api/search?q={keyword}",desc:"搜索(标题优先 3 条 + 内容匹配)",headers:t,response:`{ "success": true, "data": { "titleMatches": [{ "id": "s1", "title": "...", "snippet": "..." }], "contentMatches": [{ "id": "s2", "title": "...", "snippet": "..." }] } -}`})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Xg,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),r.jsx(Te,{className:"space-y-4",children:r.jsx(Cn,{method:"GET",url:"/api/db/book?action=ranking",desc:"排行榜数据",headers:t,response:`{ +}`})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Xg,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),r.jsx(Te,{className:"space-y-4",children:r.jsx(En,{method:"GET",url:"/api/db/book?action=ranking",desc:"排行榜数据",headers:t,response:`{ "success": true, "data": [ { "id": "s1", "title": "...", "clickCount": 100, "payCount": 50, "hotScore": 120, "hotRank": 1 } ] -}`})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5 text-[#38bdac]"}),"7. 小程序接口"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(Cn,{method:"GET",url:"/api/miniprogram/book/all-chapters",desc:"全部章节(小程序用)",headers:["Content-Type: application/json"],response:`{ +}`})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{className:"pb-3",children:r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5 text-[#38bdac]"}),"7. 小程序接口"]})}),r.jsxs(Te,{className:"space-y-4",children:[r.jsx(En,{method:"GET",url:"/api/miniprogram/book/all-chapters",desc:"全部章节(小程序用)",headers:["Content-Type: application/json"],response:`{ "success": true, "data": [ { "id": "s1", "title": "...", "price": 1.0, "isFree": false }, ... ] -}`}),r.jsx(Cn,{method:"GET",url:"/api/miniprogram/balance?userId={id}",desc:"查余额",headers:["Content-Type: application/json"],response:`{ +}`}),r.jsx(En,{method:"GET",url:"/api/miniprogram/balance?userId={id}",desc:"查余额",headers:["Content-Type: application/json"],response:`{ "success": true, "data": { "balance": 100.50, "userId": "xxx" } -}`}),r.jsx(Cn,{method:"POST",url:"/api/miniprogram/balance/gift",desc:"代付",headers:["Content-Type: application/json"],body:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/miniprogram/balance/gift",desc:"代付",headers:["Content-Type: application/json"],body:`{ "userId": "xxx", "amount": 10.00, "remark": "可选备注" }`,response:`{ "success": true, "data": { "balance": 110.50 } -}`}),r.jsx(Cn,{method:"POST",url:"/api/miniprogram/balance/gift/redeem",desc:"领取代付",headers:["Content-Type: application/json"],body:`{ +}`}),r.jsx(En,{method:"POST",url:"/api/miniprogram/balance/gift/redeem",desc:"领取代付",headers:["Content-Type: application/json"],body:`{ "code": "GIFT_XXXX" }`,response:`{ "success": true, "data": { "amount": 10.00, "balance": 120.50 } -}`})]})]}),r.jsx("p",{className:"text-gray-500 text-xs mt-6",children:"管理端仅使用 /api/admin/*、/api/db/*;小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}const gV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},xV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},yV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...xV},ckbLeadApiKey:""},bV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},vV=["system","author","admin","api-docs"];function NV(){const[t,e]=tj(),n=t.get("tab")??"system",s=vV.includes(n)?n:"system",[a,i]=b.useState(yV),[o,c]=b.useState(bV),[u,h]=b.useState(gV),[f,m]=b.useState({}),[g,y]=b.useState(!1),[N,j]=b.useState(!0),[v,k]=b.useState(!1),[C,E]=b.useState(""),[M,P]=b.useState(""),[H,L]=b.useState(!1),[R,O]=b.useState(!1),ne=(A,J,U=!1)=>{E(A),P(J),L(U),k(!0)};b.useEffect(()=>{(async()=>{try{const J=await De("/api/admin/settings");if(!J||J.success===!1)return;if(J.featureConfig&&Object.keys(J.featureConfig).length&&c(U=>({...U,...J.featureConfig})),J.mpConfig&&typeof J.mpConfig=="object"&&h(U=>({...U,...J.mpConfig})),J.ossConfig&&typeof J.ossConfig=="object"&&m(U=>({...U,...J.ossConfig})),J.siteSettings&&typeof J.siteSettings=="object"){const U=J.siteSettings;i(D=>({...D,...typeof U.sectionPrice=="number"&&{sectionPrice:U.sectionPrice},...typeof U.baseBookPrice=="number"&&{baseBookPrice:U.baseBookPrice},...typeof U.distributorShare=="number"&&{distributorShare:U.distributorShare},...U.authorInfo&&typeof U.authorInfo=="object"&&{authorInfo:{...D.authorInfo,...U.authorInfo}},...typeof U.ckbLeadApiKey=="string"&&{ckbLeadApiKey:U.ckbLeadApiKey}}))}}catch(J){console.error("Load settings error:",J)}finally{j(!1)}})()},[]);const ie=async(A,J)=>{O(!0);try{const U=await Nt("/api/admin/settings",{featureConfig:A});if(!U||U.success===!1){J(),ne("保存失败",(U==null?void 0:U.error)??"未知错误",!0);return}ne("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(U){console.error("Save feature config error:",U),J(),ne("保存失败",U instanceof Error?U.message:String(U),!0)}finally{O(!1)}},_=(A,J)=>{const U=o,D={...U,[A]:J};c(D),ie(D,()=>c(U))},[ce,pe]=b.useState(!1),z=async A=>{const J=u,U={...J,auditMode:A};h(U),pe(!0);try{const D=await Nt("/api/admin/settings",{mpConfig:U});if(!D||D.success===!1){h(J),ne("保存失败",(D==null?void 0:D.error)??"未知错误",!0);return}ne("已保存",A?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch(D){h(J),ne("保存失败",D instanceof Error?D.message:String(D),!0)}finally{pe(!1)}},q=async()=>{y(!0);try{const A=await Nt("/api/admin/settings",{featureConfig:o,siteSettings:{sectionPrice:a.sectionPrice,baseBookPrice:a.baseBookPrice,distributorShare:a.distributorShare,authorInfo:a.authorInfo,ckbLeadApiKey:a.ckbLeadApiKey||void 0},mpConfig:{...u,appId:u.appId||"",withdrawSubscribeTmplId:u.withdrawSubscribeTmplId||"",mchId:u.mchId||"",minWithdraw:typeof u.minWithdraw=="number"?u.minWithdraw:10,auditMode:u.auditMode??!1},ossConfig:Object.keys(f).length?{endpoint:f.endpoint??"",bucket:f.bucket??"",region:f.region??"",accessKeyId:f.accessKeyId??"",accessKeySecret:f.accessKeySecret??""}:void 0});if(!A||A.success===!1){ne("保存失败",(A==null?void 0:A.error)??"未知错误",!0);return}ne("已保存","设置已保存成功。")}catch(A){console.error("Save settings error:",A),ne("保存失败",A instanceof Error?A.message:String(A),!0)}finally{y(!1)}},F=A=>{e(A==="system"?{}:{tab:A})};return N?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),s==="system"&&r.jsxs(X,{onClick:q,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),g?"保存中...":"保存设置"]})]}),r.jsxs(Wd,{value:s,onValueChange:F,className:"w-full",children:[r.jsxs(sc,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[r.jsxs(Yt,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(Mo,{className:"w-4 h-4 mr-2"}),"系统设置"]}),r.jsxs(Yt,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(Wm,{className:"w-4 h-4 mr-2"}),"作者详情"]}),r.jsxs(Yt,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(od,{className:"w-4 h-4 mr-2"}),"管理员"]}),r.jsxs(Yt,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(oj,{className:"w-4 h-4 mr-2"}),"API 文档"]})]}),r.jsx(Qt,{value:"system",className:"mt-0",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Wm,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),r.jsx(Lt,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Wm,{className:"w-3 h-3"}),"主理人名称"]}),r.jsx(re,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.name??"",onChange:A=>i(J=>({...J,authorInfo:{...J.authorInfo,name:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Ah,{className:"w-3 h-3"}),"开播日期"]}),r.jsx(re,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:a.authorInfo.startDate??"",onChange:A=>i(J=>({...J,authorInfo:{...J.authorInfo,startDate:A.target.value}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Ah,{className:"w-3 h-3"}),"直播时间"]}),r.jsx(re,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:a.authorInfo.liveTime??"",onChange:A=>i(J=>({...J,authorInfo:{...J.authorInfo,liveTime:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(hj,{className:"w-3 h-3"}),"直播平台"]}),r.jsx(re,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:a.authorInfo.platform??"",onChange:A=>i(J=>({...J,authorInfo:{...J.authorInfo,platform:A.target.value}}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Gs,{className:"w-3 h-3"}),"简介描述"]}),r.jsx(re,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.description??"",onChange:A=>i(J=>({...J,authorInfo:{...J.authorInfo,description:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),r.jsx(rc,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:a.authorInfo.bio??"",onChange:A=>i(J=>({...J,authorInfo:{...J.authorInfo,bio:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Ir,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),r.jsx(re,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:a.ckbLeadApiKey??"",onChange:A=>i(J=>({...J,ckbLeadApiKey:A.target.value}))}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),r.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[r.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(a.authorInfo.name??"K").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-semibold",children:a.authorInfo.name}),r.jsx("p",{className:"text-gray-400 text-xs",children:a.authorInfo.description}),r.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",a.authorInfo.liveTime," · ",a.authorInfo.platform]})]})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ih,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),r.jsx(Te,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"单节价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.sectionPrice,onChange:A=>i(J=>({...J,sectionPrice:Number.parseFloat(A.target.value)||1}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"整本价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.baseBookPrice,onChange:A=>i(J=>({...J,baseBookPrice:Number.parseFloat(A.target.value)||9.9}))})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),r.jsx(Lt,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),r.jsx(Te,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"小程序 AppID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:A=>h(J=>({...J,appId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"提现订阅模板 ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:A=>h(J=>({...J,withdrawSubscribeTmplId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"微信支付商户号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:A=>h(J=>({...J,mchId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最低提现金额 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:A=>h(J=>({...J,minWithdraw:Number.parseFloat(A.target.value)||10}))})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(oM,{className:"w-5 h-5 text-[#38bdac]"}),"OSS 配置(阿里云对象存储)"]}),r.jsx(Lt,{className:"text-gray-400",children:"endpoint、bucket、accessKey 等,用于图片/文件上传"})]}),r.jsx(Te,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"Endpoint"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:f.endpoint??"",onChange:A=>m(J=>({...J,endpoint:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"Bucket"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:f.bucket??"",onChange:A=>m(J=>({...J,bucket:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"Region"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:f.region??"",onChange:A=>m(J=>({...J,region:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"AccessKey ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:f.accessKeyId??"",onChange:A=>m(J=>({...J,accessKeyId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"AccessKey Secret"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:f.accessKeySecret??"",onChange:A=>m(J=>({...J,accessKeySecret:A.target.value}))})]})]})})]}),r.jsxs(Ee,{className:`bg-[#0f2137] shadow-xl ${u.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(od,{className:"w-5 h-5 text-amber-400"}),"小程序审核模式"]}),r.jsx(Lt,{className:"text-gray-400",children:"提交微信审核前开启,审核通过后关闭即可恢复支付功能"})]}),r.jsx(Te,{children:r.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg border ${u.auditMode?"bg-amber-500/10 border-amber-500/30":"bg-[#0a1628] border-gray-700/50"}`,children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(od,{className:`w-4 h-4 ${u.auditMode?"text-amber-400":"text-gray-400"}`}),r.jsx(Z,{htmlFor:"audit-mode",className:"text-white font-medium cursor-pointer",children:u.auditMode?"审核模式(已开启)":"审核模式(已关闭)"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:u.auditMode?"当前已隐藏所有支付、VIP、充值、收益等入口,审核员看不到任何付费内容":"关闭状态,小程序正常显示所有功能(含支付、VIP 等)"})]}),r.jsx(Ct,{id:"audit-mode",checked:u.auditMode??!1,disabled:ce,onCheckedChange:z})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Mo,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),r.jsx(Lt,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_n,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),r.jsx(Ct,{id:"match-enabled",checked:o.matchEnabled,disabled:R,onCheckedChange:A=>_("matchEnabled",A)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(cj,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"})]}),r.jsx(Ct,{id:"referral-enabled",checked:o.referralEnabled,disabled:R,onCheckedChange:A=>_("referralEnabled",A)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Gs,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页、目录页搜索栏的显示"})]}),r.jsx(Ct,{id:"search-enabled",checked:o.searchEnabled,disabled:R,onCheckedChange:A=>_("searchEnabled",A)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Mo,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),r.jsx(Ct,{id:"about-enabled",checked:o.aboutEnabled,disabled:R,onCheckedChange:A=>_("aboutEnabled",A)})]})]}),r.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:r.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]})]})}),r.jsx(Qt,{value:"author",className:"mt-0",children:r.jsx(pV,{})}),r.jsx(Qt,{value:"admin",className:"mt-0",children:r.jsx(mV,{})}),r.jsx(Qt,{value:"api-docs",className:"mt-0",children:r.jsx(Y4,{})})]}),r.jsx(Rt,{open:v,onOpenChange:k,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsxs(Pt,{children:[r.jsx(Ot,{className:H?"text-red-400":"text-[#38bdac]",children:C}),r.jsx(Cd,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:M})]}),r.jsx(tn,{className:"mt-4",children:r.jsx(X,{onClick:()=>k(!1),className:H?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const Pw={wechat:{enabled:!0,qrCode:"/images/wechat-pay.png",account:"卡若",websiteAppId:"",merchantId:"",groupQrCode:"/images/party-group-qr.png"},alipay:{enabled:!0,qrCode:"/images/alipay.png",account:"卡若",partnerId:"",securityKey:""},usdt:{enabled:!1,network:"TRC20",address:"",exchangeRate:7.2},paypal:{enabled:!1,email:"",exchangeRate:7.2}};function wV(){const[t,e]=b.useState(!1),[n,s]=b.useState(Pw),[a,i]=b.useState(""),o=async()=>{e(!0);try{const k=await De("/api/config");k!=null&&k.paymentMethods&&s({...Pw,...k.paymentMethods})}catch(k){console.error(k)}finally{e(!1)}};b.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await Nt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),se.success("配置已保存!")}catch(k){console.error("保存失败:",k),se.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,C)=>{navigator.clipboard.writeText(k),i(C),setTimeout(()=>i(""),2e3)},h=(k,C)=>{s(E=>({...E,wechat:{...E.wechat,[k]:C}}))},f=(k,C)=>{s(E=>({...E,alipay:{...E.alipay,[k]:C}}))},m=(k,C)=>{s(E=>({...E,usdt:{...E.usdt,[k]:C}}))},g=(k,C)=>{s(E=>({...E,paypal:{...E.paypal,[k]:C}}))},y=n.wechat,N=n.alipay,j=n.usdt,v=n.paypal;return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),r.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(X,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),r.jsxs(X,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),r.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(aj,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),r.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[r.jsx("li",{children:"打开微信,进入目标微信群"}),r.jsx("li",{children:'点击右上角"..." → "群二维码"'}),r.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),r.jsx("li",{children:"在电脑上保存二维码图片,上传到图床获取URL"}),r.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),r.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示:微信群二维码7天后失效,建议使用活码工具"})]})]})}),r.jsxs(Wd,{defaultValue:"wechat",className:"space-y-6",children:[r.jsxs(sc,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[r.jsxs(Yt,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[r.jsx(zi,{className:"w-4 h-4 mr-2"}),"微信"]}),r.jsxs(Yt,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[r.jsx(Yv,{className:"w-4 h-4 mr-2"}),"支付宝"]}),r.jsxs(Yt,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[r.jsx(Gv,{className:"w-4 h-4 mr-2"}),"USDT"]}),r.jsxs(Yt,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[r.jsx(Gg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),r.jsx(Qt,{value:"wechat",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#07C160] flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5"}),"微信支付配置"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),r.jsx(Ct,{checked:!!y.enabled,onCheckedChange:k=>h("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"网站AppID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"商户号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:k=>h("merchantId",k.target.value)})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[r.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[r.jsx(ra,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"微信收款码/支付链接"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:k=>h("qrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),r.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[r.jsx(Z,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),r.jsx(re,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(y.groupQrCode??""),onChange:k=>h("groupQrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),r.jsx(Qt,{value:"alipay",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#1677FF] flex items-center gap-2",children:[r.jsx(Yv,{className:"w-5 h-5"}),"支付宝配置"]}),r.jsx(Lt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),r.jsx(Ct,{checked:!!N.enabled,onCheckedChange:k=>f("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"合作者身份 (PID)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),r.jsx(X,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?r.jsx(Of,{className:"w-4 h-4 text-green-500"}):r.jsx(s0,{className:"w-4 h-4 text-gray-400"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"安全校验码 (Key)"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.securityKey??""),onChange:k=>f("securityKey",k.target.value)})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[r.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[r.jsx(ra,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(N.qrCode??""),onChange:k=>f("qrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),r.jsx(Qt,{value:"usdt",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#26A17B] flex items-center gap-2",children:[r.jsx(Gv,{className:"w-5 h-5"}),"USDT配置"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),r.jsx(Ct,{checked:!!j.enabled,onCheckedChange:k=>m("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"网络类型"}),r.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(j.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[r.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),r.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),r.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"收款地址"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(j.address??""),onChange:k=>m("address",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(j.exchangeRate)??7.2,onChange:k=>m("exchangeRate",Number.parseFloat(k.target.value)||7.2)})]})]})]})}),r.jsx(Qt,{value:"paypal",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#169BD7] flex items-center gap-2",children:[r.jsx(Gg,{className:"w-5 h-5"}),"PayPal配置"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),r.jsx(Ct,{checked:!!v.enabled,onCheckedChange:k=>g("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"PayPal邮箱"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(v.email??""),onChange:k=>g("email",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(v.exchangeRate)??7.2,onChange:k=>g("exchangeRate",Number(k.target.value)||7.2)})]})]})]})})]})]})}const jV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},kV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},SV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function CV(){const[t,e]=b.useState({siteConfig:{...jV},menuConfig:{...kV},pageConfig:{...SV}}),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{De("/api/config").then(f=>{f!=null&&f.siteConfig&&e(m=>({...m,siteConfig:{...m.siteConfig,...f.siteConfig}})),f!=null&&f.menuConfig&&e(m=>({...m,menuConfig:{...m.menuConfig,...f.menuConfig}})),f!=null&&f.pageConfig&&e(m=>({...m,pageConfig:{...m.pageConfig,...f.pageConfig}}))}).catch(console.error)},[]);const o=async()=>{i(!0);try{await Nt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await Nt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await Nt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),s(!0),setTimeout(()=>s(!1),2e3),se.success("配置已保存")}catch(f){console.error(f),se.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{i(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),r.jsxs(X,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Gg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),r.jsx(re,{id:"site-name",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteName??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteName:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),r.jsx(re,{id:"site-title",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteTitle??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteTitle:f.target.value}}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),r.jsx(re,{id:"site-desc",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteDescription??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteDescription:f.target.value}}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),r.jsx(re,{id:"logo",className:"bg-[#0a1628] border-gray-700 text-white",value:c.logo??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,logo:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),r.jsx(re,{id:"favicon",className:"bg-[#0a1628] border-gray-700 text-white",value:c.favicon??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,favicon:f.target.value}}))})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(d5,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置网站主题色"})]}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"space-y-2 flex-1",children:[r.jsx(Z,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(re,{id:"primary-color",type:"color",className:"w-16 h-10 bg-[#0a1628] border-gray-700 cursor-pointer p-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white flex-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))})]})]}),r.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(s5,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),r.jsx(Lt,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),r.jsx(Te,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[r.jsx(Ct,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),r.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,label:g.target.value}}}))})]}),r.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(oj,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"首页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"首页副标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"目录页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"我的页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"关于作者标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function EV(){const[t,e]=b.useState(""),[n,s]=b.useState(""),[a,i]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,N,j,v;try{const k=await De("/api/config"),C=(N=(y=k==null?void 0:k.liveQRCodes)==null?void 0:y[0])==null?void 0:N.urls;Array.isArray(C)&&e(C.join(` +}`})]})]}),r.jsx("p",{className:"text-gray-500 text-xs mt-6",children:"管理端仅使用 /api/admin/*、/api/db/*;小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}const gV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},xV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},yV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...xV},ckbLeadApiKey:""},bV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},vV=["system","author","admin","api-docs"];function NV(){const[t,e]=tj(),n=t.get("tab")??"system",s=vV.includes(n)?n:"system",[a,i]=b.useState(yV),[o,c]=b.useState(bV),[u,h]=b.useState(gV),[f,m]=b.useState({}),[g,y]=b.useState(!1),[N,j]=b.useState(!0),[v,k]=b.useState(!1),[C,E]=b.useState(""),[M,P]=b.useState(""),[H,L]=b.useState(!1),[R,O]=b.useState(!1),se=(A,Y,U=!1)=>{E(A),P(Y),L(U),k(!0)};b.useEffect(()=>{(async()=>{try{const Y=await De("/api/admin/settings");if(!Y||Y.success===!1)return;if(Y.featureConfig&&Object.keys(Y.featureConfig).length&&c(U=>({...U,...Y.featureConfig})),Y.mpConfig&&typeof Y.mpConfig=="object"&&h(U=>({...U,...Y.mpConfig})),Y.ossConfig&&typeof Y.ossConfig=="object"&&m(U=>({...U,...Y.ossConfig})),Y.siteSettings&&typeof Y.siteSettings=="object"){const U=Y.siteSettings;i(D=>({...D,...typeof U.sectionPrice=="number"&&{sectionPrice:U.sectionPrice},...typeof U.baseBookPrice=="number"&&{baseBookPrice:U.baseBookPrice},...typeof U.distributorShare=="number"&&{distributorShare:U.distributorShare},...U.authorInfo&&typeof U.authorInfo=="object"&&{authorInfo:{...D.authorInfo,...U.authorInfo}},...typeof U.ckbLeadApiKey=="string"&&{ckbLeadApiKey:U.ckbLeadApiKey}}))}}catch(Y){console.error("Load settings error:",Y)}finally{j(!1)}})()},[]);const ie=async(A,Y)=>{O(!0);try{const U=await Nt("/api/admin/settings",{featureConfig:A});if(!U||U.success===!1){Y(),se("保存失败",(U==null?void 0:U.error)??"未知错误",!0);return}se("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(U){console.error("Save feature config error:",U),Y(),se("保存失败",U instanceof Error?U.message:String(U),!0)}finally{O(!1)}},z=(A,Y)=>{const U=o,D={...U,[A]:Y};c(D),ie(D,()=>c(U))},[ce,me]=b.useState(!1),_=async A=>{const Y=u,U={...Y,auditMode:A};h(U),me(!0);try{const D=await Nt("/api/admin/settings",{mpConfig:U});if(!D||D.success===!1){h(Y),se("保存失败",(D==null?void 0:D.error)??"未知错误",!0);return}se("已保存",A?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch(D){h(Y),se("保存失败",D instanceof Error?D.message:String(D),!0)}finally{me(!1)}},G=async()=>{y(!0);try{const A=await Nt("/api/admin/settings",{featureConfig:o,siteSettings:{sectionPrice:a.sectionPrice,baseBookPrice:a.baseBookPrice,distributorShare:a.distributorShare,authorInfo:a.authorInfo,ckbLeadApiKey:a.ckbLeadApiKey||void 0},mpConfig:{...u,appId:u.appId||"",withdrawSubscribeTmplId:u.withdrawSubscribeTmplId||"",mchId:u.mchId||"",minWithdraw:typeof u.minWithdraw=="number"?u.minWithdraw:10,auditMode:u.auditMode??!1},ossConfig:Object.keys(f).length?{endpoint:f.endpoint??"",bucket:f.bucket??"",region:f.region??"",accessKeyId:f.accessKeyId??"",accessKeySecret:f.accessKeySecret??""}:void 0});if(!A||A.success===!1){se("保存失败",(A==null?void 0:A.error)??"未知错误",!0);return}se("已保存","设置已保存成功。")}catch(A){console.error("Save settings error:",A),se("保存失败",A instanceof Error?A.message:String(A),!0)}finally{y(!1)}},$=A=>{e(A==="system"?{}:{tab:A})};return N?r.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),s==="system"&&r.jsxs(X,{onClick:G,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),g?"保存中...":"保存设置"]})]}),r.jsxs(Wd,{value:s,onValueChange:$,className:"w-full",children:[r.jsxs(sc,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[r.jsxs(Zt,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(Mo,{className:"w-4 h-4 mr-2"}),"系统设置"]}),r.jsxs(Zt,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(Wm,{className:"w-4 h-4 mr-2"}),"作者详情"]}),r.jsxs(Zt,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(od,{className:"w-4 h-4 mr-2"}),"管理员"]}),r.jsxs(Zt,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[r.jsx(oj,{className:"w-4 h-4 mr-2"}),"API 文档"]})]}),r.jsx(en,{value:"system",className:"mt-0",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Wm,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),r.jsx(Ft,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Wm,{className:"w-3 h-3"}),"主理人名称"]}),r.jsx(re,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.name??"",onChange:A=>i(Y=>({...Y,authorInfo:{...Y.authorInfo,name:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Ah,{className:"w-3 h-3"}),"开播日期"]}),r.jsx(re,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:a.authorInfo.startDate??"",onChange:A=>i(Y=>({...Y,authorInfo:{...Y.authorInfo,startDate:A.target.value}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Ah,{className:"w-3 h-3"}),"直播时间"]}),r.jsx(re,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:a.authorInfo.liveTime??"",onChange:A=>i(Y=>({...Y,authorInfo:{...Y.authorInfo,liveTime:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(hj,{className:"w-3 h-3"}),"直播平台"]}),r.jsx(re,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:a.authorInfo.platform??"",onChange:A=>i(Y=>({...Y,authorInfo:{...Y.authorInfo,platform:A.target.value}}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Ys,{className:"w-3 h-3"}),"简介描述"]}),r.jsx(re,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.description??"",onChange:A=>i(Y=>({...Y,authorInfo:{...Y.authorInfo,description:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),r.jsx(rc,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:a.authorInfo.bio??"",onChange:A=>i(Y=>({...Y,authorInfo:{...Y.authorInfo,bio:A.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[r.jsx(Rr,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),r.jsx(re,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:a.ckbLeadApiKey??"",onChange:A=>i(Y=>({...Y,ckbLeadApiKey:A.target.value}))}),r.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),r.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[r.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(a.authorInfo.name??"K").charAt(0)}),r.jsxs("div",{children:[r.jsx("p",{className:"text-white font-semibold",children:a.authorInfo.name}),r.jsx("p",{className:"text-gray-400 text-xs",children:a.authorInfo.description}),r.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",a.authorInfo.liveTime," · ",a.authorInfo.platform]})]})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ih,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),r.jsx(Te,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"单节价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.sectionPrice,onChange:A=>i(Y=>({...Y,sectionPrice:Number.parseFloat(A.target.value)||1}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"整本价格 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.baseBookPrice,onChange:A=>i(Y=>({...Y,baseBookPrice:Number.parseFloat(A.target.value)||9.9}))})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),r.jsx(Ft,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),r.jsx(Te,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"小程序 AppID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:A=>h(Y=>({...Y,appId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"提现订阅模板 ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:A=>h(Y=>({...Y,withdrawSubscribeTmplId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"微信支付商户号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:A=>h(Y=>({...Y,mchId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"最低提现金额 (元)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:A=>h(Y=>({...Y,minWithdraw:Number.parseFloat(A.target.value)||10}))})]})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(oM,{className:"w-5 h-5 text-[#38bdac]"}),"OSS 配置(阿里云对象存储)"]}),r.jsx(Ft,{className:"text-gray-400",children:"endpoint、bucket、accessKey 等,用于图片/文件上传"})]}),r.jsx(Te,{className:"space-y-4",children:r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"Endpoint"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:f.endpoint??"",onChange:A=>m(Y=>({...Y,endpoint:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"Bucket"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:f.bucket??"",onChange:A=>m(Y=>({...Y,bucket:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"Region"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:f.region??"",onChange:A=>m(Y=>({...Y,region:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"AccessKey ID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:f.accessKeyId??"",onChange:A=>m(Y=>({...Y,accessKeyId:A.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"AccessKey Secret"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:f.accessKeySecret??"",onChange:A=>m(Y=>({...Y,accessKeySecret:A.target.value}))})]})]})})]}),r.jsxs(Ee,{className:`bg-[#0f2137] shadow-xl ${u.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(od,{className:"w-5 h-5 text-amber-400"}),"小程序审核模式"]}),r.jsx(Ft,{className:"text-gray-400",children:"提交微信审核前开启,审核通过后关闭即可恢复支付功能"})]}),r.jsx(Te,{children:r.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg border ${u.auditMode?"bg-amber-500/10 border-amber-500/30":"bg-[#0a1628] border-gray-700/50"}`,children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(od,{className:`w-4 h-4 ${u.auditMode?"text-amber-400":"text-gray-400"}`}),r.jsx(Z,{htmlFor:"audit-mode",className:"text-white font-medium cursor-pointer",children:u.auditMode?"审核模式(已开启)":"审核模式(已关闭)"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:u.auditMode?"当前已隐藏所有支付、VIP、充值、收益等入口,审核员看不到任何付费内容":"关闭状态,小程序正常显示所有功能(含支付、VIP 等)"})]}),r.jsx(jt,{id:"audit-mode",checked:u.auditMode??!1,disabled:ce,onCheckedChange:_})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Mo,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),r.jsx(Ft,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_n,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),r.jsx(jt,{id:"match-enabled",checked:o.matchEnabled,disabled:R,onCheckedChange:A=>z("matchEnabled",A)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(cj,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"})]}),r.jsx(jt,{id:"referral-enabled",checked:o.referralEnabled,disabled:R,onCheckedChange:A=>z("referralEnabled",A)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ys,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页、目录页搜索栏的显示"})]}),r.jsx(jt,{id:"search-enabled",checked:o.searchEnabled,disabled:R,onCheckedChange:A=>z("searchEnabled",A)})]}),r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Mo,{className:"w-4 h-4 text-[#38bdac]"}),r.jsx(Z,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),r.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),r.jsx(jt,{id:"about-enabled",checked:o.aboutEnabled,disabled:R,onCheckedChange:A=>z("aboutEnabled",A)})]})]}),r.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:r.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]})]})}),r.jsx(en,{value:"author",className:"mt-0",children:r.jsx(pV,{})}),r.jsx(en,{value:"admin",className:"mt-0",children:r.jsx(mV,{})}),r.jsx(en,{value:"api-docs",className:"mt-0",children:r.jsx(Y4,{})})]}),r.jsx(It,{open:v,onOpenChange:k,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[r.jsxs(Rt,{children:[r.jsx(Pt,{className:H?"text-red-400":"text-[#38bdac]",children:C}),r.jsx(Cd,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:M})]}),r.jsx(sn,{className:"mt-4",children:r.jsx(X,{onClick:()=>k(!1),className:H?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const Pw={wechat:{enabled:!0,qrCode:"/images/wechat-pay.png",account:"卡若",websiteAppId:"",merchantId:"",groupQrCode:"/images/party-group-qr.png"},alipay:{enabled:!0,qrCode:"/images/alipay.png",account:"卡若",partnerId:"",securityKey:""},usdt:{enabled:!1,network:"TRC20",address:"",exchangeRate:7.2},paypal:{enabled:!1,email:"",exchangeRate:7.2}};function wV(){const[t,e]=b.useState(!1),[n,s]=b.useState(Pw),[a,i]=b.useState(""),o=async()=>{e(!0);try{const k=await De("/api/config");k!=null&&k.paymentMethods&&s({...Pw,...k.paymentMethods})}catch(k){console.error(k)}finally{e(!1)}};b.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await Nt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),te.success("配置已保存!")}catch(k){console.error("保存失败:",k),te.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,C)=>{navigator.clipboard.writeText(k),i(C),setTimeout(()=>i(""),2e3)},h=(k,C)=>{s(E=>({...E,wechat:{...E.wechat,[k]:C}}))},f=(k,C)=>{s(E=>({...E,alipay:{...E.alipay,[k]:C}}))},m=(k,C)=>{s(E=>({...E,usdt:{...E.usdt,[k]:C}}))},g=(k,C)=>{s(E=>({...E,paypal:{...E.paypal,[k]:C}}))},y=n.wechat,N=n.alipay,j=n.usdt,v=n.paypal;return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),r.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(X,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),r.jsxs(X,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),r.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(aj,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),r.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[r.jsx("li",{children:"打开微信,进入目标微信群"}),r.jsx("li",{children:'点击右上角"..." → "群二维码"'}),r.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),r.jsx("li",{children:"在电脑上保存二维码图片,上传到图床获取URL"}),r.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),r.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示:微信群二维码7天后失效,建议使用活码工具"})]})]})}),r.jsxs(Wd,{defaultValue:"wechat",className:"space-y-6",children:[r.jsxs(sc,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[r.jsxs(Zt,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[r.jsx(zi,{className:"w-4 h-4 mr-2"}),"微信"]}),r.jsxs(Zt,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[r.jsx(Yv,{className:"w-4 h-4 mr-2"}),"支付宝"]}),r.jsxs(Zt,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[r.jsx(Gv,{className:"w-4 h-4 mr-2"}),"USDT"]}),r.jsxs(Zt,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[r.jsx(Gg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),r.jsx(en,{value:"wechat",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#07C160] flex items-center gap-2",children:[r.jsx(zi,{className:"w-5 h-5"}),"微信支付配置"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),r.jsx(jt,{checked:!!y.enabled,onCheckedChange:k=>h("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"网站AppID"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"商户号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:k=>h("merchantId",k.target.value)})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[r.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[r.jsx(ra,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"微信收款码/支付链接"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:k=>h("qrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),r.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[r.jsx(Z,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),r.jsx(re,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(y.groupQrCode??""),onChange:k=>h("groupQrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),r.jsx(en,{value:"alipay",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#1677FF] flex items-center gap-2",children:[r.jsx(Yv,{className:"w-5 h-5"}),"支付宝配置"]}),r.jsx(Ft,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),r.jsx(jt,{checked:!!N.enabled,onCheckedChange:k=>f("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"合作者身份 (PID)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),r.jsx(X,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?r.jsx(Of,{className:"w-4 h-4 text-green-500"}):r.jsx(s0,{className:"w-4 h-4 text-gray-400"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"安全校验码 (Key)"}),r.jsx(re,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.securityKey??""),onChange:k=>f("securityKey",k.target.value)})]})]}),r.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[r.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[r.jsx(ra,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(N.qrCode??""),onChange:k=>f("qrCode",k.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),r.jsx(en,{value:"usdt",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#26A17B] flex items-center gap-2",children:[r.jsx(Gv,{className:"w-5 h-5"}),"USDT配置"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),r.jsx(jt,{checked:!!j.enabled,onCheckedChange:k=>m("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"网络类型"}),r.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(j.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[r.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),r.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),r.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"收款地址"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(j.address??""),onChange:k=>m("address",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(j.exchangeRate)??7.2,onChange:k=>m("exchangeRate",Number.parseFloat(k.target.value)||7.2)})]})]})]})}),r.jsx(en,{value:"paypal",className:"space-y-4",children:r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between pb-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Ye,{className:"text-[#169BD7] flex items-center gap-2",children:[r.jsx(Gg,{className:"w-5 h-5"}),"PayPal配置"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),r.jsx(jt,{checked:!!v.enabled,onCheckedChange:k=>g("enabled",k)})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"PayPal邮箱"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(v.email??""),onChange:k=>g("email",k.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(v.exchangeRate)??7.2,onChange:k=>g("exchangeRate",Number(k.target.value)||7.2)})]})]})]})})]})]})}const jV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},kV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},SV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function CV(){const[t,e]=b.useState({siteConfig:{...jV},menuConfig:{...kV},pageConfig:{...SV}}),[n,s]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{De("/api/config").then(f=>{f!=null&&f.siteConfig&&e(m=>({...m,siteConfig:{...m.siteConfig,...f.siteConfig}})),f!=null&&f.menuConfig&&e(m=>({...m,menuConfig:{...m.menuConfig,...f.menuConfig}})),f!=null&&f.pageConfig&&e(m=>({...m,pageConfig:{...m.pageConfig,...f.pageConfig}}))}).catch(console.error)},[]);const o=async()=>{i(!0);try{await Nt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await Nt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await Nt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),s(!0),setTimeout(()=>s(!1),2e3),te.success("配置已保存")}catch(f){console.error(f),te.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{i(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),r.jsxs(X,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Gg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),r.jsx(re,{id:"site-name",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteName??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteName:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),r.jsx(re,{id:"site-title",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteTitle??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteTitle:f.target.value}}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),r.jsx(re,{id:"site-desc",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteDescription??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteDescription:f.target.value}}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),r.jsx(re,{id:"logo",className:"bg-[#0a1628] border-gray-700 text-white",value:c.logo??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,logo:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),r.jsx(re,{id:"favicon",className:"bg-[#0a1628] border-gray-700 text-white",value:c.favicon??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,favicon:f.target.value}}))})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(d5,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置网站主题色"})]}),r.jsx(Te,{children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"space-y-2 flex-1",children:[r.jsx(Z,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(re,{id:"primary-color",type:"color",className:"w-16 h-10 bg-[#0a1628] border-gray-700 cursor-pointer p-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white flex-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))})]})]}),r.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(s5,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),r.jsx(Ft,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),r.jsx(Te,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>r.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[r.jsx(jt,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),r.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,label:g.target.value}}}))})]}),r.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(oj,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"首页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"首页副标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"目录页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"我的页标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"关于作者标题"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function EV(){const[t,e]=b.useState(""),[n,s]=b.useState(""),[a,i]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,N,j,v;try{const k=await De("/api/config"),C=(N=(y=k==null?void 0:k.liveQRCodes)==null?void 0:y[0])==null?void 0:N.urls;Array.isArray(C)&&e(C.join(` `));const E=(v=(j=k==null?void 0:k.paymentMethods)==null?void 0:j.wechat)==null?void 0:v.groupQrCode;E&&s(E),c({paymentMethods:k==null?void 0:k.paymentMethods,liveQRCodes:k==null?void 0:k.liveQRCodes})}catch(k){console.error(k)}};b.useEffect(()=>{u()},[]);const h=(y,N)=>{navigator.clipboard.writeText(y),i(N),setTimeout(()=>i(""),2e3)},f=async()=>{try{const y=t.split(` -`).map(j=>j.trim()).filter(Boolean),N=[...o.liveQRCodes||[]];N[0]?N[0].urls=y:N.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Nt("/api/db/config",{key:"live_qr_codes",value:N,description:"群活码配置"}),se.success("群活码配置已保存!"),await u()}catch(y){console.error(y),se.error("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await Nt("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),se.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(N){console.error(N),se.error("保存失败: "+(N instanceof Error?N.message:String(N)))}},g=()=>{n?window.open(n,"_blank"):se.error("请先配置微信群链接")};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"mb-8",children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),r.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(aj,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),r.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[r.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),r.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[r.jsx("li",{children:"访问草料二维码创建活码"}),r.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),r.jsx("li",{children:"复制生成的短链接填入下方配置"}),r.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),r.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),r.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[r.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),r.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),r.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意:微信原生群二维码7天后失效,建议使用草料活码"})]})]})]})}),r.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-[#07C160] flex items-center gap-2",children:[r.jsx(Xv,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),r.jsx(Lt,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Jg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{placeholder:"https://cli.im/xxxxx 或 https://weixin.qq.com/g/...",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",value:n,onChange:y=>s(y.target.value)}),r.jsx(X,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?r.jsx(Of,{className:"w-4 h-4 text-green-500"}):r.jsx(s0,{className:"w-4 h-4 text-gray-400"})})]}),r.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(X,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),r.jsxs(X,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[r.jsx(ra,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Xv,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Jg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),r.jsx(rc,{placeholder:"https://cli.im/group1\\nhttps://cli.im/group2",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 min-h-[120px] font-mono text-sm",value:t,onChange:y=>e(y.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),r.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[r.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),r.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` -`).filter(Boolean).length," 个"]})]}),r.jsxs(X,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),r.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[r.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),r.jsxs("div",{className:"space-y-3 text-sm",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),r.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接,群满后可直接在后台更换新群码,无需修改网站配置。微信原生群码7天失效。"})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),r.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const Ow={matchTypes:[{id:"partner",label:"创业合伙",matchLabel:"创业伙伴",icon:"⭐",matchFromDB:!0,showJoinAfterMatch:!1,price:1,enabled:!0},{id:"investor",label:"资源对接",matchLabel:"资源对接",icon:"👥",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"mentor",label:"导师顾问",matchLabel:"导师顾问",icon:"❤️",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"team",label:"团队招募",matchLabel:"加入项目",icon:"🎮",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}],freeMatchLimit:3,matchPrice:1,settings:{enableFreeMatches:!0,enablePaidMatches:!0,maxMatchesPerDay:10}},TV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function MV(){const[t,e]=b.useState(Ow),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),g=async()=>{s(!0);try{const E=await De("/api/db/config/full?key=match_config"),M=(E==null?void 0:E.data)??(E==null?void 0:E.config);M&&e({...Ow,...M})}catch(E){console.error("加载匹配配置失败:",E)}finally{s(!1)}};b.useEffect(()=>{g()},[]);const y=async()=>{i(!0);try{const E=await Nt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});E&&E.success!==!1?se.success("配置保存成功!"):se.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:"未知错误"))}catch(E){console.error("保存配置失败:",E),se.error("保存失败")}finally{i(!1)}},N=E=>{h(E),m({id:E.id,label:E.label,matchLabel:E.matchLabel,icon:E.icon,matchFromDB:E.matchFromDB,showJoinAfterMatch:E.showJoinAfterMatch,price:E.price,enabled:E.enabled}),c(!0)},j=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},v=()=>{if(!f.id||!f.label){se.error("请填写类型ID和名称");return}const E=[...t.matchTypes];if(u){const M=E.findIndex(P=>P.id===u.id);M!==-1&&(E[M]={...f})}else{if(E.some(M=>M.id===f.id)){se.error("类型ID已存在");return}E.push({...f})}e({...t,matchTypes:E}),c(!1)},k=E=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(M=>M.id!==E)})},C=E=>{e({...t,matchTypes:t.matchTypes.map(M=>M.id===E?{...M,enabled:!M.enabled}:M)})};return r.jsxs("div",{className:"p-8 w-full space-y-6",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Mo,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(X,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),r.jsxs(X,{onClick:y,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ti,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),r.jsxs(Te,{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:E=>e({...t,freeMatchLimit:parseInt(E.target.value,10)||0})}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:E=>e({...t,matchPrice:parseFloat(E.target.value)||1})}),r.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),r.jsx(re,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:E=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(E.target.value,10)||10}})}),r.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),r.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:t.settings.enableFreeMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enableFreeMatches:E}})}),r.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:t.settings.enablePaidMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enablePaidMatches:E}})}),r.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),r.jsxs(X,{onClick:j,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),r.jsx(Te,{children:r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"图标"}),r.jsx(we,{className:"text-gray-400",children:"类型ID"}),r.jsx(we,{className:"text-gray-400",children:"显示名称"}),r.jsx(we,{className:"text-gray-400",children:"匹配标签"}),r.jsx(we,{className:"text-gray-400",children:"价格"}),r.jsx(we,{className:"text-gray-400",children:"数据库匹配"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsx(ns,{children:t.matchTypes.map(E=>r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx("span",{className:"text-2xl",children:E.icon})}),r.jsx(ve,{className:"font-mono text-gray-300",children:E.id}),r.jsx(ve,{className:"text-white font-medium",children:E.label}),r.jsx(ve,{className:"text-gray-300",children:E.matchLabel}),r.jsx(ve,{children:r.jsxs(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",E.price]})}),r.jsx(ve,{children:E.matchFromDB?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),r.jsx(ve,{children:r.jsx(Ct,{checked:E.enabled,onCheckedChange:()=>C(E.id)})}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(E),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Vt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>k(E.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Yn,{className:"w-4 h-4"})})]})})]},E.id))})]})})]}),r.jsx(Rt,{open:o,onOpenChange:c,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[u?r.jsx(Vt,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(fn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:E=>m({...f,id:E.target.value}),disabled:!!u})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"图标"}),r.jsx("div",{className:"flex gap-1 flex-wrap",children:TV.map(E=>r.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===E?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:E}),children:E},E))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"显示名称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:E=>m({...f,label:E.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:E=>m({...f,matchLabel:E.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:E=>m({...f,price:parseFloat(E.target.value)||1})})]}),r.jsxs("div",{className:"flex gap-6 pt-2",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:f.matchFromDB,onCheckedChange:E=>m({...f,matchFromDB:E})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:f.showJoinAfterMatch,onCheckedChange:E=>m({...f,showJoinAfterMatch:E})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:f.enabled,onCheckedChange:E=>m({...f,enabled:E})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsxs(X,{onClick:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const Dw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function AV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null);async function N(){m(!0),y(null);try{const v=new URLSearchParams({page:String(a),pageSize:String(o)});u&&v.set("matchType",u);const k=await De(`/api/db/match-records?${v}`);k!=null&&k.success?(e(k.records||[]),s(k.total??0)):y("加载匹配记录失败")}catch(v){console.error("加载匹配记录失败",v),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{N()},[a,u]);const j=Math.ceil(n/o)||1;return r.jsxs("div",{className:"p-8 w-full",children:[g&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:g}),r.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("select",{value:u,onChange:v=>{h(v.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"",children:"全部类型"}),Object.entries(Dw).map(([v,k])=>r.jsx("option",{value:v,children:k},v))]}),r.jsxs("button",{type:"button",onClick:N,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx($e,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:f?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"匹配时间"})]})}),r.jsxs(ns,{children:[t.map(v=>r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[v.userAvatar?r.jsx("img",{src:v.userAvatar,alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const C=k.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,r.jsx("span",{className:v.userAvatar?"hidden":"",children:(v.userNickname||v.userId||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white",children:v.userNickname||v.userId}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.userId.slice(0,16),"..."]})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[v.matchedUserAvatar?r.jsx("img",{src:v.matchedUserAvatar,alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const C=k.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,r.jsx("span",{className:v.matchedUserAvatar?"hidden":"",children:(v.matchedNickname||v.matchedUserId||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white",children:v.matchedNickname||v.matchedUserId}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.matchedUserId.slice(0,16),"..."]})]})]})}),r.jsx(ve,{children:r.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Dw[v.matchType]||v.matchType})}),r.jsxs(ve,{className:"text-gray-400 text-sm",children:[v.phone&&r.jsxs("div",{children:["📱 ",v.phone]}),v.wechatId&&r.jsxs("div",{children:["💬 ",v.wechatId]}),!v.phone&&!v.wechatId&&"-"]}),r.jsx(ve,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleString():"-"})]},v.id)),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),r.jsx(zs,{page:a,totalPages:j,total:n,pageSize:o,onPageChange:i,onPageSizeChange:v=>{c(v),i(1)}})]})})})]})}function IV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0);async function a(){s(!0);try{const i=await De("/api/db/vip-members?limit=100");if(i!=null&&i.success&&i.data){const o=[...i.data].map((c,u)=>({...c,vipSort:typeof c.vipSort=="number"?c.vipSort:u+1}));o.sort((c,u)=>(c.vipSort??999999)-(u.vipSort??999999)),e(o)}}catch(i){console.error("Load VIP members error:",i),se.error("加载 VIP 成员失败")}finally{s(!1)}}return b.useEffect(()=>{a()},[]),r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("div",{className:"flex justify-between items-center mb-8",children:r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx($l,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400 w-20",children:"序号"}),r.jsx(we,{className:"text-gray-400",children:"成员"}),r.jsx(we,{className:"text-gray-400 w-40",children:"超级个体"}),r.jsx(we,{className:"text-gray-400 w-28",children:"排序值"})]})}),r.jsxs(ns,{children:[t.map((i,o)=>{var c;return r.jsxs(lt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:o+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?r.jsx("img",{src:i.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((c=i.name)==null?void 0:c[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:i.name})})]})}),r.jsx(ve,{className:"text-gray-300",children:i.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),r.jsx(ve,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function Q4(t){const[e,n]=b.useState([]),[s,a]=b.useState(!0),[i,o]=b.useState(!1),[c,u]=b.useState(null),[h,f]=b.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0}),[m,g]=b.useState(!1),[y,N]=b.useState(!1),j=b.useRef(null),v=async R=>{var ne;const O=(ne=R.target.files)==null?void 0:ne[0];if(O){N(!0);try{const ie=new FormData;ie.append("file",O),ie.append("folder","mentors");const _=Df(),ce={};_&&(ce.Authorization=`Bearer ${_}`);const z=await(await fetch(Lo("/api/upload"),{method:"POST",body:ie,credentials:"include",headers:ce})).json();z!=null&&z.success&&(z!=null&&z.url)?f(q=>({...q,avatar:z.url})):se.error("上传失败: "+((z==null?void 0:z.error)||"未知错误"))}catch(ie){console.error(ie),se.error("上传失败")}finally{N(!1),j.current&&(j.current.value="")}}};async function k(){a(!0);try{const R=await De("/api/db/mentors");R!=null&&R.success&&R.data&&n(R.data)}catch(R){console.error("Load mentors error:",R)}finally{a(!1)}}b.useEffect(()=>{k()},[]);const C=()=>{f({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:e.length>0?Math.max(...e.map(R=>R.sort))+1:0,enabled:!0})},E=()=>{u(null),C(),o(!0)},M=R=>{u(R),f({name:R.name,avatar:R.avatar||"",intro:R.intro||"",tags:R.tags||"",priceSingle:R.priceSingle!=null?String(R.priceSingle):"",priceHalfYear:R.priceHalfYear!=null?String(R.priceHalfYear):"",priceYear:R.priceYear!=null?String(R.priceYear):"",quote:R.quote||"",whyFind:R.whyFind||"",offering:R.offering||"",judgmentStyle:R.judgmentStyle||"",sort:R.sort,enabled:R.enabled??!0}),o(!0)},P=async()=>{if(!h.name.trim()){se.error("导师姓名不能为空");return}g(!0);try{const R=ne=>ne===""?void 0:parseFloat(ne),O={name:h.name.trim(),avatar:h.avatar.trim()||void 0,intro:h.intro.trim()||void 0,tags:h.tags.trim()||void 0,priceSingle:R(h.priceSingle),priceHalfYear:R(h.priceHalfYear),priceYear:R(h.priceYear),quote:h.quote.trim()||void 0,whyFind:h.whyFind.trim()||void 0,offering:h.offering.trim()||void 0,judgmentStyle:h.judgmentStyle.trim()||void 0,sort:h.sort,enabled:h.enabled};if(c){const ne=await Dt("/api/db/mentors",{id:c.id,...O});ne!=null&&ne.success?(o(!1),k()):se.error("更新失败: "+(ne==null?void 0:ne.error))}else{const ne=await Nt("/api/db/mentors",O);ne!=null&&ne.success?(o(!1),k()):se.error("新增失败: "+(ne==null?void 0:ne.error))}}catch(R){console.error("Save error:",R),se.error("保存失败")}finally{g(!1)}},H=async R=>{if(confirm("确定删除该导师?"))try{const O=await ea(`/api/db/mentors?id=${R}`);O!=null&&O.success?k():se.error("删除失败: "+(O==null?void 0:O.error))}catch(O){console.error("Delete error:",O),se.error("删除失败")}},L=R=>R!=null?`¥${R}`:"-";return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),r.jsxs(X,{onClick:E,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:s?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"姓名"}),r.jsx(we,{className:"text-gray-400",children:"简介"}),r.jsx(we,{className:"text-gray-400",children:"单次"}),r.jsx(we,{className:"text-gray-400",children:"半年"}),r.jsx(we,{className:"text-gray-400",children:"年度"}),r.jsx(we,{className:"text-gray-400",children:"排序"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(ns,{children:[e.map(R=>r.jsxs(lt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:R.id}),r.jsx(ve,{className:"text-white",children:R.name}),r.jsx(ve,{className:"text-gray-400 max-w-[200px] truncate",children:R.intro||"-"}),r.jsx(ve,{className:"text-gray-400",children:L(R.priceSingle)}),r.jsx(ve,{className:"text-gray-400",children:L(R.priceHalfYear)}),r.jsx(ve,{className:"text-gray-400",children:L(R.priceYear)}),r.jsx(ve,{className:"text-gray-400",children:R.sort}),r.jsxs(ve,{className:"text-right",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>M(R),className:"text-gray-400 hover:text-[#38bdac]",children:r.jsx(Vt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>H(R.id),className:"text-gray-400 hover:text-red-400",children:r.jsx(Yn,{className:"w-4 h-4"})})]})]},R.id)),e.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),r.jsx(Rt,{open:i,onOpenChange:o,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsx(Pt,{children:r.jsx(Ot,{className:"text-white",children:c?"编辑导师":"新增导师"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"姓名 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:h.name,onChange:R=>f(O=>({...O,name:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"排序"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:h.sort,onChange:R=>f(O=>({...O,sort:parseInt(R.target.value,10)||0}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"头像"}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:h.avatar,onChange:R=>f(O=>({...O,avatar:R.target.value})),placeholder:"点击上传或粘贴图片地址"}),r.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:v}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:y,onClick:()=>{var R;return(R=j.current)==null?void 0:R.click()},children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),y?"上传中...":"上传"]})]}),h.avatar&&r.jsx("div",{className:"mt-2",children:r.jsx("img",{src:h.avatar.startsWith("http")?h.avatar:Lo(h.avatar),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"简介"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:h.intro,onChange:R=>f(O=>({...O,intro:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:h.tags,onChange:R=>f(O=>({...O,tags:R.target.value}))})]}),r.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[r.jsx(Z,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:h.priceSingle,onChange:R=>f(O=>({...O,priceSingle:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:h.priceHalfYear,onChange:R=>f(O=>({...O,priceHalfYear:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:h.priceYear,onChange:R=>f(O=>({...O,priceYear:R.target.value}))})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"引言"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:h.quote,onChange:R=>f(O=>({...O,quote:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"为什么找(文本)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.whyFind,onChange:R=>f(O=>({...O,whyFind:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"提供什么(文本)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.offering,onChange:R=>f(O=>({...O,offering:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:h.judgmentStyle,onChange:R=>f(O=>({...O,judgmentStyle:R.target.value}))})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"enabled",checked:h.enabled,onChange:R=>f(O=>({...O,enabled:R.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),r.jsx(Z,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),r.jsxs(tn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>o(!1),className:"border-gray-600 text-gray-300",children:[r.jsx(hs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:P,disabled:m,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"}),m?"保存中...":"保存"]})]})]})})]})}function RV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState("");async function o(){s(!0);try{const h=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",f=await De(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{s(!1)}}b.useEffect(()=>{o()},[a]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Ah,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:a,onChange:h=>i(h.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[r.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>r.jsx("option",{value:h,children:f},h))]}),r.jsxs(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"用户ID"}),r.jsx(we,{className:"text-gray-400",children:"导师ID"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"创建时间"})]})}),r.jsxs(ns,{children:[t.map(h=>r.jsxs(lt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:h.id}),r.jsx(ve,{className:"text-gray-400",children:h.userId}),r.jsx(ve,{className:"text-gray-400",children:h.mentorId}),r.jsx(ve,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),r.jsxs(ve,{className:"text-white",children:["¥",h.amount]}),r.jsx(ve,{className:"text-gray-400",children:c[h.status]||h.status}),r.jsx(ve,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const id={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},Lw={matchTypes:[{id:"partner",label:"找伙伴",matchLabel:"找伙伴",icon:"⭐",matchFromDB:!0,showJoinAfterMatch:!1,price:1,enabled:!0},{id:"investor",label:"资源对接",matchLabel:"资源对接",icon:"👥",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"mentor",label:"导师顾问",matchLabel:"导师顾问",icon:"❤️",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"team",label:"团队招募",matchLabel:"加入项目",icon:"🎮",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}],freeMatchLimit:3,matchPrice:1,settings:{enableFreeMatches:!0,enablePaidMatches:!0,maxMatchesPerDay:10},poolSettings:id},PV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function OV(){const t=Ki(),[e,n]=b.useState(Lw),[s,a]=b.useState(!0),[i,o]=b.useState(!1),[c,u]=b.useState(!1),[h,f]=b.useState(null),[m,g]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,N]=b.useState(null),[j,v]=b.useState(!1),k=async()=>{v(!0);try{const O=await De("/api/db/match-pool-counts");O!=null&&O.success&&O.data&&N(O.data)}catch(O){console.error("加载池子人数失败:",O)}finally{v(!1)}},C=async()=>{a(!0);try{const O=await De("/api/db/config/full?key=match_config"),ne=(O==null?void 0:O.data)??(O==null?void 0:O.config);if(ne){let ie=ne.poolSettings??id;ie.poolSource&&!Array.isArray(ie.poolSource)&&(ie={...ie,poolSource:[ie.poolSource]}),n({...Lw,...ne,poolSettings:ie})}}catch(O){console.error("加载匹配配置失败:",O)}finally{a(!1)}};b.useEffect(()=>{C(),k()},[]);const E=async()=>{o(!0);try{const O=await Nt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});se.error((O==null?void 0:O.success)!==!1?"配置保存成功!":"保存失败: "+((O==null?void 0:O.error)||"未知错误"))}catch(O){console.error(O),se.error("保存失败")}finally{o(!1)}},M=O=>{f(O),g({...O}),u(!0)},P=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},H=()=>{if(!m.id||!m.label){se.error("请填写类型ID和名称");return}const O=[...e.matchTypes];if(h){const ne=O.findIndex(ie=>ie.id===h.id);ne!==-1&&(O[ne]={...m})}else{if(O.some(ne=>ne.id===m.id)){se.error("类型ID已存在");return}O.push({...m})}n({...e,matchTypes:O}),u(!1)},L=O=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(ne=>ne.id!==O)})},R=O=>{n({...e,matchTypes:e.matchTypes.map(ne=>ne.id===O?{...ne,enabled:!ne.enabled}:ne)})};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex justify-end gap-3",children:[r.jsxs(X,{variant:"outline",onClick:C,disabled:s,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:E,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(lj,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),r.jsx(Lt,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),r.jsxs(Te,{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配来源池"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{value:"vip",label:"超级个体(VIP会员)",desc:"付费 ¥1980 的VIP会员",icon:"👑",countKey:"vip"},{value:"complete",label:"完善资料用户",desc:"符合下方完善度要求的用户",icon:"✅",countKey:"complete"},{value:"all",label:"全部用户",desc:"所有已注册用户",icon:"👥",countKey:"all"}].map(O=>{const ne=e.poolSettings??id,_=(Array.isArray(ne.poolSource)?ne.poolSource:[ne.poolSource]).includes(O.value),ce=y==null?void 0:y[O.countKey],pe=()=>{const z=Array.isArray(ne.poolSource)?[...ne.poolSource]:[ne.poolSource],q=_?z.filter(F=>F!==O.value):[...z,O.value];q.length===0&&q.push(O.value),n({...e,poolSettings:{...ne,poolSource:q}})};return r.jsxs("button",{type:"button",onClick:pe,className:`p-4 rounded-lg border text-left transition-all ${_?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${_?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:_&&"✓"}),r.jsx("span",{className:"text-xl",children:O.icon}),r.jsx("span",{className:`text-sm font-medium ${_?"text-[#38bdac]":"text-gray-300"}`,children:O.label})]}),r.jsxs("span",{className:"text-lg font-bold text-white",children:[j?"...":ce??"-",r.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),r.jsx("p",{className:"text-gray-500 text-xs mt-2",children:O.desc}),r.jsx("span",{role:"link",tabIndex:0,onClick:z=>{z.stopPropagation(),t(`/users?pool=${O.value}`)},onKeyDown:z=>{z.key==="Enter"&&(z.stopPropagation(),t(`/users?pool=${O.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},O.value)})})]}),r.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[r.jsx(Z,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{key:"requirePhone",label:"有手机号",icon:"📱"},{key:"requireNickname",label:"有昵称",icon:"👤"},{key:"requireAvatar",label:"有头像",icon:"🖼️"},{key:"requireBusiness",label:"有业务需求",icon:"💼"}].map(O=>{const ie=(e.poolSettings??id)[O.key];return r.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[r.jsx(Ct,{checked:ie,onCheckedChange:_=>n({...e,poolSettings:{...e.poolSettings??id,[O.key]:_}})}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{children:O.icon}),r.jsx(Z,{className:"text-gray-300 text-sm",children:O.label})]})]},O.key)})})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Ti,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),r.jsxs(Te,{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:O=>n({...e,freeMatchLimit:parseInt(O.target.value,10)||0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:O=>n({...e,matchPrice:parseFloat(O.target.value)||1})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),r.jsx(re,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:O=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(O.target.value,10)||10}})})]})]}),r.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:e.settings.enableFreeMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enableFreeMatches:O}})}),r.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:e.settings.enablePaidMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enablePaidMatches:O}})}),r.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),r.jsx(Lt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),r.jsxs(X,{onClick:P,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),r.jsx(Te,{children:r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"图标"}),r.jsx(we,{className:"text-gray-400",children:"类型ID"}),r.jsx(we,{className:"text-gray-400",children:"显示名称"}),r.jsx(we,{className:"text-gray-400",children:"匹配标签"}),r.jsx(we,{className:"text-gray-400",children:"价格"}),r.jsx(we,{className:"text-gray-400",children:"数据库匹配"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsx(ns,{children:e.matchTypes.map(O=>r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx("span",{className:"text-2xl",children:O.icon})}),r.jsx(ve,{className:"font-mono text-gray-300",children:O.id}),r.jsx(ve,{className:"text-white font-medium",children:O.label}),r.jsx(ve,{className:"text-gray-300",children:O.matchLabel}),r.jsx(ve,{children:r.jsxs(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",O.price]})}),r.jsx(ve,{children:O.matchFromDB?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),r.jsx(ve,{children:r.jsx(Ct,{checked:O.enabled,onCheckedChange:()=>R(O.id)})}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>M(O),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Vt,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>L(O.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Yn,{className:"w-4 h-4"})})]})})]},O.id))})]})})]}),r.jsx(Rt,{open:c,onOpenChange:u,children:r.jsxs(St,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[r.jsx(Pt,{children:r.jsxs(Ot,{className:"text-white flex items-center gap-2",children:[h?r.jsx(Vt,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(fn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:O=>g({...m,id:O.target.value}),disabled:!!h})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"图标"}),r.jsx("div",{className:"flex gap-1 flex-wrap",children:PV.map(O=>r.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===O?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:O}),children:O},O))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"显示名称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:O=>g({...m,label:O.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:O=>g({...m,matchLabel:O.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:O=>g({...m,price:parseFloat(O.target.value)||1})})]}),r.jsxs("div",{className:"flex gap-6 pt-2",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:m.matchFromDB,onCheckedChange:O=>g({...m,matchFromDB:O})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:m.showJoinAfterMatch,onCheckedChange:O=>g({...m,showJoinAfterMatch:O})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ct,{checked:m.enabled,onCheckedChange:O=>g({...m,enabled:O})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),r.jsxs(tn,{children:[r.jsx(X,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsxs(X,{onClick:H,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const _w={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function DV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null),[N,j]=b.useState(null);async function v(){m(!0),y(null);try{const E=new URLSearchParams({page:String(a),pageSize:String(o)});u&&E.set("matchType",u);const M=await De(`/api/db/match-records?${E}`);M!=null&&M.success?(e(M.records||[]),s(M.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{v()},[a,u]);const k=Math.ceil(n/o)||1,C=({userId:E,nickname:M,avatar:P})=>r.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>j(E),children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[P?r.jsx("img",{src:P,alt:"",className:"w-full h-full object-cover",onError:H=>{H.currentTarget.style.display="none"}}):null,r.jsx("span",{className:P?"hidden":"",children:(M||E||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:M||E}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[E==null?void 0:E.slice(0,16),(E==null?void 0:E.length)>16?"...":""]})]})]});return r.jsxs("div",{children:[g&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:g}),r.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("select",{value:u,onChange:E=>{h(E.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"",children:"全部类型"}),Object.entries(_w).map(([E,M])=>r.jsx("option",{value:E,children:M},E))]}),r.jsxs("button",{type:"button",onClick:v,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx($e,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:f?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"匹配时间"})]})}),r.jsxs(ns,{children:[t.map(E=>r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx(C,{userId:E.userId,nickname:E.userNickname,avatar:E.userAvatar})}),r.jsx(ve,{children:E.matchedUserId?r.jsx(C,{userId:E.matchedUserId,nickname:E.matchedNickname,avatar:E.matchedUserAvatar}):r.jsx("span",{className:"text-gray-500",children:"—"})}),r.jsx(ve,{children:r.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:_w[E.matchType]||E.matchType})}),r.jsxs(ve,{className:"text-sm",children:[E.phone&&r.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&r.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&r.jsx("span",{className:"text-gray-600",children:"-"})]}),r.jsx(ve,{className:"text-gray-400",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"})]},E.id)),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),r.jsx(zs,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})}),r.jsx(y0,{open:!!N,onClose:()=>j(null),userId:N,onUserUpdated:v})]})}function LV(){const[t,e]=b.useState("records");return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>e("records"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="records"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配记录"}),r.jsx("button",{type:"button",onClick:()=>e("pool"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="pool"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配池设置"})]}),t==="records"&&r.jsx(DV,{}),t==="pool"&&r.jsx(OV,{})]})}const zw={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function _V(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0),[f,m]=b.useState("investor"),[g,y]=b.useState(null);async function N(){h(!0);try{const C=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),E=await De(`/api/db/match-records?${C}`);E!=null&&E.success&&(e(E.records||[]),s(E.total??0))}catch(C){console.error(C)}finally{h(!1)}}b.useEffect(()=>{N()},[a,f]);const j=async C=>{if(!C.phone&&!C.wechatId){se.info("该记录无联系方式,无法推送到存客宝");return}y(C.id);try{const E=await Nt("/api/ckb/join",{type:C.matchType||"investor",phone:C.phone||"",wechat:C.wechatId||"",userId:C.userId,name:C.userNickname||""});se.error((E==null?void 0:E.message)||(E!=null&&E.success?"推送成功":"推送失败"))}catch(E){se.error("推送失败: "+(E instanceof Error?E.message:"网络错误"))}finally{y(null)}},v=Math.ceil(n/o)||1,k=C=>!!(C.phone||C.wechatId);return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),r.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("select",{value:f,onChange:C=>{m(C.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(zw).map(([C,E])=>r.jsx("option",{value:C,children:E},C))}),r.jsxs(X,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:u?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"时间"}),r.jsx(we,{className:"text-gray-400 text-right",children:"操作"})]})}),r.jsxs(ns,{children:[t.map(C=>{var E,M;return r.jsxs(lt,{className:`border-gray-700/50 ${k(C)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[r.jsx(ve,{className:"text-white",children:C.userNickname||((E=C.userId)==null?void 0:E.slice(0,12))}),r.jsx(ve,{className:"text-white",children:C.matchedNickname||((M=C.matchedUserId)==null?void 0:M.slice(0,12))}),r.jsx(ve,{children:r.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:zw[C.matchType]||C.matchType})}),r.jsxs(ve,{className:"text-sm",children:[C.phone&&r.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&r.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&r.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),r.jsx(ve,{className:"text-gray-400 text-sm",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"}),r.jsx(ve,{className:"text-right",children:k(C)?r.jsxs(X,{size:"sm",onClick:()=>j(C),disabled:g===C.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[r.jsx(M5,{className:"w-3 h-3 mr-1"}),g===C.id?"推送中...":"推送CKB"]}):r.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},C.id)}),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),r.jsx(zs,{page:a,totalPages:v,total:n,pageSize:o,onPageChange:i,onPageSizeChange:C=>{c(C),i(1)}})]})})})]})}const $w={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},zV={single:"单次",half_year:"半年",year:"年度"};function $V(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState("");async function o(){s(!0);try{const c=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",u=await De(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{s(!1)}}return b.useEffect(()=>{o()},[a]),r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:a,onChange:c=>i(c.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[r.jsx("option",{value:"",children:"全部状态"}),Object.entries($w).map(([c,u])=>r.jsx("option",{value:c,children:u},c))]}),r.jsxs(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"用户ID"}),r.jsx(we,{className:"text-gray-400",children:"导师ID"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"创建时间"})]})}),r.jsxs(ns,{children:[t.map(c=>r.jsxs(lt,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:c.id}),r.jsx(ve,{className:"text-gray-400",children:c.userId}),r.jsx(ve,{className:"text-gray-400",children:c.mentorId}),r.jsx(ve,{className:"text-gray-400",children:zV[c.consultationType]||c.consultationType}),r.jsxs(ve,{className:"text-white",children:["¥",c.amount]}),r.jsx(ve,{className:"text-gray-400",children:$w[c.status]||c.status}),r.jsx(ve,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function FV(){const[t,e]=b.useState("booking");return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>e("booking"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="booking"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"预约记录"}),r.jsx("button",{type:"button",onClick:()=>e("manage"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="manage"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"导师管理"})]}),t==="booking"&&r.jsx($V,{}),t==="manage"&&r.jsx("div",{className:"-mx-8",children:r.jsx(Q4,{embedded:!0})})]})}function BV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0);async function f(){h(!0);try{const g=new URLSearchParams({page:String(a),pageSize:String(o),matchType:"team"}),y=await De(`/api/db/match-records?${g}`);y!=null&&y.success&&(e(y.records||[]),s(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}b.useEffect(()=>{f()},[a]);const m=Math.ceil(n/o)||1;return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("div",{children:[r.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),r.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),r.jsxs("button",{type:"button",onClick:f,disabled:u,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx($e,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:u?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx($e,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(es,{children:[r.jsx(ts,{children:r.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(ns,{children:[t.map(g=>r.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-white",children:g.userNickname||g.userId}),r.jsx(ve,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),r.jsxs(ve,{className:"text-gray-400 text-sm",children:[g.phone&&r.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&r.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),r.jsx(ve,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&r.jsx(lt,{children:r.jsx(ve,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),r.jsx(zs,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:g=>{c(g),i(1)}})]})})})]})}const Fw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"},Bw={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮"};function VV({onSwitchTab:t,onOpenCKB:e}={}){const n=Ki(),[s,a]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!0),h=b.useCallback(async()=>{var m,g;u(!0);try{const[y,N]=await Promise.allSettled([De("/api/db/match-records?stats=true"),De("/api/db/ckb-plan-stats")]);if(y.status==="fulfilled"&&((m=y.value)!=null&&m.success)&&y.value.data){let j=y.value.data;if(j.totalMatches>0&&(!j.uniqueUsers||j.uniqueUsers===0))try{const v=await De("/api/db/match-records?page=1&pageSize=200");if(v!=null&&v.success&&v.records){const k=new Set(v.records.map(C=>C.userId).filter(Boolean));j={...j,uniqueUsers:k.size}}}catch{}a(j)}N.status==="fulfilled"&&((g=N.value)!=null&&g.success)&&N.value.data&&o(N.value.data)}catch(y){console.error("加载统计失败:",y)}finally{u(!1)}},[]);b.useEffect(()=>{h()},[h]);const f=m=>c?"—":String(m??0);return r.jsxs("div",{className:"space-y-8",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"})," 找伙伴数据"]}),r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",children:[r.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-[#38bdac]/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"总匹配次数"}),r.jsx("p",{className:"text-4xl font-bold text-white",children:f(s==null?void 0:s.totalMatches)}),r.jsxs("p",{className:"text-[#38bdac] text-xs mt-3 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," 查看匹配记录"]})]})}),r.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-yellow-500/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"今日匹配"}),r.jsx("p",{className:"text-4xl font-bold text-white",children:f(s==null?void 0:s.todayMatches)}),r.jsxs("p",{className:"text-yellow-400/60 text-xs mt-3 flex items-center gap-1",children:[r.jsx(Ti,{className:"w-3 h-3"})," 今日实时"]})]})}),r.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-blue-500/60 transition-all",onClick:()=>n("/users"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"匹配用户数"}),r.jsx("p",{className:"text-4xl font-bold text-white",children:f(s==null?void 0:s.uniqueUsers)}),r.jsxs("p",{className:"text-blue-400/60 text-xs mt-3 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," 查看用户管理"]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"人均匹配"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":s!=null&&s.uniqueUsers?(s.totalMatches/s.uniqueUsers).toFixed(1):"0"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"付费匹配次数"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:f(s==null?void 0:s.paidMatchCount)})]})})]})]}),(s==null?void 0:s.byType)&&s.byType.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"各类型匹配分布"}),r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:s.byType.map(m=>{const g=s.totalMatches>0?m.count/s.totalMatches*100:0;return r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/40 rounded-xl p-5",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx("span",{className:"text-2xl",children:Bw[m.matchType]||"📊"}),r.jsx("span",{className:"text-gray-300 font-medium",children:Fw[m.matchType]||m.matchType})]}),r.jsx("p",{className:"text-3xl font-bold text-white mb-2",children:m.count}),r.jsx("div",{className:"w-full h-2 bg-gray-700/50 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full transition-all",style:{width:`${Math.min(g,100)}%`}})}),r.jsxs("p",{className:"text-gray-500 text-xs mt-1.5",children:[g.toFixed(1),"%"]})]},m.matchType)})})]}),r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[r.jsx(Ir,{className:"w-5 h-5 text-orange-400"})," AI 获客数据"]}),r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5 mb-6",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"已提交线索"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(i==null?void 0:i.ckbTotal)??0}),r.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("contact"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"有联系方式"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(i==null?void 0:i.withContact)??0}),r.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("test"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"AI 添加进度"}),r.jsx("p",{className:"text-xl font-bold text-orange-400",children:"查看详情 →"}),r.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"添加成功率 · 回复率 · API 文档"})]})})]}),(i==null?void 0:i.byType)&&i.byType.length>0&&r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:i.byType.map(m=>r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-lg p-4 flex items-center gap-3",children:[r.jsx("span",{className:"text-xl",children:Bw[m.matchType]||"📋"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-xs",children:Fw[m.matchType]||m.matchType}),r.jsx("p",{className:"text-xl font-bold text-white",children:m.total})]})]},m.matchType))})]})]})}const HV=["partner","investor","mentor","team"],zg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Vw=`# 场景获客接口摘要 +`).map(j=>j.trim()).filter(Boolean),N=[...o.liveQRCodes||[]];N[0]?N[0].urls=y:N.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Nt("/api/db/config",{key:"live_qr_codes",value:N,description:"群活码配置"}),te.success("群活码配置已保存!"),await u()}catch(y){console.error(y),te.error("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await Nt("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),te.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(N){console.error(N),te.error("保存失败: "+(N instanceof Error?N.message:String(N)))}},g=()=>{n?window.open(n,"_blank"):te.error("请先配置微信群链接")};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"mb-8",children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),r.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),r.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(aj,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),r.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[r.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),r.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[r.jsx("li",{children:"访问草料二维码创建活码"}),r.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),r.jsx("li",{children:"复制生成的短链接填入下方配置"}),r.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),r.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),r.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[r.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),r.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),r.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意:微信原生群二维码7天后失效,建议使用草料活码"})]})]})]})}),r.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-[#07C160] flex items-center gap-2",children:[r.jsx(Xv,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),r.jsx(Ft,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Jg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(re,{placeholder:"https://cli.im/xxxxx 或 https://weixin.qq.com/g/...",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",value:n,onChange:y=>s(y.target.value)}),r.jsx(X,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?r.jsx(Of,{className:"w-4 h-4 text-green-500"}):r.jsx(s0,{className:"w-4 h-4 text-gray-400"})})]}),r.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(X,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),r.jsxs(X,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[r.jsx(ra,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Xv,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),r.jsxs(Te,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[r.jsx(Jg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),r.jsx(rc,{placeholder:"https://cli.im/group1\\nhttps://cli.im/group2",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 min-h-[120px] font-mono text-sm",value:t,onChange:y=>e(y.target.value)}),r.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),r.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[r.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),r.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` +`).filter(Boolean).length," 个"]})]}),r.jsxs(X,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),r.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[r.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),r.jsxs("div",{className:"space-y-3 text-sm",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),r.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接,群满后可直接在后台更换新群码,无需修改网站配置。微信原生群码7天失效。"})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),r.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const Ow={matchTypes:[{id:"partner",label:"创业合伙",matchLabel:"创业伙伴",icon:"⭐",matchFromDB:!0,showJoinAfterMatch:!1,price:1,enabled:!0},{id:"investor",label:"资源对接",matchLabel:"资源对接",icon:"👥",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"mentor",label:"导师顾问",matchLabel:"导师顾问",icon:"❤️",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"team",label:"团队招募",matchLabel:"加入项目",icon:"🎮",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}],freeMatchLimit:3,matchPrice:1,settings:{enableFreeMatches:!0,enablePaidMatches:!0,maxMatchesPerDay:10}},TV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function MV(){const[t,e]=b.useState(Ow),[n,s]=b.useState(!0),[a,i]=b.useState(!1),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),g=async()=>{s(!0);try{const E=await De("/api/db/config/full?key=match_config"),M=(E==null?void 0:E.data)??(E==null?void 0:E.config);M&&e({...Ow,...M})}catch(E){console.error("加载匹配配置失败:",E)}finally{s(!1)}};b.useEffect(()=>{g()},[]);const y=async()=>{i(!0);try{const E=await Nt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});E&&E.success!==!1?te.success("配置保存成功!"):te.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:"未知错误"))}catch(E){console.error("保存配置失败:",E),te.error("保存失败")}finally{i(!1)}},N=E=>{h(E),m({id:E.id,label:E.label,matchLabel:E.matchLabel,icon:E.icon,matchFromDB:E.matchFromDB,showJoinAfterMatch:E.showJoinAfterMatch,price:E.price,enabled:E.enabled}),c(!0)},j=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},v=()=>{if(!f.id||!f.label){te.error("请填写类型ID和名称");return}const E=[...t.matchTypes];if(u){const M=E.findIndex(P=>P.id===u.id);M!==-1&&(E[M]={...f})}else{if(E.some(M=>M.id===f.id)){te.error("类型ID已存在");return}E.push({...f})}e({...t,matchTypes:E}),c(!1)},k=E=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(M=>M.id!==E)})},C=E=>{e({...t,matchTypes:t.matchTypes.map(M=>M.id===E?{...M,enabled:!M.enabled}:M)})};return r.jsxs("div",{className:"p-8 w-full space-y-6",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Mo,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(X,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),r.jsxs(X,{onClick:y,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Fa,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),r.jsxs(Te,{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:E=>e({...t,freeMatchLimit:parseInt(E.target.value,10)||0})}),r.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:E=>e({...t,matchPrice:parseFloat(E.target.value)||1})}),r.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),r.jsx(re,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:E=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(E.target.value,10)||10}})}),r.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),r.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:t.settings.enableFreeMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enableFreeMatches:E}})}),r.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:t.settings.enablePaidMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enablePaidMatches:E}})}),r.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),r.jsxs(X,{onClick:j,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),r.jsx(Te,{children:r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"图标"}),r.jsx(we,{className:"text-gray-400",children:"类型ID"}),r.jsx(we,{className:"text-gray-400",children:"显示名称"}),r.jsx(we,{className:"text-gray-400",children:"匹配标签"}),r.jsx(we,{className:"text-gray-400",children:"价格"}),r.jsx(we,{className:"text-gray-400",children:"数据库匹配"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsx(as,{children:t.matchTypes.map(E=>r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx("span",{className:"text-2xl",children:E.icon})}),r.jsx(ve,{className:"font-mono text-gray-300",children:E.id}),r.jsx(ve,{className:"text-white font-medium",children:E.label}),r.jsx(ve,{className:"text-gray-300",children:E.matchLabel}),r.jsx(ve,{children:r.jsxs(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",E.price]})}),r.jsx(ve,{children:E.matchFromDB?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),r.jsx(ve,{children:r.jsx(jt,{checked:E.enabled,onCheckedChange:()=>C(E.id)})}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>N(E),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>k(E.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Zn,{className:"w-4 h-4"})})]})})]},E.id))})]})})]}),r.jsx(It,{open:o,onOpenChange:c,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[u?r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(fn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:E=>m({...f,id:E.target.value}),disabled:!!u})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"图标"}),r.jsx("div",{className:"flex gap-1 flex-wrap",children:TV.map(E=>r.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===E?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:E}),children:E},E))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"显示名称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:E=>m({...f,label:E.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:E=>m({...f,matchLabel:E.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:E=>m({...f,price:parseFloat(E.target.value)||1})})]}),r.jsxs("div",{className:"flex gap-6 pt-2",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:f.matchFromDB,onCheckedChange:E=>m({...f,matchFromDB:E})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:f.showJoinAfterMatch,onCheckedChange:E=>m({...f,showJoinAfterMatch:E})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:f.enabled,onCheckedChange:E=>m({...f,enabled:E})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsxs(X,{onClick:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const Dw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function AV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null);async function N(){m(!0),y(null);try{const v=new URLSearchParams({page:String(a),pageSize:String(o)});u&&v.set("matchType",u);const k=await De(`/api/db/match-records?${v}`);k!=null&&k.success?(e(k.records||[]),s(k.total??0)):y("加载匹配记录失败")}catch(v){console.error("加载匹配记录失败",v),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{N()},[a,u]);const j=Math.ceil(n/o)||1;return r.jsxs("div",{className:"p-8 w-full",children:[g&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:g}),r.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),r.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("select",{value:u,onChange:v=>{h(v.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"",children:"全部类型"}),Object.entries(Dw).map(([v,k])=>r.jsx("option",{value:v,children:k},v))]}),r.jsxs("button",{type:"button",onClick:N,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx(Fe,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:f?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"匹配时间"})]})}),r.jsxs(as,{children:[t.map(v=>r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[v.userAvatar?r.jsx("img",{src:v.userAvatar,alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const C=k.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,r.jsx("span",{className:v.userAvatar?"hidden":"",children:(v.userNickname||v.userId||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white",children:v.userNickname||v.userId}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.userId.slice(0,16),"..."]})]})]})}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[v.matchedUserAvatar?r.jsx("img",{src:v.matchedUserAvatar,alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const C=k.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,r.jsx("span",{className:v.matchedUserAvatar?"hidden":"",children:(v.matchedNickname||v.matchedUserId||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white",children:v.matchedNickname||v.matchedUserId}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.matchedUserId.slice(0,16),"..."]})]})]})}),r.jsx(ve,{children:r.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Dw[v.matchType]||v.matchType})}),r.jsxs(ve,{className:"text-gray-400 text-sm",children:[v.phone&&r.jsxs("div",{children:["📱 ",v.phone]}),v.wechatId&&r.jsxs("div",{children:["💬 ",v.wechatId]}),!v.phone&&!v.wechatId&&"-"]}),r.jsx(ve,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleString():"-"})]},v.id)),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),r.jsx(Fs,{page:a,totalPages:j,total:n,pageSize:o,onPageChange:i,onPageSizeChange:v=>{c(v),i(1)}})]})})})]})}function IV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0);async function a(){s(!0);try{const i=await De("/api/db/vip-members?limit=100");if(i!=null&&i.success&&i.data){const o=[...i.data].map((c,u)=>({...c,vipSort:typeof c.vipSort=="number"?c.vipSort:u+1}));o.sort((c,u)=>(c.vipSort??999999)-(u.vipSort??999999)),e(o)}}catch(i){console.error("Load VIP members error:",i),te.error("加载 VIP 成员失败")}finally{s(!1)}}return b.useEffect(()=>{a()},[]),r.jsxs("div",{className:"p-8 w-full",children:[r.jsx("div",{className:"flex justify-between items-center mb-8",children:r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Fl,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400 w-20",children:"序号"}),r.jsx(we,{className:"text-gray-400",children:"成员"}),r.jsx(we,{className:"text-gray-400 w-40",children:"超级个体"}),r.jsx(we,{className:"text-gray-400 w-28",children:"排序值"})]})}),r.jsxs(as,{children:[t.map((i,o)=>{var c;return r.jsxs(it,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:o+1}),r.jsx(ve,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?r.jsx("img",{src:i.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((c=i.name)==null?void 0:c[0])||"创"}),r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"text-white text-sm truncate",children:i.name})})]})}),r.jsx(ve,{className:"text-gray-300",children:i.vipRole||r.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),r.jsx(ve,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function Q4(t){const[e,n]=b.useState([]),[s,a]=b.useState(!0),[i,o]=b.useState(!1),[c,u]=b.useState(null),[h,f]=b.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0}),[m,g]=b.useState(!1),[y,N]=b.useState(!1),j=b.useRef(null),v=async R=>{var se;const O=(se=R.target.files)==null?void 0:se[0];if(O){N(!0);try{const ie=new FormData;ie.append("file",O),ie.append("folder","mentors");const z=Df(),ce={};z&&(ce.Authorization=`Bearer ${z}`);const _=await(await fetch(Lo("/api/upload"),{method:"POST",body:ie,credentials:"include",headers:ce})).json();_!=null&&_.success&&(_!=null&&_.url)?f(G=>({...G,avatar:_.url})):te.error("上传失败: "+((_==null?void 0:_.error)||"未知错误"))}catch(ie){console.error(ie),te.error("上传失败")}finally{N(!1),j.current&&(j.current.value="")}}};async function k(){a(!0);try{const R=await De("/api/db/mentors");R!=null&&R.success&&R.data&&n(R.data)}catch(R){console.error("Load mentors error:",R)}finally{a(!1)}}b.useEffect(()=>{k()},[]);const C=()=>{f({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:e.length>0?Math.max(...e.map(R=>R.sort))+1:0,enabled:!0})},E=()=>{u(null),C(),o(!0)},M=R=>{u(R),f({name:R.name,avatar:R.avatar||"",intro:R.intro||"",tags:R.tags||"",priceSingle:R.priceSingle!=null?String(R.priceSingle):"",priceHalfYear:R.priceHalfYear!=null?String(R.priceHalfYear):"",priceYear:R.priceYear!=null?String(R.priceYear):"",quote:R.quote||"",whyFind:R.whyFind||"",offering:R.offering||"",judgmentStyle:R.judgmentStyle||"",sort:R.sort,enabled:R.enabled??!0}),o(!0)},P=async()=>{if(!h.name.trim()){te.error("导师姓名不能为空");return}g(!0);try{const R=se=>se===""?void 0:parseFloat(se),O={name:h.name.trim(),avatar:h.avatar.trim()||void 0,intro:h.intro.trim()||void 0,tags:h.tags.trim()||void 0,priceSingle:R(h.priceSingle),priceHalfYear:R(h.priceHalfYear),priceYear:R(h.priceYear),quote:h.quote.trim()||void 0,whyFind:h.whyFind.trim()||void 0,offering:h.offering.trim()||void 0,judgmentStyle:h.judgmentStyle.trim()||void 0,sort:h.sort,enabled:h.enabled};if(c){const se=await Ot("/api/db/mentors",{id:c.id,...O});se!=null&&se.success?(o(!1),k()):te.error("更新失败: "+(se==null?void 0:se.error))}else{const se=await Nt("/api/db/mentors",O);se!=null&&se.success?(o(!1),k()):te.error("新增失败: "+(se==null?void 0:se.error))}}catch(R){console.error("Save error:",R),te.error("保存失败")}finally{g(!1)}},H=async R=>{if(confirm("确定删除该导师?"))try{const O=await ea(`/api/db/mentors?id=${R}`);O!=null&&O.success?k():te.error("删除失败: "+(O==null?void 0:O.error))}catch(O){console.error("Delete error:",O),te.error("删除失败")}},L=R=>R!=null?`¥${R}`:"-";return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),r.jsxs(X,{onClick:E,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:s?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"姓名"}),r.jsx(we,{className:"text-gray-400",children:"简介"}),r.jsx(we,{className:"text-gray-400",children:"单次"}),r.jsx(we,{className:"text-gray-400",children:"半年"}),r.jsx(we,{className:"text-gray-400",children:"年度"}),r.jsx(we,{className:"text-gray-400",children:"排序"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsxs(as,{children:[e.map(R=>r.jsxs(it,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:R.id}),r.jsx(ve,{className:"text-white",children:R.name}),r.jsx(ve,{className:"text-gray-400 max-w-[200px] truncate",children:R.intro||"-"}),r.jsx(ve,{className:"text-gray-400",children:L(R.priceSingle)}),r.jsx(ve,{className:"text-gray-400",children:L(R.priceHalfYear)}),r.jsx(ve,{className:"text-gray-400",children:L(R.priceYear)}),r.jsx(ve,{className:"text-gray-400",children:R.sort}),r.jsxs(ve,{className:"text-right",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>M(R),className:"text-gray-400 hover:text-[#38bdac]",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>H(R.id),className:"text-gray-400 hover:text-red-400",children:r.jsx(Zn,{className:"w-4 h-4"})})]})]},R.id)),e.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),r.jsx(It,{open:i,onOpenChange:o,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsx(Rt,{children:r.jsx(Pt,{className:"text-white",children:c?"编辑导师":"新增导师"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"姓名 *"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:h.name,onChange:R=>f(O=>({...O,name:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"排序"}),r.jsx(re,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:h.sort,onChange:R=>f(O=>({...O,sort:parseInt(R.target.value,10)||0}))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"头像"}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx(re,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:h.avatar,onChange:R=>f(O=>({...O,avatar:R.target.value})),placeholder:"点击上传或粘贴图片地址"}),r.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:v}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:y,onClick:()=>{var R;return(R=j.current)==null?void 0:R.click()},children:[r.jsx(Rh,{className:"w-4 h-4 mr-2"}),y?"上传中...":"上传"]})]}),h.avatar&&r.jsx("div",{className:"mt-2",children:r.jsx("img",{src:h.avatar.startsWith("http")?h.avatar:Lo(h.avatar),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"简介"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:h.intro,onChange:R=>f(O=>({...O,intro:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:h.tags,onChange:R=>f(O=>({...O,tags:R.target.value}))})]}),r.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[r.jsx(Z,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:h.priceSingle,onChange:R=>f(O=>({...O,priceSingle:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:h.priceHalfYear,onChange:R=>f(O=>({...O,priceHalfYear:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),r.jsx(re,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:h.priceYear,onChange:R=>f(O=>({...O,priceYear:R.target.value}))})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"引言"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:h.quote,onChange:R=>f(O=>({...O,quote:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"为什么找(文本)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.whyFind,onChange:R=>f(O=>({...O,whyFind:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"提供什么(文本)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.offering,onChange:R=>f(O=>({...O,offering:R.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:h.judgmentStyle,onChange:R=>f(O=>({...O,judgmentStyle:R.target.value}))})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"enabled",checked:h.enabled,onChange:R=>f(O=>({...O,enabled:R.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),r.jsx(Z,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),r.jsxs(sn,{children:[r.jsxs(X,{variant:"outline",onClick:()=>o(!1),className:"border-gray-600 text-gray-300",children:[r.jsx(gs,{className:"w-4 h-4 mr-2"}),"取消"]}),r.jsxs(X,{onClick:P,disabled:m,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"}),m?"保存中...":"保存"]})]})]})})]})}function RV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState("");async function o(){s(!0);try{const h=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",f=await De(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{s(!1)}}b.useEffect(()=>{o()},[a]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex justify-between items-center mb-8",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(Ah,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:a,onChange:h=>i(h.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[r.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>r.jsx("option",{value:h,children:f},h))]}),r.jsxs(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"用户ID"}),r.jsx(we,{className:"text-gray-400",children:"导师ID"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"创建时间"})]})}),r.jsxs(as,{children:[t.map(h=>r.jsxs(it,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:h.id}),r.jsx(ve,{className:"text-gray-400",children:h.userId}),r.jsx(ve,{className:"text-gray-400",children:h.mentorId}),r.jsx(ve,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),r.jsxs(ve,{className:"text-white",children:["¥",h.amount]}),r.jsx(ve,{className:"text-gray-400",children:c[h.status]||h.status}),r.jsx(ve,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const id={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},Lw={matchTypes:[{id:"partner",label:"找伙伴",matchLabel:"找伙伴",icon:"⭐",matchFromDB:!0,showJoinAfterMatch:!1,price:1,enabled:!0},{id:"investor",label:"资源对接",matchLabel:"资源对接",icon:"👥",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"mentor",label:"导师顾问",matchLabel:"导师顾问",icon:"❤️",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"team",label:"团队招募",matchLabel:"加入项目",icon:"🎮",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}],freeMatchLimit:3,matchPrice:1,settings:{enableFreeMatches:!0,enablePaidMatches:!0,maxMatchesPerDay:10},poolSettings:id},PV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function OV(){const t=Ki(),[e,n]=b.useState(Lw),[s,a]=b.useState(!0),[i,o]=b.useState(!1),[c,u]=b.useState(!1),[h,f]=b.useState(null),[m,g]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,N]=b.useState(null),[j,v]=b.useState(!1),k=async()=>{v(!0);try{const O=await De("/api/db/match-pool-counts");O!=null&&O.success&&O.data&&N(O.data)}catch(O){console.error("加载池子人数失败:",O)}finally{v(!1)}},C=async()=>{a(!0);try{const O=await De("/api/db/config/full?key=match_config"),se=(O==null?void 0:O.data)??(O==null?void 0:O.config);if(se){let ie=se.poolSettings??id;ie.poolSource&&!Array.isArray(ie.poolSource)&&(ie={...ie,poolSource:[ie.poolSource]}),n({...Lw,...se,poolSettings:ie})}}catch(O){console.error("加载匹配配置失败:",O)}finally{a(!1)}};b.useEffect(()=>{C(),k()},[]);const E=async()=>{o(!0);try{const O=await Nt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});te.error((O==null?void 0:O.success)!==!1?"配置保存成功!":"保存失败: "+((O==null?void 0:O.error)||"未知错误"))}catch(O){console.error(O),te.error("保存失败")}finally{o(!1)}},M=O=>{f(O),g({...O}),u(!0)},P=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},H=()=>{if(!m.id||!m.label){te.error("请填写类型ID和名称");return}const O=[...e.matchTypes];if(h){const se=O.findIndex(ie=>ie.id===h.id);se!==-1&&(O[se]={...m})}else{if(O.some(se=>se.id===m.id)){te.error("类型ID已存在");return}O.push({...m})}n({...e,matchTypes:O}),u(!1)},L=O=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(se=>se.id!==O)})},R=O=>{n({...e,matchTypes:e.matchTypes.map(se=>se.id===O?{...se,enabled:!se.enabled}:se)})};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex justify-end gap-3",children:[r.jsxs(X,{variant:"outline",onClick:C,disabled:s,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:E,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(lj,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),r.jsx(Ft,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),r.jsxs(Te,{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配来源池"}),r.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{value:"vip",label:"超级个体(VIP会员)",desc:"付费 ¥1980 的VIP会员",icon:"👑",countKey:"vip"},{value:"complete",label:"完善资料用户",desc:"符合下方完善度要求的用户",icon:"✅",countKey:"complete"},{value:"all",label:"全部用户",desc:"所有已注册用户",icon:"👥",countKey:"all"}].map(O=>{const se=e.poolSettings??id,z=(Array.isArray(se.poolSource)?se.poolSource:[se.poolSource]).includes(O.value),ce=y==null?void 0:y[O.countKey],me=()=>{const _=Array.isArray(se.poolSource)?[...se.poolSource]:[se.poolSource],G=z?_.filter($=>$!==O.value):[..._,O.value];G.length===0&&G.push(O.value),n({...e,poolSettings:{...se,poolSource:G}})};return r.jsxs("button",{type:"button",onClick:me,className:`p-4 rounded-lg border text-left transition-all ${z?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${z?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:z&&"✓"}),r.jsx("span",{className:"text-xl",children:O.icon}),r.jsx("span",{className:`text-sm font-medium ${z?"text-[#38bdac]":"text-gray-300"}`,children:O.label})]}),r.jsxs("span",{className:"text-lg font-bold text-white",children:[j?"...":ce??"-",r.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),r.jsx("p",{className:"text-gray-500 text-xs mt-2",children:O.desc}),r.jsx("span",{role:"link",tabIndex:0,onClick:_=>{_.stopPropagation(),t(`/users?pool=${O.value}`)},onKeyDown:_=>{_.key==="Enter"&&(_.stopPropagation(),t(`/users?pool=${O.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},O.value)})})]}),r.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[r.jsx(Z,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{key:"requirePhone",label:"有手机号",icon:"📱"},{key:"requireNickname",label:"有昵称",icon:"👤"},{key:"requireAvatar",label:"有头像",icon:"🖼️"},{key:"requireBusiness",label:"有业务需求",icon:"💼"}].map(O=>{const ie=(e.poolSettings??id)[O.key];return r.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[r.jsx(jt,{checked:ie,onCheckedChange:z=>n({...e,poolSettings:{...e.poolSettings??id,[O.key]:z}})}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{children:O.icon}),r.jsx(Z,{className:"text-gray-300 text-sm",children:O.label})]})]},O.key)})})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(Fa,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),r.jsxs(Te,{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),r.jsx(re,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:O=>n({...e,freeMatchLimit:parseInt(O.target.value,10)||0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:O=>n({...e,matchPrice:parseFloat(O.target.value)||1})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),r.jsx(re,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:O=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(O.target.value,10)||10}})})]})]}),r.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:e.settings.enableFreeMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enableFreeMatches:O}})}),r.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:e.settings.enablePaidMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enablePaidMatches:O}})}),r.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[r.jsxs(Je,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Ye,{className:"text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),r.jsx(Ft,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),r.jsxs(X,{onClick:P,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(fn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),r.jsx(Te,{children:r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"图标"}),r.jsx(we,{className:"text-gray-400",children:"类型ID"}),r.jsx(we,{className:"text-gray-400",children:"显示名称"}),r.jsx(we,{className:"text-gray-400",children:"匹配标签"}),r.jsx(we,{className:"text-gray-400",children:"价格"}),r.jsx(we,{className:"text-gray-400",children:"数据库匹配"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-right text-gray-400",children:"操作"})]})}),r.jsx(as,{children:e.matchTypes.map(O=>r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx("span",{className:"text-2xl",children:O.icon})}),r.jsx(ve,{className:"font-mono text-gray-300",children:O.id}),r.jsx(ve,{className:"text-white font-medium",children:O.label}),r.jsx(ve,{className:"text-gray-300",children:O.matchLabel}),r.jsx(ve,{children:r.jsxs(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",O.price]})}),r.jsx(ve,{children:O.matchFromDB?r.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):r.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),r.jsx(ve,{children:r.jsx(jt,{checked:O.enabled,onCheckedChange:()=>R(O.id)})}),r.jsx(ve,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>M(O),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:r.jsx(Ut,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>L(O.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:r.jsx(Zn,{className:"w-4 h-4"})})]})})]},O.id))})]})})]}),r.jsx(It,{open:c,onOpenChange:u,children:r.jsxs(Ct,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[r.jsx(Rt,{children:r.jsxs(Pt,{className:"text-white flex items-center gap-2",children:[h?r.jsx(Ut,{className:"w-5 h-5 text-[#38bdac]"}):r.jsx(fn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:O=>g({...m,id:O.target.value}),disabled:!!h})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"图标"}),r.jsx("div",{className:"flex gap-1 flex-wrap",children:PV.map(O=>r.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===O?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:O}),children:O},O))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"显示名称"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:O=>g({...m,label:O.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:O=>g({...m,matchLabel:O.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),r.jsx(re,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:O=>g({...m,price:parseFloat(O.target.value)||1})})]}),r.jsxs("div",{className:"flex gap-6 pt-2",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:m.matchFromDB,onCheckedChange:O=>g({...m,matchFromDB:O})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:m.showJoinAfterMatch,onCheckedChange:O=>g({...m,showJoinAfterMatch:O})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(jt,{checked:m.enabled,onCheckedChange:O=>g({...m,enabled:O})}),r.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),r.jsxs(sn,{children:[r.jsx(X,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),r.jsxs(X,{onClick:H,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const _w={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function DV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null),[N,j]=b.useState(null);async function v(){m(!0),y(null);try{const E=new URLSearchParams({page:String(a),pageSize:String(o)});u&&E.set("matchType",u);const M=await De(`/api/db/match-records?${E}`);M!=null&&M.success?(e(M.records||[]),s(M.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{v()},[a,u]);const k=Math.ceil(n/o)||1,C=({userId:E,nickname:M,avatar:P})=>r.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>j(E),children:[r.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[P?r.jsx("img",{src:P,alt:"",className:"w-full h-full object-cover",onError:H=>{H.currentTarget.style.display="none"}}):null,r.jsx("span",{className:P?"hidden":"",children:(M||E||"?").charAt(0)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:M||E}),r.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[E==null?void 0:E.slice(0,16),(E==null?void 0:E.length)>16?"...":""]})]})]});return r.jsxs("div",{children:[g&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[r.jsx("span",{children:g}),r.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("select",{value:u,onChange:E=>{h(E.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[r.jsx("option",{value:"",children:"全部类型"}),Object.entries(_w).map(([E,M])=>r.jsx("option",{value:E,children:M},E))]}),r.jsxs("button",{type:"button",onClick:v,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx(Fe,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:f?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"匹配时间"})]})}),r.jsxs(as,{children:[t.map(E=>r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{children:r.jsx(C,{userId:E.userId,nickname:E.userNickname,avatar:E.userAvatar})}),r.jsx(ve,{children:E.matchedUserId?r.jsx(C,{userId:E.matchedUserId,nickname:E.matchedNickname,avatar:E.matchedUserAvatar}):r.jsx("span",{className:"text-gray-500",children:"—"})}),r.jsx(ve,{children:r.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:_w[E.matchType]||E.matchType})}),r.jsxs(ve,{className:"text-sm",children:[E.phone&&r.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&r.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&r.jsx("span",{className:"text-gray-600",children:"-"})]}),r.jsx(ve,{className:"text-gray-400",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"})]},E.id)),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),r.jsx(Fs,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})}),r.jsx(y0,{open:!!N,onClose:()=>j(null),userId:N,onUserUpdated:v})]})}function LV(){const[t,e]=b.useState("records");return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>e("records"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="records"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配记录"}),r.jsx("button",{type:"button",onClick:()=>e("pool"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="pool"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配池设置"})]}),t==="records"&&r.jsx(DV,{}),t==="pool"&&r.jsx(OV,{})]})}const zw={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function _V(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0),[f,m]=b.useState("investor"),[g,y]=b.useState(null);async function N(){h(!0);try{const C=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),E=await De(`/api/db/match-records?${C}`);E!=null&&E.success&&(e(E.records||[]),s(E.total??0))}catch(C){console.error(C)}finally{h(!1)}}b.useEffect(()=>{N()},[a,f]);const j=async C=>{if(!C.phone&&!C.wechatId){te.info("该记录无联系方式,无法推送到存客宝");return}y(C.id);try{const E=await Nt("/api/ckb/join",{type:C.matchType||"investor",phone:C.phone||"",wechat:C.wechatId||"",userId:C.userId,name:C.userNickname||""});te.error((E==null?void 0:E.message)||(E!=null&&E.success?"推送成功":"推送失败"))}catch(E){te.error("推送失败: "+(E instanceof Error?E.message:"网络错误"))}finally{y(null)}},v=Math.ceil(n/o)||1,k=C=>!!(C.phone||C.wechatId);return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),r.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("select",{value:f,onChange:C=>{m(C.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(zw).map(([C,E])=>r.jsx("option",{value:C,children:E},C))}),r.jsxs(X,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:u?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"时间"}),r.jsx(we,{className:"text-gray-400 text-right",children:"操作"})]})}),r.jsxs(as,{children:[t.map(C=>{var E,M;return r.jsxs(it,{className:`border-gray-700/50 ${k(C)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[r.jsx(ve,{className:"text-white",children:C.userNickname||((E=C.userId)==null?void 0:E.slice(0,12))}),r.jsx(ve,{className:"text-white",children:C.matchedNickname||((M=C.matchedUserId)==null?void 0:M.slice(0,12))}),r.jsx(ve,{children:r.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:zw[C.matchType]||C.matchType})}),r.jsxs(ve,{className:"text-sm",children:[C.phone&&r.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&r.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&r.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),r.jsx(ve,{className:"text-gray-400 text-sm",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"}),r.jsx(ve,{className:"text-right",children:k(C)?r.jsxs(X,{size:"sm",onClick:()=>j(C),disabled:g===C.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[r.jsx(M5,{className:"w-3 h-3 mr-1"}),g===C.id?"推送中...":"推送CKB"]}):r.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},C.id)}),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),r.jsx(Fs,{page:a,totalPages:v,total:n,pageSize:o,onPageChange:i,onPageSizeChange:C=>{c(C),i(1)}})]})})})]})}const Fw={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},zV={single:"单次",half_year:"半年",year:"年度"};function FV(){const[t,e]=b.useState([]),[n,s]=b.useState(!0),[a,i]=b.useState("");async function o(){s(!0);try{const c=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",u=await De(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{s(!1)}}return b.useEffect(()=>{o()},[a]),r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:a,onChange:c=>i(c.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[r.jsx("option",{value:"",children:"全部状态"}),Object.entries(Fw).map(([c,u])=>r.jsx("option",{value:c,children:u},c))]}),r.jsxs(X,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:r.jsx(Te,{className:"p-0",children:n?r.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"ID"}),r.jsx(we,{className:"text-gray-400",children:"用户ID"}),r.jsx(we,{className:"text-gray-400",children:"导师ID"}),r.jsx(we,{className:"text-gray-400",children:"类型"}),r.jsx(we,{className:"text-gray-400",children:"金额"}),r.jsx(we,{className:"text-gray-400",children:"状态"}),r.jsx(we,{className:"text-gray-400",children:"创建时间"})]})}),r.jsxs(as,{children:[t.map(c=>r.jsxs(it,{className:"border-gray-700/50",children:[r.jsx(ve,{className:"text-gray-300",children:c.id}),r.jsx(ve,{className:"text-gray-400",children:c.userId}),r.jsx(ve,{className:"text-gray-400",children:c.mentorId}),r.jsx(ve,{className:"text-gray-400",children:zV[c.consultationType]||c.consultationType}),r.jsxs(ve,{className:"text-white",children:["¥",c.amount]}),r.jsx(ve,{className:"text-gray-400",children:Fw[c.status]||c.status}),r.jsx(ve,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function $V(){const[t,e]=b.useState("booking");return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>e("booking"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="booking"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"预约记录"}),r.jsx("button",{type:"button",onClick:()=>e("manage"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="manage"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"导师管理"})]}),t==="booking"&&r.jsx(FV,{}),t==="manage"&&r.jsx("div",{className:"-mx-8",children:r.jsx(Q4,{embedded:!0})})]})}function BV(){const[t,e]=b.useState([]),[n,s]=b.useState(0),[a,i]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0);async function f(){h(!0);try{const g=new URLSearchParams({page:String(a),pageSize:String(o),matchType:"team"}),y=await De(`/api/db/match-records?${g}`);y!=null&&y.success&&(e(y.records||[]),s(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}b.useEffect(()=>{f()},[a]);const m=Math.ceil(n/o)||1;return r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between items-center mb-4",children:[r.jsxs("div",{children:[r.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),r.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),r.jsxs("button",{type:"button",onClick:f,disabled:u,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[r.jsx(Fe,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:r.jsx(Te,{className:"p-0",children:u?r.jsxs("div",{className:"flex justify-center py-12",children:[r.jsx(Fe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),r.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ss,{children:[r.jsx(rs,{children:r.jsxs(it,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[r.jsx(we,{className:"text-gray-400",children:"发起人"}),r.jsx(we,{className:"text-gray-400",children:"匹配到"}),r.jsx(we,{className:"text-gray-400",children:"联系方式"}),r.jsx(we,{className:"text-gray-400",children:"时间"})]})}),r.jsxs(as,{children:[t.map(g=>r.jsxs(it,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[r.jsx(ve,{className:"text-white",children:g.userNickname||g.userId}),r.jsx(ve,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),r.jsxs(ve,{className:"text-gray-400 text-sm",children:[g.phone&&r.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&r.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),r.jsx(ve,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&r.jsx(it,{children:r.jsx(ve,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),r.jsx(Fs,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:g=>{c(g),i(1)}})]})})})]})}const $w={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"},Bw={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮"};function VV({onSwitchTab:t,onOpenCKB:e}={}){const n=Ki(),[s,a]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!0),h=b.useCallback(async()=>{var m,g;u(!0);try{const[y,N]=await Promise.allSettled([De("/api/db/match-records?stats=true"),De("/api/db/ckb-plan-stats")]);if(y.status==="fulfilled"&&((m=y.value)!=null&&m.success)&&y.value.data){let j=y.value.data;if(j.totalMatches>0&&(!j.uniqueUsers||j.uniqueUsers===0))try{const v=await De("/api/db/match-records?page=1&pageSize=200");if(v!=null&&v.success&&v.records){const k=new Set(v.records.map(C=>C.userId).filter(Boolean));j={...j,uniqueUsers:k.size}}}catch{}a(j)}N.status==="fulfilled"&&((g=N.value)!=null&&g.success)&&N.value.data&&o(N.value.data)}catch(y){console.error("加载统计失败:",y)}finally{u(!1)}},[]);b.useEffect(()=>{h()},[h]);const f=m=>c?"—":String(m??0);return r.jsxs("div",{className:"space-y-8",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[r.jsx(_n,{className:"w-5 h-5 text-[#38bdac]"})," 找伙伴数据"]}),r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",children:[r.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-[#38bdac]/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"总匹配次数"}),r.jsx("p",{className:"text-4xl font-bold text-white",children:f(s==null?void 0:s.totalMatches)}),r.jsxs("p",{className:"text-[#38bdac] text-xs mt-3 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," 查看匹配记录"]})]})}),r.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-yellow-500/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"今日匹配"}),r.jsx("p",{className:"text-4xl font-bold text-white",children:f(s==null?void 0:s.todayMatches)}),r.jsxs("p",{className:"text-yellow-400/60 text-xs mt-3 flex items-center gap-1",children:[r.jsx(Fa,{className:"w-3 h-3"})," 今日实时"]})]})}),r.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-blue-500/60 transition-all",onClick:()=>n("/users"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"匹配用户数"}),r.jsx("p",{className:"text-4xl font-bold text-white",children:f(s==null?void 0:s.uniqueUsers)}),r.jsxs("p",{className:"text-blue-400/60 text-xs mt-3 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," 查看用户管理"]})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"人均匹配"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":s!=null&&s.uniqueUsers?(s.totalMatches/s.uniqueUsers).toFixed(1):"0"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/40",children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"付费匹配次数"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:f(s==null?void 0:s.paidMatchCount)})]})})]})]}),(s==null?void 0:s.byType)&&s.byType.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"各类型匹配分布"}),r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:s.byType.map(m=>{const g=s.totalMatches>0?m.count/s.totalMatches*100:0;return r.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/40 rounded-xl p-5",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx("span",{className:"text-2xl",children:Bw[m.matchType]||"📊"}),r.jsx("span",{className:"text-gray-300 font-medium",children:$w[m.matchType]||m.matchType})]}),r.jsx("p",{className:"text-3xl font-bold text-white mb-2",children:m.count}),r.jsx("div",{className:"w-full h-2 bg-gray-700/50 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[#38bdac] rounded-full transition-all",style:{width:`${Math.min(g,100)}%`}})}),r.jsxs("p",{className:"text-gray-500 text-xs mt-1.5",children:[g.toFixed(1),"%"]})]},m.matchType)})})]}),r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[r.jsx(Rr,{className:"w-5 h-5 text-orange-400"})," AI 获客数据"]}),r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5 mb-6",children:[r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"已提交线索"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(i==null?void 0:i.ckbTotal)??0}),r.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("contact"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"有联系方式"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(i==null?void 0:i.withContact)??0}),r.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("test"),children:r.jsxs(Te,{className:"p-6",children:[r.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"AI 添加进度"}),r.jsx("p",{className:"text-xl font-bold text-orange-400",children:"查看详情 →"}),r.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"添加成功率 · 回复率 · API 文档"})]})})]}),(i==null?void 0:i.byType)&&i.byType.length>0&&r.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:i.byType.map(m=>r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-lg p-4 flex items-center gap-3",children:[r.jsx("span",{className:"text-xl",children:Bw[m.matchType]||"📋"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 text-xs",children:$w[m.matchType]||m.matchType}),r.jsx("p",{className:"text-xl font-bold text-white",children:m.total})]})]},m.matchType))})]})]})}const HV=["partner","investor","mentor","team"],zg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Vw=`# 场景获客接口摘要 - 地址:POST /v1/api/scenarios - 必填:apiKey、sign、timestamp - 主标识:phone 或 wechatId 至少一项 - 可选:name、source、remark、tags、siteTags、portrait - 签名:排除 sign/apiKey/portrait,键名升序拼接值后双重 MD5 -- 成功:code=200,message=新增成功 或 已存在`;function WV({initialTab:t="overview"}){const[e,n]=b.useState(t),[s,a]=b.useState("13800000000"),[i,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(Vw),[m,g]=b.useState(!1),[y,N]=b.useState(!1),[j,v]=b.useState([]),[k,C]=b.useState([]),[E,M]=b.useState({}),[P,H]=b.useState([{endpoint:"/api/ckb/join",label:"找伙伴",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"资源对接",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"导师顾问",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"团队招募",method:"POST",status:"idle"},{endpoint:"/api/ckb/match",label:"匹配上报",method:"POST",status:"idle"},{endpoint:"/api/miniprogram/ckb/lead",label:"链接卡若",method:"POST",status:"idle"},{endpoint:"/api/match/config",label:"匹配配置",method:"GET",status:"idle"}]),L=b.useMemo(()=>{const z={};return zg.forEach(q=>{z[q.key]=E[q.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),z},[E]),R=z=>{const q=s.trim(),F=i.trim();return z<=3?{type:HV[z],phone:q||void 0,wechat:F||void 0,userId:"admin_test",name:"后台测试"}:z===4?{matchType:"partner",phone:q||void 0,wechat:F||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:z===5?{phone:q||void 0,wechatId:F||void 0,userId:"admin_test",name:"后台测试"}:{}};async function O(){N(!0);try{const[z,q,F]=await Promise.all([De("/api/db/config/full?key=ckb_config"),De("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),De("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),A=z==null?void 0:z.data;A!=null&&A.routes&&M(A.routes),A!=null&&A.docNotes&&u(A.docNotes),A!=null&&A.docContent&&f(A.docContent),q!=null&&q.success&&v(q.records||[]),F!=null&&F.success&&C(F.records||[])}finally{N(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{O()},[]);async function ne(){g(!0);try{const z=await Nt("/api/db/config",{key:"ckb_config",value:{routes:L,docNotes:c,docContent:h},description:"存客宝接口配置"});se.error((z==null?void 0:z.success)!==!1?"存客宝配置已保存":`保存失败: ${(z==null?void 0:z.error)||"未知错误"}`)}catch(z){se.error(`保存失败: ${z instanceof Error?z.message:"网络错误"}`)}finally{g(!1)}}const ie=(z,q)=>{M(F=>({...F,[z]:{...L[z],...q}}))},_=async z=>{const q=P[z];if(q.method==="POST"&&!s.trim()&&!i.trim()){se.error("请填写测试手机号");return}const F=[...P];F[z]={...q,status:"testing",message:void 0,responseTime:void 0},H(F);const A=performance.now();try{const J=q.method==="GET"?await De(q.endpoint):await Nt(q.endpoint,R(z)),U=Math.round(performance.now()-A),D=(J==null?void 0:J.message)||"",W=(J==null?void 0:J.success)===!0||D.includes("已存在")||D.includes("已加入")||D.includes("已提交"),le=[...P];le[z]={...q,status:W?"success":"error",message:D||(W?"正常":"异常"),responseTime:U},H(le),await O()}catch(J){const U=Math.round(performance.now()-A),D=[...P];D[z]={...q,status:"error",message:J instanceof Error?J.message:"失败",responseTime:U},H(D)}},ce=async()=>{if(!s.trim()&&!i.trim()){se.error("请填写测试手机号");return}for(let z=0;zr.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:r.jsxs("tr",{children:[r.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),r.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),r.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),r.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),r.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),r.jsx("tbody",{children:z.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:q})}):z.map(F=>r.jsxs("tr",{className:"border-t border-gray-700/30",children:[r.jsx("td",{className:"px-4 py-3 text-white",children:F.userNickname||F.userId}),r.jsx("td",{className:"px-4 py-3 text-gray-300",children:F.matchType}),r.jsx("td",{className:"px-4 py-3 text-green-400",children:F.phone||"—"}),r.jsx("td",{className:"px-4 py-3 text-blue-400",children:F.wechatId||"—"}),r.jsx("td",{className:"px-4 py-3 text-gray-400",children:F.createdAt?new Date(F.createdAt).toLocaleString():"—"})]},F.id))})]})});return r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:r.jsxs(Te,{className:"p-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),r.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," API 文档"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{onClick:()=>O(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx($e,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:ne,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(Nn,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),r.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([z,q])=>r.jsx("button",{type:"button",onClick:()=>n(z),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===z?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:q},z))}),e==="overview"&&r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:j.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:k.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:zg.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),r.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&pe(j,"暂无已提交线索"),e==="contact"&&pe(k,"暂无有联系方式线索"),e==="config"&&r.jsx("div",{className:"space-y-4",children:zg.map(z=>r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h4",{className:"text-white font-medium",children:z.label}),r.jsx(Ke,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:z.key})]}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"API 地址"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[z.key].apiUrl,onChange:q=>ie(z.key,{apiUrl:q.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"API Key"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[z.key].apiKey,onChange:q=>ie(z.key,{apiKey:q.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"Source"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[z.key].source,onChange:q=>ie(z.key,{source:q.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"Tags"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[z.key].tags,onChange:q=>ie(z.key,{tags:q.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"SiteTags"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[z.key].siteTags,onChange:q=>ie(z.key,{siteTags:q.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"说明备注"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[z.key].notes,onChange:q=>ie(z.key,{notes:q.target.value})})]})]})]},z.key))}),e==="test"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[r.jsx(zi,{className:"w-4 h-4 text-gray-500 shrink-0"}),r.jsxs("div",{className:"flex-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"测试手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:s,onChange:z=>a(z.target.value)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[r.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),r.jsxs("div",{className:"flex-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:z=>o(z.target.value)})]})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs(X,{onClick:ce,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[r.jsx(Ti,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:P.map((z,q)=>r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[z.status==="idle"&&r.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),z.status==="testing"&&r.jsx($e,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),z.status==="success"&&r.jsx(Ug,{className:"w-3 h-3 text-green-400 shrink-0"}),z.status==="error"&&r.jsx(ij,{className:"w-3 h-3 text-red-400 shrink-0"}),r.jsx("span",{className:"text-white text-xs truncate",children:z.label})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[z.responseTime!==void 0&&r.jsxs("span",{className:"text-gray-600 text-[10px]",children:[z.responseTime,"ms"]}),r.jsx("button",{type:"button",onClick:()=>_(q),disabled:z.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${z.endpoint}-${q}`))})]}),e==="doc"&&r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),r.jsxs("a",{href:"https://ckbapi.quwanzhi.com/v1/api/scenarios",target:"_blank",rel:"noreferrer",className:"text-orange-400/70 hover:text-orange-400 text-xs flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," 打开外链"]})]}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Vw})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),r.jsx("textarea",{className:"w-full min-h-[260px] bg-[#0f2137] border border-gray-700 rounded-md text-sm text-gray-300 p-3 outline-none focus:border-orange-500/50 resize-y",value:c,onChange:z=>u(z.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const UV=[{id:"stats",label:"数据统计",icon:Wg},{id:"partner",label:"找伙伴",icon:_n},{id:"resource",label:"资源对接",icon:TM},{id:"mentor",label:"导师预约",icon:SM},{id:"team",label:"团队招募",icon:dd}];function KV(){const[t,e]=b.useState("stats"),[n,s]=b.useState(!1),[a,i]=b.useState("overview");return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-6 h-6 text-[#38bdac]"}),"找伙伴"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"数据统计、匹配池与记录、资源对接、导师预约、团队招募"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>s(o=>!o),className:"border-orange-500/40 text-orange-300 hover:bg-orange-500/10 bg-transparent",children:[r.jsx(Ir,{className:"w-4 h-4 mr-2"}),"存客宝"]})]}),n&&r.jsx(WV,{initialTab:a}),r.jsx("div",{className:"flex flex-wrap gap-1 mb-6 bg-[#0f2137] rounded-lg p-1 border border-gray-700/50",children:UV.map(o=>{const c=t===o.id;return r.jsxs("button",{type:"button",onClick:()=>e(o.id),className:`flex items-center gap-2 px-5 py-2.5 rounded-md text-sm font-medium transition-all ${c?"bg-[#38bdac] text-white shadow-lg":"text-gray-400 hover:text-white hover:bg-gray-700/50"}`,children:[r.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id)})}),t==="stats"&&r.jsx(VV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{i(o||"overview"),s(!0)}}),t==="partner"&&r.jsx(LV,{}),t==="resource"&&r.jsx(_V,{}),t==="mentor"&&r.jsx(FV,{}),t==="team"&&r.jsx(BV,{})]})}function qV(){return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[r.jsx(Ir,{className:"w-8 h-8 text-[#38bdac]"}),r.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"})]}),r.jsx("p",{className:"text-gray-400 mb-6",children:"API 风格:RESTful · 版本 v1.0 · 基础路径 /api · 简单、清晰、易用。"}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"1. 接口总览"})}),r.jsxs(Te,{className:"space-y-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 mb-2",children:"接口分类"}),r.jsxs("ul",{className:"space-y-1 text-gray-300 font-mono",children:[r.jsx("li",{children:"/api/book — 书籍内容(章节列表、内容获取、同步)"}),r.jsx("li",{children:"/api/payment — 支付系统(订单创建、回调、状态查询)"}),r.jsx("li",{children:"/api/referral — 分销系统(邀请码、收益、提现)"}),r.jsx("li",{children:"/api/user — 用户系统(登录、注册、信息更新)"}),r.jsx("li",{children:"/api/match — 匹配系统(寻找匹配、匹配历史)"}),r.jsx("li",{children:"/api/admin — 管理后台(内容/订单/用户/分销管理)"}),r.jsx("li",{children:"/api/config — 配置系统"})]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 mb-2",children:"认证方式"}),r.jsx("p",{className:"text-gray-300",children:"用户:Cookie session_id(可选)"}),r.jsx("p",{className:"text-gray-300",children:"管理端:Authorization: Bearer admin-token-secret"})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"2. 书籍内容"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"GET /api/book/all-chapters — 获取所有章节"}),r.jsx("p",{children:"GET /api/book/chapter/:id — 获取单章内容"}),r.jsx("p",{children:"POST /api/book/sync — 同步章节(需管理员认证)"})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"3. 支付"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"POST /api/payment/create-order — 创建订单"}),r.jsx("p",{children:"POST /api/payment/alipay/notify — 支付宝回调"}),r.jsx("p",{children:"POST /api/payment/wechat/notify — 微信回调"})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"4. 分销与用户"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"/api/referral/* — 邀请码、收益查询、提现"}),r.jsx("p",{children:"/api/user/* — 登录、注册、信息更新"}),r.jsx("p",{children:"/api/match/* — 匹配、匹配历史"})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"5. 管理后台"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"GET/POST /api/admin/referral-settings — 推广/分销设置(含 VIP 配置)"}),r.jsx("p",{children:"GET /api/db/users、/api/db/book — 用户与章节数据"}),r.jsx("p",{children:"GET /api/admin/orders — 订单列表"})]})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"完整说明见项目内 开发文档/5、接口/API接口完整文档.md"})]})}function GV(){const t=Ui();return r.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:r.jsxs("div",{className:"text-center max-w-md",children:[r.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-red-500/20 text-red-400 mb-6",children:r.jsx(rj,{className:"w-10 h-10"})}),r.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),r.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),r.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),r.jsx(X,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:r.jsxs(Hg,{to:"/",children:[r.jsx(_M,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function JV(){return r.jsxs(jT,{children:[r.jsx(Bt,{path:"/login",element:r.jsx(sI,{})}),r.jsxs(Bt,{path:"/",element:r.jsx(iA,{}),children:[r.jsx(Bt,{index:!0,element:r.jsx(Vm,{to:"/dashboard",replace:!0})}),r.jsx(Bt,{path:"dashboard",element:r.jsx(fP,{})}),r.jsx(Bt,{path:"orders",element:r.jsx(pP,{})}),r.jsx(Bt,{path:"users",element:r.jsx(mP,{})}),r.jsx(Bt,{path:"distribution",element:r.jsx(_P,{})}),r.jsx(Bt,{path:"withdrawals",element:r.jsx(zP,{})}),r.jsx(Bt,{path:"content",element:r.jsx(fV,{})}),r.jsx(Bt,{path:"referral-settings",element:r.jsx(Gk,{})}),r.jsx(Bt,{path:"author-settings",element:r.jsx(Vm,{to:"/settings?tab=author",replace:!0})}),r.jsx(Bt,{path:"vip-roles",element:r.jsx(IV,{})}),r.jsx(Bt,{path:"mentors",element:r.jsx(Q4,{})}),r.jsx(Bt,{path:"mentor-consultations",element:r.jsx(RV,{})}),r.jsx(Bt,{path:"admin-users",element:r.jsx(Vm,{to:"/settings?tab=admin",replace:!0})}),r.jsx(Bt,{path:"settings",element:r.jsx(NV,{})}),r.jsx(Bt,{path:"payment",element:r.jsx(wV,{})}),r.jsx(Bt,{path:"site",element:r.jsx(CV,{})}),r.jsx(Bt,{path:"qrcodes",element:r.jsx(EV,{})}),r.jsx(Bt,{path:"find-partner",element:r.jsx(KV,{})}),r.jsx(Bt,{path:"match",element:r.jsx(MV,{})}),r.jsx(Bt,{path:"match-records",element:r.jsx(AV,{})}),r.jsx(Bt,{path:"api-doc",element:r.jsx(qV,{})}),r.jsx(Bt,{path:"api-docs",element:r.jsx(Y4,{})})]}),r.jsx(Bt,{path:"*",element:r.jsx(GV,{})})]})}TE.createRoot(document.getElementById("root")).render(r.jsx(b.StrictMode,{children:r.jsx(IT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:r.jsx(JV,{})})})); +- 成功:code=200,message=新增成功 或 已存在`;function WV({initialTab:t="overview"}){const[e,n]=b.useState(t),[s,a]=b.useState("13800000000"),[i,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(Vw),[m,g]=b.useState(!1),[y,N]=b.useState(!1),[j,v]=b.useState([]),[k,C]=b.useState([]),[E,M]=b.useState({}),[P,H]=b.useState([{endpoint:"/api/ckb/join",label:"找伙伴",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"资源对接",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"导师顾问",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"团队招募",method:"POST",status:"idle"},{endpoint:"/api/ckb/match",label:"匹配上报",method:"POST",status:"idle"},{endpoint:"/api/miniprogram/ckb/lead",label:"链接卡若",method:"POST",status:"idle"},{endpoint:"/api/match/config",label:"匹配配置",method:"GET",status:"idle"}]),L=b.useMemo(()=>{const _={};return zg.forEach(G=>{_[G.key]=E[G.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),_},[E]),R=_=>{const G=s.trim(),$=i.trim();return _<=3?{type:HV[_],phone:G||void 0,wechat:$||void 0,userId:"admin_test",name:"后台测试"}:_===4?{matchType:"partner",phone:G||void 0,wechat:$||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:_===5?{phone:G||void 0,wechatId:$||void 0,userId:"admin_test",name:"后台测试"}:{}};async function O(){N(!0);try{const[_,G,$]=await Promise.all([De("/api/db/config/full?key=ckb_config"),De("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),De("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),A=_==null?void 0:_.data;A!=null&&A.routes&&M(A.routes),A!=null&&A.docNotes&&u(A.docNotes),A!=null&&A.docContent&&f(A.docContent),G!=null&&G.success&&v(G.records||[]),$!=null&&$.success&&C($.records||[])}finally{N(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{O()},[]);async function se(){g(!0);try{const _=await Nt("/api/db/config",{key:"ckb_config",value:{routes:L,docNotes:c,docContent:h},description:"存客宝接口配置"});te.error((_==null?void 0:_.success)!==!1?"存客宝配置已保存":`保存失败: ${(_==null?void 0:_.error)||"未知错误"}`)}catch(_){te.error(`保存失败: ${_ instanceof Error?_.message:"网络错误"}`)}finally{g(!1)}}const ie=(_,G)=>{M($=>({...$,[_]:{...L[_],...G}}))},z=async _=>{const G=P[_];if(G.method==="POST"&&!s.trim()&&!i.trim()){te.error("请填写测试手机号");return}const $=[...P];$[_]={...G,status:"testing",message:void 0,responseTime:void 0},H($);const A=performance.now();try{const Y=G.method==="GET"?await De(G.endpoint):await Nt(G.endpoint,R(_)),U=Math.round(performance.now()-A),D=(Y==null?void 0:Y.message)||"",W=(Y==null?void 0:Y.success)===!0||D.includes("已存在")||D.includes("已加入")||D.includes("已提交"),le=[...P];le[_]={...G,status:W?"success":"error",message:D||(W?"正常":"异常"),responseTime:U},H(le),await O()}catch(Y){const U=Math.round(performance.now()-A),D=[...P];D[_]={...G,status:"error",message:Y instanceof Error?Y.message:"失败",responseTime:U},H(D)}},ce=async()=>{if(!s.trim()&&!i.trim()){te.error("请填写测试手机号");return}for(let _=0;_r.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:r.jsxs("tr",{children:[r.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),r.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),r.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),r.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),r.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),r.jsx("tbody",{children:_.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:G})}):_.map($=>r.jsxs("tr",{className:"border-t border-gray-700/30",children:[r.jsx("td",{className:"px-4 py-3 text-white",children:$.userNickname||$.userId}),r.jsx("td",{className:"px-4 py-3 text-gray-300",children:$.matchType}),r.jsx("td",{className:"px-4 py-3 text-green-400",children:$.phone||"—"}),r.jsx("td",{className:"px-4 py-3 text-blue-400",children:$.wechatId||"—"}),r.jsx("td",{className:"px-4 py-3 text-gray-400",children:$.createdAt?new Date($.createdAt).toLocaleString():"—"})]},$.id))})]})});return r.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:r.jsxs(Te,{className:"p-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),r.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),r.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," API 文档"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{onClick:()=>O(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[r.jsx(Fe,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),r.jsxs(X,{onClick:se,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[r.jsx(wn,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),r.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([_,G])=>r.jsx("button",{type:"button",onClick:()=>n(_),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===_?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:G},_))}),e==="overview"&&r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:j.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:k.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),r.jsx("p",{className:"text-3xl font-bold text-white",children:zg.length})]}),r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[r.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),r.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&me(j,"暂无已提交线索"),e==="contact"&&me(k,"暂无有联系方式线索"),e==="config"&&r.jsx("div",{className:"space-y-4",children:zg.map(_=>r.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h4",{className:"text-white font-medium",children:_.label}),r.jsx(Ke,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:_.key})]}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"API 地址"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[_.key].apiUrl,onChange:G=>ie(_.key,{apiUrl:G.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"API Key"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[_.key].apiKey,onChange:G=>ie(_.key,{apiKey:G.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"Source"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[_.key].source,onChange:G=>ie(_.key,{source:G.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"Tags"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[_.key].tags,onChange:G=>ie(_.key,{tags:G.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"SiteTags"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[_.key].siteTags,onChange:G=>ie(_.key,{siteTags:G.target.value})})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"说明备注"}),r.jsx(re,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:L[_.key].notes,onChange:G=>ie(_.key,{notes:G.target.value})})]})]})]},_.key))}),e==="test"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[r.jsx(zi,{className:"w-4 h-4 text-gray-500 shrink-0"}),r.jsxs("div",{className:"flex-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"测试手机号"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:s,onChange:_=>a(_.target.value)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[r.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),r.jsxs("div",{className:"flex-1",children:[r.jsx(Z,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),r.jsx(re,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:_=>o(_.target.value)})]})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs(X,{onClick:ce,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[r.jsx(Fa,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:P.map((_,G)=>r.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[_.status==="idle"&&r.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),_.status==="testing"&&r.jsx(Fe,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),_.status==="success"&&r.jsx(Ug,{className:"w-3 h-3 text-green-400 shrink-0"}),_.status==="error"&&r.jsx(ij,{className:"w-3 h-3 text-red-400 shrink-0"}),r.jsx("span",{className:"text-white text-xs truncate",children:_.label})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[_.responseTime!==void 0&&r.jsxs("span",{className:"text-gray-600 text-[10px]",children:[_.responseTime,"ms"]}),r.jsx("button",{type:"button",onClick:()=>z(G),disabled:_.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${_.endpoint}-${G}`))})]}),e==="doc"&&r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),r.jsxs("a",{href:"https://ckbapi.quwanzhi.com/v1/api/scenarios",target:"_blank",rel:"noreferrer",className:"text-orange-400/70 hover:text-orange-400 text-xs flex items-center gap-1",children:[r.jsx(ra,{className:"w-3 h-3"})," 打开外链"]})]}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Vw})]}),r.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[r.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),r.jsx("textarea",{className:"w-full min-h-[260px] bg-[#0f2137] border border-gray-700 rounded-md text-sm text-gray-300 p-3 outline-none focus:border-orange-500/50 resize-y",value:c,onChange:_=>u(_.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const UV=[{id:"stats",label:"数据统计",icon:Wg},{id:"partner",label:"找伙伴",icon:_n},{id:"resource",label:"资源对接",icon:TM},{id:"mentor",label:"导师预约",icon:SM},{id:"team",label:"团队招募",icon:dd}];function KV(){const[t,e]=b.useState("stats"),[n,s]=b.useState(!1),[a,i]=b.useState("overview");return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[r.jsx(_n,{className:"w-6 h-6 text-[#38bdac]"}),"找伙伴"]}),r.jsx("p",{className:"text-gray-400 mt-1",children:"数据统计、匹配池与记录、资源对接、导师预约、团队招募"})]}),r.jsxs(X,{type:"button",variant:"outline",onClick:()=>s(o=>!o),className:"border-orange-500/40 text-orange-300 hover:bg-orange-500/10 bg-transparent",children:[r.jsx(Rr,{className:"w-4 h-4 mr-2"}),"存客宝"]})]}),n&&r.jsx(WV,{initialTab:a}),r.jsx("div",{className:"flex flex-wrap gap-1 mb-6 bg-[#0f2137] rounded-lg p-1 border border-gray-700/50",children:UV.map(o=>{const c=t===o.id;return r.jsxs("button",{type:"button",onClick:()=>e(o.id),className:`flex items-center gap-2 px-5 py-2.5 rounded-md text-sm font-medium transition-all ${c?"bg-[#38bdac] text-white shadow-lg":"text-gray-400 hover:text-white hover:bg-gray-700/50"}`,children:[r.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id)})}),t==="stats"&&r.jsx(VV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{i(o||"overview"),s(!0)}}),t==="partner"&&r.jsx(LV,{}),t==="resource"&&r.jsx(_V,{}),t==="mentor"&&r.jsx($V,{}),t==="team"&&r.jsx(BV,{})]})}function qV(){return r.jsxs("div",{className:"p-8 w-full",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[r.jsx(Rr,{className:"w-8 h-8 text-[#38bdac]"}),r.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"})]}),r.jsx("p",{className:"text-gray-400 mb-6",children:"API 风格:RESTful · 版本 v1.0 · 基础路径 /api · 简单、清晰、易用。"}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"1. 接口总览"})}),r.jsxs(Te,{className:"space-y-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 mb-2",children:"接口分类"}),r.jsxs("ul",{className:"space-y-1 text-gray-300 font-mono",children:[r.jsx("li",{children:"/api/book — 书籍内容(章节列表、内容获取、同步)"}),r.jsx("li",{children:"/api/payment — 支付系统(订单创建、回调、状态查询)"}),r.jsx("li",{children:"/api/referral — 分销系统(邀请码、收益、提现)"}),r.jsx("li",{children:"/api/user — 用户系统(登录、注册、信息更新)"}),r.jsx("li",{children:"/api/match — 匹配系统(寻找匹配、匹配历史)"}),r.jsx("li",{children:"/api/admin — 管理后台(内容/订单/用户/分销管理)"}),r.jsx("li",{children:"/api/config — 配置系统"})]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-gray-400 mb-2",children:"认证方式"}),r.jsx("p",{className:"text-gray-300",children:"用户:Cookie session_id(可选)"}),r.jsx("p",{className:"text-gray-300",children:"管理端:Authorization: Bearer admin-token-secret"})]})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"2. 书籍内容"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"GET /api/book/all-chapters — 获取所有章节"}),r.jsx("p",{children:"GET /api/book/chapter/:id — 获取单章内容"}),r.jsx("p",{children:"POST /api/book/sync — 同步章节(需管理员认证)"})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"3. 支付"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"POST /api/payment/create-order — 创建订单"}),r.jsx("p",{children:"POST /api/payment/alipay/notify — 支付宝回调"}),r.jsx("p",{children:"POST /api/payment/wechat/notify — 微信回调"})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"4. 分销与用户"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"/api/referral/* — 邀请码、收益查询、提现"}),r.jsx("p",{children:"/api/user/* — 登录、注册、信息更新"}),r.jsx("p",{children:"/api/match/* — 匹配、匹配历史"})]})]}),r.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[r.jsx(Je,{children:r.jsx(Ye,{className:"text-white",children:"5. 管理后台"})}),r.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[r.jsx("p",{children:"GET/POST /api/admin/referral-settings — 推广/分销设置(含 VIP 配置)"}),r.jsx("p",{children:"GET /api/db/users、/api/db/book — 用户与章节数据"}),r.jsx("p",{children:"GET /api/admin/orders — 订单列表"})]})]}),r.jsx("p",{className:"text-gray-500 text-xs",children:"完整说明见项目内 开发文档/5、接口/API接口完整文档.md"})]})}function GV(){const t=Ui();return r.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:r.jsxs("div",{className:"text-center max-w-md",children:[r.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-red-500/20 text-red-400 mb-6",children:r.jsx(rj,{className:"w-10 h-10"})}),r.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),r.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),r.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),r.jsx(X,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:r.jsxs(Hg,{to:"/",children:[r.jsx(_M,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function JV(){return r.jsxs(jT,{children:[r.jsx(Wt,{path:"/login",element:r.jsx(sI,{})}),r.jsxs(Wt,{path:"/",element:r.jsx(iA,{}),children:[r.jsx(Wt,{index:!0,element:r.jsx(Vm,{to:"/dashboard",replace:!0})}),r.jsx(Wt,{path:"dashboard",element:r.jsx(fP,{})}),r.jsx(Wt,{path:"orders",element:r.jsx(pP,{})}),r.jsx(Wt,{path:"users",element:r.jsx(mP,{})}),r.jsx(Wt,{path:"distribution",element:r.jsx(_P,{})}),r.jsx(Wt,{path:"withdrawals",element:r.jsx(zP,{})}),r.jsx(Wt,{path:"content",element:r.jsx(fV,{})}),r.jsx(Wt,{path:"referral-settings",element:r.jsx(Gk,{})}),r.jsx(Wt,{path:"author-settings",element:r.jsx(Vm,{to:"/settings?tab=author",replace:!0})}),r.jsx(Wt,{path:"vip-roles",element:r.jsx(IV,{})}),r.jsx(Wt,{path:"mentors",element:r.jsx(Q4,{})}),r.jsx(Wt,{path:"mentor-consultations",element:r.jsx(RV,{})}),r.jsx(Wt,{path:"admin-users",element:r.jsx(Vm,{to:"/settings?tab=admin",replace:!0})}),r.jsx(Wt,{path:"settings",element:r.jsx(NV,{})}),r.jsx(Wt,{path:"payment",element:r.jsx(wV,{})}),r.jsx(Wt,{path:"site",element:r.jsx(CV,{})}),r.jsx(Wt,{path:"qrcodes",element:r.jsx(EV,{})}),r.jsx(Wt,{path:"find-partner",element:r.jsx(KV,{})}),r.jsx(Wt,{path:"match",element:r.jsx(MV,{})}),r.jsx(Wt,{path:"match-records",element:r.jsx(AV,{})}),r.jsx(Wt,{path:"api-doc",element:r.jsx(qV,{})}),r.jsx(Wt,{path:"api-docs",element:r.jsx(Y4,{})})]}),r.jsx(Wt,{path:"*",element:r.jsx(GV,{})})]})}TE.createRoot(document.getElementById("root")).render(r.jsx(b.StrictMode,{children:r.jsx(IT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:r.jsx(JV,{})})})); diff --git a/soul-admin/dist/assets/index-DGXqHqcA.css b/soul-admin/dist/assets/index-DGXqHqcA.css new file mode 100644 index 00000000..c6fdd7c0 --- /dev/null +++ b/soul-admin/dist/assets/index-DGXqHqcA.css @@ -0,0 +1 @@ +.rich-editor-wrapper{border:1px solid #374151;border-radius:.5rem;background:#0a1628;overflow:hidden}.rich-editor-toolbar{display:flex;align-items:center;gap:2px;padding:6px 8px;border-bottom:1px solid #374151;background:#0f1d32;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:1px}.toolbar-divider{width:1px;height:20px;background:#374151;margin:0 4px}.rich-editor-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer;transition:all .15s}.rich-editor-toolbar button:hover{background:#1f2937;color:#d1d5db}.rich-editor-toolbar button.is-active{background:#38bdac33;color:#38bdac}.rich-editor-toolbar button:disabled{opacity:.3;cursor:not-allowed}.link-tag-select{background:#0a1628;border:1px solid #374151;color:#d1d5db;font-size:12px;padding:2px 6px;border-radius:4px;cursor:pointer;max-width:160px}.link-input-bar{display:flex;align-items:center;gap:4px;padding:4px 8px;border-bottom:1px solid #374151;background:#0f1d32}.link-input{flex:1;background:#0a1628;border:1px solid #374151;color:#fff;padding:4px 8px;border-radius:4px;font-size:13px}.link-confirm,.link-remove{padding:4px 10px;border-radius:4px;border:none;font-size:12px;cursor:pointer}.link-confirm{background:#38bdac;color:#fff}.link-remove{background:#374151;color:#9ca3af}.rich-editor-content{min-height:450px;max-height:720px;overflow-y:auto;padding:12px 16px;color:#e5e7eb;font-size:14px;line-height:1.7}.rich-editor-content:focus{outline:none}.rich-editor-content h1{font-size:1.5em;font-weight:700;margin:.8em 0 .4em;color:#fff}.rich-editor-content h2{font-size:1.3em;font-weight:600;margin:.7em 0 .3em;color:#fff}.rich-editor-content h3{font-size:1.15em;font-weight:600;margin:.6em 0 .3em;color:#fff}.rich-editor-content p{margin:.4em 0}.rich-editor-content strong{color:#fff}.rich-editor-content code{background:#1f2937;padding:2px 6px;border-radius:3px;font-size:.9em;color:#38bdac}.rich-editor-content pre{background:#1f2937;padding:12px;border-radius:6px;overflow-x:auto;margin:.6em 0}.rich-editor-content blockquote{border-left:3px solid #38bdac;padding-left:12px;margin:.6em 0;color:#9ca3af}.rich-editor-content ul,.rich-editor-content ol{padding-left:1.5em;margin:.4em 0}.rich-editor-content li{margin:.2em 0}.rich-editor-content hr{border:none;border-top:1px solid #374151;margin:1em 0}.rich-editor-content img{max-width:100%;border-radius:6px;margin:.5em 0}.rich-editor-content a,.rich-link{color:#38bdac;text-decoration:underline;cursor:pointer}.rich-editor-content table{border-collapse:collapse;width:100%;margin:.5em 0}.rich-editor-content th,.rich-editor-content td{border:1px solid #374151;padding:6px 10px;text-align:left}.rich-editor-content th{background:#1f2937;font-weight:600}.rich-editor-content .ProseMirror-placeholder:before{content:attr(data-placeholder);color:#6b7280;float:left;height:0;pointer-events:none}.mention-tag{background:#38bdac26;color:#38bdac;border-radius:4px;padding:1px 4px;font-weight:500}.link-tag-node{background:#ffd7001f;color:gold;border-radius:4px;padding:1px 4px;font-weight:500;cursor:default;-webkit-user-select:all;user-select:all}.mention-popup{position:fixed;z-index:9999;background:#1a2638;border:1px solid #374151;border-radius:8px;padding:4px;min-width:180px;max-height:240px;overflow-y:auto;box-shadow:0 4px 20px #0006}.mention-item{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-radius:4px;cursor:pointer;color:#d1d5db;font-size:13px}.mention-item:hover,.mention-item.is-selected{background:#38bdac26;color:#38bdac}.mention-name{font-weight:500}.mention-id{font-size:11px;color:#6b7280}.bubble-menu{display:flex;gap:2px;background:#1a2638;border:1px solid #374151;border-radius:6px;padding:4px;box-shadow:0 4px 12px #0000004d}.bubble-menu button{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer}.bubble-menu button:hover{background:#1f2937;color:#d1d5db}.bubble-menu button.is-active{color:#38bdac}/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-pan-x:initial;--tw-pan-y:initial;--tw-pinch-zoom:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-100:oklch(93.6% .032 17.717);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-rose-400:oklch(71.2% .194 13.428);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--blur-xl:24px;--blur-3xl:64px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}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;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.not-sr-only{clip-path:none;white-space:normal;width:auto;height:auto;margin:0;padding:0;position:static;overflow:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.-top-2\.5{top:calc(var(--spacing)*-2.5)}.top-0{top:calc(var(--spacing)*0)}.top-1\/2{top:50%}.top-1\/4{top:25%}.top-4{top:calc(var(--spacing)*4)}.top-16{top:calc(var(--spacing)*16)}.top-\[50\%\]{top:50%}.top-full{top:100%}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\/4{right:25%}.right-4{right:calc(var(--spacing)*4)}.bottom-1\/4{bottom:25%}.-left-2\.5{left:calc(var(--spacing)*-2.5)}.left-0{left:calc(var(--spacing)*0)}.left-1\/4{left:25%}.left-2{left:calc(var(--spacing)*2)}.left-3{left:calc(var(--spacing)*3)}.left-\[50\%\]{left:50%}.isolate{isolation:isolate}.isolation-auto{isolation:auto}.z-10{z-index:10}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-mx-2{margin-inline:calc(var(--spacing)*-2)}.-mx-8{margin-inline:calc(var(--spacing)*-8)}.mx-20{margin-inline:calc(var(--spacing)*20)}.mx-auto{margin-inline:auto}.-mt-6{margin-top:calc(var(--spacing)*-6)}.mt-0{margin-top:calc(var(--spacing)*0)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-auto{margin-right:auto}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.flow-root{display:flow-root}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline\!{display:inline!important}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.inline-table{display:inline-table}.list-item{display:list-item}.table{display:table}.table\!{display:table!important}.table-caption{display:table-caption}.table-cell{display:table-cell}.table-column{display:table-column}.table-column-group{display:table-column-group}.table-footer-group{display:table-footer-group}.table-header-group{display:table-header-group}.table-row{display:table-row}.table-row-group{display:table-row-group}.size-4{width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.size-8{width:calc(var(--spacing)*8);height:calc(var(--spacing)*8)}.size-9{width:calc(var(--spacing)*9);height:calc(var(--spacing)*9)}.size-10{width:calc(var(--spacing)*10);height:calc(var(--spacing)*10)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-96{height:calc(var(--spacing)*96)}.h-\[75vh\]{height:75vh}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[450px\]{max-height:450px}.max-h-none{max-height:none}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-8{min-height:calc(var(--spacing)*8)}.min-h-\[32px\]{min-height:32px}.min-h-\[40px\]{min-height:40px}.min-h-\[60vh\]{min-height:60vh}.min-h-\[72px\]{min-height:72px}.min-h-\[80px\]{min-height:80px}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[260px\]{min-height:260px}.min-h-\[400px\]{min-height:400px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing)*.5)}.w-2{width:calc(var(--spacing)*2)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-28{width:calc(var(--spacing)*28)}.w-32{width:calc(var(--spacing)*32)}.w-40{width:calc(var(--spacing)*40)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-96{width:calc(var(--spacing)*96)}.w-\[280px\]{width:280px}.w-fit{width:fit-content}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-\[72px\]{max-width:72px}.max-w-\[96px\]{max-width:96px}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[140px\]{max-width:140px}.max-w-\[160px\]{max-width:160px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[420px\]{max-width:420px}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[60px\]{min-width:60px}.min-w-\[120px\]{min-width:120px}.min-w-\[200px\]{min-width:200px}.min-w-\[1024px\]{min-width:1024px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-3d{scale:var(--tw-scale-x)var(--tw-scale-y)var(--tw-scale-z)}.scale-\[0\.98\]{scale:.98}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.touch-none{touch-action:none}.resize{resize:both}.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-\[40px_40px_1fr_80px_80px_80px_60px\]{grid-template-columns:40px 40px 1fr 80px 80px 80px 60px}.grid-cols-\[60px_1fr_100px_100px_80px_120px\]{grid-template-columns:60px 1fr 100px 100px 80px 120px}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-reverse>:not(:last-child)){--tw-space-y-reverse:1}.gap-x-8{column-gap:calc(var(--spacing)*8)}:where(.space-x-reverse>:not(:last-child)){--tw-space-x-reverse:1}.gap-y-4{row-gap:calc(var(--spacing)*4)}:where(.divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px*var(--tw-divide-x-reverse));border-inline-end-width:calc(1px*calc(1 - var(--tw-divide-x-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-y-reverse>:not(:last-child)){--tw-divide-y-reverse:1}:where(.divide-gray-700\/50>:not(:last-child)){border-color:#36415380}@supports (color:color-mix(in lab,red,red)){:where(.divide-gray-700\/50>:not(:last-child)){border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}:where(.divide-white\/5>:not(:last-child)){border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){:where(.divide-white\/5>:not(:last-child)){border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[\#07C160\]{border-color:#07c160}.border-\[\#07C160\]\/20{border-color:#07c16033}.border-\[\#07C160\]\/30{border-color:#07c1604d}.border-\[\#38bdac\]{border-color:#38bdac}.border-\[\#38bdac\]\/20{border-color:#38bdac33}.border-\[\#38bdac\]\/30{border-color:#38bdac4d}.border-\[\#38bdac\]\/40{border-color:#38bdac66}.border-\[\#38bdac\]\/50{border-color:#38bdac80}.border-amber-400\/60{border-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.border-amber-400\/60{border-color:color-mix(in oklab,var(--color-amber-400)60%,transparent)}}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500)40%,transparent)}}.border-amber-500\/50{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/50{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-cyan-500\/30{border-color:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/30{border-color:color-mix(in oklab,var(--color-cyan-500)30%,transparent)}}.border-cyan-500\/40{border-color:#00b7d766}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/40{border-color:color-mix(in oklab,var(--color-cyan-500)40%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-700\/30{border-color:#3641534d}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/30{border-color:color-mix(in oklab,var(--color-gray-700)30%,transparent)}}.border-gray-700\/40{border-color:#36415366}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/40{border-color:color-mix(in oklab,var(--color-gray-700)40%,transparent)}}.border-gray-700\/50{border-color:#36415380}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/50{border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.border-gray-700\/60{border-color:#36415399}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/60{border-color:color-mix(in oklab,var(--color-gray-700)60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-inherit{border-color:inherit}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-orange-500\/50{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/50{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-purple-500\/40{border-color:#ac4bff66}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/40{border-color:color-mix(in oklab,var(--color-purple-500)40%,transparent)}}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-600\/50{border-color:#e4001480}@supports (color:color-mix(in lab,red,red)){.border-red-600\/50{border-color:color-mix(in oklab,var(--color-red-600)50%,transparent)}}.border-transparent{border-color:#0000}.border-white\/5{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/5{border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/40{border-color:#edb20066}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/40{border-color:color-mix(in oklab,var(--color-yellow-500)40%,transparent)}}.bg-\[\#0a1628\]{background-color:#0a1628}.bg-\[\#0a1628\]\/50{background-color:#0a162880}.bg-\[\#0a1628\]\/60{background-color:#0a162899}.bg-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#07C160\]{background-color:#07c160}.bg-\[\#07C160\]\/5{background-color:#07c1600d}.bg-\[\#07C160\]\/10{background-color:#07c1601a}.bg-\[\#38bdac\]{background-color:#38bdac}.bg-\[\#38bdac\]\/5{background-color:#38bdac0d}.bg-\[\#38bdac\]\/10{background-color:#38bdac1a}.bg-\[\#38bdac\]\/15{background-color:#38bdac26}.bg-\[\#38bdac\]\/20{background-color:#38bdac33}.bg-\[\#38bdac\]\/30{background-color:#38bdac4d}.bg-\[\#38bdac\]\/60{background-color:#38bdac99}.bg-\[\#38bdac\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#162840\]{background-color:#162840}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/10{background-color:#6a72821a}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/10{background-color:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-600\/20{background-color:#4a556533}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/20{background-color:color-mix(in oklab,var(--color-gray-600)20%,transparent)}}.bg-gray-600\/50{background-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/50{background-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.bg-gray-700{background-color:var(--color-gray-700)}.bg-gray-700\/50{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.bg-gray-700\/50{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab,red,red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/80{background-color:#82181acc}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/80{background-color:color-mix(in oklab,var(--color-red-900)80%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/5{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-\[\#0f2137\]{--tw-gradient-from:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#00CED1\]{--tw-gradient-from:#00ced1;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#38bdac\]\/10{--tw-gradient-from:oklab(72.378% -.11483 -.0053193/.1);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/20{--tw-gradient-from:#3080ff33}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.from-blue-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-cyan-500\/20{--tw-gradient-from:#00b7d733}@supports (color:color-mix(in lab,red,red)){.from-cyan-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.from-cyan-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-green-500\/20{--tw-gradient-from:#00c75833}@supports (color:color-mix(in lab,red,red)){.from-green-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.from-green-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/20{--tw-gradient-from:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.from-purple-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/20{--tw-gradient-from:#edb20033}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.from-yellow-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-\[\#38bdac\]\/30{--tw-gradient-via:oklab(72.378% -.11483 -.0053193/.3);--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-\[\#0f2137\]{--tw-gradient-to:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#20B2AA\]{--tw-gradient-to:#20b2aa;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#162d4a\]{--tw-gradient-to:#162d4a;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-amber-500\/20{--tw-gradient-to:#f99c0033}@supports (color:color-mix(in lab,red,red)){.to-amber-500\/20{--tw-gradient-to:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.to-amber-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-cyan-500\/5{--tw-gradient-to:#00b7d70d}@supports (color:color-mix(in lab,red,red)){.to-cyan-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-cyan-500)5%,transparent)}}.to-cyan-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-green-500\/5{--tw-gradient-to:#00c7580d}@supports (color:color-mix(in lab,red,red)){.to-green-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-green-500)5%,transparent)}}.to-green-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-purple-500\/5{--tw-gradient-to:#ac4bff0d}@supports (color:color-mix(in lab,red,red)){.to-purple-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-purple-500)5%,transparent)}}.to-purple-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-yellow-500\/5{--tw-gradient-to:#edb2000d}@supports (color:color-mix(in lab,red,red)){.to-yellow-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.to-yellow-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-repeat{background-repeat:repeat}.mask-no-clip{-webkit-mask-clip:no-clip;mask-clip:no-clip}.mask-repeat{-webkit-mask-repeat:repeat;mask-repeat:repeat}.fill-amber-400{fill:var(--color-amber-400)}.fill-current{fill:currentColor}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.px-0{padding-inline:calc(var(--spacing)*0)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-5{padding-block:calc(var(--spacing)*5)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-10{padding-block:calc(var(--spacing)*10)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-5{padding-top:calc(var(--spacing)*5)}.pt-6{padding-top:calc(var(--spacing)*6)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-4{padding-right:calc(var(--spacing)*4)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-6{--tw-leading:calc(var(--spacing)*6);line-height:calc(var(--spacing)*6)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-wrap{text-wrap:wrap}.wrap-break-word{overflow-wrap:break-word}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#00CED1\]{color:#00ced1}.text-\[\#07C160\]{color:#07c160}.text-\[\#07C160\]\/60{color:#07c16099}.text-\[\#07C160\]\/70{color:#07c160b3}.text-\[\#07C160\]\/80{color:#07c160cc}.text-\[\#26A17B\]{color:#26a17b}.text-\[\#38bdac\]{color:#38bdac}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/30{color:#fcbb004d}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/30{color:color-mix(in oklab,var(--color-amber-400)30%,transparent)}}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400)80%,transparent)}}.text-amber-400\/90{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/90{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.text-black{color:var(--color-black)}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/60{color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/60{color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-400\/60{color:#54a2ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-400\/60{color:color-mix(in oklab,var(--color-blue-400)60%,transparent)}}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-200{color:var(--color-gray-200)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/90{color:#05df72e6}@supports (color:color-mix(in lab,red,red)){.text-green-400\/90{color:color-mix(in oklab,var(--color-green-400)90%,transparent)}}.text-green-500{color:var(--color-green-500)}.text-orange-300{color:var(--color-orange-300)}.text-orange-300\/60{color:#ffb96d99}@supports (color:color-mix(in lab,red,red)){.text-orange-300\/60{color:color-mix(in oklab,var(--color-orange-300)60%,transparent)}}.text-orange-400{color:var(--color-orange-400)}.text-orange-400\/60{color:#ff8b1a99}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/60{color:color-mix(in oklab,var(--color-orange-400)60%,transparent)}}.text-orange-400\/70{color:#ff8b1ab3}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/70{color:color-mix(in oklab,var(--color-orange-400)70%,transparent)}}.text-orange-400\/80{color:#ff8b1acc}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/80{color:color-mix(in oklab,var(--color-orange-400)80%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-red-100{color:var(--color-red-100)}.text-red-300{color:var(--color-red-300)}.text-red-400{color:var(--color-red-400)}.text-rose-400{color:var(--color-rose-400)}.text-sky-300{color:var(--color-sky-300)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-400\/60{color:#fac80099}@supports (color:color-mix(in lab,red,red)){.text-yellow-400\/60{color:color-mix(in oklab,var(--color-yellow-400)60%,transparent)}}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.capitalize{text-transform:capitalize}.lowercase{text-transform:lowercase}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.italic\!{font-style:italic!important}.not-italic{font-style:normal}.diagonal-fractions{--tw-numeric-fraction:diagonal-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.lining-nums{--tw-numeric-figure:lining-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.oldstyle-nums{--tw-numeric-figure:oldstyle-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.proportional-nums{--tw-numeric-spacing:proportional-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.slashed-zero{--tw-slashed-zero:slashed-zero;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.stacked-fractions{--tw-numeric-fraction:stacked-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.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,)}.normal-nums{font-variant-numeric:normal}.line-through{text-decoration-line:line-through}.no-underline{text-decoration-line:none}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.underline\!{text-decoration-line:underline!important}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.subpixel-antialiased{-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto}.accent-\[\#38bdac\]{accent-color:#38bdac}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-55{opacity:.55}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.inset-ring{--tw-inset-ring-shadow:inset 0 0 0 1px var(--tw-inset-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[\#38bdac\]\/20{--tw-shadow-color:#38bdac33}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/20{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.2) var(--tw-shadow-alpha),transparent)}}.shadow-\[\#38bdac\]\/30{--tw-shadow-color:#38bdac4d}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/30{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.3) var(--tw-shadow-alpha),transparent)}}.ring-\[\#38bdac\]{--tw-ring-color:#38bdac}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.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-3xl{--tw-blur:blur(var(--blur-3xl));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,)}.drop-shadow{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#0000001a))drop-shadow(0 1px 1px var(--tw-drop-shadow-color,#0000000f));--tw-drop-shadow:drop-shadow(0 1px 2px #0000001a)drop-shadow(0 1px 1px #0000000f);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,)}.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,)!important}.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-xl{--tw-backdrop-blur:blur(var(--blur-xl));-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-grayscale{--tw-backdrop-grayscale:grayscale(100%);-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-invert{--tw-backdrop-invert:invert(100%);-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-sepia{--tw-backdrop-sepia:sepia(100%);-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-filter{-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,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition\!{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events!important;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))!important;transition-duration:var(--tw-duration,var(--default-transition-duration))!important}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}@media(hover:hover){.group-hover\:text-\[\#38bdac\]:is(:where(.group):hover *){color:#38bdac}.group-hover\:text-gray-400:is(:where(.group):hover *){color:var(--color-gray-400)}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.peer-disabled\:opacity-70:is(:where(.peer):disabled~*){opacity:.7}.placeholder\:text-gray-500::placeholder{color:var(--color-gray-500)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-\[\#38bdac\]\/30:hover{border-color:#38bdac4d}.hover\:border-\[\#38bdac\]\/50:hover{border-color:#38bdac80}.hover\:border-\[\#38bdac\]\/60:hover{border-color:#38bdac99}.hover\:border-\[\#38bdac\]\/70:hover{border-color:#38bdacb3}.hover\:border-blue-500\/60:hover{border-color:#3080ff99}@supports (color:color-mix(in lab,red,red)){.hover\:border-blue-500\/60:hover{border-color:color-mix(in oklab,var(--color-blue-500)60%,transparent)}}.hover\:border-gray-500:hover{border-color:var(--color-gray-500)}.hover\:border-gray-600:hover{border-color:var(--color-gray-600)}.hover\:border-orange-500\/50:hover{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.hover\:border-orange-500\/50:hover{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.hover\:border-yellow-500\/60:hover{border-color:#edb20099}@supports (color:color-mix(in lab,red,red)){.hover\:border-yellow-500\/60:hover{border-color:color-mix(in oklab,var(--color-yellow-500)60%,transparent)}}.hover\:bg-\[\#0a1628\]:hover{background-color:#0a1628}.hover\:bg-\[\#0a1628\]\/80:hover{background-color:#0a1628cc}.hover\:bg-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-emerald-500\/20:hover{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/20:hover{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.hover\:bg-gray-500:hover{background-color:var(--color-gray-500)}.hover\:bg-gray-500\/20:hover{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-500\/20:hover{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-gray-700\/50:hover{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-700\/50:hover{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.hover\:bg-gray-800:hover{background-color:var(--color-gray-800)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-500\/10:hover{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/10:hover{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.hover\:bg-orange-500\/20:hover{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/20:hover{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.hover\:bg-orange-600:hover{background-color:var(--color-orange-600)}.hover\:bg-purple-500\/10:hover{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/10:hover{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.hover\:bg-purple-500\/20:hover{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/20:hover{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.hover\:bg-purple-500\/30:hover{background-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/30:hover{background-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-red-800\/50:hover{background-color:#9f071280}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-800\/50:hover{background-color:color-mix(in oklab,var(--color-red-800)50%,transparent)}}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/20:hover{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/20:hover{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.hover\:bg-yellow-500\/20:hover{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:text-\[\#2da396\]:hover{color:#2da396}.hover\:text-\[\#5fe0cd\]:hover{color:#5fe0cd}.hover\:text-\[\#38bdac\]:hover{color:#38bdac}.hover\:text-amber-200:hover{color:var(--color-amber-200)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-400:hover{color:var(--color-amber-400)}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-green-400:hover{color:var(--color-green-400)}.hover\:text-orange-400:hover{color:var(--color-orange-400)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-sky-200:hover{color:var(--color-sky-200)}.hover\:text-white:hover{color:var(--color-white)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}}.focus\:border-\[\#38bdac\]:focus{border-color:#38bdac}.focus\:border-orange-500\/50:focus{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.focus\:border-orange-500\/50:focus{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.focus\:bg-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-\[\#38bdac\]:focus{--tw-ring-color:#38bdac}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-0:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[\#38bdac\]:focus-visible{--tw-ring-color:#38bdac}.focus-visible\:ring-red-500:focus-visible{--tw-ring-color:var(--color-red-500)}.focus-visible\:ring-offset-0:focus-visible{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-\[\#0a1628\]:focus-visible{--tw-ring-offset-color:#0a1628}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing)*2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing)*3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing)*4)}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=active\]\:bg-\[\#07C160\]\/20[data-state=active]{background-color:#07c16033}.data-\[state\=active\]\:bg-\[\#26A17B\]\/20[data-state=active]{background-color:#26a17b33}.data-\[state\=active\]\:bg-\[\#38bdac\]\/20[data-state=active]{background-color:#38bdac33}.data-\[state\=active\]\:bg-\[\#1677FF\]\/20[data-state=active]{background-color:#1677ff33}.data-\[state\=active\]\:bg-\[\#003087\]\/20[data-state=active]{background-color:#00308733}.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.data-\[state\=active\]\:font-medium[data-state=active]{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.data-\[state\=active\]\:text-\[\#07C160\][data-state=active]{color:#07c160}.data-\[state\=active\]\:text-\[\#26A17B\][data-state=active]{color:#26a17b}.data-\[state\=active\]\:text-\[\#38bdac\][data-state=active]{color:#38bdac}.data-\[state\=active\]\:text-\[\#169BD7\][data-state=active]{color:#169bd7}.data-\[state\=active\]\:text-\[\#1677FF\][data-state=active]{color:#1677ff}.data-\[state\=active\]\:text-amber-400[data-state=active]{color:var(--color-amber-400)}.data-\[state\=active\]\:text-purple-400[data-state=active]{color:var(--color-purple-400)}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=checked\]\:bg-\[\#38bdac\][data-state=checked]{background-color:#38bdac}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-gray-600[data-state=unchecked]{background-color:var(--color-gray-600)}@media(min-width:40rem){.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:text-left{text-align:left}}@media(min-width:48rem){.md\:col-span-2{grid-column:span 2/span 2}.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-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:64rem){.lg\:block{display:block}.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-8{grid-template-columns:repeat(8,minmax(0,1fr))}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:calc(var(--spacing)*0)}.\[\&\>span\]\:line-clamp-1>span{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}}:root{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20% .02 240);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20% .02 240);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(65% .15 180);--primary-foreground:oklch(20% 0 0);--secondary:oklch(27% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(27% 0 0);--muted-foreground:oklch(65% 0 0);--accent:oklch(27% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(55% .2 25);--destructive-foreground:oklch(98.5% 0 0);--border:oklch(35% 0 0);--input:oklch(35% 0 0);--ring:oklch(65% .15 180);--radius:.625rem}body{font-family:var(--font-sans);color:var(--foreground);background:#0a1628}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-pan-x{syntax:"*";inherits:false}@property --tw-pan-y{syntax:"*";inherits:false}@property --tw-pinch-zoom{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/soul-admin/dist/index.html b/soul-admin/dist/index.html index 4339038c..0a1b61ad 100644 --- a/soul-admin/dist/index.html +++ b/soul-admin/dist/index.html @@ -4,8 +4,8 @@ 管理后台 - Soul创业派对 - - + +
    diff --git a/soul-api/devloy.py b/soul-api/devloy.py index 5acf5df3..70e62359 100644 --- a/soul-api/devloy.py +++ b/soul-api/devloy.py @@ -775,7 +775,7 @@ def deploy_runner_container(cfg): sftp.close() cmd = ( "mkdir -p %s && cd %s && gunzip -c soul_runner_image.tar.gz | docker load && " - "docker compose -f docker-compose.runner.standalone.yml up -d && " + "docker-compose -f docker-compose.runner.standalone.yml up -d && " "rm -f soul_runner_image.tar.gz && echo OK" ) % (deploy_path, deploy_path) stdin, stdout, stderr = client.exec_command(cmd, timeout=300) diff --git a/soul-api/wechat/info.log b/soul-api/wechat/info.log index 969f7e41..edaac6ac 100644 --- a/soul-api/wechat/info.log +++ b/soul-api/wechat/info.log @@ -74,3 +74,11 @@ {"level":"debug","timestamp":"2026-03-20T13:35:34+08:00","caller":"kernel/baseClient.go:459","content":"------------------response content:HTTP/1.1 200 OK\r\nContent-Length: 250\r\nCache-Control: no-cache, must-revalidate\r\nConnection: keep-alive\r\nContent-Language: zh-CN\r\nContent-Type: application/json; charset=utf-8\r\nDate: Fri, 20 Mar 2026 05:35:33 GMT\r\nKeep-Alive: timeout=8\r\nRequest-Id: 08A5B9F3CD0610D00118C3B9F8AF012098C81228AAF801-0\r\nServer: nginx\r\nWechatpay-Nonce: 3ac56a1aba0043f64f699ffe371ebabe\r\nWechatpay-Serial: 5F2543BF58239A4EB68FA4433DF1438A88B34B16\r\nWechatpay-Signature: tJsbXVjsXPLgAzH1ETyBrZ+xsrwmgOnT+sH8JmcqlyxUkFGCFkiqm+5DiKhE07f60dHXGeOSS4qrBzR37HzZitTeqodR7E2JB0Ut5xFbBKQL39nMDvB314u3CmklcjRrrUuSayXNUHrINYYwizfaj3GQMWlytWiS/IuC8rKhOSD1LxKQRUZvs9YD/v2EtjJrU8rXqIJdtdpAggMdIxl88oGR9/cPqBE+fSrngtqJtS+8HXfClPhrDOka1ah/faeHsQxYnb9Izglix057mv7W6vUBIjlbPsTxL1dREPQyyZ9UumcbPgnXXHkJ4iufXD61KPDPHtJjMQRaoLyZMCKR7A==\r\nWechatpay-Signature-Type: WECHATPAY2-SHA256-RSA2048\r\nWechatpay-Timestamp: 1773984933\r\nX-Content-Type-Options: nosniff\r\n\r\n{\"amount\":{\"payer_currency\":\"CNY\",\"total\":1000},\"appid\":\"wxb8bbb2b10dec74aa\",\"mchid\":\"1318592501\",\"out_trade_no\":\"MP20260320130728781800\",\"promotion_detail\":[],\"scene_info\":{\"device_id\":\"\"},\"trade_state\":\"NOTPAY\",\"trade_state_desc\":\"订单未支付\"}"} {"level":"debug","timestamp":"2026-03-20T13:35:34+08:00","caller":"kernel/baseClient.go:457","content":"GET https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/MP20260320130734906900?mchid=1318592501 request header: { Authorization:WECHATPAY2-SHA256-RSA2048 mchid=\"1318592501\",nonce_str=\"F4jAe1o38Lshn82q3fXtEKVPM1DONLof\",timestamp=\"1773984934\",serial_no=\"4A1DB62CD5C9BE0B6FC51C30621D6F99686E75C5\",signature=\"TIlP8QQWNG3f+RHfZefrC7CIaovaFw6JW0V8O5r6bbPu37/aKwItYZcWKlfIkv/oxQDc1hYEx/u3EU+Wwj51DemXo4ct2phaBjLH7bc2KVM5lJEOFSODme9AKlrWiu8etlYESCjSZ01TXwrD1VFoIO3Ga16TNa7xV9Y4V9MXnkcvd2v1OUHpIwB1VjjrKvpoC31959mQfXOKvJ8aLTdru+IjYuCYlMIlz7hIy6tNTpzfHA0biVsHSU8Y4ap301GeuyRp4GQdS0px8pJR0wN7BXuuXuUA3GO6vNqVCREveYcEAaFOgz0GDyCAqYiVk5MMXNNueLqGmUXBz9mvj9d/Mw==\"Accept:*/*Content-Type:application/json} request body:"} {"level":"debug","timestamp":"2026-03-20T13:35:34+08:00","caller":"kernel/baseClient.go:459","content":"------------------response content:HTTP/1.1 200 OK\r\nContent-Length: 250\r\nCache-Control: no-cache, must-revalidate\r\nConnection: keep-alive\r\nContent-Language: zh-CN\r\nContent-Type: application/json; charset=utf-8\r\nDate: Fri, 20 Mar 2026 05:35:33 GMT\r\nKeep-Alive: timeout=8\r\nRequest-Id: 08A5B9F3CD0610A60318FACDC0552094913028E68402-0\r\nServer: nginx\r\nWechatpay-Nonce: c8cd238aa151bc5b3562d983525c9a10\r\nWechatpay-Serial: 5F2543BF58239A4EB68FA4433DF1438A88B34B16\r\nWechatpay-Signature: cU4LnoqphDCn40rM/L3JSxkg6E3H9TZXBZ2xFed9nrEt885jzrXhZACABPs+o9Pw6yyIoPDbzTukJlAZNQTZT/6zliHHuP4Wp+XF1HnWm/AxbDQwK6t23GtzY8L60ZgCJQN7xbnjqHmwKL2cX86ZB9lWGvoAcMXRhLKN3McoicwTC4268Z7xwSvUGBbIv3zmawbXZkqiYKckowym8kEHP9KXzV/7SEwwvW3CIGmloTukwcpaYOtJSRuit6/A3uz25ryxrgHT2gIudNRpW/SRKV/+M5uCd8gsJgQX27IE+KW58BnUu7oP0JC0PZXtvBHheSXo/9PmfBQVRt4Bgsbqtg==\r\nWechatpay-Signature-Type: WECHATPAY2-SHA256-RSA2048\r\nWechatpay-Timestamp: 1773984933\r\nX-Content-Type-Options: nosniff\r\n\r\n{\"amount\":{\"payer_currency\":\"CNY\",\"total\":1000},\"appid\":\"wxb8bbb2b10dec74aa\",\"mchid\":\"1318592501\",\"out_trade_no\":\"MP20260320130734906900\",\"promotion_detail\":[],\"scene_info\":{\"device_id\":\"\"},\"trade_state\":\"NOTPAY\",\"trade_state_desc\":\"订单未支付\"}"} +{"level":"debug","timestamp":"2026-03-20T13:40:34+08:00","caller":"kernel/baseClient.go:457","content":"GET https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/MP20260320130728781800?mchid=1318592501 request header: { Content-Type:application/jsonAuthorization:WECHATPAY2-SHA256-RSA2048 mchid=\"1318592501\",nonce_str=\"J1pqkGs4r9ufJmtmovx3Cmohp0AVzD1p\",timestamp=\"1773985233\",serial_no=\"4A1DB62CD5C9BE0B6FC51C30621D6F99686E75C5\",signature=\"YcC2AmHsM/4iEuchlI60nv43aVTuEiCEKHCsJgxy0Ai0PhYuJJpyUoJJJegjcGSKqWPqGBuQxhNO93dVdWVSoYWpxUgX0DFpWfgSwSJyA7ORL5Zih1tQ9Y+bRZNR2SUrH4/a3IHDgKB5pEBg9JqeRXZSSzIjFda/mBFRMvHEZqGNWZaXc2YUxTtGIQJcTOYvz/69PgsiT8KwyzrWndgi/Kl77L1NtGpHQMvijCsNfrMDd7OgF8GPt6kiR+c94pQPRLl1yNJJ1bOkYTA5o5gOwgOnKLz+AgzVFTW1mHBnOnKFWp16tE1ppu2nBd/BV3RDs7A/riV+WteSkfRSyfN6kw==\"Accept:*/*} request body:"} +{"level":"debug","timestamp":"2026-03-20T13:40:34+08:00","caller":"kernel/baseClient.go:459","content":"------------------response content:HTTP/1.1 200 OK\r\nContent-Length: 250\r\nCache-Control: no-cache, must-revalidate\r\nConnection: keep-alive\r\nContent-Language: zh-CN\r\nContent-Type: application/json; charset=utf-8\r\nDate: Fri, 20 Mar 2026 05:40:33 GMT\r\nKeep-Alive: timeout=8\r\nRequest-Id: 08D1BBF3CD0610F30118B9B4F8AF0120CC933228B19E05-0\r\nServer: nginx\r\nWechatpay-Nonce: b9df57e2e45c6e3daaf7587ae548dae7\r\nWechatpay-Serial: 5F2543BF58239A4EB68FA4433DF1438A88B34B16\r\nWechatpay-Signature: a6eIinFWYfNr7C2vNL+oxWVo8gKXwg5/l5+pmFHnQFB23ziIBzAYmOdCmbY93Wyy9iPoqJoltohjpGAwHno61Zdz/PVAxEtuQ3bU23nr6h3YhRa4wYJxGqNlrQg+Mx6WP3uaYcRzF0x7BMo0OQDCNiJs9oaaswQlSnZPrSZJhDfYuhhR5GXWqRkvfHh6efayvosWung+91KoYDRKVnZEuxYNwwZhRMNcQcBhwb+gGw8qirzTrv4tCsgqOT8mOQYiG+z+P6dKcym0VMnWoJIeuPR68C+5Sx7K8C0g/3F8/YJqQZPnWPNN3icFIgEY+stS6tJ0/6O0gHv49PCdetZyKA==\r\nWechatpay-Signature-Type: WECHATPAY2-SHA256-RSA2048\r\nWechatpay-Timestamp: 1773985233\r\nX-Content-Type-Options: nosniff\r\n\r\n{\"amount\":{\"payer_currency\":\"CNY\",\"total\":1000},\"appid\":\"wxb8bbb2b10dec74aa\",\"mchid\":\"1318592501\",\"out_trade_no\":\"MP20260320130728781800\",\"promotion_detail\":[],\"scene_info\":{\"device_id\":\"\"},\"trade_state\":\"NOTPAY\",\"trade_state_desc\":\"订单未支付\"}"} +{"level":"debug","timestamp":"2026-03-20T13:40:34+08:00","caller":"kernel/baseClient.go:457","content":"GET https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/MP20260320130734906900?mchid=1318592501 request header: { Content-Type:application/jsonAuthorization:WECHATPAY2-SHA256-RSA2048 mchid=\"1318592501\",nonce_str=\"AC0lRpeh3hYl39CPzGGmTPIS2JAdf7kx\",timestamp=\"1773985234\",serial_no=\"4A1DB62CD5C9BE0B6FC51C30621D6F99686E75C5\",signature=\"Gzk8hxM6I8DpDa/YYrSEqBXKVxMAfswSmY9fA4BiwGwCftGZzISk1ywGO+2RGvr7qR+7rjH36vTum/j3fb90WUopAtW2yJt42uFpuXyoHL3dw4aO6GAeNMT1BAsixXR82w+KwyYnHOMD29qgmZMzQScn+o6ID6zhCT0TusQY885R9YQN7XmnyxsNJhYchlWN5N3pBJSeDVFrlwy8RR2+ZvyRYtHy69m2Vm8rnL44cRNX0jhYyOph5ofeOYcxAL2nHRYHfuOxpjszPA1BWBHHwTm/G1Ql9VW1ZVM41N0+tfsSuAGncYfkEIkqHmEXosHvJMLle1utod879SFF5R3vXw==\"Accept:*/*} request body:"} +{"level":"debug","timestamp":"2026-03-20T13:40:34+08:00","caller":"kernel/baseClient.go:459","content":"------------------response content:HTTP/1.1 200 OK\r\nContent-Length: 250\r\nCache-Control: no-cache, must-revalidate\r\nConnection: keep-alive\r\nContent-Language: zh-CN\r\nContent-Type: application/json; charset=utf-8\r\nDate: Fri, 20 Mar 2026 05:40:33 GMT\r\nKeep-Alive: timeout=8\r\nRequest-Id: 08D1BBF3CD0610C804188EC8C05520CEB40728EEC304-0\r\nServer: nginx\r\nWechatpay-Nonce: 40782685ba30351314483606d380e1b0\r\nWechatpay-Serial: 5F2543BF58239A4EB68FA4433DF1438A88B34B16\r\nWechatpay-Signature: lCv+RTz7EyD7pg/TCP+EOS+iPm5ks3uYPZ0CHeL9U8JvW/jSo5IziNC5HAHrRoA/2kgusr/PF1/0JbogjvLpJj1dNjQhlQrhu2qvtDwV5aafkPPkRIEnE6GwKxK0qYUbk/Kf4Q3yPpodSsluOioLzRAE9fDabcaIBt0ier+r2dpQZ6ObEx+jkVoyxf07FMSFNiROClJKmFaITP+DtdjmARpEc4uzZpeVLgk6o18nHe/r/1r+7TO+jo1LgZF6vj9pUXkoWP5gjQjFUNCbGJMLbDLQgkOhn0JbQjIpN82Woi8FOhFdRUCQfCASBbSFpDcBfydi6FNqaZcpB2bX5Msh5A==\r\nWechatpay-Signature-Type: WECHATPAY2-SHA256-RSA2048\r\nWechatpay-Timestamp: 1773985233\r\nX-Content-Type-Options: nosniff\r\n\r\n{\"amount\":{\"payer_currency\":\"CNY\",\"total\":1000},\"appid\":\"wxb8bbb2b10dec74aa\",\"mchid\":\"1318592501\",\"out_trade_no\":\"MP20260320130734906900\",\"promotion_detail\":[],\"scene_info\":{\"device_id\":\"\"},\"trade_state\":\"NOTPAY\",\"trade_state_desc\":\"订单未支付\"}"} +{"level":"debug","timestamp":"2026-03-20T13:51:02+08:00","caller":"kernel/accessToken.go:381","content":"GET https://api.weixin.qq.com/cgi-bin/token?appid=wxb8bbb2b10dec74aa&grant_type=client_credential&neededText=&secret=3c1fb1f63e6e052222bbcead9d07fe0c request header: { Accept:*/*} "} +{"level":"debug","timestamp":"2026-03-20T13:51:02+08:00","caller":"kernel/accessToken.go:383","content":"------------------response content:HTTP/1.1 200 OK\r\nContent-Length: 174\r\nConnection: keep-alive\r\nContent-Type: application/json; encoding=utf-8\r\nDate: Fri, 20 Mar 2026 05:51:01 GMT\r\n\r\n{\"access_token\":\"102_q0Pwcij9HevkF1S3emEoJBECS3UyMRcGqUkz5ot41QOeP_Qo-AaeayA2e9WuJh3mebufTiBJEu7eXwXThAgAbR9LYsn0QFMXVrVg9Q1WR4_Xdwy9xdHbiO5JhpICBAeAHAPON\",\"expires_in\":7200}"} +{"level":"debug","timestamp":"2026-03-20T13:51:02+08:00","caller":"kernel/baseClient.go:457","content":"GET https://api.weixin.qq.com/sns/jscode2session?access_token=102_q0Pwcij9HevkF1S3emEoJBECS3UyMRcGqUkz5ot41QOeP_Qo-AaeayA2e9WuJh3mebufTiBJEu7eXwXThAgAbR9LYsn0QFMXVrVg9Q1WR4_Xdwy9xdHbiO5JhpICBAeAHAPON&appid=wxb8bbb2b10dec74aa&grant_type=authorization_code&js_code=0b3jvdGa1Q6VoL0cTlHa1BJvuq3jvdGA&secret=3c1fb1f63e6e052222bbcead9d07fe0c request header: { Accept:*/*} "} +{"level":"debug","timestamp":"2026-03-20T13:51:02+08:00","caller":"kernel/baseClient.go:459","content":"------------------response content:HTTP/1.1 200 OK\r\nContent-Length: 82\r\nConnection: keep-alive\r\nContent-Type: text/plain\r\nDate: Fri, 20 Mar 2026 05:51:01 GMT\r\n\r\n{\"session_key\":\"R/QHH5/k9JfJYETxk2lLDQ==\",\"openid\":\"ogpTW5fmXRGNpoUbXB3UEqnVe5Tg\"}"} diff --git a/soul-api/文档索引.md b/soul-api/文档索引.md index 3324da41..4cefea64 100644 --- a/soul-api/文档索引.md +++ b/soul-api/文档索引.md @@ -2,12 +2,14 @@ > 相关文档已统一移至 **开发文档**。 -- [6、后端/管理端鉴权设计](../开发文档/6、后端/管理端鉴权设计.md) -- [6、后端/miniprogram接口补全说明](../开发文档/6、后端/miniprogram接口补全说明.md) -- [8、部署/宝塔反向代理说明](../开发文档/8、部署/宝塔反向代理说明.md) +- [8、部署/部署总览](../开发文档/8、部署/部署总览.md) — 部署入口 - [8、部署/DOCKER部署说明](../开发文档/8、部署/DOCKER部署说明.md) +- [8、部署/宝塔-Docker首次配置指南](../开发文档/8、部署/宝塔-Docker首次配置指南.md) +- [8、部署/宝塔反向代理说明](../开发文档/8、部署/宝塔反向代理说明.md) - [8、部署/提现功能完整技术文档](../开发文档/8、部署/提现功能完整技术文档.md) - [8、部署/订阅消息](../开发文档/8、部署/订阅消息.md) - [8、部署/商家转账](../开发文档/8、部署/商家转账.md) +- [6、后端/管理端鉴权设计](../开发文档/6、后端/管理端鉴权设计.md) +- [6、后端/miniprogram接口补全说明](../开发文档/6、后端/miniprogram接口补全说明.md) -详见 [开发文档 README](../开发文档/README.md)。 +详见 [开发文档索引](../开发文档/索引.md)。 diff --git a/开发文档/10、项目管理/README.md b/开发文档/10、项目管理/README.md new file mode 100644 index 00000000..7a742e13 --- /dev/null +++ b/开发文档/10、项目管理/README.md @@ -0,0 +1,8 @@ +# 10、项目管理 + +> 里程碑、运营与变更 + +| 文件 | 用途 | +|------|------| +| [项目落地推进表](项目落地推进表.md) | 当前阶段、里程碑、风险与阻塞、永平落地 | +| [运营与变更](运营与变更.md) | 运营数据、soul-admin 变更、近期讨论、技术决策 | diff --git a/开发文档/10、项目管理/运营与变更.md b/开发文档/10、项目管理/运营与变更.md index 9dc0a593..fc03b270 100644 --- a/开发文档/10、项目管理/运营与变更.md +++ b/开发文档/10、项目管理/运营与变更.md @@ -171,6 +171,29 @@ VIP 接口、章节推荐逻辑、数据库依赖 --- +## 小程序登录改为手机号一键登录(2026-03-20 橙子同步) + +### 变更摘要 + +| 项目 | 说明 | +|------|------| +| **登录方式** | 主登录改为「手机号一键登录」,按钮文案统一;用户拒绝手机号时回退微信静默登录 | +| **公用组件** | 新增 `components/login-modal`,read、my、gift-pay/detail 引入,去除三处重复实现 | +| **隐私协议** | getPhoneNumber 必须 `open-type="getPhoneNumber\|agreePrivacyAuthorization"`;onNeedPrivacyAuthorization 支持 read/my/gift-pay/index/settings | +| **手机号同步** | 登录后若 user.phone 为空,从 profile 拉取并更新本地 userInfo | + +### 管理后台配置 + +- 小程序管理后台 → 设置 → 用户隐私保护指引,必须声明「收集你选择的手机号」 +- 个人主体小程序无法使用 getPhoneNumber + +### 经验入库 + +- `agent/小程序开发工程师/evolution/2026-03-20-手机号登录与公用组件.md` +- miniprogram-dev SKILL §8 已补充 getPhoneNumber 耦合与 login-modal 约定 + +--- + # 第七部分:开发进度同步(2026-02-27 橙子) ## 三端开发进度汇报 @@ -509,3 +532,31 @@ Mycontent-temp/miniprogram 为样式预览分支,miniprogram 为线上主线 - `开发文档/代付-业务线框图.md`:流程、角色映射、领取记录、UI 规则 - `开发文档/代付-简化流程设计.md`:改动清单全部标记已完成 - `开发文档/代付-需求分析与待完善.md`:已实现项与待确认项 + +--- + +# 第二十一部分:提现功能完善(2026-03-20 橙子同步) + +## 变更摘要 + +| 项 | 说明 | +|------|------| +| **审批逻辑修复** | 批准时校验「累计佣金-已提现>=待审核」,避免本笔在 pending 中导致误拒;使用 -0.01 浮点容差 | +| **我的收益字段** | 小程序我的页「我的收益」取 availableEarnings(可提现金额),不再显示累计佣金 | +| **提现手续费** | 推广设置「提现规则」增加「提现手续费(%)」可配置;批准时按比例扣除后打款 | +| **自动审批开关** | 推广中心-提现审核列表与搜索框同行增加「自动审批」开关;与推广设置 enableAutoWithdraw 同源 | +| **备注列** | 提现列表增加「备注」列:失败时显示 fail_reason/error_message,否则显示用户 remark | +| **失败记录** | 打款失败/拒绝时落库 fail_reason、error_message;Withdrawal 模型增加 ErrorMessage 字段 | + +## 提现规则配置(referral_config)使用情况 + +| 配置项 | 使用位置 | +|--------|----------| +| minWithdrawAmount | 后端申请校验;小程序推广中心「满 X 元可提现」 | +| withdrawFee | 后端批准时扣除;管理端推广设置可配置 | +| enableAutoWithdraw | 后端 WithdrawPost 后自动审批;管理端推广设置 + 提现审核开关 | + +## 相关文档 + +- `开发文档/1、需求/三端需求整理.md`:按小程序/管理端/后端分类的需求整理 +- `开发文档/1、需求/需求汇总.md`:需求清单已追加 2026-03-20 提现相关条目 diff --git a/开发文档/1、需求/2026-03-20-需求.md b/开发文档/1、需求/2026-03-20-需求.md new file mode 100644 index 00000000..a9237fb8 --- /dev/null +++ b/开发文档/1、需求/2026-03-20-需求.md @@ -0,0 +1,63 @@ +# Soul 创业派对 - 需求汇总 + +> **主需求文件**(日期最新)。基准:《[以界面定需求](以界面定需求.md)》 + +--- + +## 需求基准 + +- 需求以《以界面定需求》为准,以界面定需求 +- 需求文件命名:`YYYY-MM-DD-需求.md`,**日期最新的为主需求文件** +- 同步需求时:新建或更新当日需求文件,并更新本目录 `索引.md` + +--- + +## 需求清单 + +| 日期 | 描述 | 状态 | 备注 | +|------|------|------|------| +| 2026-02 | 内容管理页仅保留「API 接口」按钮 | 已完成 | soul-admin ContentPage | +| 2026-02 | 侧栏与分销页「交易中心」→「推广中心」 | 已完成 | AdminLayout、DistributionPage | +| 2026-02 | 推广中心/我的收益:绑定中、已付款、已过期清晰展示 | 已有 | referral 页 | +| 2026-02 | 海报小程序码带用户 ID(scene ref=userId) | 已完成 | referral.js generatePoster | +| 2026-02 | 复制朋友圈文案去掉「专属邀请码」展示 | 已完成 | 海报 | +| 2026-02 | 我的页:待领收益→我的收益、头像/昵称/ID 一键获取 | 已有 | my.wxml | +| 2026-02 | 设置页:手机/微信号一键获取、自动提现默认开启 | 已有 | settings.js | +| 2026-02 | 后台与前台参数一致(绑定有效期、自动提现、免费章节等) | 已检查 | 推广设置 | +| 2026-02 | 找伙伴匹配后台用户库、资源对接两步 | 已有 | match 页 | +| 2026-02 | VIP 手动设置 + 支付设置 + 日志 | 已完成 | 用户详情弹窗、支付回调 | +| 2026-02 | 管理端设置 VIP 必填到期日 | 已完成 | 前后端校验 | +| 2026-02 | 会员订单分润差异化(会员 20% / 非会员 10%) | 已完成 | computeOrderCommission | +| 2026-02 | VIP 设置入口拆分、SetVipModal、VIP 角色管理 | 已完成 | UserDetailModal、SetVipModal | +| 2026-02 | VIP 排序:vip_activated_at、vip_sort | 已完成 | VipMembers | +| 2026-02 | VIP 角色:可选择 + 可手动填写 | 已完成 | vip_roles 表 | +| 2026-03-08 | 文章阅读付费规则:免费章节以 free_chapters 为准;VIP 全章免费 | 已完成 | soul-api book.go | +| 2026-03-10 | 我的页阅读统计改为后端接口(真实数据) | 已完成 | loadDashboardStats | +| 2026-03-10 | 富文本渲染升级(TipTap HTML → rich-text,保留 @mention) | 待实施 | 确认 DB 格式 | +| 2026-03-16 | 文章编辑 @某人/#标签 自动创建并同步存客宝 | 已完成 | ParseAutoLinkContent | +| 2026-03-16 | 编辑资料页分享名片:Canvas 封面、标题「昵称+为您分享名片」 | 已完成 | profile-edit.js | +| 2026-03-16 | 链接人与事列表:table、planId/apiKey 列、删除 Dialog | 已完成 | ContentPage.tsx | +| 2026-03-16 | 存客宝创建计划参数:planType=1、sceneId=9、status=1 | 已完成 | db_person.go | +| 2026-03-16 | @mention 存储格式:span 必须含 data-label | 已完成 | ParseAutoLinkContent | +| 2026-03-17 | 代付统一到代付页 | 已完成 | read.js onLoad | +| 2026-03-18 | 代付流程:阅读页弹窗选择名额→支付→分享;好友自动领取 | 已完成 | read 页、singlePage 引导 | +| 2026-03-18 | 代付退款后禁用:status=refunded | 已完成 | gift_pay_requests | +| 2026-03-20 | 提现审批逻辑修复:批准时校验「累计-已提现>=待审核」 | 已完成 | doApproveWithdrawal | +| 2026-03-20 | 我的页「我的收益」取 availableEarnings | 已完成 | my.wxml pendingEarnings | +| 2026-03-20 | 推广设置:提现手续费、自动提现开关 | 已完成 | ReferralSettingsPage | +| 2026-03-20 | 提现审核列表:自动审批开关、备注列 | 已完成 | DistributionPage | +| 2026-03-20 | 提现失败记录:fail_reason/error_message 落库 | 已完成 | admin_withdrawals | + +--- + +## 三端需求速查 + +| 端 | 主需求 | +|----|--------| +| 小程序 | 我的收益、推广中心、代付、阅读统计、VIP | +| 管理端 | 推广设置、提现审核、VIP 设置、链接人与事 | +| 后端 | 提现审批、referral_config、代付、分润 | + +--- + +**最后更新**:2026-03-20 diff --git a/开发文档/1、需求/archive/README.md b/开发文档/1、需求/archive/README.md new file mode 100644 index 00000000..dc2ae4ab --- /dev/null +++ b/开发文档/1、需求/archive/README.md @@ -0,0 +1,11 @@ +# 1、需求 - 归档 + +专项需求、技术分析、已合并或过时文档,保留供追溯。 + +| 文件 | 说明 | +|------|------| +| 链接人与事-实现方案.md | 实现方案 | +| 链接人与事-存客宝同步-需求规划.md | 存客宝同步需求规划 | +| 链接人与事-所有同步需求.md | 链接人与事所有同步需求 | +| 链接人与事-置顶功能-技术分析.md | 置顶功能技术分析 | +| 文章详情-阅读页线框图.md | 阅读页线框图 | diff --git a/开发文档/1、需求/文章详情-阅读页线框图.md b/开发文档/1、需求/archive/文章详情-阅读页线框图.md similarity index 100% rename from 开发文档/1、需求/文章详情-阅读页线框图.md rename to 开发文档/1、需求/archive/文章详情-阅读页线框图.md diff --git a/开发文档/1、需求/链接人与事-存客宝同步-需求规划.md b/开发文档/1、需求/archive/链接人与事-存客宝同步-需求规划.md similarity index 100% rename from 开发文档/1、需求/链接人与事-存客宝同步-需求规划.md rename to 开发文档/1、需求/archive/链接人与事-存客宝同步-需求规划.md diff --git a/开发文档/1、需求/链接人与事-实现方案.md b/开发文档/1、需求/archive/链接人与事-实现方案.md similarity index 100% rename from 开发文档/1、需求/链接人与事-实现方案.md rename to 开发文档/1、需求/archive/链接人与事-实现方案.md diff --git a/开发文档/1、需求/链接人与事-所有同步需求.md b/开发文档/1、需求/archive/链接人与事-所有同步需求.md similarity index 100% rename from 开发文档/1、需求/链接人与事-所有同步需求.md rename to 开发文档/1、需求/archive/链接人与事-所有同步需求.md diff --git a/开发文档/1、需求/链接人与事-置顶功能-技术分析.md b/开发文档/1、需求/archive/链接人与事-置顶功能-技术分析.md similarity index 100% rename from 开发文档/1、需求/链接人与事-置顶功能-技术分析.md rename to 开发文档/1、需求/archive/链接人与事-置顶功能-技术分析.md diff --git a/开发文档/1、需求/以界面定需求.md b/开发文档/1、需求/以界面定需求.md index 77069cbd..b0718845 100644 --- a/开发文档/1、需求/以界面定需求.md +++ b/开发文档/1、需求/以界面定需求.md @@ -29,6 +29,7 @@ | **pages/my/my** | 我的:配置、阅读统计、待确认提现、收益、VIP 状态、提现入口 | `GET /api/miniprogram/config`、`GET /api/miniprogram/user/dashboard-stats`、`GET /api/miniprogram/withdraw/pending-confirm`、`GET /api/miniprogram/earnings`、`GET /api/miniprogram/vip/status`、`POST /api/miniprogram/user/update`、`POST /api/miniprogram/withdraw` | | **pages/referral/referral** | 推广中心:推广数据、海报与小程序码、复制文案、申请提现 | `GET /api/miniprogram/referral/data`、`POST /api/miniprogram/qrcode`、`POST /api/miniprogram/withdraw` | | **pages/settings/settings** | 设置:头像/昵称/手机/微信号、用户资料编辑、一键获取 | `GET /api/miniprogram/user/profile`、`POST /api/miniprogram/user/update`、`POST /api/miniprogram/phone` | +| **components/login-modal** | 公用登录弹窗:手机号一键登录、隐私协议、协议勾选;read/my/gift-pay 等页面引入 | 无独立接口,内部调 `app.loginWithPhone`、`app.login` | | **pages/vip/vip** | VIP:状态查询、开通支付 | `GET /api/miniprogram/vip/status`、`POST /api/miniprogram/pay`(productType=vip) | | **pages/purchases/purchases** | 购买记录 | `GET /api/miniprogram/orders` | | **pages/withdraw-records/withdraw-records** | 提现记录、确认收款 | `GET /api/miniprogram/withdraw/records`、`GET /api/miniprogram/withdraw/confirm-info` | @@ -115,7 +116,7 @@ | 文档 | 关系 | |------|------| | **本文档(以界面定需求)** | 界面级需求基准;新增/改版界面或业务规则时先更新本文档。 | -| **需求汇总.md** | 需求清单、历史与待办;需求描述与验收标准应与本文档界面及§四业务逻辑一致。 | +| **1、需求/索引.md** | 主需求 = 日期最新的需求文件(如 2026-03-20-需求.md);需求描述与验收标准应与本文档界面及§四业务逻辑一致。 | | **运营与变更.md** | 近期变更、讨论结论、技术决策;涉及界面或规则时同步引用本文档。 | --- @@ -126,3 +127,4 @@ |------|----------| | 2026-03-11 | 初版:小程序与管理端界面清单、业务逻辑对齐(VIP 资料以用户资料为准、三端路由、免费章与 VIP、分销提现);与需求汇总、README、运营与变更同步。 | | 2026-03-17 | 管理端清单补充:用户规则、用户余额、订单支付方式;详见《管理端迁移分析-基于小程序功能.md》。 | +| 2026-03-20 | 小程序:登录改为手机号一键登录;新增公用组件 login-modal(read/my/gift-pay 引入);getPhoneNumber 需耦合 agreePrivacyAuthorization。 | diff --git a/开发文档/1、需求/索引.md b/开发文档/1、需求/索引.md new file mode 100644 index 00000000..a85caff1 --- /dev/null +++ b/开发文档/1、需求/索引.md @@ -0,0 +1,25 @@ +# 1、需求 - 索引 + +## 命名规则 + +| 规则 | 说明 | +|------|------| +| **文件名** | `YYYY-MM-DD-需求.md` 或 `YYYY-MM-DD-简短描述.md` | +| **主需求文件** | **日期最新的**需求文件为主,作为当前需求基准 | +| **同步需求时** | 新建当日 `YYYY-MM-DD-需求.md` 或更新已有;更新本索引 | + +## 当前主需求文件 + +**2026-03-20-需求.md**(日期最新) + +## 基准文档(常驻) + +| 文件 | 说明 | +|------|------| +| [以界面定需求](以界面定需求.md) | 界面级需求基准:小程序/管理端界面清单、主要接口、业务逻辑对齐 | + +## 归档 + +| 目录 | 说明 | +|------|------| +| [archive/](archive/) | 专项需求、技术分析、已合并或过时文档 | diff --git a/开发文档/1、需求/需求汇总.md b/开发文档/1、需求/需求汇总.md deleted file mode 100644 index 601fa378..00000000 --- a/开发文档/1、需求/需求汇总.md +++ /dev/null @@ -1,60 +0,0 @@ -# 需求汇总(合并自 业务需求、技术需求、需求方案汇总、需求日志、卡若角色设定) - -## 需求基准(必读) - -**需求以《[以界面定需求](以界面定需求.md)》为准,以界面定需求。** -- 小程序、管理端各界面及主要接口见该文档第二、三节。 -- 业务逻辑对齐(用户/VIP 资料展示、三端 API 边界、免费章与 VIP、分销提现等)见该文档第四节。 -- 新增或变更功能时,先对齐界面与接口,再在本文档需求清单中补充或更新条目。 - ---- - -## 业务需求 - -项目目标、成本、技术要求(见原业务需求、技术需求)。 - -## 需求方案 - -Soul 创业派对整体定位、闭环、用户画像;小程序改造与迭代、已修复问题、已完成功能、配置与上线检查。详见原需求方案汇总。 - -## 需求日志 - -日常需求变更记录(见原需求日志)。 - -## 卡若角色设定 - -IP 设定、风格、输出规范(见原卡若角色设定)。 - ---- - -## 需求清单(来自 cursor_1_14 与永平落地) - -| 日期 | 描述 | 状态 | 备注 | -|------|------|------|------| -| 2026-02 | 内容管理页仅保留「API 接口」按钮 | 已完成 | soul-admin ContentPage 源码改造 | -| 2026-02 | 侧栏与分销页「交易中心」→「推广中心」 | 已完成 | AdminLayout、DistributionPage | -| 2026-02 | 推广中心/我的收益:绑定中、已付款、已过期清晰展示 | 已有 | referral 页数据结构支持 | -| 2026-02 | 海报小程序码带用户 ID(scene ref=userId) | 已完成 | referral.js generatePoster | -| 2026-02 | 复制朋友圈文案去掉「专属邀请码」展示 | 已完成 | 海报上去掉邀请码文案 | -| 2026-02 | 我的页:待领收益→我的收益、头像/昵称/ID 一键获取 | 已有/已完成 | my.wxml 文案统一 | -| 2026-02 | 设置页:手机/微信号一键获取、自动提现默认开启 | 已有 | settings.js | -| 2026-02 | 后台与前台参数一致(绑定有效期、自动提现、免费章节等) | 已检查 | 推广设置、系统设置已对齐 | -| 2026-02 | 找伙伴匹配后台用户库、资源对接两步(能帮什么/需要什么) | 已有 | match 页与后端 /api/match | -| 2026-02 | VIP 手动设置 + 支付设置 + 日志(区分来源、订单号) | 已完成 | 用户详情弹窗、支付回调、db/miniprogram handler | -| 2026-02 | 管理端设置 VIP 必填到期日 | 已完成 | 前后端校验 | -| 2026-02 | 会员订单分润差异化(会员 20% / 非会员 10%) | 已完成 | 技术分析见 临时需求池/分润需求-技术分析.md;computeOrderCommission;推广设置页增加会员分润配置 | -| 2026-02 | VIP 设置入口拆分:用户列表「设置 VIP」按钮 + 独立弹窗 | 已完成 | UserDetailModal 移除 VIP 区块;SetVipModal 独立 | -| 2026-02 | VIP 排序:后付款/后设置在前;支持手动排序 | 已完成 | vip_activated_at、vip_sort;VipMembers 排序逻辑 | -| 2026-02 | VIP 角色:可选择 + 可手动填写 | 已完成 | vip_roles 表;VIP 角色管理页;SetVipModal 角色下拉 | -| 2026-03-08 | 文章阅读付费规则:免费章节以 free_chapters 为准;VIP 全章免费 | 已完成 | soul-api book.go 合并 free_chapters;check-purchased 已支持 VIP | -| 2026-03-10 | 小程序「我的」页阅读统计改为后端接口(真实数据) | 已完成 | my.js loadDashboardStats;soul-api GET /api/miniprogram/user/dashboard-stats | -| 2026-03-10 | 富文本渲染升级(TipTap HTML → rich-text 组件,保留 @mention 交互) | 待实施 | 确认 DB 内容格式后实施;当前 contentParser.js 为纯文本剥除 | -| 2026-03-16 | 文章编辑时 @某人/#标签 自动创建:不存在则自动新增到链接人与事/链接标签并同步存客宝 | 已完成 | 临时需求池/2026-03-16-文章编辑自动创建@和#.md | -| 2026-03-16 | 编辑资料页分享名片:转发/朋友圈特殊处理,Canvas 封面(头像+昵称+四栏信息),标题「昵称+为您分享名片」 | 已完成 | profile-edit.js generateShareCard | -| 2026-03-16 | 链接人与事列表:table 布局、planId/apiKey 列、apiKey 复制图标、删除 Dialog 二次确认 | 已完成 | ContentPage.tsx | -| 2026-03-16 | 存客宝创建计划参数:planType=1、sceneId=9、status=1 | 已完成 | db_person.go | -| 2026-03-16 | @mention 存储格式:span 必须含 data-label,否则 TipTap 显示 token | 已完成 | ParseAutoLinkContent、autolink.go | -| 2026-03-17 | 代付统一到代付页:gift=1&ref 打开 read 页时 redirectTo 代付页,禁止在阅读页代付;代付页显示部分文章信息 | 已完成 | read.js onLoad;代付页已有 description | -| 2026-03-18 | 代付流程调整:阅读页内居中弹窗选择名额→支付成功直接分享;好友打开阅读页自动领取并解锁(含朋友圈 singlePage 降级引导) | 已完成 | read 页代付弹窗+自动领取;singlePage 引导规则入库 | -| 2026-03-18 | 代付退款后禁用:订单退款后代付请求标记 refunded,小程序/管理端均展示“已退款”,不可再分享/领取 | 已完成 | 后端退款同步 gift_pay_requests.status=refunded | -| - | 链接人与事所有同步需求汇总 | - | 链接人与事-所有同步需求.md | diff --git a/开发文档/6、后端/README.md b/开发文档/6、后端/README.md new file mode 100644 index 00000000..62484371 --- /dev/null +++ b/开发文档/6、后端/README.md @@ -0,0 +1,9 @@ +# 6、后端 + +> soul-api 相关技术文档 + +| 文件 | 用途 | +|------|------| +| [管理端鉴权设计](管理端鉴权设计.md) | JWT 鉴权、路由分层、AdminAuth 中间件 | +| [miniprogram接口补全说明](miniprogram接口补全说明.md) | VIP/users 接口迁移至 /api/miniprogram/* | +| [soul-admin与Mycontent-temp内容页对比](soul-admin与Mycontent-temp内容页对比.md) | 内容管理页功能对比,soul-admin 为基准 | diff --git a/开发文档/8、部署/DOCKER部署说明.md b/开发文档/8、部署/DOCKER部署说明.md index 248b0daa..941c4a65 100644 --- a/开发文档/8、部署/DOCKER部署说明.md +++ b/开发文档/8、部署/DOCKER部署说明.md @@ -1,285 +1,84 @@ # soul-api Docker 部署说明 -## 一、前置要求 - -- 服务器已安装 **Docker** 和 **Docker Compose** -- 已有 **MySQL** 数据库(如腾讯云 CDB) -- 准备 **微信支付证书**:`apiclient_cert.pem`、`apiclient_key.pem`(放在 `certs/` 目录) +> 当前实际部署以 **master.py(正式)** 和 **devloy.py(测试)** 为主。Docker 用于测试环境的 Runner 模式。详见 [部署总览](部署总览.md)。 --- -## 二、部署步骤 +## 一、测试环境 Runner 模式(推荐) -### 1. 准备配置 +容器内红蓝切换,宝塔 Nginx 固定 `proxy_pass http://127.0.0.1:9001`,无需改配置。 + +### 1. 首次准备(服务器) ```bash cd soul-api - -# 复制生产配置为 .env(不要直接修改 .env.production,避免敏感信息进 git) -cp .env.production .env - -# 编辑 .env,重点确认: -# - DB_DSN:MySQL 连接串(腾讯云 CDB 等) -# - API_BASE_URL:你的 API 域名 -# - 其他微信、存客宝等配置 -# -# REDIS_URL 由 docker-compose 自动注入,无需在 .env 中配置。 -# Docker 自建 Redis,与宝塔已有 Redis 完全隔离,互不影响。 +bash deploy/runner-init.sh ``` -### 2. 准备证书 +会构建 `soul-api-runner:latest` 并启动容器,使用 `network_mode: host`,容器内监听 9001。 -确保 `certs/` 目录下有: +### 2. 部署新版本(本地) -- `apiclient_cert.pem` -- `apiclient_key.pem` - -Docker 启动时会挂载 `./certs` 到容器内的 `/app/certs`。 - -### 3. 构建并启动 - -```bash -# 构建镜像并启动 -docker compose -f docker-compose.production.yml up -d --build - -# 查看日志 -docker compose -f docker-compose.production.yml logs -f soul-api -``` - -### 4. 验证 - -```bash -# 健康检查 -curl http://localhost:8080/health - -# 应返回类似:{"success":true,"version":"0.0.0",...} -``` - ---- - -## 三、常用命令 - -| 操作 | 命令 | -|------------|------------------------------------------------------------| -| 启动 | `docker compose -f docker-compose.production.yml up -d` | -| 停止 | `docker compose -f docker-compose.production.yml down` | -| 查看日志 | `docker compose -f docker-compose.production.yml logs -f` | -| 重启 API | `docker compose -f docker-compose.production.yml restart soul-api` | -| 仅重新构建 | `docker compose -f docker-compose.production.yml build --no-cache` | - ---- - -## 四、端口与数据 - -| 服务 | 端口映射 | 说明 | -|-----------|-------------|--------------------------| -| soul-api | 8080:8080 | API 服务 | -| redis | 6379:6379 | 可按需不暴露到公网 | - -**持久化卷**: - -- `soul_uploads`:上传文件(头像、书籍封面等) -- `redis_data`:Redis 数据 - ---- - -## 五、Nginx 反向代理示例 - -```nginx -server { - listen 443 ssl; - server_name soulapi.quwanzhi.com; - - ssl_certificate /path/to/fullchain.pem; - ssl_certificate_key /path/to/privkey.pem; - - location / { - proxy_pass http://127.0.0.1:8080; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} -``` - ---- - -## 六、从宝塔部署迁移到 Docker - -原先通过 `master.py` 部署到宝塔的流程,可改为: - -1. 在服务器创建目录,如 `/opt/soul-api` -2. 上传项目代码(或 git clone) -3. 按上述步骤配置 `.env`、`certs/` -4. 执行 `docker compose -f docker-compose.production.yml up -d --build` -5. 在 Nginx/宝塔中配置反向代理到 `127.0.0.1:8080` - -数据库、Redis 可继续使用原有实例,只需在 `.env` 中正确配置连接串即可。 - ---- - -## 七、蓝绿无缝部署(deploy.py --mode docker) - -运行 `deploy.py --mode docker` 后,可**本地构建镜像 → 上传宝塔 → 自动蓝绿切换、零停机**。 - -### 原理 - -- **blue** 实例:端口 8081 -- **green** 实例:端口 8082 -- 部署时:先启动新实例 → 健康检查通过 → 切换 Nginx 到新端口 → 停止旧实例 - -### 首次服务器准备 - -1. 创建目录:`mkdir -p /www/wwwroot/self/soul-dev` -2. 放入 `.env`、`certs/`(与普通 Docker 部署相同) -3. 配置环境变量(本地执行 deploy.py 前): - -```bash -export DEPLOY_DOCKER_PATH=/www/wwwroot/self/soul-dev -export DEPLOY_NGINX_CONF=/www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf -``` - -### 使用方式 - -```bash +```powershell cd soul-api -python deploy.py --mode docker +python devloy.py --mode runner ``` -脚本会:构建镜像 → 导出 tar.gz → 上传 → 服务器执行蓝绿切换。Nginx 由脚本自动修改 `proxy_pass` 端口并重载。 +流程:本地 go build → 打包二进制 + .env.development + certs → 上传 → 容器内红蓝切换。 + +### 3. 前置要求 + +- 服务器已安装 Docker、Docker Compose +- soul-api 目录有 `.env.development`、`certs/`(apiclient_cert.pem、apiclient_key.pem) +- 宝塔站点 souldev.quwanzhi.com 的 `location /` 已配置 `proxy_pass http://127.0.0.1:9001` --- -## 七、蓝绿无缝部署(deploy.py --mode docker) +## 二、测试环境 Docker 蓝绿模式(宿主机) -本地运行 `python deploy.py --mode docker` 可一键打包镜像、上传到宝塔、自动蓝绿切换,**零停机**。 +宿主机双实例 8081/8082 轮流对外,需脚本自动修改 Nginx `proxy_pass` 端口。 -### 原理 +### 1. 环境变量 -- **双实例**:blue(8081)、green(8082)轮流对外服务 -- **部署流程**:先启动新实例 → 健康检查通过 → Nginx 切到新端口 → 停止旧实例 -- **无缝切换**:切换过程中始终有实例在服务,用户无感知 - -### 首次部署准备(服务器) - -```bash -# 1. 创建目录 -mkdir -p /www/wwwroot/self/soul-dev -cd /www/wwwroot/self/soul-dev - -# 2. 准备 .env、certs/ -cp soul-api/.env.production .env -# 将微信证书放到 certs/ - -# 3. 设置 Nginx 配置路径(宝塔常用路径) -export DEPLOY_NGINX_CONF=/www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf +```powershell +$env:DEPLOY_DOCKER_PATH="/www/wwwroot/self/soul-dev" +$env:DEPLOY_NGINX_CONF="/www/server/panel/vhost/nginx/souldev.quwanzhi.com.conf" ``` -### 本地执行 +### 2. 执行 -```bash +```powershell cd soul-api - -# 环境变量(或写入 .env) -export DEPLOY_HOST=43.139.27.93 -export DEPLOY_USER=root -export DEPLOY_PASSWORD=你的密码 -export DEPLOY_DOCKER_PATH=/www/wwwroot/self/soul-dev -export DEPLOY_NGINX_CONF=/www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf - -# 执行(需本地安装 Docker) -python deploy.py --mode docker +python devloy.py --mode docker ``` -### 参数说明 +流程:本地 go build → Dockerfile.local 打镜像 → 导出 tar.gz → 上传 → 服务器加载 → 蓝绿切换 → 修改 Nginx 并重载。 -| 参数 | 说明 | +--- + +## 三、Docker 相关文件 + +| 文件 | 用途 | |------|------| -| `--mode docker` | 使用 Docker 蓝绿部署(默认 binary) | -| `--no-build` | 跳过镜像构建(使用已有 soul-api:latest) | -| `--no-env` | 不上传 .env(保留服务器现有配置) | +| deploy/Dockerfile.runner | Runner 容器镜像(Alpine + nginx + redis) | +| deploy/docker-compose.runner.yml | Runner 容器编排 | +| deploy/runner-init.sh | 首次构建并启动 Runner 容器 | +| deploy/runner/entrypoint.sh | 容器入口,启动 nginx + 红蓝切换逻辑 | +| deploy/runner/deploy.sh | 容器内部署脚本 | --- -## 七、蓝绿部署(无缝切换,deploy.py --mode docker) +## 四、正式环境(非 Docker) -通过 `deploy.py` 一键打包镜像、上传并自动蓝绿切换,实现 **零停机部署**。 - -### 原理 - -- 双实例:blue(8081)、green(8082)交替使用 -- 部署时:启动新实例 → 健康检查通过 → 切换 Nginx → 停旧实例 -- 请求始终有实例在服务,实现无缝切换 - -### 首次准备(服务器端) - -```bash -# 在服务器创建目录 -mkdir -p /www/wwwroot/self/soul-dev -cd /www/wwwroot/self/soul-dev - -# 从本地上传或创建 .env、certs/ -# .env 同第二节 -# certs/ 下放 apiclient_cert.pem、apiclient_key.pem -``` - -### 配置环境变量(本地) - -```bash -# .env 或 系统环境变量 -DEPLOY_HOST=43.139.27.93 -DEPLOY_USER=root -DEPLOY_PASSWORD=你的密码 -DEPLOY_SSH_PORT=22022 -DEPLOY_DOCKER_PATH=/www/wwwroot/self/soul-dev -# 宝塔 Nginx 配置路径(必填,用于自动切换端口) -DEPLOY_NGINX_CONF=/www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf -``` - -### 一键部署 - -```bash -cd soul-api -python deploy.py --mode docker -``` - -流程:本地 `docker build` → 导出 tar.gz → 上传 → 服务器 `docker load` → 蓝绿切换 → 完成。 - -### 首次部署 - -若 Nginx 当前指向 8080(原二进制),首次执行后会自动改为 8081 或 8082。请先停用宝塔里的 soulApi Go 项目,避免端口冲突。 +正式环境使用 **master.py** 部署 Go 二进制到宝塔,不走 Docker。详见 [部署总览](部署总览.md) 第三节。 --- -## 七、deploy.py 蓝绿无缝部署(零停机) - -本地运行 `deploy.py --mode docker` 可一键完成:构建镜像 → 上传服务器 → 蓝绿切换。 - -### 7.1 流程说明 - -| 步骤 | 操作 | -|------|------| -| 1 | 本地 `docker build` 构建 soul-api:latest | -| 2 | `docker save` 导出为 tar.gz | -| 3 | SFTP 上传镜像、docker-compose.bluegreen.yml、deploy 脚本 | -| 4 | 服务器加载镜像,启动**未活跃**实例(blue 或 green) | -| 5 | 等待健康检查通过 | -| 6 | Nginx `proxy_pass` 切换到新实例端口 | -| 7 | 停止旧实例 | - -### 7.2 使用前准备 - -1. **服务器**创建目录 `/www/wwwroot/self/soul-dev`,放入 `.env`、`certs/` -2. **环境变量**(或 `.env`): - - `DEPLOY_HOST` / `DEPLOY_USER` / `DEPLOY_PASSWORD`:SSH - - `DEPLOY_DOCKER_PATH=/www/wwwroot/self/soul-dev` - - `DEPLOY_NGINX_CONF=/www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf` - -### 7.3 执行 +## 五、健康检查 ```bash -cd soul-api -python deploy.py --mode docker -# 或跳过构建(使用已有镜像):python deploy.py --mode docker --no-build +curl -s http://127.0.0.1:9001/health # Runner 模式 +curl -s http://127.0.0.1:8080/health # 正式环境 ``` + +应返回 `{"status":"ok"}` 或 `{"success":true,...}`。 diff --git a/开发文档/8、部署/README.md b/开发文档/8、部署/README.md new file mode 100644 index 00000000..085c9b94 --- /dev/null +++ b/开发文档/8、部署/README.md @@ -0,0 +1,13 @@ +# 8、部署 + +> soul-api 部署、提现、订阅消息相关 + +| 文件 | 用途 | +|------|------| +| [部署总览](部署总览.md) | **入口**:正式/测试/管理端部署脚本、环境、命令 | +| [DOCKER部署说明](DOCKER部署说明.md) | 测试环境 Runner/Docker 模式、Docker 相关文件 | +| [宝塔-Docker首次配置指南](宝塔-Docker首次配置指南.md) | 测试环境 Runner 首次配置 | +| [宝塔反向代理说明](宝塔反向代理说明.md) | 域名 404 排查、Nginx 反向代理 | +| [提现功能完整技术文档](提现功能完整技术文档.md) | 微信支付商家转账到零钱 API 集成 | +| [订阅消息](订阅消息.md) | 提现成功订阅消息(PowerWeChat) | +| [商家转账](商家转账.md) | PowerWeChat 商家转账示例 | diff --git a/开发文档/8、部署/宝塔-Docker首次配置指南.md b/开发文档/8、部署/宝塔-Docker首次配置指南.md index 8193d37b..1b1b4374 100644 --- a/开发文档/8、部署/宝塔-Docker首次配置指南.md +++ b/开发文档/8、部署/宝塔-Docker首次配置指南.md @@ -1,24 +1,24 @@ # soul-api 测试环境 - 宝塔 Docker 首次配置指南 -> deploy.py 部署的是**测试环境**。运行 `python deploy.py` 前,在宝塔服务器上完成本指南的一次性配置。 +> 运行 `python devloy.py --mode runner` 前,在宝塔服务器上完成本指南的一次性配置。 --- -## 一、运行 deploy.py 会做什么(测试环境) +## 一、devloy.py 会做什么(Runner 模式) 在 soul-api 目录执行: -```bash -python deploy.py +```powershell +python devloy.py --mode runner ``` 会自动完成: -1. 本地构建 Docker 镜像(含 certs、.env.development) -2. 导出为 tar.gz -3. 通过 SSH 上传到宝塔测试环境服务器 -4. 服务器加载镜像并执行蓝绿部署 -5. 自动切换 Nginx 到新实例 +1. 本地 go build 交叉编译 Linux 二进制 +2. 打包二进制 + .env.development + certs 为 tar.gz +3. 通过 SSH 上传到服务器 +4. 上传到 Runner 容器内,执行红蓝切换 +5. 宝塔 Nginx 固定 `proxy_pass http://127.0.0.1:9001`,无需改配置 --- @@ -29,34 +29,35 @@ python deploy.py 在宝塔终端或 SSH 执行: ```bash -# 安装 Docker(若未安装) curl -fsSL https://get.docker.com | sh systemctl enable docker systemctl start docker -# 安装 Docker Compose +# Docker Compose curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose ``` -### 2. 创建部署目录 +### 2. 首次启动 Runner 容器 + +在服务器上(或通过 SSH 上传 soul-api 后): ```bash -mkdir -p /www/wwwroot/self/soul-dev -cd /www/wwwroot/self/soul-dev +cd /path/to/soul-api +bash deploy/runner-init.sh ``` -本目录用于存放 `docker-compose.bluegreen.yml` 和 `docker-deploy-remote.sh`(deploy.py 每次部署会覆盖),以及持久化数据卷。 +会构建 `soul-api-runner:latest` 并启动容器,监听 9001。 ### 3. 配置 Nginx 站点 -在宝塔:**网站** → 找到 `soulapi.quwanzhi.com`(若没有则新建站点) +在宝塔:**网站** → 找到 `souldev.quwanzhi.com`(若没有则新建站点) **设置** → **配置文件**,确保 `location /` 为反向代理: ```nginx location / { - proxy_pass http://127.0.0.1:8081; + proxy_pass http://127.0.0.1:9001; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -65,35 +66,22 @@ location / { } ``` -- 首次可用 `8081` 或 `8082`,deploy.py 部署时会自动切换 +- Runner 模式固定 9001,无需 8081/8082 - 删除或注释掉原来的 `root`、`index` 等静态配置,否则会 404 保存后点击 **重载配置**。 -### 4. 确认 Nginx 配置文件路径 - -宝塔 Nginx 配置通常在: - -``` -/www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf -``` - -若域名不同,请在宝塔 **网站** → 该站点 → **设置** → **配置文件** 查看实际路径。 - --- -## 三、本地环境变量(执行 deploy.py 前) - -在本地设置以下环境变量(或写入 soul-api 同级的 `.env`): +## 三、本地环境变量(执行 devloy.py 前) | 变量 | 示例 | 说明 | |------|------|------| | DEPLOY_HOST | 43.139.27.93 | 宝塔服务器 IP | | DEPLOY_USER | root | SSH 用户名 | | DEPLOY_PASSWORD | xxx | SSH 密码 | -| DEPLOY_SSH_PORT | 22022 | SSH 端口(默认 22022) | -| DEPLOY_DOCKER_PATH | /www/wwwroot/self/soul-dev | 测试环境部署目录 | -| DEPLOY_NGINX_CONF | /www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf | Nginx 配置路径 | +| DEPLOY_SSH_PORT | 22022 | SSH 端口 | +| DEPLOY_DOCKER_PATH | /www/wwwroot/self/soul-dev | 测试环境部署目录(Runner 模式也会用到) | PowerShell 示例: @@ -102,41 +90,47 @@ $env:DEPLOY_HOST="43.139.27.93" $env:DEPLOY_USER="root" $env:DEPLOY_PASSWORD="你的密码" $env:DEPLOY_DOCKER_PATH="/www/wwwroot/self/soul-dev" -$env:DEPLOY_NGINX_CONF="/www/server/panel/vhost/nginx/soulapi.quwanzhi.com.conf" ``` +**注意**:Runner 模式不需要 `DEPLOY_NGINX_CONF`(Nginx 固定 9001)。若用 `--mode docker` 蓝绿模式才需要。 + --- ## 四、首次部署前检查 -1. **soul-api 目录**:已有 `.env.development`(deploy.py 固定用测试环境配置) +1. **soul-api 目录**:已有 `.env.development`(devloy 固定用测试环境配置) 2. **certs/**:包含 `apiclient_cert.pem`、`apiclient_key.pem` -3. **本地 Docker**:已安装并运行 -4. **宝塔 Go 项目**:若之前用 soulApi 二进制,建议先在宝塔里**停止** soulApi,避免 8080 冲突(Docker 用 8081/8082) +3. **服务器**:已执行 `deploy/runner-init.sh`,Runner 容器在跑 +4. **宝塔**:souldev.quwanzhi.com 的 Nginx 已配置 `proxy_pass http://127.0.0.1:9001` --- ## 五、执行部署 -```bash +```powershell cd soul-api -python deploy.py +python devloy.py --mode runner ``` -首次会构建镜像并上传,之后每次有代码变更再执行即可,会自动蓝绿切换、零停机。 +首次会构建并上传,之后每次有代码变更再执行即可,容器内红蓝切换、零停机。 --- ## 六、常见问题 -### Nginx 配置路径不对 +### Nginx 404 -若 `DEPLOY_NGINX_CONF` 填错,部署脚本会提示「未配置 DEPLOY_NGINX_CONF」。请在宝塔中确认实际配置文件路径并修正环境变量。 - -### 原 soulApi 还在跑导致冲突 - -Docker 使用 8081、8082,与宝塔 Go 项目的 8080 不冲突。若 Nginx 仍指向 8080,请改为指向 8081 或 8082,或先停止宝塔里的 soulApi。 +确认 `location /` 已改为 `proxy_pass http://127.0.0.1:9001`,且删除了 `root`、`index` 等静态配置。详见 [宝塔反向代理说明](宝塔反向代理说明.md)。 ### 健康检查超时 -检查服务器防火墙、MySQL/Redis 等是否可访问,以及 `.env` 中 DB_DSN、REDIS 等配置是否正确。 +```bash +curl -s http://127.0.0.1:9001/health +``` + +若失败,检查 Runner 容器是否在跑:`docker ps | grep soul-api-runner`,以及 `.env` 中 DB_DSN、REDIS 等配置。 + +### 正式与测试域名区分 + +- **正式**:soulapi.quwanzhi.com → master.py → 8080 +- **测试**:souldev.quwanzhi.com → devloy.py --mode runner → 9001 diff --git a/开发文档/8、部署/宝塔反向代理说明.md b/开发文档/8、部署/宝塔反向代理说明.md index a776fa15..c3ca1b85 100644 --- a/开发文档/8、部署/宝塔反向代理说明.md +++ b/开发文档/8、部署/宝塔反向代理说明.md @@ -1,18 +1,35 @@ # soul-api 域名 404 原因与解决 ## 原因 -域名请求先到 Nginx,若没有把请求转发到本机 8080 的 Go,或站点用了 root/静态目录,就会 404。 +域名请求先到 Nginx,若没有把请求转发到本机对应端口,或站点用了 root/静态目录,就会 404。 --- -## 一、先确认 Go 是否在跑(必做) +## 端口对照 + +| 环境 | 域名 | 端口 | 部署方式 | +|------|------|------|----------| +| 正式 | soulapi.quwanzhi.com | 8080 | master.py,宝塔 soulApi | +| 测试 | souldev.quwanzhi.com | 9001 | devloy.py --mode runner | + +--- + +## 一、先确认服务是否在跑(必做) 在宝塔终端或 SSH 里执行: - curl -s http://127.0.0.1:8080/health +```bash +# 正式环境 +curl -s http://127.0.0.1:8080/health -- 若返回 {"status":"ok"}:说明 Go 正常,问题在 Nginx,看下面第二步。 -- 若连接被拒绝或超时:说明 8080 没在监听。去 宝塔 → Go项目管理 → soulApi → 服务状态,看是否“运行中”;看“项目日志”是否有报错。 +# 测试环境(Runner 模式) +curl -s http://127.0.0.1:9001/health +``` + +- 若返回 `{"status":"ok"}` 或 `{"success":true,...}`:说明服务正常,问题在 Nginx,看下面第二步。 +- 若连接被拒绝或超时: + - **正式**:宝塔 → Go项目管理 → soulApi → 服务状态,看是否“运行中” + - **测试**:`docker ps | grep soul-api-runner` 看容器是否在跑 --- @@ -23,16 +40,16 @@ - 站点默认有 location / { root ...; index ...; },请求被当成静态文件处理,/health 找不到就 404; - 或反向代理只绑在了子路径(如 /api),/ 和 /health 没被代理。 -做法:让 soulapi.quwanzhi.com 的**所有路径**都走 8080,不要用 root。 +做法:让站点的**所有路径**都走对应端口,不要用 root。端口:正式 8080,测试 9001。 -在宝塔:网站 → soulapi.quwanzhi.com → 设置 → 配置文件,找到该站点的 server { ... },按下面两种方式之一改。 +在宝塔:网站 → 对应站点 → 设置 → 配置文件,找到该站点的 server { ... },按下面两种方式之一改。 ### 方式 A:只保留一个 location /(推荐) -把 server 里**原来的** location / { ... }(含 root、index 的那段)**删掉或注释掉**,只保留下面这一段: +把 server 里**原来的** location / { ... }(含 root、index 的那段)**删掉或注释掉**,只保留下面这一段(端口按环境改): location / { - proxy_pass http://127.0.0.1:8080; + proxy_pass http://127.0.0.1:8080; # 正式用 8080,测试用 9001 proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/开发文档/8、部署/部署总览.md b/开发文档/8、部署/部署总览.md new file mode 100644 index 00000000..4030d9a7 --- /dev/null +++ b/开发文档/8、部署/部署总览.md @@ -0,0 +1,144 @@ +# Soul 创业派对 - 部署总览 + +> 基于当前实际部署脚本整理。最后更新:2026-03-20 + +--- + +## 一、环境与域名 + +| 环境 | 域名 | 服务器 | 部署目录 | 说明 | +|------|------|--------|----------|------| +| **正式** | soulapi.quwanzhi.com | 43.139.27.93:22022 | /www/wwwroot/self/soul-api | Go 二进制 + 宝塔 soulApi | +| **测试** | souldev.quwanzhi.com | 43.139.27.93:22022 | /www/wwwroot/self/soul-dev | Runner/Docker/Binary 三选一 | +| **管理端** | (同服务器) | 43.139.27.93:22022 | /www/wwwroot/self/soul-admin-dev | 静态站点 dist/dist2 互换 | + +--- + +## 二、部署脚本索引 + +| 项目 | 脚本 | 用途 | 命令 | +|------|------|------|------| +| **soul-api 正式** | soul-api/master.py | 交叉编译 → 打包 .env.production → 上传 → 重启 | `cd soul-api && python master.py` | +| **soul-api 测试** | soul-api/devloy.py | 三种模式:runner / docker / binary | `cd soul-api && python devloy.py --mode runner` | +| **soul-admin** | soul-admin/deploy.py | pnpm build:dev → zip → dist/dist2 互换 | `cd soul-admin && python deploy.py` | + +--- + +## 三、soul-api 正式环境(master.py) + +### 流程 + +1. 本地交叉编译 Go 二进制(Linux amd64) +2. 打包 `.env.production` → `.env`,设置 `PORT=8080`、`WECHAT_MINI_PROGRAM_STATE=formal` +3. 上传 tar.gz 到 `/www/wwwroot/self/soul-api` +4. 解压、chmod +x,重启:优先宝塔 API,否则 SSH nohup + +### 命令 + +```powershell +cd soul-api +python master.py +``` + +### 参数 + +| 参数 | 说明 | +|------|------| +| --no-build | 跳过编译,使用已有 soul-api 二进制 | +| --no-env | 不打包 .env,保留服务器现有配置 | +| --no-restart | 上传后不重启 | +| --restart-method auto/btapi/ssh | 重启方式,默认 auto | + +### 环境变量 + +| 变量 | 默认 | 说明 | +|------|------|------| +| DEPLOY_HOST | 43.139.27.93 | SSH 主机 | +| DEPLOY_USER | root | SSH 用户 | +| DEPLOY_PASSWORD | (需设置) | SSH 密码 | +| DEPLOY_SSH_PORT | 22022 | SSH 端口 | +| BT_PANEL_URL | https://{host}:9988 | 宝塔面板 | +| BT_API_KEY | (脚本内默认) | 宝塔 API 密钥 | +| BT_GO_PROJECT_NAME | soulApi | 宝塔 Go 项目名 | + +### Nginx + +宝塔站点 soulapi.quwanzhi.com → `proxy_pass http://127.0.0.1:8080` + +--- + +## 四、soul-api 测试环境(devloy.py) + +### 三种模式 + +| 模式 | 说明 | Nginx | 推荐 | +|------|------|-------|------| +| **runner** | 容器内红蓝切换,固定 9001 | proxy_pass 127.0.0.1:9001 | ✅ | +| **docker** | 宿主机蓝绿 8081/8082 | 脚本自动切换 proxy_pass | 需改 Nginx | +| **binary** | Go 二进制 + 宝塔 soulDev | 8080 | 与正式类似 | + +### Runner 模式(推荐) + +**首次**(服务器执行): + +```bash +cd soul-api +bash deploy/runner-init.sh +``` + +**部署**(本地执行): + +```powershell +cd soul-api +python devloy.py --mode runner +``` + +- 打包:Go 二进制 + .env.development + certs,PORT=18081,REDIS 容器内 +- 上传到容器内 /app,红蓝目录切换,Nginx 固定 9001 + +### 环境变量(测试) + +| 变量 | 默认 | 说明 | +|------|------|------| +| DEPLOY_HOST | 43.139.27.93 | 同正式 | +| DEPLOY_DOCKER_PATH | /www/wwwroot/self/soul-dev | 测试部署目录 | +| DEPLOY_NGINX_CONF | (docker 模式必填) | 如 /www/server/panel/vhost/nginx/souldev.quwanzhi.com.conf | + +--- + +## 五、soul-admin 部署 + +### 流程 + +1. 本地 `pnpm run build:dev`(.env.development) +2. 打包 dist 为 zip +3. 上传到 /www/wwwroot/self/soul-admin-dev +4. 解压到 dist2,与 dist 互换,实现无缝切换 + +### 命令 + +```powershell +cd soul-admin +python deploy.py +``` + +### 环境变量 + +| 变量 | 默认 | 说明 | +|------|------|------| +| DEPLOY_HOST | 43.139.27.93 | 同 soul-api | +| DEPLOY_BASE_PATH | /www/wwwroot/self/soul-admin-dev | 站点根目录 | +| DEPLOY_WWW_USER | www:www | chown 属主 | + +--- + +## 六、相关文档 + +| 文档 | 用途 | +|------|------| +| [宝塔反向代理说明](宝塔反向代理说明.md) | 域名 404 排查、Nginx 配置 | +| [宝塔-Docker首次配置指南](宝塔-Docker首次配置指南.md) | 测试环境 Runner 首次配置 | +| [DOCKER部署说明](DOCKER部署说明.md) | Docker 构建、Runner 模式 | +| [提现功能完整技术文档](提现功能完整技术文档.md) | 微信支付商家转账 API | +| [订阅消息](订阅消息.md) | 提现成功订阅消息(PowerWeChat) | +| [商家转账](商家转账.md) | PowerWeChat 商家转账示例 | diff --git a/开发文档/README.md b/开发文档/README.md index 3c778d87..1fa76736 100644 --- a/开发文档/README.md +++ b/开发文档/README.md @@ -1,6 +1,8 @@ -# Soul 创业派对 - 开发文档索引 +# Soul 创业派对 - 开发文档 -> 小橙整理 · 2026-02-26 +> 入口索引:[**索引.md**](索引.md) — 按目录与文件标注用途,便于快速定位 + +--- ## 当前项目架构 @@ -13,83 +15,41 @@ --- -## 文档导航 +## 文档导航(按目录) -### 需求与项目管理 - -| 文档 | 说明 | +| 目录 | 说明 | |------|------| -| [1、需求/以界面定需求](1、需求/以界面定需求.md) | **界面级需求基准**:以界面定需求,小程序与管理端界面清单、主要接口、业务逻辑对齐(三端路由、VIP 资料以用户资料为准等) | -| [1、需求/需求汇总](1、需求/需求汇总.md) | 需求清单、业务需求 | -| [10、项目管理/项目落地推进表](10、项目管理/项目落地推进表.md) | 里程碑、永平落地 | -| [10、项目管理/运营与变更](10、项目管理/运营与变更.md) | 近期讨论、变更记录 | -| [迁移完成度与待办清单](迁移完成度与待办清单.md) | 迁移完成度、剩余待办、搁置项 | -| [代付-业务线框图](代付-业务线框图.md) | 代付主流程(发起人支付、好友领取) | -| [代付-简化流程设计](代付-简化流程设计.md) | 代付页面态与操作 | -| [代付-需求分析与待完善](代付-需求分析与待完善.md) | 已实现项与待确认 | -| [新版与稳定版-管理端功能样式差异分析](新版与稳定版-管理端功能样式差异分析.md) | 管理端两版功能/样式对比、文章内容弹窗差异 | -| [功能测试流程](../scripts/test/功能测试流程.md) | 功能测试流程、测试报告模板、自动化用例 | - -### 架构与规范 - -| 文档 | 说明 | -|------|------| -| [2、架构/系统与技术](2、架构/系统与技术.md) | 系统与技术栈 | -| [2、架构/soul-api技术栈](2、架构/soul-api技术栈.md) | soul-api Go 技术栈(Gin、GORM、PowerWeChat、JWT) | -| [2、架构/链路与变现](2、架构/链路与变现.md) | 业务链路 | -| [4、前端/前端开发规范](4、前端/前端开发规范.md) | 前端规范 | -| [6、后端/后端开发规范](6、后端/后端开发规范.md) | 后端规范 | - -### 接口与部署 - -| 文档 | 说明 | -|------|------| -| [5、接口/API接口完整文档](5、接口/API接口完整文档.md) | API 完整文档 | -| [Cunkebao接口文档](Cunkebao接口文档/README.md) | **存客宝(Cunkebao)** 前端项目接口清单、入参出参结构 | -| [6、后端/管理端鉴权设计](6、后端/管理端鉴权设计.md) | soul-api 管理端 JWT 鉴权、路由分层 | -| [8、部署/部署总览](8、部署/部署总览.md) | 部署入口、分销与流程 | -| [8、部署/宝塔反向代理说明](8、部署/宝塔反向代理说明.md) | soul-api 域名 404 排查、Nginx 反向代理配置 | -| [8、部署/DOCKER部署说明](8、部署/DOCKER部署说明.md) | soul-api Docker 构建与生产环境部署 | -| [8、部署/提现功能完整技术文档](8、部署/提现功能完整技术文档.md) | 微信支付商家转账到零钱 API 集成 | -| [8、部署/分销提现流程图](8、部署/分销提现流程图.md) | 提现业务流程图 | -| [8、部署/订阅消息](8、部署/订阅消息.md) | 提现成功订阅消息(PowerWeChat) | -| [8、部署/商家转账](8、部署/商家转账.md) | PowerWeChat 商家转账示例 | - -### 临时需求池 - -| 文档 | 说明 | -|------|------| -| 临时需求池/需求分析-产品经理视角 | 需求分析 | -| 临时需求池/分润需求-技术分析 | 会员分润差异化技术方案 | +| [1、需求/](1、需求/) | 需求基准、主需求文件(按日期命名)、归档 | +| [6、后端/](6、后端/) | 鉴权设计、接口补全、迁移对比 | +| [8、部署/](8、部署/) | Docker、宝塔、提现、订阅消息 | +| [10、项目管理/](10、项目管理/) | 里程碑、运营与变更 | +| [Cunkebao接口文档/](Cunkebao接口文档/) | 存客宝前端项目接口清单 | --- -## 已移除文档(2026-02-26) +## 常用文档 -- Prisma ORM 迁移相关(3 份)— 项目已迁至 Go/GORM -- Next.js 宝塔部署方案、Standalone 模式 — next-project 仅预览 -- 拆解计划 — 已完成,soul-admin 与 soul-api 已落地 -- 近3天更新文档(5 份)— 已合并至 运营与变更 第六部分 -- 8、部署 历史修复说明(约 35 份)— 一次性修复记录,已无参考价值 +| 文档 | 用途 | +|------|------| +| [1、需求/以界面定需求](1、需求/以界面定需求.md) | **界面级需求基准**:小程序/管理端界面清单、业务逻辑对齐 | +| [1、需求/索引](1、需求/索引.md) | 主需求 = 日期最新的需求文件 | +| [10、项目管理/项目落地推进表](10、项目管理/项目落地推进表.md) | 里程碑、永平落地 | +| [10、项目管理/运营与变更](10、项目管理/运营与变更.md) | 近期讨论、变更记录 | +| [8、部署/部署总览](8、部署/部署总览.md) | **部署入口**:正式/测试/管理端脚本与命令 | +| [8、部署/提现功能完整技术文档](8、部署/提现功能完整技术文档.md) | 微信支付商家转账 API 集成 | +| [6、后端/管理端鉴权设计](6、后端/管理端鉴权设计.md) | soul-api 管理端 JWT 鉴权 | +| [scripts/test/功能测试流程](../scripts/test/功能测试流程.md) | 功能测试流程、自动化用例 | -## 已移除文件(2026-02-27 橙子清理) +--- -- `.DS_Store`(4 处)— macOS 系统缓存 -- `1、需求/修改/1.doc` — 空文件 -- `SKILL.md`(根目录)— 技术栈已过期(写的是 Next.js),以 README 与 .cursor/skills 为准 -- `小程序管理/scripts/__pycache__/*.pyc` — Python 缓存 -- `小程序管理/scripts/reports/*.json`(4 份)— 脚本生成的一次性报告 +## 已移除/归档(历史记录) -## 已移除文件(2026-03-10 橙子清理) +
    +点击展开 -- `api_v1.md` — 存客宝对外获客 API 文档,项目已明确搁置对接,文档无继续维护价值 -- `小程序功能与管理端配置补齐分析.md` — 2026-02-25 一次性补齐分析,全部项目已标注 ✅ 已完成,分析目的达成 +- 2026-03-20:需求汇总、三端需求整理 → 合并至 2026-03-20-需求.md;链接人与事等 → archive/ +- 2026-03-17:代付逻辑旧文档 → 已合并至代付-业务线框图等 +- 2026-03-10:api_v1、小程序功能补齐分析 +- 2026-02-26:Prisma 迁移、Next 部署、拆解计划等 -## 已移除文件(2026-03-17 橙子清理) - -- `代付功能-美团式方案与场景清单.md` — 描述「好友代付」旧逻辑,已由「发起人支付、好友领取」替代 -- `找朋友代付-流程与配置.md` — 描述「好友帮他付款」旧流程,已过时 -- `代付逻辑-正确需求与改造方案.md` — 需求已落地,内容已合并至 代付-业务线框图、代付-简化流程设计 -- `代付逻辑-开发排期与任务清单.md` — 排期已执行完毕 -- `代付逻辑-开发任务指派.md` — 任务指派已执行完毕 -- `代付逻辑-设计评审与跑通验证.md` — 评审结论已落地 +
    diff --git a/开发文档/config接口优化分析.md b/开发文档/config接口优化分析.md deleted file mode 100644 index dddde132..00000000 --- a/开发文档/config接口优化分析.md +++ /dev/null @@ -1,163 +0,0 @@ -# Config 接口优化分析 - -## 一、现状 - -### 1.1 当前 config 接口 - -- **路径**:`GET /api/miniprogram/config` -- **Handler**:`GetPublicDBConfig`(soul-api/internal/handler/db.go) -- **缓存**:Redis 10min,配置变更时 `InvalidateConfig()` 失效 - -### 1.2 返回内容(buildMiniprogramConfig) - -| 字段 | 来源 | 小程序使用场景 | 使用频率 | -|-----|------|----------------|----------| -| **prices** | chapter_config | 阅读页解锁价格、chapterAccessManager | 中 | -| **features** | chapter_config + feature_config | 首页/目录/我的/TabBar:searchEnabled、matchEnabled、referralEnabled | 高 | -| **mpConfig** | mp_config | auditMode、appId、mchId、withdrawSubscribeTmplId、supportWechat | 高(auditMode)/ 低(支付) | -| **linkTags** | link_tags 表 | 阅读页 onLinkTagTap、contentParser | 低(仅阅读页) | -| **linkedMiniprograms** | system_config | 阅读页跳转关联小程序 | 低(仅阅读页) | -| **userDiscount** | referral_config | 阅读页优惠价展示 | 低 | -| **configs** | 原始配置 | 备用格式 | 低 | - -### 1.3 管理端与审核模式 - -- 管理端 SettingsPage 通过 `/api/admin/settings` 读写 `mp_config`,其中 `auditMode` 由管理端开关控制 -- 审核模式开启时:小程序隐藏支付、提现、VIP 等 UI -- 小程序从后台切回时需刷新 auditMode(onShow 节流 30s) - ---- - -## 二、优化目标 - -1. **审核模式独立**:管理端控制,需单独接口,不影响线上 config -2. **config 保留**:向后兼容,不破坏现有小程序 -3. **拆分按需加载**:提升首屏/预览速度,减少单次请求体积 -4. **废弃标记**:对后续计划废弃的接口在代码中标记 - ---- - -## 三、拆分方案 - -### 3.1 新增接口 - -| 接口 | 用途 | 返回内容 | 缓存 | 调用时机 | -|-----|------|----------|------|----------| -| **GET /api/miniprogram/config/audit-mode** | 审核模式(独立) | `{ auditMode: boolean }` | 1min(可更短) | onShow、阅读页 onLoad、支付前 | -| **GET /api/miniprogram/config/core** | 核心配置(精简) | prices、features、userDiscount | 10min | 首屏、Tab 切换、getConfig 主入口 | -| **GET /api/miniprogram/config/read-extras** | 阅读页扩展 | linkTags、linkedMiniprograms | 10min | 阅读页 onLoad 懒加载 | - -### 3.2 保留接口(加废弃标记) - -| 接口 | 标记 | 说明 | -|-----|------|------| -| **GET /api/miniprogram/config** | `@deprecated` | 保留至小程序全部迁移到 core + audit-mode + read-extras 后废弃 | - -### 3.3 数据流示意 - -``` -首屏 / Tab 切换 - → app.getConfig() 优先请求 /config/core(轻量) - → 并行或单独请求 /config/audit-mode(从后台切回时必拉) - -阅读页 onLoad - → 若已有 config 缓存,用 linkTags/linkedMiniprograms - → 若无,懒加载 /config/read-extras - -支付 / 提现前 - → 拉取 audit-mode 确认非审核态 - → mpConfig(appId、mchId 等)可从 core 或保留在 config 中,按需 -``` - ---- - -## 四、实施步骤建议 - -### 阶段一:新增接口(不破坏现有) - -1. **后端**:新增 `GetAuditMode`、`GetCoreConfig`、`GetReadExtras` 三个 handler -2. **缓存**:audit-mode 单独 key、短 TTL;core、read-extras 复用或新建 key -3. **管理端**:保存 mp_config 时,除 `InvalidateConfig()` 外,增加 `InvalidateAuditMode()`(若 audit-mode 单独缓存) - -### 阶段二:小程序迁移 - -1. **app.getConfig()**:改为请求 `/config/core`,内部合并 audit-mode(可并行请求) -2. **app.getAuditMode()**:新增,单独拉取 audit-mode,用于 onShow 刷新 -3. **阅读页**:优先用 `app.globalData.linkTagsConfig`,无则请求 `/config/read-extras` - -### 阶段三:废弃标记 - -1. **db.go**:`GetPublicDBConfig` 注释加 `@deprecated 计划迁移至 /config/core + /config/audit-mode + /config/read-extras` -2. **router.go**:`miniprogram.GET("/config", ...)` 上方加废弃说明 -3. **小程序**:保留对 `/config` 的兼容逻辑,逐步移除 - ---- - -## 五、接口详细设计 - -### 5.1 GET /api/miniprogram/config/audit-mode - -**响应**: -```json -{ "auditMode": false } -``` - -**缓存**:`soul:config:audit-mode`,TTL 60s(审核开关后需较快生效) - -**失效**:管理端保存 mp_config 时调用 `InvalidateAuditMode()` - -### 5.2 GET /api/miniprogram/config/core - -**响应**: -```json -{ - "success": true, - "prices": { "section": 1, "fullbook": 9.9 }, - "features": { "matchEnabled": true, "referralEnabled": true, "searchEnabled": true }, - "userDiscount": 5 -} -``` - -**缓存**:`soul:config:core`,TTL 10min,与现有 config 变更联动 - -### 5.3 GET /api/miniprogram/config/read-extras - -**响应**: -```json -{ - "linkTags": [...], - "linkedMiniprograms": [...] -} -``` - -**缓存**:`soul:config:read-extras`,TTL 10min,link_tags / linked_miniprograms 变更时失效 - ---- - -## 六、性能与兼容 - -| 指标 | 当前 config | 拆分后(首屏) | -|------|-------------|----------------| -| 首请求体量 | 全量(含 linkTags、linkedMiniprograms、configs) | core + audit-mode,体积约 1/3 | -| 阅读页 | 依赖全量 config | 无 linkTags 时再请求 read-extras | -| 审核模式刷新 | 拉全量 config | 仅拉 audit-mode | -| 兼容性 | - | 保留 /config,加 @deprecated | - ---- - -## 七、废弃标记清单(代码位置) - -| 文件 | 位置 | 状态 | -|------|------|------| -| soul-api/internal/handler/db.go | GetPublicDBConfig 函数注释 | ✅ 已加 Deprecated | -| soul-api/internal/router/router.go | miniprogram.GET("/config", ...) 上方 | ✅ 已加 Deprecated | -| miniprogram/app.js | getConfig 已迁移至 core+audit-mode | ✅ 已实现 | - ---- - -## 八、总结 - -- **审核模式**:独立接口 `/config/audit-mode`,管理端开关后快速生效,不依赖全量 config -- **config 保留**:继续可用,加废弃标记,便于后续统一下线 -- **拆分策略**:core(首屏必需)、audit-mode(独立)、read-extras(阅读页懒加载) -- **迁移节奏**:先上新接口,小程序逐步切到 core + audit-mode + read-extras,最后废弃 /config diff --git a/开发文档/代付-业务线框图.md b/开发文档/代付-业务线框图.md deleted file mode 100644 index f9a25c40..00000000 --- a/开发文档/代付-业务线框图.md +++ /dev/null @@ -1,296 +0,0 @@ -# 代付分享 - 业务线框图(ASCII) - -> 改造后:发起人支付,好友免费领取。更新日期:2026-03-17(橙子整理) - ---- - -## 〇、业务说明(与卡券系统类比) - -代付与**卡券系统**类似: - -| 环节 | 代付 | 卡券类比 | -|------|------|----------| -| 购买 | 用户输入数量,按文章单价计算总金额,发起微信支付 | 购买多张卡券 | -| 录入 | 支付成功后,在卡片系统录入代付记录 | 卡券入库 | -| 分享 | 用户分享链接给其他人 | 转赠/发放卡券 | -| 领取 | 他人进入页面后领取文章(当前:点击「领取并阅读」) | 核销/兑换卡券 | -| 权益 | 领取后相当于已购买该文章,可正常阅读 | 获得权益 | -| 分佣 | **领取不参与分佣**,发起人支付时已完成分销 | 分佣在购买端 | -| 记录 | **发起人可查看领取记录**:谁领取了、何时领取 | 核销记录 | - ---- - -## 一、主流程总览 - -``` -┌─────────────────────────────────────────────────────────────────────────────┐ -│ 发起人(购买者) │ -└─────────────────────────────────────────────────────────────────────────────┘ - - ┌──────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ - │ 阅读章节 │────>│ 点击代付分享 │────>│ 跳转detail │────>│ 输入份数 │ - └──────────┘ └──────────────┘ │ sectionId │ │ 去支付→create│ - └──────────────┘ └──────┬───────┘ - v - ┌──────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ - │ 分享链接 │<────│ 支付成功 │<────│ 微信支付 │<────│ initiator-pay│ - │ 给好友 │ └──────────────┘ └──────┬───────┘ └──────────────┘ - └────┬─────┘ │ - │ - │ - │ 分享 - v -┌─────────────────────────────────────────────────────────────────────────────┐ -│ 好友(领取者) │ -└─────────────────────────────────────────────────────────────────────────────┘ - - ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ - │ 收到分享链接 │────>│ 打开detail │────>│ 已登录? │ - └──────────────┘ └──────────────┘ └──────┬───────┘ - │ - ┌──────────────────────┼──────────────────────┐ - │ 否 │ 是 │ - v v │ - ┌──────────────┐ ┌──────────────┐ │ - │ 弹窗登录 │────────>│ 领取并阅读 │<──────────────┘ - └──────────────┘ └──────┬───────┘ - │ - v - ┌──────────────┐ ┌──────────────┐ - │ 调用redeem │────>│ 跳转read阅读 │ - └──────────────┘ └──────────────┘ -``` - ---- - -## 二、发起人流程(详细) - -``` -┌─ read 页 ─────────────────────────────────────────────────────────────────┐ -│ │ -│ 阅读章节 ──> 代付分享入口 ──> 直接跳转 gift-pay/detail?sectionId=xxx │ -│ │ -└────────────────────────────────────────┬───────────────────────────────────┘ - │ - v -┌─ API create ──────────────────────────────────────────────────────────────┐ -│ │ -│ 校验登录/章节 ──> amount=单价×quantity ──> 创建 gift_pay_request │ -│ │ │ -│ v │ -│ status=pending_pay ──> 返回 requestSn, path │ -│ │ -└────────────────────────────────────────┬───────────────────────────────────┘ - │ - v -┌─ gift-pay/detail 页 ──────────────────────────────────────────────────────┐ -│ │ -│ 创建态:输入份数 ──> 去支付 ──> create(quantity) ──> initiator-pay │ -│ │ │ -│ v │ -│ 微信支付 ──> 支付成功 ──> 显示「发送给好友」 │ -│ │ -│ 发起人视角:隐藏发起人信息卡片、安全徽章、右侧箭头 │ -│ 创建态提示:创建后无法退款 │ -│ │ -└────────────────────────────────────────────────────────────────────────────┘ -``` - ---- - -## 三、好友领取流程(详细) - -``` -┌─ 进入详情页 ───────────────────────────────────────────────────────────────┐ -│ │ -│ 打开链接/扫码 ──> GET /gift-pay/detail ──> isInitiator? │ -│ │ │ -│ ┌─────────────────────────┼─────────────────────────┐ │ -│ │ 是 │ 否 │ │ -│ v v │ │ -│ 发起人:显示支付/分享 好友:显示「领取并阅读」 │ -│ │ -└────────────────────────────────────────┬───────────────────────────────────┘ - │ - v -┌─ 领取流程 ─────────────────────────────────────────────────────────────────┐ -│ │ -│ 已登录? │ -│ │ │ -│ ├── 否 ──> 弹窗:微信/手机号登录 ──> 登录成功 ──┐ │ -│ │ │ │ -│ └── 是 ──────────────────────────────────────────┼──> 点击「领取并阅读」 │ -│ │ │ -│ v │ -│ POST /gift-pay/redeem -│ │ │ -│ v │ -│ 创建好友订单 │ -│ section+paid │ -│ │ │ -│ v │ -│ redeemed_count+1 │ -│ │ │ -│ v │ -│ 跳转 read 页 │ -│ │ -│ 单页模式 ──> 提示「前往小程序」 │ -│ │ -└────────────────────────────────────────────────────────────────────────────┘ -``` - ---- - -## 四、状态流转 - -``` - create 创建 - ┌─────────────> ┌──────────────┐ - │ │ pending_pay │ - │ │ 待发起人支付 │ - │ └──────┬───────┘ - │ │ - │ │ 发起人支付成功 - │ v - │ ┌──────────────┐ - │ │ paid │ - │ │ 已支付 │ - │ └──────┬───────┘ - │ │ - │ │ 好友领取完毕或过期 - │ v - │ ┌──────────────┐ - │ │ [结束] │ - │ └──────────────┘ - │ - │ 24h 过期 - │ - └──────────────> ┌──────────────┐ - │ expired │ - │ 已过期 │ - └──────┬───────┘ - │ - v - ┌──────────────┐ - │ [结束] │ - └──────────────┘ -``` - ---- - -## 五、接口调用时序 - -``` - 发起人 小程序 后端 微信支付 - │ │ │ │ - │ 1. 创建代付请求 - │ │ │ │ - │ 输入份数确认 │ │ │ - │────────────>│ │ │ - │ │ POST create │ │ - │ │────────────>│ │ - │ │ │ 创建gift_pay_request - │ │ │ │ - │ │ requestSn │ │ - │ │<────────────│ │ - │ 跳转detail │ │ │ - │<────────────│ │ │ - │ │ │ │ - │ 2. 发起人支付 - │ │ │ │ - │ 点击立即支付 │ │ │ - │────────────>│ │ │ - │ │ POST initiator-pay │ - │ │────────────>│ │ - │ │ │ 统一下单 │ - │ │ │────────────>│ - │ │ │ prepay_id │ - │ │ │<────────────│ - │ │ payParams │ │ - │ │<────────────│ │ - │ │ │ │ - │ │ wx.requestPayment │ - │ │─────────────────────────>│ - │ 支付成功 │<─────────────────────────│ - │<────────────│ │ │ - │ │ │ PayNotify │ - │ │ │<────────────│ - │ │ │ status=paid │ - │ │ │ │ - │ 3. 好友领取 - │ │ │ │ - │ 分享链接 │ │ │ - │────────────>│ │ │ - │ │ GET detail │ │ - │ │────────────>│ │ - │ │ action=redeem │ - │ │<────────────│ │ - │ │ │ │ - │ 点击领取 │ │ │ - │────────────>│ │ │ - │ │ POST redeem │ │ - │ │────────────>│ │ - │ │ │ 创建好友订单 │ - │ │ sectionId │ │ - │ │<────────────│ │ - │ 跳转read │ │ │ - │<────────────│ │ │ - │ │ │ │ -``` - ---- - -## 六、角色与页面映射 - -| 角色 | 入口 | 页面 | 主要操作 | -|------|------|------|----------| -| 发起人 | read 页「代付分享」 | gift-pay/detail | 创建态输入份数→去支付 → 分享态发送给好友 | -| 发起人 | 我的代付列表 | gift-pay/redemption-detail | 查看文章信息、领取人明细、剩余份数 | -| 好友 | 分享链接/扫码 | gift-pay/detail | 领取并阅读 | -| 好友(单页) | 朋友圈分享 | gift-pay/detail | 引导「前往小程序」 | - ---- - -## 七、关键业务规则 - -| 规则 | 说明 | -|------|------| -| 份数 | 前端不限制,发起支付时校验正整数;后端校验 ≥1 | -| 金额 | amount = 单价 × quantity,支持推荐人折扣 | -| 过期 | 24 小时未支付则 expired | -| 领取 | 好友需登录,每人限领 1 份 | -| 领取不分佣 | 分佣在发起人支付时完成,好友领取不触发分销 | -| 领取记录 | 发起人可查看该代付的领取人列表(my-requests 已返回 redeemList) | -| attach | 微信支付 attach 最大 128 字节,发起人付用 `{"ip":1}` | - ---- - -## 八、领取记录与列表(发起人视角) - -``` -┌─ 我发起的代付 ─────────────────────────────────────────────────────────────┐ -│ │ -│ 代付列表(gift-pay/list) │ -│ │ 待支付:仅显示「取消」;已支付:仅显示「分享」 │ -│ │ 取消后自动从列表移除;my-requests 不返回 status=cancelled 的项 │ -│ │ │ -│ v 点击卡片 │ -│ ┌─────────────────────────────────────────────────────────────────────┐ │ -│ │ 领取详情页(gift-pay/redemption-detail) │ │ -│ │ ├─ 文章信息:标题、内容预览、总份数、剩余份数 │ │ -│ │ ├─ 领取人明细:头像、昵称、领取时间 │ │ -│ │ └─ 操作:去阅读、去分享/去支付 │ │ -│ └─────────────────────────────────────────────────────────────────────┘ │ -│ │ -│ 数据来源:detail 接口返回 redeemList(含 avatar、nickname、redeemAt) │ -│ │ -└────────────────────────────────────────────────────────────────────────────┘ -``` - -## 九、UI 与体验规则 - -| 规则 | 说明 | -|------|------| -| 发起人视角 | 发起人信息卡片、安全徽章、右侧箭头在 detail 页不展示 | -| 创建态提示 | 创建后无法退款 | -| 分享带 ref | 分享 path 含 `&ref=发起人推荐码`,用于拉新 | diff --git a/开发文档/代付-简化流程设计.md b/开发文档/代付-简化流程设计.md deleted file mode 100644 index 554908ec..00000000 --- a/开发文档/代付-简化流程设计.md +++ /dev/null @@ -1,157 +0,0 @@ -# 代付分享 - 简化流程设计 - -> 目标:更简单、简洁、方便。领取时未登录先弹窗登录。更新日期:2026-03-17(橙子整理) - ---- - -## 一、简化后的主流程 - -``` -┌─────────────────────────────────────────────────────────────────────────────┐ -│ 发起人 │ -└─────────────────────────────────────────────────────────────────────────────┘ - - read 页「代付分享」 - │ - v - gift-pay/detail?sectionId=xxx ← 无 requestSn,进入「创建态」 - │ - ├─ 展示:文章标题、单价、数量输入框(无上限,支付时校验正整数) - ├─ 点击「去支付」 - │ │ - │ v - │ create(quantity) + initiator-pay(连续调用,用户无感知) - │ │ - │ v - │ 微信支付 - │ - v - 支付成功 → 刷新为「分享态」 - │ - ├─ 显示「分享给好友」按钮 - └─ 分享 path:detail?requestSn=xxx&ref=发起人推荐码 - - -┌─────────────────────────────────────────────────────────────────────────────┐ -│ 好友 │ -└─────────────────────────────────────────────────────────────────────────────┘ - - 打开链接 detail?requestSn=xxx&ref=xxx - │ - v - 展示:发起人头像、昵称、文章信息 - │ - v - 点击「领取」 - │ - ├─ 未登录 ──> 弹窗「请先登录」──> 登录成功 ──> 自动继续领取 - │ - ├─ 未领取 ──> 领取成功 ──> 跳转 read 阅读 - │ - └─ 已领取 ──> 提示「已领取」──> 自动跳转 read(或显示「去阅读」) -``` - ---- - -## 二、页面状态与路由 - -### gift-pay/detail(统一承载) - -| 入参 | 身份 | 页面态 | 主要操作 | -|------|------|--------|----------| -| sectionId(无 requestSn) | 发起人 | 创建态 | 输入数量 → 去支付(创建后无法退款) | -| requestSn,isInitiator,status=paid | 发起人 | 分享态 | 分享给好友 | -| requestSn,!isInitiator,未领取 | 好友 | 领取态 | 领取(未登录先弹窗) | -| requestSn,!isInitiator,已领取 | 好友 | 已领态 | 去阅读 | - -### gift-pay/redemption-detail(领取详情,新建) - -| 入口 | 展示内容 | -|------|----------| -| 列表点击「我发起的代付」卡片 | 文章信息、领取人明细(头像、昵称、领取时间)、剩余份数 | - ---- - -## 三、关键简化点 - -### 3.1 入口统一,一步到位 - -- **旧**:read 弹窗输入份数 → 确认 → create → 跳转 detail → 支付 -- **新**:read 点击「代付分享」→ 直接跳转 detail(带 sectionId)→ 在 detail 输入数量并支付 - -减少一次弹窗、一次确认,流程更顺。 - -### 3.2 创建+支付一气呵成 - -- 用户点击「去支付」→ 后端先 create(quantity),再 initiator-pay -- 前端可封装为一次「去支付」操作:create 成功拿到 requestSn 后,立即调 initiator-pay,用户只看到一次支付弹窗 - -### 3.3 领取前登录(已实现,需确认) - -- 点击「领取」时若无 userId → `showLoginModal = true` -- 登录成功后 `handleWechatLogin` 内调用 `_doRedeem()` -- 弹窗文案:「登录后可免费领取并阅读」 - -### 3.4 已领取自动解锁 - -- detail 接口增加:好友已领取时返回 `alreadyRedeemed: true`、`sectionId`、`sectionMid` -- 前端:展示「已领取」+ 自动跳转 read,或提供「去阅读」按钮 - -### 3.5 分享带 ref - -- 分享 path:`/pages/gift-pay/detail?requestSn=${requestSn}&ref=${发起人referralCode}` - ---- - -## 四、接口与前端改动清单(已完成) - -| 序号 | 改动 | 状态 | -|------|------|------| -| 1 | read 页「代付分享」 | ✅ 直接跳转 detail?sectionId=xxx | -| 2 | detail 支持 sectionId 入参 | ✅ | -| 3 | detail 创建态 UI | ✅ 数量输入框 +「去支付」+「创建后无法退款」 | -| 4 | 去支付逻辑 | ✅ create(quantity) → initiator-pay | -| 5 | GiftPayDetail | ✅ 支持 sectionId;已领取返回 action=alreadyRedeemed;redeemList 含 avatar | -| 6 | 分享 path | ✅ 含 `&ref=${发起人referralCode}` | -| 7 | 已领取态 | ✅ 按钮「已领取,去阅读」 | -| 8 | 领取详情页 | ✅ redemption-detail:文章信息、领取人明细、剩余份数 | -| 9 | 列表 | ✅ 点击→领取详情;待支付仅取消、已支付仅分享;取消后自动删除 | -| 10 | 发起人视角 | ✅ 隐藏发起人信息、安全徽章、右侧箭头 | -| 11 | 份数 | ✅ 前端不限制,支付时校验正整数;后端校验 ≥1 | - ---- - -## 五、登录弹窗流程(已有,保持不变) - -``` -好友点击「领取」 - │ - v -userId 存在? - │ - ├─ 是 ──> 直接 _doRedeem() - │ - └─ 否 ──> setData({ showLoginModal: true }) - │ - v - 用户点击「微信快捷登录」/ 手机号登录 - │ - v - 登录成功 ──> closeLoginModal ──> _doRedeem() -``` - ---- - -## 六、read 页改动(极简) - -**旧**: -```javascript -showGiftShareModal() → 弹窗输入份数 → confirmGiftShare() → create → 跳转 detail -``` - -**新**: -```javascript -showGiftShareModal() → 直接 wx.navigateTo(`/pages/gift-pay/detail?sectionId=${sectionId}`) -``` - -移除:`showGiftModal`、`giftQuantity`、`onGiftQuantityInput`、`confirmGiftShare`、弹窗 wxml。 diff --git a/开发文档/代付-需求分析与待完善.md b/开发文档/代付-需求分析与待完善.md deleted file mode 100644 index ce70faab..00000000 --- a/开发文档/代付-需求分析与待完善.md +++ /dev/null @@ -1,91 +0,0 @@ -# 代付分享 - 需求分析与待完善 - -> 基于用户描述整理,含 ref=发起人推荐码 说明。更新日期:2026-03-17(橙子整理) - ---- - -## 一、您描述的逻辑梳理 - -### 1. 流程总览 - -``` -read 页「代付分享」 - │ - v -代付页面(gift-pay/detail 或新建入口页) - │ - ├─ 输入发放数量 - ├─ 支付(单价×数量) - │ - v -支付完成 → 点击「分享给好友」 - │ - v -分享链接:路径 + 代付码(requestSn) + 推荐码(ref=发起人referralCode) - │ - v -好友打开领取页 - │ - ├─ 变更推荐人逻辑(ref 绑定到发起人,给发起人拉新) - ├─ 根据代付码显示:发起人头像、昵称、文章信息 - │ - v -点击「领取」 - │ - ├─ 未领取 → 领取 → 创建订单(不参与分佣)→ 解锁文章 - └─ 已领取 → 提示「已领取」→ 自动解锁文章(跳转 read) -``` - -### 2. ref 的含义 - -| 字段 | 含义 | 用途 | -|------|------|------| -| ref | 发起人的推荐码 | 好友从带 ref 的链接进入时,绑定为发起人推荐的用户,给发起人拉新 | - ---- - -## 二、与当前实现的差异(已对齐) - -| 环节 | 当前实现 | 状态 | -|------|----------|------| -| 输入数量 | detail 页输入数量 → 去支付(create + initiator-pay) | ✅ 已实现 | -| 分享链接 | `detail?requestSn=xxx&ref=发起人推荐码` | ✅ 已实现 | -| 已领取处理 | action=alreadyRedeemed,按钮「已领取,去阅读」 | ✅ 已实现 | -| 文章解锁 | 依赖 orders 表,领取订单不参与分佣 | ✅ 已实现 | -| 领取记录 | 领取详情页展示头像、昵称、领取时间 | ✅ 已实现 | - ---- - -## 三、已实现项 - -| 项 | 说明 | -|------|------| -| 输入数量 | detail 页输入,create + initiator-pay 连续调用 | -| 分享带 ref | 使用 `app.getMyReferralCode()` | -| 已领取态 | 后端返回 action=alreadyRedeemed,前端「已领取,去阅读」 | -| 领取详情页 | redemption-detail:文章信息、领取人明细(头像、昵称)、剩余份数 | -| 列表逻辑 | 待支付仅取消、已支付仅分享;取消后自动删除 | -| 发起人视角 | 隐藏发起人信息、安全徽章、右侧箭头 | -| 创建态提示 | 创建后无法退款 | -| 份数校验 | 前端支付时校验正整数;后端校验 ≥1 | -| 退款后禁用 | 订单退款后,同步将 gift_pay_requests 标记为 refunded,小程序端不可再分享/领取,展示「已退款」 | ✅ 已实现(2026-03-18) | - ---- - -## 四、待确认 - -| 项 | 说明 | -|------|------| -| ref 解析 | app 对分享 path 中 ref 的解析,与 bindReferralCode 规则是否一致 | - ---- - -## 五、状态机补充(用于验收) - -| gift_pay_requests.status | 含义 | 发起人可操作 | 好友可操作 | -|---|---|---|---| -| pending_pay | 待发起人支付 | 支付 / 取消 | 等待 | -| paid | 已支付待领取 | 分享 | 领取/已领取 | -| refunded | 已退款 | 不可分享(仅展示已退款) | 不可领取 | -| cancelled | 已取消 | 不可操作 | 不可操作 | -| expired | 已过期 | 不可操作 | 不可操作 | diff --git a/开发文档/代付逻辑-检查与修复记录.md b/开发文档/代付逻辑-检查与修复记录.md deleted file mode 100644 index 9c2ed665..00000000 --- a/开发文档/代付逻辑-检查与修复记录.md +++ /dev/null @@ -1,63 +0,0 @@ -# 代付逻辑改造 - 检查与修复记录 - -> 变更完成检查。更新日期:2026-03-17 - ---- - -## 一、流程漏洞(已修复) - -### 1. 发起人「已拥有」校验错误 - -**问题**:新逻辑为「发起人帮别人买」,发起人自己可已拥有该章节/全书/VIP,但后端仍校验「您已拥有该章节」并拒绝创建。 - -**修复**:移除 GiftPayCreate 中的 section/fullbook/vip 的「发起人已拥有」校验。 - -**文件**:`soul-api/internal/handler/gift_pay.go` - -### 2. gift-pay/detail 缺少 stopPropagation - -**问题**:登录弹窗使用 `catchtap="stopPropagation"`,但 detail.js 未定义该方法,可能导致点击弹窗内部时冒泡异常。 - -**修复**:在 detail.js 中添加 `stopPropagation() {}`。 - -**文件**:`miniprogram/pages/gift-pay/detail.js` - ---- - -## 二、样式修复(已修复) - -### 1. 登录弹窗 modal-close 定位 - -**问题**:modal-close 使用 `position: absolute`,父级缺少 `position: relative`,关闭按钮可能定位异常。 - -**修复**:为 `.modal-content.login-modal` 添加 `position: relative`。 - -**文件**:`miniprogram/pages/gift-pay/detail.wxss` - -### 2. redeem 按钮图标颜色 - -**问题**:redeem-btn 的 btn-icon 未应用 `filter: brightness(0)`,图标颜色可能与 pay/share 按钮不一致。 - -**修复**:将 redeem-btn 的 btn-icon 加入 filter 规则。 - -**文件**:`miniprogram/pages/gift-pay/detail.wxss` - ---- - -## 三、已确认无问题的项 - -| 项 | 说明 | -|------|------| -| read 页 gift modal | modal-header、modal-title 等样式在 read.wxss 中已有 | -| onGiftQuantityInput | 空输入、0、超范围均已处理 | -| redeem 跳转 | sectionMid 为 0 时用 id,逻辑正确 | -| 后端 detail 错误处理 | cancelled/expired 返回 error,前端显示 empty | -| 单页模式 footer | footer-summary 与 footer-tip-single 并排,可接受 | - ---- - -## 四、建议联调验证 - -1. **发起人已拥有章节**:发起人已购买某章节 → 点击代付分享 → 应能正常创建并支付 -2. **登录弹窗**:好友未登录点击领取 → 弹窗打开 → 点击弹窗内部不关闭 → 点击遮罩关闭 -3. **redeem 按钮**:图标与 pay 按钮风格一致 diff --git a/开发文档/存客宝对接逻辑图.md b/开发文档/存客宝对接逻辑图.md deleted file mode 100644 index e94f1672..00000000 --- a/开发文档/存客宝对接逻辑图.md +++ /dev/null @@ -1,121 +0,0 @@ -# 存客宝对接逻辑图 - -## 一、概念区分 - -| 字段 | 含义 | 来源 | 用途 | -|------|------|------|------| -| **token** | 32 位唯一标识 | 我们 `genPersonToken()` 生成 | 存在文章 `data-id`,小程序传 `targetUserId` | -| **ckb_api_key** | 存客宝计划级密钥 | 存客宝 `plan/detail` 接口返回 | 调 scenarios 内部 API 时作为 `apiKey` 鉴权 | - -**token ≠ apiKey**。scenarios 内部 API 需要的是 `ckb_api_key`,不是 token。 - ---- - -## 二、Person 创建流程(含存客宝计划) - -``` -管理端添加 / 文章 @新人物 保存 - │ - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ DBPersonSave / createPersonMinimal │ -├─────────────────────────────────────────────────────────────┤ -│ 1. genPersonToken() → 生成 token(32 位) │ -│ 2. ckbOpenGetToken() → 获取开放 API JWT │ -│ 3. ckbOpenCreatePlan(JWT, payload) → 创建计划,返回 planId │ -│ 4. ckbOpenGetPlanDetail(JWT, planId) → 获取 plan 的 apiKey │ -│ 5. 落库 Person: │ -│ - token = 我们生成的 token │ -│ - ckb_api_key = 存客宝返回的 apiKey │ -│ - ckb_plan_id = planId │ -└─────────────────────────────────────────────────────────────┘ -``` - ---- - -## 三、文章 @ 到留资提交流程 - -``` -文章 content 解析 - @远志 - │ - ▼ -小程序 contentParser → seg.userId = TOKEN - │ - ▼ -用户点击 @远志 → onMentionTap → targetUserId = TOKEN - │ - ▼ -POST /api/miniprogram/ckb/lead - { targetUserId: TOKEN, phone, wechatId, ... } - │ - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ CKBLead │ -├─────────────────────────────────────────────────────────────┤ -│ 1. targetUserId 有值 → 用 token 查 Person │ -│ 2. leadKey = Person.CkbApiKey(存客宝计划级 apiKey) │ -│ 3. 若 CkbApiKey 为空 → 报错,不 fallback .env │ -│ 4. 调 scenarios: GET ckbAPIURL?apiKey=leadKey&...&sign=... │ -└─────────────────────────────────────────────────────────────┘ - │ - ▼ -存客宝 scenarios 内部 API 按 apiKey 路由到对应计划,收线索 -``` - ---- - -## 四、首页「链接卡若」流程 - -``` -首页留资(无 targetUserId) - │ - ▼ -POST /api/miniprogram/ckb/lead - { phone, wechatId, ... } // 无 targetUserId - │ - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ CKBLead / CKBIndexLead │ -├─────────────────────────────────────────────────────────────┤ -│ leadKey = getCkbLeadApiKey() │ -│ → system_config.site_settings.ckbLeadApiKey │ -│ → .env CKB_LEAD_API_KEY │ -│ → 代码内置 ckbAPIKey │ -└─────────────────────────────────────────────────────────────┘ -``` - ---- - -## 五、数据流总览 - -``` -┌──────────────┐ token ┌──────────────┐ ckb_api_key ┌──────────────┐ -│ 文章 content │ ──────────────▶│ persons 表 │ ─────────────────▶│ scenarios │ -│ data-id │ │ token │ │ 内部 API │ -└──────────────┘ │ ckb_api_key │ └──────────────┘ - ▲ │ ckb_plan_id │ - │ └──────────────┘ - │ ▲ - │ │ 创建时 - │ ┌──────┴──────┐ - │ │ 开放 API │ - │ │ createPlan │ - │ │ getPlanDetail│ - │ └─────────────┘ - │ -┌──────┴──────┐ -│ 管理端/autolink │ -│ 添加/编辑 Person │ -└──────────────┘ -``` - ---- - -## 六、关键结论 - -1. **apiKey 已存储**:创建计划时 `ckbOpenGetPlanDetail` 返回的 apiKey 会写入 `persons.ckb_api_key`。 -2. **CKBLead 应用 CkbApiKey**:文章 @ 场景下,用 token 查 Person,取 `CkbApiKey` 作为 scenarios 的 apiKey,**不能用 token 代替**。 -3. **CkbApiKey 为空时**:应返回明确错误,提示该人物尚未配置存客宝密钥,**不要 fallback 到 .env**(.env 是卡若的,会路由到错误计划)。 -4. **创建计划参数**:`planType=1`、`sceneId=9`、`scenario=9`、`status=1`(2026-03-16 修正,否则 401 无效 apiKey)。 -5. **mention span 需 data-label**:TipTap 仅从 `data-label` 解析显示名,缺则显示 token;ParseAutoLinkContent 输出必须含 `data-label`。 diff --git a/开发文档/小程序-图标清单-阿里云iconfont.md b/开发文档/小程序-图标清单-阿里云iconfont.md deleted file mode 100644 index 218a0414..00000000 --- a/开发文档/小程序-图标清单-阿里云iconfont.md +++ /dev/null @@ -1,147 +0,0 @@ -# Soul 创业派对 - 小程序图标清单(阿里云 iconfont 采购用) - -> 用于在 [iconfont.cn](https://www.iconfont.cn) 或阿里云设计资源中搜索、下载。建议统一风格(线性/描边),尺寸 24×24 或 48×48。 - ---- - -## 一、icon 组件内联 SVG(需对应 name) - -当前 `components/icon/icon.js` 使用 Lucide 风格,若改为阿里云图标,需按以下 name 一一对应: - -| 序号 | name | 中文名 | 用途/场景 | -|-----|------|--------|----------| -| 1 | share | 分享 | 分享到好友/朋友圈 | -| 2 | chevron-left | 左箭头 | 返回、导航 | -| 3 | chevron-right | 右箭头 | 进入、下一步 | -| 4 | chevron-down | 下箭头 | 展开、下拉 | -| 5 | search | 搜索 | 搜索框、目录搜索 | -| 6 | user | 用户 | 个人中心、头像占位 | -| 7 | users | 用户组 | 找伙伴、资源对接 | -| 8 | home | 首页 | 首页入口 | -| 9 | star | 星星 | 找伙伴、收藏 | -| 10 | heart | 心形 | 导师顾问、喜欢 | -| 11 | message-circle | 消息/对话 | 微信、联系方式 | -| 12 | smartphone | 手机 | 手机号、绑定 | -| 13 | map-pin | 地图定位 | 地区、地址 | -| 14 | book-open | 打开的书 | 书籍、阅读、目录 | -| 15 | lightbulb | 灯泡 | 想法、亮点 | -| 16 | handshake | 握手 | 合作、我能帮到你 | -| 17 | rocket | 火箭 | 成长、我能帮到你 | -| 18 | trophy | 奖杯 | 最赚钱的一个月 | -| 19 | star | 星星 | 最有成就感的一件事 | -| 20 | refresh-cw | 刷新 | 人生的转折点 | -| 21 | shield | 盾牌 | 安全、代付保障 | -| 22 | wallet | 钱包 | 余额、支付、提现 | -| 23 | camera | 相机 | 头像上传 | -| 24 | lock | 锁 | 登录、付费墙 | -| 25 | gift | 礼物 | 代付、礼包 | -| 26 | megaphone | 喇叭 | 分享到朋友圈 | -| 27 | image | 图片 | 生成海报 | -| 28 | clipboard | 剪贴板 | 复制联系方式 | -| 29 | check | 勾选 | 同意协议、已绑定 | -| 30 | trash-2 | 删除 | 删除地址 | -| 31 | plus | 加号 | 新增 | -| 32 | pencil | 编辑 | 编辑资料、编辑地址 | -| 33 | zap | 闪电 | 购买次数、解锁 | -| 34 | info | 信息 | 温馨提示 | -| 35 | x | 关闭 | 弹窗关闭 | -| 36 | gamepad | 手柄 | 团队招募 | -| 37 | briefcase | 公文包 | 对私域运营感兴趣 | -| 38 | target | 靶心 | 相似的创业方向 | -| 39 | save | 保存 | 保存海报 | -| 40 | globe | 地球 | 朋友圈 | -| 41 | package | 包裹 | 空状态、订单 | -| 42 | clock | 时钟 | 时间、过期 | -| 43 | corner-down-left | 退款 | 退款类型 | -| 44 | folder | 文件夹 | 目录 | - ---- - -## 二、assets/icons 独立文件(image 引用) - -当前 `miniprogram/assets/icons/` 下已有,若需阿里云统一风格可替换: - -| 文件名 | 用途 | -|--------|------| -| home.svg | 底部 Tab 首页 | -| list.svg | 底部 Tab 目录 | -| user.svg | 底部 Tab 我的 | -| partners.svg | 底部 Tab 找伙伴(中间突出) | -| edit-gray.svg | 我的页编辑、设置入口 | -| wallet.svg | 我的余额、提现 | -| eye-teal.svg | 阅读统计 | -| book-open-teal.svg | 阅读统计 | -| clock-teal.svg | 阅读统计 | -| users-teal.svg | 阅读统计 | -| book-arrow-teal.svg | 阅读统计 | -| folder-teal.svg | 目录入口 | -| gift.svg | 代付入口 | -| settings-gray.svg | 设置入口 | -| chevron-left.svg | 返回 | -| arrow-right.svg | 右箭头 | -| bell.svg | 消息提醒 | -| alert-circle.svg | 警告提示 | -| users.svg | 绑定用户 | -| image.svg | 分享 | -| share.svg | 分享 | -| message-circle.svg | 微信分享 | -| user.svg | 用户占位 | -| gift.svg | 礼包空状态 | -| info.svg | 礼包页说明 | -| eye-off.svg | 未解锁(联系方式/微信号) | -| user-edit-gray.svg | (备用) | -| info-blue.svg | (备用) | -| book.svg | (备用) | -| book-arrow.svg | (备用) | -| clock.svg | (备用) | -| eye.svg | (备用) | -| folder.svg | (备用) | -| settings.svg | (备用) | - -**PNG(Tab 激活态,可考虑改为 SVG):** -- home.png / home-active.png -- my.png / my-active.png -- match.png / match-active.png - ---- - -## 三、iconfont 搜索关键词建议 - -| 图标 | 搜索词 | -|------|--------| -| 分享 | 分享、share | -| 返回 | 左箭头、返回、chevron | -| 箭头 | 右箭头、arrow、chevron | -| 搜索 | 搜索、search、放大镜 | -| 用户 | 用户、user、person | -| 用户组 | 用户组、users、people | -| 首页 | 首页、home、房子 | -| 星星 | 星星、star | -| 心形 | 心、heart、喜欢 | -| 消息 | 消息、对话、message、微信 | -| 手机 | 手机、smartphone | -| 定位 | 定位、地图、map、pin | -| 书本 | 书本、book、阅读 | -| 灯泡 | 灯泡、lightbulb、想法 | -| 握手 | 握手、handshake | -| 火箭 | 火箭、rocket | -| 奖杯 | 奖杯、trophy | -| 盾牌 | 盾牌、shield | -| 钱包 | 钱包、wallet | -| 相机 | 相机、camera | -| 锁 | 锁、lock | -| 礼物 | 礼物、gift | -| 勾选 | 勾选、check、对勾 | -| 删除 | 删除、trash | -| 编辑 | 编辑、pencil、铅笔 | -| 闪电 | 闪电、zap | -| 信息 | 信息、info | - ---- - -## 四、规格建议 - -- **格式**:SVG(优先,可缩放)或 PNG -- **尺寸**:24×24、32×32、48×48(多尺寸备选) -- **风格**:线性描边(stroke),与 Lucide 风格一致 -- **颜色**:单色或透明底,便于在代码中动态设置 `color` diff --git a/开发文档/小程序变更影响分析-20260318.md b/开发文档/小程序变更影响分析-20260318.md deleted file mode 100644 index 8281dbb3..00000000 --- a/开发文档/小程序变更影响分析-20260318.md +++ /dev/null @@ -1,67 +0,0 @@ -# 小程序变更影响分析(2026-03-18) - -## 一、近期变更汇总 - -| 变更项 | 影响 | -|--------|------| -| config 拆分 | core + audit-mode + read-extras,已迁移 | -| all-chapters 废弃 | 改用 book/parts、chapters-by-part、book/stats | -| idMidMap/getSectionMid 移除 | 列表/接口均带 mid,跳转用 mid 或 id | -| 章节接口 | by-mid、by-id,移除 /chapter/:id | -| 文章详情 | 响应含 prev/next,无需单独请求 | - ---- - -## 二、各页面检查结果 - -### ✅ 无影响 - -| 页面 | 说明 | -|------|------| -| **index** | recommended/hot/latest 均带 mid,goToRead 用 dataset | -| **chapters** | book/parts + chapters-by-part,section 有 mid,fixedSections 有 mid | -| **search** | 搜索结果带 id+mid | -| **my** | recentChapters 来自 dashboard-stats,后端返回 id+mid | -| **read** | _getChapterUrl 支持 by-mid/by-id,prev/next 在详情内 | -| **gift-pay** | detail 含 productMid+productId,goToRead 优先 mid | -| **purchases** | 订单列表无跳转阅读,sectionMid 兜底为 0 | - -### ✅ 已优化 - -| 位置 | 变更 | -|------|------| -| **read 海报 scene** | 有 sectionMid 时用 mid,与分享一致 | - -### 可选优化(低优先级) - -| 位置 | 现状 | 说明 | -|------|------|------| -| **read copyLink** | `soul.quwanzhi.com/read/${sectionId}` | H5 若仅支持 id,保持即可 | -| **index bookData** | data 中仍有 bookData: [] | 未在 wxml 展示,可后续清理 | - -### 📋 数据流确认 - -| 数据源 | id | mid | 说明 | -|--------|----|-----|------| -| recommended | ✓ | ✓ | toSection 映射 | -| latest-chapters | ✓ | ✓ | 直接使用 | -| hot | ✓ | ✓ | 直接使用 | -| chapters-by-part | ✓ | ✓ | section 含 mid | -| book/parts fixedSections | id | mid | fixedSectionsMap | -| dashboard-stats recentChapters | ✓ | ✓ | 后端查 chapters 表 | -| gift-pay detail | productId | productMid | 后端查 chapters 表 | - ---- - -## 三、潜在风险点 - -1. **序言/尾声**:fixedSectionsMap 来自 book/parts 的 fixedSections,若后端未返回 mid,data-mid 为空,goToRead 会传 id。需确认 book/parts 的 fixedSections 是否含 mid。 -2. **orders API**:purchases 从 /api/miniprogram/orders 取数,有 section_mid 时正常;fallback 到 purchasedSections 时 sectionMid=0,当前无跳转阅读,无影响。 -3. **H5 链接**:copyLink 的 soul.quwanzhi.com 若仅支持 id,保持现状即可。 - ---- - -## 四、结论 - -- **核心流程**:首页、目录、搜索、我的、阅读、代付、分享均正常。 -- **建议**:海报 scene 改为优先 mid;index bookData 可清理。 diff --git a/开发文档/小程序性能分析-20260318.md b/开发文档/小程序性能分析-20260318.md deleted file mode 100644 index 4cb0ef21..00000000 --- a/开发文档/小程序性能分析-20260318.md +++ /dev/null @@ -1,142 +0,0 @@ -# Soul 创业派对 - 小程序性能分析(2026-03-18) - -## 一、整体架构 - -| 层级 | 策略 | 说明 | -|------|------|------| -| **前端** | 并行请求、懒加载、GET 去重 | app.request 同 URL 并发共享 promise | -| **前端** | 配置缓存 5min | getConfig 减少重复请求 | -| **后端** | Redis + 内存双层缓存 | 启动预热,冷启动 502 已规避 | -| **后端** | 按需加载 | book/parts、chapters-by-part 懒加载,无全量 all-chapters | - ---- - -## 二、启动与首屏 - -### 2.1 App onLaunch - -| 任务 | 接口 | 并行 | 说明 | -|------|------|------|------| -| loadBookData | book/parts | ✓ | 仅取 totalSections | -| loadMpConfig | config/core + audit-mode | ✓ | Promise.all 并行 | -| checkUpdate | wx.getUpdateManager | ✓ | 系统 API | -| handleReferralCode | 本地/可选请求 | ✓ | 推荐码绑定 | - -**结论**:启动阶段请求少,config 已拆分,体积小。 - -### 2.2 首页 index initData - -| 任务 | 接口 | 并行 | 说明 | -|------|------|------|------| -| loadBookData | book/parts | ✓ | 与 app 同 URL,GET 去重 | -| loadFeaturedFromServer | recommended + latest-chapters | ✓ | Promise.all | -| loadSuperMembers | vip/members → users | 串行 | 不足 4 人时补 users | -| loadLatestChapters | latest-chapters | ✓ | 与 loadFeatured 同 URL,去重 | - -**首屏请求汇总**(去重后): -- book/parts × 1 -- config/core + audit-mode × 1(app 已拉) -- book/recommended × 1 -- book/latest-chapters × 1 -- vip/members × 1 -- users(条件) × 1 - -**优化点**: -- loadFeaturedFromServer 与 loadLatestChapters 都请求 latest-chapters,并发时会被去重,但逻辑重复,可合并为一次请求、两处使用。 - ---- - -## 三、核心页面 - -### 3.1 目录页 chapters - -| 阶段 | 接口 | 说明 | -|------|------|------| -| onLoad | book/parts | 仅篇章列表 + totalSections + fixedSections | -| 展开篇章 | chapters-by-part | 按需懒加载,每篇章一次 | - -**潜在问题**:`loadChaptersByPart` 每次展开都会 `wx.setStorageSync('bookData', bookDataFlat)`,章节多时可能阻塞主线程,可考虑节流或异步写入。 - -### 3.2 阅读页 read - -| 阶段 | 接口 | 说明 | -|------|------|------| -| onLoad 预加载 | getConfig + getReadExtras | Promise.all,read-extras 懒加载 | -| mid 解析 | chapter/by-mid/:mid | 仅 mid 有值且无 id 时 | -| 主流程 | chapter/by-mid 或 by-id | 单次请求 | -| 权限 | check-purchased | 非免费章节且已登录时 | -| 内容 | 复用 chapterRes | 无二次请求 | - -**结论**:章节数据一次拉取、复用,prev/next 在详情内返回,无额外接口。 - -### 3.3 阅读追踪 readingTracker - -| 行为 | 频率 | 说明 | -|------|------|------| -| 初始化 | 立即上报 1 次 | 打开即记录点击 | -| 定期上报 | 每 30 秒 | 增量 duration,不重复累加 | -| 读完 | 立即上报 | progress≥90% 且停留 3 秒 | - -**结论**:上报策略合理,对性能影响小。 - ---- - -## 四、后端缓存 - -| 接口 | Redis TTL | 内存 TTL | 预热 | -|------|-----------|----------|------| -| config/core | 10min | - | ✓ | -| config/audit-mode | 1min | - | ✓ | -| config/read-extras | 10min | - | ✓ | -| book/parts | 10min | 30s | ✓ | -| chapters-by-part | 10min | 30s | - | -| chapter 正文 | 30min | - | - | -| hot/recommended/stats | 5min | - | ✓ | -| latest-chapters | 5min | - | ✓ | - -**结论**:Redis + 内存 + 启动预热,冷启动已优化。 - ---- - -## 五、优化建议(按优先级) - -### 高优先级 - -| 项 | 现状 | 建议 | -|----|------|------| -| index latest-chapters 重复 | loadFeatured + loadLatestChapters 各请求一次 | 合并为一次请求,两处共用数据 | - -### 中优先级 - -| 项 | 现状 | 建议 | -|----|------|------| -| loadSuperMembers 串行 | vip/members 完成后再请求 users | 可并行发起,按需合并结果 | -| chapters setStorage | 每次展开都同步写入 bookData | 节流或改为异步,避免大对象阻塞 | - -### 低优先级 - -| 项 | 现状 | 说明 | -|----|------|------| -| read-extras | 阅读页 onLoad 即拉 | 可延到首次需要 linkTags 时再拉 | -| GET 去重窗口 | 请求完成即删除 | 可考虑短时(如 200ms)窗口,覆盖快速重复点击 | - ---- - -## 六、性能风险点 - -1. **Storage 同步写入**:`wx.setStorageSync` 在章节多时可能卡顿,建议监控或改为异步。 -2. **read 页 setData**:约 41 处 setData,单次更新数据量需控制,避免大对象。 -3. **长列表**:latestChapters 最多 20 条,当前规模可接受;若扩展需考虑虚拟列表。 - ---- - -## 七、总结 - -| 维度 | 评分 | 说明 | -|------|------|------| -| 网络请求 | 良好 | 并行、去重、懒加载、缓存完善 | -| 首屏速度 | 良好 | 请求少,后端有预热 | -| 阅读体验 | 良好 | 单次拉取、复用、追踪合理 | -| 存储与渲染 | 一般 | setStorage 同步、setData 次数可优化 | - -**整体**:当前性能可接受,优先落地「index 合并 latest-chapters」即可带来明显收益。 diff --git a/开发文档/废弃接口清单.md b/开发文档/废弃接口清单.md deleted file mode 100644 index 525010d4..00000000 --- a/开发文档/废弃接口清单.md +++ /dev/null @@ -1,34 +0,0 @@ -# Soul 创业派对 - 废弃接口清单 - -> 以下接口已标记 Deprecated,保留以兼容旧版/管理端/next-project,计划后续下线。新开发请使用替代接口。 - -## 一、小程序组 `/api/miniprogram/*` - -| 废弃接口 | 替代接口 | 说明 | -|----------|----------|------| -| `GET /api/miniprogram/config` | `GET /config/core` + `GET /config/audit-mode` + `GET /config/read-extras` | 小程序已迁移至拆分接口 | -| `GET /api/miniprogram/book/all-chapters` | `GET /book/parts` + `GET /book/chapters-by-part` + `GET /book/stats` | 小程序已迁移至按需加载 | - -## 二、API 组 `/api/*`(next-project / 管理端) - -| 废弃接口 | 替代接口 | 说明 | -|----------|----------|------| -| `GET /api/book/all-chapters` | 同上 | 小程序已迁移至 miniprogram 组 | -| `GET /api/db/config` | 小程序用 `/miniprogram/config/core` 等 | 公开配置,小程序已迁移 | - -## 三、代码标记位置 - -| 文件 | 位置 | -|------|------| -| soul-api/internal/handler/db.go | `GetPublicDBConfig` 函数注释 | -| soul-api/internal/handler/book.go | `BookAllChapters` 函数注释 | -| soul-api/internal/router/router.go | miniprogram `/config`、`/book/all-chapters` 路由上方 | -| soul-api/internal/router/router.go | api `/book/all-chapters`、`/db/config` 路由上方 | - -## 四、迁移状态 - -| 端 | config | all-chapters | -|----|--------|--------------| -| 小程序 | ✅ 已迁移 core + audit-mode + read-extras | ✅ 已迁移 book/parts + chapters-by-part | -| 管理端 | 使用 /api/db/config、config/full | 不直接调用 all-chapters | -| next-project | 可能仍用 /api/db/config | 可能仍用 /api/book/all-chapters | diff --git a/开发文档/性能优化-综合分析.md b/开发文档/性能优化-综合分析.md deleted file mode 100644 index eef9236f..00000000 --- a/开发文档/性能优化-综合分析.md +++ /dev/null @@ -1,124 +0,0 @@ -# Soul 创业派对 - 小程序与 API 性能优化综合分析 - -**分析时间**: 2026-03-18 -**范围**: 小程序(miniprogram)+ 后端 API(soul-api) - ---- - -## 一、当前已完成的优化 - -### 1.1 API 端(soul-api) - -| 优化项 | 说明 | 效果 | -|--------|------|------| -| **Redis 缓存** | config、book/parts、all-chapters、chapters-by-part、latest-chapters、free_chapters、chapter content、hot、recommended、stats | 命中时免 DB,响应 <50ms | -| **启动预热** | WarmConfigCache、WarmAllChaptersCache、WarmBookPartsCache、WarmLatestChaptersCache | 首请求无冷启动 | -| **Gzip 压缩** | gin-contrib/gzip 中间件 | 响应体缩小 60–80% | -| **内存兜底** | parts、all-chapters、chapters-by-part 有 30s 内存缓存 | Redis 不可用时仍快 | - -### 1.2 小程序端(miniprogram) - -| 优化项 | 说明 | 效果 | -|--------|------|------| -| **骨架屏** | 阅读页、目录页、代付详情、搜索页 | 加载过程有占位,减少白屏 | -| **bookData 本地缓存** | app.loadBookData 先读 wx.getStorageSync('bookData') | 二次打开可先展示缓存 | -| **config 节流** | onShow 时 loadMpConfig 30 秒节流 | 避免频繁请求 | -| **静默请求** | 统计、推荐访问等用 silent: true | 不阻塞 UI | - -### 1.3 实测数据(正式环境 2026-03-18) - -| 接口 | 平均(ms) | 最小(ms) | 最大(ms) | -|------|----------|----------|----------| -| config | 390 | 378 | 406 | -| book/parts | 396 | 387 | 403 | -| book/all-chapters | 390 | 376 | 407 | -| book/chapters-by-part | 420 | 416 | 424 | -| book/chapter/:id | 420 | 401 | 425 | -| book/chapter/by-mid/:mid | 424 | 419 | 431 | - -**说明**:约 390–430ms 主要为网络 RTT(用户→服务器),Redis 命中时服务端处理通常 <20ms。 - ---- - -## 二、待优化项(按优先级) - -### 2.1 高优先级:减少重复请求 - -| 问题 | 现状 | 建议 | -|------|------|------| -| **config 多端重复** | app.loadMpConfig、index.loadFeatureConfig、read 页、TabBar 各自拉 config | 统一用 `app.globalData` 缓存,首次拉取后 5–10min 内复用;各页优先读缓存,过期再拉 | -| **all-chapters 重复** | app.loadBookData + index.loadBookData 都调 all-chapters | index 优先用 `app.globalData.bookData`,仅当为空或需刷新时再请求 | -| **loadFeaturedFromServer 串行** | 先 recommended → 失败再 hot → 再 latest-chapters | 可并行请求 recommended + latest-chapters,失败再兜底 | - -### 2.2 中优先级:请求策略 - -| 问题 | 现状 | 建议 | -|------|------|------| -| **首页请求过多** | initData 触发 loadBookData、loadFeaturedFromServer、loadSuperMembers、loadLatestChapters 等 4+ 请求 | 合并或分阶段:首屏只拉 latestSection + featured 前 3;超级个体、最新新增可延迟加载 | -| **阅读页 config** | 与 app.loadMpConfig 可能重复 | 优先用 `app.globalData` 中的 config,无缓存再请求 | -| **request 无请求去重** | 同一接口并发多次会发多次请求 | 对相同 url 做短时(如 200ms)去重,避免重复请求 | - -### 2.3 低优先级:体验与资源 - -| 问题 | 现状 | 建议 | -|------|------|------| -| **图片未优化** | 头像、海报等直接原图 | 使用 CDN 或后端缩略图;`` 加 `lazy-load` | -| **setData 频率** | 部分页面多次 setData 更新列表 | 合并更新,减少 setData 调用次数 | -| **分包** | 未使用分包 | 非首屏页面(设置、代付、导师等)可放入分包,降低主包体积 | - ---- - -## 三、API 端可进一步优化 - -| 方向 | 说明 | -|------|------| -| **HTTP/2** | 若部署支持,启用 HTTP/2 多路复用,减少连接开销 | -| **Redis 连接池** | 检查 go-redis 默认 PoolSize,高并发时可适当调大 | -| **book/search 缓存** | 搜索接口无缓存,热门关键词可加短 TTL(如 1–2min)缓存 | -| **CDN 静态资源** | uploads 图片走 CDN,减轻 API 带宽压力 | - ---- - -## 四、实施建议(分阶段) - -### 阶段一:快速见效(1–2 天) - -1. **config 统一缓存**:在 app.js 维护 `configCache` + 过期时间,各页优先读缓存。 -2. **index 复用 bookData**:`app.globalData.bookData` 有值时,index 不再单独请求 all-chapters。 -3. **loadFeaturedFromServer 并行**:`Promise.all([recommended, latest-chapters])` 并行请求。 - -### 阶段二:结构优化(3–5 天) - -1. **首页分阶段加载**:首屏只拉 latestSection + featured;超级个体、最新新增 onShow 后延迟拉取。 -2. **request 去重**:对相同 url 在 200ms 内只发一次请求,后续调用复用同一 Promise。 -3. **图片 lazy-load**:列表、头像等加 `lazy-load`。 - -### 阶段三:长期(按需) - -1. **分包加载**:非核心页面放入分包。 -2. **CDN**:静态资源迁移到 CDN。 -3. **监控**:接入性能监控,持续观察首屏、接口耗时。 - ---- - -## 五、关键代码位置索引 - -| 功能 | 文件路径 | -|------|----------| -| 请求封装 | miniprogram/app.js `request()` | -| 启动加载 | miniprogram/app.js `onLaunch` → loadBookData、loadMpConfig | -| 首页数据 | miniprogram/pages/index/index.js `initData`、loadFeaturedFromServer | -| 阅读页加载 | miniprogram/pages/read/read.js `onLoad` | -| API 缓存 | soul-api/internal/cache/cache.go | -| 预热逻辑 | soul-api/cmd/server/main.go | - ---- - -## 六、总结 - -- **已做**:Redis 多级缓存、启动预热、Gzip、骨架屏、本地缓存、节流等,接口平均 390–430ms,主要受网络 RTT 影响。 -- **优先做**:减少 config、all-chapters 等重复请求,统一缓存策略。 -- **中期**:首页分阶段加载、request 去重、图片懒加载。 -- **长期**:分包、CDN、性能监控。 - -按上述阶段推进,可在不大改架构的前提下,明显减少请求数和首屏等待时间。 diff --git a/开发文档/提现流程图.md b/开发文档/提现流程图.md deleted file mode 100644 index 0590408f..00000000 --- a/开发文档/提现流程图.md +++ /dev/null @@ -1,112 +0,0 @@ -# Soul 提现流程图 - -## 一、整体流程(Mermaid) - -```mermaid -flowchart TB - subgraph 小程序["小程序端"] - A1[用户进入推广中心/我的] - A2[输入提现金额] - A3[POST /api/miniprogram/withdraw] - end - - subgraph 后端校验["后端校验"] - B1{参数校验} - B2{金额 > 0?} - B3{金额 ≤ 可提现?} - B4{金额 ≥ 最低门槛?} - B5{用户存在且已绑定微信?} - end - - subgraph 落库["落库"] - C1[写入 withdrawals 表
    status = pending] - end - - subgraph 管理端["管理端"] - D1[管理员查看提现列表
    GET /api/admin/withdrawals] - D2{审核决策} - D3[拒绝 → status = failed] - D4[批准 → 调用微信转账] - end - - subgraph 微信["微信支付"] - E1[商家转账到零钱] - E2{微信返回 state} - E3[processing
    处理中] - E4[pending_confirm
    待用户确认收款] - end - - subgraph 用户确认["用户确认"] - F1[获取待确认列表
    GET /api/miniprogram/withdraw/pending-confirm] - F2[领取零钱
    wx.requestMerchantTransfer] - F3[确认收款
    POST /api/miniprogram/withdraw/confirm-received] - end - - subgraph 终态["终态"] - G1[success
    已到账] - G2[failed
    已拒绝/打款失败] - end - - A1 --> A2 --> A3 --> B1 - B1 --> B2 --> B3 --> B4 --> B5 - B5 -->|通过| C1 - C1 --> D1 --> D2 - D2 -->|拒绝| D3 --> G2 - D2 -->|批准| D4 --> E1 --> E2 - E2 --> E3 - E2 --> E4 --> F1 --> F2 --> F3 --> G1 - E3 -->|回调/同步| G1 - E3 -->|失败| G2 -``` - -## 二、可提现金额计算逻辑 - -```mermaid -flowchart LR - subgraph 公式["可提现 = 累计佣金 - 已提现 - 待审核"] - A[累计佣金
    paid 订单佣金求和] - B[已提现
    status=success 的 sum] - C[待审核
    pending+processing+pending_confirm 的 sum] - end - A --> D[可提现] - B --> D - C --> D -``` - -## 三、状态流转 - -```mermaid -stateDiagram-v2 - [*] --> pending: 用户申请 - pending --> failed: 管理员拒绝 - pending --> processing: 批准且微信直接处理 - pending --> pending_confirm: 批准且需用户确认收款 - processing --> success: 微信回调/主动同步 - processing --> failed: 打款失败 - pending_confirm --> success: 用户点击确认收款 - success --> [*] - failed --> [*] -``` - -## 四、关键接口一览 - -| 端 | 接口 | 用途 | -|---|---|---| -| 小程序 | POST /api/miniprogram/withdraw | 申请提现 | -| 小程序 | GET /api/miniprogram/withdraw/records | 提现记录 | -| 小程序 | GET /api/miniprogram/withdraw/pending-confirm | 待确认收款列表 | -| 小程序 | GET /api/miniprogram/withdraw/confirm-info | 领取零钱参数 | -| 小程序 | POST /api/miniprogram/withdraw/confirm-received | 确认收款 | -| 管理端 | GET /api/admin/withdrawals | 提现列表 | -| 管理端 | PUT /api/admin/withdrawals | 审核/打款(approve/reject) | -| 管理端 | POST /api/admin/withdrawals/sync | 主动同步微信转账结果 | - -## 五、校验规则(申请时) - -1. **金额 > 0** -2. **金额 ≤ 可提现余额**(累计佣金 - 已提现 - 待审核) -3. **金额 ≥ 最低提现门槛**(默认 10 元,来自 referral_config.minWithdrawAmount) -4. **用户存在** -5. **用户已绑定微信**(openid 不为空) - -批准时二次校验可提现金额,防止退款/冲正后超额打款。 diff --git a/开发文档/新版与稳定版-小程序界面差异清单.md b/开发文档/新版与稳定版-小程序界面差异清单.md deleted file mode 100644 index 241b4309..00000000 --- a/开发文档/新版与稳定版-小程序界面差异清单.md +++ /dev/null @@ -1,115 +0,0 @@ -# 新版与稳定版 - 小程序界面差异清单 - -> 乘风检测:`new-soul/miniprogram`(新版) vs `miniprogram`(稳定版) -> 更新日期:2026-03-17 - ---- - -## 一、检测结论摘要 - -| 维度 | 结论 | -|------|------| -| **页面结构** | 一致:23 个页面,4 个 Tab(首页、目录、找伙伴、我的) | -| **app.json** | 完全一致 | -| **WXML 结构** | 核心页面(index、my、read、chapters、vip、wallet、referral、search、match)结构高度一致 | -| **WXSS 样式** | 无显著差异 | -| **自定义组件** | 均仅有 `components/icon` | - ---- - -## 二、页面级差异(逐页对比) - -### 2.1 首页 index - -| 差异项 | 稳定版 miniprogram | 新版 new-soul | 说明 | -|--------|-------------------|---------------|------| -| 搜索栏 | 有 | 有 | 一致 | -| 搜索开关 | 可能有 `wx:if="{{searchEnabled}}"` | 无 | 若稳定版已迁审核/功能开关,则按配置显隐 | -| Banner 标签 | 「推荐」 | 「推荐」 | 一致 | -| 阅读进度卡 | 可能有 | 无 | 稳定版 P1 迁移项:已读 X/62 进度条 | -| 超级个体 | 有 | 有 | 一致 | -| 超级个体审核隐藏 | 可能有 `wx:if="{{!auditMode}}"` | 无 | 若稳定版已迁审核模式 | -| 精选推荐 | 有,支持展开 | 有,支持展开 | 一致 | -| 最新新增 | 有,支持展开 | 有,支持展开 | 一致 | -| 最新新增价格 | 可能有 `timeline-price` | 可能无 | 待确认 | -| 留资弹窗 | 有 | 有 | 一致 | -| env-switch 组件 | 可能有 | 无 | 稳定版开发环境专用悬浮切换 | - -### 2.2 我的页 my - -| 差异项 | 稳定版 | 新版 | 说明 | -|--------|--------|------|------| -| 资料编辑入口 | 有 nav-settings + profile-edit-btn | 有 nav-settings | 稳定版有「编辑」入口,新版可能无 | -| 会员/收益/余额 | 有 | 有 | 一致 | -| 审核模式隐藏 | 可能有 `wx:if="{{!auditMode}}"` 控制会员/余额/一键收款 | 无 | 若稳定版已迁 | -| 推荐开关 | 可能有 `wx:if="{{referralEnabled}}"` | 无 | 稳定版可配置显隐推荐/收益 | -| 阅读统计 | readCountText、totalReadTimeText、matchHistoryText | readCount、totalReadTime、matchHistory | 格式可能不同 | -| 钱包余额 | walletBalanceText | walletBalance | 显示格式可能不同 | -| 我的代付 | gift-card | gift-card | 一致(代付链接列表) | -| 代付入口 | 可能有 giftPay 菜单项 | 可能有 | 代付美团式后可能改为「我的代付」 | -| 设置入口 | 有 | 有 | 一致 | - -### 2.3 阅读页 read - -| 差异项 | 稳定版 | 新版 | 说明 | -|--------|--------|------|------| -| 审核模式 | 可能有 `paywall-audit-tip`、`wx:if="{{auditMode}}"` | 无 | 若稳定版已迁 | -| 分享区 | 代付分享、海报、朋友圈 | 同 | 一致 | -| share-tip-inline | 可能有「分享后好友购买,你可获得 90% 收益」 | 可能无 | 稳定版 P2 可选迁移 | -| 购买按钮 | 有 | 有 | 一致 | -| 余额支付 | 有 | 有 | 一致 | - -### 2.4 目录页 chapters - -| 差异项 | 稳定版 | 新版 | 说明 | -|--------|--------|------|------| -| 篇章结构 | 序言、篇章、尾声、附录 | 同 | 一致 | -| 每日新增 | 可能有 | 可能无 | 按需求可选 | -| 免费/NEW/¥1 标签 | 有 | 有 | 一致 | - -### 2.5 钱包 / VIP / 推广 / 搜索 / 匹配 - -| 页面 | 差异说明 | -|------|----------| -| wallet | 稳定版可能有 auditMode 隐藏充值入口;结构一致 | -| vip | 结构一致 | -| referral | 结构一致 | -| search | 结构一致 | -| match | 结构一致 | - ---- - -## 三、功能差异(逻辑层,非纯界面) - -| 功能 | 稳定版 | 新版 | 说明 | -|------|--------|------|------| -| 审核模式 auditMode | 有(index/my/wallet/read 按配置隐藏支付) | 无 | 提审必备 | -| 运行时配置 | getRuntimeBootstrapConfig、envVersion 区分 develop/trial/release | 简单 extConfig+storage | 稳定版按环境区分 baseUrl | -| loadMpConfig | 有,支持 auditMode、apiDomain、supportWechat | 可能无或简化 | 稳定版从 config 接口拉取 | -| 规则引擎 ruleEngine | 有 | 无 | 稳定版 after_login、after_match 等 | -| 埋点 trackClick | 有(index/my/match/vip/search/referral 等) | 可能有 | 稳定版已补齐 | -| 代付流程 | 读页→代付页→分享(美团式) | 读页弹窗分享(gift-link) | 稳定版有独立 gift-pay 页则不同 | -| 开发环境 env-switch | 有 | 无 | 稳定版 develop/trial 显示悬浮切换 | - ---- - -## 四、页面与路由差异 - -| 项目 | 稳定版 | 新版 | -|------|--------|------| -| gift-pay 独立页 | 若有(gift-pay/detail、gift-pay/list) | 无(app.json 未配置) | -| 代付入口 | 可能有「我的代付」菜单 | 「我的代付链接」gift-card | - ---- - -## 五、建议与结论 - -1. **界面层面**:两版 WXML/WXSS 高度一致,无明显布局差异。 -2. **功能层面**:稳定版在审核模式、运行时配置、规则引擎、埋点、代付流程上更完善。 -3. **迁移建议**:以 `miniprogram/` 为主开发目录;新版可作参考,但稳定版已吸收并增强。 -4. **后续验证**:建议在真机/模拟器并排对比 index、my、read 三页,确认 auditMode、searchEnabled、阅读进度卡、env-switch 等是否在稳定版中正确展示。 - ---- - -**生成时间**:2026-03-17 -**对比范围**:WXML、WXSS、app.json、app.js、pages、components diff --git a/开发文档/新版与稳定版-管理端功能样式差异分析.md b/开发文档/新版与稳定版-管理端功能样式差异分析.md deleted file mode 100644 index 439aed00..00000000 --- a/开发文档/新版与稳定版-管理端功能样式差异分析.md +++ /dev/null @@ -1,113 +0,0 @@ -# 新版与稳定版管理端 - 功能与样式差异分析 - -> 橙子整理。基于现有文档与代码分析。更新日期:2026-03-17 - -**目录说明**:`new-soul/soul-admin` = **稳定版**(生产主用);`soul-admin/`(根目录)= 另一版/迁移对照 - ---- - -## 一、全站功能与样式差异总表 - -| 模块 | 功能/样式项 | 稳定版 new-soul/soul-admin | 根目录 soul-admin | 说明 | -|------|-------------|---------------------------|-------------------|------| -| **Settings** | 审核模式 auditMode | ✅ 独立 Card + Switch | ❌ 无 | 稳定版有 | -| **Settings** | 关于页面 aboutEnabled | ✅ | ❌ 无 | 稳定版有 | -| **Settings** | 功能开关保存 | 独立 saveFeatureConfigOnly | 与站点设置一起 | 稳定版更细粒度 | -| **Settings** | API 文档 Tab | ✅ 内嵌 ApiDocsPage | 无或简单 | 稳定版有 | -| **Settings** | OSS 配置 | ✅ 完整(含 region) | ✅ 有 | 一致或稳定版更完整 | -| **Dashboard** | 代付金额 giftedTotal | ✅ 含 sub「含代付 ¥xx」 | ❌ 无 | 稳定版有 | -| **Dashboard** | 最近订单条数 | 默认 4 条,可展开至 10 条 | 固定 5 条 | 稳定版可展开 | -| **Dashboard** | 订单类型展示 | ✅ balance_recharge、gift_pay | 无 balance_recharge | 稳定版更全 | -| **Dashboard** | 埋点统计 track/stats | ✅ period=week/day | ❌ 无 | 稳定版有,依赖后端 | -| **用户编辑** | 编辑时手机号 | 禁用 | 可编辑 | 稳定版更安全 | -| **Layout** | 鉴权逻辑 | 先检查 token 再请求 | 基础 | 稳定版优化 | -| **Content** | 内容管理整体 | chapters/ranking/search/link-person/link-tag/linkedmp | 同 | 一致 | -| **根目录版独有** | 搜索功能文案 | 「首页搜索栏」 | 「首页、目录页搜索栏」 | 根目录版更完整 | -| **根目录版独有** | 用户详情余额 | ❌ 或无 | ✅ | 根目录版有 | -| **根目录版独有** | 订单支付方式/代付 | 可能简化 | ✅ 微信/余额/代付 | 根目录版更全 | -| **根目录版独有** | RechargeAlert | ❌ 或无 | ✅ | 根目录版有 | -| **根目录版独有** | LinkedMp 关联小程序 | ❌ 或无 | ✅ | 根目录版有 | - ---- - -## 二、文章内容弹窗(新建/编辑章节)— 除富文本外的差异 - -> 迁移策略:**内容管理以稳定版(new-soul/soul-admin)为基准**。以下为稳定版实现,供对比参考。 - -### 2.1 弹窗结构 - -| 项目 | 稳定版 new-soul/soul-admin | 根目录 soul-admin | 备注 | -|------|-------------------|---------------|------| -| 弹窗尺寸 | 全屏(w-screen h-screen) | 待确认 | 稳定版新建、编辑均为全屏 | -| 布局 | flex flex-col,内容区 overflow-y-auto | 待确认 | 底部按钮始终可见 | -| 关闭方式 | showCloseButton | 待确认 | - | - -### 2.2 表单字段(非富文本) - -| 字段 | 新建章节 | 编辑章节 | 说明 | -|------|:--------:|:--------:|------| -| 章节ID | ✅ | ✅ | 新建必填,编辑可改 | -| 价格 (元) | ✅ | ✅ | 免费时禁用输入 | -| 免费 | ✅ 复选框 | ✅ 复选框 | 设为免费 | -| 最新新增 | ✅ 标记 NEW | ✅ | - | -| 小程序直推 | ✅ 强制置顶首页 | ✅ | amber 色复选框 | -| 文章类型 | ✅ 普通版/增值版 | ✅ | 单选 | -| 热度分 | ✅ number | ✅ | step=0.1, min=0 | -| 章节标题 | ✅ | ✅ | - | -| 所属篇 | ✅ Select | - | 新建时选 | -| 所属章 | ✅ Select | - | 新建时选 | -| 文件路径 | - | ✅ 只读 | 编辑时若有则展示 | -| 付款记录 | - | ✅ 按钮 | 编辑时底部左侧 | - -### 2.3 富文本相关(仅列差异方向,不展开) - -| 项 | 稳定版 | 说明 | -|------|--------|------| -| 编辑器 | RichEditor (TipTap) | 支持 @人物、#标签、图片上传 | -| 人物/标签 | persons、linkTags 传入 | 输入 @ 可链接 AI 人物,工具栏可插入 # 标签 | -| 图片上传 | onImageUpload → /api/upload | folder=book-images | - -### 2.4 文章内容弹窗 — 可能存在的样式差异(待根目录版对照确认) - -| 项目 | 稳定版 new-soul/soul-admin | 根目录 soul-admin 可能差异 | -|------|--------|----------------| -| 表单 grid 布局 | grid-cols-3 gap-4 | 可能为 grid-cols-2 或不同 gap | -| 输入框样式 | bg-[#0a1628] border-gray-700 | 可能色值、圆角不同 | -| 主色 | #38bdac(青绿) | 可能主题色不同 | -| Label 样式 | text-gray-300 | 可能字重、字号不同 | -| 底部按钮顺序 | 取消 | 创建/保存 | 可能「付款记录」位置不同(仅编辑) | -| 弹窗背景 | bg-[#0f2137] | 可能背景色不同 | - -### 2.5 其他弹窗(内容管理相关) - -| 弹窗 | 稳定版 | 说明 | -|------|--------|------| -| 编辑篇名 | Dialog max-w-md | 简单表单 | -| 编辑章节名称 | Dialog | 单字段 | -| 批量移动 | Dialog | 选择目标目录 | -| 付款记录 | Dialog | 展示订单列表 | -| 文章排名算法 | Dialog | 权重配置 | -| 新建篇 | Dialog | 篇名输入 | -| 链接人与事 | PersonAddEditModal | 添加/编辑人物 | - ---- - -## 三、迁移建议(内容管理) - -| 策略 | 说明 | -|------|------| -| **以稳定版为准** | 内容管理(含文章内容弹窗)不采纳新版,保持稳定版实现 | -| **富文本** | 稳定版 RichEditor 已支持 @人物、#标签、图片上传,无需从新版迁移 | -| **表单字段** | 稳定版新建/编辑字段已对齐,若新版有缺失则勿回退 | -| **样式** | 稳定版深色主题(#0f2137、#0a1628、#38bdac)已落地,迁移时保持 | - ---- - -## 四、待根目录 soul-admin 对照时的补充项 - -当需与根目录 `soul-admin` 逐项对比时,建议补充核对: - -1. **新建章节弹窗**:字段是否完全一致(章节ID、价格、免费、最新新增、小程序直推、文章类型、热度分、所属篇/章、内容区) -2. **编辑章节弹窗**:是否多「付款记录」按钮、文件路径展示 -3. **表单校验**:必填项、数字范围是否一致 -4. **错误提示**:保存失败、加载失败时的 toast/文案是否一致 diff --git a/开发文档/新版管理端迁移到稳定版-需求评估.md b/开发文档/新版管理端迁移到稳定版-需求评估.md deleted file mode 100644 index b34873de..00000000 --- a/开发文档/新版管理端迁移到稳定版-需求评估.md +++ /dev/null @@ -1,154 +0,0 @@ -# 新版管理端迁移到稳定版 - 需求评估 - -> 乘风整理。更新日期:2026-03-17 - -**目录说明**:`new-soul/soul-admin` = **稳定版**(生产主用);`soul-admin/`(根目录)= 根目录版。迁移时以稳定版为基准,从根目录版带入缺失能力。 - ---- - -## 一、评估基准 - -| 基准 | 说明 | -|------|------| -| **稳定版小程序** | 已梳理完毕,定义 C 端能力:余额、代付、VIP、规则引擎、埋点、找伙伴、推广等 | -| **稳定版管理端** | `new-soul/soul-admin`,需支撑上述小程序的运营与管理 | -| **以界面定需求** | 管理端界面清单见《以界面定需求》§三;业务逻辑对齐见§四 | - ---- - -## 二、稳定版管理端必须保留的能力(不可丢) - -以下能力对应小程序功能,迁移时**必须保留**,新版若缺失则需从稳定版补齐。 - -| 能力 | 对应小程序 | 稳定版现状 | 迁移时动作 | -|------|------------|------------|------------| -| 用户详情 - 当前余额 | wallet、read/vip 余额支付 | ✅ 有 | **保留**,新版无则从稳定版代码带入 | -| 订单 - 支付方式(微信/余额/支付宝) | 余额购买、代付 | ✅ 有 | **保留**,新版无则从稳定版代码带入 | -| 订单 - 代付标识、代付人 | gift-pay | ✅ 有 | **保留** | -| 用户规则 CRUD | ruleEngine | ✅ 有 | **保留** | -| 超级个体/VIP 管理 | vip、member-detail | ✅ 有 | **保留** | -| 提现审核、分销、找伙伴、导师 | 对应小程序页 | ✅ 有 | **保留** | -| **内容管理(文章内容)** | chapters、read | ✅ 有 | **以稳定版为主**,不采纳新版 | -| RechargeAlert | 商户号余额不足提示 | ✅ 有 | **保留**,运营需及时感知 | -| LinkedMp(关联小程序) | 多小程序场景 | ✅ 有 | **保留**,若业务使用 | - ---- - -## 三、稳定版可选能力(依赖后端,当前 404) - -以下能力稳定版 UI 已有,但 soul-api **router 未注册**,会 404。迁移时需决策:**修后端** 或 **暂隐 UI**。 - -| 能力 | 接口 | 调用位置 | 建议 | -|------|------|----------|------| -| 用户列表 RFM 排序 | `GET /api/db/users/rfm` | UsersPage | 若运营需要 RFM 分析 → 补 router;否则迁移时可隐 | -| 用户旅程总览 | `GET /api/db/users/journey-stats` | UsersPage | 若运营需要 → 补 router;否则迁移时可隐 | -| 神射手(用户资料完善) | `GET/POST /api/admin/shensheshou/*` | UserDetailModal | 若使用神射手 → 补 router;否则迁移时可隐 | - ---- - -## 四、新版独有、稳定版可吸纳的能力 - -以下为新版有、稳定版无,迁移时**可选择性吸纳**到稳定版。 - -| 能力 | 说明 | 需求评估 | 建议 | -|------|------|----------|------| -| **OSS 配置** | 阿里云对象存储 endpoint、bucket、accessKey 等 | 新版有 → 迁移 | **吸纳**(2026-03-17 会议决议) | -| **API 文档 Tab** | 系统设置内嵌 ApiDocsPage | 新版有 → 迁移 | **吸纳** | -| **api-docs 独立页** | `/api-docs` 路由 | 新版有 → 迁移 | **吸纳** | -| **编辑时手机号禁用** | 编辑用户时手机号不可改 | 新版有 → 迁移 | **吸纳** | -| **鉴权逻辑优化** | 先检查 token 再请求 | 新版有 → 迁移 | **吸纳** | - ---- - -## 五、迁移策略(按模块) - -### 5.1 内容管理(文章内容)— 以稳定版为主 - -| 策略 | 说明 | -|------|------| -| **ContentPage** | 完全以稳定版为准,不采纳新版 | -| **章节树、内容编辑、LinkTag、Person、LinkedMp** | 稳定版实现为准 | -| **富文本、排序、预览、免费章节配置** | 稳定版为准 | - -迁移时:内容管理相关代码**不覆盖**,保持稳定版实现。 - ---- - -### 5.2 其他模块迁移策略 - -| 模块 | 策略 | 说明 | -|------|------|------| -| **用户管理** | 以稳定版为主 | 用户详情余额、RFM、旅程、规则、超级个体均保留稳定版;可吸纳新版「编辑时手机号禁用」 | -| **订单** | 以稳定版为主 | 支付方式、代付、导出格式不覆盖 | -| **推广中心** | 以稳定版为主 | 保持稳定版实现 | -| **提现** | 以稳定版为主 | 保持稳定版实现 | -| **找伙伴** | 以稳定版为主 | CKB、匹配池、导师、资源对接等保持稳定版 | -| **系统设置** | 稳定版为主 + 吸纳 | 保持稳定版结构;可吸纳新版 API 文档 Tab、OSS 配置 | -| **Layout** | 以稳定版为主 | RechargeAlert、菜单结构保留;可吸纳新版鉴权逻辑 | -| **Dashboard** | 以稳定版为主 | 保持稳定版 | -| **支付/站点/小程序码/导师/API 文档** | 以稳定版为主 | 保持稳定版;API 文档可吸纳新版 ApiDocsPage | - ---- - -### 5.3 需调整的项 - -| 项 | 调整说明 | -|----|----------| -| **后端 router** | 若保留 RFM、journey-stats、神射手,需 soul-api 补 5 个路由 | -| **OSS** | 若吸纳,需 soul-api 支持 ossConfig(/api/admin/settings 需确认) | -| **ApiDocsPage** | 新版有独立实现,可复制到稳定版并接入设置 Tab 或独立路由 | - ---- - -### 5.4 不采纳的项 - -| 项 | 说明 | -|----|------| -| 新版 ContentPage | 内容管理以稳定版为准 | -| 新版 Layout 结构差异 | 系统设置分区等保持稳定版 | -| 新版部分 UI 细节 | grid-cols、间距等以稳定版为准 | - ---- - -## 六、需求优先级与实施顺序 - -| 阶段 | 内容 | 优先级 | -|------|------|:------:| -| **1. 必须保留** | 确保迁移后稳定版不丢失:用户详情余额、订单支付方式/代付、RechargeAlert、LinkedMp | P0 | -| **2. 后端补齐** | 若保留 RFM/journey/神射手:soul-api router 注册 5 个路由 | P1 | -| **3. 吸纳优化** | 编辑时手机号禁用、鉴权逻辑、API 文档 Tab | P2 | -| **4. 按需吸纳** | OSS 配置、api-docs 独立页 | P3 | - ---- - -## 七、验收标准(迁移完成后) - -| 验收项 | 标准 | -|--------|------| -| 用户详情 | 基础信息 Tab 有「当前余额」卡,数据来自 `/api/admin/users/:id/balance` | -| 订单页 | 支付方式列含微信/余额/支付宝,代付订单展示代付人 | -| 用户规则 | 规则配置 Tab 可 CRUD,与小程序 ruleEngine 联动 | -| RechargeAlert | 余额不足等错误时顶部红条可展示 | -| 内容管理 | 章节树、文章编辑、LinkTag、Person、LinkedMp 等以稳定版为准 | -| 其他 | 提现、分销、找伙伴、设置等页面功能正常 | - ---- - -## 八、迁移策略汇总 - -| 原则 | 模块 | -|------|------| -| **以稳定版为主(不覆盖)** | 内容管理、用户管理、订单、推广、提现、找伙伴、Layout、Dashboard | -| **吸纳新版** | 编辑时手机号禁用、鉴权逻辑、API 文档 Tab、OSS 配置(按需) | -| **内容管理** | **明确以稳定版为主**,章节树、文章编辑、LinkTag、Person、LinkedMp 等均不采纳新版 | - ---- - -## 九、总结 - -| 类型 | 说明 | -|------|------| -| **必须保留** | 余额、代付、规则、VIP、RechargeAlert、LinkedMp、**内容管理** | -| **可选(依赖后端)** | RFM、journey-stats、神射手 | -| **可吸纳** | OSS、API 文档、编辑禁用、鉴权优化 | -| **结论** | 内容管理以稳定版为主;其他模块以稳定版为主,选择性吸纳新版优化;后端按需补 router。 | diff --git a/开发文档/新版迁移-功能差异清单.md b/开发文档/新版迁移-功能差异清单.md deleted file mode 100644 index 05d566e3..00000000 --- a/开发文档/新版迁移-功能差异清单.md +++ /dev/null @@ -1,185 +0,0 @@ -# 新版迁移 - 小程序功能差异清单(稳定版 vs 体验版) - -> 乘风分析:稳定版(miniprogram)与体验版(new-soul/miniprogram)的差异。 -> 更新日期:2026-03-17 - -**目录说明**:`miniprogram` = 稳定版(生产);`new-soul/miniprogram` = 体验版(新版参考) - ---- - -## 一、差异摘要(按页面/模块) - -| 页面/模块 | 稳定版 miniprogram | 体验版 new-soul/miniprogram | 迁移建议 | -|-----------|-------------------|-----------------------------|----------| -| **app.js** | 硬编码 baseUrl、无 auditMode | loadRuntimeConfig、auditMode、timeout | 迁运行时配置 | -| **index** | 无 auditMode | auditMode 控制超级个体按钮 | 迁 auditMode | -| **gift-pay/detail** | hero-card、requester-card、完整支付流程 | 简单 card | **勿回退**,稳定版更完善 | -| **read** | 无 auditMode、无 showShareTip | auditMode、personsConfig、showShareTip | 迁 auditMode | -| **my** | profile-name-actions(编辑)、referralEnabled | auditMode 控制支付 UI | **保留**稳定版编辑入口 | -| **wallet** | 无 auditMode | auditMode | 迁 auditMode | -| **chapters** | 每日新增已删除 | 每日新增区块 | 按需求 | -| **about** | ✅ | ✅ | 一致 | -| **utils** | ruleEngine | 无 | **保留**稳定版 | - ---- - -## 二、需迁移的细节(体验版有、稳定版缺) - -### 2.1 app.js - 运行时配置与审核模式 - -| 功能项 | 稳定版 | 体验版 | 迁移建议 | -|--------|--------|--------|----------| -| **baseUrl 配置** | 硬编码 localhost | getRuntimeBootstrapConfig,extConfig/Storage/默认生产 | **P0** | -| **loadRuntimeConfig** | 仅 appId/mchId 等 | 含 apiDomain、auditMode、supportWechat | **P0** | -| **globalData** | 无 auditMode | auditMode、supportWechat | **P0** | -| **request timeout** | 无 | 15000ms | **P2** | -| **loadBookData** | 已类似 | 同 | 已对齐 | - -**新版关键代码(getRuntimeBootstrapConfig):** - -```javascript -function getRuntimeBootstrapConfig() { - try { - const extCfg = wx.getExtConfigSync ? (wx.getExtConfigSync() || {}) : {} - return { - baseUrl: extCfg.apiBaseUrl || wx.getStorageSync('apiBaseUrl') || DEFAULT_BASE_URL, - appId: extCfg.appId || DEFAULT_APP_ID, - mchId: extCfg.mchId || DEFAULT_MCH_ID, - withdrawSubscribeTmplId: extCfg.withdrawSubscribeTmplId || DEFAULT_WITHDRAW_TMPL_ID - } - } catch (_) { - return { baseUrl: DEFAULT_BASE_URL, appId: DEFAULT_APP_ID, mchId: DEFAULT_MCH_ID, withdrawSubscribeTmplId: DEFAULT_WITHDRAW_TMPL_ID } - } -} -``` - -**soul-api 支持**:`GET /api/miniprogram/config` 已存在,返回 mpConfig(含 apiDomain、appId、mchId 等)。需在 mp_config 或 defaultMp 中增加 `auditMode`、`supportWechat` 字段,供管理端配置。 - ---- - -### 2.2 index 页面 - 审核模式 - -| 功能项 | 稳定版 | 体验版 | 迁移建议 | -|--------|--------|--------|----------| -| **超级个体空态按钮** | 始终显示 | 按 auditMode 隐藏 | **P1** | -| **data** | 无 auditMode | auditMode: false | - | -| **onShow** | 无 | 同步 app.globalData.auditMode | - | - ---- - -### 2.3 my 页面 - 审核模式 - -| 功能项 | 稳定版 | 体验版 | 迁移建议 | -|--------|--------|--------|----------| -| **become-member-btn** | 无 auditMode | wx:if="{{!auditMode}}" | **P1** | -| **vip-tags** | 无 | wx:if="{{!auditMode}}" | **P1** | -| **profile-stat 推荐/收益** | referralEnabled | auditMode | **保留**稳定版 referralEnabled | -| **profile-stat 余额** | 无 | wx:if="{{!auditMode}}" | **P1** | -| **receive-card** | 无 auditMode | wx:if="{{... && !auditMode}}" | **P1** | -| **profile-name-actions** | ✅ 有编辑按钮 | ❌ 无 | **勿回退** | - ---- - -### 2.4 wallet 页面 - 审核模式 - -| 功能项 | 稳定版 | 体验版 | 迁移建议 | -|--------|--------|--------|----------| -| **data** | 无 auditMode | auditMode: false | **P1** | -| **onLoad** | 无 | 同步 app.globalData.auditMode | **P1** | - ---- - -### 2.5 read 页面 - 分享功能与图标 - -| 功能项 | 稳定版 | 体验版 | 迁移建议 | -|--------|--------|--------|----------| -| **操作区分享** | 朋友圈→海报→代付 | 分享→代付→海报 | 按产品需求 | -| **share-tip-inline** | 无 | 有「分享后好友购买,你可获得 90% 收益」 | 可选 | -| **右下角悬浮按钮** | share.svg + open-type="share" | 🌐 emoji + shareToMoments | 已迁为体验版 | - ---- - -### 2.6 read 页面 - 审核模式与配置 - -| 功能项 | 稳定版 | 体验版 | 迁移建议 | -|--------|--------|--------|----------| -| **config 预加载** | linkTags、linkedMiniprograms | 含 personsConfig | **P3** | -| **data** | walletBalance、totalSections | auditMode、showShareTip | **P2** auditMode | -| **wx.showShareMenu** | menus: ['shareAppMessage','shareTimeline'] | withShareTimeline: true | 均可 | - ---- - -## 三、稳定版有、体验版无(勿回退) - -### 3.1 gift-pay/detail - -| 功能项 | 稳定版 | 体验版 | 说明 | -|--------|--------|--------|------| -| **UI 结构** | hero-card、requester-card、footer-bar、bg-effects | 简单 card | **勿回退** | -| **发起人信息** | 可点击头像跳 member-detail | 无 | **勿回退** | -| **跳转文章** | goToArticle 跳 read | 无 | **勿回退** | -| **doPay 登录** | 静默 getOpenId,失败再弹 modal | 直接 toast | **勿回退** | -| **支付失败** | 识别 prepay 错误并重试 | 简单 toast | **勿回退** | - -### 3.2 my 页面 - 编辑入口 - -| 功能项 | 稳定版 | 体验版 | 说明 | -|--------|--------|--------|------| -| **profile-name-actions** | ✅ 有编辑按钮 | ❌ 无 | **保留**稳定版 | - -### 3.3 utils - ruleEngine - -| 功能项 | 稳定版 | 体验版 | 说明 | -|--------|--------|--------|------| -| **ruleEngine** | ✅ app.js 引用 | ❌ 无 | **保留**稳定版 | - ---- - -## 四、迁移优先级建议 - -| 优先级 | 迁移项 | 稳定版→体验版 | -|--------|--------|---------------| -| **P0** | app.js 运行时配置 | 稳定版缺,体验版有 | -| **P0** | app.js loadMpConfig 扩展 | 稳定版缺 auditMode,体验版有 | -| **P0** | soul-api mp_config | 增加 auditMode、supportWechat | -| **P1** | index/my/wallet auditMode | 稳定版缺,体验版有 | -| **P2** | app.js request timeout | 稳定版缺,体验版有 | -| **P2** | read auditMode | 稳定版缺,体验版有 | -| **P3** | read personsConfig、showShareTip | 可选 | - ---- - -## 五、不迁移项(维持现状) - -| 项 | 说明 | -|----|------| -| gift-pay/detail 从新版迁 | 稳定版 UI 与逻辑更完善,无需回退 | -| 稳定版 ruleEngine | 已迁移,保留 | -| 稳定版 profile-name-actions | 保留,新版无 | - ---- - -## 六、功能闭环 Checklist(每功能必过) - -``` -□ 界面:页面、交互、数据绑定 -□ 接口:API 存在、参数正确、响应格式规范 -□ 数据:DB/事务/幂等(若涉及) -□ 边界:未登录、余额不足、网络失败 -□ 三端:小程序+后端+管理端(如需)是否都改到 -□ 保护区域:未动 @/#、分销、支付 核心逻辑 -``` - ---- - -## 七、文档产出 - -| 文档 | 路径 | -|------|------| -| **需求采纳清单** | `开发文档/新版迁移-需求采纳清单.md`(勾选是否采纳) | -| 功能差异清单 | `开发文档/新版迁移-功能差异清单.md`(本文档) | -| 迁移方案/清单 | `开发文档/新版迁移-开发方案与清单.md` | - ---- - -**迁移前必做需求评审**:列出功能点 + 样式变更,逐一确认后再迁。先做功能对齐与取舍,评审通过后按最小功能迁移;界面修改先迁、大逻辑排后。 diff --git a/开发文档/新版迁移-开发方案与清单.md b/开发文档/新版迁移-开发方案与清单.md deleted file mode 100644 index 489e171c..00000000 --- a/开发文档/新版迁移-开发方案与清单.md +++ /dev/null @@ -1,107 +0,0 @@ -# 新版迁移 - 开发方案与清单 - -> 从 new-soul 迁移到稳定版 miniprogram 的完整开发方案,整合需求、经营、技术、运营视角。 -> 更新日期:2026-03-16 - ---- - -## 一、迁移范围总览 - -| 需求 | 说明 | 优先级 | -|------|------|--------| -| R1~R4 | 余额体系:充值、消费、交易记录、退款 | P0 | -| R5 | 我的页「我的余额」入口 | P0 | -| R2 | 阅读页余额购买(章节/全书) | P0 | -| R6~R8 | 首页精选/最新展开、按热度 | P1 | -| R9~R10 | 代付(我的代付链接 + 阅读页代付分享) | P2 | -| R11 | 埋点 trackClick | P0 | -| VIP 余额 | VIP 页支持余额购买 | P1 | -| 管理端 | 订单支付方式、用户详情余额 | P0 | - ---- - -## 二、技术实现要点 - -### 2.1 余额消费必须写 orders - -同一事务内:扣 user_balances → 写 balance_transactions → 写 orders(product_type、status=paid、payment_method=balance)。否则 check-purchased、purchase-status 失效。 - -### 2.2 分销 + 余额消费 - -consume 入参增加 referralCode,创建订单时与 pay 一致解析 referrer_id、计算佣金。 - -### 2.3 充值流程 - -1. POST balance/recharge → 创建 orders(product_type=balance_recharge, status=created)→ 返回 orderSn -2. POST pay(productType=balance_recharge, productId=orderSn)→ 后端从 orders 查 amount -3. 支付成功 → 前端调 recharge/confirm;PayNotify 也触发加余额(幂等) - -### 2.4 consume 价格校验 - -后端必须用 getStandardPrice 校验 amount,禁止仅信前端。 - ---- - -## 三、实现清单(可执行) - -### soul-api - -| # | 任务 | 接口/表 | 状态 | -|---|------|---------|:----:| -| 1 | 埋点 | POST /api/miniprogram/track | ✅ | -| 2 | 余额表 | user_balances、balance_transactions | ✅ | -| 3 | 余额接口 | GET balance、GET transactions、POST recharge、POST recharge/confirm、POST refund、POST consume | ✅ | -| 4 | pay 扩展 | productType=balance_recharge,从 orders 取 amount | ✅ | -| 5 | PayNotify | balance_recharge 分支,加余额幂等 | ✅ | -| 6 | BookHot | 支持 ?limit=,最大 50 | ✅ | -| 7 | orders | 增加 payment_method 字段 | ✅ | -| 8 | 管理端 | GET /api/admin/users/:id/balance | ✅ | - -### miniprogram - -| # | 任务 | 文件 | 状态 | -|---|------|------|:----:| -| 1 | trackClick | utils/trackClick.js | ✅ | -| 2 | wallet 页 | pages/wallet/* | ✅ | -| 3 | 我的页 | 余额入口、handleMenuTap wallet、loadWalletBalance | ✅ | -| 4 | read 页 | 余额支付、walletBalance 拉取 | ✅ | -| 5 | 首页 | featuredExpanded、latestExpanded、book/hot?limit=50 | ✅ | -| 6 | VIP 页 | 余额支付分支 | ✅ | - -### soul-admin - -| # | 任务 | 说明 | 状态 | -|---|------|------|:----:| -| 1 | 订单支付方式 | balance → 余额支付 | ✅ | -| 2 | 余额订单 | 不展示退款按钮 | ✅ | -| 3 | 用户详情 | 余额 + 最近交易 | ✅ | - ---- - -## 四、开发顺序 - -``` -1. soul-api: 余额表 + 接口 + pay 扩展 + PayNotify + track + BookHot limit + payment_method -2. soul-api: 管理端用户余额接口 -3. miniprogram: trackClick + wallet + 我的页 + read 页余额 -4. miniprogram: 首页展开 + VIP 余额 -5. soul-admin: 订单展示 + 用户详情余额 -``` - ---- - -## 五、不迁移项 - -ruleEngine、user-rules、loadRuntimeConfig。avatar-nickname 保留迁移(稳定版已有,继续使用)。 - ---- - -## 六、数据库迁移 - -执行 `soul-api/scripts/add-balance-tables.sql` 创建 user_balances、balance_transactions,并为 orders 增加 payment_method 列。GORM AutoMigrate 也会自动同步。 - ---- - -## 七、实现说明(2026-03-16) - -已完成:余额体系(充值/消费/退款)、埋点、我的页余额入口、阅读页余额支付、VIP 页余额支付、管理端订单展示与用户详情余额、首页精选/最新展开、搜索页 book/hot?limit=50。代付链接:后端 GET /api/miniprogram/gift/link + gift-link 页对接。阅读页代付分享为后续迭代项。 diff --git a/开发文档/新版迁移-管理端功能差异清单.md b/开发文档/新版迁移-管理端功能差异清单.md deleted file mode 100644 index 0a702e92..00000000 --- a/开发文档/新版迁移-管理端功能差异清单.md +++ /dev/null @@ -1,129 +0,0 @@ -# 新版迁移 - 管理端功能差异清单(new-soul vs soul-admin) - -> 更新日期:2026-03-18 - -**目录说明**: -- `new-soul/soul-admin`:new-soul 版本(对照) -- `soul-admin/`:当前稳定版(根目录,线上部署) - -> **保护区(强约束)**:文章详情富文本编辑与保存解析 @/# 标签等逻辑(如 `RichEditor` 相关)**不要动**,本清单不包含对该区域的任何改造建议。 - ---- - -## 一、差异摘要(按页面/模块) - -### 1.1 页面/路由集合结论 - -- ✅ **两边页面文件集合一致**:`src/pages/**/*.tsx` 差集为 0(only_new=0、only_old=0)。 -- ✅ **路由结构一致**:`App.tsx` 两边路由项一致(dashboard/orders/users/distribution/withdrawals/content/settings 等)。 - -因此,“未迁移”主要不是缺页面,而是**同页面内部的功能点实现深度不同**。 - -### 1.2 功能点差异表(按模块) - -| 页面/模块 | new-soul/soul-admin | soul-admin | 结论(以谁为准) | -|-----------|---------------------------|-------------------|----------| -| **Settings** | aboutEnabled;无 auditMode | aboutEnabled;✅ auditMode(审核模式开关) | 以 soul-admin 为准(new-soul 可补齐) | -| **Dashboard** | ✅ giftedTotal、✅ track/stats;订单列表固定 5;formatOrderProduct 分支较少 | ✅ giftedTotal、✅ track/stats、✅ ordersExpanded(4→10)、✅ balance_recharge/gift_pay_batch 等格式化 | 以 soul-admin 为准(new-soul 可补齐) | -| **Distribution(giftPay tab)** | 有 giftPay 列表与筛选(未核对 refunded 展示) | 已补齐 refunded 筛选与徽章 | 以 soul-admin 为准 | -| **Content/Users/Orders/Withdrawals…** | 文件存在 | 文件存在 | 需按功能点逐项复核(本次优先聚焦 Settings/Dashboard) | - ---- - -## 二、Settings 页对比(结论) - -### 2.1 auditMode(小程序审核模式) - -| 项 | new-soul/soul-admin | soul-admin | 建议 | -|---|---|---|---| -| 字段与保存 | ❌ mpConfig 无 auditMode | ✅ mpConfig.auditMode + 单独保存逻辑 | new-soul 补齐到与 soul-admin 一致 | -| UI | - | ✅ 审核模式卡片/提示文案 | new-soul 复用 soul-admin 的 UI 与交互 | - -### 2.2 aboutEnabled(关于页面开关) - -两边都已有 `featureConfig.aboutEnabled` 开关与保存逻辑,差异不大。 - ---- - -## 三、Dashboard 页面对比 - -### 3.1 统计卡片(giftedTotal 子文案) - -两边都已有 giftedTotal,并在收入卡片显示「含代付 ¥xx」子文案。 - ---- - -### 3.2 最近订单(是否可展开 4→10) - -| 项 | new-soul/soul-admin | soul-admin | 建议 | -|---|---|---|---| -| 显示条数 | 固定 5 条 | ✅ 默认 4 条,可展开至 10 条 | new-soul 补齐 ordersExpanded(同 soul-admin) | -| recent-orders limit | 未传 limit 参数 | ✅ `/recent-orders?limit=10` | new-soul 对齐 limit=10 | - ---- - -### 3.3 埋点统计(track/stats) - -两边均已调用 `/api/admin/track/stats?period=...`,差异不大。 - ---- - -## 四、Dashboard 商品类型展示(formatOrderProduct) - -| 项 | new-soul/soul-admin | soul-admin | 建议 | -|---|---|---|---| -| balance_recharge | ❌ 未特殊处理 | ✅ 特殊处理为「余额充值 ¥xx」 | new-soul 补齐 | -| gift_pay_batch | ❌ 未特殊处理 | ✅ 特殊处理为「代付分享」等 | new-soul 补齐 | -| 代付领取 | 部分处理 | ✅ 处理更完整(含 desc 文案) | new-soul 参考 soul-admin 对齐 | - ---- - -## 五、迁移优先级建议(如果目标是对齐两端) - -> 注意:本仓库当前状态下,**soul-admin 的实现更完整**;若要统一体验,应把差异从 soul-admin 同步到 new-soul。 - -| 优先级 | 迁移项(soul-admin → new-soul) | 原因 | -|--------|-------------------------------|------| -| **P0** | Settings:auditMode 开关与保存 | 影响小程序审核隐藏支付入口 | -| **P1** | Dashboard:ordersExpanded(4→10)与 recent-orders limit=10 | 体验更好、信息密度更高 | -| **P1** | Dashboard:formatOrderProduct 补齐 balance_recharge/gift_pay_batch/代付领取 | 订单类型展示更准确 | - ---- - -## 六、接口与数据层检查 - -| 接口 | 稳定版 | 体验版 | soul-api 支持 | -|------|--------|--------|---------------| -| GET /api/admin/settings | ✅ | ✅ | ✅ | -| POST /api/admin/settings | ✅ mpConfig/featureConfig/siteSettings/ossConfig | ✅ mpConfig/featureConfig/siteSettings/ossConfig | ✅(camelCase) | -| GET /api/admin/track/stats | ❌ 未用 | ✅ period=week/day | 需确认 | -| GET /api/admin/dashboard/stats | ✅ | ✅ | ✅ | -| GET /api/admin/dashboard/overview | ✅ | ✅ | ✅ | - ---- - -## 七、功能闭环 Checklist(每功能必过) - -``` -□ 界面:页面、交互、数据绑定 -□ 接口:API 存在、参数正确、响应格式规范 -□ 数据:DB/配置存储(system_config 表) -□ 边界:保存失败、加载失败 -□ 三端:管理端 + soul-api(mp_config 需供小程序 config 读取) -□ 保护区域:未动分销、支付核心逻辑 -``` - ---- - -## 八、文档产出 - -| 文档 | 路径 | -|------|------| -| **需求采纳清单** | `开发文档/新版迁移-需求采纳清单.md`(勾选是否采纳) | -| 管理端功能差异清单 | `开发文档/新版迁移-管理端功能差异清单.md`(本文档) | -| 小程序功能差异清单 | `开发文档/新版迁移-功能差异清单.md` | -| 迁移完成度 | `开发文档/迁移完成度与待办清单.md` | - ---- - -**迁移前必做需求评审**:列出功能点 + 样式变更,逐一确认后再迁。 diff --git a/开发文档/新版迁移-需求采纳清单.md b/开发文档/新版迁移-需求采纳清单.md deleted file mode 100644 index 463f4208..00000000 --- a/开发文档/新版迁移-需求采纳清单.md +++ /dev/null @@ -1,61 +0,0 @@ -# 新版迁移 - 需求采纳清单 - -> 推荐迁移项汇总,供选择是否采纳。勾选 ☐ 表示采纳,☑ 表示已确认采纳。 -> 更新日期:2026-03-17 - -**标签说明**: -- **🔴 必选**:提审/生产必备,建议优先 -- **🟠 推荐**:有明显价值,建议采纳 -- **🟡 可选**:按需采纳 -- **⚪ 不迁**:明确不迁移 - -**乘风建议(2026-03-17)**:X1/X2/X7 与审核模式配套必迁;X8/X9 低成本建议采纳;M6 因 soul-api 暂无 track/stats 接口,待接口就绪后再迁;X10 保持不迁。 - ---- - -## 一、管理端(soul-admin) - -| 序号 | 功能项 | 标签 | 简要说明 | 采纳 | -|:----:|--------|------|----------|:----:| -| M1 | 小程序审核模式 | 🔴 必选 | 系统设置 → 审核模式开关,提审前隐藏支付入口 | ☑ | -| M2 | 关于页面开关 aboutEnabled | 🟠 推荐 | 功能开关第 4 项,控制关于页访问 | ☑ | -| M3 | Dashboard 代付金额 giftedTotal | 🟠 推荐 | 总收入下显示「含代付 ¥xx」 | ☑ | -| M4 | Dashboard 订单展开 | 🟠 推荐 | 默认 4 条,可展开至 10 条 | ☑ | -| M5 | 订单类型 balance_recharge | 🟡 可选 | 订单列表正确展示余额充值类型 | ☑ | -| M6 | 埋点统计 track/stats | 🟡 可选 | 依赖 /api/admin/track/stats(soul-api 暂无,待接口就绪) | ☐ | - ---- - -## 二、小程序(miniprogram) - -| 序号 | 功能项 | 标签 | 简要说明 | 采纳 | -|:----:|--------|------|----------|:----:| -| X1 | app.js 运行时配置 | 🔴 必选 | getRuntimeBootstrapConfig,避免生产用 localhost | ☑ | -| X2 | app.js loadMpConfig 扩展 | 🔴 必选 | 支持 apiDomain、auditMode、supportWechat | ☑ | -| X3 | soul-api mp_config | 🔴 必选 | 增加 auditMode、supportWechat 字段 | ☑ | -| X4 | index 超级个体按 auditMode 隐藏 | 🟠 推荐 | 审核时隐藏超级个体空态按钮 | ☑ | -| X5 | my 页支付相关按 auditMode 隐藏 | 🟠 推荐 | 会员、收益、余额、一键收款 | ☑ | -| X6 | wallet 页 auditMode | 🟠 推荐 | 审核时隐藏或提示 | ☑ | -| X7 | read 页 auditMode | 🟠 推荐 | 购买按钮等按审核隐藏 | ☑ | -| X8 | app.js request timeout | 🟡 可选 | 15s 超时,避免长时间挂起 | ☑ | -| X9 | read share-tip-inline | 🟡 可选 | 「分享后好友购买,你可获得 90% 收益」 | ☑ | -| X10 | read personsConfig、showShareTip | ⚪ 不迁 | 按需,优先级低 | ☐ | - ---- - -## 三、不迁移项(维持现状) - -| 项 | 说明 | -|----|------| -| gift-pay/detail 从体验版迁 | 稳定版 UI 与逻辑更完善 | -| 稳定版 ruleEngine | 保留 | -| 稳定版 profile-name-actions | 保留编辑入口 | -| 稳定版 referralEnabled | 保留,与 auditMode 并存 | - ---- - -## 四、采纳后执行 - -1. 将 ☐ 改为 ☑ 表示确认采纳 -2. 按标签优先级排期:🔴 → 🟠 → 🟡 -3. 迁移完成后执行 `change-checklist` 三端关联检查 diff --git a/开发文档/测试报告-文章阅读与界面预览响应速度-20260318.md b/开发文档/测试报告-文章阅读与界面预览响应速度-20260318.md deleted file mode 100644 index cc6a925d..00000000 --- a/开发文档/测试报告-文章阅读与界面预览响应速度-20260318.md +++ /dev/null @@ -1,32 +0,0 @@ -# 文章阅读与界面预览 GET 接口响应速度测试报告 - -**测试时间**: 2026-03-18 12:43 -**测试环境**: 正式 (https://soulapi.quwanzhi.com) -**每接口请求次数**: 5 - -## 一、测试范围 - -| 分类 | 接口 | 说明 | -|------|------|------| -| 界面预览 | GET /api/miniprogram/config | 配置(价格、功能开关等) | -| 界面预览 | GET /api/miniprogram/book/parts | 目录-篇章列表 | -| 界面预览 | GET /api/miniprogram/book/all-chapters | 全书章节列表 | -| 界面预览 | GET /api/miniprogram/book/chapters-by-part | 篇章内章节列表 | -| 文章阅读 | GET /api/miniprogram/book/chapter/:id | 按业务 id 获取章节内容 | -| 文章阅读 | GET /api/miniprogram/book/chapter/by-mid/:mid | 按 mid 获取章节内容 | - -## 二、响应速度结果 - -| 接口 | 状态 | 平均(ms) | 最小(ms) | 最大(ms) | -|------|------|----------|----------|----------| -| GET /api/miniprogram/config | OK | 390 | 378 | 406 | -| GET /api/miniprogram/book/parts | OK | 396 | 387 | 403 | -| GET /api/miniprogram/book/all-chapters | OK | 390 | 376 | 407 | -| GET /api/miniprogram/book/chapters-by-part?partId=part-2026-daily | OK | 420 | 416 | 424 | -| GET /api/miniprogram/book/chapter/:id | OK | 420 | 401 | 425 | -| GET /api/miniprogram/book/chapter/by-mid/:mid | OK | 424 | 419 | 431 | - -## 三、汇总 - -- 通过: 6/6 -- 全部接口平均响应: 406ms diff --git a/开发文档/稳定版-小程序与API对比.md b/开发文档/稳定版-小程序与API对比.md deleted file mode 100644 index 627b5035..00000000 --- a/开发文档/稳定版-小程序与API对比.md +++ /dev/null @@ -1,269 +0,0 @@ -# 稳定版 vs 新版 · 小程序与 API 对比清单 - -> 稳定版:`miniprogram/`;新版:`new-soul/miniprogram/` -> 生成日期:2026-03-16 - ---- - -## 一、页面差异 - -| 页面 | 稳定版 | 新版 | 说明 | -|------|:-----:|:----:|------| -| pages/avatar-nickname | ✓ | ✗ | 新版移除,可能合并到 profile-edit | -| pages/wallet | ✗ | ✓ | **新版新增**:钱包(余额、充值、退款、交易记录) | -| 其它 22 页 | ✓ | ✓ | 一致 | - ---- - -## 二、小程序页面清单(稳定版) - -| 页面路径 | 功能 | Tab | -|---------|------|-----| -| pages/index/index | 首页 | ✓ | -| pages/chapters/chapters | 目录 | ✓ | -| pages/match/match | 找伙伴 | ✓ | -| pages/my/my | 我的 | ✓ | -| pages/read/read | 文章阅读 | - | -| pages/link-preview/link-preview | 链接预览 | - | -| pages/about/about | 关于作者 | - | -| pages/agreement/agreement | 用户协议 | - | -| pages/privacy/privacy | 隐私政策 | - | -| pages/referral/referral | 推广中心 | - | -| pages/purchases/purchases | 我的订单 | - | -| pages/settings/settings | 设置 | - | -| pages/search/search | 搜索 | - | -| pages/addresses/addresses | 收货地址列表 | - | -| pages/addresses/edit | 地址编辑 | - | -| pages/withdraw-records/withdraw-records | 提现记录 | - | -| pages/vip/vip | VIP 购买 | - | -| pages/member-detail/member-detail | 会员/用户详情 | - | -| pages/mentors/mentors | 导师列表 | - | -| pages/mentor-detail/mentor-detail | 导师详情 | - | -| pages/profile-show/profile-show | 资料展示 | - | -| pages/profile-edit/profile-edit | 资料编辑 | - | -| pages/avatar-nickname/avatar-nickname | 头像昵称 | - | - ---- - -## 三、小程序调用的 API 清单(稳定版,按模块) - -### 3.1 配置与登录 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/config | GET | app.js, my.js, read.js, chapterAccessManager.js, custom-tab-bar | 公开配置(persons、linkTags、freeChapters 等) | -| /api/miniprogram/login | POST | app.js | 微信 code 登录 | -| /api/miniprogram/phone-login | POST | app.js | 手机号一键登录 | -| /api/miniprogram/phone | POST | index.js, settings.js | 获取手机号 | -| /api/miniprogram/dev/login-as | POST | settings.js | 开发专用:按 userId 切换账号 | - -### 3.2 书籍/章节 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/book/all-chapters | GET | app.js, index.js, read.js | 全量章节树 | -| /api/miniprogram/book/parts | GET | chapters.js | 篇章列表(懒加载) | -| /api/miniprogram/book/chapters-by-part | GET | chapters.js | 按篇章返回章节 | -| /api/miniprogram/book/chapter/:id | GET | read.js | 按 id 获取章节 | -| /api/miniprogram/book/chapter/by-mid/:mid | GET | read.js | 按 mid 解析章节 | -| /api/miniprogram/book/hot | GET | search.js | 热门排行 | -| /api/miniprogram/book/recommended | GET | index.js | 推荐章节 | -| /api/miniprogram/book/latest-chapters | GET | index.js | 最新章节 | -| /api/miniprogram/book/search | GET | search.js | 搜索 | -| /api/miniprogram/book/stats | GET | about.js | 书籍统计 | - -### 3.3 用户/资料 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/user/profile | GET/POST | profile-show, profile-edit, member-detail, index, read, match, my, settings, avatar-nickname | 用户资料 | -| /api/miniprogram/user/update | POST | my.js, settings.js | 更新用户(头像、昵称等) | -| /api/miniprogram/user/purchase-status | GET | read.js, chapterAccessManager.js | 购买状态(VIP/买断/单章) | -| /api/miniprogram/user/check-purchased | GET | chapterAccessManager.js | 校验是否已购买 | -| /api/miniprogram/user/dashboard-stats | GET | my.js | 阅读统计(我的页) | -| /api/miniprogram/user/reading-progress | GET/POST | readingTracker.js | 阅读进度 | -| /api/miniprogram/user/addresses | GET/POST | addresses.js, addresses/edit.js | 收货地址 CRUD | -| /api/miniprogram/user/addresses/:id | GET/PUT/DELETE | addresses.js, addresses/edit.js | 单条地址 | - -### 3.4 VIP - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/vip/status | GET | vip.js, chapters.js, my.js, profile-edit | VIP 状态 | -| /api/miniprogram/vip/members | GET | index.js, member-detail.js | VIP 会员列表/单个 | -| /api/miniprogram/vip/profile | GET/POST | (未直接调用,vip 组有) | VIP 资料 | - -### 3.5 支付与订单 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/pay | GET/POST | read.js, vip.js, match.js | 创建订单/查询 | -| /api/miniprogram/orders | GET | purchases.js | 订单列表 | -| /api/miniprogram/qrcode | POST | read.js, referral.js | 生成小程序码 | - -### 3.6 分销/推广 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/referral/visit | POST | app.js | 访问记录 | -| /api/miniprogram/referral/bind | POST | app.js | 绑定推广关系 | -| /api/miniprogram/referral/data | GET | referral.js | 推广数据 | -| /api/miniprogram/earnings | GET | my.js | 我的收益 | -| /api/miniprogram/withdraw | POST | my.js, referral.js | 申请提现 | -| /api/miniprogram/withdraw/records | GET | withdraw-records.js | 提现记录 | -| /api/miniprogram/withdraw/pending-confirm | GET | my.js | 待确认收款 | -| /api/miniprogram/withdraw/confirm-received | POST | my.js | 确认收款 | -| /api/miniprogram/withdraw/confirm-info | GET | my.js, withdraw-records.js | 领取零钱参数 | - -### 3.7 存客宝(CKB) - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/ckb/index-lead | POST | index.js | 首页「链接卡若」留资 | -| /api/miniprogram/ckb/lead | POST | read.js | 文章 @某人 留资 | -| /api/miniprogram/ckb/match | POST | match.js | 找伙伴留资 | -| /api/miniprogram/ckb/join | POST | match.js | 加入匹配池 | - -### 3.8 找伙伴 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/match/config | GET | match.js | 找伙伴配置 | -| /api/miniprogram/match/users | POST | match.js | 匹配用户 | - -### 3.9 导师 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/mentors | GET | mentors.js | 导师列表 | -| /api/miniprogram/mentors/:id | GET | mentor-detail.js | 导师详情 | -| /api/miniprogram/mentors/:id/book | POST | mentor-detail.js | 预约导师 | - -### 3.10 其它 - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/upload | POST | my.js, profile-edit, settings, avatar-nickname | 图片上传 | -| /api/miniprogram/users | GET | index.js, member-detail.js | 用户列表/单个(超级个体、回退) | -| /api/miniprogram/about/author | GET | about.js | 关于作者配置 | - ---- - -## 四、soul-api 已注册的 miniprogram 路由(稳定版) - -| 路由 | 方法 | Handler | -|------|------|---------| -| /api/miniprogram/config | GET | GetPublicDBConfig | -| /api/miniprogram/login | POST | MiniprogramLogin | -| /api/miniprogram/phone-login | POST | WechatPhoneLogin | -| /api/miniprogram/dev/login-as | POST | MiniprogramDevLoginAs | -| /api/miniprogram/phone | POST | MiniprogramPhone | -| /api/miniprogram/pay | GET/POST | MiniprogramPay | -| /api/miniprogram/pay/notify | POST | MiniprogramPayNotify | -| /api/miniprogram/qrcode | POST | MiniprogramQrcode | -| /api/miniprogram/qrcode/image | GET | MiniprogramQrcodeImage | -| /api/miniprogram/book/all-chapters | GET | BookAllChapters | -| /api/miniprogram/book/parts | GET | BookParts | -| /api/miniprogram/book/chapters-by-part | GET | BookChaptersByPart | -| /api/miniprogram/book/chapter/:id | GET | BookChapterByID | -| /api/miniprogram/book/chapter/by-mid/:mid | GET | BookChapterByMID | -| /api/miniprogram/book/hot | GET | BookHot | -| /api/miniprogram/book/recommended | GET | BookRecommended | -| /api/miniprogram/book/latest-chapters | GET | BookLatestChapters | -| /api/miniprogram/book/search | GET | BookSearch | -| /api/miniprogram/book/stats | GET | BookStats | -| /api/miniprogram/referral/visit | POST | ReferralVisit | -| /api/miniprogram/referral/bind | POST | ReferralBind | -| /api/miniprogram/referral/data | GET | ReferralData | -| /api/miniprogram/earnings | GET | MyEarnings | -| /api/miniprogram/match/config | GET | MatchConfigGet | -| /api/miniprogram/match/users | POST | MatchUsers | -| /api/miniprogram/ckb/join | POST | CKBJoin | -| /api/miniprogram/ckb/match | POST | CKBMatch | -| /api/miniprogram/ckb/lead | POST | CKBLead | -| /api/miniprogram/ckb/index-lead | POST | CKBIndexLead | -| /api/miniprogram/upload | POST/DELETE | UploadPost / UploadDelete | -| /api/miniprogram/user/addresses | GET/POST | UserAddressesGet/Post | -| /api/miniprogram/user/addresses/:id | GET/PUT/DELETE | UserAddressesByID | -| /api/miniprogram/user/check-purchased | GET | UserCheckPurchased | -| /api/miniprogram/user/dashboard-stats | GET | UserDashboardStats | -| /api/miniprogram/user/profile | GET/POST | UserProfileGet/Post | -| /api/miniprogram/user/purchase-status | GET | UserPurchaseStatus | -| /api/miniprogram/user/reading-progress | GET/POST | UserReadingProgressGet/Post | -| /api/miniprogram/user/update | POST | UserUpdate | -| /api/miniprogram/withdraw | POST | WithdrawPost | -| /api/miniprogram/withdraw/records | GET | WithdrawRecords | -| /api/miniprogram/withdraw/pending-confirm | GET | WithdrawPendingConfirm | -| /api/miniprogram/withdraw/confirm-received | POST | WithdrawConfirmReceived | -| /api/miniprogram/withdraw/confirm-info | GET | WithdrawConfirmInfo | -| /api/miniprogram/vip/status | GET | VipStatus | -| /api/miniprogram/vip/profile | GET/POST | VipProfileGet/Post | -| /api/miniprogram/vip/members | GET | VipMembers | -| /api/miniprogram/users | GET | MiniprogramUsers | -| /api/miniprogram/orders | GET | MiniprogramOrders | -| /api/miniprogram/mentors | GET | MiniprogramMentorsList | -| /api/miniprogram/mentors/:id | GET | MiniprogramMentorsDetail | -| /api/miniprogram/mentors/:id/book | POST | MiniprogramMentorsBook | -| /api/miniprogram/about/author | GET | MiniprogramAboutAuthor | - ---- - -## 五、对齐情况 - -| 状态 | 说明 | -|------|------| -| ✓ 已对齐 | 小程序调用的所有 `/api/miniprogram/*` 接口均在 soul-api router 中注册 | -| - | 小程序未调用 `/api/miniprogram/vip/profile`,但后端已提供(备用) | - ---- - -## 六、新版(new-soul)新增 API(稳定版 soul-api 暂无) - -| 接口 | 方法 | 调用位置 | 用途 | -|------|------|----------|------| -| /api/miniprogram/balance | GET | wallet.js | 查询余额、累计充值/赠送/退款 | -| /api/miniprogram/balance/transactions | GET | wallet.js | 交易记录列表 | -| /api/miniprogram/balance/recharge | POST | wallet.js | 创建充值订单 | -| /api/miniprogram/balance/recharge/confirm | POST | wallet.js | 支付成功后确认充值 | -| /api/miniprogram/balance/refund | POST | wallet.js | 余额退款 | -| /api/miniprogram/user-rules | GET | ruleEngine.js | 规则引擎:按场景触发引导 | -| /api/miniprogram/track | POST | trackClick.js, ruleEngine.js | 埋点上报 | - -**说明**:新版 wallet 页的支付流程为:`balance/recharge` → `pay`(productType: 'balance_recharge')→ `balance/recharge/confirm`。稳定版 soul-api 需新增上述路由才能支持新版钱包功能。 - ---- - -## 七、新版新增能力(稳定版无) - -| 能力 | 说明 | -|------|------| -| **规则引擎** | `utils/ruleEngine.js` + `/api/miniprogram/user-rules`,按 page_show、after_login 等场景触发引导 | -| **埋点上报** | `utils/trackClick.js` + `/api/miniprogram/track` | -| **运行配置** | `loadRuntimeConfig()` 从 config 取 `mpConfig.apiDomain` 等,支持动态覆盖 baseUrl | -| **单页模式** | `ensureFullAppForAuth()` 检测朋友圈单页,引导用户「前往小程序」 | -| **更新检测** | `checkUpdate()` 基于 wx.getUpdateManager | -| **navigateToMiniProgramAppIdList** | 新版 app.json 配置 `wx6489c26045912fe1`、`wx3d15ed02e98b04e3` | -| **我的页** | 新版有 `loadWalletBalance`、`loadGiftList`(代付链接) | - ---- - -## 八、config 返回格式差异 - -| 字段 | 稳定版 | 新版 | -|------|--------|------| -| 主结构 | persons、linkTags、freeChapters、prices 等 | 同上 + `mpConfig`、`features` | -| mpConfig | - | apiDomain、appId、mchId、withdrawSubscribeTmplId | -| features | - | matchEnabled 等 | -| configs.feature_config | - | 备用格式,含 matchEnabled | - ---- - -## 九、迁移建议 - -1. **后端**:soul-api 需新增 balance、user-rules、track 相关路由,才能完整支持新版。 -2. **稳定版→新版**:若稳定版要升级,需补充 wallet 页、ruleEngine、trackClick,并调整 config 返回格式。 -3. **新版→稳定版**:若新版要回退,需移除 wallet、user-rules、track 依赖,或在后端做空实现。 - ---- - -*文档由助理橙子生成 | 基于 miniprogram/、new-soul/miniprogram/ 与 soul-api/internal/router/router.go 扫描* diff --git a/开发文档/稳定版-源码质量分析报告.md b/开发文档/稳定版-源码质量分析报告.md deleted file mode 100644 index dbae73cb..00000000 --- a/开发文档/稳定版-源码质量分析报告.md +++ /dev/null @@ -1,175 +0,0 @@ -# Soul 创业派对稳定版 - 源码质量分析报告 - -> 分析时间:2026-03-17 -> 分析人:乘风(老板分身) - ---- - -## 一、高优先级(建议优先处理) - -### 1. soul-api:敏感配置默认值泄露 - -**位置**:`soul-api/internal/config/config.go` 第 174–237 行 - -**问题**:AppSecret、MchKey、APIv3Key、adminPassword、adminSessionSecret、证书序列号等敏感信息有硬编码默认值。若 `.env` 未配置,将使用这些默认值,存在泄露与撞库风险。 - -**建议**: -- 生产环境强制从环境变量读取,缺则 `log.Fatal` 启动失败 -- 或使用占位符如 `"MUST_SET_IN_ENV"`,启动时校验并拒绝 - ---- - -### 2. soul-api:`/api/user/track` 无鉴权 - -**位置**:`soul-api/internal/router/router.go` 第 260–261 行;`soul-api/internal/handler/user.go` 第 535 行 - -**问题**:`GET /api/user/track?userId=xxx` 无 AdminAuth,任何人可查任意用户行为轨迹。管理端 `UserDetailModal` 调用此接口展示用户行为。 - -**建议**: -- 将接口迁至 `/api/admin/user/track` 或 `/api/db/user/track`,并加 `AdminAuth()` 中间件 -- 或保留路径,在 handler 内校验管理员 token - ---- - -### 3. miniprogram:`payment.js` 使用未定义变量 - -**位置**:`miniprogram/utils/payment.js` 第 25 行 - -**问题**:使用 `app.globalData.apiBase`,而 app 中仅有 `baseUrl`,会导致 `undefined + '/payment/create'`,请求失败。 - -**说明**:当前支付流程在 `read.js` 中直接调用 `/api/miniprogram/pay`,未使用 `payment.js`,该文件疑似废弃。若确认废弃,建议删除;若保留,需改为 `baseUrl` 并统一走 miniprogram 支付接口。 - ---- - -## 二、中优先级 - -### 4. miniprogram:`goToMatch()` 重复定义 - -**位置**:`miniprogram/pages/my/my.js` 第 801、816 行 - -**问题**:两个完全相同的 `goToMatch()`,后者覆盖前者,易造成维护困惑。 - -**建议**:删除其中一个。 - ---- - -### 5. miniprogram:敏感信息硬编码 - -**位置**:`miniprogram/app.js` 第 18–25 行 - -**问题**:appId、mchId、withdrawSubscribeTmplId 写死在代码中,与后端 config 重复。 - -**建议**:优先从 `/api/miniprogram/config` 的 `mpConfig` 读取,代码中仅保留开发兜底。 - ---- - -### 6. miniprogram:开发接口暴露 - -**位置**:`miniprogram/pages/settings/settings.js` 第 416 行 - -**问题**:`dev/login-as` 在开发/体验版可见,生产需确保后端关闭或鉴权。 - -**建议**:后端对该接口做环境或 IP 白名单限制。 - ---- - -### 7. soul-admin:RichEditor innerHTML 潜在 XSS - -**位置**:`soul-admin/src/components/RichEditor.tsx` 第 177 行 - -**问题**:`popup.innerHTML = items.map(...)` 直接拼接 `item.name`、`item.label`,若含 HTML 可能 XSS。 - -**建议**:对 `name`、`label` 做 HTML 转义,或使用 `textContent` 渲染。 - ---- - -### 8. miniprogram:`totalSections: 62` 多处硬编码 - -**位置**:`app.js`、`index.js`、`my.js`、`chapters.js` 等 - -**问题**:章节总数写死为 62,与真实数据可能不一致。 - -**建议**:从 `book/stats` 或 `all-chapters` 动态获取,或统一从 config 读取。 - ---- - -### 9. miniprogram:废弃/备份文件 - -**位置**: -- `miniprogram/pages/read/read.js.backup` -- `miniprogram/pages/referral/referral.wxss.backup` - -**问题**:备份文件混入源码,增加噪音。 - -**建议**:若无需保留,可删除或移出版本库。 - ---- - -### 10. soul-admin:`/api/user/track` 三端边界 - -**位置**:`soul-admin/src/components/modules/user/UserDetailModal.tsx` 第 192 行 - -**问题**:管理端调用 `/api/user/track`(非 admin/db 路径),与「管理端只调 admin/db」约定不符。 - -**建议**:后端将 track 查询迁至 `/api/admin/user/track` 或 `/api/db/user/track`,管理端同步改路径。 - ---- - -## 三、低优先级 - -### 11. soul-api:`DBUsersList` 函数过长 - -**位置**:`soul-api/internal/handler/db.go` - -**建议**:拆分为统计、过滤、分页等子函数,提升可读性。 - ---- - -### 12. soul-api:`AdminWithdrawTest` 默认值 - -**位置**:`soul-api/internal/handler/withdraw.go` 第 137–138 行 - -**问题**:测试接口默认 userId、amount 写死,易误用。 - -**建议**:仅开发环境启用,或强制从请求体传入。 - ---- - -### 13. miniprogram:错误处理不统一 - -**问题**:部分 `app.request` 用 `try/catch` 并提示用户,部分 `catch (e) {}` 静默吞错。 - -**建议**:统一约定:用户可见操作需提示,静默请求可吞错但需 `console.warn`。 - ---- - -### 14. soul-admin:上传逻辑重复 - -**位置**:`ContentPage.tsx`、`MentorsPage.tsx` 等 - -**建议**:抽取公共 `uploadFile(apiUrl, file)` 方法复用。 - ---- - -### 15. 性能:config / book 请求缓存 - -**问题**:`/api/miniprogram/config`、`book/all-chapters` 等频繁请求,无本地缓存。 - -**建议**:对 config 做短期缓存(如 5 分钟),减少重复请求。 - ---- - -## 四、已确认无问题 - -- **三端路由边界**:小程序统一走 `/api/miniprogram/*`,管理端走 `/api/admin/*`、`/api/db/*`,主体符合约定 -- **支付流程**:`read.js` 正确使用 `/api/miniprogram/pay`,未依赖有问题的 `payment.js` -- **read.js.backup**:未在业务中引用,可安全清理 - ---- - -## 五、建议处理顺序 - -1. **立即**:soul-api 敏感默认值、`/api/user/track` 鉴权 -2. **短期**:`payment.js` 废弃或修复、`goToMatch` 去重、`totalSections` 动态化 -3. **中期**:管理端 track 路径迁移、RichEditor XSS 修复、配置与缓存优化 -4. **长期**:代码结构优化、备份文件清理、错误处理统一 diff --git a/开发文档/稳定版-管理端与小程序对接分析.md b/开发文档/稳定版-管理端与小程序对接分析.md deleted file mode 100644 index c19fe33f..00000000 --- a/开发文档/稳定版-管理端与小程序对接分析.md +++ /dev/null @@ -1,123 +0,0 @@ -# 稳定版:管理端与小程序功能对接分析 - -> 分析时间:2026-03-17 -> 分析人:乘风(老板分身) -> 更新:2026-03-17 已完成 referralEnabled、searchEnabled 对接,删除 aboutEnabled 及关于作者页 - -## 一、结论概览 - -| 类型 | 数量 | 说明 | -|-----|------|------| -| ✅ 已对接 | 3 | matchEnabled、referralEnabled、searchEnabled | -| 🗑️ 已删除 | 1 | aboutEnabled、关于作者页 | -| ⚠️ 需确认 | 1 | site_settings 与 chapter_config 价格同步 | - ---- - -## 二、功能开关(feature_config)对接情况 - -### 管理端配置项(SettingsPage 系统设置) - -| 开关 | 管理端 | 后端 config 返回 | 小程序使用 | -|-----|--------|------------------|------------| -| **matchEnabled** | ✅ 有 | ✅ features.matchEnabled | ✅ **已用**:custom-tab-bar 控制找伙伴 tab;my 页根据此隐藏/显示找伙伴入口 | -| **referralEnabled** | ✅ 有 | ✅ features.referralEnabled | ✅ **已用**:my 页推荐好友/我的收益入口 `wx:if`;goToReferral 二次校验 | -| **searchEnabled** | ✅ 有 | ✅ features.searchEnabled | ✅ **已用**:首页搜索栏、目录页搜索按钮 `wx:if` | -| ~~aboutEnabled~~ | 🗑️ 已删除 | - | 关于作者页已移除 | - -### 小程序实际使用(对接后) - -- **custom-tab-bar**:读取 `matchEnabled`,控制找伙伴 tab -- **my.js**:`loadFeatureConfig()` 取 matchEnabled、referralEnabled、searchEnabled,存 globalData.features -- **my.wxml**:推荐好友/我的收益 `wx:if="{{referralEnabled}}"`;已删除关于作者菜单 -- **index**:`loadFeatureConfig()` 取 searchEnabled;搜索栏 `wx:if="{{searchEnabled}}"` -- **chapters**:`loadFeatureConfig()` 取 searchEnabled;搜索按钮 `wx:if="{{searchEnabled}}"` - ---- - -## 三、其他配置对接情况 - -### 已对接 - -| 配置项 | 来源 | 小程序使用位置 | -|--------|------|----------------| -| prices (section/fullbook) | chapter_config | read.js 展示价格、chapterAccessManager | -| userDiscount | referral_config | referral 页展示好友优惠 | -| linkTags | link_tag 表 | read.js onLinkTagTap | -| linkedMiniprograms | system_config | read.js 跳转关联小程序 | -| mpConfig | mp_config | 支付、提现等 | - -### 需确认 - -| 配置项 | 说明 | -|--------|------| -| site_settings (sectionPrice, baseBookPrice) | 管理端保存到 `site_settings`,小程序 config 的 prices 来自 `chapter_config`。需确认两处是否同步,或是否有单独维护 chapter_config 的流程。 | - ---- - -## 四、建议改造(补齐未用开关) - -### 1. 推广开关 referralEnabled - -**影响入口**:我的页「推荐好友」「我的收益」统计、goToReferral 跳转 - -**改造建议**: -- my.js:`loadFeatureConfig()` 增加 `referralEnabled` -- my.wxml:`profile-stat`(推荐好友、我的收益)加 `wx:if="{{referralEnabled}}"` -- 若有单独推广入口(如菜单项),也加 `wx:if="{{referralEnabled}}"` - -### 2. 搜索开关 searchEnabled - -**影响入口**:首页搜索栏、目录页搜索按钮 - -**改造建议**: -- app.js 或各页:从 config 拉取 `searchEnabled` 存 globalData -- index.wxml:搜索栏加 `wx:if="{{searchEnabled}}"` -- chapters.wxml:搜索按钮加 `wx:if="{{searchEnabled}}"` - -### 3. 关于作者开关 aboutEnabled - -**影响入口**:我的页「关于作者」菜单项 - -**改造建议**: -- my.js:`loadFeatureConfig()` 增加 `aboutEnabled` -- my.wxml:关于作者 menu-item 加 `wx:if="{{aboutEnabled}}"` - ---- - -## 五、数据流说明 - -``` -管理端 SettingsPage - → POST /api/admin/settings { featureConfig } - → 写入 system_config.feature_config - -小程序 - → GET /api/miniprogram/config - → GetPublicDBConfig 读取 feature_config,合并到 features - → 返回 { features: { matchEnabled, referralEnabled, searchEnabled, aboutEnabled } } - -当前:仅 matchEnabled 被小程序使用 -``` - ---- - -## 六、附录:config 接口返回结构(GetPublicDBConfig) - -```json -{ - "success": true, - "prices": { "section": 1, "fullbook": 9.9 }, - "features": { - "matchEnabled": true, - "referralEnabled": true, - "searchEnabled": true, - "aboutEnabled": true - }, - "mpConfig": { "appId", "apiDomain", "buyerDiscount", ... }, - "userDiscount": 5, - "linkTags": [...], - "linkedMiniprograms": [...], - "configs": { "chapter_config", "feature_config", "mp_config" } -} -``` diff --git a/开发文档/稳定版适配新界面-调整清单.md b/开发文档/稳定版适配新界面-调整清单.md deleted file mode 100644 index df34733d..00000000 --- a/开发文档/稳定版适配新界面-调整清单.md +++ /dev/null @@ -1,87 +0,0 @@ -# 稳定版适配新界面 - 调整清单 - -> 基于 stitch_soul 设计稿与迁移方案,梳理稳定版 miniprogram 需调整项及完成路径。 -> 更新日期:2026-03-16 - ---- - -## 一、设计稿与当前状态对照 - -| 设计稿 | 页面 | 当前状态 | 待调整 | -|--------|------|----------|--------| -| optimized_home_content_feed_v1 | 首页 | 品牌+搜索、最新更新、**阅读进度**、超级个体、精选推荐、最新新增、展开折叠 | ✅ | -| catalog_with_new_additions_v1 | 目录 | 篇章折叠、章节列表 | 基本对齐 | -| premium_membership_landing_v1 | VIP | 权益卡片、¥1980 按钮 | 基本对齐 | -| professional_profile_with_earnings_vip | 我的 | VIP 徽章、收益、阅读统计、最近阅读、订单、代付链接、**编辑→profile-show** | ✅ | -| enhanced_professional_profile | 个人资料展示 | profile-show、member-detail | 基本对齐 | -| comprehensive_profile_editor_v1_2 | 手机/微弹窗 | 提现/找伙伴时弹窗 | 已实现 | - ---- - -## 二、需完成的调整项(按优先级) - -### P1:首页补充「阅读进度」✅ - -**设计稿要求**:最新更新 → **阅读进度** → 超级个体 → 精选推荐 → 最新新增 - -**已完成**:在「最新更新」与「超级个体」之间插入阅读进度卡,已登录时显示,点击跳转目录。 - ---- - -### P2:我的页增加「编辑」入口 ✅ - -**设计稿要求**:我的页头像资料卡片增加「编辑」图标,点击进入**个人资料展示页**(profile-show) - -**已完成**:在 profile-name-row 增加「编辑」按钮,点击进入 profile-show,展示页内可再进 profile-edit。 - ---- - -### P3:代付功能闭环 ✅ - -**已完成**: -1. **后端**:`GET /api/miniprogram/gift/link?userId=` 返回 path、ref、scene -2. **小程序**:gift-link 页 loadGiftLink 对接真实 API - -**已完成**: -3. **阅读页**:分享操作区「代付分享」按钮 + 付费墙「找好友代付」+ 代付分享弹窗(复制链接/分享给好友,path 带 gift=1) - ---- - -### P4:目录页与设计稿对齐(可选) - -**设计稿**:免费/NEW/¥1 标签、找伙伴图标高亮 - -**当前**:chapters 页已有篇章折叠,标签与找伙伴状态需核对 - ---- - -## 三、保护区域(调整时勿动) - -| 模块 | 文件 | 说明 | -|------|------|------| -| @/# 标签 | contentParser.js、read.js、read.wxml | mention、linkTag 解析与点击 | -| 分销 | app.js、read.js、vip.js、match.js、referral/* | referralCode、bind、visit | -| 支付 | read.js、vip.js、wallet.js | pay、consume、balance | - ---- - -## 四、建议执行顺序 - -``` -1. 首页补充阅读进度(P1,仅改 index,不动支付/分销) -2. 我的页编辑入口(P2,仅改 my.wxml + 跳转逻辑) -3. 代付后端接口 + gift-link 对接(P3) -4. 阅读页代付分享(P3,可选) -``` - ---- - -## 五、已完成(无需再改) - -- 代付链接:后端 gift/link 接口 + gift-link 对接 + 阅读页代付分享入口 -- navigateToMiniProgramAppIdList 配置 -- 余额体系、埋点、wallet、VIP 余额支付 -- 首页精选/最新展开、搜索 book/hot?limit=50 -- 我的页余额入口、代付链接入口(界面) -- 管理端订单、用户详情余额 -- 超级个体、精选推荐、最新新增布局 diff --git a/开发文档/管理端两版界面差异-新需求参考.md b/开发文档/管理端两版界面差异-新需求参考.md deleted file mode 100644 index a759c3fc..00000000 --- a/开发文档/管理端两版界面差异-新需求参考.md +++ /dev/null @@ -1,37 +0,0 @@ -# 管理端两版界面差异(新需求参考) - -> 更新日期:2026-03-17 - -**目录说明**:`new-soul/soul-admin` = **稳定版**(生产主用);`soul-admin/`(根目录)= 根目录版 - ---- - -## 一、稳定版(new-soul)有、根目录版无(以稳定版为准) - -| 页面/组件 | 界面差异 | 说明 | -|-----------|----------|------| -| **系统设置** | 审核模式 auditMode、aboutEnabled、API 文档 Tab、OSS 完整 | 稳定版更全 | -| **Dashboard** | 代付金额 giftedTotal、订单可展开 4→10、埋点统计 | 稳定版有 | -| **用户编辑** | 编辑时手机号禁用 | 稳定版更安全 | -| **Layout** | 鉴权逻辑优化 | 稳定版优化 | - ---- - -## 二、根目录版有、稳定版无(迁移时需保留) - -迁移时若以稳定版为基准合并,以下能力需从根目录版**带入**,不可丢失。 - -| 页面/组件 | 界面差异 | 说明 | -|-----------|----------|------| -| **用户详情** | 基础信息 Tab 有「当前余额」卡片 | 对应小程序 wallet、余额支付 | -| **订单页** | 支付方式(微信/余额/支付宝)、代付标识、代付人 | 对应小程序 gift-pay、余额购买 | -| **用户列表** | RFM 排序模式、RFM 分值列 | 运营分析用(依赖后端 users/rfm) | -| **用户列表** | 用户旅程总览 Tab | 依赖后端 users/journey-stats | -| **内容管理** | 关联小程序管理(LinkedMpPage) | 多小程序场景 | -| **全局** | RechargeAlert 充值告警条 | 商户号余额不足提示 | - ---- - -## 三、与需求评估的关系 - -详见《新版管理端迁移到稳定版-需求评估.md》。迁移时以**稳定版(new-soul/soul-admin)为基准**,从根目录版带入用户余额、订单支付方式、RechargeAlert、LinkedMp 等能力。 diff --git a/开发文档/管理端迁移分析-基于小程序功能.md b/开发文档/管理端迁移分析-基于小程序功能.md deleted file mode 100644 index 985b02d2..00000000 --- a/开发文档/管理端迁移分析-基于小程序功能.md +++ /dev/null @@ -1,89 +0,0 @@ -# 管理端迁移分析:基于现有小程序功能 - -> 乘风整理。以 miniprogram 当前功能为基准,分析稳定版与新版管理端的差异及迁移建议。 -> 更新日期:2026-03-17 - ---- - -## 一、背景与范围 - -| 项目 | 路径 | 说明 | -|------|------|------| -| **稳定版管理端** | `new-soul/soul-admin/` | 生产主用 | -| **根目录版** | `soul-admin/` | 迁移对照 | -| **分析基准** | miniprogram 当前页面与接口(app.json、以界面定需求.md) | - -**迁移方向**:新版 → 稳定版。分析目标:**以稳定版真实需求为基准,评估新版迁移时的保留项与吸纳项**。详见《新版管理端迁移到稳定版-需求评估.md》。 - ---- - -## 二、稳定版 vs 新版 差异对比 - -| 能力 | 稳定版 soul-admin | 新版 new-soul/soul-admin | -|------|-------------------|---------------------------| -| **用户详情-余额** | ✅ 有 balanceData、余额 Tab、`GET /api/admin/users/:id/balance` | ❌ 无余额展示 | -| **订单-支付方式** | ✅ 展示 wechat/balance/alipay、代付人 payerNickname | ❌ 仅 wechat/alipay,无 balance、无代付 | -| **用户规则** | ✅ 规则配置 Tab、user-rules CRUD | ✅ 已有 | -| **超级个体/VIP** | ✅ 有 | ✅ 有 | -| **用户详情-VIP 表单** | ✅ 含 isVip、vipExpireDate、vipRole 等完整字段 | ⚠️ 有 vipForm,但 payload 不含 isVip/vipExpireDate 等(handleSave 仅保存基础字段,handleSaveVip 单独保存 VIP) | -| **LinkedMp 页** | 稳定版有 `/linked-mp` | 新版无(需确认是否需迁移) | -| **ApiDocs 页** | 单页 api-doc | 新版多 api-docs 页 | - ---- - -## 三、小程序功能 → 管理端能力对照 - -以下按 miniprogram 核心能力,逐项对照管理端是否已覆盖(以稳定版为基准)。 - -| 小程序能力 | 小程序页面/接口 | 管理端需支持 | 稳定版 | 新版 | -|------------|-----------------|--------------|:------:|:----:| -| **余额体系** | wallet、read/vip 余额支付 | 用户余额查看、交易记录 | ✅ | ❌ | -| **代付(美团式)** | gift-pay/detail、list | 订单页展示代付信息 | ✅ | ❌ | -| **规则引擎** | ruleEngine | 用户规则 CRUD | ✅ | ✅ | -| **VIP** | vip、member-detail | VIP 状态、超级个体 | ✅ | ✅ | -| **订单** | purchases、read/vip 支付 | 订单列表、支付方式、退款 | ✅ | ⚠️ 缺余额/代付 | -| **提现、分销、找伙伴、导师、内容** | 对应页面 | 已有 | ✅ | ✅ | - ---- - -## 四、迁移时稳定版必须保留(新版缺失则从稳定版带入) - -### 4.1 用户详情 - 余额展示 - -| 项 | 说明 | -|----|------| -| **目标** | 迁移后稳定版保留「当前余额」卡 | -| **接口** | `GET /api/admin/users/:id/balance` | -| **实现** | 稳定版 UserDetailModal 已有,合并时不可覆盖 | - -### 4.2 订单页 - 支付方式与代付 - -| 项 | 说明 | -|----|------| -| **目标** | 迁移后稳定版保留 balance、代付人展示 | -| **接口** | `GET /api/admin/orders` 已返回 | -| **实现** | 稳定版 OrdersPage 已有,合并时不可覆盖 | - -### 4.3 LinkedMp、RechargeAlert - -稳定版 ContentPage 嵌入 LinkedMpPage、Layout 有 RechargeAlert,合并时保留。 - ---- - -## 五、稳定版待补充(两版共用) - -| 优先级 | 项 | 说明 | -|:------:|----|------| -| P2 | 用户余额人工调整 | 用户详情增加「调整余额」入口,需 soul-api 新增 `POST /api/admin/users/:id/balance/adjust` | -| P2 | 代付列表页 | 新增代付请求维度管理,需 soul-api 新增 `GET /api/admin/gift-pay-requests` | -| P3 | 埋点看板 | 可选,低优先级 | - ---- - -## 六、总结 - -| 类型 | 说明 | -|------|------| -| **新版迁移** | 用户详情余额、订单页支付方式(余额/代付)——2 项,参考稳定版实现 | -| **稳定版待补充** | 用户余额人工调整、代付列表页——2 项,两版共用后端接口 | -| **结论** | 新版管理端需从稳定版迁移余额与代付相关展示能力,接口已就绪,以 UI 与数据绑定为主。 diff --git a/开发文档/索引.md b/开发文档/索引.md new file mode 100644 index 00000000..2f123d4f --- /dev/null +++ b/开发文档/索引.md @@ -0,0 +1,97 @@ +# Soul 创业派对 - 开发文档索引 + +> 按目录与文件标注用途,便于快速定位。最后更新:2026-03-20 + +--- + +## 一、目录总览 + +| 目录 | 用途 | +|------|------| +| **1、需求** | 需求基准、主需求文件、归档 | +| **6、后端** | soul-api 鉴权、接口补全、迁移对比 | +| **8、部署** | 部署、提现、订阅消息、宝塔配置 | +| **10、项目管理** | 里程碑、运营与变更记录 | +| **Cunkebao接口文档** | 存客宝(Cunkebao)前端项目接口清单 | + +--- + +## 二、1、需求 + +| 文件 | 用途 | +|------|------| +| **索引.md** | 主需求 = 日期最新的需求文件;命名规则 `YYYY-MM-DD-需求.md`;同步需求时更新 | +| **以界面定需求.md** | **界面级需求基准**:小程序/管理端界面清单、主要接口、业务逻辑对齐(三端路由、VIP 资料等) | +| **2026-03-20-需求.md** | 当前主需求文件:需求清单、三端需求速查 | +| **archive/** | 专项需求、技术分析、已合并或过时文档 | +| archive/README.md | 归档说明 | +| archive/链接人与事-*.md | 链接人与事相关需求与方案 | +| archive/文章详情-阅读页线框图.md | 阅读页线框图 | + +--- + +## 三、6、后端 + +| 文件 | 用途 | +|------|------| +| **管理端鉴权设计.md** | soul-api 管理端 JWT 鉴权、路由分层(AdminAuth、Cookie/admin_session) | +| **miniprogram接口补全说明.md** | VIP/users 接口从 /api/vip 迁移至 /api/miniprogram/* 的说明 | +| **soul-admin与Mycontent-temp内容页对比.md** | 内容管理页新建/编辑弹窗功能对比,soul-admin 为基准 | + +--- + +## 四、8、部署 + +| 文件 | 用途 | +|------|------| +| **部署总览.md** | **入口**:正式/测试/管理端部署脚本、环境、域名、命令 | +| **DOCKER部署说明.md** | 测试环境 Runner/Docker 模式、Docker 相关文件 | +| **宝塔-Docker首次配置指南.md** | 测试环境 Runner 首次配置 | +| **宝塔反向代理说明.md** | 域名 404 排查、Nginx 反向代理(8080/9001) | +| **提现功能完整技术文档.md** | 微信支付商家转账到零钱 API 集成、签名、加密、代码实现 | +| **订阅消息.md** | 提现成功订阅消息(PowerWeChat 示例) | +| **商家转账.md** | PowerWeChat 商家转账示例代码 | + +--- + +## 五、10、项目管理 + +| 文件 | 用途 | +|------|------| +| **项目落地推进表.md** | 里程碑、当前阶段目标、风险与阻塞、永平落地 | +| **运营与变更.md** | 运营数据、soul-admin 变更、近期讨论、技术决策 | + +--- + +## 六、Cunkebao接口文档 + +> 存客宝为前端项目,接口由后端提供。基础 URL 来自 `VITE_API_BASE_URL`。 + +| 文件 | 用途 | +|------|------| +| **README.md** | 目录说明、公共约定、工作台 type 含义 | +| **API接口清单.md** | 全部接口路径、方法、入参与简要说明 | +| **入参出参结构.md** | 核心模块请求/响应参数结构(含 TypeScript 类型) | + +--- + +## 七、项目根目录相关 + +| 路径 | 用途 | +|------|------| +| **scripts/test/功能测试流程.md** | 功能测试流程、自动化用例、手工验证、报告模板 | +| **soul-api/文档索引.md** | 指向开发文档的后端相关文档链接 | +| **miniprogram/README.md** | 小程序项目结构、设计特点 | + +--- + +## 八、快速入口 + +| 场景 | 推荐文档 | +|------|----------| +| 新增/变更功能 | 1、需求/以界面定需求.md → 1、需求/YYYY-MM-DD-需求.md | +| 部署 soul-api | 8、部署/DOCKER部署说明.md、宝塔反向代理说明.md | +| 提现/商家转账 | 8、部署/提现功能完整技术文档.md、商家转账.md | +| 管理端鉴权 | 6、后端/管理端鉴权设计.md | +| 存客宝对接 | Cunkebao接口文档/ | +| 测试验证 | scripts/test/功能测试流程.md | diff --git a/开发文档/规则引擎迁移-影响分析.md b/开发文档/规则引擎迁移-影响分析.md deleted file mode 100644 index e04b1fcb..00000000 --- a/开发文档/规则引擎迁移-影响分析.md +++ /dev/null @@ -1,77 +0,0 @@ -# 规则引擎迁移 - 影响分析 - -> 乘风严格分析,确保不破坏现有功能。2026-03-17 - ---- - -## 一、现有逻辑梳理 - -### 1. 完善头像逻辑(将被吸收) - -| 调用位置 | 文件 | 行号 | 触发时机 | -|----------|------|------|----------| -| login 成功 | app.js | 525 | 微信 code 登录成功后 | -| getOpenId 登录 | app.js | 587 | getOpenId 时接口返回 user | -| loginWithPhone | app.js | 641 | 手机号登录成功后 | - -**逻辑**:`_ensureProfileCompletedAfterLogin(user)` → 若头像/昵称未完善 → Toast + `navigateTo` avatar-nickname - -### 2. 规则引擎将接管 - -- **场景**:after_login(对应 trigger「注册」) -- **规则**:checkRule_FillAvatar -- **行为**:Modal(去完善/稍后再说)→ 确认则 navigateTo -- **目标页**:改为 avatar-nickname(与稳定版一致) - -### 3. 破坏性风险点 - -| 风险 | 条件 | 后果 | 缓解 | -|------|------|------|------| -| 规则 API 404 | 后端未部署 user-rules | loadRules 返回 [],无引导 | 先部署后端 | -| user_rules 表空 | 无「注册」规则 | isRuleEnabled 为 false,无引导 | SQL 脚本插入默认规则 | -| globalData 不兼容 | readCount/hasPurchasedFull | 部分规则不触发 | ruleEngine 内做兼容 | -| 目标页错误 | target=profile-edit | 跳错页 | 改为 avatar-nickname | - ---- - -## 二、兼容性修改清单 - -### ruleEngine.js - -| 修改项 | 原值 | 新值 | 原因 | -|--------|------|------|------| -| checkRule_FillAvatar target | profile-edit | avatar-nickname | 稳定版用 avatar-nickname | -| readCount | globalData.readCount | getReadCount() | 稳定版无 readCount | -| hasPurchasedFull | globalData.hasPurchasedFull | globalData.hasFullBook | 稳定版用 hasFullBook | - -### 空规则兜底 - -当 `rules` 为空时,after_login 不触发 → 用户无引导。**方案**:SQL 脚本插入默认「注册」规则,部署时执行。 - ---- - -## 三、执行顺序(防破坏) - -1. **soul-api**:新增 GET /api/miniprogram/user-rules -2. **soul-api**:确保 user_rules 表存在(GORM AutoMigrate) -3. **SQL**:插入默认「注册」规则(幂等) -4. **miniprogram**:复制 ruleEngine.js 并做兼容 -5. **miniprogram**:app.js 替换 _ensureProfileCompletedAfterLogin 为 checkAndExecute -6. **miniprogram**:match.js 接入 after_match - ---- - -## 四、回滚方案 - -若规则引擎导致问题: -1. app.js:恢复 _ensureProfileCompletedAfterLogin 调用,注释 checkAndExecute -2. match.js:移除 checkAndExecute 调用 -3. 规则引擎仅新增不删,可随时停用 - ---- - -## 五、部署步骤(2026-03-17 已执行) - -1. **soul-api**:重启后 AutoMigrate 会创建 user_rules 表 -2. **数据库**:执行 `soul-api/scripts/add-user-rules-default.sql` 插入默认「注册」规则 -3. **miniprogram**:已接入 ruleEngine,无需额外配置 diff --git a/开发文档/迁移完成度与待办清单.md b/开发文档/迁移完成度与待办清单.md deleted file mode 100644 index 2ee19033..00000000 --- a/开发文档/迁移完成度与待办清单.md +++ /dev/null @@ -1,127 +0,0 @@ -# 迁移完成度与待办清单 - -> 乘风吸收当前经验与交互后整理。基于 new-soul 迁移方案、稳定版适配清单、agent 经验库。 -> 更新日期:2026-03-17(乘风同步进度) - ---- - -## 一、已迁移完成(✅) - -### 新版迁移方案(R1~R11) - -| 需求 | 说明 | 状态 | -|------|------|:----:| -| R1~R4 | 余额体系:充值、消费、交易记录、退款 | ✅ | -| R5 | 我的页「我的余额」入口 | ✅ | -| R2 | 阅读页余额购买(章节/全书) | ✅ | -| R6~R8 | 首页精选/最新展开、按热度、book/hot?limit=50 | ✅ | -| R9~R10 | 代付(我的代付 + 阅读页代付分享) | ✅ | -| R11 | 埋点 trackClick | ✅ | -| VIP 余额 | VIP 页支持余额购买 | ✅ | -| 管理端 | 订单支付方式、用户详情余额 | ✅ | - -### 稳定版适配(P1~P3) - -| 项 | 说明 | 状态 | -|----|------|:----:| -| P1 | 首页「阅读进度」卡 | ✅ | -| P2 | 我的页「编辑」入口 → profile-show | ✅ | -| P3 | 代付功能闭环(美团式:读页→代付页→分享) | ✅ | - -### 代付美团式(2026-03-17) - -| 项 | 说明 | 状态 | -|----|------|:----:| -| 读页入口 | 创建请求 → 跳转代付详情页 | ✅ | -| 代付详情页 | 发起人「分享给好友」/ 好友「帮他付款」双态 | ✅ | -| PayNotify | beneficiaryUserID 权益归发起人 | ✅ | -| 订单与分佣 | 并入 orders、分销 | ✅ | - -### 体验优化(2026-03-17) - -| 项 | 说明 | 状态 | -|----|------|:----:| -| 目录页 | book/parts 加载 loading | ✅ | -| 首页最新新增 | 默认 5 条、折叠,点击展开 | ✅ | - -### 代付营销与体验(近期) - -| 项 | 说明 | 状态 | -|----|------|:----:| -| 代付页营销 | 章节标题+内容预览(20%),吸引代付人 | ✅ | -| 我的代付列表 | 点击卡片进入代付详情页 | ✅ | -| 代付页布局 | 页面协调、间距统一、视觉统一 | ✅ | - ---- - -## 二、未迁移 / 待办 - -### 明确暂不处理 - -| 项 | 说明 | 决策 | -|----|------|------| -| 导师预约支付 | mentor-detail 预约成功后调起支付 | 暂不处理,保持与 new-soul 一致,弹「请联系客服」 | - -### 边缘场景(可选) - -| 项 | 说明 | 优先级 | -|----|------|:------:| -| ~~阅读页代付直链~~ | **已禁止**:gift=1&ref 打开 read 页时直接 redirectTo 代付页,统一在代付页代付 | ✅ | -| ~~阅读统计埋点~~ | chapters/read 页补充 trackClick(篇章展开、章节点击、搜索、分享、购买) | ✅ | -| ~~目录页「每日新增」~~ | latest-chapters 拉取 + 每日新增区块展示 | ✅ | -| ~~P4 目录页与设计稿~~ | 免费/NEW/¥1/增值标签、每日新增区块 | ✅ | - -### 稳定版已有(2026-03-17 分析) - -| 项 | 说明 | 与 new-soul 对比 | -|----|------|-----------------| -| ~~富文本渲染~~ | 按稳定版处理,用户已落地 | ✅ | -| ~~打包购买引导~~ | 购买 ≥3 章显示「解锁全书」按钮,两端一致 | 稳定版 = new-soul | -| ~~存客宝对接~~ | ckb/lead、index-lead、match、join 均已对接 | 稳定版更完善:限频、linkTag ckb | - -### 搁置项(无) - -原搁置项富文本/打包引导/存客宝均已确认稳定版已有,无新增搁置。 - -### 新版细节未迁移(2026-03-17 乘风分析) - -| 项 | 说明 | 优先级 | -|----|------|:------:| -| 运行时配置 | getRuntimeBootstrapConfig、extConfig/Storage、默认生产 baseUrl | P0 | -| loadMpConfig 扩展 | apiDomain、auditMode、supportWechat | P0 | -| auditMode 审核模式 | index/my/wallet/read 支付相关 UI 按审核隐藏 | P1 | -| request timeout | app.request 增加 timeout | P2 | - -详见 `开发文档/新版迁移-功能差异清单.md`(小程序)、`开发文档/新版迁移-管理端功能差异清单.md`(管理端)。 - -### 规则引擎(2026-03-17 已迁移) - -| 项 | 状态 | -|----|:----:| -| ruleEngine.js | ✅ 已接入,兼容 readCount/hasFullBook | -| GET /api/miniprogram/user-rules | ✅ soul-api 已新增 | -| after_login(完善头像) | ✅ 吸收 _ensureProfileCompletedAfterLogin,跳 avatar-nickname | -| after_match(匹配后引导) | ✅ match.js reportMatch 后触发 | -| user_rules 表 + 默认规则 | ✅ AutoMigrate + add-user-rules-default.sql | - -### 埋点(已补齐 2026-03-17) - -| 项 | 当前状态 | -|----|----------| -| **埋点 trackClick** | 已接入:index、my、match、vip、search、referral、chapters、read、wallet | - ---- - -## 三、文档待更新 - -| 文档 | 待更新内容 | -|------|------------| -| 稳定版-小程序与API对比.md | wallet 已迁移,可更新为 ✓ | - ---- - -## 四、总结 - -**核心迁移已全部完成**:余额体系、代付美团式、埋点、首页/目录/阅读/VIP 相关功能均已落地。 - -**剩余**:导师预约支付(暂不处理);埋点待补充(见上表)。规则引擎已迁移,富文本、打包购买引导、存客宝对接均已确认稳定版已有。