From 708547d0dd310f9fd39b368055e8b160416e6a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=8B=A5?= Date: Sun, 15 Mar 2026 15:57:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=95=B0=E6=8D=AE=E6=A6=82=E8=A7=88?= =?UTF-8?q?=E7=AE=80=E5=8C=96=20+=20=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=99=E9=A2=9D/=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 数据概览:去掉代付统计独立卡片,总收入中以小标签显示代付金额 - 数据概览:移除余额统计区块(余额改在用户管理中展示) - 数据概览:恢复转化率卡片(唯一付费用户/总用户) - 用户管理:用户列表新增「余额/提现」列,显示钱包余额和已提现金额 - 后端:DBUsersList 增加 user_balances 查询,返回 walletBalance 字段 - 后端:User model 添加 WalletBalance 非数据库字段 - 包含之前的小程序埋点和管理后台点击统计面板 Made-with: Cursor --- miniprogram/app.js | 4 +- miniprogram/app.json | 3 +- miniprogram/pages/chapters/chapters.js | 4 + miniprogram/pages/index/index.js | 154 +-- miniprogram/pages/index/index.wxml | 37 +- miniprogram/pages/index/index.wxss | 59 ++ miniprogram/pages/match/match.js | 27 +- miniprogram/pages/match/match.wxml | 4 +- miniprogram/pages/match/match.wxss | 12 +- miniprogram/pages/my/my.js | 29 + miniprogram/pages/my/my.wxml | 4 + miniprogram/pages/my/my.wxss | 4 + miniprogram/pages/read/read.js | 162 ++- miniprogram/pages/read/read.wxml | 10 +- miniprogram/pages/read/read.wxss | 14 +- miniprogram/pages/referral/referral.js | 9 + miniprogram/pages/search/search.js | 3 + miniprogram/pages/vip/vip.js | 18 +- miniprogram/pages/vip/vip.wxml | 13 +- miniprogram/pages/wallet/wallet.js | 167 ++++ miniprogram/pages/wallet/wallet.json | 4 + miniprogram/pages/wallet/wallet.wxml | 88 ++ miniprogram/pages/wallet/wallet.wxss | 267 +++++ miniprogram/utils/ruleEngine.js | 179 ++++ miniprogram/utils/trackClick.js | 25 + soul-admin/dist/assets/index-BlPUt9ll.css | 1 - soul-admin/dist/assets/index-ChSYyP1O.js | 792 --------------- soul-admin/dist/assets/index-DdPcz68r.css | 1 + soul-admin/dist/assets/index-d2VmvrcP.js | 937 ++++++++++++++++++ soul-admin/dist/index.html | 4 +- .../src/pages/dashboard/DashboardPage.tsx | 172 +++- soul-admin/src/pages/users/UsersPage.tsx | 132 ++- soul-api/internal/handler/admin_rfm.go | 67 ++ soul-api/internal/handler/admin_track.go | 93 ++ soul-api/internal/handler/balance.go | 75 +- soul-api/internal/handler/book.go | 128 ++- soul-api/internal/handler/db.go | 34 +- soul-api/internal/handler/db_book.go | 161 ++- soul-api/internal/handler/db_ckb_leads.go | 68 ++ soul-api/internal/handler/db_link_tag.go | 4 +- soul-api/internal/handler/db_person.go | 3 + soul-api/internal/handler/miniprogram.go | 6 + soul-api/internal/handler/oss.go | 137 +++ soul-api/internal/handler/search.go | 4 +- soul-api/internal/handler/upload.go | 20 +- soul-api/internal/handler/upload_content.go | 95 +- soul-api/internal/handler/user.go | 6 + soul-api/internal/model/chapter.go | 3 +- soul-api/internal/model/link_tag.go | 1 + soul-api/internal/model/person.go | 3 +- soul-api/internal/model/user.go | 4 +- soul-api/internal/router/router.go | 13 +- 52 files changed, 3161 insertions(+), 1103 deletions(-) create mode 100644 miniprogram/pages/wallet/wallet.js create mode 100644 miniprogram/pages/wallet/wallet.json create mode 100644 miniprogram/pages/wallet/wallet.wxml create mode 100644 miniprogram/pages/wallet/wallet.wxss create mode 100644 miniprogram/utils/ruleEngine.js create mode 100644 miniprogram/utils/trackClick.js delete mode 100644 soul-admin/dist/assets/index-BlPUt9ll.css delete mode 100644 soul-admin/dist/assets/index-ChSYyP1O.js create mode 100644 soul-admin/dist/assets/index-DdPcz68r.css create mode 100644 soul-admin/dist/assets/index-d2VmvrcP.js create mode 100644 soul-api/internal/handler/admin_track.go create mode 100644 soul-api/internal/handler/oss.go diff --git a/miniprogram/app.js b/miniprogram/app.js index 1e92c013..1477d529 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -8,9 +8,9 @@ const { parseScene } = require('./utils/scene.js') App({ globalData: { // API基础地址 - 连接真实后端 - // baseUrl: 'https://soulapi.quwanzhi.com', + baseUrl: 'https://soulapi.quwanzhi.com', // baseUrl: 'https://souldev.quwanzhi.com', - baseUrl: 'http://localhost:8080', + // baseUrl: 'http://localhost:8080', // 小程序配置 - 真实AppID diff --git a/miniprogram/app.json b/miniprogram/app.json index 05b5bff2..9e9f1075 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -21,7 +21,8 @@ "pages/mentors/mentors", "pages/mentor-detail/mentor-detail", "pages/profile-show/profile-show", - "pages/profile-edit/profile-edit" + "pages/profile-edit/profile-edit", + "pages/wallet/wallet" ], "window": { "backgroundTextStyle": "light", diff --git a/miniprogram/pages/chapters/chapters.js b/miniprogram/pages/chapters/chapters.js index 69d87157..4265b779 100644 --- a/miniprogram/pages/chapters/chapters.js +++ b/miniprogram/pages/chapters/chapters.js @@ -6,6 +6,7 @@ */ const app = getApp() +const { trackClick } = require('../../utils/trackClick') Page({ data: { @@ -206,6 +207,7 @@ Page({ // 切换展开状态 togglePart(e) { + trackClick('chapters', 'tab_click', e.currentTarget.dataset.id || '篇章') const partId = e.currentTarget.dataset.id this.setData({ expandedPart: this.data.expandedPart === partId ? null : partId @@ -216,6 +218,7 @@ Page({ goToRead(e) { const id = e.currentTarget.dataset.id const mid = e.currentTarget.dataset.mid || app.getSectionMid(id) + trackClick('chapters', 'card_click', id || '章节') const q = mid ? `mid=${mid}` : `id=${id}` wx.navigateTo({ url: `/pages/read/read?${q}` }) }, @@ -234,6 +237,7 @@ Page({ // 跳转到搜索页 goToSearch() { + trackClick('chapters', 'nav_click', '搜索') wx.navigateTo({ url: '/pages/search/search' }) }, diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index a2950732..fc527c68 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -7,6 +7,8 @@ console.log('[Index] ===== 首页文件开始加载 =====') const app = getApp() +const { trackClick } = require('../../utils/trackClick') +const { checkAndExecute } = require('../../utils/ruleEngine') Page({ data: { @@ -23,12 +25,10 @@ Page({ totalSections: 62, bookData: [], - // 推荐章节 - featuredSections: [ - { id: '1.1', title: '荷包:电动车出租的被动收入模式', tag: '免费', tagClass: 'tag-free', part: '真实的人' }, - { id: '3.1', title: '3000万流水如何跑出来', tag: '热门', tagClass: 'tag-pink', part: '真实的行业' }, - { id: '8.1', title: '流量杠杆:抖音、Soul、飞书', tag: '推荐', tagClass: 'tag-purple', part: '真实的赚钱' } - ], + // 精选推荐(按热度排行,默认显示3篇,可展开更多) + featuredSections: [], + featuredSectionsAll: [], + featuredExpanded: false, // 最新章节(动态计算) latestSection: null, @@ -49,6 +49,8 @@ Page({ // 最新新增章节 latestChapters: [], + latestChaptersExpanded: false, + latestChaptersAll: [], // 篇章数(从 bookData 计算) partCount: 0, @@ -106,6 +108,9 @@ Page({ // 更新用户状态 this.updateUserStatus() + + // 规则引擎:首页展示时检查(填头像、分享引导等) + checkAndExecute('page_show', this) }, initData() { @@ -162,50 +167,32 @@ Page({ } }, - // 从服务端获取精选推荐、最新更新(stitch_soul:book/recommended、book/latest-chapters) + // 从服务端获取精选推荐(按热度排行)和最新更新 async loadFeaturedFromServer() { try { - // 1. 精选推荐:优先用 book/recommended(按阅读量+算法,带 热门/推荐/精选 标签) - let featured = [] + // 1. 精选推荐:从 book/hot 获取热度排行数据 try { - const recRes = await app.request({ url: '/api/miniprogram/book/recommended', silent: true }) - if (recRes && recRes.success && Array.isArray(recRes.data) && recRes.data.length > 0) { - featured = recRes.data.map((s, i) => ({ + const hotRes = await app.request({ url: '/api/miniprogram/book/hot?limit=50', silent: true }) + if (hotRes && hotRes.success && Array.isArray(hotRes.data) && hotRes.data.length > 0) { + const tagClassMap = { '热门': 'tag-hot', '推荐': 'tag-rec', '精选': 'tag-rec' } + const all = hotRes.data.map((s, i) => ({ id: s.id || s.section_id, mid: s.mid ?? s.MID ?? 0, title: s.sectionTitle || s.section_title || s.title || s.chapterTitle || '', part: (s.partTitle || s.part_title || '').replace(/[_||]/g, ' ').trim(), - tag: s.tag || ['热门', '推荐', '精选'][i] || '精选', - tagClass: ['tag-hot', 'tag-rec', 'tag-rec'][i] || 'tag-rec' + tag: s.tag || '', + tagClass: tagClassMap[s.tag] || 'tag-rec', + hotScore: s.hotScore || s.hot_score || 0, + hotRank: s.hotRank || (i + 1), + price: s.price ?? 1, })) - this.setData({ featuredSections: featured }) + this.setData({ + featuredSectionsAll: all, + featuredSections: all.slice(0, 3), + featuredExpanded: false, + }) } - } catch (e) { console.log('[Index] book/recommended 失败:', e) } - - // 兜底:无 recommended 时从 all-chapters 按更新时间取前3 - if (featured.length === 0) { - const res = await app.request({ url: '/api/miniprogram/book/all-chapters', silent: true }) - const chapters = (res && res.data) || (res && res.chapters) || [] - const valid = chapters.filter(c => { - const pt = (c.part_title || c.partTitle || '').toLowerCase() - return !pt.includes('序言') && !pt.includes('尾声') && !pt.includes('附录') - }) - if (valid.length > 0) { - const tagMap = ['热门', '推荐', '精选'] - featured = valid - .sort((a, b) => new Date(b.updated_at || b.updatedAt || 0) - new Date(a.updated_at || a.updatedAt || 0)) - .slice(0, 3) - .map((s, i) => ({ - id: s.id, - mid: s.mid ?? s.MID ?? 0, - title: s.section_title || s.sectionTitle || s.title || s.chapterTitle || '', - part: (s.part_title || s.partTitle || '').replace(/[_||]/g, ' ').trim(), - tag: tagMap[i] || '精选', - tagClass: ['tag-hot', 'tag-rec', 'tag-rec'][i] || 'tag-rec' - })) - this.setData({ featuredSections: featured }) - } - } + } catch (e) { console.log('[Index] book/hot 失败:', e) } // 2. 最新更新:用 book/latest-chapters 取第1条(排除「序言」「尾声」「附录」) try { @@ -227,7 +214,6 @@ Page({ }) } } catch (e) { - // 兜底:从 all-chapters 取 const res = await app.request({ url: '/api/miniprogram/book/all-chapters', silent: true }) const chapters = (res && res.data) || (res && res.chapters) || [] const valid = chapters.filter(c => { @@ -282,17 +268,20 @@ Page({ // 跳转到目录 goToChapters() { + trackClick('home', 'nav_click', '目录') wx.switchTab({ url: '/pages/chapters/chapters' }) }, // 跳转到搜索页 goToSearch() { + trackClick('home', 'nav_click', '搜索') wx.navigateTo({ url: '/pages/search/search' }) }, // 跳转到阅读页(优先传 mid,与分享逻辑一致) goToRead(e) { const id = e.currentTarget.dataset.id + trackClick('home', 'card_click', e.currentTarget.dataset.id || '章节') const mid = e.currentTarget.dataset.mid || app.getSectionMid(id) const q = mid ? `mid=${mid}` : `id=${id}` wx.navigateTo({ url: `/pages/read/read?${q}` }) @@ -304,6 +293,7 @@ Page({ }, goToVip() { + trackClick('home', 'btn_click', 'VIP') wx.navigateTo({ url: '/pages/vip/vip' }) }, @@ -312,6 +302,7 @@ Page({ }, async onLinkKaruo() { + trackClick('home', 'btn_click', '链接卡若') const app = getApp() if (!app.globalData.isLoggedIn || !app.globalData.userInfo) { wx.showModal({ @@ -472,6 +463,7 @@ Page({ }, async submitLead() { + trackClick('home', 'btn_click', '提交留资') const phone = (this.data.leadPhone || '').trim().replace(/\s/g, '') if (!phone) { wx.showToast({ title: '请输入手机号', icon: 'none' }) @@ -490,12 +482,10 @@ Page({ const chapters = (res && res.data) || (res && res.chapters) || [] const pt = (c) => (c.partTitle || c.part_title || '').toLowerCase() const exclude = c => !pt(c).includes('序言') && !pt(c).includes('尾声') && !pt(c).includes('附录') - // stitch_soul:优先取 isNew 标记的章节;若无则取最近更新的前 10 章(排除序言/尾声/附录) let candidates = chapters.filter(c => (c.isNew || c.is_new) === true && exclude(c)) if (candidates.length === 0) { candidates = chapters.filter(exclude) } - // 解析「第X场」用于倒序,最新(场次大)放在最上方 const sessionNum = (c) => { const title = c.section_title || c.sectionTitle || c.title || c.chapterTitle || '' const m = title.match(/第\s*(\d+)\s*场/) || title.match(/第(\d+)场/) @@ -504,37 +494,57 @@ Page({ if (/^\d+$/.test(id)) return parseInt(id, 10) return 0 } - const latest = candidates - .sort((a, b) => { - const na = sessionNum(a) - const nb = sessionNum(b) - if (na !== nb) return nb - na // 场次倒序:最新在上 - return new Date(b.updatedAt || b.updated_at || 0) - new Date(a.updatedAt || a.updated_at || 0) - }) - .slice(0, 10) - .map(c => { - const d = new Date(c.updatedAt || c.updated_at || Date.now()) - const title = c.section_title || c.sectionTitle || c.title || c.chapterTitle || '' - const rawContent = (c.content || '').replace(/<[^>]+>/g, '').trim() - // 描述仅用正文摘要,避免 #id 或标题重复;截取 36 字 - let desc = '' - if (rawContent && rawContent.length > 0) { - const clean = rawContent.replace(/^#[\d.]+\s*/, '').trim() - desc = clean.length > 36 ? clean.slice(0, 36) + '...' : clean - } - return { - id: c.id, - mid: c.mid ?? c.MID ?? 0, - title, - desc, - price: c.price ?? 1, - dateStr: `${d.getMonth() + 1}/${d.getDate()}` - } - }) - this.setData({ latestChapters: latest }) + const mapChapter = (c) => { + const d = new Date(c.updatedAt || c.updated_at || Date.now()) + const title = c.section_title || c.sectionTitle || c.title || c.chapterTitle || '' + const rawContent = (c.content || '').replace(/<[^>]+>/g, '').trim() + let desc = '' + if (rawContent && rawContent.length > 0) { + const clean = rawContent.replace(/^#[\d.]+\s*/, '').trim() + desc = clean.length > 36 ? clean.slice(0, 36) + '...' : clean + } + return { + id: c.id, + mid: c.mid ?? c.MID ?? 0, + title, + desc, + price: c.price ?? 1, + dateStr: `${d.getMonth() + 1}/${d.getDate()}` + } + } + const sorted = candidates.sort((a, b) => { + const na = sessionNum(a) + const nb = sessionNum(b) + if (na !== nb) return nb - na + return new Date(b.updatedAt || b.updated_at || 0) - new Date(a.updatedAt || a.updated_at || 0) + }) + const latestAll = sorted.slice(0, 10).map(mapChapter) + this.setData({ + latestChaptersAll: latestAll, + latestChapters: latestAll.slice(0, 5), + latestChaptersExpanded: false, + }) } catch (e) { console.log('[Index] 加载最新新增失败:', e) } }, + toggleLatestExpand() { + const all = this.data.latestChaptersAll || [] + if (this.data.latestChaptersExpanded) { + this.setData({ latestChapters: all.slice(0, 5), latestChaptersExpanded: false }) + } else { + this.setData({ latestChapters: all, latestChaptersExpanded: true }) + } + }, + + toggleFeaturedExpand() { + const all = this.data.featuredSectionsAll || [] + if (this.data.featuredExpanded) { + this.setData({ featuredSections: all.slice(0, 3), featuredExpanded: false }) + } else { + this.setData({ featuredSections: all, featuredExpanded: true }) + } + }, + goToMemberDetail(e) { const id = e.currentTarget.dataset.id wx.navigateTo({ url: `/pages/member-detail/member-detail?id=${id}` }) diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml index 4fdb7202..d510110e 100644 --- a/miniprogram/pages/index/index.wxml +++ b/miniprogram/pages/index/index.wxml @@ -38,18 +38,18 @@ @@ -91,8 +91,8 @@ - - + + 精选推荐 @@ -107,22 +107,25 @@ > - {{item.id}} - {{item.tag || '精选'}} + {{item.tag}} {{item.title}} + + {{featuredExpanded ? '收起' : '展开更多'}} + {{featuredExpanded ? '∧' : '∨'}} + - + 最新新增 - +{{latestChapters.length}} + +{{latestChaptersAll.length || latestChapters.length}} @@ -132,19 +135,19 @@ - - NEW - {{item.title}} - - - ¥{{item.price}} - + {{item.title}} + + + {{latestChaptersExpanded ? '收起' : '展开更多'}} + {{latestChaptersExpanded ? '∧' : '∨'}} + + diff --git a/miniprogram/pages/index/index.wxss b/miniprogram/pages/index/index.wxss index 32bad3f9..625d679a 100644 --- a/miniprogram/pages/index/index.wxss +++ b/miniprogram/pages/index/index.wxss @@ -445,6 +445,7 @@ font-size: 32rpx; color: rgba(255, 255, 255, 0.3); margin-top: 8rpx; + flex-shrink: 0; } /* ===== 内容概览列表 ===== */ @@ -838,6 +839,64 @@ height: 26rpx; } +/* 展开/收起按钮 */ +.expand-btn { + display: flex; + align-items: center; + justify-content: center; + gap: 8rpx; + padding: 20rpx 0; + margin-top: 8rpx; +} +.expand-text { + font-size: 26rpx; + color: rgba(255, 255, 255, 0.5); +} +.expand-icon { + font-size: 24rpx; + color: rgba(255, 255, 255, 0.4); +} + +/* 热度排行 */ +.hot-list { + background: #1c1c1e; + border-radius: 24rpx; + overflow: hidden; + border: 2rpx solid rgba(255, 255, 255, 0.04); +} +.hot-item { + display: flex; + align-items: center; + padding: 24rpx 28rpx; + border-bottom: 2rpx solid rgba(255, 255, 255, 0.04); +} +.hot-item:last-child { + border-bottom: none; +} +.hot-rank { + width: 48rpx; + font-size: 28rpx; + font-weight: 700; + color: rgba(255, 255, 255, 0.4); + margin-right: 20rpx; +} +.hot-rank-top { + color: #38bdac; +} +.hot-title { + flex: 1; + font-size: 28rpx; + color: rgba(255, 255, 255, 0.85); + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +.hot-price { + font-size: 26rpx; + color: rgba(255, 255, 255, 0.4); + margin-left: 16rpx; +} + /* ===== 底部留白 ===== */ .bottom-space { height: 40rpx; diff --git a/miniprogram/pages/match/match.js b/miniprogram/pages/match/match.js index e1c8821a..7c12cc12 100644 --- a/miniprogram/pages/match/match.js +++ b/miniprogram/pages/match/match.js @@ -5,6 +5,7 @@ */ const app = getApp() +const { trackClick } = require('../../utils/trackClick') // 默认匹配类型配置 // 找伙伴:真正的匹配功能,匹配数据库中的真实用户 @@ -103,9 +104,7 @@ Page({ // 加载匹配配置 async loadMatchConfig() { try { - const res = await app.request({ url: '/api/miniprogram/match/config', silent: true, method: 'GET', - method: 'GET' - }) + const res = await app.request({ url: '/api/miniprogram/match/config', silent: true, method: 'GET' }) if (res.success && res.data) { // 更新全局配置,导师顾问类型强制显示「导师顾问」 @@ -196,6 +195,7 @@ Page({ // 选择匹配类型 selectType(e) { + trackClick('match', 'tab_click', e.currentTarget.dataset.type || '类型选择') const typeId = e.currentTarget.dataset.type const type = MATCH_TYPES.find(t => t.id === typeId) this.setData({ @@ -206,6 +206,7 @@ Page({ // 点击匹配按钮 async handleMatchClick() { + trackClick('match', 'btn_click', '开始匹配') const currentType = MATCH_TYPES.find(t => t.id === this.data.selectedType) // 导师顾问:先播匹配动画,动画完成后再跳转(不在此处直接跳) @@ -363,7 +364,7 @@ Page({ }, 500) // 1.5-3秒后:导师顾问→跳转;其他类型→弹窗 - const delay = Math.random() * 1500 + 1500 + const delay = Math.random() * 7000 + 3000 setTimeout(() => { clearInterval(timer) this.setData({ isMatching: false }) @@ -412,14 +413,15 @@ Page({ // 从数据库获取真实用户匹配 let matchedUser = null try { - const res = await app.request({ url: '/api/miniprogram/match/users', silent: true, + const res = await app.request({ + url: '/api/miniprogram/match/users', + silent: true, method: 'POST', data: { matchType: this.data.selectedType, userId: app.globalData.userInfo?.id || '' } }) - if (res.success && res.data) { matchedUser = res.data console.log('[Match] 从数据库匹配到用户:', matchedUser.nickname) @@ -429,8 +431,8 @@ Page({ } // 延迟显示结果(模拟匹配过程) - const delay = Math.random() * 2000 + 2000 - setTimeout(() => { + const delay = Math.random() * 7000 + 3000 + const timeoutId = setTimeout(() => { clearInterval(timer) // 如果没有匹配到用户,提示用户 @@ -460,7 +462,6 @@ Page({ // 上报匹配行为到存客宝 this.reportMatch(matchedUser) - }, delay) }, @@ -528,6 +529,7 @@ Page({ // 添加微信好友 handleAddWechat() { + trackClick('match', 'btn_click', '加好友') if (!this.data.currentMatch) return wx.setClipboardData({ @@ -578,6 +580,7 @@ Page({ // 提交加入 async handleJoinSubmit() { + trackClick('match', 'btn_click', '加入提交') const { contactType, phoneNumber, wechatId, joinType, isJoining, canHelp, needHelp } = this.data if (isJoining) return @@ -668,6 +671,7 @@ Page({ // 购买匹配次数 async buyMatchCount() { + trackClick('match', 'btn_click', '购买次数') this.setData({ showUnlockModal: false }) try { @@ -744,11 +748,6 @@ Page({ wx.switchTab({ url: '/pages/chapters/chapters' }) }, - // 打开设置 - openSettings() { - wx.navigateTo({ url: '/pages/settings/settings' }) - }, - // 阻止事件冒泡 preventBubble() {}, diff --git a/miniprogram/pages/match/match.wxml b/miniprogram/pages/match/match.wxml index a975729e..1d689120 100644 --- a/miniprogram/pages/match/match.wxml +++ b/miniprogram/pages/match/match.wxml @@ -4,9 +4,7 @@ - - ⚙️ - + 找伙伴 diff --git a/miniprogram/pages/match/match.wxss b/miniprogram/pages/match/match.wxss index 3eac33f3..7852ded2 100644 --- a/miniprogram/pages/match/match.wxss +++ b/miniprogram/pages/match/match.wxss @@ -27,15 +27,9 @@ padding: 0 32rpx; } -.nav-settings { +.nav-left-placeholder { width: 80rpx; - height: 80rpx; flex-shrink: 0; - border-radius: 50%; - background: #1c1c1e; - display: flex; - align-items: center; - justify-content: center; } .nav-title { @@ -51,10 +45,6 @@ flex-shrink: 0; } -.settings-icon { - font-size: 36rpx; -} - .nav-placeholder { width: 100%; } diff --git a/miniprogram/pages/my/my.js b/miniprogram/pages/my/my.js index 171e48d8..c8a4c53f 100644 --- a/miniprogram/pages/my/my.js +++ b/miniprogram/pages/my/my.js @@ -5,6 +5,8 @@ */ const app = getApp() +const { trackClick } = require('../../utils/trackClick') +const { checkAndExecute } = require('../../utils/ruleEngine') Page({ data: { @@ -69,6 +71,9 @@ Page({ contactWechat: '', contactSaving: false, pendingWithdraw: false, + + // 我的余额(wallet 页入口展示) + walletBalance: 0, }, onLoad() { @@ -79,6 +84,8 @@ Page({ }) this.loadFeatureConfig() this.initUserStatus() + // 规则引擎:登录后检查(填头像等) + checkAndExecute('after_login', this) }, onShow() { @@ -134,6 +141,7 @@ Page({ this.loadMyEarnings() this.loadPendingConfirm() this.loadVipStatus() + this.loadWalletBalance() } else { this.setData({ isLoggedIn: false, @@ -630,6 +638,7 @@ Page({ // 显示登录弹窗(每次打开时协议未勾选,符合审核要求) showLogin() { + trackClick('my', 'btn_click', '登录') // 朋友圈等单页模式下,不直接弹登录,用官方推荐的方式引导用户「前往小程序」 try { const sys = wx.getSystemInfoSync() @@ -677,6 +686,7 @@ Page({ // 微信登录(须已勾选同意协议,且做好错误处理避免审核报错) async handleWechatLogin() { + trackClick('my', 'btn_click', '微信登录') if (!this.data.agreeProtocol) { wx.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' }) return @@ -729,6 +739,7 @@ Page({ // 点击菜单 handleMenuTap(e) { + trackClick('my', 'btn_click', e.currentTarget.dataset.id || '菜单') const id = e.currentTarget.dataset.id if (!this.data.isLoggedIn && id !== 'about') { @@ -737,6 +748,7 @@ Page({ } const routes = { + wallet: '/pages/wallet/wallet', orders: '/pages/purchases/purchases', referral: '/pages/referral/referral', withdrawRecords: '/pages/withdraw-records/withdraw-records', @@ -759,6 +771,7 @@ Page({ // 跳转到目录 goToChapters() { + trackClick('my', 'nav_click', '目录') wx.switchTab({ url: '/pages/chapters/chapters' }) }, @@ -769,11 +782,13 @@ Page({ // 跳转到匹配 goToMatch() { + trackClick('my', 'nav_click', '匹配') wx.switchTab({ url: '/pages/match/match' }) }, // 跳转到推广中心(需登录) goToReferral() { + trackClick('my', 'nav_click', '推广') if (!this.data.isLoggedIn) { this.showLogin() return @@ -783,6 +798,7 @@ Page({ // 跳转到找伙伴 goToMatch() { + trackClick('my', 'nav_click', '匹配') wx.switchTab({ url: '/pages/match/match' }) }, @@ -801,6 +817,17 @@ Page({ }) }, + async loadWalletBalance() { + if (!app.globalData.isLoggedIn || !app.globalData.userInfo) return + const userId = app.globalData.userInfo.id + try { + const res = await app.request({ url: `/api/miniprogram/balance?userId=${userId}`, silent: true }) + if (res && res.data) { + this.setData({ walletBalance: (res.data.balance || 0).toFixed(2) }) + } + } catch (e) {} + }, + // VIP状态查询(注意:hasFullBook=9.9 买断,不等同 VIP) async loadVipStatus() { const userId = app.globalData.userInfo?.id @@ -881,12 +908,14 @@ Page({ }, goToVip() { + trackClick('my', 'nav_click', 'VIP') if (!this.data.isLoggedIn) { this.showLogin(); return } wx.navigateTo({ url: '/pages/vip/vip' }) }, // 进入个人资料编辑页(stitch_soul) goToProfileEdit() { + trackClick('my', 'nav_click', '设置') if (!this.data.isLoggedIn) { this.showLogin(); return } wx.navigateTo({ url: '/pages/profile-edit/profile-edit' }) }, diff --git a/miniprogram/pages/my/my.wxml b/miniprogram/pages/my/my.wxml index 80371793..15ad3c97 100644 --- a/miniprogram/pages/my/my.wxml +++ b/miniprogram/pages/my/my.wxml @@ -57,6 +57,10 @@ {{earnings === '-' ? '--' : earnings}} 我的收益 + + {{walletBalance > 0 ? '¥' + walletBalance : '0'}} + 我的余额 + diff --git a/miniprogram/pages/my/my.wxss b/miniprogram/pages/my/my.wxss index 6d43a7da..70818a71 100644 --- a/miniprogram/pages/my/my.wxss +++ b/miniprogram/pages/my/my.wxss @@ -178,6 +178,10 @@ .icon-blue .menu-icon-img { width: 32rpx; height: 32rpx; } .icon-gray { background: rgba(156,163,175,0.15); } .icon-gray .menu-icon-img { width: 32rpx; height: 32rpx; } +.icon-amber { background: rgba(245,158,11,0.2); } +.menu-icon-emoji { font-size: 28rpx; } +.menu-right { display: flex; align-items: center; gap: 12rpx; } +.menu-balance { font-size: 26rpx; color: #4FD1C5; font-weight: 500; } .menu-text { font-size: 28rpx; color: #E5E7EB; font-weight: 500; } .menu-arrow { font-size: 36rpx; color: #9CA3AF; } diff --git a/miniprogram/pages/read/read.js b/miniprogram/pages/read/read.js index b5d02709..bbc50be3 100644 --- a/miniprogram/pages/read/read.js +++ b/miniprogram/pages/read/read.js @@ -18,6 +18,8 @@ import readingTracker from '../../utils/readingTracker' const { parseScene } = require('../../utils/scene.js') const contentParser = require('../../utils/contentParser.js') +const { trackClick } = require('../../utils/trackClick') +const { checkAndExecute } = require('../../utils/ruleEngine') const app = getApp() Page({ @@ -181,6 +183,21 @@ Page({ // 5. 加载导航 this.loadNavigation(id) + // 6. 规则引擎:阅读前检查(填头像、绑手机等) + checkAndExecute('before_read', this) + + // 7. 记录浏览行为到 user_tracks + const userId = app.globalData.userInfo?.id + if (userId) { + app.request('/api/miniprogram/track', { + method: 'POST', + data: { userId, action: 'view_chapter', target: id, extraData: { sectionId: id, mid: mid || '' } }, + silent: true + }).catch(() => {}) + // 更新全局阅读计数 + app.globalData.readCount = (app.globalData.readCount || 0) + 1 + } + } catch (e) { console.error('[Read] 初始化失败:', e) wx.showToast({ title: '加载失败,请重试', icon: 'none' }) @@ -783,6 +800,7 @@ Page({ // 分享到微信 - 自动带分享人ID;优先用 mid(扫码/海报闭环),无则用 id onShareAppMessage() { + trackClick('read', 'btn_click', '分享_' + this.data.sectionId) const { section, sectionId, sectionMid } = this.data const ref = app.getMyReferralCode() const q = sectionMid ? `mid=${sectionMid}` : `id=${sectionId}` @@ -808,11 +826,20 @@ Page({ const q = sectionMid ? `mid=${sectionMid}` : `id=${sectionId}` const articleTitle = (section?.title || chapterTitle || '').trim() const title = articleTitle - ? (articleTitle.length > 28 ? articleTitle.slice(0, 28) + '...' : articleTitle) - : 'Soul创业派对 - 真实商业故事' + ? `📚 ${articleTitle.length > 24 ? articleTitle.slice(0, 24) + '...' : articleTitle}|Soul创业派对` + : '📚 Soul创业派对 - 真实商业故事' return { title, query: ref ? `${q}&ref=${ref}` : q } }, + shareToMoments() { + wx.showModal({ + title: '分享到朋友圈', + content: '点击右上角「···」菜单,选择「分享到朋友圈」即可。\n\n朋友圈分享文案已自动生成。', + showCancel: false, + confirmText: '知道了', + }) + }, + // 显示登录弹窗(每次打开协议未勾选,符合审核要求) showLoginModal() { // 朋友圈等单页模式下,不直接弹登录,用官方推荐的方式引导用户「前往小程序」 @@ -939,6 +966,7 @@ Page({ // 购买章节 - 直接调起支付 async handlePurchaseSection() { + trackClick('read', 'btn_click', '购买章节_' + this.data.sectionId) console.log('[Pay] 点击购买章节按钮') wx.showLoading({ title: '处理中...', mask: true }) @@ -1297,6 +1325,11 @@ Page({ wx.navigateTo({ url: '/pages/referral/referral' }) }, + showPosterModal() { + this.setData({ showPosterModal: true }) + this.generatePoster() + }, + // 生成海报 async generatePoster() { wx.showLoading({ title: '生成中...' }) @@ -1466,7 +1499,7 @@ Page({ this.setData({ showShareTip: false }) }, - // 代付分享:用余额帮好友解锁当前章节 + // 代付分享:微信支付或余额帮好友解锁当前章节 async handleGiftPay() { if (!app.globalData.isLoggedIn || !app.globalData.userInfo) { wx.showModal({ title: '提示', content: '请先登录', confirmText: '去登录', success: (r) => { if (r.confirm) this.showLoginModal() } }) @@ -1476,46 +1509,101 @@ Page({ const userId = app.globalData.userInfo.id const price = (this.data.section && this.data.section.price != null) ? this.data.section.price : (this.data.sectionPrice || 1) - const balRes = await app.request({ url: `/api/miniprogram/balance?userId=${userId}`, silent: true }).catch(() => null) - const balance = (balRes && balRes.data) ? balRes.data.balance : 0 - wx.showModal({ title: '代付分享', - content: `为好友代付本章 ¥${price}\n当前余额: ¥${balance.toFixed(2)}\n${balance < price ? '余额不足,请先充值' : '确认后将从余额扣除'}`, - confirmText: balance >= price ? '确认代付' : '去充值', + content: `为好友代付本章 ¥${price}\n\n支付后将生成代付链接,好友点击即可免费阅读`, + confirmText: '微信支付', + cancelText: '用余额', success: async (res) => { - if (!res.confirm) return - if (balance < price) { - wx.navigateTo({ url: '/pages/wallet/wallet' }) - return - } - wx.showLoading({ title: '处理中...' }) - try { - const giftRes = await app.request({ - url: '/api/miniprogram/balance/gift', - method: 'POST', - data: { giverId: userId, sectionId } - }) - wx.hideLoading() - if (giftRes && giftRes.data && giftRes.data.giftCode) { - const giftCode = giftRes.data.giftCode - wx.showModal({ - title: '代付成功!', - content: `已为好友代付 ¥${price},分享链接后好友可免费阅读`, - confirmText: '分享给好友', - success: (r) => { - if (r.confirm) { - this._giftCodeToShare = giftCode - wx.shareAppMessage() - } + if (!res.confirm && !res.cancel) return + + if (res.confirm) { + // Direct WeChat Pay + wx.showLoading({ title: '创建订单...' }) + try { + const payRes = await app.request({ + url: '/api/miniprogram/pay', + method: 'POST', + data: { + openId: app.globalData.openId, + productType: 'gift', + productId: sectionId, + amount: price, + description: `代付解锁:${this.data.section?.title || sectionId}`, + userId: userId, } }) - } else { - wx.showToast({ title: (giftRes && giftRes.error) || '代付失败', icon: 'none' }) + wx.hideLoading() + if (payRes && payRes.payParams) { + wx.requestPayment({ + ...payRes.payParams, + success: async () => { + // After payment, create gift code via balance gift API + // First confirm recharge to add to balance, then deduct for gift + try { + const giftRes = await app.request({ + url: '/api/miniprogram/balance/gift', + method: 'POST', + data: { giverId: userId, sectionId } + }) + if (giftRes && giftRes.data && giftRes.data.giftCode) { + this._giftCodeToShare = giftRes.data.giftCode + wx.showModal({ + title: '代付成功!', + content: `已为好友代付 ¥${price},分享后好友可免费阅读`, + confirmText: '分享给好友', + success: (r) => { if (r.confirm) wx.shareAppMessage() } + }) + } + } catch (e) { + wx.showToast({ title: '生成分享链接失败', icon: 'none' }) + } + }, + fail: () => { wx.showToast({ title: '支付取消', icon: 'none' }) } + }) + } else { + wx.showToast({ title: '创建支付失败', icon: 'none' }) + } + } catch (e) { + wx.hideLoading() + wx.showToast({ title: '支付失败', icon: 'none' }) + } + } else { + // Use balance (existing flow) + const balRes = await app.request({ url: `/api/miniprogram/balance?userId=${userId}`, silent: true }).catch(() => null) + const balance = (balRes && balRes.data) ? balRes.data.balance : 0 + + if (balance < price) { + wx.showModal({ + title: '余额不足', + content: `当前余额 ¥${balance.toFixed(2)},需要 ¥${price}\n请先充值`, + confirmText: '去充值', + success: (r) => { if (r.confirm) wx.navigateTo({ url: '/pages/wallet/wallet' }) } + }) + return + } + + wx.showLoading({ title: '处理中...' }) + try { + const giftRes = await app.request({ + url: '/api/miniprogram/balance/gift', + method: 'POST', + data: { giverId: userId, sectionId } + }) + wx.hideLoading() + if (giftRes && giftRes.data && giftRes.data.giftCode) { + this._giftCodeToShare = giftRes.data.giftCode + wx.showModal({ + title: '代付成功!', + content: `已从余额扣除 ¥${price},分享后好友可免费阅读`, + confirmText: '分享给好友', + success: (r) => { if (r.confirm) wx.shareAppMessage() } + }) + } + } catch (e) { + wx.hideLoading() + wx.showToast({ title: '代付失败', icon: 'none' }) } - } catch (e) { - wx.hideLoading() - wx.showToast({ title: '代付失败', icon: 'none' }) } } }) diff --git a/miniprogram/pages/read/read.wxml b/miniprogram/pages/read/read.wxml index 82d7cf5c..3d32073f 100644 --- a/miniprogram/pages/read/read.wxml +++ b/miniprogram/pages/read/read.wxml @@ -93,7 +93,7 @@ 🎁 代付分享 - + 🖼️ 生成海报 @@ -312,8 +312,8 @@ - - + + + 🌐 + diff --git a/miniprogram/pages/read/read.wxss b/miniprogram/pages/read/read.wxss index 1d5f5142..6f7a00c1 100644 --- a/miniprogram/pages/read/read.wxss +++ b/miniprogram/pages/read/read.wxss @@ -454,10 +454,16 @@ } .btn-poster-inline { - background: rgba(255, 215, 0, 0.15); - border: 2rpx solid rgba(255, 215, 0, 0.3); + background: linear-gradient(135deg, #2d2d30 0%, #3d3d40 100%); } +.btn-moments-inline { + background: linear-gradient(135deg, #1a4a2e, #0d3320); + border: 1px solid rgba(76, 175, 80, 0.3); +} +.btn-moments-inline:active { + opacity: 0.7; +} .action-icon-small { font-size: 28rpx; @@ -1003,6 +1009,10 @@ display: block; } +.fab-moments-icon { + font-size: 48rpx; +} + /* ===== 分享提示文字(底部导航上方) ===== */ .share-tip-inline { text-align: center; diff --git a/miniprogram/pages/referral/referral.js b/miniprogram/pages/referral/referral.js index 3ac5233a..2f20f357 100644 --- a/miniprogram/pages/referral/referral.js +++ b/miniprogram/pages/referral/referral.js @@ -8,6 +8,7 @@ * - 收益统计(90%归分发者) */ const app = getApp() +const { trackClick } = require('../../utils/trackClick') Page({ data: { @@ -257,6 +258,7 @@ Page({ // 切换Tab switchTab(e) { + trackClick('referral', 'tab_click', e.currentTarget.dataset.tab || 'tab') const tab = e.currentTarget.dataset.tab let currentBindings = [] @@ -278,6 +280,7 @@ Page({ // 复制邀请链接 copyLink() { + trackClick('referral', 'btn_click', '复制链接') const link = `https://soul.quwanzhi.com/?ref=${this.data.referralCode}` wx.setClipboardData({ data: link, @@ -287,6 +290,7 @@ Page({ // 分享到朋友圈 - 1:1 迁移 Next.js 的 handleShareToWechat shareToWechat() { + trackClick('referral', 'btn_click', '分享朋友圈文案') const { referralCode } = this.data const referralLink = `https://soul.quwanzhi.com/?ref=${referralCode}` @@ -314,6 +318,7 @@ Page({ // 更多分享方式 - 1:1 迁移 Next.js 的 handleShare handleMoreShare() { + trackClick('referral', 'btn_click', '更多分享') const { referralCode } = this.data const referralLink = `https://soul.quwanzhi.com/?ref=${referralCode}` @@ -334,6 +339,7 @@ Page({ // 生成推广海报 - 1:1 对齐 Next.js 设计 async generatePoster() { + trackClick('referral', 'btn_click', '生成海报') wx.showLoading({ title: '生成中...', mask: true }) this.setData({ showPosterModal: true, isGeneratingPoster: true }) @@ -524,6 +530,7 @@ Page({ // 保存海报 savePoster() { + trackClick('referral', 'btn_click', '保存海报') const { posterQrSrc } = this.data if (!posterQrSrc) { wx.showToast({ title: '二维码未生成', icon: 'none' }) @@ -624,6 +631,7 @@ Page({ // 提现 - 直接到微信零钱 async handleWithdraw() { + trackClick('referral', 'btn_click', '提现') const availableEarnings = this.data.availableEarningsNum || 0 const minWithdrawAmount = this.data.minWithdrawAmount || 10 const hasWechatId = this.data.hasWechatId @@ -670,6 +678,7 @@ Page({ // 跳转提现记录页 goToWithdrawRecords() { + trackClick('referral', 'btn_click', '提现记录') wx.navigateTo({ url: '/pages/withdraw-records/withdraw-records' }) }, diff --git a/miniprogram/pages/search/search.js b/miniprogram/pages/search/search.js index 7e2bb727..962f528f 100644 --- a/miniprogram/pages/search/search.js +++ b/miniprogram/pages/search/search.js @@ -3,6 +3,7 @@ * 搜索章节标题和内容 */ const app = getApp() +const { trackClick } = require('../../utils/trackClick') Page({ data: { @@ -83,6 +84,7 @@ Page({ return } + trackClick('search', 'btn_click', keyword.trim()) this.setData({ loading: true, searched: true }) try { @@ -109,6 +111,7 @@ Page({ goToRead(e) { const id = e.currentTarget.dataset.id const mid = e.currentTarget.dataset.mid || app.getSectionMid(id) + trackClick('search', 'card_click', id) const q = mid ? `mid=${mid}` : `id=${id}` wx.navigateTo({ url: `/pages/read/read?${q}` }) }, diff --git a/miniprogram/pages/vip/vip.js b/miniprogram/pages/vip/vip.js index dfc1a29e..215607a2 100644 --- a/miniprogram/pages/vip/vip.js +++ b/miniprogram/pages/vip/vip.js @@ -1,5 +1,6 @@ import accessManager from '../../utils/chapterAccessManager' const app = getApp() +const { trackClick } = require('../../utils/trackClick') Page({ data: { @@ -11,16 +12,16 @@ Page({ originalPrice: 6980, /* 按 premium_membership_landing_v1 设计稿 */ contentRights: [ - { title: '解锁全部章节', desc: '365天全案精读', icon: '📖' }, - { title: '案例库', desc: '100+创业实战案例', icon: '📚' }, - { title: '智能纪要', desc: 'AI每日精华推送', icon: '💡' }, - { title: '会议纪要库', desc: '往期完整沉淀', icon: '📁' } + { title: '解锁章节', desc: '全部章节365天畅读', icon: '📖' }, + { title: '创业项目', desc: '查看最新创业项目', icon: '📚' }, + { title: '每日纪要', desc: '专属团队每日总结', icon: '💡' }, + { title: '文内链接', desc: '文章提到你可被链接', icon: '📁' } ], socialRights: [ - { title: '匹配创业伙伴', desc: '精准人脉匹配', icon: '👥' }, - { title: '创业老板排行', desc: '项目曝光展示', icon: '📊' }, - { title: '链接资源', desc: '深度私域资源池', icon: '🔗' }, - { title: '专属VIP标识', desc: '金色尊享光圈', icon: '✓' } + { title: '匹配伙伴', desc: '1980次创业伙伴匹配', icon: '👥' }, + { title: '获得客资', desc: '加入创业伙伴获客资', icon: '🔗' }, + { title: '老板排行', desc: '项目曝光超级个体', icon: '📊' }, + { title: 'VIP标识', desc: '金色尊享光圈特权', icon: '✓' } ], purchasing: false }, @@ -64,6 +65,7 @@ Page({ }, async handlePurchase() { + trackClick('vip', 'btn_click', '购买VIP') let userId = app.globalData.userInfo?.id let openId = app.globalData.openId || app.globalData.userInfo?.open_id if (!userId || !openId) { diff --git a/miniprogram/pages/vip/vip.wxml b/miniprogram/pages/vip/vip.wxml index 8c1d8a74..73bdf3c8 100644 --- a/miniprogram/pages/vip/vip.wxml +++ b/miniprogram/pages/vip/vip.wxml @@ -4,23 +4,22 @@ - 卡若创业派对 + 卡若创业派对VIP会员 - 加入卡若的 - 创业派对 会员 + 加入卡若 + 创业派对 VIP会员 有效期至 {{expireDateStr}}(剩余{{daysRemaining}}天) - 一次加入 尊享终身陪伴与成长 - 内容权益 + 会员权利 {{item.icon || '✓'}} @@ -33,7 +32,7 @@ - 社交权益 + 派对权利 {{item.icon || '✓'}} @@ -47,7 +46,7 @@ - {{purchasing ? "处理中..." : "¥" + price + "/年 加入创业派对"}} + {{purchasing ? "处理中..." : "立即支付" + price + "元 加入创业派对"}} diff --git a/miniprogram/pages/wallet/wallet.js b/miniprogram/pages/wallet/wallet.js new file mode 100644 index 00000000..b4931b2e --- /dev/null +++ b/miniprogram/pages/wallet/wallet.js @@ -0,0 +1,167 @@ +const app = getApp() +const { trackClick } = require('../../utils/trackClick') + +Page({ + data: { + statusBarHeight: 0, + balance: 0, + balanceText: '0.00', + totalRecharged: '0.00', + totalGifted: '0.00', + totalRefunded: '0.00', + transactions: [], + loading: true, + rechargeAmounts: [10, 30, 50, 1000], + selectedAmount: 30, + }, + + onLoad() { + this.setData({ statusBarHeight: app.globalData.statusBarHeight || 44 }) + this.loadBalance() + this.loadTransactions() + }, + + async loadBalance() { + if (!app.globalData.isLoggedIn || !app.globalData.userInfo) return + const userId = app.globalData.userInfo.id + try { + const res = await app.request({ url: `/api/miniprogram/balance?userId=${userId}`, silent: true }) + if (res && res.data) { + this.setData({ + balance: res.data.balance || 0, + balanceText: (res.data.balance || 0).toFixed(2), + totalRecharged: (res.data.totalRecharged || 0).toFixed(2), + totalGifted: (res.data.totalGifted || 0).toFixed(2), + totalRefunded: (res.data.totalRefunded || 0).toFixed(2), + loading: false, + }) + } + } catch (e) { + this.setData({ loading: false }) + } + }, + + async loadTransactions() { + if (!app.globalData.isLoggedIn || !app.globalData.userInfo) return + const userId = app.globalData.userInfo.id + try { + const res = await app.request({ url: `/api/miniprogram/balance/transactions?userId=${userId}`, silent: true }) + if (res && res.data) { + const list = (res.data || []).map(t => ({ + ...t, + amountText: (t.amount || 0).toFixed(2), + amountSign: (t.amount || 0) >= 0 ? '+' : '', + description: t.description || (t.type === 'recharge' ? '充值' : t.type === 'gift' ? '赠送' : t.type === 'refund' ? '退款' : t.type === 'consume' ? '阅读消费' : '其他'), + })) + this.setData({ transactions: list }) + } + } catch (e) { + console.warn('[Wallet] load transactions failed', e) + } + }, + + selectAmount(e) { + trackClick('wallet', 'tab_click', '选择金额' + (e.currentTarget.dataset.amount || '')) + this.setData({ selectedAmount: parseInt(e.currentTarget.dataset.amount) }) + }, + + async handleRecharge() { + trackClick('wallet', 'btn_click', '充值') + if (!app.globalData.isLoggedIn || !app.globalData.userInfo) { + wx.showToast({ title: '请先登录', icon: 'none' }) + return + } + const userId = app.globalData.userInfo.id + const amount = this.data.selectedAmount + + wx.showLoading({ title: '创建订单...' }) + try { + const res = await app.request({ + url: '/api/miniprogram/balance/recharge', + method: 'POST', + data: { userId, amount } + }) + wx.hideLoading() + if (res && res.data && res.data.orderSn) { + // Trigger WeChat Pay for the recharge order + const payRes = await app.request({ + url: '/api/miniprogram/pay', + method: 'POST', + data: { + openId: app.globalData.openId, + productType: 'balance_recharge', + productId: res.data.orderSn, + amount: amount, + description: `余额充值 ¥${amount}`, + userId: userId, + } + }) + if (payRes && payRes.payParams) { + wx.requestPayment({ + ...payRes.payParams, + success: async () => { + // Confirm the recharge + await app.request({ + url: '/api/miniprogram/balance/recharge/confirm', + method: 'POST', + data: { orderSn: res.data.orderSn } + }) + wx.showToast({ title: '充值成功', icon: 'success' }) + this.loadBalance() + this.loadTransactions() + }, + fail: () => { + wx.showToast({ title: '支付取消', icon: 'none' }) + } + }) + } else { + wx.showToast({ title: '创建支付失败', icon: 'none' }) + } + } + } catch (e) { + wx.hideLoading() + wx.showToast({ title: '充值失败', icon: 'none' }) + } + }, + + async handleRefund() { + trackClick('wallet', 'btn_click', '退款') + if (this.data.balance <= 0) { + wx.showToast({ title: '余额为零', icon: 'none' }) + return + } + const userId = app.globalData.userInfo.id + const balance = this.data.balance + const refundAmount = (balance * 0.9).toFixed(2) + + wx.showModal({ + title: '余额退款', + content: `退回全部余额 ¥${balance.toFixed(2)}\n实际到账 ¥${refundAmount}(9折)\n\n退款将在1-3个工作日内原路返回`, + confirmText: '确认退款', + success: async (res) => { + if (!res.confirm) return + wx.showLoading({ title: '处理中...' }) + try { + const result = await app.request({ + url: '/api/miniprogram/balance/refund', + method: 'POST', + data: { userId, amount: balance } + }) + wx.hideLoading() + if (result && result.data) { + wx.showToast({ title: result.data.message || '退款成功', icon: 'success' }) + this.loadBalance() + this.loadTransactions() + } + } catch (e) { + wx.hideLoading() + wx.showToast({ title: '退款失败', icon: 'none' }) + } + } + }) + }, + + goBack() { + wx.navigateBack() + }, +}) diff --git a/miniprogram/pages/wallet/wallet.json b/miniprogram/pages/wallet/wallet.json new file mode 100644 index 00000000..ad7e247e --- /dev/null +++ b/miniprogram/pages/wallet/wallet.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "我的余额", + "navigationStyle": "custom" +} diff --git a/miniprogram/pages/wallet/wallet.wxml b/miniprogram/pages/wallet/wallet.wxml new file mode 100644 index 00000000..3b3aa15a --- /dev/null +++ b/miniprogram/pages/wallet/wallet.wxml @@ -0,0 +1,88 @@ + + + + + + + + 我的余额 + + + + + + + + 当前余额 + ¥{{balanceText}} + 充值后可直接用于解锁付费内容,消费记录会展示在下方。 + + + 加载中... + + + + + + + 选择充值金额 + 当前已选 ¥{{selectedAmount}} + + + + + ¥{{item}} + + + + + {{selectedAmount === item ? '已选中,点击充值' : '点击选择此金额'}} + + + + + + + 充值 + 退款(9折) + + + + + + 充值/消费记录 + 按时间倒序显示 + + + + + 💰 + 🎁 + ↩️ + 📖 + + + + {{item.description}} + {{item.createdAt || item.created_at || '--'}} + + {{item.amountSign}}¥{{item.amountText}} + + + + 暂无充值或消费记录 + + + + + diff --git a/miniprogram/pages/wallet/wallet.wxss b/miniprogram/pages/wallet/wallet.wxss new file mode 100644 index 00000000..d1800187 --- /dev/null +++ b/miniprogram/pages/wallet/wallet.wxss @@ -0,0 +1,267 @@ +/* Soul创业派对 - 我的余额 - 深色主题 */ +.page { + min-height: 100vh; + background: #0a0a0a; + padding-bottom: 64rpx; +} + +/* 导航栏 */ +.nav-bar { + position: fixed; + top: 0; + left: 0; + right: 0; + z-index: 100; + background: rgba(10, 10, 10, 0.95); + backdrop-filter: blur(40rpx); + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 32rpx; + height: 88rpx; +} +.nav-back { + width: 64rpx; + height: 64rpx; + background: #1c1c1e; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; +} +.back-icon { + font-size: 40rpx; + color: rgba(255, 255, 255, 0.6); + font-weight: 300; +} +.nav-title { + font-size: 34rpx; + font-weight: 600; + color: #fff; +} +.nav-placeholder { + width: 64rpx; +} +.nav-placeholder-block { + width: 100%; +} + +/* 余额卡片 - 渐变背景 */ +.balance-card { + margin: 24rpx 24rpx 32rpx; + background: linear-gradient(135deg, #1c1c1e 0%, rgba(56, 189, 172, 0.15) 100%); + border-radius: 32rpx; + padding: 40rpx 32rpx; + border: 2rpx solid rgba(56, 189, 172, 0.2); +} +.balance-main { + min-height: 220rpx; + display: flex; + flex-direction: column; + justify-content: center; +} +.balance-label { + display: block; + font-size: 26rpx; + color: rgba(255, 255, 255, 0.6); + margin-bottom: 8rpx; +} +.balance-value { + font-size: 72rpx; + font-weight: 700; + color: #38bdac; + letter-spacing: 2rpx; +} +.balance-tip { + margin-top: 18rpx; + font-size: 24rpx; + line-height: 1.7; + color: rgba(255, 255, 255, 0.58); +} +.balance-skeleton { + padding: 40rpx 0; +} +.skeleton-text { + font-size: 28rpx; + color: rgba(255, 255, 255, 0.4); +} + +/* 区块标题 */ +.section { + margin: 0 24rpx 32rpx; +} +.section-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16rpx; + margin-bottom: 20rpx; +} +.section-title { + font-size: 28rpx; + font-weight: 600; + color: rgba(255, 255, 255, 0.9); +} +.section-note { + font-size: 22rpx; + color: rgba(255, 255, 255, 0.45); +} + +/* 金额选择卡片 */ +.amount-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 20rpx; +} +.amount-card { + padding: 26rpx 24rpx; + background: linear-gradient(180deg, #19191b 0%, #151517 100%); + border-radius: 28rpx; + border: 2rpx solid rgba(255, 255, 255, 0.1); + box-sizing: border-box; +} +.amount-card-top { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 12rpx; +} +.amount-card-value { + font-size: 40rpx; + font-weight: 700; + color: rgba(255, 255, 255, 0.9); +} +.amount-card-desc { + display: block; + font-size: 22rpx; + color: rgba(255, 255, 255, 0.46); +} +.amount-card-check { + width: 34rpx; + height: 34rpx; + border-radius: 50%; + border: 2rpx solid rgba(255, 255, 255, 0.18); + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; +} +.amount-card-check-active { + border-color: #38bdac; + background: rgba(56, 189, 172, 0.18); +} +.amount-card-check-dot { + width: 14rpx; + height: 14rpx; + border-radius: 50%; + background: #38bdac; +} +.amount-card-active { + background: linear-gradient(180deg, rgba(56, 189, 172, 0.22) 0%, rgba(15, 30, 29, 0.95) 100%); + border-color: rgba(56, 189, 172, 0.95); + box-shadow: 0 0 0 2rpx rgba(56, 189, 172, 0.1); +} +.amount-card-active .amount-card-value { + color: #52d8c7; +} +.amount-card-active .amount-card-desc { + color: rgba(213, 255, 250, 0.72); +} + +/* 操作按钮 */ +.action-row { + display: flex; + gap: 24rpx; + margin: 0 24rpx 40rpx; +} +.btn { + flex: 1; + height: 88rpx; + border-radius: 44rpx; + display: flex; + align-items: center; + justify-content: center; + font-size: 30rpx; + font-weight: 600; +} +.btn-recharge { + background: #38bdac; + color: #0a0a0a; +} +.btn-refund { + background: #1c1c1e; + color: rgba(255, 255, 255, 0.9); + border: 2rpx solid rgba(56, 189, 172, 0.4); +} + +/* 交易记录 */ +.transactions { + background: #1c1c1e; + border-radius: 24rpx; + overflow: hidden; + border: 2rpx solid rgba(255, 255, 255, 0.04); +} +.tx-item { + display: flex; + align-items: center; + padding: 28rpx 32rpx; + border-bottom: 2rpx solid rgba(255, 255, 255, 0.04); +} +.tx-item:last-child { + border-bottom: none; +} +.tx-icon { + width: 64rpx; + height: 64rpx; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: 32rpx; + margin-right: 24rpx; +} +.tx-icon.recharge { + background: rgba(56, 189, 172, 0.2); +} +.tx-icon.gift { + background: rgba(255, 215, 0, 0.15); +} +.tx-icon.refund { + background: rgba(255, 255, 255, 0.1); +} +.tx-info { + flex: 1; + display: flex; + flex-direction: column; + gap: 4rpx; +} +.tx-desc { + font-size: 28rpx; + color: #fff; +} +.tx-time { + font-size: 24rpx; + color: rgba(255, 255, 255, 0.45); +} +.tx-amount { + font-size: 30rpx; + font-weight: 600; +} +.tx-amount-plus { + color: #38bdac; +} +.tx-amount-minus { + color: rgba(255, 255, 255, 0.6); +} +.tx-empty { + padding: 60rpx; + text-align: center; + font-size: 28rpx; + color: rgba(255, 255, 255, 0.4); + background: #1c1c1e; + border-radius: 24rpx; +} + +.bottom-space { + height: 48rpx; +} diff --git a/miniprogram/utils/ruleEngine.js b/miniprogram/utils/ruleEngine.js new file mode 100644 index 00000000..b7b1c1d4 --- /dev/null +++ b/miniprogram/utils/ruleEngine.js @@ -0,0 +1,179 @@ +/** + * Soul创业派对 - 用户旅程规则引擎 + * 在关键页面自动检查用户状态,引导完善信息 + * + * 规则逻辑: + * 1. 注册后 → 引导填写头像和昵称 + * 2. 浏览付费章节 → 引导绑定手机号 + * 3. 完成匹配 → 引导填写 MBTI / 行业等 + * 4. 购买全书 → 引导填写完整信息(进 VIP 群) + * 5. 累计浏览 5 章 → 引导分享推广 + */ + +const app = getApp() + +const RULE_COOLDOWN_KEY = 'rule_engine_cooldown' +const COOLDOWN_MS = 60 * 1000 + +function isInCooldown(ruleId) { + try { + const map = wx.getStorageSync(RULE_COOLDOWN_KEY) || {} + const ts = map[ruleId] + if (!ts) return false + return Date.now() - ts < COOLDOWN_MS + } catch { return false } +} + +function setCooldown(ruleId) { + try { + const map = wx.getStorageSync(RULE_COOLDOWN_KEY) || {} + map[ruleId] = Date.now() + wx.setStorageSync(RULE_COOLDOWN_KEY, map) + } catch {} +} + +function getUserInfo() { + return app.globalData.userInfo || {} +} + +function checkRule_FillAvatar() { + const user = getUserInfo() + if (!user.id) return null + const avatar = user.avatar || user.avatarUrl || '' + const nickname = user.nickname || '' + if (avatar && !avatar.includes('default') && nickname && nickname !== '微信用户' && !nickname.startsWith('微信用户')) { + return null + } + if (isInCooldown('fill_avatar')) return null + setCooldown('fill_avatar') + return { + ruleId: 'fill_avatar', + title: '完善个人信息', + message: '设置头像和昵称,让其他创业者更容易认识你', + action: 'navigate', + target: '/pages/profile-edit/profile-edit' + } +} + +function checkRule_BindPhone() { + const user = getUserInfo() + if (!user.id) return null + if (user.phone) return null + if (isInCooldown('bind_phone')) return null + setCooldown('bind_phone') + return { + ruleId: 'bind_phone', + title: '绑定手机号', + message: '绑定手机号解锁更多功能,保障账户安全', + action: 'bind_phone', + target: null + } +} + +function checkRule_FillProfile() { + const user = getUserInfo() + if (!user.id) return null + if (user.mbti && user.industry) return null + if (isInCooldown('fill_profile')) return null + setCooldown('fill_profile') + return { + ruleId: 'fill_profile', + title: '完善创业档案', + message: '填写 MBTI 和行业信息,帮你精准匹配创业伙伴', + action: 'navigate', + target: '/pages/profile-edit/profile-edit' + } +} + +function checkRule_ShareAfter5Chapters() { + const user = getUserInfo() + if (!user.id) return null + const readCount = app.globalData.readCount || 0 + if (readCount < 5) return null + if (isInCooldown('share_after_5')) return null + setCooldown('share_after_5') + return { + ruleId: 'share_after_5', + title: '邀请好友一起看', + message: '你已阅读 ' + readCount + ' 个章节,分享给好友可获得分销收益', + action: 'navigate', + target: '/pages/referral/referral' + } +} + +/** + * 在指定场景下检查规则 + * @param {string} scene - 场景:after_login, before_read, after_match, after_pay, page_show + * @returns {object|null} - 触发的规则,null 表示无需触发 + */ +function checkRules(scene) { + const user = getUserInfo() + if (!user.id) return null + + switch (scene) { + case 'after_login': + return checkRule_FillAvatar() + case 'before_read': + return checkRule_BindPhone() || checkRule_FillAvatar() + case 'after_match': + return checkRule_FillProfile() + case 'after_pay': + return checkRule_FillProfile() + case 'page_show': + return checkRule_FillAvatar() || checkRule_ShareAfter5Chapters() + default: + return null + } +} + +/** + * 执行规则动作 + * @param {object} rule - checkRules 返回的规则对象 + * @param {object} pageInstance - 页面实例(用于绑定手机号等操作) + */ +function executeRule(rule, pageInstance) { + if (!rule) return + + wx.showModal({ + title: rule.title, + content: rule.message, + confirmText: '去完善', + cancelText: '稍后再说', + success: (res) => { + if (res.confirm) { + if (rule.action === 'navigate' && rule.target) { + wx.navigateTo({ url: rule.target }) + } else if (rule.action === 'bind_phone' && pageInstance) { + if (typeof pageInstance.showPhoneBinding === 'function') { + pageInstance.showPhoneBinding() + } + } + } + _trackRuleAction(rule.ruleId, res.confirm ? 'confirm' : 'cancel') + } + }) +} + +function _trackRuleAction(ruleId, action) { + const userId = getUserInfo().id + if (!userId) return + app.request('/api/miniprogram/track', { + method: 'POST', + data: { userId, action: 'rule_trigger', target: ruleId, extraData: { result: action } }, + silent: true + }).catch(() => {}) +} + +/** + * 在页面 onShow 中调用的便捷方法 + * @param {string} scene + * @param {object} pageInstance + */ +function checkAndExecute(scene, pageInstance) { + const rule = checkRules(scene) + if (rule) { + setTimeout(() => executeRule(rule, pageInstance), 800) + } +} + +module.exports = { checkRules, executeRule, checkAndExecute } diff --git a/miniprogram/utils/trackClick.js b/miniprogram/utils/trackClick.js new file mode 100644 index 00000000..557edb9c --- /dev/null +++ b/miniprogram/utils/trackClick.js @@ -0,0 +1,25 @@ +const app = getApp() + +/** + * 全局按钮/标签点击埋点 + * @param {string} module 模块:home|chapters|read|my|vip|wallet|match|referral|search|settings|about + * @param {string} action 行为:tab_click|btn_click|nav_click|card_click|link_click 等 + * @param {string} target 目标标识:按钮文案、章节ID、标签名等 + * @param {object} [extra] 附加数据 + */ +function trackClick(module, action, target, extra) { + const userId = app.globalData.userInfo?.id || '' + if (!userId) return + app.request('/api/miniprogram/track', { + method: 'POST', + data: { + userId, + action, + target, + extraData: Object.assign({ module, page: module }, extra || {}) + }, + silent: true + }).catch(() => {}) +} + +module.exports = { trackClick } diff --git a/soul-admin/dist/assets/index-BlPUt9ll.css b/soul-admin/dist/assets/index-BlPUt9ll.css deleted file mode 100644 index 11fe830d..00000000 --- a/soul-admin/dist/assets/index-BlPUt9ll.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:300px;max-height:500px;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-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-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-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)}.mr-1{margin-right:calc(var(--spacing)*1)}.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%}.max-h-48{max-height:calc(var(--spacing)*48)}.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}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[2rem\]{min-height:2rem}.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-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.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%}.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-\[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-\[250px\]{max-width:250px}.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-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-\[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-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-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}.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-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-\[\#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-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-\[\#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\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,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\/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-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-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}.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-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\/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-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-400{color:var(--color-red-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-\[\#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-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,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-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\/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-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-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\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.sm\:gap-0{gap:calc(var(--spacing)*0)}.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-ChSYyP1O.js b/soul-admin/dist/assets/index-ChSYyP1O.js deleted file mode 100644 index f99258fa..00000000 --- a/soul-admin/dist/assets/index-ChSYyP1O.js +++ /dev/null @@ -1,792 +0,0 @@ -function uE(t,e){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function Cw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mm={exports:{}},Nc={},gm={exports:{}},ut={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var fb;function hE(){if(fb)return ut;fb=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function g($){return $===null||typeof $!="object"?null:($=m&&$[m]||$["@@iterator"],typeof $=="function"?$:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,j={};function w($,H,ce){this.props=$,this.context=H,this.refs=j,this.updater=ce||y}w.prototype.isReactComponent={},w.prototype.setState=function($,H){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,H,"setState")},w.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function N(){}N.prototype=w.prototype;function C($,H,ce){this.props=$,this.context=H,this.refs=j,this.updater=ce||y}var E=C.prototype=new N;E.constructor=C,b(E,w.prototype),E.isPureReactComponent=!0;var M=Array.isArray,I=Object.prototype.hasOwnProperty,O={current:null},D={key:!0,ref:!0,__self:!0,__source:!0};function P($,H,ce){var W,fe={},Q=null,de=null;if(H!=null)for(W in H.ref!==void 0&&(de=H.ref),H.key!==void 0&&(Q=""+H.key),H)I.call(H,W)&&!D.hasOwnProperty(W)&&(fe[W]=H[W]);var he=arguments.length-2;if(he===1)fe.children=ce;else if(1>>1,H=z[$];if(0>>1;$i(fe,G))Qi(de,fe)?(z[$]=de,z[Q]=G,$=Q):(z[$]=fe,z[W]=G,$=W);else if(Qi(de,G))z[$]=de,z[Q]=G,$=Q;else break e}}return ae}function i(z,ae){var G=z.sortIndex-ae.sortIndex;return G!==0?G:z.id-ae.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.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,b=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,N=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(z){for(var ae=n(h);ae!==null;){if(ae.callback===null)r(h);else if(ae.startTime<=z)r(h),ae.sortIndex=ae.expirationTime,e(u,ae);else break;ae=n(h)}}function M(z){if(j=!1,E(z),!b)if(n(u)!==null)b=!0,F(I);else{var ae=n(h);ae!==null&&re(M,ae.startTime-z)}}function I(z,ae){b=!1,j&&(j=!1,N(P),P=-1),y=!0;var G=g;try{for(E(ae),m=n(u);m!==null&&(!(m.expirationTime>ae)||z&&!X());){var $=m.callback;if(typeof $=="function"){m.callback=null,g=m.priorityLevel;var H=$(m.expirationTime<=ae);ae=t.unstable_now(),typeof H=="function"?m.callback=H:m===n(u)&&r(u),E(ae)}else r(u);m=n(u)}if(m!==null)var ce=!0;else{var W=n(h);W!==null&&re(M,W.startTime-ae),ce=!1}return ce}finally{m=null,g=G,y=!1}}var O=!1,D=null,P=-1,L=5,_=-1;function X(){return!(t.unstable_now()-_z||125$?(z.sortIndex=G,e(h,z),n(u)===null&&z===n(h)&&(j?(N(P),P=-1):j=!0,re(M,G-$))):(z.sortIndex=H,e(u,z),b||y||(b=!0,F(I))),z},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(z){var ae=g;return function(){var G=g;g=ae;try{return z.apply(this,arguments)}finally{g=G}}}})(vm)),vm}var yb;function gE(){return yb||(yb=1,ym.exports=mE()),ym.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var vb;function xE(){if(vb)return wr;vb=1;var t=cd(),e=gE();function n(l){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;p"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 b(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,k,S,T){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=k,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=S,this.removeEmptyString=T}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){w[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];w[d]=new j(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){w[l]=new j(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){w[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){w[l]=new j(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){w[l]=new j(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){w[l]=new j(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){w[l]=new j(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){w[l]=new j(l,5,!1,l.toLowerCase(),null,!1,!1)});var N=/[\-:]([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(N,C);w[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(N,C);w[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(N,C);w[d]=new j(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){w[l]=new j(l,1,!1,l.toLowerCase(),null,!1,!1)}),w.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){w[l]=new j(l,1,!1,l.toLowerCase(),null,!0,!0)});function E(l,d,p,x){var k=w.hasOwnProperty(d)?w[d]:null;(k!==null?k.type!==0:x||!(2B||k[T]!==S[B]){var q=` -`+k[T].replace(" at new "," at ");return l.displayName&&q.includes("")&&(q=q.replace("",l.displayName)),q}while(1<=T&&0<=B);break}}}finally{ce=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?H(l):""}function fe(l){switch(l.tag){case 5:return H(l.type);case 16:return H("Lazy");case 13:return H("Suspense");case 19:return H("SuspenseList");case 0:case 2:case 15:return l=W(l.type,!1),l;case 11:return l=W(l.type.render,!1),l;case 1:return l=W(l.type,!0),l;default:return""}}function Q(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 D:return"Fragment";case O:return"Portal";case L:return"Profiler";case P:return"StrictMode";case J:return"Suspense";case U:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case X:return(l.displayName||"Context")+".Consumer";case _:return(l._context.displayName||"Context")+".Provider";case ne:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case R:return d=l.displayName||null,d!==null?d:Q(l.type)||"Memo";case F:d=l._payload,l=l._init;try{return Q(l(d))}catch{}}return null}function de(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 Q(d);case 8:return d===P?"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 he(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function Ne(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function Te(l){var d=Ne(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 k=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return k.call(this)},set:function(T){x=""+T,S.call(this,T)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(T){x=""+T},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function Ve(l){l._valueTracker||(l._valueTracker=Te(l))}function He(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=Ne(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function gt(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 Pt(l,d){var p=d.checked;return G({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function wn(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=he(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 ht(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function At(l,d){ht(l,d);var p=he(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")?Pe(l,d.type,p):d.hasOwnProperty("defaultValue")&&Pe(l,d.type,he(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function te(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 Pe(l,d,p){(d!=="number"||gt(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Qe=Array.isArray;function xt(l,d,p,x){if(l=l.options,d){d={};for(var k=0;k"+d.valueOf().toString()+"",d=Dt.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function Xr(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var ir={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},me=["Webkit","ms","Moz","O"];Object.keys(ir).forEach(function(l){me.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),ir[d]=ir[l]})});function ve(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||ir.hasOwnProperty(l)&&ir[l]?(""+d).trim():d+"px"}function ar(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,k=ve(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,k):l[p]=k}}var Hs=G({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 ki(l,d){if(d){if(Hs[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 Si(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 Sr=null;function Aa(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var _r=null,Zr=null,or=null;function Ci(l){if(l=ac(l)){if(typeof _r!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Od(d),_r(l.stateNode,l.type,d))}}function Ia(l){Zr?or?or.push(l):or=[l]:Zr=l}function Ws(){if(Zr){var l=Zr,d=or;if(or=Zr=null,Ci(l),d)for(l=0;l>>=0,l===0?32:31-(Mn(l)/lr|0)|0}var Jt=64,_n=4194304;function ns(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 Ss(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,k=l.suspendedLanes,S=l.pingedLanes,T=p&268435455;if(T!==0){var B=T&~k;B!==0?x=ns(B):(S&=T,S!==0&&(x=ns(S)))}else T=p&~k,T!==0?x=ns(T):S!==0&&(x=ns(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&k)===0&&(k=x&-x,S=d&-d,k>=S||k===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 Qs(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-et(d),l[d]=p}function vd(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=Ql),ay=" ",oy=!1;function ly(l,d){switch(l){case"keyup":return a3.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Lo=!1;function l3(l,d){switch(l){case"compositionend":return cy(d);case"keypress":return d.which!==32?null:(oy=!0,ay);case"textInput":return l=d.data,l===ay&&oy?null:l;default:return null}}function c3(l,d){if(Lo)return l==="compositionend"||!Jf&&ly(l,d)?(l=ey(),jd=Hf=Ri=null,Lo=!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=gy(p)}}function yy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?yy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function vy(){for(var l=window,d=gt();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=gt(l.document)}return d}function Xf(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 y3(l){var d=vy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&yy(p.ownerDocument.documentElement,p)){if(x!==null&&Xf(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 k=p.textContent.length,S=Math.min(x.start,k);x=x.end===void 0?S:Math.min(x.end,k),!l.extend&&S>x&&(k=x,x=S,S=k),k=xy(p,S);var T=xy(p,x);k&&T&&(l.rangeCount!==1||l.anchorNode!==k.node||l.anchorOffset!==k.offset||l.focusNode!==T.node||l.focusOffset!==T.offset)&&(d=d.createRange(),d.setStart(k.node,k.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(T.node,T.offset)):(d.setEnd(T.node,T.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,_o=null,Zf=null,tc=null,ep=!1;function by(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;ep||_o==null||_o!==gt(x)||(x=_o,"selectionStart"in x&&Xf(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=Id(Zf,"onSelect"),0Vo||(l.current=hp[Vo],hp[Vo]=null,Vo--)}function Lt(l,d){Vo++,hp[Vo]=l.current,l.current=d}var Li={},qn=Di(Li),xr=Di(!1),za=Li;function Ho(l,d){var p=l.type.contextTypes;if(!p)return Li;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var k={},S;for(S in p)k[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=k),k}function yr(l){return l=l.childContextTypes,l!=null}function Dd(){Ht(xr),Ht(qn)}function Dy(l,d,p){if(qn.current!==Li)throw Error(n(168));Lt(qn,d),Lt(xr,p)}function Ly(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var k in x)if(!(k in d))throw Error(n(108,de(l)||"Unknown",k));return G({},p,x)}function Ld(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Li,za=qn.current,Lt(qn,l),Lt(xr,xr.current),!0}function _y(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Ly(l,d,za),x.__reactInternalMemoizedMergedChildContext=l,Ht(xr),Ht(qn),Lt(qn,l)):Ht(xr),Lt(xr,p)}var ei=null,_d=!1,fp=!1;function zy(l){ei===null?ei=[l]:ei.push(l)}function A3(l){_d=!0,zy(l)}function _i(){if(!fp&&ei!==null){fp=!0;var l=0,d=yt;try{var p=ei;for(yt=1;l>=T,k-=T,ti=1<<32-et(d)+k|p<tt?(Rn=Ye,Ye=null):Rn=Ye.sibling;var vt=be(se,Ye,le[tt],Ee);if(vt===null){Ye===null&&(Ye=Rn);break}l&&Ye&&vt.alternate===null&&d(se,Ye),Y=S(vt,Y,tt),Je===null?Be=vt:Je.sibling=vt,Je=vt,Ye=Rn}if(tt===le.length)return p(se,Ye),Yt&&Fa(se,tt),Be;if(Ye===null){for(;tttt?(Rn=Ye,Ye=null):Rn=Ye.sibling;var Ki=be(se,Ye,vt.value,Ee);if(Ki===null){Ye===null&&(Ye=Rn);break}l&&Ye&&Ki.alternate===null&&d(se,Ye),Y=S(Ki,Y,tt),Je===null?Be=Ki:Je.sibling=Ki,Je=Ki,Ye=Rn}if(vt.done)return p(se,Ye),Yt&&Fa(se,tt),Be;if(Ye===null){for(;!vt.done;tt++,vt=le.next())vt=ke(se,vt.value,Ee),vt!==null&&(Y=S(vt,Y,tt),Je===null?Be=vt:Je.sibling=vt,Je=vt);return Yt&&Fa(se,tt),Be}for(Ye=x(se,Ye);!vt.done;tt++,vt=le.next())vt=Oe(Ye,se,tt,vt.value,Ee),vt!==null&&(l&&vt.alternate!==null&&Ye.delete(vt.key===null?tt:vt.key),Y=S(vt,Y,tt),Je===null?Be=vt:Je.sibling=vt,Je=vt);return l&&Ye.forEach(function(dE){return d(se,dE)}),Yt&&Fa(se,tt),Be}function mn(se,Y,le,Ee){if(typeof le=="object"&&le!==null&&le.type===D&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case I:e:{for(var Be=le.key,Je=Y;Je!==null;){if(Je.key===Be){if(Be=le.type,Be===D){if(Je.tag===7){p(se,Je.sibling),Y=k(Je,le.props.children),Y.return=se,se=Y;break e}}else if(Je.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===F&&Wy(Be)===Je.type){p(se,Je.sibling),Y=k(Je,le.props),Y.ref=oc(se,Je,le),Y.return=se,se=Y;break e}p(se,Je);break}else d(se,Je);Je=Je.sibling}le.type===D?(Y=Ga(le.props.children,se.mode,Ee,le.key),Y.return=se,se=Y):(Ee=uu(le.type,le.key,le.props,null,se.mode,Ee),Ee.ref=oc(se,Y,le),Ee.return=se,se=Ee)}return T(se);case O:e:{for(Je=le.key;Y!==null;){if(Y.key===Je)if(Y.tag===4&&Y.stateNode.containerInfo===le.containerInfo&&Y.stateNode.implementation===le.implementation){p(se,Y.sibling),Y=k(Y,le.children||[]),Y.return=se,se=Y;break e}else{p(se,Y);break}else d(se,Y);Y=Y.sibling}Y=dm(le,se.mode,Ee),Y.return=se,se=Y}return T(se);case F:return Je=le._init,mn(se,Y,Je(le._payload),Ee)}if(Qe(le))return _e(se,Y,le,Ee);if(ae(le))return Fe(se,Y,le,Ee);Bd(se,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,Y!==null&&Y.tag===6?(p(se,Y.sibling),Y=k(Y,le),Y.return=se,se=Y):(p(se,Y),Y=cm(le,se.mode,Ee),Y.return=se,se=Y),T(se)):p(se,Y)}return mn}var qo=Uy(!0),Ky=Uy(!1),Vd=Di(null),Hd=null,Go=null,vp=null;function bp(){vp=Go=Hd=null}function Np(l){var d=Vd.current;Ht(Vd),l._currentValue=d}function wp(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 Jo(l,d){Hd=l,vp=Go=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(vr=!0),l.firstContext=null)}function Vr(l){var d=l._currentValue;if(vp!==l)if(l={context:l,memoizedValue:d,next:null},Go===null){if(Hd===null)throw Error(n(308));Go=l,Hd.dependencies={lanes:0,firstContext:l}}else Go=Go.next=l;return d}var Ba=null;function jp(l){Ba===null?Ba=[l]:Ba.push(l)}function qy(l,d,p,x){var k=d.interleaved;return k===null?(p.next=p,jp(d)):(p.next=k.next,k.next=p),d.interleaved=p,ri(l,x)}function ri(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 zi=!1;function kp(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Gy(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 si(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function $i(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(mt&2)!==0){var k=x.pending;return k===null?d.next=d:(d.next=k.next,k.next=d),x.pending=d,ri(l,p)}return k=x.interleaved,k===null?(d.next=d,jp(x)):(d.next=k.next,k.next=d),x.interleaved=d,ri(l,p)}function Wd(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,Po(l,p)}}function Jy(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var k=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var T={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?k=S=T:S=S.next=T,p=p.next}while(p!==null);S===null?k=S=d:S=S.next=d}else k=S=d;p={baseState:x.baseState,firstBaseUpdate:k,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 Ud(l,d,p,x){var k=l.updateQueue;zi=!1;var S=k.firstBaseUpdate,T=k.lastBaseUpdate,B=k.shared.pending;if(B!==null){k.shared.pending=null;var q=B,ue=q.next;q.next=null,T===null?S=ue:T.next=ue,T=q;var we=l.alternate;we!==null&&(we=we.updateQueue,B=we.lastBaseUpdate,B!==T&&(B===null?we.firstBaseUpdate=ue:B.next=ue,we.lastBaseUpdate=q))}if(S!==null){var ke=k.baseState;T=0,we=ue=q=null,B=S;do{var be=B.lane,Oe=B.eventTime;if((x&be)===be){we!==null&&(we=we.next={eventTime:Oe,lane:0,tag:B.tag,payload:B.payload,callback:B.callback,next:null});e:{var _e=l,Fe=B;switch(be=d,Oe=p,Fe.tag){case 1:if(_e=Fe.payload,typeof _e=="function"){ke=_e.call(Oe,ke,be);break e}ke=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Fe.payload,be=typeof _e=="function"?_e.call(Oe,ke,be):_e,be==null)break e;ke=G({},ke,be);break e;case 2:zi=!0}}B.callback!==null&&B.lane!==0&&(l.flags|=64,be=k.effects,be===null?k.effects=[B]:be.push(B))}else Oe={eventTime:Oe,lane:be,tag:B.tag,payload:B.payload,callback:B.callback,next:null},we===null?(ue=we=Oe,q=ke):we=we.next=Oe,T|=be;if(B=B.next,B===null){if(B=k.shared.pending,B===null)break;be=B,B=be.next,be.next=null,k.lastBaseUpdate=be,k.shared.pending=null}}while(!0);if(we===null&&(q=ke),k.baseState=q,k.firstBaseUpdate=ue,k.lastBaseUpdate=we,d=k.shared.interleaved,d!==null){k=d;do T|=k.lane,k=k.next;while(k!==d)}else S===null&&(k.shared.lanes=0);Wa|=T,l.lanes=T,l.memoizedState=ke}}function Yy(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Mp.transition;Mp.transition={};try{l(!1),d()}finally{yt=p,Mp.transition=x}}function mv(){return Hr().memoizedState}function O3(l,d,p){var x=Hi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},gv(l))xv(d,p);else if(p=qy(l,d,p,x),p!==null){var k=dr();ds(p,l,x,k),yv(p,d,x)}}function D3(l,d,p){var x=Hi(l),k={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(gv(l))xv(d,k);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var T=d.lastRenderedState,B=S(T,p);if(k.hasEagerState=!0,k.eagerState=B,ss(B,T)){var q=d.interleaved;q===null?(k.next=k,jp(d)):(k.next=q.next,q.next=k),d.interleaved=k;return}}catch{}finally{}p=qy(l,d,k,x),p!==null&&(k=dr(),ds(p,l,x,k),yv(p,d,x))}}function gv(l){var d=l.alternate;return l===en||d!==null&&d===en}function xv(l,d){uc=Gd=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function yv(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Po(l,p)}}var Qd={readContext:Vr,useCallback:Gn,useContext:Gn,useEffect:Gn,useImperativeHandle:Gn,useInsertionEffect:Gn,useLayoutEffect:Gn,useMemo:Gn,useReducer:Gn,useRef:Gn,useState:Gn,useDebugValue:Gn,useDeferredValue:Gn,useTransition:Gn,useMutableSource:Gn,useSyncExternalStore:Gn,useId:Gn,unstable_isNewReconciler:!1},L3={readContext:Vr,useCallback:function(l,d){return Ms().memoizedState=[l,d===void 0?null:d],l},useContext:Vr,useEffect:ov,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Jd(4194308,4,dv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Jd(4194308,4,l,d)},useInsertionEffect:function(l,d){return Jd(4,2,l,d)},useMemo:function(l,d){var p=Ms();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=Ms();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=O3.bind(null,en,l),[x.memoizedState,l]},useRef:function(l){var d=Ms();return l={current:l},d.memoizedState=l},useState:iv,useDebugValue:Lp,useDeferredValue:function(l){return Ms().memoizedState=l},useTransition:function(){var l=iv(!1),d=l[0];return l=P3.bind(null,l[1]),Ms().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=en,k=Ms();if(Yt){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),In===null)throw Error(n(349));(Ha&30)!==0||ev(x,d,p)}k.memoizedState=p;var S={value:p,getSnapshot:d};return k.queue=S,ov(nv.bind(null,x,S,l),[l]),x.flags|=2048,pc(9,tv.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=Ms(),d=In.identifierPrefix;if(Yt){var p=ni,x=ti;p=(x&~(1<<32-et(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=hc++,0<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=T.createElement(p,{is:x.is}):(l=T.createElement(p),p==="select"&&(T=l,x.multiple?T.multiple=!0:x.size&&(T.size=x.size))):l=T.createElementNS(l,p),l[Es]=d,l[ic]=x,zv(l,d,!1,!1),d.stateNode=l;e:{switch(T=Si(p,x),p){case"dialog":Vt("cancel",l),Vt("close",l),k=x;break;case"iframe":case"object":case"embed":Vt("load",l),k=x;break;case"video":case"audio":for(k=0;kel&&(d.flags|=128,x=!0,mc(S,!1),d.lanes=4194304)}else{if(!x)if(l=Kd(T),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),mc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!T.alternate&&!Yt)return Jn(d),null}else 2*Tt()-S.renderingStartTime>el&&p!==1073741824&&(d.flags|=128,x=!0,mc(S,!1),d.lanes=4194304);S.isBackwards?(T.sibling=d.child,d.child=T):(p=S.last,p!==null?p.sibling=T:d.child=T,S.last=T)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=Tt(),d.sibling=null,p=Zt.current,Lt(Zt,x?p&1|2:p&1),d):(Jn(d),null);case 22:case 23:return am(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Ar&1073741824)!==0&&(Jn(d),d.subtreeFlags&6&&(d.flags|=8192)):Jn(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function W3(l,d){switch(mp(d),d.tag){case 1:return yr(d.type)&&Dd(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Yo(),Ht(xr),Ht(qn),Tp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Cp(d),null;case 13:if(Ht(Zt),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Ko()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return Ht(Zt),null;case 4:return Yo(),null;case 10:return Np(d.type._context),null;case 22:case 23:return am(),null;case 24:return null;default:return null}}var tu=!1,Yn=!1,U3=typeof WeakSet=="function"?WeakSet:Set,De=null;function Xo(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){ln(l,d,x)}else p.current=null}function Gp(l,d,p){try{p()}catch(x){ln(l,d,x)}}var Bv=!1;function K3(l,d){if(ap=Nd,l=vy(),Xf(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 k=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var T=0,B=-1,q=-1,ue=0,we=0,ke=l,be=null;t:for(;;){for(var Oe;ke!==p||k!==0&&ke.nodeType!==3||(B=T+k),ke!==S||x!==0&&ke.nodeType!==3||(q=T+x),ke.nodeType===3&&(T+=ke.nodeValue.length),(Oe=ke.firstChild)!==null;)be=ke,ke=Oe;for(;;){if(ke===l)break t;if(be===p&&++ue===k&&(B=T),be===S&&++we===x&&(q=T),(Oe=ke.nextSibling)!==null)break;ke=be,be=ke.parentNode}ke=Oe}p=B===-1||q===-1?null:{start:B,end:q}}else p=null}p=p||{start:0,end:0}}else p=null;for(op={focusedElem:l,selectionRange:p},Nd=!1,De=d;De!==null;)if(d=De,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,De=l;else for(;De!==null;){d=De;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 Fe=_e.memoizedProps,mn=_e.memoizedState,se=d.stateNode,Y=se.getSnapshotBeforeUpdate(d.elementType===d.type?Fe:as(d.type,Fe),mn);se.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var le=d.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ee){ln(d,d.return,Ee)}if(l=d.sibling,l!==null){l.return=d.return,De=l;break}De=d.return}return _e=Bv,Bv=!1,_e}function gc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var k=x=x.next;do{if((k.tag&l)===l){var S=k.destroy;k.destroy=void 0,S!==void 0&&Gp(d,p,S)}k=k.next}while(k!==x)}}function nu(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 Jp(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 Vv(l){var d=l.alternate;d!==null&&(l.alternate=null,Vv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Es],delete d[ic],delete d[up],delete d[T3],delete d[M3])),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 Hv(l){return l.tag===5||l.tag===3||l.tag===4}function Wv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Hv(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 Yp(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=Pd));else if(x!==4&&(l=l.child,l!==null))for(Yp(l,d,p),l=l.sibling;l!==null;)Yp(l,d,p),l=l.sibling}function Qp(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(Qp(l,d,p),l=l.sibling;l!==null;)Qp(l,d,p),l=l.sibling}var zn=null,ls=!1;function Fi(l,d,p){for(p=p.child;p!==null;)Uv(l,d,p),p=p.sibling}function Uv(l,d,p){if(Re&&typeof Re.onCommitFiberUnmount=="function")try{Re.onCommitFiberUnmount(V,p)}catch{}switch(p.tag){case 5:Yn||Xo(p,d);case 6:var x=zn,k=ls;zn=null,Fi(l,d,p),zn=x,ls=k,zn!==null&&(ls?(l=zn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):zn.removeChild(p.stateNode));break;case 18:zn!==null&&(ls?(l=zn,p=p.stateNode,l.nodeType===8?dp(l.parentNode,p):l.nodeType===1&&dp(l,p),Gl(l)):dp(zn,p.stateNode));break;case 4:x=zn,k=ls,zn=p.stateNode.containerInfo,ls=!0,Fi(l,d,p),zn=x,ls=k;break;case 0:case 11:case 14:case 15:if(!Yn&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){k=x=x.next;do{var S=k,T=S.destroy;S=S.tag,T!==void 0&&((S&2)!==0||(S&4)!==0)&&Gp(p,d,T),k=k.next}while(k!==x)}Fi(l,d,p);break;case 1:if(!Yn&&(Xo(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(B){ln(p,d,B)}Fi(l,d,p);break;case 21:Fi(l,d,p);break;case 22:p.mode&1?(Yn=(x=Yn)||p.memoizedState!==null,Fi(l,d,p),Yn=x):Fi(l,d,p);break;default:Fi(l,d,p)}}function Kv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new U3),d.forEach(function(x){var k=tE.bind(null,l,x);p.has(x)||(p.add(x),x.then(k,k))})}}function cs(l,d){var p=d.deletions;if(p!==null)for(var x=0;xk&&(k=T),x&=~S}if(x=k,x=Tt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*G3(x/1960))-x,10l?16:l,Vi===null)var x=!1;else{if(l=Vi,Vi=null,ou=0,(mt&6)!==0)throw Error(n(331));var k=mt;for(mt|=4,De=l.current;De!==null;){var S=De,T=S.child;if((De.flags&16)!==0){var B=S.deletions;if(B!==null){for(var q=0;qTt()-em?Ka(l,0):Zp|=p),Nr(l,d)}function ib(l,d){d===0&&((l.mode&1)===0?d=1:(d=_n,_n<<=1,(_n&130023424)===0&&(_n=4194304)));var p=dr();l=ri(l,d),l!==null&&(Qs(l,d,p),Nr(l,p))}function eE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),ib(l,p)}function tE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,k=l.memoizedState;k!==null&&(p=k.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),ib(l,p)}var ab;ab=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||xr.current)vr=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return vr=!1,V3(l,d,p);vr=(l.flags&131072)!==0}else vr=!1,Yt&&(d.flags&1048576)!==0&&$y(d,$d,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;eu(l,d),l=d.pendingProps;var k=Ho(d,qn.current);Jo(d,p),k=Ip(null,d,x,l,k,p);var S=Rp();return d.flags|=1,typeof k=="object"&&k!==null&&typeof k.render=="function"&&k.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,yr(x)?(S=!0,Ld(d)):S=!1,d.memoizedState=k.state!==null&&k.state!==void 0?k.state:null,kp(d),k.updater=Xd,d.stateNode=k,k._reactInternals=d,zp(d,x,l,p),d=Vp(null,d,x,!0,S,p)):(d.tag=0,Yt&&S&&pp(d),cr(null,d,k,p),d=d.child),d;case 16:x=d.elementType;e:{switch(eu(l,d),l=d.pendingProps,k=x._init,x=k(x._payload),d.type=x,k=d.tag=rE(x),l=as(x,l),k){case 0:d=Bp(null,d,x,l,p);break e;case 1:d=Rv(null,d,x,l,p);break e;case 11:d=Ev(null,d,x,l,p);break e;case 14:d=Tv(null,d,x,as(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),Bp(l,d,x,k,p);case 1:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),Rv(l,d,x,k,p);case 3:e:{if(Pv(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,k=S.element,Gy(l,d),Ud(d,x,null,p);var T=d.memoizedState;if(x=T.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){k=Qo(Error(n(423)),d),d=Ov(l,d,x,p,k);break e}else if(x!==k){k=Qo(Error(n(424)),d),d=Ov(l,d,x,p,k);break e}else for(Mr=Oi(d.stateNode.containerInfo.firstChild),Tr=d,Yt=!0,is=null,p=Ky(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Ko(),x===k){d=ii(l,d,p);break e}cr(l,d,x,p)}d=d.child}return d;case 5:return Qy(d),l===null&&xp(d),x=d.type,k=d.pendingProps,S=l!==null?l.memoizedProps:null,T=k.children,lp(x,k)?T=null:S!==null&&lp(x,S)&&(d.flags|=32),Iv(l,d),cr(l,d,T,p),d.child;case 6:return l===null&&xp(d),null;case 13:return Dv(l,d,p);case 4:return Sp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=qo(d,null,x,p):cr(l,d,x,p),d.child;case 11:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),Ev(l,d,x,k,p);case 7:return cr(l,d,d.pendingProps,p),d.child;case 8:return cr(l,d,d.pendingProps.children,p),d.child;case 12:return cr(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,k=d.pendingProps,S=d.memoizedProps,T=k.value,Lt(Vd,x._currentValue),x._currentValue=T,S!==null)if(ss(S.value,T)){if(S.children===k.children&&!xr.current){d=ii(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var B=S.dependencies;if(B!==null){T=S.child;for(var q=B.firstContext;q!==null;){if(q.context===x){if(S.tag===1){q=si(-1,p&-p),q.tag=2;var ue=S.updateQueue;if(ue!==null){ue=ue.shared;var we=ue.pending;we===null?q.next=q:(q.next=we.next,we.next=q),ue.pending=q}}S.lanes|=p,q=S.alternate,q!==null&&(q.lanes|=p),wp(S.return,p,d),B.lanes|=p;break}q=q.next}}else if(S.tag===10)T=S.type===d.type?null:S.child;else if(S.tag===18){if(T=S.return,T===null)throw Error(n(341));T.lanes|=p,B=T.alternate,B!==null&&(B.lanes|=p),wp(T,p,d),T=S.sibling}else T=S.child;if(T!==null)T.return=S;else for(T=S;T!==null;){if(T===d){T=null;break}if(S=T.sibling,S!==null){S.return=T.return,T=S;break}T=T.return}S=T}cr(l,d,k.children,p),d=d.child}return d;case 9:return k=d.type,x=d.pendingProps.children,Jo(d,p),k=Vr(k),x=x(k),d.flags|=1,cr(l,d,x,p),d.child;case 14:return x=d.type,k=as(x,d.pendingProps),k=as(x.type,k),Tv(l,d,x,k,p);case 15:return Mv(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),eu(l,d),d.tag=1,yr(x)?(l=!0,Ld(d)):l=!1,Jo(d,p),bv(d,x,k),zp(d,x,k,p),Vp(null,d,x,!0,l,p);case 19:return _v(l,d,p);case 22:return Av(l,d,p)}throw Error(n(156,d.tag))};function ob(l,d){return To(l,d)}function nE(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 Ur(l,d,p,x){return new nE(l,d,p,x)}function lm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function rE(l){if(typeof l=="function")return lm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===ne)return 11;if(l===R)return 14}return 2}function Ui(l,d){var p=l.alternate;return p===null?(p=Ur(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 uu(l,d,p,x,k,S){var T=2;if(x=l,typeof l=="function")lm(l)&&(T=1);else if(typeof l=="string")T=5;else e:switch(l){case D:return Ga(p.children,k,S,d);case P:T=8,k|=8;break;case L:return l=Ur(12,p,d,k|2),l.elementType=L,l.lanes=S,l;case J:return l=Ur(13,p,d,k),l.elementType=J,l.lanes=S,l;case U:return l=Ur(19,p,d,k),l.elementType=U,l.lanes=S,l;case re:return hu(p,k,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case _:T=10;break e;case X:T=9;break e;case ne:T=11;break e;case R:T=14;break e;case F:T=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Ur(T,p,d,k),d.elementType=l,d.type=x,d.lanes=S,d}function Ga(l,d,p,x){return l=Ur(7,l,x,d),l.lanes=p,l}function hu(l,d,p,x){return l=Ur(22,l,x,d),l.elementType=re,l.lanes=p,l.stateNode={isHidden:!1},l}function cm(l,d,p){return l=Ur(6,l,null,d),l.lanes=p,l}function dm(l,d,p){return d=Ur(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function sE(l,d,p,x,k){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=Ro(0),this.expirationTimes=Ro(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ro(0),this.identifierPrefix=x,this.onRecoverableError=k,this.mutableSourceEagerHydrationData=null}function um(l,d,p,x,k,S,T,B,q){return l=new sE(l,d,p,B,q),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Ur(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},kp(S),l}function iE(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(),xm.exports=xE(),xm.exports}var Nb;function yE(){if(Nb)return vu;Nb=1;var t=Ew();return vu.createRoot=t.createRoot,vu.hydrateRoot=t.hydrateRoot,vu}var vE=yE(),dd=Ew();const Tw=Cw(dd);/** - * @remix-run/router v1.23.2 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function Kc(){return Kc=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Ex(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function NE(){return Math.random().toString(36).substr(2,8)}function jb(t,e){return{usr:t.state,key:t.key,idx:e}}function xg(t,e,n,r){return n===void 0&&(n=null),Kc({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Rl(e):e,{state:n,key:e&&e.key||r||NE()})}function sh(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Rl(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function wE(t,e,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,c=sa.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(Kc({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=sa.Pop;let w=f(),N=w==null?null:w-h;h=w,u&&u({action:c,location:j.location,delta:N})}function g(w,N){c=sa.Push;let C=xg(j.location,w,N);h=f()+1;let E=jb(C,h),M=j.createHref(C);try{o.pushState(E,"",M)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;i.location.assign(M)}a&&u&&u({action:c,location:j.location,delta:1})}function y(w,N){c=sa.Replace;let C=xg(j.location,w,N);h=f();let E=jb(C,h),M=j.createHref(C);o.replaceState(E,"",M),a&&u&&u({action:c,location:j.location,delta:0})}function b(w){let N=i.location.origin!=="null"?i.location.origin:i.location.href,C=typeof w=="string"?w:sh(w);return C=C.replace(/ $/,"%20"),xn(N,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,N)}let j={get action(){return c},get location(){return t(i,o)},listen(w){if(u)throw new Error("A history only accepts one active listener");return i.addEventListener(wb,m),u=w,()=>{i.removeEventListener(wb,m),u=null}},createHref(w){return e(i,w)},createURL:b,encodeLocation(w){let N=b(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:g,replace:y,go(w){return o.go(w)}};return j}var kb;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(kb||(kb={}));function jE(t,e,n){return n===void 0&&(n="/"),kE(t,e,n)}function kE(t,e,n,r){let i=typeof e=="string"?Rl(e):e,a=Tx(i.pathname||"/",n);if(a==null)return null;let o=Mw(t);SE(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?a.path||"":c,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};u.relativePath.startsWith("/")&&(xn(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let h=ca([r,u.relativePath]),f=n.concat(u);a.children&&a.children.length>0&&(xn(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Mw(a.children,e,f,h)),!(a.path==null&&!a.index)&&e.push({path:h,score:RE(h,a.index),routesMeta:f})};return t.forEach((a,o)=>{var c;if(a.path===""||!((c=a.path)!=null&&c.includes("?")))i(a,o);else for(let u of Aw(a.path))i(a,o,u)}),e}function Aw(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=Aw(r.join("/")),c=[];return c.push(...o.map(u=>u===""?a:[a,u].join("/"))),i&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function SE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:PE(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const CE=/^:[\w-]+$/,EE=3,TE=2,ME=1,AE=10,IE=-2,Sb=t=>t==="*";function RE(t,e){let n=t.split("/"),r=n.length;return n.some(Sb)&&(r+=IE),e&&(r+=TE),n.filter(i=>!Sb(i)).reduce((i,a)=>i+(CE.test(a)?EE:a===""?ME:AE),r)}function PE(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function OE(t,e,n){let{routesMeta:r}=t,i={},a="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let j=c[m]||"";o=a.slice(0,a.length-j.length).replace(/(.)\/+$/,"$1")}const b=c[m];return y&&!b?h[g]=void 0:h[g]=(b||"").replace(/%2F/g,"/"),h},{}),pathname:a,pathnameBase:o,pattern:t}}function LE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),Ex(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 r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(r.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function _E(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Ex(!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 Tx(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const zE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,$E=t=>zE.test(t);function FE(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Rl(t):t,a;if(n)if($E(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Ex(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?a=Cb(n.substring(1),"/"):a=Cb(n,e)}else a=e;return{pathname:a,search:HE(r),hash:WE(i)}}function Cb(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function bm(t,e,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. 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 BE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function Mx(t,e){let n=BE(t);return e?n.map((r,i)=>i===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Ax(t,e,n,r){r===void 0&&(r=!1);let i;typeof t=="string"?i=Rl(t):(i=Kc({},t),xn(!i.pathname||!i.pathname.includes("?"),bm("?","pathname","search",i)),xn(!i.pathname||!i.pathname.includes("#"),bm("#","pathname","hash",i)),xn(!i.search||!i.search.includes("#"),bm("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!r&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;i.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=FE(i,c),h=o&&o!=="/"&&o.endsWith("/"),f=(a||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const ca=t=>t.join("/").replace(/\/\/+/g,"/"),VE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),HE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,WE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function UE(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Iw=["post","put","patch","delete"];new Set(Iw);const KE=["get",...Iw];new Set(KE);/** - * React Router v6.30.3 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function qc(){return qc=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),v.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=Ax(h,JSON.parse(o),a,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:ca([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,a,t])}const YE=v.createContext(null);function QE(t){let e=v.useContext(wi).outlet;return e&&v.createElement(YE.Provider,{value:t},e)}function Ow(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=v.useContext(Na),{matches:i}=v.useContext(wi),{pathname:a}=wa(),o=JSON.stringify(Mx(i,r.v7_relativeSplatPath));return v.useMemo(()=>Ax(t,JSON.parse(o),a,n==="path"),[t,o,a,n])}function XE(t,e){return ZE(t,e)}function ZE(t,e,n,r){Pl()||xn(!1);let{navigator:i}=v.useContext(Na),{matches:a}=v.useContext(wi),o=a[a.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=wa(),f;if(e){var m;let w=typeof e=="string"?Rl(e):e;u==="/"||(m=w.pathname)!=null&&m.startsWith(u)||xn(!1),f=w}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let w=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(w.length).join("/")}let b=jE(t,{pathname:y}),j=sT(b&&b.map(w=>Object.assign({},w,{params:Object.assign({},c,w.params),pathname:ca([u,i.encodeLocation?i.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?u:ca([u,i.encodeLocation?i.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),a,n,r);return e&&j?v.createElement(cf.Provider,{value:{location:qc({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:sa.Pop}},j):j}function eT(){let t=lT(),e=UE(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return v.createElement(v.Fragment,null,v.createElement("h2",null,"Unexpected Application Error!"),v.createElement("h3",{style:{fontStyle:"italic"}},e),n?v.createElement("pre",{style:i},n):null,null)}const tT=v.createElement(eT,null);class nT extends v.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?v.createElement(wi.Provider,{value:this.props.routeContext},v.createElement(Rw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function rT(t){let{routeContext:e,match:n,children:r}=t,i=v.useContext(Ix);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),v.createElement(wi.Provider,{value:e},r)}function sT(t,e,n,r){var i;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var a;if(!n)return null;if(n.errors)t=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(i=n)==null?void 0:i.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||xn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&r&&r.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,b=!1,j=null,w=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,j=m.route.errorElement||tT,u&&(h<0&&g===0?(dT("route-fallback"),b=!0,w=null):h===g&&(b=!0,w=m.route.hydrateFallbackElement||null)));let N=e.concat(o.slice(0,g+1)),C=()=>{let E;return y?E=j:b?E=w:m.route.Component?E=v.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,v.createElement(rT,{match:m,routeContext:{outlet:f,matches:N,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?v.createElement(nT,{location:n.location,revalidation:n.revalidation,component:j,error:y,children:C(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):C()},null)}var Dw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Dw||{}),Lw=(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})(Lw||{});function iT(t){let e=v.useContext(Ix);return e||xn(!1),e}function aT(t){let e=v.useContext(qE);return e||xn(!1),e}function oT(t){let e=v.useContext(wi);return e||xn(!1),e}function _w(t){let e=oT(),n=e.matches[e.matches.length-1];return n.route.id||xn(!1),n.route.id}function lT(){var t;let e=v.useContext(Rw),n=aT(),r=_w();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function cT(){let{router:t}=iT(Dw.UseNavigateStable),e=_w(Lw.UseNavigateStable),n=v.useRef(!1);return Pw(()=>{n.current=!0}),v.useCallback(function(i,a){a===void 0&&(a={}),n.current&&(typeof i=="number"?t.navigate(i):t.navigate(i,qc({fromRouteId:e},a)))},[t,e])}const Eb={};function dT(t,e,n){Eb[t]||(Eb[t]=!0)}function uT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Nm(t){let{to:e,replace:n,state:r,relative:i}=t;Pl()||xn(!1);let{future:a,static:o}=v.useContext(Na),{matches:c}=v.useContext(wi),{pathname:u}=wa(),h=ja(),f=Ax(e,Mx(c,a.v7_relativeSplatPath),u,i==="path"),m=JSON.stringify(f);return v.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:i}),[h,m,i,n,r]),null}function hT(t){return QE(t.context)}function Wt(t){xn(!1)}function fT(t){let{basename:e="/",children:n=null,location:r,navigationType:i=sa.Pop,navigator:a,static:o=!1,future:c}=t;Pl()&&xn(!1);let u=e.replace(/^\/*/,"/"),h=v.useMemo(()=>({basename:u,navigator:a,static:o,future:qc({v7_relativeSplatPath:!1},c)}),[u,c,a,o]);typeof r=="string"&&(r=Rl(r));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:b="default"}=r,j=v.useMemo(()=>{let w=Tx(f,u);return w==null?null:{location:{pathname:w,search:m,hash:g,state:y,key:b},navigationType:i}},[u,f,m,g,y,b,i]);return j==null?null:v.createElement(Na.Provider,{value:h},v.createElement(cf.Provider,{children:n,value:j}))}function pT(t){let{children:e,location:n}=t;return XE(yg(e),n)}new Promise(()=>{});function yg(t,e){e===void 0&&(e=[]);let n=[];return v.Children.forEach(t,(r,i)=>{if(!v.isValidElement(r))return;let a=[...e,i];if(r.type===v.Fragment){n.push.apply(n,yg(r.props.children,a));return}r.type!==Wt&&xn(!1),!r.props.index||!r.props.children||xn(!1);let o={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=yg(r.props.children,a)),n.push(o)}),n}/** - * React Router DOM v6.30.3 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function vg(){return vg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[i]=t[i]);return n}function gT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function xT(t,e){return t.button===0&&(!e||e==="_self")&&!gT(t)}function bg(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function yT(t,e){let n=bg(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}const vT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],bT="6";try{window.__reactRouterVersion=bT}catch{}const NT="startTransition",Tb=lf[NT];function wT(t){let{basename:e,children:n,future:r,window:i}=t,a=v.useRef();a.current==null&&(a.current=bE({window:i,v5Compat:!0}));let o=a.current,[c,u]=v.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=v.useCallback(m=>{h&&Tb?Tb(()=>u(m)):u(m)},[u,h]);return v.useLayoutEffect(()=>o.listen(f),[o,f]),v.useEffect(()=>uT(r),[r]),v.createElement(fT,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const jT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ng=v.forwardRef(function(e,n){let{onClick:r,relative:i,reloadDocument:a,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=mT(e,vT),{basename:y}=v.useContext(Na),b,j=!1;if(typeof h=="string"&&kT.test(h)&&(b=h,jT))try{let E=new URL(window.location.href),M=h.startsWith("//")?new URL(E.protocol+h):new URL(h),I=Tx(M.pathname,y);M.origin===E.origin&&I!=null?h=I+M.search+M.hash:j=!0}catch{}let w=GE(h,{relative:i}),N=ST(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:i,viewTransition:m});function C(E){r&&r(E),E.defaultPrevented||N(E)}return v.createElement("a",vg({},g,{href:b||w,onClick:j||a?r:C,ref:n,target:u}))});var Mb;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Mb||(Mb={}));var Ab;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(Ab||(Ab={}));function ST(t,e){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,viewTransition:c}=e===void 0?{}:e,u=ja(),h=wa(),f=Ow(t,{relative:o});return v.useCallback(m=>{if(xT(m,n)){m.preventDefault();let g=r!==void 0?r:sh(h)===sh(f);u(t,{replace:g,state:i,preventScrollReset:a,relative:o,viewTransition:c})}},[h,u,f,r,i,n,t,a,o,c])}function zw(t){let e=v.useRef(bg(t)),n=v.useRef(!1),r=wa(),i=v.useMemo(()=>yT(r.search,n.current?null:e.current),[r.search]),a=ja(),o=v.useCallback((c,u)=>{const h=bg(typeof c=="function"?c(i):c);n.current=!0,a("?"+h,u)},[a,i]);return[i,o]}/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const CT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ET=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Ib=t=>{const e=ET(t);return e.charAt(0).toUpperCase()+e.slice(1)},$w=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),TT=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/** - * @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. - */var MT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @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 AT=v.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...c},u)=>v.createElement("svg",{ref:u,...MT,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:$w("lucide",i),...!a&&!TT(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>v.createElement(h,f)),...Array.isArray(a)?a:[a]]));/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ce=(t,e)=>{const n=v.forwardRef(({className:r,...i},a)=>v.createElement(AT,{ref:a,iconNode:e,className:$w(`lucide-${CT(Ib(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Ib(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 IT=[["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"}]],wm=Ce("arrow-up-down",IT);/** - * @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 RT=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Rb=Ce("bitcoin",RT);/** - * @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 PT=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],OT=Ce("bold",PT);/** - * @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 DT=[["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"}]],ps=Ce("book-open",DT);/** - * @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 LT=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],ih=Ce("calendar",LT);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _T=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],zT=Ce("chart-column",_T);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $T=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],df=Ce("check",$T);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const FT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Gc=Ce("chevron-down",FT);/** - * @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 BT=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],VT=Ce("chevron-left",BT);/** - * @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 HT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],fl=Ce("chevron-right",HT);/** - * @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 WT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Fw=Ce("chevron-up",WT);/** - * @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 UT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],KT=Ce("circle-alert",UT);/** - * @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 qT=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Pb=Ce("circle-check-big",qT);/** - * @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 GT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],wg=Ce("circle-check",GT);/** - * @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 JT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Bw=Ce("circle-question-mark",JT);/** - * @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 YT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],jm=Ce("circle-user",YT);/** - * @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 QT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Vw=Ce("circle-x",QT);/** - * @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 XT=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],jg=Ce("clock",XT);/** - * @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 ZT=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],eM=Ce("code",ZT);/** - * @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 tM=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Hw=Ce("copy",tM);/** - * @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 nM=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Ob=Ce("credit-card",nM);/** - * @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 rM=[["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"}]],xl=Ce("crown",rM);/** - * @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 sM=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ah=Ce("dollar-sign",sM);/** - * @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 iM=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],aM=Ce("download",iM);/** - * @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 oM=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],_s=Ce("external-link",oM);/** - * @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 lM=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],oh=Ce("eye",lM);/** - * @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 cM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],dM=Ce("file-text",cM);/** - * @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 uM=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Ww=Ce("funnel",uM);/** - * @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 hM=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],fM=Ce("gift",hM);/** - * @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 pM=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],mM=Ce("git-merge",pM);/** - * @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 gM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],kg=Ce("globe",gM);/** - * @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 xM=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],yM=Ce("graduation-cap",xM);/** - * @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 vM=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],oi=Ce("grip-vertical",vM);/** - * @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 bM=[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]],NM=Ce("handshake",bM);/** - * @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 wM=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Db=Ce("hash",wM);/** - * @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 jM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],kM=Ce("heading-1",jM);/** - * @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 SM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],CM=Ce("heading-2",SM);/** - * @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 EM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],TM=Ce("heading-3",EM);/** - * @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 MM=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],AM=Ce("house",MM);/** - * @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 IM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Uw=Ce("image",IM);/** - * @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 RM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],bu=Ce("info",RM);/** - * @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 PM=[["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"}]],OM=Ce("italic",PM);/** - * @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 DM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],LM=Ce("key",DM);/** - * @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 _M=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],zM=Ce("layout-dashboard",_M);/** - * @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 $M=[["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"}]],ms=Ce("link-2",$M);/** - * @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=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Sg=Ce("link",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 BM=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],VM=Ce("list-ordered",BM);/** - * @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 HM=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],WM=Ce("list",HM);/** - * @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 UM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],KM=Ce("lock",UM);/** - * @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 qM=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],GM=Ce("log-out",qM);/** - * @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 JM=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Kw=Ce("map-pin",JM);/** - * @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 YM=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],QM=Ce("menu",YM);/** - * @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 XM=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],ZM=Ce("message-circle",XM);/** - * @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 eA=[["path",{d:"M5 12h14",key:"1ays0h"}]],tA=Ce("minus",eA);/** - * @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 nA=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],pl=Ce("navigation",nA);/** - * @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 rA=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],sA=Ce("palette",rA);/** - * @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 iA=[["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"}]],_t=Ce("pen-line",iA);/** - * @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 aA=[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],qw=Ce("pencil",aA);/** - * @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 oA=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],lA=Ce("percent",oA);/** - * @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 cA=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],dA=Ce("phone",cA);/** - * @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 uA=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],hA=Ce("pin",uA);/** - * @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 fA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],dn=Ce("plus",fA);/** - * @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 pA=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Lb=Ce("qr-code",pA);/** - * @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 mA=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],gA=Ce("quote",mA);/** - * @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 xA=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],yA=Ce("redo",xA);/** - * @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 vA=[["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"}]],Ge=Ce("refresh-cw",vA);/** - * @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 bA=[["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"}]],gn=Ce("save",bA);/** - * @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 NA=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],da=Ce("search",NA);/** - * @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 wA=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],jA=Ce("send",wA);/** - * @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 kA=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],so=Ce("settings",kA);/** - * @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 SA=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Nu=Ce("settings-2",SA);/** - * @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 CA=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Rx=Ce("shield-check",CA);/** - * @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 EA=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],Cg=Ce("shopping-bag",EA);/** - * @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 TA=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],uo=Ce("smartphone",TA);/** - * @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 MA=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],ml=Ce("star",MA);/** - * @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 AA=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],IA=Ce("strikethrough",AA);/** - * @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 RA=[["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"}]],PA=Ce("table",RA);/** - * @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 OA=[["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"}]],qu=Ce("tag",OA);/** - * @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 DA=[["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"}]],Bn=Ce("trash-2",DA);/** - * @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 LA=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Oc=Ce("trending-up",LA);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _A=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],_b=Ce("trophy",_A);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const zA=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Gw=Ce("undo-2",zA);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $A=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],FA=Ce("undo",$A);/** - * @license lucide-react v0.562.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const BA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],lh=Ce("upload",BA);/** - * @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 VA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Eg=Ce("user-plus",VA);/** - * @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 HA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],yl=Ce("user",HA);/** - * @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 WA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Un=Ce("users",WA);/** - * @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 UA=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],jl=Ce("wallet",UA);/** - * @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 KA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],hr=Ce("x",KA);/** - * @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 qA=[["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"}]],ia=Ce("zap",qA),Px="admin_token";function Ox(){try{return localStorage.getItem(Px)}catch{return null}}function GA(t){try{localStorage.setItem(Px,t)}catch{}}function JA(){try{localStorage.removeItem(Px)}catch{}}const YA="https://soulapi.quwanzhi.com",QA=15e3,XA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):YA};function ho(t){const e=XA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function uf(t,e={}){const{data:n,...r}=e,i=ho(t),a=new Headers(r.headers),o=Ox();o&&a.set("Authorization",`Bearer ${o}`),n!=null&&!a.has("Content-Type")&&a.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):r.body,u=new AbortController,h=setTimeout(()=>u.abort(),QA),f=await fetch(i,{...r,headers:a,body:c,credentials:"include",signal:u.signal}).finally(()=>clearTimeout(h)),g=(f.headers.get("Content-Type")||"").includes("application/json")?await f.json():f;if(!f.ok){const y=new Error((g==null?void 0:g.error)||`HTTP ${f.status}`);throw y.status=f.status,y.data=g,y}return g}function Le(t,e){return uf(t,{...e,method:"GET"})}function Nt(t,e,n){return uf(t,{...n,method:"POST",data:e})}function Mt(t,e,n){return uf(t,{...n,method:"PUT",data:e})}function Ps(t,e){return uf(t,{...e,method:"DELETE"})}const ZA=[{icon:zM,label:"数据概览",href:"/dashboard"},{icon:ps,label:"内容管理",href:"/content"},{icon:Un,label:"用户管理",href:"/users"},{icon:mM,label:"找伙伴",href:"/find-partner"},{icon:jl,label:"推广中心",href:"/distribution"}];function e5(){const t=wa(),e=ja(),[n,r]=v.useState(!1),[i,a]=v.useState(!1);v.useEffect(()=>{r(!0)},[]),v.useEffect(()=>{if(!n)return;a(!1);let c=!1;return Le("/api/admin").then(u=>{c||(u&&u.success!==!1?a(!0):e("/login",{replace:!0}))}).catch(()=>{c||e("/login",{replace:!0})}),()=>{c=!0}},[n,e]);const o=async()=>{JA();try{await Nt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!i?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[ZA.map(c=>{const u=t.pathname===c.href;return s.jsxs(Ng,{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:[s.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),s.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:s.jsxs(Ng,{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:[s.jsx(so,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.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:[s.jsx(GM,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsx("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0",children:s.jsx("div",{className:"w-full min-w-[1024px] min-h-full",children:s.jsx(hT,{})})})]})}function zb(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Dx(...t){return e=>{let n=!1;const r=t.map(i=>{const a=zb(i,e);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i{let{children:a,...o}=r;Jw(a)&&typeof ch=="function"&&(a=ch(a._payload));const c=v.Children.toArray(a),u=c.find(i5);if(u){const h=u.props.children,f=c.map(m=>m===u?v.Children.count(h)>1?v.Children.only(null):v.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:i,children:v.isValidElement(h)?v.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:i,children:a})});return n.displayName=`${t}.Slot`,n}var Qw=Yw("Slot");function r5(t){const e=v.forwardRef((n,r)=>{let{children:i,...a}=n;if(Jw(i)&&typeof ch=="function"&&(i=ch(i._payload)),v.isValidElement(i)){const o=o5(i),c=a5(a,i.props);return i.type!==v.Fragment&&(c.ref=r?Dx(r,o):o),v.cloneElement(i,c)}return v.Children.count(i)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var s5=Symbol("radix.slottable");function i5(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===s5}function a5(t,e){const n={...e};for(const r in e){const i=t[r],a=e[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...c)=>{const u=a(...c);return i(...c),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...t,...n}}function o5(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Xw(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,Fb=Zw,ej=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return Fb(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(h=>{const f=n==null?void 0:n[h],m=a==null?void 0:a[h];if(f===null)return null;const g=$b(f)||$b(m);return i[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||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(b=>{let[j,w]=b;return Array.isArray(w)?w.includes({...a,...c}[j]):{...a,...c}[j]===w})?[...h,m,g]:h},[]);return Fb(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},l5=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),tj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),dh="-",Bb=[],d5="arbitrary..",u5=t=>{const e=f5(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return h5(o);const c=o.split(dh),u=c[0]===""&&c.length>1?1:0;return nj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?l5(h,u):u:h||Bb}return n[o]||Bb}}},nj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const i=t[e],a=n.nextPart.get(i);if(a){const h=nj(t,e+1,a);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(dh):t.slice(e).join(dh),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?d5+r:void 0})(),f5=t=>{const{theme:e,classGroups:n}=t;return p5(n,e)},p5=(t,e)=>{const n=tj();for(const r in t){const i=t[r];Lx(i,n,r,e)}return n},Lx=(t,e,n,r)=>{const i=t.length;for(let a=0;a{if(typeof t=="string"){g5(t,e,n);return}if(typeof t=="function"){x5(t,e,n,r);return}y5(t,e,n,r)},g5=(t,e,n)=>{const r=t===""?e:rj(e,t);r.classGroupId=n},x5=(t,e,n,r)=>{if(v5(t)){Lx(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(c5(n,t))},y5=(t,e,n,r)=>{const i=Object.entries(t),a=i.length;for(let o=0;o{let n=t;const r=e.split(dh),i=r.length;for(let a=0;a"isThemeGetter"in t&&t.isThemeGetter===!0,b5=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const i=(a,o)=>{n[a]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(a){let o=n[a];if(o!==void 0)return o;if((o=r[a])!==void 0)return i(a,o),o},set(a,o){a in n?n[a]=o:i(a,o)}}},Tg="!",Vb=":",N5=[],Hb=(t,e,n,r,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),w5=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=i=>{const a=[];let o=0,c=0,u=0,h;const f=i.length;for(let j=0;ju?h-u:void 0;return Hb(a,y,g,b)};if(e){const i=e+Vb,a=r;r=o=>o.startsWith(i)?a(o.slice(i.length)):Hb(N5,!1,o,void 0,!0)}if(n){const i=r;r=a=>n({className:a,parseClassName:i})}return r},j5=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let a=0;a0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},k5=t=>({cache:b5(t.cacheSize),parseClassName:w5(t),sortModifiers:j5(t),...u5(t)}),S5=/\s+/,C5=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=e,o=[],c=t.trim().split(S5);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:b,maybePostfixModifierPosition:j}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let w=!!j,N=r(w?b.substring(0,j):b);if(!N){if(!w){u=f+(u.length>0?" "+u:u);continue}if(N=r(b),!N){u=f+(u.length>0?" "+u:u);continue}w=!1}const C=g.length===0?"":g.length===1?g[0]:a(g).join(":"),E=y?C+Tg:C,M=E+N;if(o.indexOf(M)>-1)continue;o.push(M);const I=i(N,w);for(let O=0;O0?" "+u:u)}return u},E5=(...t)=>{let e=0,n,r,i="";for(;e{if(typeof t=="string")return t;let e,n="";for(let r=0;r{let n,r,i,a;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=k5(h),r=n.cache.get,i=n.cache.set,a=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=C5(u,n);return i(u,f),f};return a=o,(...u)=>a(E5(...u))},M5=[],Cn=t=>{const e=n=>n[t]||M5;return e.isThemeGetter=!0,e},ij=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,aj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,A5=/^\d+\/\d+$/,I5=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,R5=/\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$/,P5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,O5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,D5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nl=t=>A5.test(t),ct=t=>!!t&&!Number.isNaN(Number(t)),qi=t=>!!t&&Number.isInteger(Number(t)),km=t=>t.endsWith("%")&&ct(t.slice(0,-1)),li=t=>I5.test(t),L5=()=>!0,_5=t=>R5.test(t)&&!P5.test(t),oj=()=>!1,z5=t=>O5.test(t),$5=t=>D5.test(t),F5=t=>!ze(t)&&!$e(t),B5=t=>Ol(t,dj,oj),ze=t=>ij.test(t),Ja=t=>Ol(t,uj,_5),Sm=t=>Ol(t,K5,ct),Wb=t=>Ol(t,lj,oj),V5=t=>Ol(t,cj,$5),wu=t=>Ol(t,hj,z5),$e=t=>aj.test(t),wc=t=>Dl(t,uj),H5=t=>Dl(t,q5),Ub=t=>Dl(t,lj),W5=t=>Dl(t,dj),U5=t=>Dl(t,cj),ju=t=>Dl(t,hj,!0),Ol=(t,e,n)=>{const r=ij.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Dl=(t,e,n=!1)=>{const r=aj.exec(t);return r?r[1]?e(r[1]):n:!1},lj=t=>t==="position"||t==="percentage",cj=t=>t==="image"||t==="url",dj=t=>t==="length"||t==="size"||t==="bg-size",uj=t=>t==="length",K5=t=>t==="number",q5=t=>t==="family-name",hj=t=>t==="shadow",G5=()=>{const t=Cn("color"),e=Cn("font"),n=Cn("text"),r=Cn("font-weight"),i=Cn("tracking"),a=Cn("leading"),o=Cn("breakpoint"),c=Cn("container"),u=Cn("spacing"),h=Cn("radius"),f=Cn("shadow"),m=Cn("inset-shadow"),g=Cn("text-shadow"),y=Cn("drop-shadow"),b=Cn("blur"),j=Cn("perspective"),w=Cn("aspect"),N=Cn("ease"),C=Cn("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"],I=()=>[...M(),$e,ze],O=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],P=()=>[$e,ze,u],L=()=>[nl,"full","auto",...P()],_=()=>[qi,"none","subgrid",$e,ze],X=()=>["auto",{span:["full",qi,$e,ze]},qi,$e,ze],ne=()=>[qi,"auto",$e,ze],J=()=>["auto","min","max","fr",$e,ze],U=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],F=()=>["auto",...P()],re=()=>[nl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],z=()=>[t,$e,ze],ae=()=>[...M(),Ub,Wb,{position:[$e,ze]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],$=()=>["auto","cover","contain",W5,B5,{size:[$e,ze]}],H=()=>[km,wc,Ja],ce=()=>["","none","full",h,$e,ze],W=()=>["",ct,wc,Ja],fe=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>[ct,km,Ub,Wb],he=()=>["","none",b,$e,ze],Ne=()=>["none",ct,$e,ze],Te=()=>["none",ct,$e,ze],Ve=()=>[ct,$e,ze],He=()=>[nl,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[li],breakpoint:[li],color:[L5],container:[li],"drop-shadow":[li],ease:["in","out","in-out"],font:[F5],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[li],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[li],shadow:[li],spacing:["px",ct],text:[li],"text-shadow":[li],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",nl,ze,$e,w]}],container:["container"],columns:[{columns:[ct,ze,$e,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:I()}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[qi,"auto",$e,ze]}],basis:[{basis:[nl,"full","auto",c,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ct,nl,"auto","initial","none",ze]}],grow:[{grow:["",ct,$e,ze]}],shrink:[{shrink:["",ct,$e,ze]}],order:[{order:[qi,"first","last","none",$e,ze]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:X()}],"col-start":[{"col-start":ne()}],"col-end":[{"col-end":ne()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:X()}],"row-start":[{"row-start":ne()}],"row-end":[{"row-end":ne()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...U(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...U()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":U()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:F()}],mx:[{mx:F()}],my:[{my:F()}],ms:[{ms:F()}],me:[{me:F()}],mt:[{mt:F()}],mr:[{mr:F()}],mb:[{mb:F()}],ml:[{ml:F()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:re()}],w:[{w:[c,"screen",...re()]}],"min-w":[{"min-w":[c,"screen","none",...re()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...re()]}],h:[{h:["screen","lh",...re()]}],"min-h":[{"min-h":["screen","lh","none",...re()]}],"max-h":[{"max-h":["screen","lh",...re()]}],"font-size":[{text:["base",n,wc,Ja]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,$e,Sm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",km,ze]}],"font-family":[{font:[H5,ze,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:[i,$e,ze]}],"line-clamp":[{"line-clamp":[ct,"none",$e,Sm]}],leading:[{leading:[a,...P()]}],"list-image":[{"list-image":["none",$e,ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",$e,ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...fe(),"wavy"]}],"text-decoration-thickness":[{decoration:[ct,"from-font","auto",$e,Ja]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[ct,"auto",$e,ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$e,ze]}],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",$e,ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ae()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:$()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qi,$e,ze],radial:["",$e,ze],conic:[qi,$e,ze]},U5,V5]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...fe(),"hidden","none"]}],"divide-style":[{divide:[...fe(),"hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:[...fe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ct,$e,ze]}],"outline-w":[{outline:["",ct,wc,Ja]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",f,ju,wu]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",m,ju,wu]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[ct,Ja]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",g,ju,wu]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[ct,$e,ze]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"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":[ct]}],"mask-image-linear-from-pos":[{"mask-linear-from":de()}],"mask-image-linear-to-pos":[{"mask-linear-to":de()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":de()}],"mask-image-t-to-pos":[{"mask-t-to":de()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":de()}],"mask-image-r-to-pos":[{"mask-r-to":de()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":de()}],"mask-image-b-to-pos":[{"mask-b-to":de()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":de()}],"mask-image-l-to-pos":[{"mask-l-to":de()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":de()}],"mask-image-x-to-pos":[{"mask-x-to":de()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":de()}],"mask-image-y-to-pos":[{"mask-y-to":de()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[$e,ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":de()}],"mask-image-radial-to-pos":[{"mask-radial-to":de()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"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":[ct]}],"mask-image-conic-from-pos":[{"mask-conic-from":de()}],"mask-image-conic-to-pos":[{"mask-conic-to":de()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ae()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:$()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",$e,ze]}],filter:[{filter:["","none",$e,ze]}],blur:[{blur:he()}],brightness:[{brightness:[ct,$e,ze]}],contrast:[{contrast:[ct,$e,ze]}],"drop-shadow":[{"drop-shadow":["","none",y,ju,wu]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",ct,$e,ze]}],"hue-rotate":[{"hue-rotate":[ct,$e,ze]}],invert:[{invert:["",ct,$e,ze]}],saturate:[{saturate:[ct,$e,ze]}],sepia:[{sepia:["",ct,$e,ze]}],"backdrop-filter":[{"backdrop-filter":["","none",$e,ze]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[ct,$e,ze]}],"backdrop-contrast":[{"backdrop-contrast":[ct,$e,ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ct,$e,ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ct,$e,ze]}],"backdrop-invert":[{"backdrop-invert":["",ct,$e,ze]}],"backdrop-opacity":[{"backdrop-opacity":[ct,$e,ze]}],"backdrop-saturate":[{"backdrop-saturate":[ct,$e,ze]}],"backdrop-sepia":[{"backdrop-sepia":["",ct,$e,ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",$e,ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ct,"initial",$e,ze]}],ease:[{ease:["linear","initial",N,$e,ze]}],delay:[{delay:[ct,$e,ze]}],animate:[{animate:["none",C,$e,ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,$e,ze]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:Ne()}],"rotate-x":[{"rotate-x":Ne()}],"rotate-y":[{"rotate-y":Ne()}],"rotate-z":[{"rotate-z":Ne()}],scale:[{scale:Te()}],"scale-x":[{"scale-x":Te()}],"scale-y":[{"scale-y":Te()}],"scale-z":[{"scale-z":Te()}],"scale-3d":["scale-3d"],skew:[{skew:Ve()}],"skew-x":[{"skew-x":Ve()}],"skew-y":[{"skew-y":Ve()}],transform:[{transform:[$e,ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:He()}],"translate-x":[{"translate-x":He()}],"translate-y":[{"translate-y":He()}],"translate-z":[{"translate-z":He()}],"translate-none":["translate-none"],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"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",$e,ze]}],"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":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"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",$e,ze]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[ct,wc,Ja,Sm]}],stroke:[{stroke:["none",...z()]}],"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"]}},J5=T5(G5);function Ct(...t){return J5(Zw(t))}const Y5=ej("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 ee({className:t,variant:e,size:n,asChild:r=!1,...i}){const a=r?Qw:"button";return s.jsx(a,{"data-slot":"button",className:Ct(Y5({variant:e,size:n,className:t})),...i})}function oe({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:Ct("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 Q5(){const t=ja(),[e,n]=v.useState(""),[r,i]=v.useState(""),[a,o]=v.useState(""),[c,u]=v.useState(!1),h=async()=>{o(""),u(!0);try{const f=await Nt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){GA(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 s.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),s.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),s.jsxs("div",{className:"w-full max-w-md relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.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:s.jsx(Rx,{className:"w-8 h-8 text-[#38bdac]"})}),s.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),s.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),s.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[s.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),s.jsxs("div",{className:"relative",children:[s.jsx(yl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{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]"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),s.jsxs("div",{className:"relative",children:[s.jsx(KM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"password",value:r,onChange:f=>i(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()})]})]}),a&&s.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:a}),s.jsx(ee,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),s.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Me=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Me.displayName="Card";const nt=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("flex flex-col space-y-1.5 p-6",t),...e}));nt.displayName="CardHeader";const rt=v.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:Ct("font-semibold leading-none tracking-tight",t),...e}));rt.displayName="CardTitle";const $t=v.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:Ct("text-sm text-muted-foreground",t),...e}));$t.displayName="CardDescription";const Ae=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("p-6 pt-0",t),...e}));Ae.displayName="CardContent";const X5=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("flex items-center p-6 pt-0",t),...e}));X5.displayName="CardFooter";const Z5={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Cm(t,e="info",n=3e3){const r=`toast-${Date.now()}`,i=Z5[e],a=document.createElement("div");a.id=r,a.setAttribute("role","alert"),Object.assign(a.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:i.bg,border:`1.5px solid ${i.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:i.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=i.icon;const c=document.createElement("span");c.textContent=t,a.appendChild(o),a.appendChild(c),document.body.appendChild(a),requestAnimationFrame(()=>{a.style.opacity="1",a.style.transform="translateY(0)"});const u=setTimeout(()=>h(r),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 ie={success:(t,e)=>Cm(t,"success",e),error:(t,e)=>Cm(t,"error",e),info:(t,e)=>Cm(t,"info",e)};function at(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t==null||t(i),n===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function eI(t,e){const n=v.createContext(e),r=a=>{const{children:o,...c}=a,u=v.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function i(a){const o=v.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${a}\` must be used within \`${t}\``)}return[r,i]}function ka(t,e=[]){let n=[];function r(a,o){const c=v.createContext(o),u=n.length;n=[...n,o];const h=m=>{var N;const{scope:g,children:y,...b}=m,j=((N=g==null?void 0:g[t])==null?void 0:N[u])||c,w=v.useMemo(()=>b,Object.values(b));return s.jsx(j.Provider,{value:w,children:y})};h.displayName=a+"Provider";function f(m,g){var j;const y=((j=g==null?void 0:g[t])==null?void 0:j[u])||c,b=v.useContext(y);if(b)return b;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[h,f]}const i=()=>{const a=n.map(o=>v.createContext(o));return function(c){const u=(c==null?void 0:c[t])||a;return v.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return i.scopeName=t,[r,tI(i,...e)]}function tI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(a)[`__scope${h}`];return{...c,...m}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Xn=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},nI=lf[" useId ".trim().toString()]||(()=>{}),rI=0;function ua(t){const[e,n]=v.useState(nI());return Xn(()=>{n(r=>r??String(rI++))},[t]),e?`radix-${e}`:""}var sI=lf[" useInsertionEffect ".trim().toString()]||Xn;function fo({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,a,o]=iI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:i;{const f=v.useRef(t!==void 0);v.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${r} 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,r])}const h=v.useCallback(f=>{var m;if(c){const g=aI(f)?f(t):f;g!==t&&((m=o.current)==null||m.call(o,g))}else a(f)},[c,t,a,o]);return[u,h]}function iI({defaultProp:t,onChange:e}){const[n,r]=v.useState(t),i=v.useRef(n),a=v.useRef(e);return sI(()=>{a.current=e},[e]),v.useEffect(()=>{var o;i.current!==n&&((o=a.current)==null||o.call(a,n),i.current=n)},[n,i]),[n,r,a]}function aI(t){return typeof t=="function"}function Jc(t){const e=oI(t),n=v.forwardRef((r,i)=>{const{children:a,...o}=r,c=v.Children.toArray(a),u=c.find(cI);if(u){const h=u.props.children,f=c.map(m=>m===u?v.Children.count(h)>1?v.Children.only(null):v.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:i,children:v.isValidElement(h)?v.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:i,children:a})});return n.displayName=`${t}.Slot`,n}function oI(t){const e=v.forwardRef((n,r)=>{const{children:i,...a}=n;if(v.isValidElement(i)){const o=uI(i),c=dI(a,i.props);return i.type!==v.Fragment&&(c.ref=r?Dx(r,o):o),v.cloneElement(i,c)}return v.Children.count(i)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var lI=Symbol("radix.slottable");function cI(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===lI}function dI(t,e){const n={...e};for(const r in e){const i=t[r],a=e[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...c)=>{const u=a(...c);return i(...c),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...t,...n}}function uI(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var hI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],dt=hI.reduce((t,e)=>{const n=Jc(`Primitive.${e}`),r=v.forwardRef((i,a)=>{const{asChild:o,...c}=i,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function fI(t,e){t&&dd.flushSync(()=>t.dispatchEvent(e))}function ga(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function pI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t);v.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var mI="DismissableLayer",Mg="dismissableLayer.update",gI="dismissableLayer.pointerDownOutside",xI="dismissableLayer.focusOutside",Kb,fj=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_x=v.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:c,...u}=t,h=v.useContext(fj),[f,m]=v.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=v.useState({}),b=St(e,D=>m(D)),j=Array.from(h.layers),[w]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(w),C=f?j.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,M=C>=N,I=bI(D=>{const P=D.target,L=[...h.branches].some(_=>_.contains(P));!M||L||(i==null||i(D),o==null||o(D),D.defaultPrevented||c==null||c())},g),O=NI(D=>{const P=D.target;[...h.branches].some(_=>_.contains(P))||(a==null||a(D),o==null||o(D),D.defaultPrevented||c==null||c())},g);return pI(D=>{C===h.layers.size-1&&(r==null||r(D),!D.defaultPrevented&&c&&(D.preventDefault(),c()))},g),v.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(Kb=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),qb(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Kb)}},[f,g,n,h]),v.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),qb())},[f,h]),v.useEffect(()=>{const D=()=>y({});return document.addEventListener(Mg,D),()=>document.removeEventListener(Mg,D)},[]),s.jsx(dt.div,{...u,ref:b,style:{pointerEvents:E?M?"auto":"none":void 0,...t.style},onFocusCapture:at(t.onFocusCapture,O.onFocusCapture),onBlurCapture:at(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:at(t.onPointerDownCapture,I.onPointerDownCapture)})});_x.displayName=mI;var yI="DismissableLayerBranch",vI=v.forwardRef((t,e)=>{const n=v.useContext(fj),r=v.useRef(null),i=St(e,r);return v.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(dt.div,{...t,ref:i})});vI.displayName=yI;function bI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t),r=v.useRef(!1),i=v.useRef(()=>{});return v.useEffect(()=>{const a=c=>{if(c.target&&!r.current){let u=function(){pj(gI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=u,e.addEventListener("click",i.current,{once:!0})):u()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",a),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function NI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t),r=v.useRef(!1);return v.useEffect(()=>{const i=a=>{a.target&&!r.current&&pj(xI,n,{originalEvent:a},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function qb(){const t=new CustomEvent(Mg);document.dispatchEvent(t)}function pj(t,e,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?fI(i,a):i.dispatchEvent(a)}var Em="focusScope.autoFocusOnMount",Tm="focusScope.autoFocusOnUnmount",Gb={bubbles:!1,cancelable:!0},wI="FocusScope",zx=v.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=t,[c,u]=v.useState(null),h=ga(i),f=ga(a),m=v.useRef(null),g=St(e,j=>u(j)),y=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let j=function(E){if(y.paused||!c)return;const M=E.target;c.contains(M)?m.current=M:Yi(m.current,{select:!0})},w=function(E){if(y.paused||!c)return;const M=E.relatedTarget;M!==null&&(c.contains(M)||Yi(m.current,{select:!0}))},N=function(E){if(document.activeElement===document.body)for(const I of E)I.removedNodes.length>0&&Yi(c)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const C=new MutationObserver(N);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),C.disconnect()}}},[r,c,y.paused]),v.useEffect(()=>{if(c){Yb.add(y);const j=document.activeElement;if(!c.contains(j)){const N=new CustomEvent(Em,Gb);c.addEventListener(Em,h),c.dispatchEvent(N),N.defaultPrevented||(jI(TI(mj(c)),{select:!0}),document.activeElement===j&&Yi(c))}return()=>{c.removeEventListener(Em,h),setTimeout(()=>{const N=new CustomEvent(Tm,Gb);c.addEventListener(Tm,f),c.dispatchEvent(N),N.defaultPrevented||Yi(j??document.body,{select:!0}),c.removeEventListener(Tm,f),Yb.remove(y)},0)}}},[c,h,f,y]);const b=v.useCallback(j=>{if(!n&&!r||y.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(w&&N){const C=j.currentTarget,[E,M]=kI(C);E&&M?!j.shiftKey&&N===M?(j.preventDefault(),n&&Yi(E,{select:!0})):j.shiftKey&&N===E&&(j.preventDefault(),n&&Yi(M,{select:!0})):N===C&&j.preventDefault()}},[n,r,y.paused]);return s.jsx(dt.div,{tabIndex:-1,...o,ref:g,onKeyDown:b})});zx.displayName=wI;function jI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Yi(r,{select:e}),document.activeElement!==n)return}function kI(t){const e=mj(t),n=Jb(e,t),r=Jb(e.reverse(),t);return[n,r]}function mj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function Jb(t,e){for(const n of t)if(!SI(n,{upTo:e}))return n}function SI(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 CI(t){return t instanceof HTMLInputElement&&"select"in t}function Yi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&CI(t)&&e&&t.select()}}var Yb=EI();function EI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=Qb(t,e),t.unshift(e)},remove(e){var n;t=Qb(t,e),(n=t[0])==null||n.resume()}}}function Qb(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function TI(t){return t.filter(e=>e.tagName!=="A")}var MI="Portal",$x=v.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[i,a]=v.useState(!1);Xn(()=>a(!0),[]);const o=n||i&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Tw.createPortal(s.jsx(dt.div,{...r,ref:e}),o):null});$x.displayName=MI;function AI(t,e){return v.useReducer((n,r)=>e[n][r]??n,t)}var ud=t=>{const{present:e,children:n}=t,r=II(e),i=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),a=St(r.ref,RI(i));return typeof n=="function"||r.isPresent?v.cloneElement(i,{ref:a}):null};ud.displayName="Presence";function II(t){const[e,n]=v.useState(),r=v.useRef(null),i=v.useRef(t),a=v.useRef("none"),o=t?"mounted":"unmounted",[c,u]=AI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const h=ku(r.current);a.current=c==="mounted"?h:"none"},[c]),Xn(()=>{const h=r.current,f=i.current;if(f!==t){const g=a.current,y=ku(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,u]),Xn(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const j=ku(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&j&&(u("ANIMATION_END"),!i.current)){const w=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=w)})}},g=y=>{y.target===e&&(a.current=ku(r.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:v.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function ku(t){return(t==null?void 0:t.animationName)||"none"}function RI(t){var r,i;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Mm=0;function gj(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Xb()),document.body.insertAdjacentElement("beforeend",t[1]??Xb()),Mm++,()=>{Mm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Mm--}},[])}function Xb(){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 Os=function(){return Os=Object.assign||function(e){for(var n,r=1,i=arguments.length;r"u")return JI;var e=YI(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},XI=bj(),vl="data-scroll-locked",ZI=function(t,e,n,r){var i=t.left,a=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` - .`.concat(OI,` { - overflow: hidden `).concat(r,`; - padding-right: `).concat(c,"px ").concat(r,`; - } - body[`).concat(vl,`] { - overflow: hidden `).concat(r,`; - overscroll-behavior: contain; - `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&` - padding-left: `.concat(i,`px; - padding-top: `).concat(a,`px; - padding-right: `).concat(o,`px; - margin-left:0; - margin-top:0; - margin-right: `).concat(c,"px ").concat(r,`; - `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),` - } - - .`).concat(Gu,` { - right: `).concat(c,"px ").concat(r,`; - } - - .`).concat(Ju,` { - margin-right: `).concat(c,"px ").concat(r,`; - } - - .`).concat(Gu," .").concat(Gu,` { - right: 0 `).concat(r,`; - } - - .`).concat(Ju," .").concat(Ju,` { - margin-right: 0 `).concat(r,`; - } - - body[`).concat(vl,`] { - `).concat(DI,": ").concat(c,`px; - } -`)},e1=function(){var t=parseInt(document.body.getAttribute(vl)||"0",10);return isFinite(t)?t:0},eR=function(){v.useEffect(function(){return document.body.setAttribute(vl,(e1()+1).toString()),function(){var t=e1()-1;t<=0?document.body.removeAttribute(vl):document.body.setAttribute(vl,t.toString())}},[])},tR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;eR();var a=v.useMemo(function(){return QI(i)},[i]);return v.createElement(XI,{styles:ZI(a,!e,i,n?"":"!important")})},Ag=!1;if(typeof window<"u")try{var Su=Object.defineProperty({},"passive",{get:function(){return Ag=!0,!0}});window.addEventListener("test",Su,Su),window.removeEventListener("test",Su,Su)}catch{Ag=!1}var rl=Ag?{passive:!1}:!1,nR=function(t){return t.tagName==="TEXTAREA"},Nj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!nR(t)&&n[e]==="visible")},rR=function(t){return Nj(t,"overflowY")},sR=function(t){return Nj(t,"overflowX")},t1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=wj(t,r);if(i){var a=jj(t,r),o=a[1],c=a[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},iR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},aR=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},wj=function(t,e){return t==="v"?rR(e):sR(e)},jj=function(t,e){return t==="v"?iR(e):aR(e)},oR=function(t,e){return t==="h"&&e==="rtl"?-1:1},lR=function(t,e,n,r,i){var a=oR(t,window.getComputedStyle(e).direction),o=a*r,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=jj(t,c),b=y[0],j=y[1],w=y[2],N=j-w-a*b;(b||N)&&wj(t,c)&&(m+=N,g+=b);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},Cu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},n1=function(t){return[t.deltaX,t.deltaY]},r1=function(t){return t&&"current"in t?t.current:t},cR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},dR=function(t){return` - .block-interactivity-`.concat(t,` {pointer-events: none;} - .allow-interactivity-`).concat(t,` {pointer-events: all;} -`)},uR=0,sl=[];function hR(t){var e=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),i=v.useState(uR++)[0],a=v.useState(bj)[0],o=v.useRef(t);v.useEffect(function(){o.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var j=PI([t.lockRef.current],(t.shards||[]).map(r1),!0).filter(Boolean);return j.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),j.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var c=v.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!o.current.allowPinchZoom;var N=Cu(j),C=n.current,E="deltaX"in j?j.deltaX:C[0]-N[0],M="deltaY"in j?j.deltaY:C[1]-N[1],I,O=j.target,D=Math.abs(E)>Math.abs(M)?"h":"v";if("touches"in j&&D==="h"&&O.type==="range")return!1;var P=window.getSelection(),L=P&&P.anchorNode,_=L?L===O||L.contains(O):!1;if(_)return!1;var X=t1(D,O);if(!X)return!0;if(X?I=D:(I=D==="v"?"h":"v",X=t1(D,O)),!X)return!1;if(!r.current&&"changedTouches"in j&&(E||M)&&(r.current=I),!I)return!0;var ne=r.current||I;return lR(ne,w,j,ne==="h"?E:M)},[]),u=v.useCallback(function(j){var w=j;if(!(!sl.length||sl[sl.length-1]!==a)){var N="deltaY"in w?n1(w):Cu(w),C=e.current.filter(function(I){return I.name===w.type&&(I.target===w.target||w.target===I.shadowParent)&&cR(I.delta,N)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var E=(o.current.shards||[]).map(r1).filter(Boolean).filter(function(I){return I.contains(w.target)}),M=E.length>0?c(w,E[0]):!o.current.noIsolation;M&&w.cancelable&&w.preventDefault()}}},[]),h=v.useCallback(function(j,w,N,C){var E={name:j,delta:w,target:N,should:C,shadowParent:fR(N)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(M){return M!==E})},1)},[]),f=v.useCallback(function(j){n.current=Cu(j),r.current=void 0},[]),m=v.useCallback(function(j){h(j.type,n1(j),j.target,c(j,t.lockRef.current))},[]),g=v.useCallback(function(j){h(j.type,Cu(j),j.target,c(j,t.lockRef.current))},[]);v.useEffect(function(){return sl.push(a),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,rl),document.addEventListener("touchmove",u,rl),document.addEventListener("touchstart",f,rl),function(){sl=sl.filter(function(j){return j!==a}),document.removeEventListener("wheel",u,rl),document.removeEventListener("touchmove",u,rl),document.removeEventListener("touchstart",f,rl)}},[]);var y=t.removeScrollBar,b=t.inert;return v.createElement(v.Fragment,null,b?v.createElement(a,{styles:dR(i)}):null,y?v.createElement(tR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function fR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const pR=VI(vj,hR);var Fx=v.forwardRef(function(t,e){return v.createElement(hf,Os({},t,{ref:e,sideCar:pR}))});Fx.classNames=hf.classNames;var mR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},il=new WeakMap,Eu=new WeakMap,Tu={},Pm=0,kj=function(t){return t&&(t.host||kj(t.parentNode))},gR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=kj(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},xR=function(t,e,n,r){var i=gR(e,Array.isArray(t)?t:[t]);Tu[n]||(Tu[n]=new WeakMap);var a=Tu[n],o=[],c=new Set,u=new Set(i),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};i.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(r),b=y!==null&&y!=="false",j=(il.get(g)||0)+1,w=(a.get(g)||0)+1;il.set(g,j),a.set(g,w),o.push(g),j===1&&b&&Eu.set(g,!0),w===1&&g.setAttribute(n,"true"),b||g.setAttribute(r,"true")}catch(N){console.error("aria-hidden: cannot operate on ",g,N)}})};return f(e),c.clear(),Pm++,function(){o.forEach(function(m){var g=il.get(m)-1,y=a.get(m)-1;il.set(m,g),a.set(m,y),g||(Eu.has(m)||m.removeAttribute(r),Eu.delete(m)),y||m.removeAttribute(n)}),Pm--,Pm||(il=new WeakMap,il=new WeakMap,Eu=new WeakMap,Tu={})}},Sj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=mR(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),xR(r,i,n,"aria-hidden")):function(){return null}},ff="Dialog",[Cj]=ka(ff),[yR,vs]=Cj(ff),Ej=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=t,c=v.useRef(null),u=v.useRef(null),[h,f]=fo({prop:r,defaultProp:i??!1,onChange:a,caller:ff});return s.jsx(yR,{scope:e,triggerRef:c,contentRef:u,contentId:ua(),titleId:ua(),descriptionId:ua(),open:h,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Ej.displayName=ff;var Tj="DialogTrigger",vR=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(Tj,n),a=St(e,i.triggerRef);return s.jsx(dt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Hx(i.open),...r,ref:a,onClick:at(t.onClick,i.onOpenToggle)})});vR.displayName=Tj;var Bx="DialogPortal",[bR,Mj]=Cj(Bx,{forceMount:void 0}),Aj=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,a=vs(Bx,e);return s.jsx(bR,{scope:e,forceMount:n,children:v.Children.map(r,o=>s.jsx(ud,{present:n||a.open,children:s.jsx($x,{asChild:!0,container:i,children:o})}))})};Aj.displayName=Bx;var uh="DialogOverlay",Ij=v.forwardRef((t,e)=>{const n=Mj(uh,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,a=vs(uh,t.__scopeDialog);return a.modal?s.jsx(ud,{present:r||a.open,children:s.jsx(wR,{...i,ref:e})}):null});Ij.displayName=uh;var NR=Jc("DialogOverlay.RemoveScroll"),wR=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(uh,n);return s.jsx(Fx,{as:NR,allowPinchZoom:!0,shards:[i.contentRef],children:s.jsx(dt.div,{"data-state":Hx(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),po="DialogContent",Rj=v.forwardRef((t,e)=>{const n=Mj(po,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,a=vs(po,t.__scopeDialog);return s.jsx(ud,{present:r||a.open,children:a.modal?s.jsx(jR,{...i,ref:e}):s.jsx(kR,{...i,ref:e})})});Rj.displayName=po;var jR=v.forwardRef((t,e)=>{const n=vs(po,t.__scopeDialog),r=v.useRef(null),i=St(e,n.contentRef,r);return v.useEffect(()=>{const a=r.current;if(a)return Sj(a)},[]),s.jsx(Pj,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:at(t.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:at(t.onPointerDownOutside,a=>{const o=a.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&a.preventDefault()}),onFocusOutside:at(t.onFocusOutside,a=>a.preventDefault())})}),kR=v.forwardRef((t,e)=>{const n=vs(po,t.__scopeDialog),r=v.useRef(!1),i=v.useRef(!1);return s.jsx(Pj,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,a),a.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=a.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),Pj=v.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=t,c=vs(po,n),u=v.useRef(null),h=St(e,u);return gj(),s.jsxs(s.Fragment,{children:[s.jsx(zx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:s.jsx(_x,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Hx(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(SR,{titleId:c.titleId}),s.jsx(ER,{contentRef:u,descriptionId:c.descriptionId})]})]})}),Vx="DialogTitle",Oj=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(Vx,n);return s.jsx(dt.h2,{id:i.titleId,...r,ref:e})});Oj.displayName=Vx;var Dj="DialogDescription",Lj=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(Dj,n);return s.jsx(dt.p,{id:i.descriptionId,...r,ref:e})});Lj.displayName=Dj;var _j="DialogClose",zj=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(_j,n);return s.jsx(dt.button,{type:"button",...r,ref:e,onClick:at(t.onClick,()=>i.onOpenChange(!1))})});zj.displayName=_j;function Hx(t){return t?"open":"closed"}var $j="DialogTitleWarning",[zV,Fj]=eI($j,{contentName:po,titleName:Vx,docsSlug:"dialog"}),SR=({titleId:t})=>{const e=Fj($j),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 v.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},CR="DialogDescriptionWarning",ER=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Fj(CR).contentName}}.`;return v.useEffect(()=>{var a;const i=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},TR=Ej,MR=Aj,AR=Ij,IR=Rj,RR=Oj,PR=Lj,OR=zj;function Kt(t){return s.jsx(TR,{"data-slot":"dialog",...t})}function DR(t){return s.jsx(MR,{...t})}const Bj=v.forwardRef(({className:t,...e},n)=>s.jsx(AR,{ref:n,className:Ct("fixed inset-0 z-50 bg-black/50",t),...e}));Bj.displayName="DialogOverlay";const zt=v.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},i)=>s.jsxs(DR,{children:[s.jsx(Bj,{}),s.jsxs(IR,{ref:i,"aria-describedby":void 0,className:Ct("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),...r,children:[e,n&&s.jsxs(OR,{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:[s.jsx(hr,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zt.displayName="DialogContent";function qt({className:t,...e}){return s.jsx("div",{className:Ct("flex flex-col gap-2 text-center sm:text-left",t),...e})}function hn({className:t,...e}){return s.jsx("div",{className:Ct("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Gt(t){return s.jsx(RR,{className:"text-lg font-semibold leading-none",...t})}function Wx(t){return s.jsx(PR,{className:"text-sm text-muted-foreground",...t})}const LR=ej("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 Ue({className:t,variant:e,asChild:n=!1,...r}){const i=n?Qw:"span";return s.jsx(i,{className:Ct(LR({variant:e}),t),...r})}var _R=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zR=_R.reduce((t,e)=>{const n=Yw(`Primitive.${e}`),r=v.forwardRef((i,a)=>{const{asChild:o,...c}=i,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),$R="Label",Vj=v.forwardRef((t,e)=>s.jsx(zR.label,{...t,ref:e,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=t.onMouseDown)==null||i.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Vj.displayName=$R;var Hj=Vj;const Z=v.forwardRef(({className:t,...e},n)=>s.jsx(Hj,{ref:n,className:Ct("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Z.displayName=Hj.displayName;function Ux(t){const e=t+"CollectionProvider",[n,r]=ka(e),[i,a]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=j=>{const{scope:w,children:N}=j,C=ur.useRef(null),E=ur.useRef(new Map).current;return s.jsx(i,{scope:w,itemMap:E,collectionRef:C,children:N})};o.displayName=e;const c=t+"CollectionSlot",u=Jc(c),h=ur.forwardRef((j,w)=>{const{scope:N,children:C}=j,E=a(c,N),M=St(w,E.collectionRef);return s.jsx(u,{ref:M,children:C})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Jc(f),y=ur.forwardRef((j,w)=>{const{scope:N,children:C,...E}=j,M=ur.useRef(null),I=St(w,M),O=a(f,N);return ur.useEffect(()=>(O.itemMap.set(M,{ref:M,...E}),()=>void O.itemMap.delete(M))),s.jsx(g,{[m]:"",ref:I,children:C})});y.displayName=f;function b(j){const w=a(t+"CollectionConsumer",j);return ur.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${m}]`));return Array.from(w.itemMap.values()).sort((O,D)=>E.indexOf(O.ref.current)-E.indexOf(D.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},b,r]}var FR=v.createContext(void 0);function pf(t){const e=v.useContext(FR);return t||e||"ltr"}var Om="rovingFocusGroup.onEntryFocus",BR={bubbles:!1,cancelable:!0},hd="RovingFocusGroup",[Ig,Wj,VR]=Ux(hd),[HR,Uj]=ka(hd,[VR]),[WR,UR]=HR(hd),Kj=v.forwardRef((t,e)=>s.jsx(Ig.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Ig.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(KR,{...t,ref:e})})}));Kj.displayName=hd;var KR=v.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=v.useRef(null),y=St(e,g),b=pf(a),[j,w]=fo({prop:o,defaultProp:c??null,onChange:u,caller:hd}),[N,C]=v.useState(!1),E=ga(h),M=Wj(n),I=v.useRef(!1),[O,D]=v.useState(0);return v.useEffect(()=>{const P=g.current;if(P)return P.addEventListener(Om,E),()=>P.removeEventListener(Om,E)},[E]),s.jsx(WR,{scope:n,orientation:r,dir:b,loop:i,currentTabStopId:j,onItemFocus:v.useCallback(P=>w(P),[w]),onItemShiftTab:v.useCallback(()=>C(!0),[]),onFocusableItemAdd:v.useCallback(()=>D(P=>P+1),[]),onFocusableItemRemove:v.useCallback(()=>D(P=>P-1),[]),children:s.jsx(dt.div,{tabIndex:N||O===0?-1:0,"data-orientation":r,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:at(t.onMouseDown,()=>{I.current=!0}),onFocus:at(t.onFocus,P=>{const L=!I.current;if(P.target===P.currentTarget&&L&&!N){const _=new CustomEvent(Om,BR);if(P.currentTarget.dispatchEvent(_),!_.defaultPrevented){const X=M().filter(F=>F.focusable),ne=X.find(F=>F.active),J=X.find(F=>F.id===j),R=[ne,J,...X].filter(Boolean).map(F=>F.ref.current);Jj(R,f)}}I.current=!1}),onBlur:at(t.onBlur,()=>C(!1))})})}),qj="RovingFocusGroupItem",Gj=v.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...c}=t,u=ua(),h=a||u,f=UR(qj,n),m=f.currentTabStopId===h,g=Wj(n),{onFocusableItemAdd:y,onFocusableItemRemove:b,currentTabStopId:j}=f;return v.useEffect(()=>{if(r)return y(),()=>b()},[r,y,b]),s.jsx(Ig.ItemSlot,{scope:n,id:h,focusable:r,active:i,children:s.jsx(dt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:at(t.onMouseDown,w=>{r?f.onItemFocus(h):w.preventDefault()}),onFocus:at(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:at(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const N=JR(w,f.orientation,f.dir);if(N!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let E=g().filter(M=>M.focusable).map(M=>M.ref.current);if(N==="last")E.reverse();else if(N==="prev"||N==="next"){N==="prev"&&E.reverse();const M=E.indexOf(w.currentTarget);E=f.loop?YR(E,M+1):E.slice(M+1)}setTimeout(()=>Jj(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:j!=null}):o})})});Gj.displayName=qj;var qR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function GR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function JR(t,e,n){const r=GR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return qR[r]}function Jj(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function YR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var QR=Kj,XR=Gj,mf="Tabs",[ZR]=ka(mf,[Uj]),Yj=Uj(),[eP,Kx]=ZR(mf),Qj=v.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=pf(c),[m,g]=fo({prop:r,onChange:i,defaultProp:a??"",caller:mf});return s.jsx(eP,{scope:n,baseId:ua(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:s.jsx(dt.div,{dir:f,"data-orientation":o,...h,ref:e})})});Qj.displayName=mf;var Xj="TabsList",Zj=v.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,a=Kx(Xj,n),o=Yj(n);return s.jsx(QR,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(dt.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:e})})});Zj.displayName=Xj;var ek="TabsTrigger",tk=v.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...a}=t,o=Kx(ek,n),c=Yj(n),u=sk(o.baseId,r),h=ik(o.baseId,r),f=r===o.value;return s.jsx(XR,{asChild:!0,...c,focusable:!i,active:f,children:s.jsx(dt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:u,...a,ref:e,onMouseDown:at(t.onMouseDown,m=>{!i&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:at(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:at(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!i&&m&&o.onValueChange(r)})})})});tk.displayName=ek;var nk="TabsContent",rk=v.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=t,c=Kx(nk,n),u=sk(c.baseId,r),h=ik(c.baseId,r),f=r===c.value,m=v.useRef(f);return v.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(ud,{present:i||f,children:({present:g})=>s.jsx(dt.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&&a})})});rk.displayName=nk;function sk(t,e){return`${t}-trigger-${e}`}function ik(t,e){return`${t}-content-${e}`}var tP=Qj,ak=Zj,ok=tk,lk=rk;const fd=tP,Ll=v.forwardRef(({className:t,...e},n)=>s.jsx(ak,{ref:n,className:Ct("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ll.displayName=ak.displayName;const tn=v.forwardRef(({className:t,...e},n)=>s.jsx(ok,{ref:n,className:Ct("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}));tn.displayName=ok.displayName;const nn=v.forwardRef(({className:t,...e},n)=>s.jsx(lk,{ref:n,className:Ct("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));nn.displayName=lk.displayName;function qx(t){const e=v.useRef({value:t,previous:t});return v.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function Gx(t){const[e,n]=v.useState(void 0);return Xn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let o,c;if("borderBoxSize"in a){const u=a.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 r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var gf="Switch",[nP]=ka(gf),[rP,sP]=nP(gf),ck=v.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=v.useState(null),b=St(e,E=>y(E)),j=v.useRef(!1),w=g?f||!!g.closest("form"):!0,[N,C]=fo({prop:i,defaultProp:a??!1,onChange:h,caller:gf});return s.jsxs(rP,{scope:n,checked:N,disabled:c,children:[s.jsx(dt.button,{type:"button",role:"switch","aria-checked":N,"aria-required":o,"data-state":fk(N),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:b,onClick:at(t.onClick,E=>{C(M=>!M),w&&(j.current=E.isPropagationStopped(),j.current||E.stopPropagation())})}),w&&s.jsx(hk,{control:g,bubbles:!j.current,name:r,value:u,checked:N,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});ck.displayName=gf;var dk="SwitchThumb",uk=v.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=sP(dk,n);return s.jsx(dt.span,{"data-state":fk(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});uk.displayName=dk;var iP="SwitchBubbleInput",hk=v.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...i},a)=>{const o=v.useRef(null),c=St(o,a),u=qx(n),h=Gx(e);return v.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const b=new Event("click",{bubbles:r});y.call(f,n),f.dispatchEvent(b)}},[u,n,r]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:c,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});hk.displayName=iP;function fk(t){return t?"checked":"unchecked"}var pk=ck,aP=uk;const Et=v.forwardRef(({className:t,...e},n)=>s.jsx(pk,{className:Ct("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:s.jsx(aP,{className:Ct("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")})}));Et.displayName=pk.displayName;function Jx({open:t,onClose:e,userId:n,onUserUpdated:r}){var ir;const[i,a]=v.useState(null),[o,c]=v.useState([]),[u,h]=v.useState([]),[f,m]=v.useState(!1),[g,y]=v.useState(!1),[b,j]=v.useState(!1),[w,N]=v.useState("info"),[C,E]=v.useState(""),[M,I]=v.useState(""),[O,D]=v.useState([]),[P,L]=v.useState(""),[_,X]=v.useState(""),[ne,J]=v.useState(""),[U,R]=v.useState(!1),[F,re]=v.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[z,ae]=v.useState([]),[G,$]=v.useState(!1),[H,ce]=v.useState(!1),[W,fe]=v.useState(null),[Q,de]=v.useState(null),[he,Ne]=v.useState(""),[Te,Ve]=v.useState(""),[He,gt]=v.useState(""),[Pt,wn]=v.useState(!1),[ht,At]=v.useState(null),[te,Pe]=v.useState("");v.useEffect(()=>{t&&n&&(N("info"),fe(null),de(null),At(null),Pe(""),X(""),J(""),Qe(),Le("/api/db/vip-roles").then(me=>{me!=null&&me.success&&me.data&&ae(me.data)}).catch(()=>{}))},[t,n]);async function Qe(){if(n){m(!0);try{const me=await Le(`/api/db/users?id=${encodeURIComponent(n)}`);if(me!=null&&me.success&&me.user){const ve=me.user;a(ve),E(ve.phone||""),I(ve.nickname||""),Ne(ve.phone||""),Ve(ve.wechatId||""),gt(ve.openId||"");try{D(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{D([])}re({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Le(`/api/user/track?userId=${encodeURIComponent(n)}&limit=50`);ve!=null&&ve.success&&ve.tracks&&c(ve.tracks)}catch{c([])}try{const ve=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success&&ve.referrals&&h(ve.referrals)}catch{h([])}}catch(me){console.error("Load user detail error:",me)}finally{m(!1)}}}async function xt(){if(!(i!=null&&i.phone)){ie.info("用户未绑定手机号,无法同步");return}y(!0);try{const me=await Nt("/api/ckb/sync",{action:"full_sync",phone:i.phone,userId:i.id});me!=null&&me.success?(ie.success("同步成功"),Qe()):ie.error("同步失败: "+(me==null?void 0:me.error))}catch(me){console.error("Sync CKB error:",me),ie.error("同步失败")}finally{y(!1)}}async function ft(){if(i){j(!0);try{const me={id:i.id,phone:C||void 0,nickname:M||void 0,tags:JSON.stringify(O)},ve=await Mt("/api/db/users",me);ve!=null&&ve.success?(ie.success("保存成功"),Qe(),r==null||r()):ie.error("保存失败: "+(ve==null?void 0:ve.error))}catch(me){console.error("Save user error:",me),ie.error("保存失败")}finally{j(!1)}}}const pt=()=>{P&&!O.includes(P)&&(D([...O,P]),L(""))},wt=me=>D(O.filter(ve=>ve!==me));async function Xt(){if(i){if(!_){ie.error("请输入新密码");return}if(_!==ne){ie.error("两次密码不一致");return}if(_.length<6){ie.error("密码至少 6 位");return}R(!0);try{const me=await Mt("/api/db/users",{id:i.id,password:_});me!=null&&me.success?(ie.success("修改成功"),X(""),J("")):ie.error("修改失败: "+((me==null?void 0:me.error)||""))}catch{ie.error("修改失败")}finally{R(!1)}}}async function Ot(){if(i){if(F.isVip&&!F.vipExpireDate.trim()){ie.error("开启 VIP 请填写有效到期日");return}$(!0);try{const me={id:i.id,isVip:F.isVip,vipExpireDate:F.isVip?F.vipExpireDate:void 0,vipRole:F.vipRole||void 0,vipName:F.vipName||void 0,vipProject:F.vipProject||void 0,vipContact:F.vipContact||void 0,vipBio:F.vipBio||void 0},ve=await Mt("/api/db/users",me);ve!=null&&ve.success?(ie.success("VIP 设置已保存"),Qe(),r==null||r()):ie.error("保存失败: "+((ve==null?void 0:ve.error)||""))}catch{ie.error("保存失败")}finally{$(!1)}}}async function Tn(){if(!he&&!He&&!Te){de("请至少输入手机号、微信号或 OpenID 中的一项");return}ce(!0),de(null),fe(null);try{const me=new URLSearchParams;he&&me.set("phone",he),He&&me.set("openId",He),Te&&me.set("wechatId",Te);const ve=await Le(`/api/admin/shensheshou/query?${me}`);ve!=null&&ve.success&&ve.data?(fe(ve.data),i&&await Dt(ve.data)):de((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(me){console.error("SSS query error:",me),de("请求失败,请检查神射手接口配置")}finally{ce(!1)}}async function Dt(me){if(i)try{await Nt("/api/admin/shensheshou/enrich",{userId:i.id,phone:he||i.phone||"",openId:He||i.openId||"",wechatId:Te||i.wechatId||""}),Qe()}catch(ve){console.error("SSS enrich error:",ve)}}async function Kn(){if(i){wn(!0),At(null);try{const me={users:[{phone:i.phone||"",name:i.nickname||"",openId:i.openId||"",tags:O}]},ve=await Nt("/api/admin/shensheshou/ingest",me);ve!=null&&ve.success&&ve.data?At(ve.data):At({error:(ve==null?void 0:ve.error)||"推送失败"})}catch(me){console.error("SSS ingest error:",me),At({error:"请求失败"})}finally{wn(!1)}}}const Xr=me=>{const ar={view_chapter:ps,purchase:Cg,match:Un,login:yl,register:yl,share:ms,bind_phone:dA,bind_wechat:ZM,fill_profile:qu,visit_page:pl}[me]||jg;return s.jsx(ar,{className:"w-4 h-4"})};return t?s.jsx(Kt,{open:t,onOpenChange:()=>e(),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(yl,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(i==null?void 0:i.phone)&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(i==null?void 0:i.isVip)&&s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),f?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i?s.jsxs("div",{className:"flex flex-col h-[75vh]",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:i.avatar?s.jsx("img",{src:i.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((ir=i.nickname)==null?void 0:ir.charAt(0))||"?"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-lg font-bold text-white",children:i.nickname}),i.isAdmin&&s.jsx(Ue,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),i.hasFullBook&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),i.vipRole&&s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 border-0",children:i.vipRole})]}),s.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[i.phone?`📱 ${i.phone}`:"未绑定手机",i.wechatId&&` · 💬 ${i.wechatId}`,i.mbti&&` · ${i.mbti}`]}),s.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[s.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",i.id.slice(0,16),"…"]}),i.referralCode&&s.jsxs("p",{className:"text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"推广码:"}),s.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:i.referralCode})]})]})]}),s.jsxs("div",{className:"text-right shrink-0",children:[s.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(i.earnings||0).toFixed(2)]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),s.jsxs(fd,{value:w,onValueChange:N,className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs(Ll,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[s.jsx(tn,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),s.jsx(tn,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),s.jsxs(tn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(pl,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),s.jsx(tn,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),s.jsxs(tn,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(ia,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),s.jsxs(nn,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:C,onChange:me=>E(me.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:M,onChange:me=>I(me.target.value)})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[i.openId&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),s.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:i.openId})]}),i.region&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(Kw,{className:"w-4 h-4 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),s.jsx("p",{className:"text-white",children:i.region})]})]}),i.industry&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),s.jsx("p",{className:"text-white",children:i.industry})]}),i.position&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),s.jsx("p",{className:"text-white",children:i.position})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:i.referralCount??0})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),s.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(i.pendingEarnings??0).toFixed(2)]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),s.jsx("p",{className:"text-sm text-white",children:i.createdAt?new Date(i.createdAt).toLocaleDateString():"-"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(LM,{className:"w-4 h-4 text-yellow-400"}),s.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:_,onChange:me=>X(me.target.value)}),s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:ne,onChange:me=>J(me.target.value)}),s.jsx(ee,{size:"sm",onClick:Xt,disabled:U||!_||!ne,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:U?"保存中...":"确认修改"})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(xl,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-400 text-sm",children:"VIP 会员"}),s.jsx(Et,{checked:F.isVip,onCheckedChange:me=>re(ve=>({...ve,isVip:me}))})]}),F.isVip&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"到期日"}),s.jsx(oe,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:F.vipExpireDate,onChange:me=>re(ve=>({...ve,vipExpireDate:me.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:F.vipRole,onChange:me=>re(ve=>({...ve,vipRole:me.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),z.map(me=>s.jsx("option",{value:me.name,children:me.name},me.id))]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"展示名"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:F.vipName,onChange:me=>re(ve=>({...ve,vipName:me.target.value}))})]}),s.jsx(ee,{size:"sm",onClick:Ot,disabled:G,className:"bg-amber-500/20 hover:bg-amber-500/30 text-amber-400 border border-amber-500/40",children:G?"保存中...":"保存 VIP"})]})]})]}),i.isVip&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(xl,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:i.vipRole||"VIP"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[i.vipName&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"展示名:"}),s.jsx("span",{className:"text-white",children:i.vipName})]}),i.vipProject&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"项目:"}),s.jsx("span",{className:"text-white",children:i.vipProject})]}),i.vipContact&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"联系方式:"}),s.jsx("span",{className:"text-white",children:i.vipContact})]}),i.vipExpireDate&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"到期时间:"}),s.jsx("span",{className:"text-white",children:new Date(i.vipExpireDate).toLocaleDateString()})]})]}),i.vipBio&&s.jsx("p",{className:"text-gray-400 text-sm mt-2",children:i.vipBio})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(uo,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"微信归属"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:te,onChange:me=>Pe(me.target.value)}),s.jsxs(ee,{size:"sm",onClick:async()=>{if(!(!te||!i))try{await Mt("/api/db/users",{id:i.id,wechatId:te}),ie.success("已保存微信归属"),Qe()}catch{ie.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[s.jsx(gn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),i.wechatId&&s.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",s.jsx("span",{className:"text-purple-400",children:i.wechatId})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ms,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),s.jsx(ee,{size:"sm",onClick:xt,disabled:g||!i.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"同步状态:"}),i.ckbSyncedAt?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"最后同步:"}),s.jsx("span",{className:"text-gray-300 ml-1",children:i.ckbSyncedAt?new Date(i.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),s.jsxs(nn,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(qu,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),s.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:[s.jsx(wg,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),s.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=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:me.category}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:me.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{O.includes(ve)?wt(ve):D([...O,ve])},className:`px-2 py-0.5 rounded text-xs border transition-all ${O.includes(ve)?"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:[O.includes(ve)?"✓ ":"",ve]},ve))})]},me.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[O.map((me,ve)=>s.jsxs(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[me,s.jsx("button",{type:"button",onClick:()=>wt(me),className:"ml-1 hover:text-red-400",children:s.jsx(hr,{className:"w-3 h-3"})})]},ve)),O.length===0&&s.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:P,onChange:me=>L(me.target.value),onKeyDown:me=>me.key==="Enter"&&pt()}),s.jsx(ee,{onClick:pt,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),i.ckbTags&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(qu,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:(typeof i.ckbTags=="string"?i.ckbTags.split(","):[]).map((me,ve)=>s.jsx(Ue,{className:"bg-purple-500/20 text-purple-400 border-0",children:me.trim()},ve))})]})]}),s.jsxs(nn,{value:"journey",className:"flex-1 overflow-auto",children:[s.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(pl,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),s.jsx("div",{className:"space-y-2",children:o.length>0?o.map((me,ve)=>s.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:Xr(me.action)}),ve0?u.map((me,ve)=>{var Hs;const ar=me;return s.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((Hs=ar.nickname)==null?void 0:Hs.charAt(0))||"?"}),s.jsx("span",{className:"text-white text-sm",children:ar.nickname})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[ar.status==="vip"&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-xs",children:ar.createdAt?new Date(ar.createdAt).toLocaleDateString():""})]})]},ar.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),s.jsxs(nn,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ia,{className:"w-5 h-5 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[s.jsxs("div",{children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:he,onChange:me=>Ne(me.target.value)})]}),s.jsxs("div",{children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:Te,onChange:me=>Ve(me.target.value)})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:He,onChange:me=>gt(me.target.value)})]})]}),s.jsx(ee,{onClick:Tn,disabled:H,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:H?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(da,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),s.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),Q&&s.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:Q}),W&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),s.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:W.rfm_score??"-"})]}),s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:W.user_level??"-"})]})]}),W.tags&&W.tags.length>0&&s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:W.tags.map((me,ve)=>s.jsx(Ue,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:me},ve))})]}),W.last_active&&s.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",W.last_active]})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx(ia,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),s.jsx(ee,{onClick:Kn,disabled:Pt||!i.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:Pt?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):s.jsxs(s.Fragment,{children:[s.jsx(ia,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!i.phone&&s.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),ht&&s.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:ht.error?s.jsx("p",{className:"text-red-400",children:String(ht.error)}):s.jsxs("div",{className:"space-y-1",children:[s.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[s.jsx(wg,{className:"w-4 h-4"})," 推送成功"]}),ht.enriched!==void 0&&s.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(ht.new_tags_added??0)]})]})})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[s.jsxs(ee,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(ee,{onClick:ft,disabled:b,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),b?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}):null}function oP(){const t=ja(),[e,n]=v.useState(!0),[r,i]=v.useState(!0),[a,o]=v.useState(!0),[c,u]=v.useState([]),[h,f]=v.useState([]),[m,g]=v.useState(0),[y,b]=v.useState(0),[j,w]=v.useState(0),[N,C]=v.useState(0),[E,M]=v.useState(null),[I,O]=v.useState(null),[D,P]=v.useState(!1),L=U=>{const R=U;if((R==null?void 0:R.status)===401)M("登录已过期,请重新登录");else{if((R==null?void 0:R.name)==="AbortError")return;M("加载失败,请检查网络或联系管理员")}};async function _(U){const R=U?{signal:U}:void 0;n(!0),M(null);try{const z=await Le("/api/admin/dashboard/stats",R);z!=null&&z.success&&(g(z.totalUsers??0),b(z.paidOrderCount??0),w(z.totalRevenue??0))}catch(z){if((z==null?void 0:z.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",z);try{const ae=await Le("/api/admin/dashboard/overview",R);ae!=null&&ae.success&&(g(ae.totalUsers??0),b(ae.paidOrderCount??0),w(ae.totalRevenue??0))}catch(ae){L(ae)}}}finally{n(!1)}try{const z=await Le("/api/admin/distribution/overview",R);z!=null&&z.success&&C(z.todayClicks??0)}catch{}i(!0),o(!0);const F=async()=>{try{const z=await Le("/api/admin/dashboard/recent-orders",R);if(z!=null&&z.success&&z.recentOrders)f(z.recentOrders);else throw new Error("no data")}catch(z){if((z==null?void 0:z.name)!=="AbortError")try{const ae=await Le("/api/admin/orders?page=1&pageSize=20&status=paid",R),$=((ae==null?void 0:ae.orders)??[]).filter(H=>["paid","completed","success"].includes(H.status||""));f($.slice(0,5))}catch{f([])}}finally{i(!1)}},re=async()=>{try{const z=await Le("/api/admin/dashboard/new-users",R);if(z!=null&&z.success&&z.newUsers)u(z.newUsers);else throw new Error("no data")}catch(z){if((z==null?void 0:z.name)!=="AbortError")try{const ae=await Le("/api/db/users?page=1&pageSize=10",R);u((ae==null?void 0:ae.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([F(),re()])}v.useEffect(()=>{const U=new AbortController;_(U.signal);const R=setInterval(()=>_(),3e4);return()=>{U.abort(),clearInterval(R)}},[]);const X=m,ne=U=>{const R=U.productType||"",F=U.description||"";if(F){if(R==="section"&&F.includes("章节")){if(F.includes("-")){const re=F.split("-");if(re.length>=3)return{title:`第${re[1]}章 第${re[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:F,subtitle:"章节购买"}}return R==="fullbook"||F.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:R==="match"||F.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:F,subtitle:R==="section"?"单章":R==="fullbook"?"全书":"其他"}}return R==="section"?{title:`章节 ${U.productId||""}`,subtitle:"单章购买"}:R==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:R==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:R||"其他"}},J=[{title:"总用户数",value:e?null:X,icon:Un,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(j??0).toFixed(2)}`,icon:Oc,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,icon:Cg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"今日点击",value:e?null:N,icon:oh,color:"text-blue-400",bg:"bg-blue-500/20",link:"/distribution"}];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),E&&s.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:[s.jsx("span",{children:E}),s.jsx("button",{type:"button",onClick:()=>_(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:J.map((U,R)=>s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>U.link&&t(U.link),children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(rt,{className:"text-sm font-medium text-gray-400",children:U.title}),s.jsx("div",{className:`p-2 rounded-lg ${U.bg}`,children:s.jsx(U.icon,{className:`w-4 h-4 ${U.color}`})})]}),s.jsx(Ae,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-2xl font-bold text-white min-h-[2rem] flex items-center",children:U.value!=null?U.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Ge,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),s.jsx(fl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},R))}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between",children:[s.jsx(rt,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>_(),disabled:r||a,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[r||a?s.jsx(Ge,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ge,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),s.jsx(Ae,{children:s.jsx("div",{className:"space-y-3",children:r&&h.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ge,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,5).map(U=>{var ae;const R=U.referrerId?c.find(G=>G.id===U.referrerId):void 0,F=U.referralCode||(R==null?void 0:R.referralCode)||(R==null?void 0:R.nickname)||(U.referrerId?String(U.referrerId).slice(0,8):""),re=ne(U),z=U.userNickname||((ae=c.find(G=>G.id===U.userId))==null?void 0:ae.nickname)||"匿名用户";return s.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:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[U.userAvatar?s.jsx("img",{src:U.userAvatar,alt:z,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:G=>{G.currentTarget.style.display="none";const $=G.currentTarget.nextElementSibling;$&&$.classList.remove("hidden")}}):null,s.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 ${U.userAvatar?"hidden":""}`,children:z.charAt(0)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("button",{type:"button",onClick:()=>{U.userId&&(O(U.userId),P(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:z}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",children:re.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[re.subtitle&&re.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:re.subtitle}),s.jsx("span",{children:new Date(U.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),F&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",F]})]})]}),s.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(U.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:U.paymentMethod||"微信"})]})]},U.id)}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Cg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"新注册用户"})}),s.jsx(Ae,{children:s.jsx("div",{className:"space-y-3",children:a&&c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ge,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[c.slice(0,5).map(U=>{var R;return s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((R=U.nickname)==null?void 0:R.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{O(U.id),P(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:U.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:U.phone||"-"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:U.createdAt?new Date(U.createdAt).toLocaleDateString():"-"})]},U.id)}),c.length===0&&!a&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),s.jsx(Jx,{open:D,onClose:()=>{P(!1),O(null)},userId:I,onUserUpdated:()=>_()})]})}const Zn=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:Ct("w-full caption-bottom text-sm",t),...e})}));Zn.displayName="Table";const er=v.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:Ct("[&_tr]:border-b",t),...e}));er.displayName="TableHeader";const tr=v.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:Ct("[&_tr:last-child]:border-0",t),...e}));tr.displayName="TableBody";const st=v.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:Ct("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));st.displayName="TableRow";const je=v.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:Ct("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableHead";const xe=v.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:Ct("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));xe.displayName="TableCell";function Yx(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function gs({page:t,totalPages:e,total:n,pageSize:r,onPageChange:i,onPageSizeChange:a,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!a?null:s.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[s.jsxs("span",{children:["共 ",n," 条"]}),a&&s.jsx("select",{value:r,onChange:c=>a(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=>s.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>i(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:"首页"}),s.jsx("button",{type:"button",onClick:()=>i(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:"上一页"}),s.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),s.jsx("button",{type:"button",onClick:()=>i(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:"下一页"}),s.jsx("button",{type:"button",onClick:()=>i(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 lP(){const[t,e]=v.useState([]),[n,r]=v.useState([]),[i,a]=v.useState(0),[o,c]=v.useState(0),[u,h]=v.useState(0),[f,m]=v.useState(1),[g,y]=v.useState(10),[b,j]=v.useState(""),w=Yx(b,300),[N,C]=v.useState("all"),[E,M]=v.useState(!0),[I,O]=v.useState(null),[D,P]=v.useState(null),[L,_]=v.useState(""),[X,ne]=v.useState(!1);async function J(){M(!0),O(null);try{const G=N==="all"?"":N==="completed"?"completed":N,$=new URLSearchParams({page:String(f),pageSize:String(g),...G&&{status:G},...w&&{search:w}}),[H,ce]=await Promise.all([Le(`/api/admin/orders?${$}`),Le("/api/db/users?page=1&pageSize=500")]);H!=null&&H.success&&(e(H.orders||[]),a(H.total??0),c(H.totalRevenue??0),h(H.todayRevenue??0)),ce!=null&&ce.success&&ce.users&&r(ce.users)}catch(G){console.error("加载订单失败",G),O("加载订单失败,请检查网络后重试")}finally{M(!1)}}v.useEffect(()=>{m(1)},[w,N]),v.useEffect(()=>{J()},[f,g,w,N]);const U=G=>{var $;return G.userNickname||(($=n.find(H=>H.id===G.userId))==null?void 0:$.nickname)||"匿名用户"},R=G=>{var $;return(($=n.find(H=>H.id===G))==null?void 0:$.phone)||"-"},F=G=>{const $=G.productType||G.type||"",H=G.description||"";if(H){if($==="section"&&H.includes("章节")){if(H.includes("-")){const ce=H.split("-");if(ce.length>=3)return{name:`第${ce[1]}章 第${ce[2]}节`,type:"《一场Soul的创业实验》"}}return{name:H,type:"章节购买"}}return $==="fullbook"||H.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:$==="vip"||H.includes("VIP")?{name:"VIP年度会员",type:"VIP"}:$==="match"||H.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:H,type:"其他"}}return $==="section"?{name:`章节 ${G.productId||G.sectionId||""}`,type:"单章"}:$==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:$==="vip"?{name:"VIP年度会员",type:"VIP"}:$==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:$||"其他"}},re=Math.ceil(i/g)||1;async function z(){var G;if(!(!(D!=null&&D.orderSn)&&!(D!=null&&D.id))){ne(!0),O(null);try{const $=await Mt("/api/admin/orders/refund",{orderSn:D.orderSn||D.id,reason:L||void 0});$!=null&&$.success?(P(null),_(""),J()):O(($==null?void 0:$.error)||"退款失败")}catch($){const H=$;O(((G=H==null?void 0:H.data)==null?void 0:G.error)||"退款失败,请检查网络后重试")}finally{ne(!1)}}}function ae(){if(t.length===0){ie.info("暂无数据可导出");return}const G=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],$=t.map(Q=>{const de=F(Q);return[Q.orderSn||Q.id||"",U(Q),R(Q.userId),de.name,Number(Q.amount||0).toFixed(2),Q.paymentMethod==="wechat"?"微信支付":Q.paymentMethod==="alipay"?"支付宝":Q.paymentMethod||"微信支付",Q.status==="refunded"?"已退款":Q.status==="paid"||Q.status==="completed"?"已完成":Q.status==="pending"||Q.status==="created"?"待支付":"已失败",Q.status==="refunded"&&Q.refundReason?Q.refundReason:"-",Q.referrerEarnings?Number(Q.referrerEarnings).toFixed(2):"-",Q.createdAt?new Date(Q.createdAt).toLocaleString("zh-CN"):""].join(",")}),H="\uFEFF"+[G.join(","),...$].join(` -`),ce=new Blob([H],{type:"text/csv;charset=utf-8"}),W=URL.createObjectURL(ce),fe=document.createElement("a");fe.href=W,fe.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,fe.click(),URL.revokeObjectURL(W)}return s.jsxs("div",{className:"p-8 w-full",children:[I&&s.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:[s.jsx("span",{children:I}),s.jsx("button",{type:"button",onClick:()=>O(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(ee,{variant:"outline",onClick:J,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`}),"刷新"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"text-gray-400",children:"总收入:"}),s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),s.jsx("span",{className:"text-gray-600",children:"|"}),s.jsx("span",{className:"text-gray-400",children:"今日:"}),s.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:b,onChange:G=>j(G.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ww,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:N,onChange:G=>C(G.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(ee,{variant:"outline",onClick:ae,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(aM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:E?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"订单号"}),s.jsx(je,{className:"text-gray-400",children:"用户"}),s.jsx(je,{className:"text-gray-400",children:"商品"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"支付方式"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"退款原因"}),s.jsx(je,{className:"text-gray-400",children:"分销佣金"}),s.jsx(je,{className:"text-gray-400",children:"下单时间"}),s.jsx(je,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(G=>{const $=F(G);return s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(xe,{className:"font-mono text-xs text-gray-400",children:[(G.orderSn||G.id||"").slice(0,12),"..."]}),s.jsx(xe,{children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:U(G)}),s.jsx("p",{className:"text-gray-500 text-xs",children:R(G.userId)})]})}),s.jsx(xe,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[$.name,(G.productType||G.type)==="vip"&&s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"VIP"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:$.type})]})}),s.jsxs(xe,{className:"text-[#38bdac] font-bold",children:["¥",Number(G.amount||0).toFixed(2)]}),s.jsx(xe,{className:"text-gray-300",children:G.paymentMethod==="wechat"?"微信支付":G.paymentMethod==="alipay"?"支付宝":G.paymentMethod||"微信支付"}),s.jsx(xe,{children:G.status==="refunded"?s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):G.status==="paid"||G.status==="completed"?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):G.status==="pending"||G.status==="created"?s.jsx(Ue,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Ue,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),s.jsx(xe,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:G.refundReason,children:G.status==="refunded"&&G.refundReason?G.refundReason:"-"}),s.jsx(xe,{className:"text-[#FFD700]",children:G.referrerEarnings?`¥${Number(G.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(xe,{className:"text-gray-400 text-sm",children:new Date(G.createdAt).toLocaleString("zh-CN")}),s.jsx(xe,{children:(G.status==="paid"||G.status==="completed")&&s.jsxs(ee,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{P(G),_("")},children:[s.jsx(Gw,{className:"w-3 h-3 mr-1"}),"退款"]})})]},G.id)}),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(gs,{page:f,totalPages:re,total:i,pageSize:g,onPageChange:m,onPageSizeChange:G=>{y(G),m(1)}})]})})}),s.jsx(Kt,{open:!!D,onOpenChange:G=>!G&&P(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"订单退款"})}),D&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",D.orderSn||D.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(D.amount||0).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:L,onChange:G=>_(G.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>P(null),disabled:X,children:"取消"}),s.jsx(ee,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:z,disabled:X,children:X?"退款中...":"确认退款"})]})]})})]})}const _l=v.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:Ct("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}));_l.displayName="Textarea";const Mu=[{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 cP(){var Js,Ai,ks,Oa,Da;const[t,e]=zw(),n=t.get("pool"),[r,i]=v.useState([]),[a,o]=v.useState(0),[c,u]=v.useState(1),[h,f]=v.useState(10),[m,g]=v.useState(""),y=Yx(m,300),b=n==="vip"?"vip":n==="complete"?"complete":"all",[j,w]=v.useState(b),[N,C]=v.useState(!0),[E,M]=v.useState(!1),[I,O]=v.useState(null),[D,P]=v.useState(!1),[L,_]=v.useState("desc");v.useEffect(()=>{n==="vip"?w("vip"):n==="complete"?w("complete"):n==="all"&&w("all")},[n]);const[X,ne]=v.useState(!1),[J,U]=v.useState(null),[R,F]=v.useState(!1),[re,z]=v.useState(!1),[ae,G]=v.useState({referrals:[],stats:{}}),[$,H]=v.useState(!1),[ce,W]=v.useState(null),[fe,Q]=v.useState(!1),[de,he]=v.useState(null),[Ne,Te]=v.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Ve,He]=v.useState([]),[gt,Pt]=v.useState(!1),[wn,ht]=v.useState(!1),[At,te]=v.useState(null),[Pe,Qe]=v.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[xt,ft]=v.useState([]),[pt,wt]=v.useState(!1),[Xt,Ot]=v.useState(null),[Tn,Dt]=v.useState(null),[Kn,Xr]=v.useState({}),[ir,me]=v.useState(!1);async function ve(V=!1){var Re;C(!0),V&&M(!0),O(null);try{if(D){const Xe=new URLSearchParams({search:y,limit:String(h*5)}),et=await Le(`/api/db/users/rfm?${Xe}`);if(et!=null&&et.success){let Mn=et.users||[];L==="asc"&&(Mn=[...Mn].reverse());const lr=(c-1)*h;i(Mn.slice(lr,lr+h)),o(((Re=et.users)==null?void 0:Re.length)??0),Mn.length===0&&(P(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else P(!1),O((et==null?void 0:et.error)||"RFM 加载失败,已切回普通模式")}else{const Xe=new URLSearchParams({page:String(c),pageSize:String(h),search:y,...j==="vip"&&{vip:"true"},...j==="complete"&&{pool:"complete"}}),et=await Le(`/api/db/users?${Xe}`);et!=null&&et.success?(i(et.users||[]),o(et.total??0)):O((et==null?void 0:et.error)||"加载失败")}}catch(Xe){console.error("Load users error:",Xe),O("网络错误")}finally{C(!1),V&&M(!1)}}v.useEffect(()=>{u(1)},[y,j,D]),v.useEffect(()=>{ve()},[c,h,y,j,D,L]);const ar=Math.ceil(a/h)||1,Hs=()=>{D?L==="desc"?_("asc"):(P(!1),_("desc")):(P(!0),_("desc"))},ki=V=>({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"})[V||""]||"bg-gray-500/20 text-gray-400";async function Si(V){if(confirm("确定要删除这个用户吗?"))try{const Re=await Ps(`/api/db/users?id=${encodeURIComponent(V)}`);Re!=null&&Re.success?ve():ie.error("删除失败: "+((Re==null?void 0:Re.error)||""))}catch{ie.error("删除失败")}}const Sr=V=>{U(V),Te({phone:V.phone||"",nickname:V.nickname||"",password:"",isAdmin:!!(V.isAdmin??!1),hasFullBook:!!(V.hasFullBook??!1)}),ne(!0)},Aa=()=>{U(null),Te({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),ne(!0)};async function _r(){if(!Ne.phone||!Ne.nickname){ie.error("请填写手机号和昵称");return}F(!0);try{if(J){const V=await Mt("/api/db/users",{id:J.id,nickname:Ne.nickname,isAdmin:Ne.isAdmin,hasFullBook:Ne.hasFullBook,...Ne.password&&{password:Ne.password}});if(!(V!=null&&V.success)){ie.error("更新失败: "+((V==null?void 0:V.error)||""));return}}else{const V=await Nt("/api/db/users",{phone:Ne.phone,nickname:Ne.nickname,password:Ne.password,isAdmin:Ne.isAdmin});if(!(V!=null&&V.success)){ie.error("创建失败: "+((V==null?void 0:V.error)||""));return}}ne(!1),ve()}catch{ie.error("保存失败")}finally{F(!1)}}async function Zr(V){W(V),z(!0),H(!0);try{const Re=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(V.id)}`);Re!=null&&Re.success?G({referrals:Re.referrals||[],stats:Re.stats||{}}):G({referrals:[],stats:{}})}catch{G({referrals:[],stats:{}})}finally{H(!1)}}const or=v.useCallback(async()=>{Pt(!0);try{const V=await Le("/api/db/user-rules");V!=null&&V.success&&He(V.rules||[])}catch{}finally{Pt(!1)}},[]);async function Ci(){if(!Pe.title){ie.error("请填写规则标题");return}F(!0);try{if(At){const V=await Mt("/api/db/user-rules",{id:At.id,...Pe});if(!(V!=null&&V.success)){ie.error("更新失败: "+((V==null?void 0:V.error)||""));return}}else{const V=await Nt("/api/db/user-rules",Pe);if(!(V!=null&&V.success)){ie.error("创建失败: "+((V==null?void 0:V.error)||""));return}}ht(!1),or()}catch{ie.error("保存失败")}finally{F(!1)}}async function Ia(V){if(confirm("确定删除?"))try{const Re=await Ps(`/api/db/user-rules?id=${V}`);Re!=null&&Re.success&&or()}catch{}}async function Ws(V){try{await Mt("/api/db/user-rules",{id:V.id,enabled:!V.enabled}),or()}catch{}}const ot=v.useCallback(async()=>{wt(!0);try{const V=await Le("/api/db/vip-members?limit=500");if(V!=null&&V.success&&V.data){const Re=[...V.data].map((Xe,et)=>({...Xe,vipSort:typeof Xe.vipSort=="number"?Xe.vipSort:et+1}));Re.sort((Xe,et)=>(Xe.vipSort??999999)-(et.vipSort??999999)),ft(Re)}else V&&V.error&&ie.error(V.error)}catch{ie.error("加载超级个体列表失败")}finally{wt(!1)}},[]),[Ln,es]=v.useState(!1),[Cr,ts]=v.useState(null),[rn,zr]=v.useState(""),[Us,$r]=v.useState(!1),Ks=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],jn=V=>{ts(V),zr(V.vipRole||""),es(!0)},Ns=async V=>{const Re=V.trim();if(Cr){if(!Re){ie.error("请选择或输入标签");return}$r(!0);try{const Xe=await Mt("/api/db/users",{id:Cr.id,vipRole:Re});if(!(Xe!=null&&Xe.success)){ie.error((Xe==null?void 0:Xe.error)||"更新超级个体标签失败");return}ie.success("已更新超级个体标签"),es(!1),ts(null),await ot()}catch{ie.error("更新超级个体标签失败")}finally{$r(!1)}}},[Hl,Ei]=v.useState(!1),[qs,mr]=v.useState(null),[Ra,Ti]=v.useState(""),[Gs,ws]=v.useState(!1),Mi=V=>{mr(V),Ti(V.vipSort!=null?String(V.vipSort):""),Ei(!0)},To=async()=>{if(!qs)return;const V=Number(Ra);if(!Number.isFinite(V)){ie.error("请输入有效的数字序号");return}ws(!0);try{const Re=await Mt("/api/db/users",{id:qs.id,vipSort:V});if(!(Re!=null&&Re.success)){ie.error((Re==null?void 0:Re.error)||"更新排序序号失败");return}ie.success("已更新排序序号"),Ei(!1),mr(null),await ot()}catch{ie.error("更新排序序号失败")}finally{ws(!1)}},js=(V,Re)=>{V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/plain",Re),Ot(Re)},Pa=(V,Re)=>{V.preventDefault(),Tn!==Re&&Dt(Re)},Mo=()=>{Ot(null),Dt(null)},Tt=async(V,Re)=>{V.preventDefault();const Xe=V.dataTransfer.getData("text/plain")||Xt;if(Ot(null),Dt(null),!Xe||Xe===Re)return;const et=xt.find(Jt=>Jt.id===Xe),Mn=xt.find(Jt=>Jt.id===Re);if(!et||!Mn)return;const lr=et.vipSort??xt.findIndex(Jt=>Jt.id===Xe)+1,Io=Mn.vipSort??xt.findIndex(Jt=>Jt.id===Re)+1;ft(Jt=>{const _n=[...Jt],ns=_n.findIndex(Ii=>Ii.id===Xe),Ss=_n.findIndex(Ii=>Ii.id===Re);if(ns===-1||Ss===-1)return Jt;const Ys=[..._n],[Wl,La]=[Ys[ns],Ys[Ss]];return Ys[ns]={...La,vipSort:lr},Ys[Ss]={...Wl,vipSort:Io},Ys});try{const[Jt,_n]=await Promise.all([Mt("/api/db/users",{id:Xe,vipSort:Io}),Mt("/api/db/users",{id:Re,vipSort:lr})]);if(!(Jt!=null&&Jt.success)||!(_n!=null&&_n.success)){ie.error((Jt==null?void 0:Jt.error)||(_n==null?void 0:_n.error)||"更新排序失败"),await ot();return}ie.success("已更新排序"),await ot()}catch{ie.error("更新排序失败"),await ot()}},Ao=v.useCallback(async()=>{me(!0);try{const V=await Le("/api/db/users/journey-stats");V!=null&&V.success&&V.stats&&Xr(V.stats)}catch{}finally{me(!1)}},[]);return s.jsxs("div",{className:"p-8 w-full",children:[I&&s.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:[s.jsx("span",{children:I}),s.jsx("button",{type:"button",onClick:()=>O(null),children:"×"})]}),s.jsx("div",{className:"flex justify-between items-center mb-6",children:s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",a," 位注册用户",D&&" · RFM 排序中"]})]})}),s.jsxs(fd,{defaultValue:"users",className:"w-full",children:[s.jsxs(Ll,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(tn,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Un,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(tn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Ao,children:[s.jsx(pl,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(tn,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:or,children:[s.jsx(so,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(tn,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ot,children:[s.jsx(xl,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(nn,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(ee,{variant:"outline",onClick:()=>ve(!0),disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:j,onChange:V=>{const Re=V.target.value;w(Re),u(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:D,children:[s.jsx("option",{value:"all",children:"全部用户"}),s.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),s.jsx("option",{value:"complete",children:"完善资料用户"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:m,onChange:V=>g(V.target.value)})]}),s.jsxs(ee,{onClick:Aa,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Eg,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:N?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"用户信息"}),s.jsx(je,{className:"text-gray-400",children:"绑定信息"}),s.jsx(je,{className:"text-gray-400",children:"购买状态"}),s.jsx(je,{className:"text-gray-400",children:"分销收益"}),s.jsxs(je,{className:"text-gray-400 cursor-pointer select-none",onClick:Hs,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Oc,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),D?L==="desc"?s.jsx(Gc,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Fw,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(wm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),D&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(je,{className:"text-gray-400",children:"注册时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[r.map(V=>{var Re,Xe,et;return s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:V.avatar?s.jsx("img",{src:V.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Re=V.nickname)==null?void 0:Re.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{he(V.id),Q(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:V.nickname}),V.isAdmin&&s.jsx(Ue,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),V.openId&&!((Xe=V.id)!=null&&Xe.startsWith("user_"))&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsx("p",{className:"text-xs text-gray-500 font-mono",children:V.openId?V.openId.slice(0,12)+"...":(et=V.id)==null?void 0:et.slice(0,12)})]})]})}),s.jsx(xe,{children:s.jsxs("div",{className:"space-y-1",children:[V.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:V.phone})]}),V.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:V.wechatId})]}),V.openId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"🔗"}),s.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:V.openId,children:[V.openId.slice(0,12),"..."]})]}),!V.phone&&!V.wechatId&&!V.openId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(xe,{children:V.hasFullBook?s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):s.jsx(Ue,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),s.jsx(xe,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(V.earnings||0)).toFixed(2)]}),parseFloat(String(V.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(V.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Zr(V),role:"button",tabIndex:0,onKeyDown:Mn=>Mn.key==="Enter"&&Zr(V),children:[s.jsx(Un,{className:"w-3 h-3"})," 绑定",V.referralCount||0,"人"]})]})}),s.jsx(xe,{children:V.rfmScore!==void 0?s.jsx("div",{className:"flex flex-col gap-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:V.rfmScore}),s.jsx(Ue,{className:`border-0 text-xs ${ki(V.rfmLevel)}`,children:V.rfmLevel})]})}):s.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",s.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),s.jsx(xe,{className:"text-gray-400",children:V.createdAt?new Date(V.createdAt).toLocaleDateString():"-"}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>{he(V.id),Q(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(oh,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>Sr(V),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Si(V.id),title:"删除",children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},V.id)}),r.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(gs,{page:c,totalPages:ar,total:a,pageSize:h,onPageChange:u,onPageSizeChange:V=>{f(V),u(1)}})]})})})]}),s.jsxs(nn,{value:"journey",children:[s.jsxs("div",{className:"flex items-center justify-between mb-5",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),s.jsxs(ee,{variant:"outline",onClick:Ao,disabled:ir,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${ir?"animate-spin":""}`})," 刷新数据"]})]}),s.jsxs("div",{className:"relative mb-8",children:[s.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"}),s.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:Mu.map((V,Re)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${V.color} text-center cursor-default`,children:[s.jsx("div",{className:"text-2xl mb-1",children:V.icon}),s.jsx("div",{className:`text-xs font-medium ${V.color.split(" ").find(Xe=>Xe.startsWith("text-"))}`,children:V.label}),Kn[V.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Kn[V.id]})," 人"]}),s.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:Re+1})]}),Res.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:V.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:V.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",V.next]})]})]},V.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ps,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),s.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),ir?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ge,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Kn).length>0?s.jsx("div",{className:"space-y-2",children:Mu.map(V=>{const Re=Kn[V.id]||0,Xe=Math.max(...Mu.map(Mn=>Kn[Mn.id]||0),1),et=Math.round(Re/Xe*100);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[V.icon," ",V.label]}),s.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${et}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Re})]},V.id)})}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),s.jsxs(nn,{value:"rules",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ee,{variant:"outline",onClick:or,disabled:gt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${gt?"animate-spin":""}`})," 刷新"]}),s.jsxs(ee,{onClick:()=>{te(null),Qe({title:"",description:"",trigger:"",sort:0,enabled:!0}),ht(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),gt?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Ve.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(ps,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),s.jsxs(ee,{onClick:or,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ge,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:Ve.map(V=>s.jsx("div",{className:`p-4 rounded-lg border transition-all ${V.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[s.jsx(_t,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium",children:V.title}),V.trigger&&s.jsxs(Ue,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",V.trigger]}),s.jsx(Ue,{className:`text-xs border-0 ${V.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:V.enabled?"启用":"禁用"})]}),V.description&&s.jsx("p",{className:"text-gray-400 text-sm ml-6",children:V.description})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[s.jsx(Et,{checked:V.enabled,onCheckedChange:()=>Ws(V)}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>{te(V),Qe({title:V.title,description:V.description,trigger:V.trigger,sort:V.sort,enabled:V.enabled}),ht(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>Ia(V.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Bn,{className:"w-4 h-4"})})]})]})},V.id))})]}),s.jsxs(nn,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(ee,{variant:"outline",onClick:ot,disabled:pt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${pt?"animate-spin":""}`})," ","刷新"]})})]}),pt?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):xt.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(xl,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-16",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),s.jsx(je,{className:"text-gray-400 w-24",children:"排序值"}),s.jsx(je,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),s.jsx(tr,{children:xt.map((V,Re)=>{var Mn;const Xe=Xt===V.id,et=Tn===V.id;return s.jsxs(st,{draggable:!0,onDragStart:lr=>js(lr,V.id),onDragOver:lr=>Pa(lr,V.id),onDrop:lr=>Tt(lr,V.id),onDragEnd:Mo,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${Xe?"opacity-60":""} ${et?"bg-[#38bdac]/10":""}`,children:[s.jsx(xe,{className:"text-gray-300",children:Re+1}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[V.avatar?s.jsx("img",{src:V.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.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:((Mn=V.name)==null?void 0:Mn[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:V.name})})]})}),s.jsx(xe,{className:"text-gray-300 whitespace-nowrap",children:V.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),s.jsx(xe,{className:"text-gray-300",children:V.vipSort??Re+1}),s.jsx(xe,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>jn(V),title:"设置超级个体标签",children:s.jsx(qu,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{he(V.id),Q(!0)},title:"编辑资料",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Mi(V),title:"设置排序序号",children:s.jsx(wm,{className:"w-3.5 h-3.5"})})]})})]},V.id)})})]})})})]})]}),s.jsx(Kt,{open:Hl,onOpenChange:V=>{Ei(V),V||mr(null)},children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(wm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",qs==null?void 0:qs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Ra,onChange:V=>Ti(V.target.value)})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>Ei(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:To,disabled:Gs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),Gs?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:Ln,onOpenChange:V=>{es(V),V||ts(null)},children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(xl,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",Cr==null?void 0:Cr.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Ks.map(V=>s.jsx(ee,{variant:rn===V?"default":"outline",size:"sm",className:rn===V?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>zr(V),children:V},V))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:rn,onChange:V=>zr(V.target.value)})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>es(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:()=>Ns(rn),disabled:Us,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),Us?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:X,onOpenChange:ne,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[J?s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Eg,{className:"w-5 h-5 text-[#38bdac]"}),J?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:Ne.phone,onChange:V=>Te({...Ne,phone:V.target.value}),disabled:!!J})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:Ne.nickname,onChange:V=>Te({...Ne,nickname:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:J?"新密码 (留空则不修改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:J?"留空则不修改":"请输入密码",value:Ne.password,onChange:V=>Te({...Ne,password:V.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Et,{checked:Ne.isAdmin,onCheckedChange:V=>Te({...Ne,isAdmin:V})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-300",children:"已购全书"}),s.jsx(Et,{checked:Ne.hasFullBook,onCheckedChange:V=>Te({...Ne,hasFullBook:V})})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>ne(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:_r,disabled:R,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),R?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:wn,onOpenChange:ht,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),At?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Pe.title,onChange:V=>Qe({...Pe,title:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"规则描述"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Pe.description,onChange:V=>Qe({...Pe,description:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"触发条件"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Pe.trigger,onChange:V=>Qe({...Pe,trigger:V.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(Z,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Et,{checked:Pe.enabled,onCheckedChange:V=>Qe({...Pe,enabled:V})})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>ht(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:Ci,disabled:R,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),R?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:re,onOpenChange:z,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",ce==null?void 0:ce.nickname]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Js=ae.stats)==null?void 0:Js.total)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Ai=ae.stats)==null?void 0:Ai.purchased)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((ks=ae.stats)==null?void 0:ks.earnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((Oa=ae.stats)==null?void 0:Oa.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),$?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ge,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Da=ae.referrals)==null?void 0:Da.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(ae.referrals??[]).map((V,Re)=>{var et;const Xe=V;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((et=Xe.nickname)==null?void 0:et.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:Xe.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:Xe.phone||(Xe.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Xe.status==="vip"&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Xe.status==="paid"&&s.jsxs(Ue,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Xe.purchasedSections,"章"]}),Xe.status==="free"&&s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:Xe.createdAt?new Date(Xe.createdAt).toLocaleDateString():""})]})]},Xe.id||Re)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(hn,{children:s.jsx(ee,{variant:"outline",onClick:()=>z(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(Jx,{open:fe,onClose:()=>Q(!1),userId:de,onUserUpdated:ve})]})}function hh(t,[e,n]){return Math.min(n,Math.max(e,t))}var mk=["PageUp","PageDown"],gk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],xk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},zl="Slider",[Rg,dP,uP]=Ux(zl),[yk]=ka(zl,[uP]),[hP,xf]=yk(zl),vk=v.forwardRef((t,e)=>{const{name:n,min:r=0,max:i=100,step:a=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:b,...j}=t,w=v.useRef(new Set),N=v.useRef(0),E=o==="horizontal"?fP:pP,[M=[],I]=fo({prop:f,defaultProp:h,onChange:X=>{var J;(J=[...w.current][N.current])==null||J.focus(),m(X)}}),O=v.useRef(M);function D(X){const ne=vP(M,X);_(X,ne)}function P(X){_(X,N.current)}function L(){const X=O.current[N.current];M[N.current]!==X&&g(M)}function _(X,ne,{commit:J}={commit:!1}){const U=jP(a),R=kP(Math.round((X-r)/a)*a+r,U),F=hh(R,[r,i]);I((re=[])=>{const z=xP(re,F,ne);if(wP(z,u*a)){N.current=z.indexOf(F);const ae=String(z)!==String(re);return ae&&J&&g(z),ae?z:re}else return re})}return s.jsx(hP,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:i,valueIndexToChangeRef:N,thumbs:w.current,values:M,orientation:o,form:b,children:s.jsx(Rg.Provider,{scope:t.__scopeSlider,children:s.jsx(Rg.Slot,{scope:t.__scopeSlider,children:s.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...j,ref:e,onPointerDown:at(j.onPointerDown,()=>{c||(O.current=M)}),min:r,max:i,inverted:y,onSlideStart:c?void 0:D,onSlideMove:c?void 0:P,onSlideEnd:c?void 0:L,onHomeKeyDown:()=>!c&&_(r,0,{commit:!0}),onEndKeyDown:()=>!c&&_(i,M.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:ne})=>{if(!c){const R=mk.includes(X.key)||X.shiftKey&&gk.includes(X.key)?10:1,F=N.current,re=M[F],z=a*R*ne;_(re+z,F,{commit:!0})}}})})})})});vk.displayName=zl;var[bk,Nk]=yk(zl,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fP=v.forwardRef((t,e)=>{const{min:n,max:r,dir:i,inverted:a,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=v.useState(null),y=St(e,E=>g(E)),b=v.useRef(void 0),j=pf(i),w=j==="ltr",N=w&&!a||!w&&a;function C(E){const M=b.current||m.getBoundingClientRect(),I=[0,M.width],D=Qx(I,N?[n,r]:[r,n]);return b.current=M,D(E-M.left)}return s.jsx(bk,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:s.jsx(wk,{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:()=>{b.current=void 0,u==null||u()},onStepKeyDown:E=>{const I=xk[N?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:I?-1:1})}})})}),pP=v.forwardRef((t,e)=>{const{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=v.useRef(null),m=St(e,f),g=v.useRef(void 0),y=!i;function b(j){const w=g.current||f.current.getBoundingClientRect(),N=[0,w.height],E=Qx(N,y?[r,n]:[n,r]);return g.current=w,E(j-w.top)}return s.jsx(bk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:s.jsx(wk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=b(j.clientY);a==null||a(w)},onSlideMove:j=>{const w=b(j.clientY);o==null||o(w)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:j=>{const N=xk[y?"from-bottom":"from-top"].includes(j.key);u==null||u({event:j,direction:N?-1:1})}})})}),wk=v.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=xf(zl,n);return s.jsx(dt.span,{...h,ref:e,onKeyDown:at(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):mk.concat(gk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:at(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():r(m)}),onPointerMove:at(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&i(m)}),onPointerUp:at(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),a(m))})})}),jk="SliderTrack",kk=v.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=xf(jk,n);return s.jsx(dt.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:e})});kk.displayName=jk;var Pg="SliderRange",Sk=v.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=xf(Pg,n),a=Nk(Pg,n),o=v.useRef(null),c=St(e,o),u=i.values.length,h=i.values.map(g=>Tk(g,i.min,i.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(dt.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:c,style:{...t.style,[a.startEdge]:f+"%",[a.endEdge]:m+"%"}})});Sk.displayName=Pg;var Og="SliderThumb",Ck=v.forwardRef((t,e)=>{const n=dP(t.__scopeSlider),[r,i]=v.useState(null),a=St(e,c=>i(c)),o=v.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(mP,{...t,ref:a,index:o})}),mP=v.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:i,...a}=t,o=xf(Og,n),c=Nk(Og,n),[u,h]=v.useState(null),f=St(e,C=>h(C)),m=u?o.form||!!u.closest("form"):!0,g=Gx(u),y=o.values[r],b=y===void 0?0:Tk(y,o.min,o.max),j=yP(r,o.values.length),w=g==null?void 0:g[c.size],N=w?bP(w,b,c.direction):0;return v.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${b}% + ${N}px)`},children:[s.jsx(Rg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(dt.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,...a,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:at(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(Ek,{name:i??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},r)]})});Ck.displayName=Og;var gP="RadioBubbleInput",Ek=v.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const i=v.useRef(null),a=St(i,r),o=qx(e);return v.useEffect(()=>{const c=i.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]),s.jsx(dt.input,{style:{display:"none"},...n,ref:a,defaultValue:e})});Ek.displayName=gP;function xP(t=[],e,n){const r=[...t];return r[n]=e,r.sort((i,a)=>i-a)}function Tk(t,e,n){const a=100/(n-e)*(t-e);return hh(a,[0,100])}function yP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function vP(t,e){if(t.length===1)return 0;const n=t.map(i=>Math.abs(i-e)),r=Math.min(...n);return n.indexOf(r)}function bP(t,e,n){const r=t/2,a=Qx([0,50],[0,r]);return(r-a(e)*n)*n}function NP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function wP(t,e){if(e>0){const n=NP(t);return Math.min(...n)>=e}return!0}function Qx(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function jP(t){return(String(t).split(".")[1]||"").length}function kP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var SP=vk,CP=kk,EP=Sk,TP=Ck;function MP({className:t,defaultValue:e,value:n,min:r=0,max:i=100,...a}){const o=v.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,i],[n,e,r,i]);return s.jsxs(SP,{defaultValue:e,value:n,min:r,max:i,className:Ct("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...a,children:[s.jsx(CP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(EP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(TP,{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 AP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Mk(t){const[e,n]=v.useState(AP),[r,i]=v.useState(!0),[a,o]=v.useState(!1);v.useEffect(()=>{Le("/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(()=>i(!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){ie.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}ie.success(`✅ 分销配置已保存成功! - -• 小程序与网站的推广规则会一起生效 -• 绑定关系会使用新的天数配置 -• 佣金比例会立即应用到新订单 - -如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),ie.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 r?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(jl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),s.jsxs(ee,{onClick:c,disabled:a||r,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"flex items-center gap-2 text-white",children:[s.jsx(lA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx($t,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(Ae,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Un,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(MP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),s.jsx(oe,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Un,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(oe,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"flex items-center gap-2 text-white",children:[s.jsx(jl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx($t,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(Ae,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(oe,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Ue,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx(Et,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(bu,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(Ae,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[s.jsxs("p",{children:["1. 以上配置会写入"," ",s.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),s.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),s.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function IP(){var At;const[t,e]=v.useState("overview"),[n,r]=v.useState([]),[i,a]=v.useState(null),[o,c]=v.useState([]),[u,h]=v.useState([]),[f,m]=v.useState([]),[g,y]=v.useState(!0),[b,j]=v.useState(null),[w,N]=v.useState(""),[C,E]=v.useState("all"),[M,I]=v.useState(1),[O,D]=v.useState(10),[P,L]=v.useState(0),[_,X]=v.useState(new Set),[ne,J]=v.useState(null),[U,R]=v.useState(""),[F,re]=v.useState(!1),[z,ae]=v.useState(null),[G,$]=v.useState(""),[H,ce]=v.useState(!1);v.useEffect(()=>{W()},[]),v.useEffect(()=>{I(1)},[t,C]),v.useEffect(()=>{fe(t)},[t]),v.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&fe(t,!0)},[M,O,C,w]);async function W(){j(null);try{const te=await Le("/api/admin/distribution/overview");te!=null&&te.success&&te.overview&&a(te.overview)}catch(te){console.error("[Admin] 概览接口异常:",te),j("加载概览失败")}try{const te=await Le("/api/db/users");m((te==null?void 0:te.users)||[])}catch(te){console.error("[Admin] 用户数据加载失败:",te)}}async function fe(te,Pe=!1){var Qe;if(!(!Pe&&_.has(te))){y(!0);try{const xt=f;switch(te){case"overview":break;case"orders":{try{const ft=new URLSearchParams({page:String(M),pageSize:String(O),...C!=="all"&&{status:C},...w&&{search:w}}),pt=await Le(`/api/admin/orders?${ft}`);if(pt!=null&&pt.success&&pt.orders){const wt=pt.orders.map(Xt=>{const Ot=xt.find(Dt=>Dt.id===Xt.userId),Tn=Xt.referrerId?xt.find(Dt=>Dt.id===Xt.referrerId):null;return{...Xt,amount:parseFloat(String(Xt.amount))||0,userNickname:(Ot==null?void 0:Ot.nickname)||Xt.userNickname||"未知用户",userPhone:(Ot==null?void 0:Ot.phone)||Xt.userPhone||"-",referrerNickname:(Tn==null?void 0:Tn.nickname)||null,referrerCode:(Tn==null?void 0:Tn.referralCode)??null,type:Xt.productType||Xt.type}});r(wt),L(pt.total??wt.length)}else r([]),L(0)}catch(ft){console.error(ft),j("加载订单失败"),r([])}break}case"bindings":{try{const ft=new URLSearchParams({page:String(M),pageSize:String(O),...C!=="all"&&{status:C}}),pt=await Le(`/api/db/distribution?${ft}`);c((pt==null?void 0:pt.bindings)||[]),L((pt==null?void 0:pt.total)??((Qe=pt==null?void 0:pt.bindings)==null?void 0:Qe.length)??0)}catch(ft){console.error(ft),j("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const ft=C==="completed"?"success":C==="rejected"?"failed":C,pt=new URLSearchParams({...ft&&ft!=="all"&&{status:ft},page:String(M),pageSize:String(O)}),wt=await Le(`/api/admin/withdrawals?${pt}`);if(wt!=null&&wt.success&&wt.withdrawals){const Xt=wt.withdrawals.map(Ot=>({...Ot,account:Ot.account??"未绑定微信号",status:Ot.status==="success"?"completed":Ot.status==="failed"?"rejected":Ot.status}));h(Xt),L((wt==null?void 0:wt.total)??Xt.length)}else wt!=null&&wt.success||j(`获取提现记录失败: ${(wt==null?void 0:wt.error)||"未知错误"}`),h([])}catch(ft){console.error(ft),j("加载提现数据失败"),h([])}break}}X(ft=>new Set(ft).add(te))}catch(xt){console.error(xt)}finally{y(!1)}}}async function Q(){j(null),X(te=>{const Pe=new Set(te);return Pe.delete(t),Pe}),t==="overview"&&W(),await fe(t,!0)}async function de(te){if(confirm("确认审核通过并打款?"))try{const Pe=await Mt("/api/admin/withdrawals",{id:te,action:"approve"});if(!(Pe!=null&&Pe.success)){const Qe=(Pe==null?void 0:Pe.message)||(Pe==null?void 0:Pe.error)||"操作失败";ie.error(Qe);return}await Q()}catch(Pe){console.error(Pe),ie.error("操作失败")}}function he(te){ae(te),$("")}async function Ne(){const te=z;if(!te)return;const Pe=G.trim();if(!Pe){ie.error("请填写拒绝原因");return}ce(!0);try{const Qe=await Mt("/api/admin/withdrawals",{id:te,action:"reject",errorMessage:Pe});if(!(Qe!=null&&Qe.success)){ie.error((Qe==null?void 0:Qe.error)||"操作失败");return}ie.success("已拒绝该提现申请"),ae(null),$(""),await Q()}catch(Qe){console.error(Qe),ie.error("操作失败")}finally{ce(!1)}}function Te(){z&&ie.info("已取消操作"),ae(null),$("")}async function Ve(){var te;if(!(!(ne!=null&&ne.orderSn)&&!(ne!=null&&ne.id))){re(!0),j(null);try{const Pe=await Mt("/api/admin/orders/refund",{orderSn:ne.orderSn||ne.id,reason:U||void 0});Pe!=null&&Pe.success?(J(null),R(""),await fe("orders",!0)):j((Pe==null?void 0:Pe.error)||"退款失败")}catch(Pe){const Qe=Pe;j(((te=Qe==null?void 0:Qe.data)==null?void 0:te.error)||"退款失败,请检查网络后重试")}finally{re(!1)}}}function He(te){const Pe={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 s.jsx(Ue,{className:`${Pe[te]||"bg-gray-500/20 text-gray-400"} border-0`,children:Qe[te]||te})}const gt=Math.ceil(P/O)||1,Pt=n,wn=o.filter(te=>{var Qe,xt,ft,pt;if(!w)return!0;const Pe=w.toLowerCase();return((Qe=te.refereeNickname)==null?void 0:Qe.toLowerCase().includes(Pe))||((xt=te.refereePhone)==null?void 0:xt.includes(Pe))||((ft=te.referrerName)==null?void 0:ft.toLowerCase().includes(Pe))||((pt=te.referrerCode)==null?void 0:pt.toLowerCase().includes(Pe))}),ht=u.filter(te=>{var Qe;if(!w)return!0;const Pe=w.toLowerCase();return((Qe=te.userName)==null?void 0:Qe.toLowerCase().includes(Pe))||te.account&&te.account.toLowerCase().includes(Pe)});return s.jsxs("div",{className:"p-8 w-full",children:[b&&s.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:[s.jsx("span",{children:b}),s.jsx("button",{type:"button",onClick:()=>j(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),s.jsxs(ee,{onClick:Q,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),s.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:Oc},{key:"orders",label:"订单管理",icon:ah},{key:"bindings",label:"绑定管理",icon:ms},{key:"withdrawals",label:"提现审核",icon:jl},{key:"settings",label:"推广设置",icon:so}].map(te=>s.jsxs("button",{type:"button",onClick:()=>{e(te.key),E("all"),N("")},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===te.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[s.jsx(te.icon,{className:"w-4 h-4"}),te.label]},te.key))}),g?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ge,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[t==="overview"&&i&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayClicks}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(oh,{className:"w-6 h-6 text-blue-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayUniqueVisitors??0}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:s.jsx(Un,{className:"w-6 h-6 text-cyan-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(i.todayClickRate??0).toFixed(2)}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:s.jsx(Oc,{className:"w-6 h-6 text-amber-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayBindings})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:s.jsx(ms,{className:"w-6 h-6 text-green-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayConversions})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:s.jsx(Pb,{className:"w-6 h-6 text-purple-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),s.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",i.todayEarnings.toFixed(2)]})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:s.jsx(ah,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((At=i.todayClicksByPage)==null?void 0:At.length)??0)>0&&s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(oh,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),s.jsx(Ae,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),s.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),s.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),s.jsx("tbody",{children:[...i.todayClicksByPage??[]].sort((te,Pe)=>Pe.clicks-te.clicks).map((te,Pe)=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:te.page||"(未区分)"}),s.jsx("td",{className:"py-2 pr-4 text-right text-white",children:te.clicks}),s.jsxs("td",{className:"py-2 text-right text-gray-400",children:[i.todayClicks>0?(te.clicks/i.todayClicks*100).toFixed(1):0,"%"]})]},Pe))})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Me,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:s.jsx(jg,{className:"w-6 h-6 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.expiringBindings," 个"]}),s.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),s.jsx(Me,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(jl,{className:"w-6 h-6 text-blue-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.pendingWithdrawals," 笔"]}),s.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",i.pendingWithdrawAmount.toFixed(2)]})]}),s.jsx(ee,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ih,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthClicks})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthBindings})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",i.monthEarnings.toFixed(2)]})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Oc,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),s.jsxs(Ae,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalClicks.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalBindings.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",i.totalEarnings.toFixed(2)]})]})]}),s.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[s.jsx("span",{className:"text-gray-300",children:"点击转化率"}),s.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[i.conversionRate,"%"]})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-white",children:i.totalDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-green-400",children:i.activeDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:w,onChange:te=>N(te.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:te=>E(te.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-0",children:[n.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Pt.map(te=>{var Pe,Qe;return s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Pe=te.id)==null?void 0:Pe.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:te.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:te.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const xt=te.productType||te.type;return xt==="fullbook"?`${te.bookName||"《底层逻辑》"} - 全本`:xt==="match"?"匹配次数购买":`${te.bookName||"《底层逻辑》"} - ${te.sectionTitle||te.chapterTitle||`章节${te.productId||te.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const xt=te.productType||te.type;return xt==="fullbook"?"全书解锁":xt==="match"?"功能权益":te.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof te.amount=="number"?te.amount.toFixed(2):parseFloat(String(te.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:te.paymentMethod==="wechat"?"微信支付":te.paymentMethod==="alipay"?"支付宝":te.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:te.status==="refunded"?s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):te.status==="completed"||te.status==="paid"?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):te.status==="pending"||te.status==="created"?s.jsx(Ue,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Ue,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:te.refundReason,children:te.status==="refunded"&&te.refundReason?te.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:te.referrerId||te.referralCode?s.jsxs("span",{title:te.referralCode||te.referrerCode||te.referrerId||"",children:[te.referrerNickname||te.referralCode||te.referrerCode||((Qe=te.referrerId)==null?void 0:Qe.slice(0,8)),(te.referralCode||te.referrerCode)&&` (${te.referralCode||te.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:te.referrerEarnings?`¥${(typeof te.referrerEarnings=="number"?te.referrerEarnings:parseFloat(String(te.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:te.createdAt?new Date(te.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(te.status==="paid"||te.status==="completed")&&s.jsxs(ee,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{J(te),R("")},children:[s.jsx(Gw,{className:"w-3 h-3 mr-1"}),"退款"]})})]},te.id)})})]})}),t==="orders"&&s.jsx(gs,{page:M,totalPages:gt,total:P,pageSize:O,onPageChange:I,onPageSizeChange:te=>{D(te),I(1)}})]})})]}),t==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:w,onChange:te=>N(te.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:te=>E(te.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"有效"}),s.jsx("option",{value:"converted",children:"已转化"}),s.jsx("option",{value:"expired",children:"已过期"})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-0",children:[wn.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:wn.map(te=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:te.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:te.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:te.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:te.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:te.boundAt?new Date(te.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:te.expiresAt?new Date(te.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:He(te.status)}),s.jsx("td",{className:"p-4",children:te.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",te.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},te.id))})]})}),t==="bindings"&&s.jsx(gs,{page:M,totalPages:gt,total:P,pageSize:O,onPageChange:I,onPageSizeChange:te=>{D(te),I(1)}})]})})]}),t==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:w,onChange:te=>N(te.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:te=>E(te.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待审核"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"rejected",children:"已拒绝"})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-0",children:[ht.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:ht.map(te=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[te.userAvatar?s.jsx("img",{src:te.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(te.userName||te.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:te.userName||te.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",te.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Ue,{className:te.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:te.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:te.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:te.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:te.createdAt?new Date(te.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:He(te.status)}),s.jsx("td",{className:"p-4 text-right",children:te.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(ee,{size:"sm",onClick:()=>de(te.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Pb,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(ee,{size:"sm",variant:"outline",onClick:()=>he(te.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(Vw,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},te.id))})]})}),t==="withdrawals"&&s.jsx(gs,{page:M,totalPages:gt,total:P,pageSize:O,onPageChange:I,onPageSizeChange:te=>{D(te),I(1)}})]})})]})]}),s.jsx(Kt,{open:!!ne,onOpenChange:te=>!te&&J(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"订单退款"})}),ne&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",ne.orderSn||ne.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof ne.amount=="number"?ne.amount.toFixed(2):parseFloat(String(ne.amount||"0")).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:U,onChange:te=>R(te.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>J(null),disabled:F,children:"取消"}),s.jsx(ee,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Ve,disabled:F,children:F?"退款中...":"确认退款"})]})]})}),s.jsx(Kt,{open:!!z,onOpenChange:te=>!te&&Te(),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:G,onChange:te=>$(te.target.value)})})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Te,disabled:H,children:"取消"}),s.jsx(ee,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:Ne,disabled:H||!G.trim(),children:H?"提交中...":"确认拒绝"})]})]})}),t==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(Mk,{embedded:!0})})]})}function RP(){const[t,e]=v.useState([]),[n,r]=v.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[i,a]=v.useState(!0),[o,c]=v.useState(null),[u,h]=v.useState("all"),[f,m]=v.useState(1),[g,y]=v.useState(10),[b,j]=v.useState(0),[w,N]=v.useState(null),[C,E]=v.useState(null),[M,I]=v.useState(""),[O,D]=v.useState(!1);async function P(){var R,F,re,z,ae,G,$;a(!0),c(null);try{const H=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),ce=await Le(`/api/admin/withdrawals?${H}`);if(ce!=null&&ce.success){const W=ce.withdrawals||[];e(W),j(ce.total??((R=ce.stats)==null?void 0:R.total)??W.length),r({total:((F=ce.stats)==null?void 0:F.total)??ce.total??W.length,pendingCount:((re=ce.stats)==null?void 0:re.pendingCount)??0,pendingAmount:((z=ce.stats)==null?void 0:z.pendingAmount)??0,successCount:((ae=ce.stats)==null?void 0:ae.successCount)??0,successAmount:((G=ce.stats)==null?void 0:G.successAmount)??0,failedCount:(($=ce.stats)==null?void 0:$.failedCount)??0})}else c("加载提现记录失败")}catch(H){console.error("Load withdrawals error:",H),c("加载失败,请检查网络后重试")}finally{a(!1)}}v.useEffect(()=>{m(1)},[u]),v.useEffect(()=>{P()},[u,f,g]);const L=Math.ceil(b/g)||1;async function _(R){const F=t.find(re=>re.id===R);if(F!=null&&F.userCommissionInfo&&F.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${F.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 - -确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;N(R);try{const re=await Mt("/api/admin/withdrawals",{id:R,action:"approve"});re!=null&&re.success?P():ie.error("操作失败: "+((re==null?void 0:re.error)??""))}catch{ie.error("操作失败")}finally{N(null)}}function X(R){E(R),I("")}async function ne(){const R=C;if(!R)return;const F=M.trim();if(!F){ie.error("请填写拒绝原因");return}D(!0);try{const re=await Mt("/api/admin/withdrawals",{id:R,action:"reject",errorMessage:F});re!=null&&re.success?(ie.success("已拒绝该提现申请"),E(null),I(""),P()):ie.error("操作失败: "+((re==null?void 0:re.error)??""))}catch{ie.error("操作失败")}finally{D(!1)}}function J(){C&&ie.info("已取消操作"),E(null),I("")}function U(R){switch(R){case"pending":return s.jsx(Ue,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Ue,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Ue,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Ue,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0",children:R})}}return s.jsxs("div",{className:"p-8 w-full",children:[o&&s.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:[s.jsx("span",{children:o}),s.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),s.jsxs(ee,{variant:"outline",onClick:P,disabled:i,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Me,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(Ae,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(ah,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),s.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",s.jsx("span",{className:"text-white font-medium",children:"90%"})]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准"]})]})]})]})})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),s.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),s.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),s.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(R=>s.jsx(ee,{variant:u===R?"default":"outline",size:"sm",onClick:()=>h(R),className:u===R?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:R==="all"?"全部":R==="pending"?"待处理":R==="success"?"已完成":"已拒绝"},R))}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:i?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(jl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(R=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(R.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[R.userAvatar?s.jsx("img",{src:R.userAvatar,alt:R.userName??"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(R.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:R.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:R.userPhone??R.referralCode??(R.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(R.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:R.userCommissionInfo?s.jsxs("div",{className:"text-xs space-y-1",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",R.userCommissionInfo.totalCommission.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"已提现:"}),s.jsxs("span",{className:"text-gray-400",children:["¥",R.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"待审核:"}),s.jsxs("span",{className:"text-orange-400",children:["¥",R.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[s.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),s.jsxs("span",{className:R.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",R.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsxs("td",{className:"p-4",children:[U(R.status),R.errorMessage&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:R.errorMessage})]}),s.jsx("td",{className:"p-4 text-gray-400",children:R.processedAt?new Date(R.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:R.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:R.userConfirmedAt,children:["已确认 ",new Date(R.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(R.status==="pending"||R.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(ee,{size:"sm",onClick:()=>_(R.id),disabled:w===R.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(df,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(ee,{size:"sm",variant:"outline",onClick:()=>X(R.id),disabled:w===R.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(R.status==="success"||R.status==="completed")&&R.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:R.transactionId})]})]},R.id))})]})}),s.jsx(gs,{page:f,totalPages:L,total:b,pageSize:g,onPageChange:m,onPageSizeChange:R=>{y(R),m(1)}})]})})}),s.jsx(Kt,{open:!!C,onOpenChange:R=>!R&&J(),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:M,onChange:R=>I(R.target.value)})})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:J,disabled:O,children:"取消"}),s.jsx(ee,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ne,disabled:O||!M.trim(),children:O?"提交中...":"确认拒绝"})]})]})})]})}var Dm={exports:{}},Lm={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var s1;function PP(){if(s1)return Lm;s1=1;var t=cd();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,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),b=r({inst:{value:y,getSnapshot:g}}),j=b[0].inst,w=b[1];return a(function(){j.value=y,j.getSnapshot=g,u(j)&&w({inst:j})},[m,y,g]),i(function(){return u(j)&&w({inst:j}),m(function(){u(j)&&w({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 Lm.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Lm}var i1;function Ak(){return i1||(i1=1,Dm.exports=PP()),Dm.exports}var Ik=Ak();function Fn(t){this.content=t}Fn.prototype={constructor:Fn,find:function(t){for(var e=0;e>1}};Fn.from=function(t){if(t instanceof Fn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Fn(e)};function Rk(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=Rk(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Pk(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),c=e.child(--a),u=o.nodeSize;if(o==c){n-=u,r-=u;continue}if(!o.sameMarkup(c))return{a:n,b:r};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&r(u,i+c,a||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),r,i+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",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?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&r&&(o?o=!1:a+=r),a+=h},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);ae)for(let a=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))),r.push(c),i+=c.nodeSize),o=u}return new ge(r,i)}cutByIndex(e,n){return e==n?ge.empty:e==0&&n==this.content.length?this:new ge(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new ge(i,a)}addToStart(e){return new ge([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ge(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,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Au(n+1,a):Au(n,r);r=a}}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 ge.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ge(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ge.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}};Rt.none=[];class ph extends Error{}class Ie{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Dk(this.content,e+this.openStart,n);return r&&new Ie(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ie(Ok(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 Ie.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ie(ge.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Ie(e,r,i)}}Ie.empty=new Ie(ge.empty,0,0);function Ok(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:c}=t.findIndex(n);if(i==e||a.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(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(Ok(a.content,e-i-1,n-i-1)))}function Dk(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Dk(o.content,e-a-1,n,o);return c&&t.replaceChild(i,o.copy(c))}function OP(t,e,n){if(n.openStart>t.depth)throw new ph("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ph("Inconsistent open depths");return Lk(t,e,n,0)}function Lk(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Dc(t,e,n,r){let i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(io(t.nodeAfter,r),a++));for(let c=a;ci&&Lg(t,e,i+1),o=r.depth>i&&Lg(n,r,i+1),c=[];return Dc(null,t,i,c),a&&o&&e.index(i)==n.index(i)?(_k(a,o),io(ao(a,zk(t,e,n,r,i+1)),c)):(a&&io(ao(a,mh(t,e,i+1)),c),Dc(e,n,i,c),o&&io(ao(o,mh(n,r,i+1)),c)),Dc(r,null,i,c),new ge(c)}function mh(t,e,n){let r=[];if(Dc(null,t,n,r),t.depth>n){let i=Lg(t,e,n+1);io(ao(i,mh(t,e,n+1)),r)}return Dc(e,null,n,r),new ge(r)}function DP(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(ge.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Yc{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,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 r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}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 r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new gh(this,e,r);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 r=[],i=0,a=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(a),h=a-u;if(r.push(o,c,i+u),!h||(o=o.child(c),o.isText))break;a=h-1,i+=u+1}return new Yc(n,r,a)}static resolveCached(e,n){let r=a1.get(e);if(r)for(let a=0;ae&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}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()+")"),$k(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,r=ge.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=i;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 r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let i=ge.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};xi.prototype.text=void 0;class xh extends xi{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$k(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 xh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xh(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 $k(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class mo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new $P(e,n);if(r.next==null)return mo.empty;let i=Fk(r);r.next&&r.err("Unexpected trailing text");let a=KP(UP(i));return qP(a,r),a}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(r){e.push(r);for(let i=0;i{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return a}).join(` -`)}}mo.empty=new mo(!0);class $P{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 Fk(t){let e=[];do e.push(FP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function FP(t){let e=[];do e.push(BP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function BP(t){let e=WP(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=VP(t,e);else break;return e}function o1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function VP(t,e){let n=o1(t),r=n;return t.eat(",")&&(t.next!="}"?r=o1(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function HP(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function WP(t){if(t.eat("(")){let e=Fk(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=HP(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 UP(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function i(o,c){o.forEach(u=>u.to=c)}function a(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(a(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=a(o.exprs[u],c);if(u==o.exprs.length-1)return h;i(h,c=n())}else if(o.type=="star"){let u=n();return r(c,u),i(a(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return i(a(o.expr,c),u),i(a(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(c)].concat(a(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||i.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let a=e[r.join(",")]=new mo(r.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:Hk(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xi(this,this.computeAttrs(e),ge.from(n),Rt.setFrom(r))}createChecked(e=null,n,r){return n=ge.from(n),this.checkContent(n),new xi(this,this.computeAttrs(e),n,Rt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ge.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(ge.empty,!0);return a?new xi(this,e,n.append(a),Rt.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[a]=new Kk(a,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function GP(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class JP{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?GP(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class yf{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Uk(e,i.attrs),this.excluded=null;let a=Vk(this.attrs);this.instance=a?new Rt(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Rt(this,Hk(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new yf(a,i++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class qk{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Fn.from(e.nodes),n.marks=Fn.from(e.marks||{}),this.nodes=c1.compile(this.spec.nodes,this),this.marks=yf.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",c=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=mo.parse(o,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=c=="_"?null:c?d1(this,c.split(" ")):c==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:d1(this,o.split(" "))}this.nodeFromJSON=i=>xi.fromJSON(this,i),this.markFromJSON=i=>Rt.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof c1){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,r,i)}text(e,n){let r=this.nodes.text;return new xh(r,r.defaultAttrs,e,Rt.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 d1(t,e){let n=[];for(let r=0;r-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function YP(t){return t.tag!=null}function QP(t){return t.style!=null}class ha{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(YP(i))this.tags.push(i);else if(QP(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new h1(this,n,!1);return r.addAll(e,Rt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new h1(this,n,!0);return r.addAll(e,Rt.none,n.from,n.to),Ie.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.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 r(i){let a=i.priority==null?50:i.priority,o=0;for(;o{r(o=f1(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=f1(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ha(e,ha.schemaRules(e)))}}const Gk={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},XP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jk={ol:!0,ul:!0},Qc=1,zg=2,Lc=4;function u1(t,e,n){return e!=null?(e?Qc:0)|(e==="full"?zg:0):t&&t.whitespace=="pre"?Qc|zg:n&~Lc}class Iu{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Rt.none,this.match=a||(o&Lc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ge.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qc)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=ge.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ge.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&&!Gk.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class h1{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=u1(null,n.preserveWhitespace,0)|(r?Lc:0);i?a=new Iu(i.type,i.attrs,Rt.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new Iu(null,null,Rt.none,!0,null,o):a=new Iu(e.schema.topNodeType,null,Rt.none,!0,null,o),this.nodes=[a],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 r=e.nodeValue,i=this.top,a=i.options&zg?"full":this.localPreserveWS||(i.options&Qc)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,` -`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=r.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,r,i){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(a=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!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,r),this.findAround(e,u,!1)}a&&this.sync(c)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];o!=c;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!i||i.length>h.length+c)&&(i=h,a=u,!h.length))break;if(u.solid){if(r)break;c+=2}}if(!i)return null;this.sync(a);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):p1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new Iu(e,n,u,i,null,c)),this.open++,r}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|=Qc)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?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>=a;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&i?this.nodes[u].type:r&&u>=a?r.node(u-a).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 r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function ZP(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jk.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function eO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function f1(t){let e={};for(let n in t)e[n]=t[n];return e}function p1(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=c=>{a.push(c);for(let u=0;u{if(a.length||o.marks.length){let c=0,u=0;for(;c=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Yu(zm(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Yu(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new So(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=m1(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return m1(e.marks)}}function m1(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zm(t){return t.document||window.document}const g1=new WeakMap;function tO(t){let e=g1.get(t);return e===void 0&&g1.set(t,e=nO(t)),e}function nO(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-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=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let c,u=n?t.createElementNS(n,i):t.createElement(i),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:b}=Yu(t,g,n,r);if(u.appendChild(y),b){if(c)throw new RangeError("Multiple content holes");c=b}}}return{dom:u,contentDOM:c}}const Yk=65535,Qk=Math.pow(2,16);function rO(t,e){return t+e*Qk}function x1(t){return t&Yk}function sO(t){return(t-(t&Yk))/Qk}const Xk=1,Zk=2,Qu=4,eS=8;class $g{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&eS)>0}get deletedBefore(){return(this.delInfo&(Xk|Qu))>0}get deletedAfter(){return(this.delInfo&(Zk|Qu))>0}get deletedAcross(){return(this.delInfo&Qu)>0}}class Pr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Pr.empty)return Pr.empty}recover(e){let n=0,r=x1(e);if(!this.inverted)for(let i=0;ie)break;let h=this.ranges[c+a],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+i+(g<0?0:f);if(r)return y;let b=e==(n<0?u:m)?null:rO(c/3,e-u),j=e==u?Zk:e==m?Xk:Qu;return(n<0?e!=u:e!=m)&&(j|=eS),new $g(y,j,b)}i+=f-h}return r?e+i:new $g(e+i,0,null)}touches(e,n){let r=0,i=x1(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+a],f=u+h;if(e<=f&&c==i*3)return!0;r+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Xc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ra&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return vn.fromReplace(e,this.from,this.to,a)}invert(){return new fs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new aa(n.pos,r.pos,this.mark)}merge(e){return e instanceof aa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new aa(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 aa(n.from,n.to,e.markFromJSON(n.mark))}}sr.jsonID("addMark",aa);class fs extends sr{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Ie(Xx(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return vn.fromReplace(e,this.from,this.to,r)}invert(){return new aa(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new fs(n.pos,r.pos,this.mark)}merge(e){return e instanceof fs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new fs(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 fs(n.from,n.to,e.markFromJSON(n.mark))}}sr.jsonID("removeMark",fs);class oa extends sr{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return vn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return vn.fromReplace(e,this.pos,this.pos+1,new Ie(ge.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new On(n.pos,r.pos,i,a,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 On(n.from,n.to,n.gapFrom,n.gapTo,Ie.fromJSON(e,n.slice),n.insert,!!n.structure)}}sr.jsonID("replaceAround",On);function Fg(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function iO(t,e,n,r){let i=[],a=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&f.type.allowsMarkType(r.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),b=r.addToSet(m);for(let j=0;jt.step(u)),a.forEach(u=>t.step(u))}function aO(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;a++;let u=null;if(r instanceof yf){let h=o.marks,f;for(;f=r.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new fs(o.from,o.to,o.style)))}function Zx(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function oO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $l(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+i,u=t.$to.indexAfter(r)-a;if(rn;b--)j||r.index(b)>0?(j=!0,f=ge.from(r.node(b).copy(f)),m++):u--;let g=ge.empty,y=0;for(let b=a,j=!1;b>n;b--)j||i.after(b+1)=0;o--){if(r.size){let c=n[o].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ge.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new On(i,a,i,a,new Ie(r,0,0),n.length,!0))}function hO(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,u)&&fO(t.doc,t.mapping.slice(a).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!b?h=!1:!y&&b&&(h=!0)}h===!1&&nS(t,o,c,a),Zx(t,t.mapping.slice(a).map(c,1),r,void 0,h===null);let f=t.mapping.slice(a),m=f.map(c,1),g=f.map(c+o.nodeSize,1);return t.step(new On(m,g,m+1,g-1,new Ie(ge.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&tS(t,o,c,a),!1}})}function tS(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(i.text);){let u=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function nS(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(` -`))}})}function fO(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function pO(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new On(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ie(ge.from(o),0,0),1,!0))}function yi(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let h=i.depth-1,f=n-2;h>a;h--,f--){let m=i.node(h),g=i.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),b=r&&r[f+1];b&&(y=y.replaceChild(0,b.type.create(b.attrs)));let j=r&&r[f]||m;if(!m.canReplace(g+1,m.childCount)||!j.type.validContent(y))return!1}let c=i.indexAfter(a),u=r&&r[0];return i.node(a).canReplaceWith(c,c,u?u.type:i.node(a+1).type)}function mO(t,e,n=1,r){let i=t.doc.resolve(e),a=ge.empty,o=ge.empty;for(let c=i.depth,u=i.depth-n,h=n-1;c>u;c--,h--){a=ge.from(i.node(c).copy(a));let f=r&&r[h];o=ge.from(f?f.type.create(f.attrs,o):i.node(c).copy(o))}t.step(new Pn(e,e,new Ie(a.append(o),n,n),!0))}function Sa(t,e){let n=t.resolve(e),r=n.index();return rS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function gO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i0?(a=r.node(i+1),c++,o=r.node(i).maybeChild(c)):(a=r.node(i).maybeChild(c-1),o=r.node(i+1)),a&&!a.isTextblock&&rS(a,o)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function xO(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(i);f&&!m?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);nS(t,f.node(),f.before(),c)}o.inlineContent&&Zx(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new Pn(h,u.map(e+n,-1),Ie.empty,!0)),r===!0){let f=t.doc.resolve(h);tS(t,f.node(),f.before(),t.steps.length)}return t}function yO(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a=0;o--){let c=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(c>0?1:0),h=r.node(o),f=!1;if(a==1)f=h.canReplace(u,u,i);else{let m=h.contentMatchAt(u).findWrapping(i.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?r.pos:c<0?r.before(o+1):r.after(o+1)}return null}function bf(t,e,n=e,r=Ie.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return iS(i,a,r)?new Pn(e,n,r):new vO(i,a,r).fit()}function iS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class vO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ge.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=ge.from(e.node(i).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,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,c=i.depth;for(;o&&c&&a.childCount==1;)a=a.firstChild.content,o--,c--;let u=new Ie(a,o,c);return e>-1?new On(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new Pn(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=Fm(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.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(ge.from(o),!1)):a&&u.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:c,parent:a,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:c,parent:a,wrap:f};if(a&&h.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Fm(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ie(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Fm(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ie(Ec(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ie(Ec(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let j=0;j1||u==0||j.content.size)&&(m=w,f.push(aS(j.mark(g.allowedMarks(j.marks)),h==1?u:0,h==c.childCount?y:-1)))}let b=h==c.childCount;b||(y=-1),this.placed=Tc(this.placed,n,ge.from(f)),this.frontier[n].match=m,b&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=c;j1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n=0;c--){let{match:u,type:h}=this.frontier[c],f=Bm(e,c,h,u,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:a?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=Tc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Tc(this.placed,this.depth,ge.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ge.empty,!0);n.childCount&&(this.placed=Tc(this.placed,this.frontier.length,n))}}function Ec(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ec(t.firstChild.content,e-1,n)))}function Tc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Tc(t.lastChild.content,e-1,n)))}function Fm(t,e){for(let n=0;n1&&(r=r.replaceChild(0,aS(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(ge.empty,!0)))),t.copy(r)}function Bm(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let c=r.fillBefore(a.content,!0,o);return c&&!bO(n,a.content,o)?c:null}function bO(t,e,n){for(let r=n;r0;g--,y--){let b=i.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;o.indexOf(g)>-1?c=g:i.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=r.openStart;for(let g=r.content,y=0;;y++){let b=g.firstChild;if(h.push(b),y==r.openStart)break;g=b.content}for(let g=f-1;g>=0;g--){let y=h[g],b=NO(y.type);if(b&&!y.sameMarkup(i.node(Math.abs(c)-1)))f=g;else if(b||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+f+1)%(r.openStart+1),b=h[y];if(b)for(let j=0;j=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=i.before(y),n=a.after(y))}}function oS(t,e,n,r,i){if(er){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(ge.empty,!0))}return t}function jO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=yO(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ie(ge.from(r),0,0))}function kO(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=lS(r,i);for(let o=0;o0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return t.delete(r.before(c),i.after(c))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function lS(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(ae.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class bl extends sr{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return vn.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return vn.fromReplace(e,this.pos,this.pos+1,new Ie(ge.from(i),0,n.isLeaf?0:1))}getMap(){return Pr.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)}}sr.jsonID("attr",bl);class Zc extends sr{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return vn.ok(r)}getMap(){return Pr.empty}invert(e){return new Zc(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 Zc(n.attr,n.value)}}sr.jsonID("docAttr",Zc);let kl=class extends Error{};kl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kl.prototype=Object.create(Error.prototype);kl.prototype.constructor=kl;kl.prototype.name="TransformError";class t0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new kl(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 r=0;r{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,r=Ie.empty){let i=bf(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ie(ge.from(r),0,0))}delete(e,n){return this.replace(e,n,Ie.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return wO(this,e,n,r),this}replaceRangeWith(e,n,r){return jO(this,e,n,r),this}deleteRange(e,n){return kO(this,e,n),this}lift(e,n){return lO(this,e,n),this}join(e,n=1){return xO(this,e,n),this}wrap(e,n){return uO(this,e,n),this}setBlockType(e,n=e,r,i=null){return hO(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return pO(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new bl(e,n,r)),this}setDocAttribute(e,n){return this.step(new Zc(e,n)),this}addNodeMark(e,n){return this.step(new oa(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Rt)n.isInSet(r.marks)&&this.step(new go(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new go(e,a)),i=a.removeFromSet(i);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,r){return mO(this,e,n,r),this}addMark(e,n,r){return iO(this,e,n,r),this}removeMark(e,n,r){return aO(this,e,n,r),this}clearIncompatible(e,n,r){return Zx(this,e,n,r),this}}const Vm=Object.create(null);class Ze{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new cS(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;a--){let o=n<0?ll(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):ll(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Dr(e.node(0))}static atStart(e){return ll(e,e,0,0,1)||new Dr(e)}static atEnd(e){return ll(e,e,e.content.size,e.childCount,-1)||new Dr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Vm[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Vm)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vm[e]=n,n.prototype.jsonID=e,n}getBookmark(){return qe.between(this.$anchor,this.$head).getBookmark()}}Ze.prototype.visible=!0;class cS{constructor(e,n){this.$from=e,this.$to=n}}let v1=!1;function b1(t){!v1&&!t.parent.inlineContent&&(v1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class qe extends Ze{constructor(e,n=e){b1(e),b1(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ze.near(r);let i=e.resolve(n.map(this.anchor));return new qe(i.parent.inlineContent?i:r,r)}replace(e,n=Ie.empty){if(super.replace(e,n),n==Ie.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof qe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Nf(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 qe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=Ze.findFrom(n,r,!0)||Ze.findFrom(n,-r,!0);if(a)n=a.$head;else return Ze.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Ze.findFrom(e,-r,!0)||Ze.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let c=e.child(o);if(c.isAtom){if(!a&&Ke.isSelectable(c))return Ke.create(t,n-(i<0?c.nodeSize:0))}else{let u=ll(t,c,n+i,i<0?c.childCount:0,i,a);if(u)return u}n+=c.nodeSize*i}return null}function N1(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(Ze.near(t.doc.resolve(o),n))}const w1=1,Ru=2,j1=4;class CO extends t0{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|=Ru,this}ensureMarks(e){return Rt.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&Ru)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ru,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Rt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ze.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|=j1,this}get scrolledIntoView(){return(this.updated&j1)>0}}function k1(t,e){return!e||!t?t:t.bind(e)}class Mc{constructor(e,n,r){this.name=e,this.init=k1(n.init,r),this.apply=k1(n.apply,r)}}const EO=[new Mc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Mc("selection",{init(t,e){return t.selection||Ze.atStart(e.doc)},apply(t){return t.selection}}),new Mc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Mc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Hm{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=EO.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Mc(r.key,r.spec.state,r))})}}class gl{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 r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Hm(e.schema,e.plugins),a=new gl(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=xi.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=Ze.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){a[o.name]=h.fromJSON.call(u,e,n[c],a);return}}a[o.name]=o.init(e,a)}}),a}}function dS(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=dS(i,e,{})),n[r]=i}return n}class Bt{constructor(e){this.spec=e,this.props={},e.props&&dS(e.props,this,this.props),this.key=e.key?e.key.key:uS("plugin")}getState(e){return e[this.key]}}const Wm=Object.create(null);function uS(t){return t in Wm?t+"$"+ ++Wm[t]:(Wm[t]=0,t+"$")}class Qt{constructor(e="key"){this.key=uS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const r0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function hS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const fS=(t,e,n)=>{let r=hS(t,n);if(!r)return!1;let i=s0(r);if(!i){let o=r.blockRange(),c=o&&$l(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let a=i.nodeBefore;if(wS(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Sl(a,"end")||Ke.isSelectable(a)))for(let o=r.depth;;o--){let c=bf(t.doc,r.before(o),r.after(o),Ie.empty);if(c&&c.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},TO=(t,e,n)=>{let r=hS(t,n);if(!r)return!1;let i=s0(r);return i?pS(t,i,e):!1},MO=(t,e,n)=>{let r=gS(t,n);if(!r)return!1;let i=i0(r);return i?pS(t,i,e):!1};function pS(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let f=i.lastChild;if(!f)return!1;i=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=bf(t.doc,a,u,Ie.empty);if(!h||h.from!=a||h instanceof Pn&&h.slice.size>=u-a)return!1;if(n){let f=t.tr.step(h);f.setSelection(qe.create(f.doc,a)),n(f.scrollIntoView())}return!0}function Sl(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const mS=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=s0(r)}let o=a&&a.nodeBefore;return!o||!Ke.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ke.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function s0(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 gS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=gS(t,n);if(!r)return!1;let i=i0(r);if(!i)return!1;let a=i.nodeAfter;if(wS(t,i,e,1))return!0;if(r.parent.content.size==0&&(Sl(a,"start")||Ke.isSelectable(a))){let o=bf(t.doc,r.before(),r.after(),Ie.empty);if(o&&o.slice.size{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof Ke,i;if(r){if(n.node.isTextblock||!Sa(t.doc,n.from))return!1;i=n.from}else if(i=vf(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Ke.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},IO=(t,e)=>{let n=t.selection,r;if(n instanceof Ke){if(n.node.isTextblock||!Sa(t.doc,n.to))return!1;r=n.to}else if(r=vf(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},RO=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&$l(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},vS=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` -`).scrollIntoView()),!0)};function a0(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=a0(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(Ze.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},bS=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Dr||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=a0(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(yi(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&$l(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function OO(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ke&&e.selection.node.isBlock)return!r.parentOffset||!yi(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,c,u=!1,h=!1;for(let y=r.depth;;y--)if(r.node(y).isBlock){u=r.end(y)==r.pos+(r.depth-y),h=r.start(y)==r.pos-(r.depth-y),c=a0(r.node(y-1).contentMatchAt(r.indexAfter(y-1))),a.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;a.unshift(null)}let f=e.tr;(e.selection instanceof qe||e.selection instanceof Dr)&&f.deleteSelection();let m=f.mapping.map(r.pos),g=yi(f.doc,m,a.length,a);if(g||(a[0]=c?{type:c}:null,g=yi(f.doc,m,a.length,a)),!g)return!1;if(f.split(m,a.length,a),!u&&h&&r.node(o).type!=c){let y=f.mapping.map(r.before(o)),b=f.doc.resolve(y);c&&r.node(o-1).canReplaceWith(b.index(),b.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const DO=OO(),LO=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Ke.create(t.doc,i))),!0)};function _O(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||Sa(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function wS(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,c,u=i.type.spec.isolating||a.type.spec.isolating;if(!u&&_O(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let y=e.pos+a.nodeSize,b=ge.empty;for(let N=o.length-1;N>=0;N--)b=ge.from(o[N].create(null,b));b=ge.from(i.copy(b));let j=t.tr.step(new On(e.pos-1,y,e.pos,y,new Ie(b,1,0),o.length,!0)),w=j.doc.resolve(y+2*o.length);w.nodeAfter&&w.nodeAfter.type==i.type&&Sa(j.doc,w.pos)&&j.join(w.pos),n(j.scrollIntoView())}return!0}let f=a.type.spec.isolating||r>0&&u?null:Ze.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&$l(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Sl(a,"start",!0)&&Sl(i,"end")){let y=i,b=[];for(;b.push(y),!y.isTextblock;)y=y.lastChild;let j=a,w=1;for(;!j.isTextblock;j=j.firstChild)w++;if(y.canReplace(y.childCount,y.childCount,j.content)){if(n){let N=ge.empty;for(let E=b.length-1;E>=0;E--)N=ge.from(b[E].copy(N));let C=t.tr.step(new On(e.pos-b.length,e.pos+a.nodeSize,e.pos+w,e.pos+a.nodeSize-w,new Ie(N,b.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function jS(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(qe.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const zO=jS(-1),$O=jS(1);function FO(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),c=o&&e0(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function S1(t,e=null){return function(n,r){let i=!1;for(let a=0;a{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)i=!0;else{let f=n.doc.resolve(h),m=f.index();i=f.parent.canReplaceWith(m,m+1,t)}})}if(!i)return!1;if(r){let a=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);a=new gh(u,u,e.depth),e.endIndex=0;f--)a=ge.from(n[f].type.create(n[f].attrs,a));t.step(new On(e.start-(r?2:0),e.end,e.start,e.end,new Ie(a,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?UO(e,n,t,a):KO(e,n,a):!0:!1}}function UO(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);aj;b--)y-=i.child(b).nodeSize,r.delete(y-1,y+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==i.childCount,h=a.node(-1),f=a.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?ge.empty:ge.from(i))))return!1;let m=a.pos,g=m+o.nodeSize;return r.step(new On(m-(c?1:0),g+(u?1:0),m+1,g-1,new Ie((c?ge.empty:ge.from(i.copy(ge.empty))).append(u?ge.empty:ge.from(i.copy(ge.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function qO(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,h=>h.childCount>0&&h.firstChild.type==t);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let c=a.parent,u=c.child(o-1);if(u.type!=t)return!1;if(n){let h=u.lastChild&&u.lastChild.type==c.type,f=ge.from(h?t.create():null),m=new Ie(ge.from(t.create(null,ge.from(c.type.create(null,f)))),h?3:1,0),g=a.start,y=a.end;n(e.tr.step(new On(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Vn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Cl=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Bg=null;const pi=function(t,e,n){let r=Bg||(Bg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},GO=function(){Bg=null},xo=function(t,e,n,r){return n&&(C1(t,e,n,r,-1)||C1(t,e,n,r,1))},JO=/^(img|br|input|textarea|hr)$/i;function C1(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Jr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||pd(t)||JO.test(t.nodeName)||t.contentEditable=="false")return!1;e=Vn(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Jr(t):0}else return!1}}function Jr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function YO(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=Jr(t)}else if(t.parentNode&&!pd(t))e=Vn(t),t=t.parentNode;else return null}}function QO(t,e){for(;;){if(t.nodeType==3&&e2),Gr=El||(zs?/Mac/.test(zs.platform):!1),CS=zs?/Win/.test(zs.platform):!1,gi=/Android \d/.test(Ca),md=!!E1&&"webkitFontSmoothing"in E1.documentElement.style,tD=md?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function nD(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 ci(t,e){return typeof t=="number"?t:t[e]}function rD(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function T1(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Cl(o);continue}let c=o,u=c==a.body,h=u?nD(a):rD(c),f=0,m=0;if(e.toph.bottom-ci(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ci(i,"top")-h.top:e.bottom-h.bottom+ci(i,"bottom")),e.lefth.right-ci(r,"right")&&(f=e.right-h.right+ci(i,"right")),f||m)if(u)a.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,b=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let j=c.scrollLeft-y,w=c.scrollTop-b;e={left:e.left-j,top:e.top-w,right:e.right-j,bottom:e.bottom-w}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:Cl(o)}}function sD(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o=n-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:ES(t.dom)}}function ES(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Cl(r));return e}function iD({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;TS(n,r==0?0:r-e)}function TS(t,e){for(let n=0;n=c){o=Math.max(b.bottom,o),c=Math.min(b.top,c);let j=b.left>e.left?b.left-e.left:b.right=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!u&&b.left<=e.left&&b.right>=e.left&&(u=f,h={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=m+1)}}return!n&&u&&(n=u,i=h,r=0),n&&n.nodeType==3?oD(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:MS(n,i)}function oD(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function l0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function lD(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(r,i,a)}function dD(t,e,n,r){let i=-1;for(let a=e,o=!1;a!=t.dom;){let c=t.docView.nearestDesc(a,!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>r.left||u.top>r.top?i=c.posBefore:(!o&&u.right-1?i:t.docView.posFromDOM(e,n,-1)}function AS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let h;md&&i&&r.nodeType==1&&(h=r.childNodes[i-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=dD(t,r,i,e))}c==null&&(c=cD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function M1(t){return t.top=0&&i==r.nodeValue.length?(u--,f=1):n<0?u--:h++,jc(Qi(pi(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Jr(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return Um(u.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==Jr(r))){let u=r.childNodes[i-1],h=u.nodeType==3?pi(u,Jr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return jc(Qi(h,1),!1)}if(a==null&&i=0)}function jc(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 Um(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 RS(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function fD(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return RS(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(a,!0);if(!c)break;if(c.node.isBlock){a=c.contentDOM||c.dom;break}a=c.dom.parentNode}let o=IS(t,i.pos,1);for(let c=a.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=pi(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 pD=/[\u0590-\u08ac]/;function mD(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,c=t.domSelection();return c?!pD.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?a:o:RS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:j}=t.domSelectionRange(),w=b&&!y.contains(b.nodeType==1?b:b.parentNode)||u==b&&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),w}):r.pos==r.start()||r.pos==r.end()}let A1=null,I1=null,R1=!1;function gD(t,e,n){return A1==e&&I1==n?R1:(A1=e,I1=n,R1=n=="up"||n=="down"?fD(t,e,n):mD(t,e,n))}const Qr=0,P1=1,eo=2,$s=3;class gd{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Qr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nVn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof OS){i=e-a;break}a=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof PS&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?Vn(a.dom)+1:0}}else{let a,o=!0;for(;a=r=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)){i=Vn(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fb&&on){let b=c;c=u,u=b}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 r=0,i=0;i=r:er){let c=r+a.border,u=o-a.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?eo:P1,e==c&&n==u&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=$s:a.markDirty(e-c,n-c);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?eo:$s}r=o}this.dirty=eo}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?eo:P1;n.dirty{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!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,a=this}matchesWidget(e){return this.dirty==Qr&&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 xD extends gd{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}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 yo extends gd{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=So.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new yo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&$s||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=$s&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Qr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(a=Kg(a,0,e,r));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,i),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}=So.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=_S(f,r,n),h?u=new yD(e,n,r,i,f,m||null,g,h,a,o+1):n.isText?new jf(e,n,r,i,f,g,a):new pa(e,n,r,i,f,m||null,g,a,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 r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>ge.empty)}return e}matchesNode(e,n,r){return this.dirty==Qr&&e.eq(this.node)&&yh(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,c=a&&a.pos<0,u=new bD(this,o&&o.node,e);jD(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,r,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?Rt.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,i)},(h,f,m,g)=>{u.syncToMarks(h.marks,r,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>i&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,i)||u.addNode(h,f,m,e,i),i+=h.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==eo)&&(o&&this.protectLocalComposition(e,o),DS(this.contentDOM,this.children,e),El&&kD(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof qe)||rn+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let o=a.nodeValue,c=SD(this.node.content,o,r-n,i-n);return c<0?null:{node:a,pos:c,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let o=new xD(this,a,n,i);e.input.compositionNodes.push(o),this.children=Kg(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==$s||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Qr}updateOuterDeco(e){if(yh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=LS(this.dom,this.nodeDOM,Ug(this.outerDeco,this.node,n),Ug(e,this.node,n)),this.dom!=r&&(r.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 O1(t,e,n,r,i){_S(r,e,t);let a=new pa(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class jf extends pa{constructor(e,n,r,i,a,o,c){super(e,n,r,i,a,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,r,i){return this.dirty==$s||this.dirty!=Qr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Qr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Qr,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new jf(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=$s)}get domAtom(){return!1}isText(e){return this.node.text==e}}class OS extends gd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Qr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class yD extends pa{constructor(e,n,r,i,a,o,c,u,h,f){super(e,n,r,i,a,o,c,h,f),this.spec=u}update(e,n,r,i){if(this.dirty==$s)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}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 DS(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a>1,c=Math.min(o,e.length);for(;a-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=yo.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=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(r){let h=n.children[r-1];if(h instanceof yo)n=h,r=h.children.length;else{c=h,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(i-1))break;--i,a.set(c,i),o.push(c)}}return{index:i,matched:a,matches:o.reverse()}}function wD(t,e){return t.type.side-e.type.side}function jD(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let h=0;ha;)c.push(i[o++]);let b=a+g.nodeSize;if(g.isText){let w=b;o!w.inline):c.slice();r(g,j,e.forChild(a,g),y),a=b}}function kD(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 SD(t,e,n,r){for(let i=0,a=0;i=n){if(a>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let h=c=0&&h+e.length+c>=n)return c+h;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function Kg(t,e,n,r,i){let a=[];for(let o=0,c=0;o=n||f<=e?a.push(u):(hn&&a.push(u.slice(n-h,u.size,r)))}return a}function c0(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=r.resolve(o),u,h;if(wf(n)){for(u=o;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&Ke.isSelectable(m)&&i.parent&&!(m.isInline&&XO(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;h=new Ke(o==g?c:r.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!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ED(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Vn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&kr&&fa<=11&&(n.disabled=!0,n.disabled=!1)}function $S(t,e){if(e instanceof Ke){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($1(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $1(t)}function $1(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function d0(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||qe.between(e,n,r)}function F1(t){return t.editable&&!t.hasFocus()?!1:FS(t)}function FS(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 TD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return xo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function qg(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&Ze.findFrom(a,e)}function Xi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function B1(t,e,n){let r=t.state.selection;if(r instanceof qe)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Xi(t,new qe(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=qg(t.state,e);return i&&i instanceof Ke?Xi(t,i):!1}else if(!(Gr&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let c=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?Ke.isSelectable(a)?Xi(t,new Ke(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):md?Xi(t,new qe(t.state.doc.resolve(e<0?c:c+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ke&&r.node.isInline)return Xi(t,new qe(e>0?r.$to:r.$from));{let i=qg(t.state,e);return i?Xi(t,i):!1}}}function vh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function zc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ol(t,e){return e<0?MD(t):AD(t)}function MD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(Yr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(zc(c,-1))i=n,a=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(BS(n))break;{let c=n.previousSibling;for(;c&&zc(c,-1);)i=n.parentNode,a=Vn(c),c=c.previousSibling;if(c)n=c,r=vh(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Gg(t,n,r):i&&Gg(t,i,a)}function AD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=vh(n),a,o;for(;;)if(r{t.state==i&&vi(t)},50)}function V1(t,e){let n=t.state.doc.resolve(e);if(!(Wn||CS)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o1)return a.lefti.top&&o1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function H1(t,e,n){let r=t.state.selection;if(r instanceof qe&&!r.empty||n.indexOf("s")>-1||Gr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=qg(t.state,e);if(o&&o instanceof Ke)return Xi(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,c=r instanceof Dr?Ze.near(o,e):Ze.findFrom(o,e);return c?Xi(t,c):!1}return!1}function W1(t,e){if(!(t.state.selection instanceof qe))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function U1(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function PD(t){if(!nr||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 r=e.firstChild;U1(t,r,"true"),setTimeout(()=>U1(t,r,"false"),20)}return!1}function OD(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function DD(t,e){let n=e.keyCode,r=OD(e);if(n==8||Gr&&n==72&&r=="c")return W1(t,-1)||ol(t,-1);if(n==46&&!e.shiftKey||Gr&&n==68&&r=="c")return W1(t,1)||ol(t,1);if(n==13||n==27)return!0;if(n==37||Gr&&n==66&&r=="c"){let i=n==37?V1(t,t.state.selection.from)=="ltr"?-1:1:-1;return B1(t,i,r)||ol(t,i)}else if(n==39||Gr&&n==70&&r=="c"){let i=n==39?V1(t,t.state.selection.from)=="ltr"?1:-1:1;return B1(t,i,r)||ol(t,i)}else{if(n==38||Gr&&n==80&&r=="c")return H1(t,-1,r)||ol(t,-1);if(n==40||Gr&&n==78&&r=="c")return PD(t)||H1(t,1,r)||ol(t,1);if(r==(Gr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function u0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let o=t.someProp("clipboardSerializer")||So.fromSchema(t.state.schema),c=qS(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=KS[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let b=c.createElement(f[y]);for(;u.firstChild;)b.appendChild(u.firstChild);u.appendChild(b),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${i} ${a}${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 VS(t,e,n,r,i){let a=i.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(r||a||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return c=new Ie(ge.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,i,r,t));if(m)c=m;else{let g=i.marks(),{schema:y}=t.state,b=So.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=o.appendChild(document.createElement("p"));j&&w.appendChild(b.serializeNode(y.text(j,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=$D(n),md&&FD(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")||ha.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!LD.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=BD(K1(c,+f[1],+f[2]),f[4]);else if(c=Ie.maxOpen(_D(c.content,i),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,u)}),c}const LD=/^(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 _D(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(c=>{if(!o)return;let u=i.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&a.length&&WS(u,a,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=US(o[o.length-1],a.length));let f=HS(c,u);o.push(f),i=i.matchType(f.type),a=u}}),o)return ge.from(o)}return t}function HS(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ge.from(t));return t}function WS(t,e,n,r,i){if(i1&&(a=0),i=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,a<=i).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(ge.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function K1(t,e,n){return en})),qm.createHTML(t)):t}function $D(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=qS().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&KS[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"").reverse().join("")),n.innerHTML=zD(t),i)for(let a=0;a=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=ge.from(u.create(r[c+1],i)),a++,o++}return new Ie(i,a,o)}const fr={},pr={},VD={touchstart:!0,touchmove:!0};class HD{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 WD(t){for(let e in fr){let n=fr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{KD(t,r)&&!h0(t,r)&&(t.editable||!(r.type in pr))&&n(t,r)},VD[e]?{passive:!0}:void 0)}nr&&t.dom.addEventListener("input",()=>null),Yg(t)}function la(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function UD(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 Yg(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>h0(t,r))})}function h0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function KD(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 qD(t,e){!h0(t,e)&&fr[e.type]&&(t.editable||!(e.type in pr))&&fr[e.type](t,e)}pr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!JS(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(gi&&Wn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),El&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Qa(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||DD(t,n)?n.preventDefault():la(t,"key")};pr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};pr.keypress=(t,e)=>{let n=e;if(JS(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Gr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof qe)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function kf(t){return{left:t.clientX,top:t.clientY}}function GD(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function f0(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,c=>o>a.depth?c(t,n,a.nodeAfter,a.before(o),i,!0):c(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Nl(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function JD(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ke.isSelectable(r)?(Nl(t,new Ke(n)),!0):!1}function YD(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ke&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let c=o>a.depth?a.nodeAfter:a.node(o);if(Ke.isSelectable(c)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Nl(t,Ke.create(t.state.doc,i)),!0):!1}function QD(t,e,n,r,i){return f0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?YD(t,n):JD(t,n))}function XD(t,e,n,r){return f0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function ZD(t,e,n,r){return f0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||eL(t,n,r)}function eL(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Nl(t,qe.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),c=i.before(a);if(o.inlineContent)Nl(t,qe.create(r,c+1,c+1+o.content.size));else if(Ke.isSelectable(o))Nl(t,Ke.create(r,c));else continue;return!0}}function p0(t){return bh(t)}const GS=Gr?"metaKey":"ctrlKey";fr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=p0(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&GD(n,t.input.lastClick)&&!n[GS]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(kf(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new tL(t,o,n,!!r)):(a=="doubleClick"?XD:ZD)(t,o.pos,o.inside,n)?n.preventDefault():la(t,"pointer"))};class tL{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[GS],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);a=f.parent,o=f.depth?f.before():0}const c=i?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||h instanceof Ke&&h.from<=o&&h.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Yr&&!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)),la(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(()=>vi(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(kf(e))),this.updateAllowDefault(e),this.allowDefault||!n?la(this.view,"pointer"):QD(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||nr&&this.mightDrag&&!this.mightDrag.node.isAtom||Wn&&!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)?(Nl(this.view,Ze.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):la(this.view,"pointer")}move(e){this.updateAllowDefault(e),la(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)}}fr.touchstart=t=>{t.input.lastTouch=Date.now(),p0(t),la(t,"pointer")};fr.touchmove=t=>{t.input.lastTouch=Date.now(),la(t,"pointer")};fr.contextmenu=t=>p0(t);function JS(t,e){return t.composing?!0:nr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const nL=gi?5e3:-1;pr.compositionstart=pr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof qe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Wn&&CS&&rL(t)))t.markCursor=t.state.storedMarks||n.marks(),bh(t,!0),t.markCursor=null;else if(bh(t,!e.selection.empty),Yr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}YS(t,nL)};function rL(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}pr.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++,YS(t,20))};function YS(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>bh(t),e))}function QS(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=iL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function sL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=YO(e.focusNode,e.focusOffset),r=QO(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function iL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function bh(t,e=!1){if(!(gi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),QS(t),e||t.docView&&t.docView.dirty){let n=c0(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function aL(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 r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const ed=kr&&fa<15||El&&tD<604;fr.copy=pr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ed?null:n.clipboardData,o=r.content(),{dom:c,text:u}=u0(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",c.innerHTML),a.setData("text/plain",u)):aL(t,c),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function oL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function lL(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?td(t,r.value,null,i,e):td(t,r.textContent,r.innerHTML,i,e)},50)}function td(t,e,n,r,i){let a=VS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,i,a||Ie.empty)))return!0;if(!a)return!1;let o=oL(a),c=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function XS(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," "):""}pr.paste=(t,e)=>{let n=e;if(t.composing&&!gi)return;let r=ed?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&td(t,XS(r),r.getData("text/html"),i,n)?n.preventDefault():lL(t,n)};class ZS{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const cL=Gr?"altKey":"ctrlKey";function e2(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[cL]}fr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(kf(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Ke?i.to-1:i.to))){if(r&&r.mightDrag)o=Ke.create(t.state.doc,r.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=Ke.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=u0(t,c);(!n.dataTransfer.files.length||!Wn||SS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ed?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",ed||n.dataTransfer.setData("text/plain",h),t.dragging=new ZS(f,e2(t,n),o)};fr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};pr.dragover=pr.dragenter=(t,e)=>e.preventDefault();pr.drop=(t,e)=>{try{dL(t,e,t.dragging)}finally{t.dragging=null}};function dL(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(kf(e));if(!r)return;let i=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",y=>{a=y(a,t,!1)}):a=VS(t,XS(e.dataTransfer),ed?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&e2(t,e));if(t.someProp("handleDrop",y=>y(t,e,a||Ie.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let c=a?sS(t.state.doc,i.pos,a):i.pos;c==null&&(c=i.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=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,a.content.firstChild):u.replaceRange(h,h,a),u.doc.eq(m))return;let g=u.doc.resolve(h);if(f&&Ke.isSelectable(a.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(a.content.firstChild))u.setSelection(new Ke(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((b,j,w,N)=>y=N),u.setSelection(d0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}fr.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())&&vi(t)},20))};fr.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)};fr.beforeinput=(t,e)=>{if(Wn&&gi&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Qa(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in pr)fr[t]=pr[t];function nd(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 Nh{constructor(e,n){this.toDOM=e,this.spec=n||oo,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new En(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Nh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&nd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ma{constructor(e,n){this.attrs=e,this.spec=n||oo}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new En(a,o,this)}valid(e,n){return n.from=e&&(!a||a(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let o=0;oe){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,r,i+c,a)}}map(e,n,r){return this==Qn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||oo)}mapInner(e,n,r,i,a){let o;for(let c=0;c{let h=u+r,f;if(f=n2(n,c,h)){for(i||(i=this.children.slice());ac&&m.to=e){this.children[c]==e&&(r=this.children[c+2]);break}let a=e+1,o=a+n.content.size;for(let c=0;ca&&u.type instanceof ma){let h=Math.max(a,u.from)-a,f=Math.min(o,u.to)-a;hi.map(e,n,oo));return ta.from(r)}forChild(e,n){if(n.isLeaf)return It.empty;let r=[];for(let i=0;in instanceof It)?e:e.reduce((n,r)=>n.concat(r instanceof It?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let w=j-b-(y-g);for(let N=0;NC+f-m)continue;let E=c[N]+f-m;y>=E?c[N+1]=g<=E?-2:-1:g>=f&&w&&(c[N]+=w,c[N+1]+=w)}m+=w}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let g=n.map(t[h+1]+a,-1),y=g-i,{index:b,offset:j}=r.content.findIndex(m),w=r.maybeChild(b);if(w&&j==m&&j+w.nodeSize==y){let N=c[h+2].mapInner(n,w,f+1,t[h]+a+1,o);N!=Qn?(c[h]=m,c[h+1]=y,c[h+2]=N):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=hL(c,t,e,n,i,a,o),f=wh(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=n2(t,c,u+n);if(h){a=!0;let f=wh(h,c,n+u+1,r);f!=Qn&&i.push(u,u+c.nodeSize,f)}});let o=t2(a?r2(t):t,-n).sort(lo);for(let c=0;c0;)e++;t.splice(e,0,n)}function Gm(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Qn&&e.push(r)}),t.cursorWrapper&&e.push(It.create(t.state.doc,[t.cursorWrapper.deco])),ta.from(e)}const fL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},pL=kr&&fa<=11;class mL{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 gL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():nr&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),pL&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,fL)),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(F1(this.view)){if(this.suppressingSelectionUpdates)return vi(this.view);if(kr&&fa<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xo(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,r;for(let a=e.focusNode;a;a=Cl(a))n.add(a);for(let a=e.anchorNode;a;a=Cl(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&F1(e)&&!this.ignoreSelectionChange(r),a=-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(Yr&&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||vL(e,m)!=y)&&g.remove()}}}let h=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(a>-1&&(e.docView.markDirty(a,o),xL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,bL(e,u)),this.handleDOMChange(a,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||vi(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fi;w--){let N=r.childNodes[w-1],C=N.pmViewDesc;if(N.nodeName=="BR"&&!C){a=w;break}if(!C||C.size)break}let m=t.state.doc,g=t.someProp("domParser")||ha.fromSchema(t.state.schema),y=m.resolve(o),b=null,j=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:i,to:a,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:wL,context:y});if(h&&h[0].pos!=null){let w=h[0].pos,N=h[1]&&h[1].pos;N==null&&(N=w),b={anchor:w+o,head:N+o}}return{doc:j,sel:b,from:o,to:c}}function wL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(nr&&/^(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||nr&&/^(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 jL=/^(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 kL(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let D=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=c0(t,D);if(P&&!t.state.selection.eq(P)){if(Wn&&gi&&t.input.lastKeyCode===13&&Date.now()-100_(t,Qa(13,"Enter"))))return;let L=t.state.tr.setSelection(P);D=="pointer"?L.setMeta("pointer",!0):D=="key"&&L.scrollIntoView(),a&&L.setMeta("composition",a),t.dispatch(L)}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=NL(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||gi)&&i.some(D=>D.nodeType==1&&!jL.test(D.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",D=>D(t,Qa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&u instanceof qe&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))b={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let D=X1(t,t.state.doc,h.sel);if(D&&!D.eq(t.state.selection)){let P=t.state.tr.setSelection(D);a&&P.setMeta("composition",a),t.dispatch(P)}}return}t.state.selection.fromt.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?b.start=t.state.selection.from:b.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),kr&&fa<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>h.from&&h.doc.textBetween(b.start-h.from-1,b.start-h.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let j=h.doc.resolveNoCache(b.start-h.from),w=h.doc.resolveNoCache(b.endB-h.from),N=f.resolve(b.start),C=j.sameParent(w)&&j.parent.inlineContent&&N.end()>=b.endA;if((El&&t.input.lastIOSEnter>Date.now()-225&&(!C||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!C&&j.posD(t,Qa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&CL(f,b.start,b.endA,j,w)&&t.someProp("handleKeyDown",D=>D(t,Qa(8,"Backspace")))){gi&&Wn&&t.domObserver.suppressSelectionUpdates();return}Wn&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),gi&&!C&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==b.endA&&(b.endB-=2,w=h.doc.resolveNoCache(b.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(D){return D(t,Qa(13,"Enter"))})},20));let E=b.start,M=b.endA,I=D=>{let P=D||t.state.tr.replace(E,M,h.doc.slice(b.start-h.from,b.endB-h.from));if(h.sel){let L=X1(t,P.doc,h.sel);L&&!(Wn&&t.composing&&L.empty&&(b.start!=b.endB||t.input.lastChromeDeletevi(t),20));let D=I(t.state.tr.delete(E,M)),P=f.resolve(b.start).marksAcross(f.resolve(b.endA));P&&D.ensureMarks(P),t.dispatch(D)}else if(b.endA==b.endB&&(O=SL(j.parent.content.cut(j.parentOffset,w.parentOffset),N.parent.content.cut(N.parentOffset,b.endA-N.start())))){let D=I(t.state.tr);O.type=="add"?D.addMark(E,M,O.mark):D.removeMark(E,M,O.mark),t.dispatch(D)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let D=j.parent.textBetween(j.parentOffset,w.parentOffset),P=()=>I(t.state.tr.insertText(D,E,M));t.someProp("handleTextInput",L=>L(t,E,M,D,P))||t.dispatch(P())}else t.dispatch(I());else t.dispatch(I())}function X1(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:d0(t,e.resolve(n.anchor),e.resolve(n.head))}function SL(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,c,u;for(let f=0;ff.mark(c.addToSet(f.marks));else if(i.length==0&&a.length==1)c=a[0],o="remove",u=f=>f.mark(c.removeFromSet(f.marks));else return null;let h=[];for(let f=0;fn||Jm(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function EL(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:o,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let u=Math.max(0,a-Math.min(o,c));r-=o+u-a}if(o=o?a-r:0;a-=u,a&&a=c?a-r:0;a-=u,a&&a=56320&&e<=57343&&n>=55296&&n<=56319}class s2{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 HD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(sN),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=nN(this),tN(this),this.nodeViews=rN(this),this.docView=O1(this.state.doc,eN(this),Gm(this),this.dom,this),this.domObserver=new gL(this,(r,i,a,o)=>kL(this,r,i,a,o)),this.domObserver.start(),WD(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&&Yg(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sN),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(QS(this),o=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=rN(this);ML(y,this.nodeViews)&&(this.nodeViews=y,a=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Yg(this),this.editable=nN(this),tN(this);let u=Gm(this),h=eN(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",m=a||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(i.selection))&&(o=!0);let g=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&sD(this);if(o){this.domObserver.stop();let y=m&&(kr||Wn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&TL(i.selection,e.selection);if(m){let b=Wn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=sL(this)),(a||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=O1(e.doc,h,u,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&TD(this))?vi(this,y):($S(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&iD(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 Ke){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&T1(this,n.getBoundingClientRect(),e)}else T1(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(a))==r.node&&(i=a)}this.dragging=new ZS(e.slice,e.move,i<0?void 0:Ke.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return uD(this,e)}coordsAtPos(e,n=1){return IS(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,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return gD(this,n||this.state,e)}pasteHTML(e,n){return td(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return td(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return u0(this,e)}destroy(){this.docView&&(UD(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Gm(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,GO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return qD(this,e)}domSelectionRange(){let e=this.domSelection();return e?nr&&this.root.nodeType===11&&ZO(this.dom.ownerDocument)==this.dom&&yL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}s2.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function eN(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 r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[En.node(0,t.state.doc.content.size,e)]}function tN(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:En.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function nN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function TL(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 rN(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function ML(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function sN(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 xa={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:"'"},jh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},AL=typeof navigator<"u"&&/Mac/.test(navigator.platform),IL=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Hn=0;Hn<10;Hn++)xa[48+Hn]=xa[96+Hn]=String(Hn);for(var Hn=1;Hn<=24;Hn++)xa[Hn+111]="F"+Hn;for(var Hn=65;Hn<=90;Hn++)xa[Hn]=String.fromCharCode(Hn+32),jh[Hn]=String.fromCharCode(Hn);for(var Ym in xa)jh.hasOwnProperty(Ym)||(jh[Ym]=xa[Ym]);function RL(t){var e=AL&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||IL&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?jh:xa)[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 PL=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),OL=typeof navigator<"u"&&/Win/.test(navigator.platform);function DL(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,o;for(let c=0;c{for(var n in e)zL(t,n,{get:e[n],enumerable:!0})};function Sf(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=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 a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Cf=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:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],c=!!t,u=t||i.tr,h=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(u),o.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...b)=>{const j=this.buildProps(u,e),w=g(...b)(j);return o.push(w),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:Sf({state:i,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}},i2={};y0(i2,{blur:()=>$L,clearContent:()=>FL,clearNodes:()=>BL,command:()=>VL,createParagraphNear:()=>HL,cut:()=>WL,deleteCurrentNode:()=>UL,deleteNode:()=>KL,deleteRange:()=>qL,deleteSelection:()=>GL,enter:()=>JL,exitCode:()=>YL,extendMarkRange:()=>QL,first:()=>XL,focus:()=>e8,forEach:()=>t8,insertContent:()=>n8,insertContentAt:()=>i8,joinBackward:()=>l8,joinDown:()=>o8,joinForward:()=>c8,joinItemBackward:()=>d8,joinItemForward:()=>u8,joinTextblockBackward:()=>h8,joinTextblockForward:()=>f8,joinUp:()=>a8,keyboardShortcut:()=>m8,lift:()=>g8,liftEmptyBlock:()=>x8,liftListItem:()=>y8,newlineInCode:()=>v8,resetAttributes:()=>b8,scrollIntoView:()=>N8,selectAll:()=>w8,selectNodeBackward:()=>j8,selectNodeForward:()=>k8,selectParentNode:()=>S8,selectTextblockEnd:()=>C8,selectTextblockStart:()=>E8,setContent:()=>T8,setMark:()=>G8,setMeta:()=>J8,setNode:()=>Y8,setNodeSelection:()=>Q8,setTextDirection:()=>X8,setTextSelection:()=>Z8,sinkListItem:()=>e6,splitBlock:()=>t6,splitListItem:()=>n6,toggleList:()=>r6,toggleMark:()=>s6,toggleNode:()=>i6,toggleWrap:()=>a6,undoInputRule:()=>o6,unsetAllMarks:()=>l6,unsetMark:()=>c6,unsetTextDirection:()=>d6,updateAttributes:()=>u6,wrapIn:()=>h6,wrapInList:()=>f6});var $L=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),FL=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),BL=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.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 b=$l(y);if(c.type.isTextblock){const{defaultType:j}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,j)}(b||b===0)&&e.lift(y,b)})}),!0},VL=t=>e=>t(e),HL=()=>({state:t,dispatch:e})=>bS(t,e),WL=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new qe(r.doc.resolve(Math.max(o-1,0)))),!0},UL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const c=i.before(a),u=i.after(a);t.delete(c,u).scrollIntoView()}return!0}return!1};function bn(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 KL=t=>({tr:e,state:n,dispatch:r})=>{const i=bn(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const u=a.before(o),h=a.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},qL=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},GL=()=>({state:t,dispatch:e})=>r0(t,e),JL=()=>({commands:t})=>t.keyboardShortcut("Enter"),YL=()=>({state:t,dispatch:e})=>PO(t,e);function v0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function kh(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:v0(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function a2(t,e,n={}){return t.find(r=>r.type===e&&kh(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function iN(t,e,n={}){return!!a2(t,e,n)}function b0(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!a2([...i.node.marks],e,n)))return;let o=i.index,c=t.start()+i.offset,u=o+1,h=c+i.node.nodeSize;for(;o>0&&iN([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u({tr:n,state:r,dispatch:i})=>{const a=ji(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(i){const m=b0(u,a,e);if(m&&m.from<=h&&m.to>=f){const g=qe.create(o,m.from,m.to);n.setSelection(g)}}return!0},XL=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(Sh()||aN())&&r.dom.focus(),ZL()&&!Sh()&&!aN()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(a&&t===null&&!o2(n.state.selection))return o(),!0;const c=l2(i.doc,t)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},t8=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),n8=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),c2=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&c2(r)}return t};function Pu(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 c2(n)}function rd(t,e,n){if(t instanceof xi||t instanceof ge)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return ge.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),rd("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,c="";const u=new qk({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?ha.fromSchema(u).parseSlice(Pu(t),n.parseOptions):ha.fromSchema(u).parse(Pu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const a=ha.fromSchema(e);return n.slice?a.parseSlice(Pu(t),n.parseOptions).content:a.parse(Pu(t),n.parseOptions)}return rd("",e,n)}function r8(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(Ze.near(t.doc.resolve(o),n))}var s8=t=>!("type"in t),i8=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=w=>{a.emit("contentError",{editor:a,error:w,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{rd(e,a.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(w){u(w)}try{c=rd(e,a.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(w){return u(w),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((s8(c)?c:[c]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,y=y?w.isBlock:!1}),f===m&&y){const{parent:w}=r.doc.resolve(f);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(f-=1,m+=1)}let j;if(g){if(Array.isArray(e))j=e.map(w=>w.text||"").join("");else if(e instanceof ge){let w="";e.forEach(N=>{N.text&&(w+=N.text)}),j=w}else typeof e=="object"&&e&&e.text?j=e.text:j=e;r.insertText(j,f,m)}else{j=c;const w=r.doc.resolve(f),N=w.node(),C=w.parentOffset===0,E=N.isText||N.isTextblock,M=N.content.size>0;C&&E&&M&&(f=Math.max(0,f-1)),r.replaceWith(f,m,j)}n.updateSelection&&r8(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:f,text:j}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:f,text:j})}return!0},a8=()=>({state:t,dispatch:e})=>AO(t,e),o8=()=>({state:t,dispatch:e})=>IO(t,e),l8=()=>({state:t,dispatch:e})=>fS(t,e),c8=()=>({state:t,dispatch:e})=>xS(t,e),d8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vf(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},u8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vf(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},h8=()=>({state:t,dispatch:e})=>TO(t,e),f8=()=>({state:t,dispatch:e})=>MO(t,e);function d2(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function p8(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let c=0;c({editor:e,view:n,tr:r,dispatch:i})=>{const a=p8(t).split(/-(?!$)/),o=a.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),c=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.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(r.mapping);f&&i&&r.maybeStep(f)}),!0};function ya(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?bn(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),b=Math.min(i,g+m.nodeSize);c.push({node:m,from:y,to:b})});const u=i-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>kh(m.node.attrs,n,{strict:!1}));return a?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var g8=(t,e={})=>({state:n,dispatch:r})=>{const i=bn(t,n.schema);return ya(n,i,e)?RO(n,r):!1},x8=()=>({state:t,dispatch:e})=>NS(t,e),y8=t=>({state:e,dispatch:n})=>{const r=bn(t,e.schema);return WO(r)(e,n)},v8=()=>({state:t,dispatch:e})=>vS(t,e);function Ef(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function oN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var b8=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const c=Ef(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=bn(t,r.schema)),c==="mark"&&(o=ji(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{r.doc.nodesBetween(h.$from.pos,h.$to.pos,(f,m)=>{a&&a===f.type&&(u=!0,i&&n.setNodeMarkup(m,void 0,oN(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&(u=!0,i&&n.addMark(m,m+f.nodeSize,o.create(oN(g.attrs,e))))})})}),u},N8=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),w8=()=>({tr:t,dispatch:e})=>{if(e){const n=new Dr(t.doc);t.setSelection(n)}return!0},j8=()=>({state:t,dispatch:e})=>mS(t,e),k8=()=>({state:t,dispatch:e})=>yS(t,e),S8=()=>({state:t,dispatch:e})=>LO(t,e),C8=()=>({state:t,dispatch:e})=>$O(t,e),E8=()=>({state:t,dispatch:e})=>zO(t,e);function Qg(t,e,n={},r={}){return rd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var T8=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:c})=>{const{doc:u}=a;if(r.preserveWhitespace!=="full"){const h=Qg(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function u2(t,e){const n=ji(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function h2(t,e){const n=new t0(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function M8(t){for(let e=0;e{n(i)&&r.push({node:i,pos:a})}),r}function f2(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Tf(t){return e=>f2(e.$from,t)}function We(t,e,n){return t.config[e]===void 0&&t.parent?We(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?We(t.parent,e,n):null}):t.config[e]}function N0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=We(e,"addExtensions",n);return r?[e,...N0(r())]:e}).flat(10)}function w0(t,e){const n=So.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function p2(t){return typeof t=="function"}function jt(t,e=void 0,...n){return p2(t)?e?t.bind(e)(...n):t(...n):t}function I8(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Tl(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function m2(t){const e=[],{nodeExtensions:n,markExtensions:r}=Tl(t),i=[...n,...r],a={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=r.map(h=>h.name),u=[...o,...c];return t.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage,extensions:i},m=We(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let b;Array.isArray(y.types)?b=y.types:y.types==="*"?b=u:y.types==="nodes"?b=o:y.types==="marks"?b=c:b=[],b.forEach(j=>{Object.entries(y.attributes).forEach(([w,N])=>{e.push({type:j,name:w,attribute:{...a,...N}})})})})}),i.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=We(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,b])=>{const j={...a,...b};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 R8(t){const e=[];let n="",r=!1,i=!1,a=0;const o=t.length;for(let c=0;c0){a-=1,n+=u;continue}if(u===";"&&a===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function lN(t){const e=[],n=R8(t||""),r=n.length;for(let i=0;i!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const c=a?String(a).split(" "):[],u=r[i]?r[i].split(" "):[],h=c.filter(f=>!u.includes(f));r[i]=[...u,...h].join(" ")}else if(i==="style"){const c=new Map([...lN(r[i]),...lN(a)]);r[i]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[i]=a}),r},{})}function sd(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,r)=>kt(n,r),{})}function P8(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function cN(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):P8(n.getAttribute(o.name));return c==null?a:{...a,[o.name]:c}},{});return{...r,...i}}}}function dN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&I8(n)?!1:n!=null))}function uN(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function O8(t,e){var n;const r=m2(t),{nodeExtensions:i,markExtensions:a}=Tl(t),o=(n=i.find(h=>We(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(i.map(h=>{const f=r.filter(N=>N.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((N,C)=>{const E=We(C,"extendNodeSchema",m);return{...N,...E?E(h):{}}},{}),y=dN({...g,content:jt(We(h,"content",m)),marks:jt(We(h,"marks",m)),group:jt(We(h,"group",m)),inline:jt(We(h,"inline",m)),atom:jt(We(h,"atom",m)),selectable:jt(We(h,"selectable",m)),draggable:jt(We(h,"draggable",m)),code:jt(We(h,"code",m)),whitespace:jt(We(h,"whitespace",m)),linebreakReplacement:jt(We(h,"linebreakReplacement",m)),defining:jt(We(h,"defining",m)),isolating:jt(We(h,"isolating",m)),attrs:Object.fromEntries(f.map(uN))}),b=jt(We(h,"parseHTML",m));b&&(y.parseDOM=b.map(N=>cN(N,f)));const j=We(h,"renderHTML",m);j&&(y.toDOM=N=>j({node:N,HTMLAttributes:sd(N,f)}));const w=We(h,"renderText",m);return w&&(y.toText=w),[h.name,y]})),u=Object.fromEntries(a.map(h=>{const f=r.filter(w=>w.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((w,N)=>{const C=We(N,"extendMarkSchema",m);return{...w,...C?C(h):{}}},{}),y=dN({...g,inclusive:jt(We(h,"inclusive",m)),excludes:jt(We(h,"excludes",m)),group:jt(We(h,"group",m)),spanning:jt(We(h,"spanning",m)),code:jt(We(h,"code",m)),attrs:Object.fromEntries(f.map(uN))}),b=jt(We(h,"parseHTML",m));b&&(y.parseDOM=b.map(w=>cN(w,f)));const j=We(h,"renderHTML",m);return j&&(y.toDOM=w=>j({mark:w,HTMLAttributes:sd(w,f)})),[h.name,y]}));return new qk({topNode:o,nodes:c,marks:u})}function D8(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function $c(t){return t.sort((n,r)=>{const i=We(n,"priority")||100,a=We(r,"priority")||100;return i>a?-1:ir.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function x2(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=` - -`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,i,(u,h,f,m)=>{var g;u.isBlock&&h>r&&(c+=a);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(r,h)-h,i-h))}),c}function L8(t,e){const n={from:0,to:t.content.size};return x2(t,n,e)}function y2(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function _8(t,e){const n=bn(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,c=>{a.push(c)});const o=a.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function v2(t,e){const n=Ef(typeof e=="string"?e:e.name,t.schema);return n==="node"?_8(t,e):n==="mark"?u2(t,e):{}}function z8(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function $8(t){const e=z8(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function b2(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((c,u)=>{o.push({from:c,to:u})});else{const{from:c,to:u}=n[a];if(c===void 0||u===void 0)return;o.push({from:c,to:u})}o.forEach(({from:c,to:u})=>{const h=e.slice(a).map(c,-1),f=e.slice(a).map(u),m=e.invert().map(h,-1),g=e.invert().map(f);r.push({oldRange:{from:m,to:g},newRange:{from:h,to:f}})})}),$8(r)}function j0(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=b0(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var F8=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const c=i.node(a);(c==null?void 0:c.type.name)===e?o=c:a-=1}return[o,a]};function kc(t,e){return e.nodes[t]||e.marks[t]||null}function Xu(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var B8=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,c)=>{var u,h;const f=((h=(u=i.type.spec).toText)==null?void 0:h.call(u,{node:i,pos:a,parent:o,index:c}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?f:f.slice(0,Math.max(0,r-a))}),n};function Xg(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?ji(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>a?a.name===m.type.name:!0).find(m=>kh(m.attrs,n,{strict:!1}));let o=0;const c=[];if(i.forEach(({$from:m,$to:g})=>{const y=m.pos,b=g.pos;t.doc.nodesBetween(y,b,(j,w)=>{if(a&&j.inlineContent&&!j.type.allowsMarkType(a))return!1;if(!j.isText&&!j.marks.length)return;const N=Math.max(y,w),C=Math.min(b,w+j.nodeSize),E=C-N;o+=E,c.push(...j.marks.map(M=>({mark:M,from:N,to:C})))})}),o===0)return!1;const u=c.filter(m=>a?a.name===m.mark.type.name:!0).filter(m=>kh(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),h=c.filter(m=>a?m.mark.type!==a&&m.mark.type.excludes(a):!0).reduce((m,g)=>m+g.to-g.from,0);return(u>0?u+h:u)>=o}function V8(t,e,n={}){if(!e)return ya(t,null,n)||Xg(t,null,n);const r=Ef(e,t.schema);return r==="node"?ya(t,e,n):r==="mark"?Xg(t,e,n):!1}var H8=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=Tf(c=>c.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function hN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function fN(t,e){const{nodeExtensions:n}=Tl(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=jt(We(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Mf(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(Mf(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function N2(t){return t instanceof Ke}var w2=class j2{constructor(e){this.position=e}static fromJSON(e){return new j2(e.position)}toJSON(){return{position:this.position}}};function U8(t,e){const n=e.mapping.mapResult(t.position);return{position:new w2(n.pos),mapResult:n}}function K8(t){return new w2(t)}function q8(t,e,n){var r;const{selection:i}=e;let a=null;if(o2(i)&&(a=i.$cursor),a){const c=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(h=>h.type.excludes(n)))}const{ranges:o}=i;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),b=!!n.isInSet(f.marks)||!f.marks.some(j=>j.type.excludes(n));h=y&&b}return!h}),h})}var G8=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:c}=a,u=ji(t,r.schema);if(i)if(o){const h=u2(r,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;r.doc.nodesBetween(f,m,(g,y)=>{const b=Math.max(y,f),j=Math.min(y+g.nodeSize,m);g.marks.find(N=>N.type===u)?g.marks.forEach(N=>{u===N.type&&n.addMark(b,j,u.create({...N.attrs,...e}))}):n.addMark(b,j,u.create(e))})});return q8(r,n,u)},J8=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Y8=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=bn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:c})=>S1(a,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>S1(a,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Q8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=no(t,0,r.content.size),a=Ke.create(r,i);e.setSelection(a)}return!0},X8=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;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=a.from,c=a.to),i&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},Z8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=qe.atStart(r).from,c=qe.atEnd(r).to,u=no(i,o,c),h=no(a,o,c),f=qe.create(r,u,h);e.setSelection(f)}return!0},e6=t=>({state:e,dispatch:n})=>{const r=bn(t,e.schema);return qO(r)(e,n)};function pN(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}var t6=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:c,$to:u}=a,h=i.extensionManager.attributes,f=Xu(h,c.node().type.name,c.node().attrs);if(a instanceof Ke&&a.node.isBlock)return!c.parentOffset||!yi(o,c.pos)?!1:(r&&(t&&pN(n,i.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:M8(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,b=yi(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!b&&yi(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(b=!0,y=g?[{type:g,attrs:f}]:void 0),r){if(b&&(a instanceof qe&&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()),w=e.doc.resolve(j);c.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&pN(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},n6=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const c=bn(t,r.schema),{$from:u,$to:h}=r.selection,f=r.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=a.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(i){let N=ge.empty;const C=u.index(-1)?1:u.index(-2)?2:3;for(let P=u.depth-C;P>=u.depth-3;P-=1)N=ge.from(u.node(P).copy(N));const E=u.indexAfter(-1){if(D>-1)return!1;P.isTextblock&&P.content.size===0&&(D=L+1)}),D>-1&&n.setSelection(qe.near(n.doc.resolve(D))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,b={...Xu(g,m.type.name,m.attrs),...e},j={...Xu(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const w=y?[{type:c,attrs:b},{type:y,attrs:j}]:[{type:c,attrs:b}];if(!yi(n.doc,u.pos,2))return!1;if(i){const{selection:N,storedMarks:C}=r,{splittableMarks:E}=a.extensionManager,M=C||N.$to.parentOffset&&N.$from.marks();if(n.split(u.pos,2,w).scrollIntoView(),!M||!i)return!0;const I=M.filter(O=>E.includes(O.type.name));n.ensureMarks(I)}return!0},Xm=(t,e)=>{const n=Tf(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Sa(t.doc,n.pos)&&t.join(n.pos),!0},Zm=(t,e)=>{const n=Tf(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Sa(t.doc,r)&&t.join(r),!0},r6=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=i.extensionManager,y=bn(t,o.schema),b=bn(e,o.schema),{selection:j,storedMarks:w}=o,{$from:N,$to:C}=j,E=N.blockRange(C),M=w||j.$to.parentOffset&&j.$from.marks();if(!E)return!1;const I=Tf(O=>fN(O.type.name,m))(j);if(E.depth>=1&&I&&E.depth-I.depth<=1){if(I.node.type===y)return h.liftListItem(b);if(fN(I.node.type.name,m)&&y.validContent(I.node.content)&&c)return u().command(()=>(a.setNodeMarkup(I.pos,y),!0)).command(()=>Xm(a,y)).command(()=>Zm(a,y)).run()}return!n||!M||!c?u().command(()=>f().wrapInList(y,r)?!0:h.clearNodes()).wrapInList(y,r).command(()=>Xm(a,y)).command(()=>Zm(a,y)).run():u().command(()=>{const O=f().wrapInList(y,r),D=M.filter(P=>g.includes(P.type.name));return a.ensureMarks(D),O?!0:h.clearNodes()}).wrapInList(y,r).command(()=>Xm(a,y)).command(()=>Zm(a,y)).run()},s6=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=ji(t,r.schema);return Xg(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},i6=(t,e,n={})=>({state:r,commands:i})=>{const a=bn(t,r.schema),o=bn(e,r.schema),c=ya(r,a,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?i.setNode(o,u):i.setNode(a,{...u,...n})},a6=(t,e={})=>({state:n,commands:r})=>{const i=bn(t,n.schema);return ya(n,i,e)?r.lift(i):r.wrapIn(i,e)},o6=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=0;u-=1)o.step(c.steps[u].invert(c.docs[u]));if(a.text){const u=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,u))}else o.delete(a.from,a.to)}return!0}}return!1},l6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},c6=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=ji(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!i)return!0;if(f&&o){let{from:g,to:y}=c;const b=(a=h.marks().find(w=>w.type===u))==null?void 0:a.attrs,j=b0(h,u,b);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},d6=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(c,u)=>{if(c.isText)return;const h={...c.attrs};delete h.dir,e.setNodeMarkup(u,void 0,h)}),!0},u6=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const c=Ef(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=bn(t,r.schema)),c==="mark"&&(o=ji(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,b,j;n.selection.empty?r.doc.nodesBetween(f,m,(w,N)=>{a&&a===w.type&&(u=!0,b=Math.max(N,f),j=Math.min(N+w.nodeSize,m),g=N,y=w)}):r.doc.nodesBetween(f,m,(w,N)=>{N=f&&N<=m&&(a&&a===w.type&&(u=!0,i&&n.setNodeMarkup(N,void 0,{...w.attrs,...e})),o&&w.marks.length&&w.marks.forEach(C=>{if(o===C.type&&(u=!0,i)){const E=Math.max(N,f),M=Math.min(N+w.nodeSize,m);n.addMark(E,M,o.create({...C.attrs,...e}))}}))}),y&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(w=>{o===w.type&&i&&n.addMark(b,j,o.create({...w.attrs,...e}))}))}),u},h6=(t,e={})=>({state:n,dispatch:r})=>{const i=bn(t,n.schema);return FO(i,e)(n,r)},f6=(t,e={})=>({state:n,dispatch:r})=>{const i=bn(t,n.schema);return BO(i,e)(n,r)},p6=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(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Af=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},m6=(t,e)=>{if(v0(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Ou(t){var e;const{editor:n,from:r,to:i,text:a,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(r);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=B8(h)+a;return o.forEach(g=>{if(f)return;const y=m6(m,g.find);if(!y)return;const b=u.state.tr,j=Sf({state:u.state,transaction:b}),w={from:r-(y[0].length-a.length),to:i},{commands:N,chain:C,can:E}=new Cf({editor:n,state:j});g.handler({state:j,range:w,match:y,commands:N,chain:C,can:E})===null||!b.steps.length||(g.undoable&&b.setMeta(c,{transform:b,from:r,to:i,text:a}),u.dispatch(b),f=!0)}),f}function g6(t){const{editor:e,rules:n}=t,r=new Bt({state:{init(){return null},apply(i,a,o){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=w0(ge.from(f),o.schema);const{from:m}=u,g=m+f.length;Ou({editor:e,from:m,to:g,text:f,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,c){return Ou({editor:e,from:a,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&Ou({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Ou({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function x6(t){return Object.prototype.toString.call(t).slice(8,-1)}function Du(t){return x6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function k2(t,e){const n={...t};return Du(t)&&Du(e)&&Object.keys(e).forEach(r=>{Du(e[r])&&Du(t[r])?n[r]=k2(t[r],e[r]):n[r]=e[r]}),n}var k0=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{...jt(We(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...jt(We(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>k2(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}},Co=class S2 extends k0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new S2(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.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&&r.removeStoredMark(u),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function y6(t){return typeof t=="number"}var v6=class{constructor(t){this.find=t.find,this.handler=t.handler}},b6=(t,e,n)=>{if(v0(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function N6(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Cf({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,i,(y,b)=>{var j,w,N,C,E;if((w=(j=y.type)==null?void 0:j.spec)!=null&&w.code||!(y.isText||y.isTextblock||y.isInline))return;const M=(E=(C=(N=y.content)==null?void 0:N.size)!=null?C:y.nodeSize)!=null?E:0,I=Math.max(r,b),O=Math.min(i,b+M);if(I>=O)return;const D=y.isText?y.text||"":y.textBetween(I-b,O-b,void 0,"");b6(D,a.find,o).forEach(L=>{if(L.index===void 0)return;const _=I+L.index+1,X=_+L[0].length,ne={from:n.tr.mapping.map(_),to:n.tr.mapping.map(X)},J=a.handler({state:n,range:ne,match:L,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(J)})}),m.every(y=>y!==null)}var Lu=null,w6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function j6(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!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:b})=>{const j=f.tr,w=Sf({state:f,transaction:j});if(!(!N6({editor:e,state:w,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:b,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 Bt({view(m){const g=b=>{var j;r=(j=m.dom.parentElement)!=null&&j.contains(b.target)?m.dom.parentElement:null,r&&(Lu=e)},y=()=>{Lu&&(Lu=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(a=r===m.dom.parentElement,c=g,!a){const y=Lu;y!=null&&y.isEditable&&setTimeout(()=>{const b=y.state.selection;b&&y.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(m,g)=>{var y;const b=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,i=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const b=m[0],j=b.getMeta("uiEvent")==="paste"&&!i,w=b.getMeta("uiEvent")==="drop"&&!a,N=b.getMeta("applyPasteRules"),C=!!N;if(!j&&!w&&!C)return;if(C){let{text:I}=N;typeof I=="string"?I=I:I=w0(ge.from(I),y.schema);const{from:O}=N,D=O+I.length,P=w6(I);return u({rule:f,state:y,from:O,to:{b:D},pasteEvt:P})}const E=g.doc.content.findDiffStart(y.doc.content),M=g.doc.content.findDiffEnd(y.doc.content);if(!(!y6(E)||!M||E===M.b))return u({rule:f,state:y,from:E,to:M,pasteEvt:o})}}))}var If=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=g2(t),this.schema=O8(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:kc(e.name,this.schema)},r=We(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return $c([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:kc(r.name,this.schema)},a=[],o=We(r,"addKeyboardShortcuts",i);let c={};if(r.type==="mark"&&We(r,"exitable",i)&&(c.ArrowRight=()=>Co.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,b])=>[y,()=>b({editor:t})]));c={...c,...g}}const u=_L(c);a.push(u);const h=We(r,"addInputRules",i);if(hN(r,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=g6({editor:t,rules:g}),b=Array.isArray(y)?y:[y];a.push(...b)}}const f=We(r,"addPasteRules",i);if(hN(r,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=j6({editor:t,rules:g});a.push(...y)}}const m=We(r,"addProseMirrorPlugins",i);if(m){const g=m();a.push(...g)}return a})}get attributes(){return m2(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Tl(this.extensions);return Object.fromEntries(e.filter(n=>!!We(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:bn(n.name,this.schema)},a=We(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const c=(u,h,f,m,g)=>{const y=sd(u,r);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 $c([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:kc(i.name,this.schema)},o=We(i,"dispatchTransaction",a);return o?c=>{o.call(a,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return $c([...this.extensions]).reduce((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:kc(i.name,this.schema)},o=We(i,"transformPastedHTML",a);return o?(c,u)=>{const h=r(c,u);return o.call(a,h)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=Tl(this.extensions);return Object.fromEntries(e.filter(n=>!!We(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ji(n.name,this.schema)},a=We(n,"addMarkView",i);if(!a)return[];const o=(c,u,h)=>{const f=sd(c,r);return a()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{z6(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 r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:kc(e.name,this.schema)};e.type==="mark"&&((n=jt(We(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=We(e,"onBeforeCreate",r),a=We(e,"onCreate",r),o=We(e,"onUpdate",r),c=We(e,"onSelectionUpdate",r),u=We(e,"onTransaction",r),h=We(e,"onFocus",r),f=We(e,"onBlur",r),m=We(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),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)})}};If.resolve=g2;If.sort=$c;If.flatten=N0;var k6={};y0(k6,{ClipboardTextSerializer:()=>E2,Commands:()=>T2,Delete:()=>M2,Drop:()=>A2,Editable:()=>I2,FocusEvents:()=>P2,Keymap:()=>O2,Paste:()=>D2,Tabindex:()=>L2,TextDirection:()=>_2,focusEventsPluginKey:()=>R2});var pn=class C2 extends k0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new C2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},E2=pn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Bt({key:new Qt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(f=>f.$from.pos)),c=Math.max(...a.map(f=>f.$to.pos)),u=y2(n);return x2(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),T2=pn.create({name:"commands",addCommands(){return{...i2}}}),M2=pn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{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=h2(t.before,[t,...e]);b2(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,(b,j)=>{const w=j+b.nodeSize-2,N=y.oldRange.from<=j&&w<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:j,to:w,newFrom:f.mapping.map(j),newTo:f.mapping.map(w),deletedRange:y.oldRange,newRange:y.newRange,partial:!N,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,b)=>{var j,w;if(y instanceof fs){const N=g.slice(b).map(y.from,-1),C=g.slice(b).map(y.to),E=g.invert().map(N,-1),M=g.invert().map(C),I=(j=f.doc.nodeAt(N-1))==null?void 0:j.marks.some(D=>D.eq(y.mark)),O=(w=f.doc.nodeAt(C))==null?void 0:w.marks.some(D=>D.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:N,to:C},partial:!!(O||I),editor:this.editor,transaction:t,combinedTransform:f})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),A2=pn.create({name:"drop",addProseMirrorPlugins(){return[new Bt({key:new Qt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),I2=pn.create({name:"editable",addProseMirrorPlugins(){return[new Bt({key:new Qt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),R2=new Qt("focusEvents"),P2=pn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Bt({key:R2,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),O2=pn.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,b=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,j=b.parent.type.spec.isolating,w=m.pos-m.parentOffset,N=j&&b.parent.childCount===1?w===m.pos:Ze.atStart(h).from===g;return!f||!y.type.isTextblock||y.textContent.length||!N||N&&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()]),r={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()},i={...r},a={...r,"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 Sh()||d2()?a:i},addProseMirrorPlugins(){return[new Bt({key:new Qt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(j=>j.getMeta("composition")))return;const r=t.some(j=>j.docChanged)&&!e.doc.eq(n.doc),i=t.some(j=>j.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:c}=e.selection,u=Ze.atStart(e.doc).from,h=Ze.atEnd(e.doc).to;if(a||!(o===u&&c===h)||!Mf(n.doc))return;const g=n.tr,y=Sf({state:n,transaction:g}),{commands:b}=new Cf({editor:this.editor,state:y});if(b.clearNodes(),!!g.steps.length)return g}})]}}),D2=pn.create({name:"paste",addProseMirrorPlugins(){return[new Bt({key:new Qt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),L2=pn.create({name:"tabindex",addProseMirrorPlugins(){return[new Bt({key:new Qt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),_2=pn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Tl(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 Bt({key:new Qt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),S6=class Ac{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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,r=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,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},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 Ac(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 Ac(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 Ac(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+r+(a?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!i&&!o&&u.depth<=this.depth)return;const h=new Ac(u,this.editor,i,i||o?n:null);i&&(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 r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let c=0;c{r&&i.length>0||(o.node.type.name===e&&a.every(u=>n[u]===o.node.attrs[u])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},C6=`.ProseMirror { - position: relative; -} - -.ProseMirror { - word-wrap: break-word; - white-space: pre-wrap; - white-space: break-spaces; - -webkit-font-variant-ligatures: none; - font-variant-ligatures: none; - font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ -} - -.ProseMirror [contenteditable="false"] { - white-space: normal; -} - -.ProseMirror [contenteditable="false"] [contenteditable="true"] { - white-space: pre-wrap; -} - -.ProseMirror pre { - white-space: pre-wrap; -} - -img.ProseMirror-separator { - display: inline !important; - border: none !important; - margin: 0 !important; - width: 0 !important; - height: 0 !important; -} - -.ProseMirror-gapcursor { - display: none; - pointer-events: none; - position: absolute; - margin: 0; -} - -.ProseMirror-gapcursor:after { - content: ""; - display: block; - position: absolute; - top: -2px; - width: 20px; - border-top: 1px solid black; - animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; -} - -@keyframes ProseMirror-cursor-blink { - to { - visibility: hidden; - } -} - -.ProseMirror-hideselection *::selection { - background: transparent; -} - -.ProseMirror-hideselection *::-moz-selection { - background: transparent; -} - -.ProseMirror-hideselection * { - caret-color: transparent; -} - -.ProseMirror-focused .ProseMirror-gapcursor { - display: block; -}`;function E6(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var T6=class extends p6{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:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:U8,createMappablePosition:K8},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:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=l2(e,this.options.autofocus);this.editorState=gl.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=E6(C6,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],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[I2,E2.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),T2,P2,O2,L2,A2,D2,M2,_2.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new If(r,this)}createCommandManager(){this.commandManager=new Cf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Qg(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=Qg(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new s2(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:i,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),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&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)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return v2(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return V8(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return w0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` - -`,textSerializers:n={}}=t||{};return L8(this.state.doc,{blockSeparator:e,textSerializers:{...y2(this.schema),...n}})}get isEmpty(){return Mf(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 S6(e,this)}get $doc(){return this.$pos(0)}};function Ml(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=jt(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,o=r[r.length-1],c=r[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(j0(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&&a.delete(n.from+u,h);const g=n.from+u+o.length;a.addMark(n.from+u,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function z2(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=jt(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let c=n.to;const u=t.type.create(i);if(r[1]){const h=r[0].lastIndexOf(r[1]);let f=o+h;f>c?f=c:c=f+r[1].length;const m=r[0][r[0].length-1];a.insertText(m,o+r[0].length-1),a.replaceWith(f,c,u)}else if(r[0]){const h=t.type.isInline?o:o-1;a.insert(h,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(c))}a.scrollIntoView()},undoable:t.undoable})}function Zg(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=jt(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function Al(t){return new Af({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=jt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&e0(u,t.type,a);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,b=g||m.$to.parentOffset&&m.$from.marks();if(b){const j=b.filter(w=>y.includes(w.type.name));o.ensureMarks(j)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(m,a).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&Sa(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var M6=t=>"touches"in t,A6=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,r,i,a,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),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.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"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(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,M6(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:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return a?r=this.startWidth+e:o&&(r=this.startWidth-e),c?i=this.startHeight+n:u&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,o;if(!n){let h=Math.max(this.minSize.width,t),f=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(h=Math.min(this.maxSize.width,h)),(i=this.maxSize)!=null&&i.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 r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function I6(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ke){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}function R6(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var P6={};y0(P6,{createAtomBlockMarkdownSpec:()=>O6,createBlockMarkdownSpec:()=>D6,createInlineMarkdownSpec:()=>$2,parseAttributes:()=>S0,parseIndentedBlocks:()=>ex,renderNestedMarkdownContent:()=>E0,serializeAttributes:()=>C0});function S0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const h=i.map(f=>f.trim().slice(1));e.class=h.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.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=r.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 C0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function O6(t){const{nodeName:e,name:n,parseAttributes:r=S0,serializeAttributes:i=C0,defaultAttributes:a={},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={...a,...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|$)`),b=f.match(y);if(!b)return;const j=b[1]||"",w=r(j);if(!o.find(C=>!(C in w)))return{type:e,raw:b[0],attributes:w}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=i(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function D6(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=S0,serializeAttributes:a=C0,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(r){const j=r(m);y=typeof j=="string"?[{type:"text",text:j}]:j}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const b={...o,...m.attributes};return g.createNode(e,b,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),b=(g=m.match(y))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(m,g,y){var b;const j=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=m.match(j);if(!w)return;const[N,C=""]=w,E=i(C);let M=1;const I=N.length;let O="";const D=/^:::([\w-]*)(\s.*)?/gm,P=m.slice(I);for(D.lastIndex=0;;){const L=D.exec(P);if(L===null)break;const _=L.index,X=L[1];if(!((b=L[2])!=null&&b.endsWith(":::"))){if(X)M+=1;else if(M-=1,M===0){const ne=P.slice(0,_);O=ne.trim();const J=m.slice(0,I+_+L[0].length);let U=[];if(O)if(c==="block")for(U=y.blockTokens(ne),U.forEach(R=>{R.text&&(!R.tokens||R.tokens.length===0)&&(R.tokens=y.inlineTokens(R.text))});U.length>0;){const R=U[U.length-1];if(R.type==="paragraph"&&(!R.text||R.text.trim()===""))U.pop();else break}else U=y.inlineTokens(O);return{type:e,raw:J,attributes:E,content:O,tokens:U}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),b=a(y),j=b?` {${b}}`:"",w=g.renderChildren(m.content||[],` - -`);return`:::${h}${j} - -${w} - -:::`}}}function L6(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function _6(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function $2(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=L6,serializeAttributes:a=_6,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(b=>{const j=typeof b=="string"?b:b.name,w=typeof b=="string"?void 0:b.skipIfDefault;if(j in g){const N=g[j];if(w!==void 0&&N===w)return;y[j]=N}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const b={...o,...g.attributes};if(c)return y.createNode(e,b);const j=r?r(g):g.content||"";return j?y.createNode(e,b,[y.createTextNode(j)]):y.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),b=g.match(y),j=b==null?void 0:b.index;return j!==void 0?j:-1},tokenize(g,y,b){const j=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),w=g.match(j);if(!w)return;let N="",C="";if(c){const[,M]=w;C=M}else{const[,M,I]=w;C=M,N=I||""}const E=i(C.trim());return{type:e,raw:w[0],content:N.trim(),attributes:E}}},renderMarkdown:g=>{let y="";r?y=r(g):g.content&&g.content.length>0&&(y=g.content.filter(N=>N.type==="text").map(N=>N.text).join(""));const b=f(g.attrs||{}),j=a(b),w=j?` ${j}`:"";return c?`[${h}${w}]`:`[${h}${w}]${y}[/${h}]`}}}function ex(t,e,n){var r,i,a,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 b=e.extractItemData(y),{indentLevel:j,mainContent:w}=b;h=`${h}${g} -`;const N=[w];for(f+=1;f_.trim()!=="");if(D===-1)break;if((((i=(r=c[f+1+D].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>j){N.push(I),h=`${h}${I} -`,f+=1;continue}else break}if((((o=(a=I.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>j)N.push(I),h=`${h}${I} -`,f+=1;else break}let C;const E=N.slice(1);if(E.length>0){const I=E.map(O=>O.slice(j+m)).join(` -`);I.trim()&&(e.customNestedParser?C=e.customNestedParser(I):C=n.blockTokens(I))}const M=e.createToken(b,C);u.push(M)}if(u.length!==0)return{items:u,raw:h}}function E0(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,c=e.renderChildren([a]),u=[`${i}${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 z6(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.descendants((c,u)=>{const h=a.mapping.map(u),f=a.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});a.removeMark(h,f,t.type),a.addMark(h,f,y)}}),a.docChanged&&e.view.dispatch(a)}var Nn=class F2 extends k0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new F2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function vo(t){return new v6({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=jt(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=e,c=r[r.length-1],u=r[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),g=m+c.length;if(j0(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.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(a||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:$6,getOwnPropertySymbols:F6}=Object,{hasOwnProperty:B6}=Object.prototype;function eg(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function _u(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:a}=i,o=a.get(n),c=a.get(r);if(o&&c)return o===r&&c===n;a.set(n,r),a.set(r,n);const u=t(n,r,i);return a.delete(n),a.delete(r),u}}function V6(t){return t!=null?t[Symbol.toStringTag]:void 0}function mN(t){return $6(t).concat(F6(t))}const H6=Object.hasOwn||((t,e)=>B6.call(t,e));function Eo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const W6="__v",U6="__o",K6="_owner",{getOwnPropertyDescriptor:gN,keys:xN}=Object;function q6(t,e){return t.byteLength===e.byteLength&&Ch(new Uint8Array(t),new Uint8Array(e))}function G6(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function J6(t,e){return t.byteLength===e.byteLength&&Ch(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Y6(t,e){return Eo(t.getTime(),e.getTime())}function Q6(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function X6(t,e){return t===e}function yN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.entries();let o,c,u=0;for(;(o=a.next())&&!o.done;){const h=e.entries();let f=!1,m=0;for(;(c=h.next())&&!c.done;){if(i[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=i[m]=!0;break}m++}if(!f)return!1;u++}return!0}const Z6=Eo;function e_(t,e,n){const r=xN(t);let i=r.length;if(xN(e).length!==i)return!1;for(;i-- >0;)if(!B2(t,e,n,r[i]))return!1;return!0}function Sc(t,e,n){const r=mN(t);let i=r.length;if(mN(e).length!==i)return!1;let a,o,c;for(;i-- >0;)if(a=r[i],!B2(t,e,n,a)||(o=gN(t,a),c=gN(e,a),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function t_(t,e){return Eo(t.valueOf(),e.valueOf())}function n_(t,e){return t.source===e.source&&t.flags===e.flags}function vN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.values();let o,c;for(;(o=a.next())&&!o.done;){const u=e.values();let h=!1,f=0;for(;(c=u.next())&&!c.done;){if(!i[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=i[f]=!0;break}f++}if(!h)return!1}return!0}function Ch(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 r_(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 B2(t,e,n,r){return(r===K6||r===U6||r===W6)&&(t.$$typeof||e.$$typeof)?!0:H6(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const s_="[object ArrayBuffer]",i_="[object Arguments]",a_="[object Boolean]",o_="[object DataView]",l_="[object Date]",c_="[object Error]",d_="[object Map]",u_="[object Number]",h_="[object Object]",f_="[object RegExp]",p_="[object Set]",m_="[object String]",g_={"[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},x_="[object URL]",y_=Object.prototype.toString;function v_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:b}){return function(w,N,C){if(w===N)return!0;if(w==null||N==null)return!1;const E=typeof w;if(E!==typeof N)return!1;if(E!=="object")return E==="number"?c(w,N,C):E==="function"?a(w,N,C):!1;const M=w.constructor;if(M!==N.constructor)return!1;if(M===Object)return u(w,N,C);if(Array.isArray(w))return e(w,N,C);if(M===Date)return r(w,N,C);if(M===RegExp)return f(w,N,C);if(M===Map)return o(w,N,C);if(M===Set)return m(w,N,C);const I=y_.call(w);if(I===l_)return r(w,N,C);if(I===f_)return f(w,N,C);if(I===d_)return o(w,N,C);if(I===p_)return m(w,N,C);if(I===h_)return typeof w.then!="function"&&typeof N.then!="function"&&u(w,N,C);if(I===x_)return y(w,N,C);if(I===c_)return i(w,N,C);if(I===i_)return u(w,N,C);if(g_[I])return g(w,N,C);if(I===s_)return t(w,N,C);if(I===o_)return n(w,N,C);if(I===a_||I===u_||I===m_)return h(w,N,C);if(b){let O=b[I];if(!O){const D=V6(w);D&&(O=b[D])}if(O)return O(w,N,C)}return!1}}function b_({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:q6,areArraysEqual:n?Sc:G6,areDataViewsEqual:J6,areDatesEqual:Y6,areErrorsEqual:Q6,areFunctionsEqual:X6,areMapsEqual:n?eg(yN,Sc):yN,areNumbersEqual:Z6,areObjectsEqual:n?Sc:e_,arePrimitiveWrappersEqual:t_,areRegExpsEqual:n_,areSetsEqual:n?eg(vN,Sc):vN,areTypedArraysEqual:n?eg(Ch,Sc):Ch,areUrlsEqual:r_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=_u(r.areArraysEqual),a=_u(r.areMapsEqual),o=_u(r.areObjectsEqual),c=_u(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:c})}return r}function N_(t){return function(e,n,r,i,a,o,c){return t(e,n,c)}}function w_({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(c,u){const{cache:h=t?new WeakMap:void 0,meta:f}=n();return e(c,u,{cache:h,equals:r,meta:f,strict:i})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const a={cache:void 0,equals:r,meta:void 0,strict:i};return function(c,u){return e(c,u,a)}}const j_=Ea();Ea({strict:!0});Ea({circular:!0});Ea({circular:!0,strict:!0});Ea({createInternalComparator:()=>Eo});Ea({strict:!0,createInternalComparator:()=>Eo});Ea({circular:!0,createInternalComparator:()=>Eo});Ea({circular:!0,createInternalComparator:()=>Eo,strict:!0});function Ea(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=b_(t),o=v_(a),c=n?n(o):N_(o);return w_({circular:e,comparator:o,createState:r,equals:c,strict:i})}var tg={exports:{}},ng={};/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var bN;function k_(){if(bN)return ng;bN=1;var t=cd(),e=Ak();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return ng.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var b=a(null);if(b.current===null){var j={hasValue:!1,value:null};b.current=j}else j=b.current;b=c(function(){function N(O){if(!C){if(C=!0,E=O,O=g(O),y!==void 0&&j.hasValue){var D=j.value;if(y(D,O))return M=D}return M=O}if(D=M,r(E,O))return D;var P=g(O);return y!==void 0&&y(D,P)?(E=O,D):(E=O,M=P)}var C=!1,E,M,I=m===void 0?null:m;return[function(){return N(f())},I===null?void 0:function(){return N(I())}]},[f,m,g,y]);var w=i(h,b[0],b[1]);return o(function(){j.hasValue=!0,j.value=w},[w]),u(w),w},ng}var NN;function S_(){return NN||(NN=1,tg.exports=k_()),tg.exports}var C_=S_(),E_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},T_=({contentComponent:t})=>{const e=Ik.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function M_(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Tw.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var A_=class extends ur.Component{constructor(t){var e;super(t),this.editorContentRef=ur.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=M_(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:E_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(T_,{contentComponent:t.contentComponent})]})}},I_=v.forwardRef((t,e)=>{const n=ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ur.createElement(A_,{key:n,innerRef:e,...t})}),V2=ur.memo(I_),R_=typeof window<"u"?v.useLayoutEffect:v.useEffect,P_=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(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function O_(t){var e;const[n]=v.useState(()=>new P_(t.editor)),r=C_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:j_);return R_(()=>n.watch(t.editor),[t.editor,n]),v.useDebugValue(r),r}var D_=!1,tx=typeof window>"u",L_=tx||!!(typeof window<"u"&&window.next),__=class H2{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?tx||L_?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new T6(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(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?H2.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((r,i)=>r===e[i]))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 z_(t={},e=[]){const n=v.useRef(t);n.current=t;const[r]=v.useState(()=>new __(n)),i=Ik.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return v.useDebugValue(i),v.useEffect(r.onRender(e)),O_({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var W2=v.createContext({editor:null});W2.Consumer;var $_=v.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),F_=()=>v.useContext($_);ur.forwardRef((t,e)=>{const{onDragStart:n}=F_(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ur.createContext({markViewContentRef:()=>{}});var T0=v.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});T0.displayName="TiptapContext";var B_=()=>v.useContext(T0);function U2({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=v.useMemo(()=>({editor:r}),[r]),a=v.useMemo(()=>({editor:r}),[r]);return s.jsx(W2.Provider,{value:a,children:s.jsx(T0.Provider,{value:i,children:n})})}U2.displayName="Tiptap";function K2({...t}){const{editor:e}=B_();return s.jsx(V2,{editor:e,...t})}K2.displayName="Tiptap.Content";Object.assign(U2,{Content:K2});var Eh=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},V_=/^\s*>\s$/,H_=Nn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Eh("blockquote",{...kt(this.options.HTMLAttributes,t),children:Eh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const c=e.renderChildren([i]).split(` -`).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(c.join(` -`))}),r.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[Al({find:V_,type:this.type})]}}),W_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,U_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,K_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,q_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,G_=Co.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 Eh("strong",{...kt(this.options.HTMLAttributes,t),children:Eh("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[Ml({find:W_,type:this.type}),Ml({find:K_,type:this.type})]},addPasteRules(){return[vo({find:U_,type:this.type}),vo({find:q_,type:this.type})]}}),J_=/(^|[^`])`([^`]+)`(?!`)$/,Y_=/(^|[^`])`([^`]+)`(?!`)/g,Q_=Co.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",kt(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[Ml({find:J_,type:this.type})]},addPasteRules(){return[vo({find:Y_,type:this.type})]}}),rg=4,X_=/^```([a-z]+)?[\s\n]$/,Z_=/^~~~([a-z]+)?[\s\n]$/,e7=Nn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:rg,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 a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",kt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(` -`):r=`\`\`\`${i} - -\`\`\``,r},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:rg,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.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}=i,y=r.doc.textBetween(h,f,` -`,` -`).split(` -`).map(b=>c+b).join(` -`);return u.replaceWith(h,f,r.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:rg,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:c})=>{var u;const{pos:h}=a,f=a.start(),m=a.end(),y=r.doc.textBetween(f,m,` -`,` -`).split(` -`);let b=0,j=0;const w=h-f;for(let O=0;O=w){b=O;break}j+=y[O].length+1}const C=((u=y[b].match(/^ */))==null?void 0:u[0])||"",E=Math.min(C.length,n);if(E===0)return!0;let M=f;for(let O=0;O{const{from:u,to:h}=i,g=r.doc.textBetween(u,h,` -`,` -`).split(` -`).map(y=>{var b;const j=((b=y.match(/^ */))==null?void 0:b[0])||"",w=Math.min(j.length,n);return y.slice(w)}).join(` -`);return c.replaceWith(u,h,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` - -`);return!a||!o?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(Ze.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Zg({find:X_,type:this.type,getAttributes:t=>({language:t[1]})}),Zg({find:Z_,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Bt({key:new Qt("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i==null?void 0:i.mode;if(!n||!a)return!1;const{tr:o,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,` -`));return o.replaceSelectionWith(this.type.create({language:a},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(qe.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),t7=Nn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` - -`):""}),n7=Nn.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",kt(this.options.HTMLAttributes,t)]},renderText(){return` -`},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=r.extensionManager,u=a||i.$to.parentOffset&&i.$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()}}}),r7=Nn.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]}`,kt(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 r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${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=>Zg({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),s7=Nn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",kt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!I6(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return N2(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:o,dispatch:c})=>{if(c){const{$to:u}=o.selection,h=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(qe.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Ke.create(o.doc,u.pos)):o.setSelection(qe.create(o.doc,u.pos));else{const f=a.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=f==null?void 0:f.create();m&&(o.insert(h,m),o.setSelection(qe.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[z2({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),i7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,a7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,o7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,l7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,c7=Co.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",kt(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[Ml({find:i7,type:this.type}),Ml({find:o7,type:this.type})]},addPasteRules(){return[vo({find:a7,type:this.type}),vo({find:l7,type:this.type})]}});const d7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",u7="ελ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",nx="numeric",rx="ascii",sx="alpha",Fc="asciinumeric",Ic="alphanumeric",ix="domain",q2="emoji",h7="scheme",f7="slashscheme",sg="whitespace";function p7(t,e){return t in e||(e[t]=[]),e[t]}function ro(t,e,n){e[nx]&&(e[Fc]=!0,e[Ic]=!0),e[rx]&&(e[Fc]=!0,e[sx]=!0),e[Fc]&&(e[Ic]=!0),e[sx]&&(e[Ic]=!0),e[Ic]&&(e[ix]=!0),e[q2]&&(e[ix]=!0);for(const r in e){const i=p7(r,n);i.indexOf(t)<0&&i.push(t)}}function m7(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function jr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}jr.groups={};jr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),cn=(t,e,n,r,i)=>t.tr(e,n,r,i),wN=(t,e,n,r,i)=>t.ts(e,n,r,i),Se=(t,e,n,r,i)=>t.tt(e,n,r,i),hi="WORD",ax="UWORD",G2="ASCIINUMERICAL",J2="ALPHANUMERICAL",id="LOCALHOST",ox="TLD",lx="UTLD",Zu="SCHEME",dl="SLASH_SCHEME",M0="NUM",cx="WS",A0="NL",Bc="OPENBRACE",Vc="CLOSEBRACE",Th="OPENBRACKET",Mh="CLOSEBRACKET",Ah="OPENPAREN",Ih="CLOSEPAREN",Rh="OPENANGLEBRACKET",Ph="CLOSEANGLEBRACKET",Oh="FULLWIDTHLEFTPAREN",Dh="FULLWIDTHRIGHTPAREN",Lh="LEFTCORNERBRACKET",_h="RIGHTCORNERBRACKET",zh="LEFTWHITECORNERBRACKET",$h="RIGHTWHITECORNERBRACKET",Fh="FULLWIDTHLESSTHAN",Bh="FULLWIDTHGREATERTHAN",Vh="AMPERSAND",Hh="APOSTROPHE",Wh="ASTERISK",Zi="AT",Uh="BACKSLASH",Kh="BACKTICK",qh="CARET",na="COLON",I0="COMMA",Gh="DOLLAR",Is="DOT",Jh="EQUALS",R0="EXCLAMATION",qr="HYPHEN",Hc="PERCENT",Yh="PIPE",Qh="PLUS",Xh="POUND",Wc="QUERY",P0="QUOTE",Y2="FULLWIDTHMIDDLEDOT",O0="SEMI",Rs="SLASH",Uc="TILDE",Zh="UNDERSCORE",Q2="EMOJI",ef="SYM";var X2=Object.freeze({__proto__:null,ALPHANUMERICAL:J2,AMPERSAND:Vh,APOSTROPHE:Hh,ASCIINUMERICAL:G2,ASTERISK:Wh,AT:Zi,BACKSLASH:Uh,BACKTICK:Kh,CARET:qh,CLOSEANGLEBRACKET:Ph,CLOSEBRACE:Vc,CLOSEBRACKET:Mh,CLOSEPAREN:Ih,COLON:na,COMMA:I0,DOLLAR:Gh,DOT:Is,EMOJI:Q2,EQUALS:Jh,EXCLAMATION:R0,FULLWIDTHGREATERTHAN:Bh,FULLWIDTHLEFTPAREN:Oh,FULLWIDTHLESSTHAN:Fh,FULLWIDTHMIDDLEDOT:Y2,FULLWIDTHRIGHTPAREN:Dh,HYPHEN:qr,LEFTCORNERBRACKET:Lh,LEFTWHITECORNERBRACKET:zh,LOCALHOST:id,NL:A0,NUM:M0,OPENANGLEBRACKET:Rh,OPENBRACE:Bc,OPENBRACKET:Th,OPENPAREN:Ah,PERCENT:Hc,PIPE:Yh,PLUS:Qh,POUND:Xh,QUERY:Wc,QUOTE:P0,RIGHTCORNERBRACKET:_h,RIGHTWHITECORNERBRACKET:$h,SCHEME:Zu,SEMI:O0,SLASH:Rs,SLASH_SCHEME:dl,SYM:ef,TILDE:Uc,TLD:ox,UNDERSCORE:Zh,UTLD:lx,UWORD:ax,WORD:hi,WS:cx});const di=/[a-z]/,Cc=new RegExp("\\p{L}","u"),ig=new RegExp("\\p{Emoji}","u"),ui=/\d/,ag=/\s/,jN="\r",og=` -`,g7="️",x7="‍",lg="";let zu=null,$u=null;function y7(t=[]){const e={};jr.groups=e;const n=new jr;zu==null&&(zu=kN(d7)),$u==null&&($u=kN(u7)),Se(n,"'",Hh),Se(n,"{",Bc),Se(n,"}",Vc),Se(n,"[",Th),Se(n,"]",Mh),Se(n,"(",Ah),Se(n,")",Ih),Se(n,"<",Rh),Se(n,">",Ph),Se(n,"(",Oh),Se(n,")",Dh),Se(n,"「",Lh),Se(n,"」",_h),Se(n,"『",zh),Se(n,"』",$h),Se(n,"<",Fh),Se(n,">",Bh),Se(n,"&",Vh),Se(n,"*",Wh),Se(n,"@",Zi),Se(n,"`",Kh),Se(n,"^",qh),Se(n,":",na),Se(n,",",I0),Se(n,"$",Gh),Se(n,".",Is),Se(n,"=",Jh),Se(n,"!",R0),Se(n,"-",qr),Se(n,"%",Hc),Se(n,"|",Yh),Se(n,"+",Qh),Se(n,"#",Xh),Se(n,"?",Wc),Se(n,'"',P0),Se(n,"/",Rs),Se(n,";",O0),Se(n,"~",Uc),Se(n,"_",Zh),Se(n,"\\",Uh),Se(n,"・",Y2);const r=cn(n,ui,M0,{[nx]:!0});cn(r,ui,r);const i=cn(r,di,G2,{[Fc]:!0}),a=cn(r,Cc,J2,{[Ic]:!0}),o=cn(n,di,hi,{[rx]:!0});cn(o,ui,i),cn(o,di,o),cn(i,ui,i),cn(i,di,i);const c=cn(n,Cc,ax,{[sx]:!0});cn(c,di),cn(c,ui,a),cn(c,Cc,c),cn(a,ui,a),cn(a,di),cn(a,Cc,a);const u=Se(n,og,A0,{[sg]:!0}),h=Se(n,jN,cx,{[sg]:!0}),f=cn(n,ag,cx,{[sg]:!0});Se(n,lg,f),Se(h,og,u),Se(h,lg,f),cn(h,ag,f),Se(f,jN),Se(f,og),cn(f,ag,f),Se(f,lg,f);const m=cn(n,ig,Q2,{[q2]:!0});Se(m,"#"),cn(m,ig,m),Se(m,g7,m);const g=Se(m,x7);Se(g,"#"),cn(g,ig,m);const y=[[di,o],[ui,i]],b=[[di,null],[Cc,c],[ui,a]];for(let j=0;jj[0]>w[0]?1:-1);for(let j=0;j=0?C[ix]=!0:di.test(w)?ui.test(w)?C[Fc]=!0:C[rx]=!0:C[nx]=!0,wN(n,w,w,C)}return wN(n,"localhost",id,{ascii:!0}),n.jd=new jr(ef),{start:n,tokens:Object.assign({groups:e},X2)}}function Z2(t,e){const n=v7(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o=0&&(m+=n[o].length,g++),h+=n[o].length,a+=n[o].length,o++;a-=m,o-=g,h-=m,i.push({t:f.t,v:e.slice(a-h,a),s:a-h,e:a})}return i}function v7(t){const e=[],n=t.length;let r=0;for(;r56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Gi(t,e,n,r,i){let a;const o=e.length;for(let c=0;c=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const ad={defaultProtocol:"http",events:null,format:SN,formatHref:SN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function D0(t,e=null){let n=Object.assign({},ad);t&&(n=Object.assign(n,t instanceof D0?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;an?r.substring(0,n)+"…":r},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=ad.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")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=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=r,c&&(o.class=c),u&&(o.target=u),h&&(o.rel=h),f&&Object.assign(o,f),{tagName:i,attributes:o,content:a,eventListeners:m}}};function Rf(t,e){class n extends eC{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const CN=Rf("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),EN=Rf("text"),b7=Rf("nl"),Fu=Rf("url",{isLink:!0,toHref(t=ad.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==id&&t[1].t===na}}),Kr=t=>new jr(t);function N7({groups:t}){const e=t.domain.concat([Vh,Wh,Zi,Uh,Kh,qh,Gh,Jh,qr,M0,Hc,Yh,Qh,Xh,Rs,ef,Uc,Zh]),n=[Hh,na,I0,Is,R0,Hc,Wc,P0,O0,Rh,Ph,Bc,Vc,Mh,Th,Ah,Ih,Oh,Dh,Lh,_h,zh,$h,Fh,Bh],r=[Vh,Hh,Wh,Uh,Kh,qh,Gh,Jh,qr,Bc,Vc,Hc,Yh,Qh,Xh,Wc,Rs,ef,Uc,Zh],i=Kr(),a=Se(i,Uc);lt(a,r,a),lt(a,t.domain,a);const o=Kr(),c=Kr(),u=Kr();lt(i,t.domain,o),lt(i,t.scheme,c),lt(i,t.slashscheme,u),lt(o,r,a),lt(o,t.domain,o);const h=Se(o,Zi);Se(a,Zi,h),Se(c,Zi,h),Se(u,Zi,h);const f=Se(a,Is);lt(f,r,a),lt(f,t.domain,a);const m=Kr();lt(h,t.domain,m),lt(m,t.domain,m);const g=Se(m,Is);lt(g,t.domain,m);const y=Kr(CN);lt(g,t.tld,y),lt(g,t.utld,y),Se(h,id,y);const b=Se(m,qr);Se(b,qr,b),lt(b,t.domain,m),lt(y,t.domain,m),Se(y,Is,g),Se(y,qr,b);const j=Se(y,na);lt(j,t.numeric,CN);const w=Se(o,qr),N=Se(o,Is);Se(w,qr,w),lt(w,t.domain,o),lt(N,r,a),lt(N,t.domain,o);const C=Kr(Fu);lt(N,t.tld,C),lt(N,t.utld,C),lt(C,t.domain,o),lt(C,r,a),Se(C,Is,N),Se(C,qr,w),Se(C,Zi,h);const E=Se(C,na),M=Kr(Fu);lt(E,t.numeric,M);const I=Kr(Fu),O=Kr();lt(I,e,I),lt(I,n,O),lt(O,e,I),lt(O,n,O),Se(C,Rs,I),Se(M,Rs,I);const D=Se(c,na),P=Se(u,na),L=Se(P,Rs),_=Se(L,Rs);lt(c,t.domain,o),Se(c,Is,N),Se(c,qr,w),lt(u,t.domain,o),Se(u,Is,N),Se(u,qr,w),lt(D,t.domain,I),Se(D,Rs,I),Se(D,Wc,I),lt(_,t.domain,I),lt(_,e,I),Se(_,Rs,I);const X=[[Bc,Vc],[Th,Mh],[Ah,Ih],[Rh,Ph],[Oh,Dh],[Lh,_h],[zh,$h],[Fh,Bh]];for(let ne=0;ne=0&&g++,i++,f++;if(g<0)i-=f,i0&&(a.push(cg(EN,e,o)),o=[]),i-=g,f-=g;const y=m.t,b=n.slice(i-f,i);a.push(cg(y,e,b))}}return o.length>0&&a.push(cg(EN,e,o)),a}function cg(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const j7=typeof console<"u"&&console&&console.warn||(()=>{}),k7="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ut={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function S7(){return jr.groups={},Ut.scanner=null,Ut.parser=null,Ut.tokenQueue=[],Ut.pluginQueue=[],Ut.customSchemes=[],Ut.initialized=!1,Ut}function TN(t,e=!1){if(Ut.initialized&&j7(`linkifyjs: already initialized - will not register custom scheme "${t}" ${k7}`),!/^[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`);Ut.customSchemes.push([t,e])}function C7(){Ut.scanner=y7(Ut.customSchemes);for(let t=0;t{const i=e.some(h=>h.docChanged)&&!n.doc.eq(r.doc),a=e.some(h=>h.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,c=h2(n.doc,[...e]);if(b2(c).forEach(({newRange:h})=>{const f=A8(r.doc,h,y=>y.isTextblock);let m,g;if(f.length>1)m=f[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const y=r.doc.textBetween(h.from,h.to," "," ");if(!T7.test(y))return;m=f[0],g=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(E7).filter(Boolean);if(y.length<=0)return!1;const b=y[y.length-1],j=m.pos+g.lastIndexOf(b);if(!b)return!1;const w=L0(b).map(N=>N.toObject(t.defaultProtocol));if(!A7(w))return!1;w.filter(N=>N.isLink).map(N=>({...N,from:j+N.start+1,to:j+N.end+1})).filter(N=>r.schema.marks.code?!r.doc.rangeHasMark(N.from,N.to,r.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{j0(N.from,N.to,r.doc).some(C=>C.mark.type===t.type)||o.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!o.steps.length)return o}})}function R7(t){return new Bt({key:new Qt("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const u=r.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=v2(e.state,t.type.name),h=(i=o.href)!=null?i:u.href,f=(a=o.target)!=null?a:u.target;h&&(window.open(h,f),c=!0)}return c}}})}function P7(t){return new Bt({key:new Qt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:c}=o;if(c)return!1;let u="";r.content.forEach(f=>{u+=f.textContent});const h=tC(u,{defaultProtocol:t.defaultProtocol}).find(f=>f.isLink&&f.value===u);return!u||!h||i!==void 0&&!i(h.value)?!1:t.editor.commands.setMark(t.type,{href:h.href})}}})}function Ya(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(M7,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var nC=Co.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"){TN(t);return}TN(t.scheme,t.optionalSlashes)})},onDestroy(){S7()},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)=>!!Ya(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 i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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=>!!Ya(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=>!!Ya(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",kt(this.options.HTMLAttributes,t),0]:["a",kt(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,r,i,a;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(a=(i=t.attrs)==null?void 0:i.title)!=null?a:"",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:r=>!!Ya(r,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:r=>!!Ya(r,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[vo({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=tC(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Ya(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.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(I7({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ya(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(R7({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(P7({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),O7=nC,D7=Object.defineProperty,L7=(t,e)=>{for(var n in e)D7(t,n,{get:e[n],enumerable:!0})},_7="listItem",MN="textStyle",AN=/^\s*([-+*])\s$/,rC=Nn.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",kt(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(_7,this.editor.getAttributes(MN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Al({find:AN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Al({find:AN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(MN),editor:this.editor})),[t]}}),sC=Nn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",kt(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(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.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)=>E0(t,e,r=>{var i,a;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((a=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:a.start)||1)+r.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)}}}),z7={};L7(z7,{findListItemPos:()=>xd,getNextListDepth:()=>z0,handleBackspace:()=>dx,handleDelete:()=>ux,hasListBefore:()=>iC,hasListItemAfter:()=>$7,hasListItemBefore:()=>aC,listItemHasSubList:()=>oC,nextListIsDeeper:()=>lC,nextListIsHigher:()=>cC});var xd=(t,e)=>{const{$from:n}=e.selection,r=bn(t,e.schema);let i=null,a=n.depth,o=n.pos,c=null;for(;a>0&&c===null;)i=n.node(a),i.type===r?c=a:(a-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},z0=(t,e)=>{const n=xd(t,e);if(!n)return!1;const[,r]=F8(e,t,n.$pos.pos+4);return r},iC=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},aC=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},oC=(t,e,n)=>{if(!n)return!1;const r=bn(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},dx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ya(t.state,e)&&iC(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(!ya(t.state,e)||!W8(t.state))return!1;const r=xd(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=oC(e,t.state,a);return aC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},lC=(t,e)=>{const n=z0(t,e),r=xd(t,e);return!r||!n?!1:n>r.depth},cC=(t,e)=>{const n=z0(t,e),r=xd(t,e);return!r||!n?!1:n{if(!ya(t.state,e)||!H8(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:lC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():cC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},$7=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},dC=pn.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&&ux(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&&ux(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&dx(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&dx(t,n,r)&&(e=!0)}),e}}}}),IN=/^(\s*)(\d+)\.\s+(.*)$/,F7=/^\s/;function B7(t){const e=[];let n=0,r=0;for(;ne;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(j=>j.indent)),b=uC(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(j=>j.raw).join(` -`)})}i.push({type:"list_item",raw:o.raw,tokens:h}),a=m}else a+=1}return i}function V7(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var H7="listItem",RN="textStyle",PN=/^(\d+)\.\s$/,hC=Nn.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",kt(this.options.HTMLAttributes,n),0]:["ol",kt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?V7(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},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 r;const i=t.split(` -`),[a,o]=B7(i);if(a.length===0)return;const c=uC(a,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:c,raw:i.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(H7,this.editor.getAttributes(RN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Al({find:PN,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=Al({find:PN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(RN)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),W7=/^\s*(\[([( |x])?\])\s$/,U7=Nn.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",kt(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 r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return E0(t,e,i)},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:r})=>{const i=document.createElement("li"),a=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),a.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const b=n();if(typeof b!="number")return!1;const j=y.doc.nodeAt(b);return y.setNodeMarkup(b,void 0,{...j==null?void 0:j.attrs,checked:g}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{i.setAttribute(m,g)}),i.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,a.append(c,o),i.append(a,u),Object.entries(e).forEach(([m,g])=>{i.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:i,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;i.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=r.extensionManager.attributes,y=sd(m,g),b=new Set(Object.keys(y)),j=this.options.HTMLAttributes;return f.forEach(w=>{b.has(w)||(w in j?i.setAttribute(w,j[w]):i.removeAttribute(w))}),Object.entries(y).forEach(([w,N])=>{N==null?w in j?i.setAttribute(w,j[w]):i.removeAttribute(w):i.setAttribute(w,N)}),f=b,!0}}}},addInputRules(){return[Al({find:W7,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),K7=Nn.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",kt(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 r=a=>{const o=ex(a,{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:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(a)},i=ex(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.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()}}});pn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(rC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(sC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(dC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(hC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(U7.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(K7.configure(this.options.taskList)),t}});var ON=" ",q7=" ",G7=Nn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",kt(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 r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===ON||r[0].text===q7)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?ON:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),J7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Y7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Q7=Co.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",kt(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[Ml({find:J7,type:this.type})]},addPasteRules(){return[vo({find:Y7,type:this.type})]}}),X7=Nn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Z7=Co.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",kt(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 i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},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 ez(t={}){return new Bt({view(e){return new tz(e,t)}})}class tz{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}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,r,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,c=a.height/i.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 b=y.getBoundingClientRect(),j=m?b.bottom:b.top;m&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*c;r={left:b.left,right:b.right,top:j-w,bottom:j+w}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={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=(r.left-h)/o+"px",this.element.style.top=(r.top-f)/c+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.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}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=sS(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 un extends Ze{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return un.valid(r)?new un(r):Ze.near(r)}content(){return Ie.empty}eq(e){return e instanceof un&&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 un(e.resolve(n.pos))}getBookmark(){return new $0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!nz(e)||!rz(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&un.valid(e))return e;let i=e.pos,a=null;for(let o=e.depth;;o--){let c=e.node(o);if(n>0?e.indexAfter(o)0){a=c.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let u=e.doc.resolve(i);if(un.valid(u))return u}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Ke.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let c=e.doc.resolve(i);if(un.valid(c))return c}return null}}}un.prototype.visible=!1;un.findFrom=un.findGapCursorFrom;Ze.jsonID("gapcursor",un);class $0{constructor(e){this.pos=e}map(e){return new $0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return un.valid(n)?new un(n):Ze.near(n)}}function fC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function nz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||fC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function rz(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||fC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function sz(){return new Bt({props:{decorations:lz,createSelectionBetween(t,e,n){return e.pos==n.pos&&un.valid(n)?new un(n):null},handleClick:az,handleKeyDown:iz,handleDOMEvents:{beforeinput:oz}}})}const iz=x0({ArrowLeft:Bu("horiz",-1),ArrowRight:Bu("horiz",1),ArrowUp:Bu("vert",-1),ArrowDown:Bu("vert",1)});function Bu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof qe){if(!a.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=un.findGapCursorFrom(c,e,u);return h?(i&&i(r.tr.setSelection(new un(h))),!0):!1}}function az(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!un.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ke.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new un(r))),!0)}function oz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof un))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=ge.empty;for(let o=r.length-1;o>=0;o--)i=ge.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Ie(i,0,0));return a.setSelection(qe.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function lz(t){if(!(t.selection instanceof un))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",It.create(t.doc,[En.widget(t.selection.head,e,{key:"gapcursor"})])}var tf=200,Dn=function(){};Dn.prototype.append=function(e){return e.length?(e=Dn.from(e),!this.length&&e||e.length=n?Dn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Dn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Dn.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Dn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Dn.from=function(e){return e instanceof Dn?e:e&&e.length?new pC(e):Dn.empty};var pC=(function(t){function e(r){t.call(this),this.values=r}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(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,c){for(var u=a;u=o;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=tf)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=tf)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Dn);Dn.empty=new pC([]);var cz=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.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(r){return rc&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,a)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(a,c)-c,o+c)===!1||a=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Dn);const dz=500;class hs{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,f.push(m);return}if(i){f.push(new Ji(m.map));let y=m.step.map(i.slice(a)),b;y&&o.maybeStep(y).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],h.push(new Ji(b,void 0,void 0,h.length+f.length))),a--,b&&i.appendMap(b,a)}else o.maybeStep(m.step);if(m.selection)return c=i?m.selection.map(i.slice(a)):m.selection,u=new hs(this.items.slice(0,r).append(f.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:c}}addTransform(e,n,r,i){let a=[],o=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let f=0;fhz&&(c=uz(c,h),o-=h),new hs(c.append(a),o)}remapping(e,n){let r=new Xc;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new hs(this.items.append(e.map(n=>new Ji(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},i);let u=n;this.items.forEach(g=>{let y=a.getMirror(--u);if(y==null)return;o=Math.min(o,y);let b=a.maps[y];if(g.step){let j=e.steps[y].invert(e.docs[y]),w=g.selection&&g.selection.map(a.slice(u+1,y));w&&c++,r.push(new Ji(b,j,w))}else r.push(new Ji(b))},i);let h=[];for(let g=n;gdz&&(m=m.compress(this.items.length-r.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),r=n.maps.length,i=[],a=0;return this.items.forEach((o,c)=>{if(c>=e)i.push(o),o.selection&&a++;else if(o.step){let u=o.step.map(n.slice(r)),h=u&&u.getMap();if(r--,h&&n.appendMap(h,r),u){let f=o.selection&&o.selection.map(n.slice(r));f&&a++;let m=new Ji(h.invert(),u,f),g,y=i.length-1;(g=i.length&&i[y].merge(m))?i[y]=g:i.push(m)}}else o.map&&r--},this.items.length,0),new hs(Dn.from(i.reverse()),a)}}hs.empty=new hs(Dn.empty,0);function uz(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}let Ji=class mC{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new mC(n.getMap().invert(),n,this.selection)}}};class ea{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const hz=20;function fz(t,e,n,r){let i=n.getMeta(co),a;if(i)return i.historyState;n.getMeta(gz)&&(t=new ea(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(co))return o.getMeta(co).redo?new ea(t.done.addTransform(n,void 0,r,eh(e)),t.undone,DN(n.mapping.maps),t.prevTime,t.prevComposition):new ea(t.done,t.undone.addTransform(n,void 0,r,eh(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)-r.newGroupDelay||!pz(n,t.prevRanges)),h=o?dg(t.prevRanges,n.mapping):DN(n.mapping.maps);return new ea(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,eh(e)),hs.empty,h,n.time,c??t.prevComposition)}else return(a=n.getMeta("rebased"))?new ea(t.done.rebased(n,a),t.undone.rebased(n,a),dg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ea(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),dg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function pz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a=e[a]&&(n=!0)}),n}function DN(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function dg(t,e){if(!t)return null;let n=[];for(let r=0;r{let i=co.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=mz(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const xC=gC(!1,!0),yC=gC(!0,!0);pn.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 r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}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 Bt({key:new Qt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-i,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const h=r.tr.deleteRange(c,u);return t=!0,h}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=a-r,h=c-u,f=c;return e.deleteRange(h,f),!(this.storage.characters({node:e.doc})>r)}})]}});var yz=pn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ez(this.options)]}});pn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Bt({key:new Qt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return It.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,h)=>{if(u.isText)return;if(!(i>=h&&i<=h+u.nodeSize-1))return!1;o+=1});let c=0;return t.descendants((u,h)=>{if(u.isText||!(i>=h&&i<=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";a.push(En.node(h,h+u.nodeSize,{class:this.options.className}))}),It.create(t,a)}}})]}});var vz=pn.create({name:"gapCursor",addProseMirrorPlugins(){return[sz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=jt(We(t,"allowGapCursor",n)))!=null?e:null}}}),_N="placeholder";function bz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Nz=pn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:_N,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${bz(this.options.dataAttribute)}`:`data-${_N}`;return[new Bt({key:new Qt("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=i>=u&&i<=u+c.nodeSize,f=!c.isLeaf&&Mf(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=En.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});a.push(g)}return this.options.includeChildren}),It.create(e,a)}}})]}});pn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Bt({key:new Qt("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||N2(n.selection)||t.view.dragging?null:It.create(n.doc,[En.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function zN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var wz=pn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Qt(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Bt({key:e,appendTransaction:(i,a,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:(i,a)=>{const o=a.tr.doc.lastChild;return!zN({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!zN({node:o,types:r})}}})]}}),jz=pn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>xC(t,e),redo:()=>({state:t,dispatch:e})=>yC(t,e)}},addProseMirrorPlugins(){return[xz(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()}}}),kz=pn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(G_.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(H_.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(rC.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Q_.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(e7.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(t7.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(yz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(vz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(n7.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(r7.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(jz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(s7.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(c7.configure(this.options.italic)),this.options.listItem!==!1&&i.push(sC.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(dC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(nC.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(hC.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(G7.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Q7.configure(this.options.strike)),this.options.text!==!1&&i.push(X7.configure(this.options.text)),this.options.underline!==!1&&i.push(Z7.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(wz.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),Sz=kz,Cz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ez=Nn.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",kt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",h=(o=(a=t.attrs)==null?void 0:a.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:r}=this.options.resize;return({node:i,getPos:a,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 A6({element:u,editor:c,node:i,getPos:a,onResize:(m,g)=>{u.style.width=`${m}px`,u.style.height=`${g}px`},onCommit:(m,g)=>{const y=a();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!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[z2({find:Cz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Tz=Ez;function Mz(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:c}=t,u=r&&!i,h=R6(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=i?"":h,y=u?new RegExp(`${m}${h}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${g}]*`,"gm"),b=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!b)return null;const j=c.pos-b.length,w=Array.from(b.matchAll(y)).pop();if(!w||w.input===void 0||w.index===void 0)return null;const N=w.input.slice(Math.max(0,w.index-1),w.index),C=new RegExp(`^[${a==null?void 0:a.join("")}\0]?$`).test(N);if(a!==null&&!C)return null;const E=j+w.index;let M=E+w[0].length;return u&&f.test(b.slice(M-1,M+1))&&(w[0]+=" ",M+=1),E=c.pos?{range:{from:E,to:M},query:w[0].slice(n.length),text:w[0]}:null}var Az=new Qt("suggestion");function Iz({pluginKey:t=Az,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[" "],startOfLine:o=!1,decorationTag:c="span",decorationClass:u="suggestion",decorationContent:h="",decorationEmptyClass:f="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:b=()=>!0,findSuggestionMatch:j=Mz,shouldShow:w}){let N;const C=y==null?void 0:y(),E=()=>{const D=e.state.selection.$anchor.pos,P=e.view.coordsAtPos(D),{top:L,right:_,bottom:X,left:ne}=P;try{return new DOMRect(ne,L,_-ne,X-L)}catch{return null}},M=(D,P)=>P?()=>{const L=t.getState(e.state),_=L==null?void 0:L.decorationId,X=D.dom.querySelector(`[data-decoration-id="${_}"]`);return(X==null?void 0:X.getBoundingClientRect())||null}:E;function I(D,P){var L;try{const X=t.getState(D.state),ne=X!=null&&X.decorationId?D.dom.querySelector(`[data-decoration-id="${X.decorationId}"]`):null,J={editor:e,range:(X==null?void 0:X.range)||{from:0,to:0},query:(X==null?void 0:X.query)||null,text:(X==null?void 0:X.text)||null,items:[],command:U=>m({editor:e,range:(X==null?void 0:X.range)||{from:0,to:0},props:U}),decorationNode:ne,clientRect:M(D,ne)};(L=C==null?void 0:C.onExit)==null||L.call(C,J)}catch{}const _=D.state.tr.setMeta(P,{exit:!0});D.dispatch(_)}const O=new Bt({key:t,view(){return{update:async(D,P)=>{var L,_,X,ne,J,U,R;const F=(L=this.key)==null?void 0:L.getState(P),re=(_=this.key)==null?void 0:_.getState(D.state),z=F.active&&re.active&&F.range.from!==re.range.from,ae=!F.active&&re.active,G=F.active&&!re.active,$=!ae&&!G&&F.query!==re.query,H=ae||z&&$,ce=$||z,W=G||z&&$;if(!H&&!ce&&!W)return;const fe=W&&!H?F:re,Q=D.dom.querySelector(`[data-decoration-id="${fe.decorationId}"]`);N={editor:e,range:fe.range,query:fe.query,text:fe.text,items:[],command:de=>m({editor:e,range:fe.range,props:de}),decorationNode:Q,clientRect:M(D,Q)},H&&((X=C==null?void 0:C.onBeforeStart)==null||X.call(C,N)),ce&&((ne=C==null?void 0:C.onBeforeUpdate)==null||ne.call(C,N)),(ce||H)&&(N.items=await g({editor:e,query:fe.query})),W&&((J=C==null?void 0:C.onExit)==null||J.call(C,N)),ce&&((U=C==null?void 0:C.onUpdate)==null||U.call(C,N)),H&&((R=C==null?void 0:C.onStart)==null||R.call(C,N))},destroy:()=>{var D;N&&((D=C==null?void 0:C.onExit)==null||D.call(C,N))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(D,P,L,_){const{isEditable:X}=e,{composing:ne}=e.view,{selection:J}=D,{empty:U,from:R}=J,F={...P},re=D.getMeta(t);if(re&&re.exit)return F.active=!1,F.decorationId=null,F.range={from:0,to:0},F.query=null,F.text=null,F;if(F.composing=ne,X&&(U||e.view.composing)){(RP.range.to)&&!ne&&!P.composing&&(F.active=!1);const z=j({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:J.$from}),ae=`id_${Math.floor(Math.random()*4294967295)}`;z&&b({editor:e,state:_,range:z.range,isActive:P.active})&&(!w||w({editor:e,range:z.range,query:z.query,text:z.text,transaction:D}))?(F.active=!0,F.decorationId=P.decorationId?P.decorationId:ae,F.range=z.range,F.query=z.query,F.text=z.text):F.active=!1}else F.active=!1;return F.active||(F.decorationId=null,F.range={from:0,to:0},F.query=null,F.text=null),F}},props:{handleKeyDown(D,P){var L,_,X,ne;const{active:J,range:U}=O.getState(D.state);if(!J)return!1;if(P.key==="Escape"||P.key==="Esc"){const F=O.getState(D.state),re=(L=N==null?void 0:N.decorationNode)!=null?L:null,z=re??(F!=null&&F.decorationId?D.dom.querySelector(`[data-decoration-id="${F.decorationId}"]`):null);if(((_=C==null?void 0:C.onKeyDown)==null?void 0:_.call(C,{view:D,event:P,range:F.range}))||!1)return!0;const G={editor:e,range:F.range,query:F.query,text:F.text,items:[],command:$=>m({editor:e,range:F.range,props:$}),decorationNode:z,clientRect:z?()=>z.getBoundingClientRect()||null:null};return(X=C==null?void 0:C.onExit)==null||X.call(C,G),I(D,t),!0}return((ne=C==null?void 0:C.onKeyDown)==null?void 0:ne.call(C,{view:D,event:P,range:U}))||!1},decorations(D){const{active:P,range:L,decorationId:_,query:X}=O.getState(D);if(!P)return null;const ne=!(X!=null&&X.length),J=[u];return ne&&J.push(f),It.create(D.doc,[En.inline(L.from,L.to,{nodeName:c,class:J.join(" "),"data-decoration-id":_,"data-decoration-content":h})])}}});return O}function Rz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const i=new Qt;return{editor:t,char:r,pluginKey:i,command:({editor:a,range:o,props:c})=>{var u,h,f;const m=a.view.state.selection.$to.nodeAfter;((u=m==null?void 0:m.text)==null?void 0:u.startsWith(" "))&&(o.to+=1),a.chain().focus().insertContentAt(o,[{type:n,attrs:{...c,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(f=(h=a.view.dom.ownerDocument.defaultView)==null?void 0:h.getSelection())==null||f.collapseToEnd()},allow:({state:a,range:o})=>{const c=a.doc.resolve(o.from),u=a.schema.nodes[n];return!!c.parent.type.contentMatch.matchType(u)},...e}}function vC(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Rz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function $N(t,e){const n=vC(t),r=n.find(i=>i.char===e);return r||(n.length?n[0]:null)}var Pz=Nn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e==null?void 0:e.char)!=null?n:"@"}${(r=t.attrs.label)!=null?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,i;return["span",kt(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(i=e.attrs.label)!=null?i: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=$N(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",kt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=kt({"data-type":this.name},this.options.HTMLAttributes,e);const i=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof i=="string"?["span",kt({"data-type":this.name},this.options.HTMLAttributes,e),i]:i},...$2({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r,c=a??o;e[i==="char"?"mentionSuggestionChar":i]=c,r=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:$N(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:r}=e,{empty:i,anchor:a}=r;if(!i)return!1;let o=new xi,c=0;return e.doc.nodesBetween(a-1,a,(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 vC(this).map(Iz)}}),Oz=Pz,Dz=Nz;let hx,fx;if(typeof WeakMap<"u"){let t=new WeakMap;hx=e=>t.get(e),fx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;hx=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var fn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(a||(a=[])).push({type:"overlong_rowspan",pos:f,n:N-E});break}const M=i+E*e;for(let I=0;Ir&&(a+=h.attrs.colspan)}}for(let o=0;o1&&(n=!0)}e==-1?e=a:e!=a&&(e=Math.max(e,a))}return e}function zz(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Fz(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 bs(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 Pf(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=bo(e.$head)||Bz(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Bz(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function px(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Vz(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function F0(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function bC(t,e,n){const r=t.node(-1),i=fn.get(r),a=t.start(-1),o=i.nextCell(t.pos-a,e,n);return o==null?null:t.node(0).resolve(a+o)}function No(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function NC(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;if!=n.pos-a);u.unshift(n.pos-a);const h=u.map(f=>{const m=r.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=a+f+1;return new cS(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 r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(px(r)&&px(i)&&F0(r,i)){const a=this.$anchorCell.node(-1)!=r.node(-1);return a&&this.isRowSelection()?fi.rowSelection(r,i):a&&this.isColSelection()?fi.colSelection(r,i):new fi(r,i)}return qe.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),a={},o=[];for(let u=i.top;u0||w>0){let N=b.attrs;if(j>0&&(N=No(N,0,j)),w>0&&(N=No(N,N.colspan-w,w)),y.lefti.bottom){const N={...b.attrs,rowspan:Math.min(y.bottom,i.bottom)-Math.max(y.top,i.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=fn.get(r),a=e.start(-1),o=i.findCell(e.pos-a),c=i.findCell(n.pos-a),u=e.node(0);return o.top<=c.top?(o.top>0&&(e=u.resolve(a+i.map[o.left])),c.bottom0&&(n=u.resolve(a+i.map[c.left])),o.bottom0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,c=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,c)==n.width}eq(e){return e instanceof fi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=fn.get(r),a=e.start(-1),o=i.findCell(e.pos-a),c=i.findCell(n.pos-a),u=e.node(0);return o.left<=c.left?(o.left>0&&(e=u.resolve(a+i.map[o.top*i.width])),c.right0&&(n=u.resolve(a+i.map[c.top*i.width])),o.right{e.push(En.node(r,r+n.nodeSize,{class:"selectedCell"}))}),It.create(t.doc,e)}function Kz({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(a+1)>e.start(a));a--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function qz({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const a=t.node(i);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){n=a;break}}for(let i=e.depth;i>0;i--){const a=e.node(i);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){r=a;break}}return n!==r&&e.parentOffset===0}function Gz(t,e,n){const r=(e||t).selection,i=(e||t).doc;let a,o;if(r instanceof Ke&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")a=Ft.create(i,r.from);else if(o=="row"){const c=i.resolve(r.from+1);a=Ft.rowSelection(c,c)}else if(!n){const c=fn.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];a=Ft.create(i,u+1,h)}}else r instanceof qe&&Kz(r)?a=qe.create(i,r.from):r instanceof qe&&qz(r)&&(a=qe.create(i,r.$from.start(),r.$from.end()));return a&&(e||(e=t.tr)).setSelection(a),e}const Jz=new Qt("fix-tables");function jC(t,e,n,r){const i=t.childCount,a=e.childCount;e:for(let o=0,c=0;o{i.type.spec.tableRole=="table"&&(n=Yz(t,i,a,n))};return e?e.doc!=t.doc&&jC(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Yz(t,e,n,r){const i=fn.get(e);if(!i.problems)return r;r||(r=t.tr);const a=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const b=[];for(let w=0;w0?-1:0;Hz(e,r,i+a)&&(a=i==0||i==e.width?null:0);for(let o=0;o0&&i0&&e.map[c-1]==u||i0?-1:0;t$(e,r,i+c)&&(c=i==0||i==e.height?null:0);for(let h=0,f=e.width*i;h0&&i0&&m==e.map[f-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g,rowspan:g.rowspan-1}),h+=g.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-t]||r.bottom0){const f=u+1+h.content.size,m=FN(h)?u+1:f;a.replaceWith(m+r.tableStart,f+r.tableStart,c)}a.setSelection(new Ft(a.doc.resolve(u+r.tableStart))),e(a)}return!0}function VN(t,e){const n=rr(t.schema);return o$(({node:r})=>n[r.type.spec.tableRole])(t,e)}function o$(t){return(e,n)=>{const r=e.selection;let i,a;if(r instanceof Ft){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{var o;if(i=Fz(r.$from),!i)return!1;a=(o=bo(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let c=i.attrs;const u=[],h=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const f=Bs(e),m=e.tr;for(let y=0;y{o.attrs[t]!==e&&a.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(a)}return!0}}function c$(t){return function(e,n){if(!bs(e))return!1;if(n){const r=rr(e.schema),i=Bs(e),a=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),c=o.map(u=>i.table.nodeAt(u));for(let u=0;u{const y=g+a.tableStart,b=o.doc.nodeAt(y);b&&o.setNodeMarkup(y,m,b.attrs)}),r(o)}return!0}}od("row",{useDeprecatedLogic:!0});od("column",{useDeprecatedLogic:!0});const d$=od("cell",{useDeprecatedLogic:!0});function u$(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const a=t.node(-1).child(r),o=a.lastChild;if(o)return i-1-o.nodeSize;i-=a.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Vu(t,e){const n=t.selection;if(!(n instanceof Ft))return!1;if(e){const r=t.tr,i=rr(t.schema).cell.createAndFill().content;n.forEachCell((a,o)=>{a.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+a.nodeSize-1),new Ie(i,0,0))}),r.docChanged&&e(r)}return!0}function f$(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),a=i.type.spec.tableRole,o=i.type.schema,c=[];if(a=="row")for(let u=0;u=0;o--){const{rowspan:c,colspan:u}=a.child(o).attrs;for(let h=i;h=e.length&&e.push(ge.empty),n[i]r&&(g=g.type.createChecked(No(g.attrs,g.attrs.colspan,f+g.attrs.colspan-r),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;yi&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,i-m.attrs.rowspan)},m.content)),u.push(m)}a.push(ge.from(u))}n=a,e=i}return{width:t,height:e,rows:n}}function g$(t,e,n,r,i,a,o){const c=t.doc.type.schema,u=rr(c);let h,f;if(i>e.width)for(let m=0,g=0;me.height){const m=[];for(let b=0,j=(e.height-1)*e.width;b=e.width?!1:n.nodeAt(e.map[j+b]).type==u.header_cell;m.push(w?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,ge.from(m)),y=[];for(let b=e.height;b{if(!i)return!1;const a=n.selection;if(a instanceof Ft)return th(n,r,Ze.near(a.$headCell,e));if(t!="horiz"&&!a.empty)return!1;const o=EC(i,t,e);if(o==null)return!1;if(t=="horiz")return th(n,r,Ze.near(n.doc.resolve(a.head+e),e));{const c=n.doc.resolve(o),u=bC(c,t,e);let h;return u?h=Ze.near(u,1):e<0?h=Ze.near(n.doc.resolve(c.before(-1)),-1):h=Ze.near(n.doc.resolve(c.after(-1)),1),th(n,r,h)}}}function Wu(t,e){return(n,r,i)=>{if(!i)return!1;const a=n.selection;let o;if(a instanceof Ft)o=a;else{const u=EC(i,t,e);if(u==null)return!1;o=new Ft(n.doc.resolve(u))}const c=bC(o.$headCell,t,e);return c?th(n,r,new Ft(o.$anchorCell,c)):!1}}function y$(t,e){const n=t.state.doc,r=bo(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ft(r))),!0):!1}function v$(t,e,n){if(!bs(t.state))return!1;let r=f$(n);const i=t.state.selection;if(i instanceof Ft){r||(r={width:1,height:1,rows:[ge.from(mx(rr(t.state.schema).cell,n))]});const a=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),c=fn.get(a).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=m$(r,c.right-c.left,c.bottom-c.top),qN(t.state,t.dispatch,o,c,r),!0}else if(r){const a=Pf(t.state),o=a.start(-1);return qN(t.state,t.dispatch,o,fn.get(a.node(-1)).findCell(a.pos-o),r),!0}else return!1}function b$(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=GN(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof Ft)a(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=bo(t.state.selection.$anchor))!=null&&((n=hg(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)a(i,e),e.preventDefault();else if(!r)return;function a(u,h){let f=hg(t,h);const m=ra.getState(t.state)==null;if(!f||!F0(u,f))if(m)f=u;else return;const g=new Ft(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(ra,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),ra.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ra,-1))}function c(u){const h=u,f=ra.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(GN(t,h.target)!=r&&(m=hg(t,e),!m))return o();m&&a(m,h)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",c)}function EC(t,e,n){if(!(t.state.selection instanceof qe))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole=="cell"||a.type.spec.tableRole=="header_cell"){const o=r.before(i),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function GN(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function hg(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&bo(t.state.doc.resolve(r))||bo(t.state.doc.resolve(i))}var N$=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")),gx(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,gx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function gx(t,e,n,r,i,a){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;mnew r(m,n,g)),new j$(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=Or.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{k$(o,c,t,i)},mouseleave:o=>{S$(o)},mousedown:(o,c)=>{C$(o,c,e,n)}},decorations:o=>{const c=Or.getState(o);if(c&&c.activeHandle>-1)return I$(o,c.activeHandle)},nodeViews:{}}});return a}var j$=class nh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Or);if(r&&r.setHandle!=null)return new nh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new nh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return px(e.doc.resolve(i))||(i=-1),new nh(i,n.dragging)}return n}};function k$(t,e,n,r){if(!t.editable)return;const i=Or.getState(t.state);if(i&&!i.dragging){const a=T$(e.target);let o=-1;if(a){const{left:c,right:u}=a.getBoundingClientRect();e.clientX-c<=n?o=JN(t,e,"left",n):u-e.clientX<=n&&(o=JN(t,e,"right",n))}if(o!=i.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=fn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}TC(t,o)}}}function S$(t){if(!t.editable)return;const e=Or.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&TC(t,-1)}function C$(t,e,n,r){var i;if(!t.editable)return!1;const a=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=Or.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=E$(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Or,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){a.removeEventListener("mouseup",h),a.removeEventListener("mousemove",f);const g=Or.getState(t.state);g!=null&&g.dragging&&(M$(t,g.activeHandle,YN(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Or,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=Or.getState(t.state);if(g&&g.dragging){const y=YN(g.dragging,m,n);QN(t,g.activeHandle,y,r)}}return QN(t,o.activeHandle,u,r),a.addEventListener("mouseup",h),a.addEventListener("mousemove",f),e.preventDefault(),!0}function E$(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const a=t.domAtPos(e);let o=a.node.childNodes[a.offset].offsetWidth,c=n;if(r)for(let u=0;u{var e,n;const r=t.getAttribute("colwidth"),i=r?r.split(",").map(a=>parseInt(a,10)):null;if(!i){const a=(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&&a&&a[o]){const c=a[o].getAttribute("width");return c?[parseInt(c,10)]:null}}return i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",kt(this.options.HTMLAttributes,t),0]}}),AC=Nn.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(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",kt(this.options.HTMLAttributes,t),0]}}),IC=Nn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",kt(this.options.HTMLAttributes,t),0]}});function xx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function XN(t,e,n,r,i,a){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 r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function L$(t,e,n,r,i){const a=D$(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!_$(e))return!1;let n=0;const r=f2(e.ranges[0].$from,a=>a.type.name==="table");return r==null||r.node.descendants(a=>{if(a.type.name==="table")return!1;["tableCell","tableHeader"].includes(a.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},z$="";function $$(t){return(t||"").replace(/\s+/g," ").trim()}function F$(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:z$;if(!t||!t.content||t.content.length===0)return"";const a=[];t.content.forEach(b=>{const j=[];b.content&&b.content.forEach(w=>{let N="";w.content&&Array.isArray(w.content)&&w.content.length>1?N=w.content.map(I=>e.renderChildren(I)).join(i):N=w.content?e.renderChildren(w.content):"";const C=$$(N),E=w.type==="tableHeader";j.push({text:C,isHeader:E})}),a.push(j)});const o=a.reduce((b,j)=>Math.max(b,j.length),0);if(o===0)return"";const c=new Array(o).fill(0);a.forEach(b=>{var j;for(let w=0;wc[w]&&(c[w]=C),c[w]<3&&(c[w]=3)}});const u=(b,j)=>b+" ".repeat(Math.max(0,j-b.length)),h=a[0],f=h.some(b=>b.isHeader);let m=` -`;const g=new Array(o).fill(0).map((b,j)=>f&&h[j]&&h[j].text||"");return m+=`| ${g.map((b,j)=>u(b,c[j])).join(" | ")} | -`,m+=`| ${c.map(b=>"-".repeat(Math.max(3,b))).join(" | ")} | -`,(f?a.slice(1):a).forEach(b=>{m+=`| ${new Array(o).fill(0).map((j,w)=>u(b[w]&&b[w].text||"",c[w])).join(" | ")} | -`}),m}var B$=F$,RC=Nn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:P$,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:r,tableMinWidth:i}=O$(t,this.options.cellMinWidth),a=e.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}const c=["table",kt(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 r=[];t.header.forEach(i=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const i=[];r.forEach(a=>{i.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>B$(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{const o=L$(a.schema,t,e,n);if(i){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(qe.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qz(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Xz(t,e),deleteColumn:()=>({state:t,dispatch:e})=>e$(t,e),addRowBefore:()=>({state:t,dispatch:e})=>n$(t,e),addRowAfter:()=>({state:t,dispatch:e})=>r$(t,e),deleteRow:()=>({state:t,dispatch:e})=>i$(t,e),deleteTable:()=>({state:t,dispatch:e})=>h$(t,e),mergeCells:()=>({state:t,dispatch:e})=>BN(t,e),splitCell:()=>({state:t,dispatch:e})=>VN(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>od("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>od("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>d$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>BN(t,e)?!0:VN(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>l$(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>WN(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>WN(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&kC(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ft.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}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:Uu,"Mod-Backspace":Uu,Delete:Uu,"Mod-Delete":Uu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[w$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],R$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:jt(We(t,"tableRole",e))}}});pn.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(RC.configure(this.options.table)),this.options.tableCell!==!1&&t.push(MC.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(AC.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(IC.configure(this.options.tableRow)),t}});function V$(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 - -`),e=e.replace(/]*>(.*?)<\/h2>/gi,`## $1 - -`),e=e.replace(/]*>(.*?)<\/h3>/gi,`### $1 - -`),e=e.replace(/]*>(.*?)<\/strong>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/b>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/em>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/i>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/s>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/del>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/code>/gi,"`$1`"),e=e.replace(/]*>(.*?)<\/blockquote>/gi,`> $1 - -`),e=e.replace(/]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*>/gi,"![$2]($1)"),e=e.replace(/]*src="([^"]*)"[^>]*>/gi,"![]($1)"),e=e.replace(/]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi,"[$2]($1)"),e=e.replace(/]*>(.*?)<\/li>/gi,`- $1 -`),e=e.replace(/<\/?[uo]l[^>]*>/gi,` -`),e=e.replace(//gi,` -`),e=e.replace(/]*>(.*?)<\/p>/gi,`$1 - -`),e=e.replace(//gi,`--- - -`),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 ew(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(new RegExp("(?$1"),e=e.replace(new RegExp("(?$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(` -`),r=[];for(const i of n){const a=i.trim();a&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(a)?r.push(a):r.push(`

    ${a}

    `))}return r.join("")}const H$=Nn.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",kt(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}`]}}),W$=t=>({items:({query:e})=>(t.current||[]).filter(r=>r.name.toLowerCase().includes(e.toLowerCase())||r.id.includes(e)).slice(0,8),render:()=>{let e=null,n=0,r=[],i=null;const a=()=>{e&&(e.innerHTML=r.map((o,c)=>`
    - @${o.name} - ${o.label||o.id} -
    `).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");i&&r[c]&&i({id:r[c].id,label:r[c].name})})}))};return{onStart:o=>{if(e=document.createElement("div"),e.className="mention-popup",document.body.appendChild(e),r=o.items,i=o.command,n=0,a(),o.clientRect){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onUpdate:o=>{if(r=o.items,i=o.command,n=0,a(),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),a(),!0):o.event.key==="ArrowDown"?(n=Math.min(r.length-1,n+1),a(),!0):o.event.key==="Enter"?(i&&r[n]&&i({id:r[n].id,label:r[n].name}),!0):o.event.key==="Escape"?(e==null||e.remove(),e=null,!0):!1,onExit:()=>{e==null||e.remove(),e=null}}}}),yx=v.forwardRef(({content:t,onChange:e,onImageUpload:n,persons:r=[],linkTags:i=[],placeholder:a="开始编辑内容...",className:o},c)=>{const u=v.useRef(null),[h,f]=v.useState(""),[m,g]=v.useState(!1),y=v.useRef(ew(t)),b=v.useRef(e);b.current=e;const j=v.useRef(r);j.current=r;const w=v.useRef(),N=z_({extensions:[Sz,Tz.configure({inline:!0,allowBase64:!0}),O7.configure({openOnClick:!1,HTMLAttributes:{class:"rich-link"}}),Oz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:W$(j)}),H$,Dz.configure({placeholder:a}),RC.configure({resizable:!0}),IC,MC,AC],content:y.current,onUpdate:({editor:I})=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{b.current(I.getHTML())},300)},editorProps:{attributes:{class:"rich-editor-content"}}});v.useImperativeHandle(c,()=>({getHTML:()=>(N==null?void 0:N.getHTML())||"",getMarkdown:()=>V$((N==null?void 0:N.getHTML())||"")})),v.useEffect(()=>{if(N&&t!==N.getHTML()){const I=ew(t);I!==N.getHTML()&&N.commands.setContent(I)}},[t]);const C=v.useCallback(async I=>{var D;const O=(D=I.target.files)==null?void 0:D[0];if(!(!O||!N)){if(n){const P=await n(O);P&&N.chain().focus().setImage({src:P}).run()}else{const P=new FileReader;P.onload=()=>{typeof P.result=="string"&&N.chain().focus().setImage({src:P.result}).run()},P.readAsDataURL(O)}I.target.value=""}},[N,n]),E=v.useCallback(I=>{N&&N.chain().focus().insertContent({type:"linkTag",attrs:{label:I.label,url:I.url||"",tagType:I.type||"url",tagId:I.id||"",pagePath:I.pagePath||"",appId:I.appId||"",mpKey:I.type==="miniprogram"&&I.appId||""}}).run()},[N]),M=v.useCallback(()=>{!N||!h||(N.chain().focus().setLink({href:h}).run(),f(""),g(!1))},[N,h]);return N?s.jsxs("div",{className:`rich-editor-wrapper ${o||""}`,children:[s.jsxs("div",{className:"rich-editor-toolbar",children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().toggleBold().run(),className:N.isActive("bold")?"is-active":"",type:"button",children:s.jsx(OT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleItalic().run(),className:N.isActive("italic")?"is-active":"",type:"button",children:s.jsx(OM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleStrike().run(),className:N.isActive("strike")?"is-active":"",type:"button",children:s.jsx(IA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleCode().run(),className:N.isActive("code")?"is-active":"",type:"button",children:s.jsx(eM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().toggleHeading({level:1}).run(),className:N.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(kM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleHeading({level:2}).run(),className:N.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(CM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleHeading({level:3}).run(),className:N.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(TM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().toggleBulletList().run(),className:N.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(WM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleOrderedList().run(),className:N.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(VM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleBlockquote().run(),className:N.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(gA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(tA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:C,className:"hidden"}),s.jsx("button",{onClick:()=>{var I;return(I=u.current)==null?void 0:I.click()},type:"button",children:s.jsx(Uw,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>g(!m),className:N.isActive("link")?"is-active":"",type:"button",children:s.jsx(Sg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",children:s.jsx(PA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().undo().run(),disabled:!N.can().undo(),type:"button",children:s.jsx(FA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().redo().run(),disabled:!N.can().redo(),type:"button",children:s.jsx(yA,{className:"w-4 h-4"})})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-divider"}),s.jsx("div",{className:"toolbar-group",children:s.jsxs("select",{className:"link-tag-select",onChange:I=>{const O=i.find(D=>D.id===I.target.value);O&&E(O),I.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(I=>s.jsx("option",{value:I.id,children:I.label},I.id))]})})]})]}),m&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:h,onChange:I=>f(I.target.value),onKeyDown:I=>I.key==="Enter"&&M(),className:"link-input"}),s.jsx("button",{onClick:M,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{N.chain().focus().unsetLink().run(),g(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(V2,{editor:N})]}):null});yx.displayName="RichEditor";const U$=["top","right","bottom","left"],va=Math.min,Rr=Math.max,nf=Math.round,Ku=Math.floor,Ls=t=>({x:t,y:t}),K$={left:"right",right:"left",bottom:"top",top:"bottom"},q$={start:"end",end:"start"};function vx(t,e,n){return Rr(t,va(e,n))}function bi(t,e){return typeof t=="function"?t(e):t}function Ni(t){return t.split("-")[0]}function Fl(t){return t.split("-")[1]}function B0(t){return t==="x"?"y":"x"}function V0(t){return t==="y"?"height":"width"}const G$=new Set(["top","bottom"]);function Ds(t){return G$.has(Ni(t))?"y":"x"}function H0(t){return B0(Ds(t))}function J$(t,e,n){n===void 0&&(n=!1);const r=Fl(t),i=H0(t),a=V0(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(o=rf(o)),[o,rf(o)]}function Y$(t){const e=rf(t);return[bx(t),e,bx(e)]}function bx(t){return t.replace(/start|end/g,e=>q$[e])}const tw=["left","right"],nw=["right","left"],Q$=["top","bottom"],X$=["bottom","top"];function Z$(t,e,n){switch(t){case"top":case"bottom":return n?e?nw:tw:e?tw:nw;case"left":case"right":return e?Q$:X$;default:return[]}}function eF(t,e,n,r){const i=Fl(t);let a=Z$(Ni(t),n==="start",r);return i&&(a=a.map(o=>o+"-"+i),e&&(a=a.concat(a.map(bx)))),a}function rf(t){return t.replace(/left|right|bottom|top/g,e=>K$[e])}function tF(t){return{top:0,right:0,bottom:0,left:0,...t}}function PC(t){return typeof t!="number"?tF(t):{top:t,right:t,bottom:t,left:t}}function sf(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function rw(t,e,n){let{reference:r,floating:i}=t;const a=Ds(e),o=H0(e),c=V0(o),u=Ni(e),h=a==="y",f=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,g=r[c]/2-i[c]/2;let y;switch(u){case"top":y={x:f,y:r.y-i.height};break;case"bottom":y={x:f,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:m};break;case"left":y={x:r.x-i.width,y:m};break;default:y={x:r.x,y:r.y}}switch(Fl(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 nF(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:a,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=bi(e,t),b=PC(y),w=c[g?m==="floating"?"reference":"floating":m],N=sf(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),C=m==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),M=await(a.isElement==null?void 0:a.isElement(E))?await(a.getScale==null?void 0:a.getScale(E))||{x:1,y:1}:{x:1,y:1},I=sf(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:C,offsetParent:E,strategy:u}):C);return{top:(N.top-I.top+b.top)/M.y,bottom:(I.bottom-N.bottom+b.bottom)/M.y,left:(N.left-I.left+b.left)/M.x,right:(I.right-N.right+b.right)/M.x}}const rF=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:o}=n,c=a.filter(Boolean),u=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:m}=rw(h,r,u),g=r,y={},b=0;for(let w=0;w({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:a,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=bi(t,e)||{};if(h==null)return{};const m=PC(f),g={x:n,y:r},y=H0(i),b=V0(y),j=await o.getDimensions(h),w=y==="y",N=w?"top":"left",C=w?"bottom":"right",E=w?"clientHeight":"clientWidth",M=a.reference[b]+a.reference[y]-g[y]-a.floating[b],I=g[y]-a.reference[y],O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let D=O?O[E]:0;(!D||!await(o.isElement==null?void 0:o.isElement(O)))&&(D=c.floating[E]||a.floating[b]);const P=M/2-I/2,L=D/2-j[b]/2-1,_=va(m[N],L),X=va(m[C],L),ne=_,J=D-j[b]-X,U=D/2-j[b]/2+P,R=vx(ne,U,J),F=!u.arrow&&Fl(i)!=null&&U!==R&&a.reference[b]/2-(UU<=0)){var X,ne;const U=(((X=a.flip)==null?void 0:X.index)||0)+1,R=D[U];if(R&&(!(m==="alignment"?C!==Ds(R):!1)||_.every(z=>Ds(z.placement)===C?z.overflows[0]>0:!0)))return{data:{index:U,overflows:_},reset:{placement:R}};let F=(ne=_.filter(re=>re.overflows[0]<=0).sort((re,z)=>re.overflows[1]-z.overflows[1])[0])==null?void 0:ne.placement;if(!F)switch(y){case"bestFit":{var J;const re=(J=_.filter(z=>{if(O){const ae=Ds(z.placement);return ae===C||ae==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(ae=>ae>0).reduce((ae,G)=>ae+G,0)]).sort((z,ae)=>z[1]-ae[1])[0])==null?void 0:J[0];re&&(F=re);break}case"initialPlacement":F=c;break}if(i!==F)return{reset:{placement:F}}}return{}}}};function sw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function iw(t){return U$.some(e=>t[e]>=0)}const aF=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...a}=bi(t,e);switch(i){case"referenceHidden":{const o=await r.detectOverflow(e,{...a,elementContext:"reference"}),c=sw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:iw(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...a,altBoundary:!0}),c=sw(o,n.floating);return{data:{escapedOffsets:c,escaped:iw(c)}}}default:return{}}}}},OC=new Set(["left","top"]);async function oF(t,e){const{placement:n,platform:r,elements:i}=t,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ni(n),c=Fl(n),u=Ds(n)==="y",h=OC.has(o)?-1:1,f=a&&u?-1:1,m=bi(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:b}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof b=="number"&&(y=c==="end"?b*-1:b),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const lF=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:a,placement:o,middlewareData:c}=e,u=await oF(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:a+u.y,data:{...u,placement:o}}}}},cF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:a}=e,{mainAxis:o=!0,crossAxis:c=!1,limiter:u={fn:N=>{let{x:C,y:E}=N;return{x:C,y:E}}},...h}=bi(t,e),f={x:n,y:r},m=await a.detectOverflow(e,h),g=Ds(Ni(i)),y=B0(g);let b=f[y],j=f[g];if(o){const N=y==="y"?"top":"left",C=y==="y"?"bottom":"right",E=b+m[N],M=b-m[C];b=vx(E,b,M)}if(c){const N=g==="y"?"top":"left",C=g==="y"?"bottom":"right",E=j+m[N],M=j-m[C];j=vx(E,j,M)}const w=u.fn({...e,[y]:b,[g]:j});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[y]:o,[g]:c}}}}}},dF=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:a,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=bi(t,e),f={x:n,y:r},m=Ds(i),g=B0(m);let y=f[g],b=f[m];const j=bi(c,e),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(u){const E=g==="y"?"height":"width",M=a.reference[g]-a.floating[E]+w.mainAxis,I=a.reference[g]+a.reference[E]-w.mainAxis;yI&&(y=I)}if(h){var N,C;const E=g==="y"?"width":"height",M=OC.has(Ni(i)),I=a.reference[m]-a.floating[E]+(M&&((N=o.offset)==null?void 0:N[m])||0)+(M?0:w.crossAxis),O=a.reference[m]+a.reference[E]+(M?0:((C=o.offset)==null?void 0:C[m])||0)-(M?w.crossAxis:0);bO&&(b=O)}return{[g]:y,[m]:b}}}},uF=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:a,platform:o,elements:c}=e,{apply:u=()=>{},...h}=bi(t,e),f=await o.detectOverflow(e,h),m=Ni(i),g=Fl(i),y=Ds(i)==="y",{width:b,height:j}=a.floating;let w,N;m==="top"||m==="bottom"?(w=m,N=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(N=m,w=g==="end"?"top":"bottom");const C=j-f.top-f.bottom,E=b-f.left-f.right,M=va(j-f[w],C),I=va(b-f[N],E),O=!e.middlewareData.shift;let D=M,P=I;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(P=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(D=C),O&&!g){const _=Rr(f.left,0),X=Rr(f.right,0),ne=Rr(f.top,0),J=Rr(f.bottom,0);y?P=b-2*(_!==0||X!==0?_+X:Rr(f.left,f.right)):D=j-2*(ne!==0||J!==0?ne+J:Rr(f.top,f.bottom))}await u({...e,availableWidth:P,availableHeight:D});const L=await o.getDimensions(c.floating);return b!==L.width||j!==L.height?{reset:{rects:!0}}:{}}}};function Of(){return typeof window<"u"}function Bl(t){return DC(t)?(t.nodeName||"").toLowerCase():"#document"}function Lr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Vs(t){var e;return(e=(DC(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function DC(t){return Of()?t instanceof Node||t instanceof Lr(t).Node:!1}function xs(t){return Of()?t instanceof Element||t instanceof Lr(t).Element:!1}function Fs(t){return Of()?t instanceof HTMLElement||t instanceof Lr(t).HTMLElement:!1}function aw(t){return!Of()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Lr(t).ShadowRoot}const hF=new Set(["inline","contents"]);function yd(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=ys(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!hF.has(i)}const fF=new Set(["table","td","th"]);function pF(t){return fF.has(Bl(t))}const mF=[":popover-open",":modal"];function Df(t){return mF.some(e=>{try{return t.matches(e)}catch{return!1}})}const gF=["transform","translate","scale","rotate","perspective"],xF=["transform","translate","scale","rotate","perspective","filter"],yF=["paint","layout","strict","content"];function W0(t){const e=U0(),n=xs(t)?ys(t):t;return gF.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||xF.some(r=>(n.willChange||"").includes(r))||yF.some(r=>(n.contain||"").includes(r))}function vF(t){let e=ba(t);for(;Fs(e)&&!Il(e);){if(W0(e))return e;if(Df(e))return null;e=ba(e)}return null}function U0(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bF=new Set(["html","body","#document"]);function Il(t){return bF.has(Bl(t))}function ys(t){return Lr(t).getComputedStyle(t)}function Lf(t){return xs(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ba(t){if(Bl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||aw(t)&&t.host||Vs(t);return aw(e)?e.host:e}function LC(t){const e=ba(t);return Il(e)?t.ownerDocument?t.ownerDocument.body:t.body:Fs(e)&&yd(e)?e:LC(e)}function ld(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=LC(t),a=i===((r=t.ownerDocument)==null?void 0:r.body),o=Lr(i);if(a){const c=Nx(o);return e.concat(o,o.visualViewport||[],yd(i)?i:[],c&&n?ld(c):[])}return e.concat(i,ld(i,[],n))}function Nx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _C(t){const e=ys(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Fs(t),a=i?t.offsetWidth:n,o=i?t.offsetHeight:r,c=nf(n)!==a||nf(r)!==o;return c&&(n=a,r=o),{width:n,height:r,$:c}}function K0(t){return xs(t)?t:t.contextElement}function wl(t){const e=K0(t);if(!Fs(e))return Ls(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:a}=_C(e);let o=(a?nf(n.width):n.width)/r,c=(a?nf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const NF=Ls(0);function zC(t){const e=Lr(t);return!U0()||!e.visualViewport?NF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function wF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Lr(t)?!1:e}function wo(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),a=K0(t);let o=Ls(1);e&&(r?xs(r)&&(o=wl(r)):o=wl(t));const c=wF(a,n,r)?zC(a):Ls(0);let u=(i.left+c.x)/o.x,h=(i.top+c.y)/o.y,f=i.width/o.x,m=i.height/o.y;if(a){const g=Lr(a),y=r&&xs(r)?Lr(r):r;let b=g,j=Nx(b);for(;j&&r&&y!==b;){const w=wl(j),N=j.getBoundingClientRect(),C=ys(j),E=N.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,M=N.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;u*=w.x,h*=w.y,f*=w.x,m*=w.y,u+=E,h+=M,b=Lr(j),j=Nx(b)}}return sf({width:f,height:m,x:u,y:h})}function _f(t,e){const n=Lf(t).scrollLeft;return e?e.left+n:wo(Vs(t)).left+n}function $C(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-_f(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function jF(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const a=i==="fixed",o=Vs(r),c=e?Df(e.floating):!1;if(r===o||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=Ls(1);const f=Ls(0),m=Fs(r);if((m||!m&&!a)&&((Bl(r)!=="body"||yd(o))&&(u=Lf(r)),Fs(r))){const y=wo(r);h=wl(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const g=o&&!m&&!a?$C(o,u):Ls(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 kF(t){return Array.from(t.getClientRects())}function SF(t){const e=Vs(t),n=Lf(t),r=t.ownerDocument.body,i=Rr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),a=Rr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+_f(t);const c=-n.scrollTop;return ys(r).direction==="rtl"&&(o+=Rr(e.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:c}}const ow=25;function CF(t,e){const n=Lr(t),r=Vs(t),i=n.visualViewport;let a=r.clientWidth,o=r.clientHeight,c=0,u=0;if(i){a=i.width,o=i.height;const f=U0();(!f||f&&e==="fixed")&&(c=i.offsetLeft,u=i.offsetTop)}const h=_f(r);if(h<=0){const f=r.ownerDocument,m=f.body,g=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,b=Math.abs(r.clientWidth-m.clientWidth-y);b<=ow&&(a-=b)}else h<=ow&&(a+=h);return{width:a,height:o,x:c,y:u}}const EF=new Set(["absolute","fixed"]);function TF(t,e){const n=wo(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,a=Fs(t)?wl(t):Ls(1),o=t.clientWidth*a.x,c=t.clientHeight*a.y,u=i*a.x,h=r*a.y;return{width:o,height:c,x:u,y:h}}function lw(t,e,n){let r;if(e==="viewport")r=CF(t,n);else if(e==="document")r=SF(Vs(t));else if(xs(e))r=TF(e,n);else{const i=zC(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return sf(r)}function FC(t,e){const n=ba(t);return n===e||!xs(n)||Il(n)?!1:ys(n).position==="fixed"||FC(n,e)}function MF(t,e){const n=e.get(t);if(n)return n;let r=ld(t,[],!1).filter(c=>xs(c)&&Bl(c)!=="body"),i=null;const a=ys(t).position==="fixed";let o=a?ba(t):t;for(;xs(o)&&!Il(o);){const c=ys(o),u=W0(o);!u&&c.position==="fixed"&&(i=null),(a?!u&&!i:!u&&c.position==="static"&&!!i&&EF.has(i.position)||yd(o)&&!u&&FC(t,o))?r=r.filter(f=>f!==o):i=c,o=ba(o)}return e.set(t,r),r}function AF(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?Df(e)?[]:MF(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=lw(e,f,i);return h.top=Rr(m.top,h.top),h.right=va(m.right,h.right),h.bottom=va(m.bottom,h.bottom),h.left=Rr(m.left,h.left),h},lw(e,c,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function IF(t){const{width:e,height:n}=_C(t);return{width:e,height:n}}function RF(t,e,n){const r=Fs(e),i=Vs(e),a=n==="fixed",o=wo(t,!0,a,e);let c={scrollLeft:0,scrollTop:0};const u=Ls(0);function h(){u.x=_f(i)}if(r||!r&&!a)if((Bl(e)!=="body"||yd(i))&&(c=Lf(e)),r){const y=wo(e,!0,a,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else i&&h();a&&!r&&i&&h();const f=i&&!r&&!a?$C(i,c):Ls(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 fg(t){return ys(t).position==="static"}function cw(t,e){if(!Fs(t)||ys(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Vs(t)===n&&(n=n.ownerDocument.body),n}function BC(t,e){const n=Lr(t);if(Df(t))return n;if(!Fs(t)){let i=ba(t);for(;i&&!Il(i);){if(xs(i)&&!fg(i))return i;i=ba(i)}return n}let r=cw(t,e);for(;r&&pF(r)&&fg(r);)r=cw(r,e);return r&&Il(r)&&fg(r)&&!W0(r)?n:r||vF(t)||n}const PF=async function(t){const e=this.getOffsetParent||BC,n=this.getDimensions,r=await n(t.floating);return{reference:RF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function OF(t){return ys(t).direction==="rtl"}const DF={convertOffsetParentRelativeRectToViewportRelativeRect:jF,getDocumentElement:Vs,getClippingRect:AF,getOffsetParent:BC,getElementRects:PF,getClientRects:kF,getDimensions:IF,getScale:wl,isElement:xs,isRTL:OF};function VC(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function LF(t,e){let n=null,r;const i=Vs(t);function a(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function o(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const h=t.getBoundingClientRect(),{left:f,top:m,width:g,height:y}=h;if(c||e(),!g||!y)return;const b=Ku(m),j=Ku(i.clientWidth-(f+g)),w=Ku(i.clientHeight-(m+y)),N=Ku(f),E={rootMargin:-b+"px "+-j+"px "+-w+"px "+-N+"px",threshold:Rr(0,va(1,u))||1};let M=!0;function I(O){const D=O[0].intersectionRatio;if(D!==u){if(!M)return o();D?o(!1,D):r=setTimeout(()=>{o(!1,1e-7)},1e3)}D===1&&!VC(h,t.getBoundingClientRect())&&o(),M=!1}try{n=new IntersectionObserver(I,{...E,root:i.ownerDocument})}catch{n=new IntersectionObserver(I,E)}n.observe(t)}return o(!0),a}function _F(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,h=K0(t),f=i||a?[...h?ld(h):[],...ld(e)]:[];f.forEach(N=>{i&&N.addEventListener("scroll",n,{passive:!0}),a&&N.addEventListener("resize",n)});const m=h&&c?LF(h,n):null;let g=-1,y=null;o&&(y=new ResizeObserver(N=>{let[C]=N;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 b,j=u?wo(t):null;u&&w();function w(){const N=wo(t);j&&!VC(j,N)&&n(),j=N,b=requestAnimationFrame(w)}return n(),()=>{var N;f.forEach(C=>{i&&C.removeEventListener("scroll",n),a&&C.removeEventListener("resize",n)}),m==null||m(),(N=y)==null||N.disconnect(),y=null,u&&cancelAnimationFrame(b)}}const zF=lF,$F=cF,FF=iF,BF=uF,VF=aF,dw=sF,HF=dF,WF=(t,e,n)=>{const r=new Map,i={platform:DF,...n},a={...i.platform,_c:r};return rF(t,e,{...i,platform:a})};var UF=typeof document<"u",KF=function(){},rh=UF?v.useLayoutEffect:KF;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,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!af(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const a=i[r];if(!(a==="_owner"&&t.$$typeof)&&!af(t[a],e[a]))return!1}return!0}return t!==t&&e!==e}function HC(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function uw(t,e){const n=HC(t);return Math.round(e*n)/n}function pg(t){const e=v.useRef(t);return rh(()=>{e.current=t}),e}function qF(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=v.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=v.useState(r);af(g,r)||y(r);const[b,j]=v.useState(null),[w,N]=v.useState(null),C=v.useCallback(z=>{z!==O.current&&(O.current=z,j(z))},[]),E=v.useCallback(z=>{z!==D.current&&(D.current=z,N(z))},[]),M=a||b,I=o||w,O=v.useRef(null),D=v.useRef(null),P=v.useRef(f),L=u!=null,_=pg(u),X=pg(i),ne=pg(h),J=v.useCallback(()=>{if(!O.current||!D.current)return;const z={placement:e,strategy:n,middleware:g};X.current&&(z.platform=X.current),WF(O.current,D.current,z).then(ae=>{const G={...ae,isPositioned:ne.current!==!1};U.current&&!af(P.current,G)&&(P.current=G,dd.flushSync(()=>{m(G)}))})},[g,e,n,X,ne]);rh(()=>{h===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,m(z=>({...z,isPositioned:!1})))},[h]);const U=v.useRef(!1);rh(()=>(U.current=!0,()=>{U.current=!1}),[]),rh(()=>{if(M&&(O.current=M),I&&(D.current=I),M&&I){if(_.current)return _.current(M,I,J);J()}},[M,I,J,_,L]);const R=v.useMemo(()=>({reference:O,floating:D,setReference:C,setFloating:E}),[C,E]),F=v.useMemo(()=>({reference:M,floating:I}),[M,I]),re=v.useMemo(()=>{const z={position:n,left:0,top:0};if(!F.floating)return z;const ae=uw(F.floating,f.x),G=uw(F.floating,f.y);return c?{...z,transform:"translate("+ae+"px, "+G+"px)",...HC(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ae,top:G}},[n,c,F.floating,f.x,f.y]);return v.useMemo(()=>({...f,update:J,refs:R,elements:F,floatingStyles:re}),[f,J,R,F,re])}const GF=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?dw({element:r.current,padding:i}).fn(n):{}:r?dw({element:r,padding:i}).fn(n):{}}}},JF=(t,e)=>({...zF(t),options:[t,e]}),YF=(t,e)=>({...$F(t),options:[t,e]}),QF=(t,e)=>({...HF(t),options:[t,e]}),XF=(t,e)=>({...FF(t),options:[t,e]}),ZF=(t,e)=>({...BF(t),options:[t,e]}),eB=(t,e)=>({...VF(t),options:[t,e]}),tB=(t,e)=>({...GF(t),options:[t,e]});var nB="Arrow",WC=v.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...a}=t;return s.jsx(dt.svg,{...a,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});WC.displayName=nB;var rB=WC,q0="Popper",[UC,KC]=ka(q0),[sB,qC]=UC(q0),GC=t=>{const{__scopePopper:e,children:n}=t,[r,i]=v.useState(null);return s.jsx(sB,{scope:e,anchor:r,onAnchorChange:i,children:n})};GC.displayName=q0;var JC="PopperAnchor",YC=v.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,a=qC(JC,n),o=v.useRef(null),c=St(e,o),u=v.useRef(null);return v.useEffect(()=>{const h=u.current;u.current=(r==null?void 0:r.current)||o.current,h!==u.current&&a.onAnchorChange(u.current)}),r?null:s.jsx(dt.div,{...i,ref:c})});YC.displayName=JC;var G0="PopperContent",[iB,aB]=UC(G0),QC=v.forwardRef((t,e)=>{var de,he,Ne,Te,Ve,He;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:a="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:b,...j}=t,w=qC(G0,n),[N,C]=v.useState(null),E=St(e,gt=>C(gt)),[M,I]=v.useState(null),O=Gx(M),D=(O==null?void 0:O.width)??0,P=(O==null?void 0:O.height)??0,L=r+(a!=="center"?"-"+a:""),_=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},X=Array.isArray(h)?h:[h],ne=X.length>0,J={padding:_,boundary:X.filter(lB),altBoundary:ne},{refs:U,floatingStyles:R,placement:F,isPositioned:re,middlewareData:z}=qF({strategy:"fixed",placement:L,whileElementsMounted:(...gt)=>_F(...gt,{animationFrame:y==="always"}),elements:{reference:w.anchor},middleware:[JF({mainAxis:i+P,alignmentAxis:o}),u&&YF({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?QF():void 0,...J}),u&&XF({...J}),ZF({...J,apply:({elements:gt,rects:Pt,availableWidth:wn,availableHeight:ht})=>{const{width:At,height:te}=Pt.reference,Pe=gt.floating.style;Pe.setProperty("--radix-popper-available-width",`${wn}px`),Pe.setProperty("--radix-popper-available-height",`${ht}px`),Pe.setProperty("--radix-popper-anchor-width",`${At}px`),Pe.setProperty("--radix-popper-anchor-height",`${te}px`)}}),M&&tB({element:M,padding:c}),cB({arrowWidth:D,arrowHeight:P}),g&&eB({strategy:"referenceHidden",...J})]}),[ae,G]=e4(F),$=ga(b);Xn(()=>{re&&($==null||$())},[re,$]);const H=(de=z.arrow)==null?void 0:de.x,ce=(he=z.arrow)==null?void 0:he.y,W=((Ne=z.arrow)==null?void 0:Ne.centerOffset)!==0,[fe,Q]=v.useState();return Xn(()=>{N&&Q(window.getComputedStyle(N).zIndex)},[N]),s.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...R,transform:re?R.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:fe,"--radix-popper-transform-origin":[(Te=z.transformOrigin)==null?void 0:Te.x,(Ve=z.transformOrigin)==null?void 0:Ve.y].join(" "),...((He=z.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(iB,{scope:n,placedSide:ae,onArrowChange:I,arrowX:H,arrowY:ce,shouldHideArrow:W,children:s.jsx(dt.div,{"data-side":ae,"data-align":G,...j,ref:E,style:{...j.style,animation:re?void 0:"none"}})})})});QC.displayName=G0;var XC="PopperArrow",oB={top:"bottom",right:"left",bottom:"top",left:"right"},ZC=v.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,a=aB(XC,r),o=oB[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(rB,{...i,ref:n,style:{...i.style,display:"block"}})})});ZC.displayName=XC;function lB(t){return t!==null}var cB=t=>({name:"transformOrigin",options:t,fn(e){var w,N,C;const{placement:n,rects:r,middlewareData:i}=e,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=e4(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((N=i.arrow)==null?void 0:N.x)??0)+c/2,y=(((C=i.arrow)==null?void 0:C.y)??0)+u/2;let b="",j="";return h==="bottom"?(b=o?m:`${g}px`,j=`${-u}px`):h==="top"?(b=o?m:`${g}px`,j=`${r.floating.height+u}px`):h==="right"?(b=`${-u}px`,j=o?m:`${y}px`):h==="left"&&(b=`${r.floating.width+u}px`,j=o?m:`${y}px`),{data:{x:b,y:j}}}});function e4(t){const[e,n="center"]=t.split("-");return[e,n]}var dB=GC,uB=YC,hB=QC,fB=ZC,t4=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"}),pB="VisuallyHidden",mB=v.forwardRef((t,e)=>s.jsx(dt.span,{...t,ref:e,style:{...t4,...t.style}}));mB.displayName=pB;var gB=[" ","Enter","ArrowUp","ArrowDown"],xB=[" ","Enter"],jo="Select",[zf,$f,yB]=Ux(jo),[Vl]=ka(jo,[yB,KC]),Ff=KC(),[vB,Ta]=Vl(jo),[bB,NB]=Vl(jo),n4=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:b}=t,j=Ff(e),[w,N]=v.useState(null),[C,E]=v.useState(null),[M,I]=v.useState(!1),O=pf(h),[D,P]=fo({prop:r,defaultProp:i??!1,onChange:a,caller:jo}),[L,_]=fo({prop:o,defaultProp:c,onChange:u,caller:jo}),X=v.useRef(null),ne=w?b||!!w.closest("form"):!0,[J,U]=v.useState(new Set),R=Array.from(J).map(F=>F.props.value).join(";");return s.jsx(dB,{...j,children:s.jsxs(vB,{required:y,scope:e,trigger:w,onTriggerChange:N,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:M,onValueNodeHasChildrenChange:I,contentId:ua(),value:L,onValueChange:_,open:D,onOpenChange:P,dir:O,triggerPointerDownPosRef:X,disabled:g,children:[s.jsx(zf.Provider,{scope:e,children:s.jsx(bB,{scope:t.__scopeSelect,onNativeOptionAdd:v.useCallback(F=>{U(re=>new Set(re).add(F))},[]),onNativeOptionRemove:v.useCallback(F=>{U(re=>{const z=new Set(re);return z.delete(F),z})},[]),children:n})}),ne?s.jsxs(k4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:L,onChange:F=>_(F.target.value),disabled:g,form:b,children:[L===void 0?s.jsx("option",{value:""}):null,Array.from(J)]},R):null]})})};n4.displayName=jo;var r4="SelectTrigger",s4=v.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...i}=t,a=Ff(n),o=Ta(r4,n),c=o.disabled||r,u=St(e,o.onTriggerChange),h=$f(n),f=v.useRef("touch"),[m,g,y]=C4(j=>{const w=h().filter(E=>!E.disabled),N=w.find(E=>E.value===o.value),C=E4(w,j,N);C!==void 0&&o.onValueChange(C.value)}),b=j=>{c||(o.onOpenChange(!0),y()),j&&(o.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return s.jsx(uB,{asChild:!0,...a,children:s.jsx(dt.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":S4(o.value)?"":void 0,...i,ref:u,onClick:at(i.onClick,j=>{j.currentTarget.focus(),f.current!=="mouse"&&b(j)}),onPointerDown:at(i.onPointerDown,j=>{f.current=j.pointerType;const w=j.target;w.hasPointerCapture(j.pointerId)&&w.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(b(j),j.preventDefault())}),onKeyDown:at(i.onKeyDown,j=>{const w=m.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(w&&j.key===" ")&&gB.includes(j.key)&&(b(),j.preventDefault())})})})});s4.displayName=r4;var i4="SelectValue",a4=v.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,children:a,placeholder:o="",...c}=t,u=Ta(i4,n),{onValueNodeHasChildrenChange:h}=u,f=a!==void 0,m=St(e,u.onValueNodeChange);return Xn(()=>{h(f)},[h,f]),s.jsx(dt.span,{...c,ref:m,style:{pointerEvents:"none"},children:S4(u.value)?s.jsx(s.Fragment,{children:o}):a})});a4.displayName=i4;var wB="SelectIcon",o4=v.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...i}=t;return s.jsx(dt.span,{"aria-hidden":!0,...i,ref:e,children:r||"▼"})});o4.displayName=wB;var jB="SelectPortal",l4=t=>s.jsx($x,{asChild:!0,...t});l4.displayName=jB;var ko="SelectContent",c4=v.forwardRef((t,e)=>{const n=Ta(ko,t.__scopeSelect),[r,i]=v.useState();if(Xn(()=>{i(new DocumentFragment)},[]),!n.open){const a=r;return a?dd.createPortal(s.jsx(d4,{scope:t.__scopeSelect,children:s.jsx(zf.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),a):null}return s.jsx(u4,{...t,ref:e})});c4.displayName=ko;var us=10,[d4,Ma]=Vl(ko),kB="SelectContentImpl",SB=Jc("SelectContent.RemoveScroll"),u4=v.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:b,hideWhenDetached:j,avoidCollisions:w,...N}=t,C=Ta(ko,n),[E,M]=v.useState(null),[I,O]=v.useState(null),D=St(e,de=>M(de)),[P,L]=v.useState(null),[_,X]=v.useState(null),ne=$f(n),[J,U]=v.useState(!1),R=v.useRef(!1);v.useEffect(()=>{if(E)return Sj(E)},[E]),gj();const F=v.useCallback(de=>{const[he,...Ne]=ne().map(He=>He.ref.current),[Te]=Ne.slice(-1),Ve=document.activeElement;for(const He of de)if(He===Ve||(He==null||He.scrollIntoView({block:"nearest"}),He===he&&I&&(I.scrollTop=0),He===Te&&I&&(I.scrollTop=I.scrollHeight),He==null||He.focus(),document.activeElement!==Ve))return},[ne,I]),re=v.useCallback(()=>F([P,E]),[F,P,E]);v.useEffect(()=>{J&&re()},[J,re]);const{onOpenChange:z,triggerPointerDownPosRef:ae}=C;v.useEffect(()=>{if(E){let de={x:0,y:0};const he=Te=>{var Ve,He;de={x:Math.abs(Math.round(Te.pageX)-(((Ve=ae.current)==null?void 0:Ve.x)??0)),y:Math.abs(Math.round(Te.pageY)-(((He=ae.current)==null?void 0:He.y)??0))}},Ne=Te=>{de.x<=10&&de.y<=10?Te.preventDefault():E.contains(Te.target)||z(!1),document.removeEventListener("pointermove",he),ae.current=null};return ae.current!==null&&(document.addEventListener("pointermove",he),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",he),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[E,z,ae]),v.useEffect(()=>{const de=()=>z(!1);return window.addEventListener("blur",de),window.addEventListener("resize",de),()=>{window.removeEventListener("blur",de),window.removeEventListener("resize",de)}},[z]);const[G,$]=C4(de=>{const he=ne().filter(Ve=>!Ve.disabled),Ne=he.find(Ve=>Ve.ref.current===document.activeElement),Te=E4(he,de,Ne);Te&&setTimeout(()=>Te.ref.current.focus())}),H=v.useCallback((de,he,Ne)=>{const Te=!R.current&&!Ne;(C.value!==void 0&&C.value===he||Te)&&(L(de),Te&&(R.current=!0))},[C.value]),ce=v.useCallback(()=>E==null?void 0:E.focus(),[E]),W=v.useCallback((de,he,Ne)=>{const Te=!R.current&&!Ne;(C.value!==void 0&&C.value===he||Te)&&X(de)},[C.value]),fe=r==="popper"?wx:h4,Q=fe===wx?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:b,hideWhenDetached:j,avoidCollisions:w}:{};return s.jsx(d4,{scope:n,content:E,viewport:I,onViewportChange:O,itemRefCallback:H,selectedItem:P,onItemLeave:ce,itemTextRefCallback:W,focusSelectedItem:re,selectedItemText:_,position:r,isPositioned:J,searchRef:G,children:s.jsx(Fx,{as:SB,allowPinchZoom:!0,children:s.jsx(zx,{asChild:!0,trapped:C.open,onMountAutoFocus:de=>{de.preventDefault()},onUnmountAutoFocus:at(i,de=>{var he;(he=C.trigger)==null||he.focus({preventScroll:!0}),de.preventDefault()}),children:s.jsx(_x,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:de=>de.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:s.jsx(fe,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:de=>de.preventDefault(),...N,...Q,onPlaced:()=>U(!0),ref:D,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:at(N.onKeyDown,de=>{const he=de.ctrlKey||de.altKey||de.metaKey;if(de.key==="Tab"&&de.preventDefault(),!he&&de.key.length===1&&$(de.key),["ArrowUp","ArrowDown","Home","End"].includes(de.key)){let Te=ne().filter(Ve=>!Ve.disabled).map(Ve=>Ve.ref.current);if(["ArrowUp","End"].includes(de.key)&&(Te=Te.slice().reverse()),["ArrowUp","ArrowDown"].includes(de.key)){const Ve=de.target,He=Te.indexOf(Ve);Te=Te.slice(He+1)}setTimeout(()=>F(Te)),de.preventDefault()}})})})})})})});u4.displayName=kB;var CB="SelectItemAlignedPosition",h4=v.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...i}=t,a=Ta(ko,n),o=Ma(ko,n),[c,u]=v.useState(null),[h,f]=v.useState(null),m=St(e,D=>f(D)),g=$f(n),y=v.useRef(!1),b=v.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:N,focusSelectedItem:C}=o,E=v.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&h&&j&&w&&N){const D=a.trigger.getBoundingClientRect(),P=h.getBoundingClientRect(),L=a.valueNode.getBoundingClientRect(),_=N.getBoundingClientRect();if(a.dir!=="rtl"){const Ve=_.left-P.left,He=L.left-Ve,gt=D.left-He,Pt=D.width+gt,wn=Math.max(Pt,P.width),ht=window.innerWidth-us,At=hh(He,[us,Math.max(us,ht-wn)]);c.style.minWidth=Pt+"px",c.style.left=At+"px"}else{const Ve=P.right-_.right,He=window.innerWidth-L.right-Ve,gt=window.innerWidth-D.right-He,Pt=D.width+gt,wn=Math.max(Pt,P.width),ht=window.innerWidth-us,At=hh(He,[us,Math.max(us,ht-wn)]);c.style.minWidth=Pt+"px",c.style.right=At+"px"}const X=g(),ne=window.innerHeight-us*2,J=j.scrollHeight,U=window.getComputedStyle(h),R=parseInt(U.borderTopWidth,10),F=parseInt(U.paddingTop,10),re=parseInt(U.borderBottomWidth,10),z=parseInt(U.paddingBottom,10),ae=R+F+J+z+re,G=Math.min(w.offsetHeight*5,ae),$=window.getComputedStyle(j),H=parseInt($.paddingTop,10),ce=parseInt($.paddingBottom,10),W=D.top+D.height/2-us,fe=ne-W,Q=w.offsetHeight/2,de=w.offsetTop+Q,he=R+F+de,Ne=ae-he;if(he<=W){const Ve=X.length>0&&w===X[X.length-1].ref.current;c.style.bottom="0px";const He=h.clientHeight-j.offsetTop-j.offsetHeight,gt=Math.max(fe,Q+(Ve?ce:0)+He+re),Pt=he+gt;c.style.height=Pt+"px"}else{const Ve=X.length>0&&w===X[0].ref.current;c.style.top="0px";const gt=Math.max(W,R+j.offsetTop+(Ve?H:0)+Q)+Ne;c.style.height=gt+"px",j.scrollTop=he-W+j.offsetTop}c.style.margin=`${us}px 0`,c.style.minHeight=G+"px",c.style.maxHeight=ne+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[g,a.trigger,a.valueNode,c,h,j,w,N,a.dir,r]);Xn(()=>E(),[E]);const[M,I]=v.useState();Xn(()=>{h&&I(window.getComputedStyle(h).zIndex)},[h]);const O=v.useCallback(D=>{D&&b.current===!0&&(E(),C==null||C(),b.current=!1)},[E,C]);return s.jsx(TB,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:O,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:s.jsx(dt.div,{...i,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});h4.displayName=CB;var EB="SelectPopperPosition",wx=v.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=us,...a}=t,o=Ff(n);return s.jsx(hB,{...o,...a,ref:e,align:r,collisionPadding:i,style:{boxSizing:"border-box",...a.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)"}})});wx.displayName=EB;var[TB,J0]=Vl(ko,{}),jx="SelectViewport",f4=v.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...i}=t,a=Ma(jx,n),o=J0(jx,n),c=St(e,a.onViewportChange),u=v.useRef(0);return s.jsxs(s.Fragment,{children:[s.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:r}),s.jsx(zf.Slot,{scope:n,children:s.jsx(dt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:at(i.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 b=window.innerHeight-us*2,j=parseFloat(m.style.minHeight),w=parseFloat(m.style.height),N=Math.max(j,w);if(N0?M:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});f4.displayName=jx;var p4="SelectGroup",[MB,AB]=Vl(p4),IB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=ua();return s.jsx(MB,{scope:n,id:i,children:s.jsx(dt.div,{role:"group","aria-labelledby":i,...r,ref:e})})});IB.displayName=p4;var m4="SelectLabel",RB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=AB(m4,n);return s.jsx(dt.div,{id:i.id,...r,ref:e})});RB.displayName=m4;var of="SelectItem",[PB,g4]=Vl(of),x4=v.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=t,c=Ta(of,n),u=Ma(of,n),h=c.value===r,[f,m]=v.useState(a??""),[g,y]=v.useState(!1),b=St(e,C=>{var E;return(E=u.itemRefCallback)==null?void 0:E.call(u,C,r,i)}),j=ua(),w=v.useRef("touch"),N=()=>{i||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")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 s.jsx(PB,{scope:n,value:r,disabled:i,textId:j,isSelected:h,onItemTextChange:v.useCallback(C=>{m(E=>E||((C==null?void 0:C.textContent)??"").trim())},[]),children:s.jsx(zf.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:s.jsx(dt.div,{role:"option","aria-labelledby":j,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:b,onFocus:at(o.onFocus,()=>y(!0)),onBlur:at(o.onBlur,()=>y(!1)),onClick:at(o.onClick,()=>{w.current!=="mouse"&&N()}),onPointerUp:at(o.onPointerUp,()=>{w.current==="mouse"&&N()}),onPointerDown:at(o.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:at(o.onPointerMove,C=>{var E;w.current=C.pointerType,i?(E=u.onItemLeave)==null||E.call(u):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(o.onPointerLeave,C=>{var E;C.currentTarget===document.activeElement&&((E=u.onItemLeave)==null||E.call(u))}),onKeyDown:at(o.onKeyDown,C=>{var M;((M=u.searchRef)==null?void 0:M.current)!==""&&C.key===" "||(xB.includes(C.key)&&N(),C.key===" "&&C.preventDefault())})})})})});x4.displayName=of;var Rc="SelectItemText",y4=v.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,...a}=t,o=Ta(Rc,n),c=Ma(Rc,n),u=g4(Rc,n),h=NB(Rc,n),[f,m]=v.useState(null),g=St(e,N=>m(N),u.onItemTextChange,N=>{var C;return(C=c.itemTextRefCallback)==null?void 0:C.call(c,N,u.value,u.disabled)}),y=f==null?void 0:f.textContent,b=v.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=h;return Xn(()=>(j(b),()=>w(b)),[j,w,b]),s.jsxs(s.Fragment,{children:[s.jsx(dt.span,{id:u.textId,...a,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?dd.createPortal(a.children,o.valueNode):null]})});y4.displayName=Rc;var v4="SelectItemIndicator",b4=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return g4(v4,n).isSelected?s.jsx(dt.span,{"aria-hidden":!0,...r,ref:e}):null});b4.displayName=v4;var kx="SelectScrollUpButton",N4=v.forwardRef((t,e)=>{const n=Ma(kx,t.__scopeSelect),r=J0(kx,t.__scopeSelect),[i,a]=v.useState(!1),o=St(e,r.onScrollButtonChange);return Xn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollTop>0;a(h)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),i?s.jsx(j4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});N4.displayName=kx;var Sx="SelectScrollDownButton",w4=v.forwardRef((t,e)=>{const n=Ma(Sx,t.__scopeSelect),r=J0(Sx,t.__scopeSelect),[i,a]=v.useState(!1),o=St(e,r.onScrollButtonChange);return Xn(()=>{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]),i?s.jsx(j4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});w4.displayName=Sx;var j4=v.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=t,a=Ma("SelectScrollButton",n),o=v.useRef(null),c=$f(n),u=v.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return v.useEffect(()=>()=>u(),[u]),Xn(()=>{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]),s.jsx(dt.div,{"aria-hidden":!0,...i,ref:e,style:{flexShrink:0,...i.style},onPointerDown:at(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:at(i.onPointerMove,()=>{var h;(h=a.onItemLeave)==null||h.call(a),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:at(i.onPointerLeave,()=>{u()})})}),OB="SelectSeparator",DB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(dt.div,{"aria-hidden":!0,...r,ref:e})});DB.displayName=OB;var Cx="SelectArrow",LB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=Ff(n),a=Ta(Cx,n),o=Ma(Cx,n);return a.open&&o.position==="popper"?s.jsx(fB,{...i,...r,ref:e}):null});LB.displayName=Cx;var _B="SelectBubbleInput",k4=v.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const i=v.useRef(null),a=St(r,i),o=qx(e);return v.useEffect(()=>{const c=i.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]),s.jsx(dt.select,{...n,style:{...t4,...n.style},ref:a,defaultValue:e})});k4.displayName=_B;function S4(t){return t===""||t===void 0}function C4(t){const e=ga(t),n=v.useRef(""),r=v.useRef(0),i=v.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),a=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function E4(t,e,n){const i=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,a=n?t.indexOf(n):-1;let o=zB(t,Math.max(a,0));i.length===1&&(o=o.filter(h=>h!==n));const u=o.find(h=>h.textValue.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function zB(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var $B=n4,T4=s4,FB=a4,BB=o4,VB=l4,M4=c4,HB=f4,A4=x4,WB=y4,UB=b4,KB=N4,qB=w4;const ul=$B,hl=FB,Xa=v.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(T4,{ref:r,className:Ct("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,s.jsx(BB,{asChild:!0,children:s.jsx(Gc,{className:"h-4 w-4 opacity-50"})})]}));Xa.displayName=T4.displayName;const Za=v.forwardRef(({className:t,children:e,position:n="popper",...r},i)=>s.jsx(VB,{children:s.jsxs(M4,{ref:i,className:Ct("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,...r,children:[s.jsx(KB,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Fw,{className:"h-4 w-4"})}),s.jsx(HB,{className:"p-1",children:e}),s.jsx(qB,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Gc,{className:"h-4 w-4"})})]})}));Za.displayName=M4.displayName;const Ir=v.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(A4,{ref:r,className:Ct("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(UB,{children:s.jsx(df,{className:"h-4 w-4"})})}),s.jsx(WB,{children:e})]}));Ir.displayName=A4.displayName;function GB(){const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState(!1),[o,c]=v.useState(null),[u,h]=v.useState({name:"",appId:"",path:"",sort:0}),[f,m]=v.useState(!1);async function g(){r(!0);try{const N=await Le("/api/admin/linked-miniprograms");if(N!=null&&N.success&&Array.isArray(N.data)){const C=[...N.data].sort((E,M)=>(E.sort??0)-(M.sort??0));e(C)}}catch(N){console.error("Load linked miniprograms error:",N),ie.error("加载失败")}finally{r(!1)}}v.useEffect(()=>{g()},[]);function y(){c(null),h({name:"",appId:"",path:"",sort:t.length}),a(!0)}function b(N){c(N),h({name:N.name,appId:N.appId,path:N.path??"",sort:N.sort??0}),a(!0)}async function j(){const N=u.name.trim(),C=u.appId.trim();if(!N||!C){ie.error("请填写小程序名称和 AppID");return}m(!0);try{if(o){const E=await Mt("/api/admin/linked-miniprograms",{key:o.key,name:N,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(ie.success("已更新"),a(!1),g()):ie.error((E==null?void 0:E.error)??"更新失败")}else{const E=await Nt("/api/admin/linked-miniprograms",{name:N,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(ie.success("已添加"),a(!1),g()):ie.error((E==null?void 0:E.error)??"添加失败")}}catch{ie.error("操作失败")}finally{m(!1)}}async function w(N){if(confirm(`确定要删除「${N.name}」吗?`))try{const C=await Ps(`/api/admin/linked-miniprograms/${N.key}`);C!=null&&C.success?(ie.success("已删除"),g()):ie.error((C==null?void 0:C.error)??"删除失败")}catch{ie.error("删除失败")}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5 text-[#38bdac]"}),"关联小程序管理"]}),s.jsx($t,{className:"text-gray-400",children:"添加后生成 32 位密钥,链接标签选择小程序时存密钥;小程序端点击 #标签 时用密钥查 appId 再跳转。需在 app.json 的 navigateToMiniProgramAppIdList 中配置目标 AppID。"})]}),s.jsxs(Ae,{children:[s.jsx("div",{className:"flex justify-end mb-4",children:s.jsxs(ee,{onClick:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加关联小程序"]})}),n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"名称"}),s.jsx(je,{className:"text-gray-400",children:"密钥"}),s.jsx(je,{className:"text-gray-400",children:"AppID"}),s.jsx(je,{className:"text-gray-400",children:"路径"}),s.jsx(je,{className:"text-gray-400 w-24",children:"排序"}),s.jsx(je,{className:"text-gray-400 w-32",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(N=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-white",children:N.name}),s.jsx(xe,{className:"text-gray-300 font-mono text-xs",children:N.key}),s.jsx(xe,{className:"text-gray-300 font-mono text-sm",children:N.appId}),s.jsx(xe,{className:"text-gray-400 text-sm",children:N.path||"—"}),s.jsx(xe,{className:"text-gray-300",children:N.sort??0}),s.jsx(xe,{children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/20",onClick:()=>b(N),children:s.jsx(qw,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:bg-red-500/20",onClick:()=>w(N),children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},N.key)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无关联小程序,点击「添加关联小程序」开始配置"})})]})]})]})]}),s.jsx(Kt,{open:i,onOpenChange:a,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(qt,{className:"gap-1",children:[s.jsx(Gt,{className:"text-base",children:o?"编辑关联小程序":"添加关联小程序"}),s.jsx(Wx,{className:"text-gray-400 text-xs",children:"填写目标小程序的名称和 AppID,路径可选(为空则打开首页)"})]}),s.jsxs("div",{className:"space-y-3 py-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"小程序名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:Soul 创业派对",value:u.name,onChange:N=>h(C=>({...C,name:N.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono h-8 text-sm",placeholder:"例如:wxb8bbb2b10dec74aa",value:u.appId,onChange:N=>h(C=>({...C,appId:N.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"路径(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:pages/index/index",value:u.path,onChange:N=>h(C=>({...C,path:N.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"排序"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm w-20",value:u.sort,onChange:N=>h(C=>({...C,sort:parseInt(N.target.value,10)||0}))})]})]}),s.jsxs(hn,{className:"gap-2 pt-1",children:[s.jsx(ee,{variant:"outline",onClick:()=>a(!1),className:"border-gray-600",children:"取消"}),s.jsx(ee,{onClick:j,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:f?"保存中...":"保存"})]})]})})]})}const JB=["一","二","三","四","五","六","七","八","九","十"];function mg(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 YB({parts:t,expandedParts:e,onTogglePart:n,onReorder:r,onReadSection:i,onDeleteSection:a,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:b,pinnedSectionIds:j=[]}){const[w,N]=v.useState(null),[C,E]=v.useState(null),M=(_,X)=>(w==null?void 0:w.type)===_&&(w==null?void 0:w.id)===X,I=(_,X)=>(C==null?void 0:C.type)===_&&(C==null?void 0:C.id)===X,O=v.useCallback(()=>{const _=[];for(const X of t)for(const ne of X.chapters)for(const J of ne.sections)_.push({id:J.id,partId:X.id,partTitle:X.title,chapterId:ne.id,chapterTitle:ne.title});return _},[t]),D=v.useCallback(async(_,X,ne,J)=>{var z;_.preventDefault(),_.stopPropagation();const U=_.dataTransfer.getData("text/plain"),R=mg(U);if(!R||R.type===X&&R.id===ne)return;const F=O(),re=new Map(F.map(ae=>[ae.id,ae]));if(R.type==="part"&&X==="part"){const ae=t.map(W=>W.id),G=ae.indexOf(R.id),$=ae.indexOf(ne);if(G===-1||$===-1)return;const H=[...ae];H.splice(G,1),H.splice(G<$?$-1:$,0,R.id);const ce=[];for(const W of H){const fe=t.find(Q=>Q.id===W);if(fe)for(const Q of fe.chapters)for(const de of Q.sections){const he=re.get(de.id);he&&ce.push(he)}}await r(ce);return}if(R.type==="chapter"&&(X==="chapter"||X==="section"||X==="part")){const ae=t.find(he=>he.chapters.some(Ne=>Ne.id===R.id)),G=ae==null?void 0:ae.chapters.find(he=>he.id===R.id);if(!ae||!G)return;let $,H,ce=null;if(X==="section"){const he=re.get(ne);if(!he)return;$=he.partId,H=he.partTitle,ce=ne}else if(X==="chapter"){const he=t.find(Ve=>Ve.chapters.some(He=>He.id===ne)),Ne=he==null?void 0:he.chapters.find(Ve=>Ve.id===ne);if(!he||!Ne)return;$=he.id,H=he.title;const Te=F.filter(Ve=>Ve.chapterId===ne).pop();ce=(Te==null?void 0:Te.id)??null}else{const he=t.find(Te=>Te.id===ne);if(!he||!he.chapters[0])return;$=he.id,H=he.title;const Ne=F.filter(Te=>Te.partId===he.id&&Te.chapterId===he.chapters[0].id);ce=((z=Ne[Ne.length-1])==null?void 0:z.id)??null}const W=G.sections.map(he=>he.id),fe=F.filter(he=>!W.includes(he.id));let Q=fe.length;if(ce){const he=fe.findIndex(Ne=>Ne.id===ce);he>=0&&(Q=he+1)}const de=W.map(he=>({...re.get(he),partId:$,partTitle:H,chapterId:G.id,chapterTitle:G.title}));await r([...fe.slice(0,Q),...de,...fe.slice(Q)]);return}if(R.type==="section"&&(X==="section"||X==="chapter"||X==="part")){if(!J)return;const{partId:ae,partTitle:G,chapterId:$,chapterTitle:H}=J;let ce;if(X==="section")ce=F.findIndex(Ne=>Ne.id===ne);else if(X==="chapter"){const Ne=F.filter(Te=>Te.chapterId===ne).pop();ce=Ne?F.findIndex(Te=>Te.id===Ne.id)+1:F.length}else{const Ne=t.find(He=>He.id===ne);if(!(Ne!=null&&Ne.chapters[0]))return;const Te=F.filter(He=>He.partId===Ne.id&&He.chapterId===Ne.chapters[0].id),Ve=Te[Te.length-1];ce=Ve?F.findIndex(He=>He.id===Ve.id)+1:0}const W=F.findIndex(Ne=>Ne.id===R.id);if(W===-1)return;const fe=F.filter(Ne=>Ne.id!==R.id),Q=W({onDragEnter:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",E({type:_,id:X})},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",E({type:_,id:X})},onDragLeave:()=>E(null),onDrop:J=>{E(null);const U=mg(J.dataTransfer.getData("text/plain"));if(U&&!(_==="section"&&U.type==="section"&&U.id===X))if(_==="part")if(U.type==="part")D(J,"part",X);else{const R=t.find(re=>re.id===X);(R==null?void 0:R.chapters[0])&&ne&&D(J,"part",X,ne)}else _==="chapter"&&ne?(U.type==="section"||U.type==="chapter")&&D(J,"chapter",X,ne):_==="section"&&ne&&D(J,"section",X,ne)}}),L=_=>JB[_]??String(_+1);return s.jsx("div",{className:"space-y-3",children:t.map((_,X)=>{var G,$,H,ce;const ne=_.title==="序言"||_.title.includes("序言"),J=_.title==="尾声"||_.title.includes("尾声"),U=_.title==="附录"||_.title.includes("附录"),R=I("part",_.id),F=e.includes(_.id),re=_.chapters.length,z=_.chapters.reduce((W,fe)=>W+fe.sections.length,0);if(ne&&_.chapters.length===1&&_.chapters[0].sections.length===1){const W=_.chapters[0].sections[0],fe=I("section",W.id),Q={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+W.id),de.dataTransfer.effectAllowed="move",N({type:"section",id:W.id})},onDragEnd:()=>{N(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] ${fe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",W.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",W.id,Q),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(W.id),onChange:()=>y(W.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx(ps,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",W.title]}),j.includes(W.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:de=>de.stopPropagation(),onClick:de=>de.stopPropagation(),children:[W.price===0||W.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",W.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",W.clickCount??0," · 付款 ",W.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(W.hotScore??0).toFixed(1)," · 第",W.hotRank&&W.hotRank>0?W.hotRank:"-","名"]}),b&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>b(W),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(W),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(W),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}if(_.title==="2026每日派对干货"||_.title.includes("2026每日派对干货")){const W=I("part",_.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${W?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...P("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((G=_.chapters[0])==null?void 0:G.id)??"",chapterTitle:(($=_.chapters[0])==null?void 0:$.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:fe=>{fe.stopPropagation(),fe.dataTransfer.setData("text/plain","part:"+_.id),fe.dataTransfer.effectAllowed="move",N({type:"part",id:_.id})},onDragEnd:()=>{N(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:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",z," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:fe=>fe.stopPropagation(),onClick:fe=>fe.stopPropagation(),children:[o&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[re,"章"]}),F?s.jsx(Gc,{className:"w-5 h-5 text-gray-500"}):s.jsx(fl,{className:"w-5 h-5 text-gray-500"})]})]}),F&&_.chapters.length>0&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map(fe=>s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:fe.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:Q=>Q.stopPropagation(),children:[m&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>m(_,fe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>u(_,fe),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:fe.sections.map(Q=>{const de=I("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+Q.id),he.dataTransfer.effectAllowed="move",N({type:"section",id:Q.id})},onDragEnd:()=>{N(null),E(null)},onClick:()=>i(Q),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${de?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:fe.id,chapterTitle:fe.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(Q.id),onChange:()=>y(Q.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[Q.id," ",Q.title]}),j.includes(Q.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onClick:he=>he.stopPropagation(),children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),b&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]},Q.id)})})]},fe.id))})]},_.id)}if(U)return s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),s.jsx("div",{className:"space-y-3",children:_.chapters.map((W,fe)=>W.sections.length>0?W.sections.map(Q=>{const de=I("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+Q.id),he.dataTransfer.effectAllowed="move",N({type:"section",id:Q.id})},onDragEnd:()=>{N(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 ${de?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(Q.id),onChange:()=>y(Q.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",fe+1," | ",W.title," | ",Q.title]}),j.includes(Q.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),b&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(fl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},Q.id)}):s.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[s.jsxs("span",{className:"text-sm text-gray-500",children:["附录",fe+1," | ",W.title,"(空)"]}),s.jsx(fl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},W.id))})]},_.id);if(J&&_.chapters.length===1&&_.chapters[0].sections.length===1){const W=_.chapters[0].sections[0],fe=I("section",W.id),Q={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+W.id),de.dataTransfer.effectAllowed="move",N({type:"section",id:W.id})},onDragEnd:()=>{N(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] ${fe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",W.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",W.id,Q),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(W.id),onChange:()=>y(W.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx(ps,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",W.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:de=>de.stopPropagation(),onClick:de=>de.stopPropagation(),children:[W.price===0||W.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",W.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",W.clickCount??0," · 付款 ",W.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(W.hotScore??0).toFixed(1)," · 第",W.hotRank&&W.hotRank>0?W.hotRank:"-","名"]}),b&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>b(W),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(W),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(W),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}return J?s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),s.jsx("div",{className:"space-y-3",children:_.chapters.map(W=>W.sections.map(fe=>{const Q=I("section",fe.id);return s.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+fe.id),de.dataTransfer.effectAllowed="move",N({type:"section",id:fe.id})},onDragEnd:()=>{N(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 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",fe.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",fe.id,{partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(fe.id),onChange:()=>y(fe.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-300",children:[W.title," | ",fe.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",fe.clickCount??0," · 付款 ",fe.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(fe.hotScore??0).toFixed(1)," · 第",fe.hotRank&&fe.hotRank>0?fe.hotRank:"-","名"]}),b&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>b(fe),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(fe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(fe),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},fe.id)}))})]},_.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${R?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...P("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((H=_.chapters[0])==null?void 0:H.id)??"",chapterTitle:((ce=_.chapters[0])==null?void 0:ce.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:W=>{W.stopPropagation(),W.dataTransfer.setData("text/plain","part:"+_.id),W.dataTransfer.effectAllowed="move",N({type:"part",id:_.id})},onDragEnd:()=>{N(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:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.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:L(X)}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",z," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:W=>W.stopPropagation(),onClick:W=>W.stopPropagation(),children:[o&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[re,"章"]}),F?s.jsx(Gc,{className:"w-5 h-5 text-gray-500"}):s.jsx(fl,{className:"w-5 h-5 text-gray-500"})]})]}),F&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map(W=>{const fe=I("chapter",W.id);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","chapter:"+W.id),Q.dataTransfer.effectAllowed="move",N({type:"chapter",id:W.id})},onDragEnd:()=>{N(null),E(null)},onDragEnter:Q=>{Q.preventDefault(),Q.stopPropagation(),Q.dataTransfer.dropEffect="move",E({type:"chapter",id:W.id})},onDragOver:Q=>{Q.preventDefault(),Q.stopPropagation(),Q.dataTransfer.dropEffect="move",E({type:"chapter",id:W.id})},onDragLeave:()=>E(null),onDrop:Q=>{E(null);const de=mg(Q.dataTransfer.getData("text/plain"));if(!de)return;const he={partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title};(de.type==="section"||de.type==="chapter")&&D(Q,"chapter",W.id,he)},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 ${fe?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${M("chapter",W.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:W.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:Q=>Q.stopPropagation(),children:[m&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>m(_,W),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>u(_,W),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:W.sections.map(Q=>{const de=I("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+Q.id),he.dataTransfer.effectAllowed="move",N({type:"section",id:Q.id})},onDragEnd:()=>{N(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 ${de?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...P("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(Q.id),onChange:()=>y(Q.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${Q.price===0||Q.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[Q.id," ",Q.title]}),j.includes(Q.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:he=>he.stopPropagation(),onClick:he=>he.stopPropagation(),children:[Q.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),Q.price===0||Q.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",Q.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),b&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),s.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},Q.id)})})]},W.id)})})]},_.id)})})}function QB(t){var i;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(i=t==null?void 0:t.keyword)!=null&&i.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString(),r=n?`/api/admin/ckb/devices?${n}`:"/api/admin/ckb/devices";return Le(r)}function XB(t){return Le(`/api/db/person?personId=${encodeURIComponent(t)}`)}const I4=11,hw={personId:"",name:"",label:"",sceneId:I4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"09:00",endTime:"18:00",deviceGroups:""};function ZB({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){const i=!!n,[a,o]=v.useState(hw),[c,u]=v.useState(!1),[h,f]=v.useState(!1),[m,g]=v.useState([]),[y,b]=v.useState(!1),[j,w]=v.useState(""),[N,C]=v.useState({});v.useEffect(()=>{t&&(w(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",label:n.label??"",sceneId:I4,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??""}:{...hw}),C({}),m.length===0&&E(""))},[t,n]);const E=async I=>{b(!0);try{const O=await QB({page:1,limit:50,keyword:I});O!=null&&O.success&&Array.isArray(O.devices)?g(O.devices):O!=null&&O.error&&ie.error(O.error)}catch(O){ie.error(O instanceof Error?O.message:"加载设备列表失败")}finally{b(!1)}},M=async()=>{var P;const I={};(!a.name||!String(a.name).trim())&&(I.name="请填写名称");const O=a.addFriendInterval;if((typeof O!="number"||O<1)&&(I.addFriendInterval="添加间隔至少为 1 分钟"),(((P=a.deviceGroups)==null?void 0:P.split(",").map(L=>L.trim()).filter(Boolean))??[]).length===0&&(I.deviceGroups="请至少选择 1 台设备"),C(I),Object.keys(I).length>0){ie.error(I.name||I.addFriendInterval||I.deviceGroups||"请完善必填项");return}u(!0);try{await r(a),e(!1)}catch(L){ie.error(L instanceof Error?L.message:"保存失败")}finally{u(!1)}};return s.jsx(Kt,{open:t,onOpenChange:e,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(qt,{children:[s.jsx(Gt,{className:"text-[#38bdac]",children:i?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Wx,{className:"text-gray-400 text-sm",children:i?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),s.jsxs("div",{className:"space-y-6 py-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(Z,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(oe,{className:`bg-[#0a1628] text-white ${N.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:a.name,onChange:I=>{o(O=>({...O,name:I.target.value})),N.name&&C(O=>({...O,name:void 0}))}}),N.name&&s.jsx("p",{className:"text-xs text-red-400",children:N.name})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:a.personId,onChange:I=>o(O=>({...O,personId:I.target.value})),disabled:i})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:a.label,onChange:I=>o(O=>({...O,label:I.target.value}))})]})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝密钥(计划 apiKey)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"创建计划成功后自动回填,不可手动修改",value:a.ckbApiKey,readOnly:!0}),s.jsx("p",{className:"text-xs text-gray-500",children:"由存客宝计划详情接口返回的 apiKey,用于小程序 @人物 时推送到对应获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(Z,{className:"text-gray-400 text-xs",children:["选择设备 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:`flex gap-2 rounded-md border ${N.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(oe,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:a.deviceGroups?`已选择 ${a.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>f(!0)}),s.jsx(ee,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),N.deviceGroups?s.jsx("p",{className:"text-xs text-red-400",children:N.deviceGroups}):s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(ul,{value:a.remarkType,onValueChange:I=>o(O=>({...O,remarkType:I})),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择备注类型"})}),s.jsxs(Za,{children:[s.jsx(Ir,{value:"phone",children:"手机号"}),s.jsx(Ir,{value:"nickname",children:"昵称"}),s.jsx(Ir,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"备注格式"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 手机号+SOUL链接人与事-{名称},留空用默认",value:a.remarkFormat,onChange:I=>o(O=>({...O,remarkFormat:I.target.value}))})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:a.greeting,onChange:I=>o(O=>({...O,greeting:I.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(oe,{type:"number",min:1,className:`bg-[#0a1628] text-white ${N.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:a.addFriendInterval,onChange:I=>{o(O=>({...O,addFriendInterval:Number(I.target.value)||1})),N.addFriendInterval&&C(O=>({...O,addFriendInterval:void 0}))}}),N.addFriendInterval&&s.jsx("p",{className:"text-xs text-red-400",children:N.addFriendInterval})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:a.startTime,onChange:I=>o(O=>({...O,startTime:I.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:a.endTime,onChange:I=>o(O=>({...O,endTime:I.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:a.tips,onChange:I=>o(O=>({...O,tips:I.target.value}))})]})]})]})]})]}),s.jsxs(hn,{className:"gap-3 pt-2",children:[s.jsx(ee,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(ee,{onClick:M,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":i?"保存":"添加"})]}),h&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),s.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:j,onChange:I=>w(I.target.value),onKeyDown:I=>{I.key==="Enter"&&E(j)}}),s.jsx(ee,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>E(j),disabled:y,children:"刷新"}),s.jsx(ee,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:y?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):s.jsx("div",{className:"p-4 space-y-2",children:m.map(I=>{const O=String(I.id??""),D=a.deviceGroups?a.deviceGroups.split(",").map(_=>_.trim()).filter(Boolean):[],P=D.includes(O),L=()=>{let _;P?_=D.filter(X=>X!==O):_=[...D,O],o(X=>({...X,deviceGroups:_.join(",")})),_.length>0&&C(X=>({...X,deviceGroups:void 0}))};return s.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:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-[#38bdac]",checked:P,onChange:L}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-white truncate max-w-xs",children:I.memo||I.wechatId||`设备 ${O}`}),I.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),I.status==="offline"&&s.jsx("span",{className:"rounded-full bg-gray-600/20 text-gray-400 text-[11px] px-2 py-0.5",children:"离线"})]}),s.jsxs("div",{className:"text-[11px] text-gray-400 mt-0.5",children:[s.jsxs("span",{className:"mr-3",children:["ID: ",O]}),I.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",I.wechatId]}),typeof I.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",I.totalFriend]})]})]})]},O)})})}),s.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[s.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",a.deviceGroups?a.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ee,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),s.jsx(ee,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function fw(t,e,n){if(!t||!t.includes("@")&&!t.includes("#")||typeof document>"u")return t;const r=document.createElement("div");r.innerHTML=t;const i=u=>e.find(h=>h.name===u),a=u=>n.find(h=>h.label===u),o=u=>{const h=u.textContent||"";if(!h||!h.includes("@")&&!h.includes("#"))return;const f=u.parentNode;if(!f)return;const m=document.createDocumentFragment(),g=/(@[^\s@#]+|#[^\s@#]+)/g;let y=0,b;for(;b=g.exec(h);){const[j]=b,w=b.index;if(w>y&&m.appendChild(document.createTextNode(h.slice(y,w))),j.startsWith("@")){const N=j.slice(1),C=i(N);if(C){const E=document.createElement("span");E.setAttribute("data-type","mention"),E.setAttribute("data-id",C.id),E.className="mention-tag",E.textContent=`@${C.name}`,m.appendChild(E)}else m.appendChild(document.createTextNode(j))}else if(j.startsWith("#")){const N=j.slice(1),C=a(N);if(C){const E=document.createElement("span");E.setAttribute("data-type","linkTag"),E.setAttribute("data-url",C.url||""),E.setAttribute("data-tag-type",C.type||"url"),E.setAttribute("data-tag-id",C.id||""),E.setAttribute("data-page-path",C.pagePath||""),E.setAttribute("data-app-id",C.appId||""),C.type==="miniprogram"&&C.appId&&E.setAttribute("data-mp-key",C.appId),E.className="link-tag-node",E.textContent=`#${C.label}`,m.appendChild(E)}else m.appendChild(document.createTextNode(j))}else m.appendChild(document.createTextNode(j));y=w+j.length}y{if(u.nodeType===Node.ELEMENT_NODE){const f=u.getAttribute("data-type");if(f==="mention"||f==="linkTag")return;u.childNodes.forEach(m=>c(m));return}u.nodeType===Node.TEXT_NODE&&o(u)};return r.childNodes.forEach(u=>c(u)),r.innerHTML}function eV(t){const e=new Map;for(const c of t){const u=c.partId||"part-1",h=c.partTitle||"未分类",f=c.chapterId||"chapter-1",m=c.chapterTitle||"未分类";e.has(u)||e.set(u,{id:u,title:h,chapters:new Map});const g=e.get(u);g.chapters.has(f)||g.chapters.set(f,{id:f,title:m,sections:[]}),g.chapters.get(f).sections.push({id:c.id,title:c.title,price:c.price??1,filePath:c.filePath,isFree:c.isFree,isNew:c.isNew,clickCount:c.clickCount??0,payCount:c.payCount??0,hotScore:c.hotScore??0,hotRank:c.hotRank??0})}const n="part-2026-daily",r="2026每日派对干货";Array.from(e.values()).some(c=>c.title===r||c.title.includes(r))||e.set(n,{id:n,title:r,chapters:new Map([["chapter-2026-daily",{id:"chapter-2026-daily",title:r,sections:[]}]])});const a=Array.from(e.values()).map(c=>({...c,chapters:Array.from(c.chapters.values())})),o=c=>c.includes("序言")?0:c.includes(r)?1.5:c.includes("附录")?2:c.includes("尾声")?3:1;return a.sort((c,u)=>{const h=o(c.title),f=o(u.title);return h!==f?h-f:0})}function tV(){var Po,yt,Ul;const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState([]),[o,c]=v.useState(null),[u,h]=v.useState(!1),[f,m]=v.useState(!1),[g,y]=v.useState(!1),[b,j]=v.useState(""),[w,N]=v.useState([]),[C,E]=v.useState(!1),[M,I]=v.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[O,D]=v.useState(null),[P,L]=v.useState(!1),[_,X]=v.useState(!1),[ne,J]=v.useState(null),[U,R]=v.useState(!1),[F,re]=v.useState([]),[z,ae]=v.useState(!1),[G,$]=v.useState(""),[H,ce]=v.useState(""),[W,fe]=v.useState(!1),[Q,de]=v.useState(""),[he,Ne]=v.useState(!1),[Te,Ve]=v.useState(null),[He,gt]=v.useState(!1),[Pt,wn]=v.useState(!1),[ht,At]=v.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[te,Pe]=v.useState(!1),[Qe,xt]=v.useState(!1),[ft,pt]=v.useState(1),[wt,Xt]=v.useState([]),[Ot,Tn]=v.useState(!1),[Dt,Kn]=v.useState([]),[Xr,ir]=v.useState(!1),[me,ve]=v.useState(20),[ar,Hs]=v.useState(!1),[ki,Si]=v.useState(!1),[Sr,Aa]=v.useState([]),[_r,Zr]=v.useState([]),[or,Ci]=v.useState(!1),[Ia,Ws]=v.useState(null),[ot,Ln]=v.useState({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),[es,Cr]=v.useState(null),ts=v.useRef(null),rn=eV(t),zr=t.length,Us=10,$r=Math.max(1,Math.ceil(wt.length/Us)),Ks=wt.slice((ft-1)*Us,ft*Us),jn=async()=>{r(!0);try{const A=await Le("/api/db/book?action=list",{cache:"no-store"});e(Array.isArray(A==null?void 0:A.sections)?A.sections:[])}catch(A){console.error(A),e([])}finally{r(!1)}},Ns=async()=>{Tn(!0);try{const A=await Le("/api/db/book?action=ranking",{cache:"no-store"}),K=Array.isArray(A==null?void 0:A.sections)?A.sections:[];Xt(K);const pe=K.filter(ye=>ye.isPinned).map(ye=>ye.id);Kn(pe)}catch(A){console.error(A),Xt([])}finally{Tn(!1)}};v.useEffect(()=>{jn(),Ns()},[]);const Hl=A=>{a(K=>K.includes(A)?K.filter(pe=>pe!==A):[...K,A])},Ei=v.useCallback(A=>{const K=t,pe=A.flatMap(ye=>{const it=K.find(bt=>bt.id===ye.id);return it?[{...it,partId:ye.partId,partTitle:ye.partTitle,chapterId:ye.chapterId,chapterTitle:ye.chapterTitle}]:[]});return e(pe),Mt("/api/db/book",{action:"reorder",items:A}).then(ye=>{ye&&ye.success===!1&&(e(K),ie.error("排序失败: "+(ye&&typeof ye=="object"&&"error"in ye?ye.error:"未知错误")))}).catch(ye=>{e(K),console.error("排序失败:",ye),ie.error("排序失败: "+(ye instanceof Error?ye.message:"网络或服务异常"))}),Promise.resolve()},[t]),qs=async A=>{if(confirm(`确定要删除章节「${A.title}」吗?此操作不可恢复。`))try{const K=await Ps(`/api/db/book?id=${encodeURIComponent(A.id)}`);K&&K.success!==!1?(ie.success("已删除"),jn(),Ns()):ie.error("删除失败: "+(K&&typeof K=="object"&&"error"in K?K.error:"未知错误"))}catch(K){console.error(K),ie.error("删除失败")}},mr=v.useCallback(async()=>{Pe(!0);try{const A=await Le("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),K=A&&A.data;K&&typeof K.readWeight=="number"&&typeof K.recencyWeight=="number"&&typeof K.payWeight=="number"&&At({readWeight:Math.max(0,Math.min(1,K.readWeight)),recencyWeight:Math.max(0,Math.min(1,K.recencyWeight)),payWeight:Math.max(0,Math.min(1,K.payWeight))})}catch{}finally{Pe(!1)}},[]);v.useEffect(()=>{Pt&&mr()},[Pt,mr]);const Ra=async()=>{const{readWeight:A,recencyWeight:K,payWeight:pe}=ht,ye=A+K+pe;if(Math.abs(ye-1)>.001){ie.error("三个权重之和必须等于 1");return}xt(!0);try{const it=await Nt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:A,recencyWeight:K,payWeight:pe},description:"文章排名算法权重"});it&&it.success!==!1?(ie.success("排名权重已保存"),jn()):ie.error("保存失败: "+(it&&typeof it=="object"&&"error"in it?it.error:""))}catch(it){console.error(it),ie.error("保存失败")}finally{xt(!1)}},Ti=v.useCallback(async()=>{ir(!0);try{const A=await Le("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),K=A&&A.data;Array.isArray(K)&&Kn(K)}catch{}finally{ir(!1)}},[]),Gs=v.useCallback(async()=>{try{const A=await Le("/api/db/persons");A!=null&&A.success&&A.persons&&Aa(A.persons.map(K=>{const pe=K.deviceGroups,ye=Array.isArray(pe)?pe.join(","):pe??"";return{id:K.token??K.personId??"",personId:K.personId,name:K.name,label:K.label??"",ckbApiKey:K.ckbApiKey??"",ckbPlanId:K.ckbPlanId,remarkType:K.remarkType,remarkFormat:K.remarkFormat,addFriendInterval:K.addFriendInterval,startTime:K.startTime,endTime:K.endTime,deviceGroups:ye}}))}catch{}},[]),ws=v.useCallback(async()=>{try{const A=await Le("/api/db/link-tags");A!=null&&A.success&&A.linkTags&&Zr(A.linkTags.map(K=>({id:K.tagId,label:K.label,url:K.url,type:K.type||"url",appId:K.appId||"",pagePath:K.pagePath||""})))}catch{}},[]),[Mi,To]=v.useState([]),[js,Pa]=v.useState(""),[Mo,Tt]=v.useState(!1),Ao=v.useRef(null),Js=v.useCallback(async()=>{try{const A=await Le("/api/admin/linked-miniprograms");A!=null&&A.success&&Array.isArray(A.data)&&To(A.data.map(K=>({...K,key:K.key})))}catch{}},[]),Ai=Mi.filter(A=>!js.trim()||A.name.toLowerCase().includes(js.toLowerCase())||A.key&&A.key.toLowerCase().includes(js.toLowerCase())||A.appId.toLowerCase().includes(js.toLowerCase())),ks=async A=>{const K=Dt.includes(A)?Dt.filter(pe=>pe!==A):[...Dt,A];Kn(K);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:K,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),Ns()}catch{Kn(Dt)}},Oa=v.useCallback(async()=>{Hs(!0);try{const A=await Le("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),K=A&&A.data;typeof K=="number"&&K>0&&K<=100&&ve(K)}catch{}finally{Hs(!1)}},[]),Da=async()=>{if(me<1||me>100){ie.error("预览比例需在 1~100 之间");return}Si(!0);try{const A=await Nt("/api/db/config",{key:"unpaid_preview_percent",value:me,description:"小程序未付费内容默认预览比例(%)"});A&&A.success!==!1?ie.success("预览比例已保存"):ie.error("保存失败: "+(A.error||""))}catch{ie.error("保存失败")}finally{Si(!1)}};v.useEffect(()=>{Ti(),Oa(),Gs(),ws(),Js()},[Ti,Oa,Gs,ws,Js]);const V=async A=>{Ve({section:A,orders:[]}),gt(!0);try{const K=await Le(`/api/db/book?action=section-orders&id=${encodeURIComponent(A.id)}`),pe=K!=null&&K.success&&Array.isArray(K.orders)?K.orders:[];Ve(ye=>ye?{...ye,orders:pe}:null)}catch(K){console.error(K),Ve(pe=>pe?{...pe,orders:[]}:null)}finally{gt(!1)}},Re=async A=>{m(!0);try{const K=await Le(`/api/db/book?action=read&id=${encodeURIComponent(A.id)}`);if(K!=null&&K.success&&K.section){const pe=K.section,ye=pe.editionPremium===!0;c({id:A.id,originalId:A.id,title:K.section.title??A.title,price:K.section.price??A.price,content:K.section.content??"",filePath:A.filePath,isFree:A.isFree||A.price===0,isNew:pe.isNew??A.isNew,isPinned:Dt.includes(A.id),hotScore:A.hotScore??0,editionStandard:ye?!1:pe.editionStandard??!0,editionPremium:ye})}else c({id:A.id,originalId:A.id,title:A.title,price:A.price,content:"",filePath:A.filePath,isFree:A.isFree,isNew:A.isNew,isPinned:Dt.includes(A.id),hotScore:A.hotScore??0,editionStandard:!0,editionPremium:!1}),K&&!K.success&&ie.error("无法读取文件内容: "+(K.error||"未知错误"))}catch(K){console.error(K),c({id:A.id,title:A.title,price:A.price,content:"",filePath:A.filePath,isFree:A.isFree})}finally{m(!1)}},Xe=async()=>{var A;if(o){y(!0);try{let K=o.content||"";K=fw(K,Sr,_r);const pe=[new RegExp(`^#+\\s*${o.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${o.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(A=o.title)==null?void 0:A.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const an of pe)K=K.replace(an,"");K=K.replace(/^\s*\n+/,"").trim();const ye=o.originalId||o.id,it=o.id!==ye,bt=await Mt("/api/db/book",{id:ye,...it?{newId:o.id}:{},title:o.title,price:o.isFree?0:o.price,content:K,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}),sn=it?o.id:ye;o.isPinned!==Dt.includes(sn)&&await ks(sn),bt&&bt.success!==!1?(ie.success(`已保存:${o.title}`),c(null),jn()):ie.error("保存失败: "+(bt&&typeof bt=="object"&&"error"in bt?bt.error:"未知错误"))}catch(K){console.error(K),ie.error("保存失败")}finally{y(!1)}}},et=async()=>{if(!M.id||!M.title){ie.error("请填写章节ID和标题");return}y(!0);try{const A=rn.find(ye=>ye.id===M.partId),K=A==null?void 0:A.chapters.find(ye=>ye.id===M.chapterId),pe=await Mt("/api/db/book",{id:M.id,title:M.title,price:M.isFree?0:M.price,content:fw(M.content||"",Sr,_r),partId:M.partId,partTitle:(A==null?void 0:A.title)??"",chapterId:M.chapterId,chapterTitle:(K==null?void 0:K.title)??"",isFree:M.isFree,isNew:M.isNew,editionStandard:M.editionPremium?!1:M.editionStandard??!0,editionPremium:M.editionPremium??!1,hotScore:M.hotScore??0,saveToFile:!1});if(pe&&pe.success!==!1){if(M.isPinned){const ye=[...Dt,M.id];Kn(ye);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:ye,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}ie.success(`章节创建成功:${M.title}`),h(!1),I({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),jn()}else ie.error("创建失败: "+(pe&&typeof pe=="object"&&"error"in pe?pe.error:"未知错误"))}catch(A){console.error(A),ie.error("创建失败")}finally{y(!1)}},Mn=A=>{I(K=>{var pe;return{...K,partId:A.id,chapterId:((pe=A.chapters[0])==null?void 0:pe.id)??"chapter-1"}}),h(!0)},lr=A=>{D({id:A.id,title:A.title})},Io=async()=>{var A;if((A=O==null?void 0:O.title)!=null&&A.trim()){L(!0);try{const K=t.map(ye=>({id:ye.id,partId:ye.partId||"part-1",partTitle:ye.partId===O.id?O.title.trim():ye.partTitle||"",chapterId:ye.chapterId||"chapter-1",chapterTitle:ye.chapterTitle||""})),pe=await Mt("/api/db/book",{action:"reorder",items:K});if(pe&&pe.success!==!1){const ye=O.title.trim();e(it=>it.map(bt=>bt.partId===O.id?{...bt,partTitle:ye}:bt)),D(null),jn()}else ie.error("更新篇名失败: "+(pe&&typeof pe=="object"&&"error"in pe?pe.error:"未知错误"))}catch(K){console.error(K),ie.error("更新篇名失败")}finally{L(!1)}}},Jt=A=>{const K=A.chapters.length+1,pe=`chapter-${A.id}-${K}-${Date.now()}`;I({id:`${K}.1`,title:"新章节",price:1,partId:A.id,chapterId:pe,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),h(!0)},_n=(A,K)=>{J({part:A,chapter:K,title:K.title})},ns=async()=>{var A;if((A=ne==null?void 0:ne.title)!=null&&A.trim()){R(!0);try{const K=t.map(ye=>({id:ye.id,partId:ye.partId||ne.part.id,partTitle:ye.partId===ne.part.id?ne.part.title:ye.partTitle||"",chapterId:ye.chapterId||ne.chapter.id,chapterTitle:ye.partId===ne.part.id&&ye.chapterId===ne.chapter.id?ne.title.trim():ye.chapterTitle||""})),pe=await Mt("/api/db/book",{action:"reorder",items:K});if(pe&&pe.success!==!1){const ye=ne.title.trim(),it=ne.part.id,bt=ne.chapter.id;e(sn=>sn.map(an=>an.partId===it&&an.chapterId===bt?{...an,chapterTitle:ye}:an)),J(null),jn()}else ie.error("保存失败: "+(pe&&typeof pe=="object"&&"error"in pe?pe.error:"未知错误"))}catch(K){console.error(K),ie.error("保存失败")}finally{R(!1)}}},Ss=async(A,K)=>{const pe=K.sections.map(ye=>ye.id);if(pe.length===0){ie.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${A.chapters.indexOf(K)+1}章 | ${K.title}」吗?将删除共 ${pe.length} 节,此操作不可恢复。`))try{for(const ye of pe)await Ps(`/api/db/book?id=${encodeURIComponent(ye)}`);jn()}catch(ye){console.error(ye),ie.error("删除失败")}},Ys=async()=>{if(!Q.trim()){ie.error("请输入篇名");return}Ne(!0);try{const A=`part-new-${Date.now()}`,K="chapter-1",pe=`part-placeholder-${Date.now()}`,ye=await Mt("/api/db/book",{id:pe,title:"占位节(可编辑)",price:0,content:"",partId:A,partTitle:Q.trim(),chapterId:K,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ye&&ye.success!==!1?(ie.success(`篇「${Q}」创建成功`),X(!1),de(""),jn()):ie.error("创建失败: "+(ye&&typeof ye=="object"&&"error"in ye?ye.error:"未知错误"))}catch(A){console.error(A),ie.error("创建失败")}finally{Ne(!1)}},Wl=async()=>{if(F.length===0){ie.error("请先勾选要移动的章节");return}const A=rn.find(pe=>pe.id===G),K=A==null?void 0:A.chapters.find(pe=>pe.id===H);if(!A||!K||!G||!H){ie.error("请选择目标篇和章");return}fe(!0);try{const pe=()=>{const sn=new Set(F),an=t.map(on=>({id:on.id,partId:on.partId||"",partTitle:on.partTitle||"",chapterId:on.chapterId||"",chapterTitle:on.chapterTitle||""})),Cs=an.filter(on=>sn.has(on.id)).map(on=>({...on,partId:G,partTitle:A.title||G,chapterId:H,chapterTitle:K.title||H})),gr=an.filter(on=>!sn.has(on.id));let Xs=gr.length;for(let on=gr.length-1;on>=0;on-=1){const rs=gr[on];if(rs.partId===G&&rs.chapterId===H){Xs=on+1;break}}return[...gr.slice(0,Xs),...Cs,...gr.slice(Xs)]},ye=async()=>{const sn=pe(),an=await Mt("/api/db/book",{action:"reorder",items:sn});return an&&an.success!==!1?(ie.success(`已移动 ${F.length} 节到「${A.title}」-「${K.title}」`),ae(!1),re([]),await jn(),!0):!1},it={action:"move-sections",sectionIds:F,targetPartId:G,targetChapterId:H,targetPartTitle:A.title||G,targetChapterTitle:K.title||H},bt=await Mt("/api/db/book",it);if(bt&&bt.success!==!1)ie.success(`已移动 ${bt.count??F.length} 节到「${A.title}」-「${K.title}」`),ae(!1),re([]),await jn();else{const sn=bt&&typeof bt=="object"&&"error"in bt?bt.error||"":"未知错误";if((sn.includes("缺少 id")||sn.includes("无效的 action"))&&await ye())return;ie.error("移动失败: "+sn)}}catch(pe){console.error(pe),ie.error("移动失败: "+(pe instanceof Error?pe.message:"网络或服务异常"))}finally{fe(!1)}},La=A=>{re(K=>K.includes(A)?K.filter(pe=>pe!==A):[...K,A])},Ii=async A=>{const K=t.filter(pe=>pe.partId===A.id).map(pe=>pe.id);if(K.length===0){ie.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${A.title}」整篇吗?将删除共 ${K.length} 节内容,此操作不可恢复。`))try{for(const pe of K)await Ps(`/api/db/book?id=${encodeURIComponent(pe)}`);jn()}catch(pe){console.error(pe),ie.error("删除失败")}},Ro=async()=>{var A;if(b.trim()){E(!0);try{const K=await Le(`/api/search?q=${encodeURIComponent(b)}`);K!=null&&K.success&&((A=K.data)!=null&&A.results)?N(K.data.results):(N([]),K&&!K.success&&ie.error("搜索失败: "+K.error))}catch(K){console.error(K),N([]),ie.error("搜索失败")}finally{E(!1)}}},Qs=rn.find(A=>A.id===M.partId),vd=(Qs==null?void 0:Qs.chapters)??[];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",rn.length," 篇 · ",zr," 节内容"]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(ee,{onClick:()=>wn(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Nu,{className:"w-4 h-4 mr-2"}),"排名算法"]}),s.jsxs(ee,{onClick:()=>{const A=typeof window<"u"?`${window.location.origin}/api-doc`:"";A&&window.open(A,"_blank","noopener,noreferrer")},variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ms,{className:"w-4 h-4 mr-2"}),"API 接口"]})]})]}),s.jsx(Kt,{open:u,onOpenChange:h,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(qt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(dn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节ID *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:M.id,onChange:A=>I({...M,id:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:M.isFree?0:M.price,onChange:A=>I({...M,price:Number(A.target.value),isFree:Number(A.target.value)===0}),disabled:M.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:M.isFree,onChange:A=>I({...M,isFree:A.target.checked,price:A.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:M.isNew,onChange:A=>I({...M,isNew:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:M.isPinned,onChange:A=>I({...M,isPinned:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium!==!0,onChange:()=>I({...M,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium===!0,onChange:()=>I({...M,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:M.hotScore??0,onChange:A=>I({...M,hotScore:Math.max(0,parseFloat(A.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:M.title,onChange:A=>I({...M,title:A.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"所属篇"}),s.jsxs(ul,{value:M.partId,onValueChange:A=>{var pe;const K=rn.find(ye=>ye.id===A);I({...M,partId:A,chapterId:((pe=K==null?void 0:K.chapters[0])==null?void 0:pe.id)??"chapter-1"})},children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{})}),s.jsxs(Za,{className:"bg-[#0f2137] border-gray-700",children:[rn.map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id)),rn.length===0&&s.jsx(Ir,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"所属章"}),s.jsxs(ul,{value:M.chapterId,onValueChange:A=>I({...M,chapterId:A}),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{})}),s.jsxs(Za,{className:"bg-[#0f2137] border-gray-700",children:[vd.map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id)),vd.length===0&&s.jsx(Ir,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(yx,{content:M.content||"",onChange:A=>I({...M,content:A}),onImageUpload:async A=>{var it;const K=new FormData;K.append("file",A),K.append("folder","book-images");const ye=await(await fetch(ho("/api/upload"),{method:"POST",body:K,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((it=ye==null?void 0:ye.data)==null?void 0:it.url)||(ye==null?void 0:ye.url)||""},persons:Sr,linkTags:_r,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(hn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(ee,{variant:"outline",onClick:()=>h(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:et,disabled:g||!M.id||!M.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Kt,{open:!!O,onOpenChange:A=>!A&&D(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),O&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"篇名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:O.title,onChange:A=>D({...O,title:A.target.value}),placeholder:"输入篇名"})]})}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>D(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:Io,disabled:P||!((Po=O==null?void 0:O.title)!=null&&Po.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:P?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Kt,{open:!!ne,onOpenChange:A=>!A&&J(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节名称"]})}),ne&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:ne.title,onChange:A=>J({...ne,title:A.target.value}),placeholder:"输入章节名称"})]})}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>J(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:ns,disabled:U||!((yt=ne==null?void 0:ne.title)!=null&&yt.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:U?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Kt,{open:z,onOpenChange:A=>{var K;if(ae(A),A&&rn.length>0){const pe=rn[0];$(pe.id),ce(((K=pe.chapters[0])==null?void 0:K.id)??"")}},children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"批量移动至指定目录"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",s.jsx("span",{className:"text-[#38bdac] font-medium",children:F.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目标篇"}),s.jsxs(ul,{value:G,onValueChange:A=>{var pe;$(A);const K=rn.find(ye=>ye.id===A);ce(((pe=K==null?void 0:K.chapters[0])==null?void 0:pe.id)??"")},children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择篇"})}),s.jsx(Za,{className:"bg-[#0f2137] border-gray-700",children:rn.map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目标章"}),s.jsxs(ul,{value:H,onValueChange:ce,children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择章"})}),s.jsx(Za,{className:"bg-[#0f2137] border-gray-700",children:(((Ul=rn.find(A=>A.id===G))==null?void 0:Ul.chapters)??[]).map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id))})]})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>ae(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:Wl,disabled:W||F.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:W?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Kt,{open:!!Te,onOpenChange:A=>!A&&Ve(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white",children:["付款记录 — ",(Te==null?void 0:Te.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:He?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Te&&Te.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):Te?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"py-2 pr-2",children:"订单号"}),s.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),s.jsx("th",{className:"py-2 pr-2",children:"金额"}),s.jsx("th",{className:"py-2 pr-2",children:"状态"}),s.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),s.jsx("tbody",{children:Te.orders.map(A=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-2",children:s.jsx("button",{className:"text-blue-400 hover:text-blue-300 hover:underline text-left truncate max-w-[180px] block",title:`查看订单 ${A.orderSn}`,onClick:()=>window.open(`/orders?search=${A.orderSn??A.id??""}`,"_blank"),children:A.orderSn?A.orderSn.length>16?A.orderSn.slice(0,8)+"..."+A.orderSn.slice(-6):A.orderSn:"-"})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsx("button",{className:"text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[140px] block",title:`查看用户 ${A.userId??A.openId??""}`,onClick:()=>window.open(`/users?search=${A.userId??A.openId??""}`,"_blank"),children:(()=>{const K=A.userId??A.openId??"-";return K.length>12?K.slice(0,6)+"..."+K.slice(-4):K})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",A.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:A.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:A.payTime??A.createdAt??"-"})]},A.id??A.orderSn??""))})]}):null})]})}),s.jsx(Kt,{open:Pt,onOpenChange:wn,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsx("p",{className:"text-sm text-gray-400",children:"热度积分 = 阅读权重×阅读排名分 + 新度权重×新度排名分 + 付款权重×付款排名分(三权重之和须为 1)"}),te?s.jsx("p",{className:"text-gray-500",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:ht.readWeight,onChange:A=>At(K=>({...K,readWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:ht.recencyWeight,onChange:A=>At(K=>({...K,recencyWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:ht.payWeight,onChange:A=>At(K=>({...K,payWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(ht.readWeight+ht.recencyWeight+ht.payWeight).toFixed(1)]}),s.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[s.jsx("li",{children:"阅读量前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"最近更新前 30 篇:第1名=30分、第2名=29分...第30名=1分"}),s.jsx("li",{children:"付款数前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),s.jsx(ee,{onClick:Ra,disabled:Qe||Math.abs(ht.readWeight+ht.recencyWeight+ht.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Qe?"保存中...":"保存权重"})]})]})]})}),s.jsx(Kt,{open:_,onOpenChange:X,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(dn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:Q,onChange:A=>de(A.target.value),placeholder:"输入篇名"})]})}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>{X(!1),de("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:Ys,disabled:he||!Q.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:he?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Kt,{open:!!o,onOpenChange:()=>c(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(qt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),o&&s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.id,onChange:A=>c({...o,id:A.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.isFree?0:o.price,onChange:A=>c({...o,price:Number(A.target.value),isFree:Number(A.target.value)===0}),disabled:o.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isFree||o.price===0,onChange:A=>c({...o,isFree:A.target.checked,price:A.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isNew??!1,onChange:A=>c({...o,isNew:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isPinned??!1,onChange:A=>c({...o,isPinned:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.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]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.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]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:o.hotScore??0,onChange:A=>c({...o,hotScore:Math.max(0,parseFloat(A.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.title,onChange:A=>c({...o,title:A.target.value})})]}),o.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文件路径"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:o.filePath,disabled:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),f?s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(yx,{ref:ts,content:o.content||"",onChange:A=>c({...o,content:A}),onImageUpload:async A=>{var it;const K=new FormData;K.append("file",A),K.append("folder","book-images");const ye=await(await fetch(ho("/api/upload"),{method:"POST",body:K,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((it=ye==null?void 0:ye.data)==null?void 0:it.url)||(ye==null?void 0:ye.url)||""},persons:Sr,linkTags:_r,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(hn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[o&&s.jsxs(ee,{variant:"outline",onClick:()=>V({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:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(ee,{variant:"outline",onClick:()=>c(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(ee,{onClick:Xe,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(fd,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Ll,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(tn,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(tn,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(_b,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(tn,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(da,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(tn,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(ms,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),s.jsxs(tn,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(Db,{className:"w-4 h-4 mr-2"}),"链接标签"]}),s.jsxs(tn,{value:"linkedmp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(uo,{className:"w-4 h-4 mr-2"}),"关联小程序"]})]}),s.jsxs(nn,{value:"chapters",className:"space-y-4",children:[s.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.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:s.jsx(ps,{className:"w-6 h-6"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),s.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),s.jsxs("div",{className:"text-center shrink-0",children:[s.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:zr}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(ee,{onClick:()=>h(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(ee,{onClick:()=>X(!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:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(ee,{variant:"outline",onClick:()=>ae(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",F.length," 节)"]})]}),n?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(YB,{parts:rn,expandedParts:i,onTogglePart:Hl,onReorder:Ei,onReadSection:Re,onDeleteSection:qs,onAddSectionInPart:Mn,onAddChapterInPart:Jt,onDeleteChapter:Ss,onEditPart:lr,onDeletePart:Ii,onEditChapter:_n,selectedSectionIds:F,onToggleSectionSelect:La,onShowSectionOrders:V,pinnedSectionIds:Dt})]}),s.jsx(nn,{value:"search",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"内容搜索"})}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:b,onChange:A=>j(A.target.value),onKeyDown:A=>A.key==="Enter"&&Ro()}),s.jsx(ee,{onClick:Ro,disabled:C||!b.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?s.jsx(Ge,{className:"w-4 h-4 animate-spin"}):s.jsx(da,{className:"w-4 h-4"})})]}),w.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",w.length," 个结果"]}),w.map(A=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>Re({id:A.id,title:A.title,price:A.price??1,filePath:""}),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:A.id}),s.jsx("span",{className:"text-white",children:A.title}),Dt.includes(A.id)&&s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Ue,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:A.matchType==="title"?"标题匹配":"内容匹配"})]}),A.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:A.snippet}),(A.partTitle||A.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[A.partTitle," · ",A.chapterTitle]})]},A.id))]})]})]})}),s.jsxs(nn,{value:"ranking",className:"space-y-4",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{className:"pb-3",children:s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Nu,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Z,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(oe,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:me,onChange:A=>ve(Math.max(1,Math.min(100,Number(A.target.value)||20))),disabled:ar}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(ee,{size:"sm",onClick:Da,disabled:ki,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:ki?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",me,"% 内容"]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(_b,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",wt.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>Ns(),disabled:Ot,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Ge,{className:`w-4 h-4 ${Ot?"animate-spin":""}`})}),s.jsx(ee,{variant:"ghost",size:"sm",disabled:ft<=1||Ot,onClick:()=>pt(A=>Math.max(1,A-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(VT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[ft," / ",$r]}),s.jsx(ee,{variant:"ghost",size:"sm",disabled:ft>=$r||Ot,onClick:()=>pt(A=>Math.min($r,A+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(fl,{className:"w-4 h-4"})})]})]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"space-y-0",children:[s.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:[s.jsx("span",{children:"排名"}),s.jsx("span",{children:"置顶"}),s.jsx("span",{children:"标题"}),s.jsx("span",{className:"text-right",children:"点击量"}),s.jsx("span",{className:"text-right",children:"付款数"}),s.jsx("span",{className:"text-right",children:"热度"}),s.jsx("span",{className:"text-right",children:"编辑"})]}),Ks.map((A,K)=>{const pe=(ft-1)*Us+K+1,ye=A.isPinned??Dt.includes(A.id);return s.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 ${ye?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${pe<=3?"text-amber-400":"text-gray-500"}`,children:pe<=3?["🥇","🥈","🥉"][pe-1]:`#${pe}`}),s.jsx(ee,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ye?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>ks(A.id),disabled:Xr,title:ye?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ye?s.jsx(ml,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(hA,{className:"w-3.5 h-3.5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-white text-sm truncate block",children:A.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[A.partTitle," · ",A.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:A.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:A.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(A.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>Re({id:A.id,title:A.title,price:A.price,filePath:""}),title:"编辑文章",children:s.jsx(_t,{className:"w-3 h-3"})})})]},A.id)}),Ks.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(nn,{value:"link-person",className:"space-y-4",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"pb-3",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — 链接人与事(编辑器内输入 @ 可链接)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"添加时自动生成 32 位 token,文章 @ 时存 token;小程序点击 @ 时用 token 兑换真实密钥后加好友"})]}),s.jsxs(Ae,{className:"space-y-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("p",{className:"text-xs text-gray-500",children:"添加人物时同步创建存客宝场景获客计划,配置与存客宝 API 获客一致"}),s.jsxs(ee,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Ws(null),Ci(!0)},children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[Sr.length>0&&s.jsxs("div",{className:"flex items-center gap-4 px-3 py-1.5 text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("span",{className:"w-[280px] shrink-0",children:"token"}),s.jsx("span",{className:"w-24 shrink-0",children:"@的人"}),s.jsx("span",{children:"获客计划活动名"})]}),Sr.map(A=>s.jsxs("div",{className:"bg-[#0a1628] rounded px-3 py-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm min-w-0",children:[s.jsx("span",{className:"text-gray-400 text-xs font-mono shrink-0 w-[280px]",title:"32位token",children:A.id}),s.jsx("span",{className:"text-amber-400 shrink-0 w-24 truncate",title:"@的人",children:A.name}),s.jsxs("span",{className:"text-white truncate",title:"获客计划活动名",children:["SOUL链接人与事-",A.name]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const K=await XB(A.personId||"");if(K!=null&&K.success&&K.person){const pe=K.person;Ws({id:pe.token??pe.personId,personId:pe.personId,name:pe.name,label:pe.label??"",ckbApiKey:pe.ckbApiKey??"",remarkType:pe.remarkType,remarkFormat:pe.remarkFormat,addFriendInterval:pe.addFriendInterval,startTime:pe.startTime,endTime:pe.endTime,deviceGroups:pe.deviceGroups})}else Ws(A),K!=null&&K.error&&ie.error(K.error)}catch(K){console.error(K),Ws(A),ie.error(K instanceof Error?K.message:"加载人物详情失败")}Ci(!0)},children:s.jsx(qw,{className:"w-3 h-3"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-amber-400 h-6 px-2",title:"编辑计划(跳转存客宝)",onClick:()=>{const K=A.ckbPlanId;K?window.open(`https://h5.ckb.quwanzhi.com/#/scenarios/edit/${K}`,"_blank"):ie.info("该人物尚未同步存客宝计划,请先保存后等待同步完成")},children:s.jsx(_s,{className:"w-3 h-3"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:"删除(同时删除存客宝对应获客计划)",onClick:async()=>{confirm(`确定删除「SOUL链接人与事-${A.name}」?将同时删除存客宝对应获客计划。`)&&(await Ps(`/api/db/persons?personId=${A.personId}`),Gs())},children:s.jsx(hr,{className:"w-3 h-3"})})]})]},A.id)),Sr.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"pb-3",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Nu,{className:"w-4 h-4 text-green-400"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs(Ae,{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",s.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]})]}),s.jsx(nn,{value:"link-tag",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"pb-3",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Db,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),s.jsxs(Ae,{className:"space-y-3",children:[s.jsxs("div",{className:"flex gap-2 items-end flex-wrap",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"标签ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",placeholder:"如 team01",value:ot.tagId,onChange:A=>Ln({...ot,tagId:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"显示文字"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"如 神仙团队",value:ot.label,onChange:A=>Ln({...ot,label:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"类型"}),s.jsxs(ul,{value:ot.type,onValueChange:A=>Ln({...ot,type:A}),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",children:s.jsx(hl,{})}),s.jsxs(Za,{children:[s.jsx(Ir,{value:"url",children:"网页链接"}),s.jsx(Ir,{value:"miniprogram",children:"小程序"}),s.jsx(Ir,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:ot.type==="url"?"URL地址":ot.type==="ckb"?"存客宝计划URL":"小程序(选密钥)"}),ot.type==="miniprogram"&&Mi.length>0?s.jsxs("div",{ref:Ao,className:"relative w-44",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-44",placeholder:"搜索名称或密钥",value:Mo?js:ot.appId,onChange:A=>{const K=A.target.value;Pa(K),Tt(!0),Mi.some(pe=>pe.key===K)||Ln({...ot,appId:K})},onFocus:()=>{Pa(ot.appId),Tt(!0)},onBlur:()=>setTimeout(()=>Tt(!1),150)}),Mo&&s.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:Ai.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Ai.map(A=>s.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:K=>{K.preventDefault(),Ln({...ot,appId:A.key,pagePath:A.path||""}),Pa(""),Tt(!1)},children:[s.jsx("span",{children:A.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:A.key})]},A.key))})]}):s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-44",placeholder:ot.type==="url"?"https://...":ot.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联小程序的32位密钥",value:ot.type==="url"||ot.type==="ckb"?ot.url:ot.appId,onChange:A=>{ot.type==="url"||ot.type==="ckb"?Ln({...ot,url:A.target.value}):Ln({...ot,appId:A.target.value})}})]}),ot.type==="miniprogram"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"页面路径"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-36",placeholder:"pages/index/index",value:ot.pagePath,onChange:A=>Ln({...ot,pagePath:A.target.value})})]}),s.jsxs(ee,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:async()=>{if(!ot.tagId||!ot.label){ie.error("标签ID和显示文字必填");return}const A={...ot};A.type==="miniprogram"&&(A.url=""),await Nt("/api/db/link-tags",A),Ln({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),Cr(null),ws()},children:[s.jsx(dn,{className:"w-3 h-3 mr-1"}),es?"保存":"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[_r.map(A=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsxs("button",{type:"button",className:"text-amber-400 font-bold text-base hover:underline",onClick:()=>{Ln({tagId:A.id,label:A.label,url:A.url,type:A.type,appId:A.appId??"",pagePath:A.pagePath??""}),Cr(A.id)},children:["#",A.label]}),s.jsx(Ue,{variant:"secondary",className:`text-[10px] ${A.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":"bg-gray-700 text-gray-300"}`,children:A.type==="url"?"网页":A.type==="ckb"?"存客宝":"小程序"}),A.type==="miniprogram"?s.jsxs("span",{className:"text-gray-400 text-xs font-mono",children:[A.appId," ",A.pagePath?`· ${A.pagePath}`:""]}):A.url?s.jsxs("a",{href:A.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[250px] hover:underline flex items-center gap-1",children:[A.url," ",s.jsx(_s,{className:"w-3 h-3 shrink-0"})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-6 px-2",onClick:()=>{Ln({tagId:A.id,label:A.label,url:A.url,type:A.type,appId:A.appId??"",pagePath:A.pagePath??""}),Cr(A.id)},children:"编辑"}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",onClick:async()=>{await Ps(`/api/db/link-tags?tagId=${A.id}`),es===A.id&&(Cr(null),Ln({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""})),ws()},children:s.jsx(hr,{className:"w-3 h-3"})})]})]},A.id)),_r.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})]})]})]})}),s.jsx(nn,{value:"linkedmp",className:"space-y-4",children:s.jsx(GB,{})})]}),s.jsx(ZB,{open:or,onOpenChange:Ci,editingPerson:Ia,onSubmit:async A=>{var ye;const K={personId:A.personId||A.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:A.name,label:A.label,ckbApiKey:A.ckbApiKey||void 0,greeting:A.greeting||void 0,tips:A.tips||void 0,remarkType:A.remarkType||void 0,remarkFormat:A.remarkFormat||void 0,addFriendInterval:A.addFriendInterval,startTime:A.startTime||void 0,endTime:A.endTime||void 0,deviceGroups:(ye=A.deviceGroups)!=null&&ye.trim()?A.deviceGroups.split(",").map(it=>parseInt(it.trim(),10)).filter(it=>!Number.isNaN(it)):void 0},pe=await Nt("/api/db/persons",K);if(pe&&pe.success===!1){const it=pe;it.ckbResponse&&console.log("存客宝返回",it.ckbResponse);const bt=it.error||"操作失败";throw new Error(bt)}if(Gs(),ie.success(Ia?"已保存":"已添加"),pe!=null&&pe.ckbCreateResult&&Object.keys(pe.ckbCreateResult).length>0){const it=pe.ckbCreateResult;console.log("存客宝创建结果",it);const bt=it.planId??it.id,sn=bt!=null?[`planId: ${bt}`]:[];it.apiKey!=null&&sn.push("apiKey: ***"),ie.info(sn.length?`存客宝创建结果:${sn.join(",")}`:"存客宝创建结果见控制台")}}})]})}const mi={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 pw(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):mi.stats}function mw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):mi.highlights}function nV(){const[t,e]=v.useState(mi),[n,r]=v.useState(!0),[i,a]=v.useState(!1),[o,c]=v.useState(!1),u=v.useRef(null);v.useEffect(()=>{Le("/api/admin/author-settings").then(N=>{const C=N==null?void 0:N.data;C&&typeof C=="object"&&e({name:String(C.name??mi.name),avatar:String(C.avatar??mi.avatar),avatarImg:String(C.avatarImg??""),title:String(C.title??mi.title),bio:String(C.bio??mi.bio),stats:pw(C.stats).length?pw(C.stats):mi.stats,highlights:mw(C.highlights).length?mw(C.highlights):mi.highlights})}).catch(console.error).finally(()=>r(!1))},[]);const h=async()=>{a(!0);try{const N={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",N);if(!C||C.success===!1){ie.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:""));return}a(!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(N){console.error(N),ie.error("保存失败: "+(N instanceof Error?N.message:String(N)))}finally{a(!1)}},f=async N=>{var E;const C=(E=N.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 I=Ox(),O={};I&&(O.Authorization=`Bearer ${I}`);const P=await(await fetch(ho("/api/upload"),{method:"POST",body:M,credentials:"include",headers:O})).json();P!=null&&P.success&&(P!=null&&P.url)?e(L=>({...L,avatarImg:P.url})):ie.error("上传失败: "+((P==null?void 0:P.error)||"未知错误"))}catch(M){console.error(M),ie.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(N=>({...N,stats:[...N.stats,{label:"",value:""}]})),g=N=>e(C=>({...C,stats:C.stats.filter((E,M)=>M!==N)})),y=(N,C,E)=>e(M=>({...M,stats:M.stats.map((I,O)=>O===N?{...I,[C]:E}:I)})),b=()=>e(N=>({...N,highlights:[...N.highlights,""]})),j=N=>e(C=>({...C,highlights:C.highlights.filter((E,M)=>M!==N)})),w=(N,C)=>e(E=>({...E,highlights:E.highlights.map((M,I)=>I===N?C:M)}));return n?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(yl,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(ee,{onClick:h,disabled:i||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"flex items-center gap-2 text-white",children:[s.jsx(yl,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx($t,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"姓名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:N=>e(C=>({...C,name:N.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:N=>e(C=>({...C,avatar:N.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Uw,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:N=>e(C=>({...C,avatarImg:N.target.value})),placeholder:"上传或粘贴 URL,如 /uploads/avatars/xxx.png"}),s.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var N;return(N=u.current)==null?void 0:N.click()},children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:t.avatarImg.startsWith("http")?t.avatarImg:ho(t.avatarImg),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"头衔"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:N=>e(C=>({...C,title:N.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"个人简介"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:N=>e(C=>({...C,bio:N.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsx(rt,{className:"text-white",children:"统计数据"}),s.jsx($t,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs(Ae,{className:"space-y-3",children:[t.stats.map((N,C)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:N.label,onChange:E=>y(C,"label",E.target.value),placeholder:"标签"}),s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:N.value,onChange:E=>y(C,"value",E.target.value),placeholder:"数值"}),s.jsx(ee,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(C),children:s.jsx(hr,{className:"w-4 h-4"})})]},C)),s.jsxs(ee,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsx(rt,{className:"text-white",children:"亮点标签"}),s.jsx($t,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(Ae,{className:"space-y-3",children:[t.highlights.map((N,C)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:N,onChange:E=>w(C,E.target.value),placeholder:"5年私域运营经验"}),s.jsx(ee,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>j(C),children:s.jsx(hr,{className:"w-4 h-4"})})]},C)),s.jsxs(ee,{variant:"outline",size:"sm",onClick:b,className:"border-gray-600 text-gray-400",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function rV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o]=v.useState(10),[c,u]=v.useState(0),[h,f]=v.useState(""),m=Yx(h,300),[g,y]=v.useState(!0),[b,j]=v.useState(null),[w,N]=v.useState(!1),[C,E]=v.useState(null),[M,I]=v.useState(""),[O,D]=v.useState(""),[P,L]=v.useState(""),[_,X]=v.useState("admin"),[ne,J]=v.useState("active"),[U,R]=v.useState(!1);async function F(){var H;y(!0),j(null);try{const ce=new URLSearchParams({page:String(i),pageSize:String(o)});m.trim()&&ce.set("search",m.trim());const W=await Le(`/api/admin/users?${ce}`);W!=null&&W.success?(e(W.records||[]),r(W.total??0),u(W.totalPages??0)):j(W.error||"加载失败")}catch(ce){const W=ce;j(W.status===403?"无权限访问":((H=W==null?void 0:W.data)==null?void 0:H.error)||"加载失败"),e([])}finally{y(!1)}}v.useEffect(()=>{F()},[i,o,m]);const re=()=>{E(null),I(""),D(""),L(""),X("admin"),J("active"),N(!0)},z=H=>{E(H),I(H.username),D(""),L(H.name||""),X(H.role==="super_admin"?"super_admin":"admin"),J(H.status==="disabled"?"disabled":"active"),N(!0)},ae=async()=>{var H;if(!M.trim()){j("用户名不能为空");return}if(!C&&!O){j("新建时密码必填,至少 6 位");return}if(O&&O.length<6){j("密码至少 6 位");return}j(null),R(!0);try{if(C){const ce=await Mt("/api/admin/users",{id:C.id,password:O||void 0,name:P.trim(),role:_,status:ne});ce!=null&&ce.success?(N(!1),F()):j((ce==null?void 0:ce.error)||"保存失败")}else{const ce=await Nt("/api/admin/users",{username:M.trim(),password:O,name:P.trim(),role:_});ce!=null&&ce.success?(N(!1),F()):j((ce==null?void 0:ce.error)||"保存失败")}}catch(ce){const W=ce;j(((H=W==null?void 0:W.data)==null?void 0:H.error)||"保存失败")}finally{R(!1)}},G=async H=>{var ce;if(confirm("确定删除该管理员?"))try{const W=await Ps(`/api/admin/users?id=${H}`);W!=null&&W.success?F():j((W==null?void 0:W.error)||"删除失败")}catch(W){const fe=W;j(((ce=fe==null?void 0:fe.data)==null?void 0:ce.error)||"删除失败")}},$=H=>{if(!H)return"-";try{const ce=new Date(H);return isNaN(ce.getTime())?H:ce.toLocaleString("zh-CN")}catch{return H}};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Rx,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{placeholder:"搜索用户名/昵称",value:h,onChange:H=>f(H.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(ee,{variant:"outline",size:"sm",onClick:F,disabled:g,className:"border-gray-600 text-gray-300",children:s.jsx(Ge,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),s.jsxs(ee,{onClick:re,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),b&&s.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:[s.jsx("span",{children:b}),s.jsx("button",{type:"button",onClick:()=>j(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:g?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户名"}),s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"角色"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(H=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:H.id}),s.jsx(xe,{className:"text-white font-medium",children:H.username}),s.jsx(xe,{className:"text-gray-400",children:H.name||"-"}),s.jsx(xe,{children:s.jsx(Ue,{variant:"outline",className:H.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:H.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(xe,{children:s.jsx(Ue,{variant:"outline",className:H.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:H.status==="active"?"正常":"已禁用"})}),s.jsx(xe,{className:"text-gray-500 text-sm",children:$(H.createdAt)}),s.jsxs(xe,{className:"text-right",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>z(H),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>G(H.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Bn,{className:"w-4 h-4"})})]})]},H.id)),t.length===0&&!g&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:b==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&s.jsx("div",{className:"p-4 border-t border-gray-700/50",children:s.jsx(gs,{page:i,pageSize:o,total:n,totalPages:c,onPageChange:a})})]})})}),s.jsx(Kt,{open:w,onOpenChange:N,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:C?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"用户名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:M,onChange:H=>I(H.target.value),disabled:!!C}),C&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:C?"新密码(留空不改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:C?"留空表示不修改":"至少 6 位",value:O,onChange:H=>D(H.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:P,onChange:H=>L(H.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:_,onChange:H=>X(H.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"admin",children:"管理员"}),s.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),C&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:ne,onChange:H=>J(H.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"active",children:"正常"}),s.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>N(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:ae,disabled:U,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),U?"保存中...":"保存"]})]})]})})]})}const sV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},iV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},aV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...iV},ckbLeadApiKey:""},oV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},lV=["system","author","admin"];function cV(){const[t,e]=zw(),n=t.get("tab")??"system",r=lV.includes(n)?n:"system",[i,a]=v.useState(aV),[o,c]=v.useState(oV),[u,h]=v.useState(sV),[f,m]=v.useState(!1),[g,y]=v.useState(!0),[b,j]=v.useState(!1),[w,N]=v.useState(""),[C,E]=v.useState(""),[M,I]=v.useState(!1),[O,D]=v.useState(!1),P=(J,U,R=!1)=>{N(J),E(U),I(R),j(!0)};v.useEffect(()=>{(async()=>{try{const U=await Le("/api/admin/settings");if(!U||U.success===!1)return;if(U.featureConfig&&Object.keys(U.featureConfig).length&&c(R=>({...R,...U.featureConfig})),U.mpConfig&&typeof U.mpConfig=="object"&&h(R=>({...R,...U.mpConfig})),U.siteSettings&&typeof U.siteSettings=="object"){const R=U.siteSettings;a(F=>({...F,...typeof R.sectionPrice=="number"&&{sectionPrice:R.sectionPrice},...typeof R.baseBookPrice=="number"&&{baseBookPrice:R.baseBookPrice},...typeof R.distributorShare=="number"&&{distributorShare:R.distributorShare},...R.authorInfo&&typeof R.authorInfo=="object"&&{authorInfo:{...F.authorInfo,...R.authorInfo}},...typeof R.ckbLeadApiKey=="string"&&{ckbLeadApiKey:R.ckbLeadApiKey}}))}}catch(U){console.error("Load settings error:",U)}finally{y(!1)}})()},[]);const L=async(J,U)=>{D(!0);try{const R=await Nt("/api/admin/settings",{featureConfig:J});if(!R||R.success===!1){U(),P("保存失败",(R==null?void 0:R.error)??"未知错误",!0);return}P("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(R){console.error("Save feature config error:",R),U(),P("保存失败",R instanceof Error?R.message:String(R),!0)}finally{D(!1)}},_=(J,U)=>{const R=o,F={...R,[J]:U};c(F),L(F,()=>c(R))},X=async()=>{m(!0);try{const J=await Nt("/api/admin/settings",{featureConfig:o,siteSettings:{sectionPrice:i.sectionPrice,baseBookPrice:i.baseBookPrice,distributorShare:i.distributorShare,authorInfo:i.authorInfo,ckbLeadApiKey:i.ckbLeadApiKey||void 0},mpConfig:{...u,appId:u.appId||"",withdrawSubscribeTmplId:u.withdrawSubscribeTmplId||"",mchId:u.mchId||"",minWithdraw:typeof u.minWithdraw=="number"?u.minWithdraw:10}});if(!J||J.success===!1){P("保存失败",(J==null?void 0:J.error)??"未知错误",!0);return}P("已保存","设置已保存成功。")}catch(J){console.error("Save settings error:",J),P("保存失败",J instanceof Error?J.message:String(J),!0)}finally{m(!1)}},ne=J=>{e(J==="system"?{}:{tab:J})};return g?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),r==="system"&&s.jsxs(ee,{onClick:X,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),f?"保存中...":"保存设置"]})]}),s.jsxs(fd,{value:r,onValueChange:ne,className:"w-full",children:[s.jsxs(Ll,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(tn,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(so,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(tn,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(jm,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(tn,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(Rx,{className:"w-4 h-4 mr-2"}),"管理员"]})]}),s.jsx(nn,{value:"system",className:"mt-0",children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(jm,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx($t,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(jm,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(oe,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:i.authorInfo.name??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,name:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ih,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(oe,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:i.authorInfo.startDate??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,startDate:J.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ih,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(oe,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:i.authorInfo.liveTime??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,liveTime:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Kw,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(oe,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:i.authorInfo.platform??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,platform:J.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ps,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(oe,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:i.authorInfo.description??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,description:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(_l,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:i.authorInfo.bio??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,bio:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ms,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(oe,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:i.ckbLeadApiKey??"",onChange:J=>a(U=>({...U,ckbLeadApiKey:J.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),s.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:(i.authorInfo.name??"K").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-semibold",children:i.authorInfo.name}),s.jsx("p",{className:"text-gray-400 text-xs",children:i.authorInfo.description}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",i.authorInfo.liveTime," · ",i.authorInfo.platform]})]})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx($t,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx(Ae,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:i.sectionPrice,onChange:J=>a(U=>({...U,sectionPrice:Number.parseFloat(J.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:i.baseBookPrice,onChange:J=>a(U=>({...U,baseBookPrice:Number.parseFloat(J.target.value)||9.9}))})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx($t,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsx(Ae,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:J=>h(U=>({...U,appId:J.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:J=>h(U=>({...U,withdrawSubscribeTmplId:J.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:J=>h(U=>({...U,mchId:J.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:J=>h(U=>({...U,minWithdraw:Number.parseFloat(J.target.value)||10}))})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(so,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx($t,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Un,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),s.jsx(Et,{id:"match-enabled",checked:o.matchEnabled,disabled:O,onCheckedChange:J=>_("matchEnabled",J)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fM,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"})]}),s.jsx(Et,{id:"referral-enabled",checked:o.referralEnabled,disabled:O,onCheckedChange:J=>_("referralEnabled",J)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ps,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页搜索栏的显示"})]}),s.jsx(Et,{id:"search-enabled",checked:o.searchEnabled,disabled:O,onCheckedChange:J=>_("searchEnabled",J)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(so,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),s.jsx(Et,{id:"about-enabled",checked:o.aboutEnabled,disabled:O,onCheckedChange:J=>_("aboutEnabled",J)})]})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]})]})}),s.jsx(nn,{value:"author",className:"mt-0",children:s.jsx(nV,{})}),s.jsx(nn,{value:"admin",className:"mt-0",children:s.jsx(rV,{})})]}),s.jsx(Kt,{open:b,onOpenChange:j,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(qt,{children:[s.jsx(Gt,{className:M?"text-red-400":"text-[#38bdac]",children:w}),s.jsx(Wx,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:C})]}),s.jsx(hn,{className:"mt-4",children:s.jsx(ee,{onClick:()=>j(!1),className:M?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const gw={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 dV(){const[t,e]=v.useState(!1),[n,r]=v.useState(gw),[i,a]=v.useState(""),o=async()=>{e(!0);try{const N=await Le("/api/config");N!=null&&N.paymentMethods&&r({...gw,...N.paymentMethods})}catch(N){console.error(N)}finally{e(!1)}};v.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await Nt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),ie.success("配置已保存!")}catch(N){console.error("保存失败:",N),ie.error("保存失败: "+(N instanceof Error?N.message:String(N)))}finally{e(!1)}},u=(N,C)=>{navigator.clipboard.writeText(N),a(C),setTimeout(()=>a(""),2e3)},h=(N,C)=>{r(E=>({...E,wechat:{...E.wechat,[N]:C}}))},f=(N,C)=>{r(E=>({...E,alipay:{...E.alipay,[N]:C}}))},m=(N,C)=>{r(E=>({...E,usdt:{...E.usdt,[N]:C}}))},g=(N,C)=>{r(E=>({...E,paypal:{...E.paypal,[N]:C}}))},y=n.wechat,b=n.alipay,j=n.usdt,w=n.paypal;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),s.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ee,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(ee,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Bw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),s.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[s.jsx("li",{children:"打开微信,进入目标微信群"}),s.jsx("li",{children:'点击右上角"..." → "群二维码"'}),s.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),s.jsx("li",{children:"在电脑上保存二维码图片,上传到图床获取URL"}),s.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示:微信群二维码7天后失效,建议使用活码工具"})]})]})}),s.jsxs(fd,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Ll,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(tn,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(uo,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(tn,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(Ob,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(tn,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(Rb,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(tn,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(kg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(nn,{value:"wechat",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(Et,{checked:!!y.enabled,onCheckedChange:N=>h("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"网站AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:N=>h("websiteAppId",N.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"商户号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:N=>h("merchantId",N.target.value)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(_s,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:N=>h("qrCode",N.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),s.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[s.jsx(Z,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(oe,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(y.groupQrCode??""),onChange:N=>h("groupQrCode",N.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(nn,{value:"alipay",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(Ob,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx($t,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(Et,{checked:!!b.enabled,onCheckedChange:N=>f("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.partnerId??""),onChange:N=>f("partnerId",N.target.value)}),s.jsx(ee,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(b.partnerId??""),"pid"),children:i==="pid"?s.jsx(df,{className:"w-4 h-4 text-green-500"}):s.jsx(Hw,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.securityKey??""),onChange:N=>f("securityKey",N.target.value)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(_s,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(b.qrCode??""),onChange:N=>f("qrCode",N.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(nn,{value:"usdt",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(Rb,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(Et,{checked:!!j.enabled,onCheckedChange:N=>m("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"网络类型"}),s.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(j.network??"TRC20"),onChange:N=>m("network",N.target.value),children:[s.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),s.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),s.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"收款地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(j.address??""),onChange:N=>m("address",N.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(j.exchangeRate)??7.2,onChange:N=>m("exchangeRate",Number.parseFloat(N.target.value)||7.2)})]})]})]})}),s.jsx(nn,{value:"paypal",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(kg,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(Et,{checked:!!w.enabled,onCheckedChange:N=>g("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(w.email??""),onChange:N=>g("email",N.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:N=>g("exchangeRate",Number(N.target.value)||7.2)})]})]})]})})]})]})}const uV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},hV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},fV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function pV(){const[t,e]=v.useState({siteConfig:{...uV},menuConfig:{...hV},pageConfig:{...fV}}),[n,r]=v.useState(!1),[i,a]=v.useState(!1);v.useEffect(()=>{Le("/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()=>{a(!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:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),ie.success("配置已保存")}catch(f){console.error(f),ie.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{a(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),s.jsxs(ee,{onClick:o,disabled:i,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),i?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(kg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx($t,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(oe,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(oe,{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}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(oe,{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}}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(oe,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(oe,{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}}))})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(sA,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx($t,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx(Ae,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(Z,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(oe,{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}}))}),s.jsx(oe,{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}}))})]})]}),s.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(QM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx($t,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx(Ae,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[s.jsx(Et,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(oe,{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}}}))})]}),s.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(dM,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首页副标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目录页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"我的页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function mV(){const[t,e]=v.useState(""),[n,r]=v.useState(""),[i,a]=v.useState(""),[o,c]=v.useState({}),u=async()=>{var y,b,j,w;try{const N=await Le("/api/config"),C=(b=(y=N==null?void 0:N.liveQRCodes)==null?void 0:y[0])==null?void 0:b.urls;Array.isArray(C)&&e(C.join(` -`));const E=(w=(j=N==null?void 0:N.paymentMethods)==null?void 0:j.wechat)==null?void 0:w.groupQrCode;E&&r(E),c({paymentMethods:N==null?void 0:N.paymentMethods,liveQRCodes:N==null?void 0:N.liveQRCodes})}catch(N){console.error(N)}};v.useEffect(()=>{u()},[]);const h=(y,b)=>{navigator.clipboard.writeText(y),a(b),setTimeout(()=>a(""),2e3)},f=async()=>{try{const y=t.split(` -`).map(j=>j.trim()).filter(Boolean),b=[...o.liveQRCodes||[]];b[0]?b[0].urls=y:b.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Nt("/api/db/config",{key:"live_qr_codes",value:b,description:"群活码配置"}),ie.success("群活码配置已保存!"),await u()}catch(y){console.error(y),ie.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:"支付方式配置"}),ie.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(b){console.error(b),ie.error("保存失败: "+(b instanceof Error?b.message:String(b)))}},g=()=>{n?window.open(n,"_blank"):ie.error("请先配置微信群链接")};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Bw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),s.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[s.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:"访问草料二维码创建活码"}),s.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),s.jsx("li",{children:"复制生成的短链接填入下方配置"}),s.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),s.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),s.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意:微信原生群二维码7天后失效,建议使用草料活码"})]})]})]})}),s.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(Lb,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx($t,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Sg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{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=>r(y.target.value)}),s.jsx(ee,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:i==="group"?s.jsx(df,{className:"w-4 h-4 text-green-500"}):s.jsx(Hw,{className:"w-4 h-4 text-gray-400"})})]}),s.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ee,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(ee,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(_s,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Lb,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx($t,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Sg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(_l,{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)}),s.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),s.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),s.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` -`).filter(Boolean).length," 个"]})]}),s.jsxs(ee,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),s.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[s.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),s.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接,群满后可直接在后台更换新群码,无需修改网站配置。微信原生群码7天失效。"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),s.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const xw={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}},gV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function xV(){const[t,e]=v.useState(xw),[n,r]=v.useState(!0),[i,a]=v.useState(!1),[o,c]=v.useState(!1),[u,h]=v.useState(null),[f,m]=v.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),g=async()=>{r(!0);try{const E=await Le("/api/db/config/full?key=match_config"),M=(E==null?void 0:E.data)??(E==null?void 0:E.config);M&&e({...xw,...M})}catch(E){console.error("加载匹配配置失败:",E)}finally{r(!1)}};v.useEffect(()=>{g()},[]);const y=async()=>{a(!0);try{const E=await Nt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});E&&E.success!==!1?ie.success("配置保存成功!"):ie.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:"未知错误"))}catch(E){console.error("保存配置失败:",E),ie.error("保存失败")}finally{a(!1)}},b=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)},w=()=>{if(!f.id||!f.label){ie.error("请填写类型ID和名称");return}const E=[...t.matchTypes];if(u){const M=E.findIndex(I=>I.id===u.id);M!==-1&&(E[M]={...f})}else{if(E.some(M=>M.id===f.id)){ie.error("类型ID已存在");return}E.push({...f})}e({...t,matchTypes:E}),c(!1)},N=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 s.jsxs("div",{className:"p-8 w-full space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(so,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ee,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(ee,{onClick:y,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ia,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx($t,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ae,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{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})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{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})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{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}})}),s.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:t.settings.enableFreeMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enableFreeMatches:E}})}),s.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:t.settings.enablePaidMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enablePaidMatches:E}})}),s.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx($t,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ee,{onClick:j,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(Ae,{children:s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(tr,{children:t.matchTypes.map(E=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx("span",{className:"text-2xl",children:E.icon})}),s.jsx(xe,{className:"font-mono text-gray-300",children:E.id}),s.jsx(xe,{className:"text-white font-medium",children:E.label}),s.jsx(xe,{className:"text-gray-300",children:E.matchLabel}),s.jsx(xe,{children:s.jsxs(Ue,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",E.price]})}),s.jsx(xe,{children:E.matchFromDB?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ue,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(xe,{children:s.jsx(Et,{checked:E.enabled,onCheckedChange:()=>C(E.id)})}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(E),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>N(E.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},E.id))})]})})]}),s.jsx(Kt,{open:o,onOpenChange:c,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(dn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:E=>m({...f,id:E.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:gV.map(E=>s.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))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:E=>m({...f,label:E.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:E=>m({...f,matchLabel:E.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{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})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.matchFromDB,onCheckedChange:E=>m({...f,matchFromDB:E})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.showJoinAfterMatch,onCheckedChange:E=>m({...f,showJoinAfterMatch:E})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.enabled,onCheckedChange:E=>m({...f,enabled:E})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ee,{onClick:w,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const yw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function yV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(""),[f,m]=v.useState(!0),[g,y]=v.useState(null);async function b(){m(!0),y(null);try{const w=new URLSearchParams({page:String(i),pageSize:String(o)});u&&w.set("matchType",u);const N=await Le(`/api/db/match-records?${w}`);N!=null&&N.success?(e(N.records||[]),r(N.total??0)):y("加载匹配记录失败")}catch(w){console.error("加载匹配记录失败",w),y("加载失败,请检查网络后重试")}finally{m(!1)}}v.useEffect(()=>{b()},[i,u]);const j=Math.ceil(n/o)||1;return s.jsxs("div",{className:"p-8 w-full",children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:w=>{h(w.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(yw).map(([w,N])=>s.jsx("option",{value:w,children:N},w))]}),s.jsxs("button",{type:"button",onClick:b,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:[s.jsx(Ge,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(tr,{children:[t.map(w=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:[w.userAvatar?s.jsx("img",{src:w.userAvatar,alt:"",className:"w-full h-full object-cover",onError:N=>{N.currentTarget.style.display="none";const C=N.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,s.jsx("span",{className:w.userAvatar?"hidden":"",children:(w.userNickname||w.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:w.userNickname||w.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[w.userId.slice(0,16),"..."]})]})]})}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:[w.matchedUserAvatar?s.jsx("img",{src:w.matchedUserAvatar,alt:"",className:"w-full h-full object-cover",onError:N=>{N.currentTarget.style.display="none";const C=N.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,s.jsx("span",{className:w.matchedUserAvatar?"hidden":"",children:(w.matchedNickname||w.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:w.matchedNickname||w.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[w.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(xe,{children:s.jsx(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:yw[w.matchType]||w.matchType})}),s.jsxs(xe,{className:"text-gray-400 text-sm",children:[w.phone&&s.jsxs("div",{children:["📱 ",w.phone]}),w.wechatId&&s.jsxs("div",{children:["💬 ",w.wechatId]}),!w.phone&&!w.wechatId&&"-"]}),s.jsx(xe,{className:"text-gray-400",children:w.createdAt?new Date(w.createdAt).toLocaleString():"-"})]},w.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(gs,{page:i,totalPages:j,total:n,pageSize:o,onPageChange:a,onPageSizeChange:w=>{c(w),a(1)}})]})})})]})}function vV(){const[t,e]=v.useState([]),[n,r]=v.useState(!0);async function i(){r(!0);try{const a=await Le("/api/db/vip-members?limit=100");if(a!=null&&a.success&&a.data){const o=[...a.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(a){console.error("Load VIP members error:",a),ie.error("加载 VIP 成员失败")}finally{r(!1)}}return v.useEffect(()=>{i()},[]),s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("div",{className:"flex justify-between items-center mb-8",children:s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(xl,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(je,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(tr,{children:[t.map((a,o)=>{var c;return s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:o+1}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[a.avatar?s.jsx("img",{src:a.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.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=a.name)==null?void 0:c[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:a.name})})]})}),s.jsx(xe,{className:"text-gray-300",children:a.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(xe,{className:"text-gray-300",children:a.vipSort??o+1})]},a.id)}),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function R4(t){const[e,n]=v.useState([]),[r,i]=v.useState(!0),[a,o]=v.useState(!1),[c,u]=v.useState(null),[h,f]=v.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0}),[m,g]=v.useState(!1),[y,b]=v.useState(!1),j=v.useRef(null),w=async P=>{var _;const L=(_=P.target.files)==null?void 0:_[0];if(L){b(!0);try{const X=new FormData;X.append("file",L),X.append("folder","mentors");const ne=Ox(),J={};ne&&(J.Authorization=`Bearer ${ne}`);const R=await(await fetch(ho("/api/upload"),{method:"POST",body:X,credentials:"include",headers:J})).json();R!=null&&R.success&&(R!=null&&R.url)?f(F=>({...F,avatar:R.url})):ie.error("上传失败: "+((R==null?void 0:R.error)||"未知错误"))}catch(X){console.error(X),ie.error("上传失败")}finally{b(!1),j.current&&(j.current.value="")}}};async function N(){i(!0);try{const P=await Le("/api/db/mentors");P!=null&&P.success&&P.data&&n(P.data)}catch(P){console.error("Load mentors error:",P)}finally{i(!1)}}v.useEffect(()=>{N()},[]);const C=()=>{f({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:e.length>0?Math.max(...e.map(P=>P.sort))+1:0,enabled:!0})},E=()=>{u(null),C(),o(!0)},M=P=>{u(P),f({name:P.name,avatar:P.avatar||"",intro:P.intro||"",tags:P.tags||"",priceSingle:P.priceSingle!=null?String(P.priceSingle):"",priceHalfYear:P.priceHalfYear!=null?String(P.priceHalfYear):"",priceYear:P.priceYear!=null?String(P.priceYear):"",quote:P.quote||"",whyFind:P.whyFind||"",offering:P.offering||"",judgmentStyle:P.judgmentStyle||"",sort:P.sort,enabled:P.enabled??!0}),o(!0)},I=async()=>{if(!h.name.trim()){ie.error("导师姓名不能为空");return}g(!0);try{const P=_=>_===""?void 0:parseFloat(_),L={name:h.name.trim(),avatar:h.avatar.trim()||void 0,intro:h.intro.trim()||void 0,tags:h.tags.trim()||void 0,priceSingle:P(h.priceSingle),priceHalfYear:P(h.priceHalfYear),priceYear:P(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 _=await Mt("/api/db/mentors",{id:c.id,...L});_!=null&&_.success?(o(!1),N()):ie.error("更新失败: "+(_==null?void 0:_.error))}else{const _=await Nt("/api/db/mentors",L);_!=null&&_.success?(o(!1),N()):ie.error("新增失败: "+(_==null?void 0:_.error))}}catch(P){console.error("Save error:",P),ie.error("保存失败")}finally{g(!1)}},O=async P=>{if(confirm("确定删除该导师?"))try{const L=await Ps(`/api/db/mentors?id=${P}`);L!=null&&L.success?N():ie.error("删除失败: "+(L==null?void 0:L.error))}catch(L){console.error("Delete error:",L),ie.error("删除失败")}},D=P=>P!=null?`¥${P}`:"-";return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),s.jsxs(ee,{onClick:E,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:r?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"姓名"}),s.jsx(je,{className:"text-gray-400",children:"简介"}),s.jsx(je,{className:"text-gray-400",children:"单次"}),s.jsx(je,{className:"text-gray-400",children:"半年"}),s.jsx(je,{className:"text-gray-400",children:"年度"}),s.jsx(je,{className:"text-gray-400",children:"排序"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[e.map(P=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:P.id}),s.jsx(xe,{className:"text-white",children:P.name}),s.jsx(xe,{className:"text-gray-400 max-w-[200px] truncate",children:P.intro||"-"}),s.jsx(xe,{className:"text-gray-400",children:D(P.priceSingle)}),s.jsx(xe,{className:"text-gray-400",children:D(P.priceHalfYear)}),s.jsx(xe,{className:"text-gray-400",children:D(P.priceYear)}),s.jsx(xe,{className:"text-gray-400",children:P.sort}),s.jsxs(xe,{className:"text-right",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>M(P),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>O(P.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Bn,{className:"w-4 h-4"})})]})]},P.id)),e.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Kt,{open:a,onOpenChange:o,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:c?"编辑导师":"新增导师"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"姓名 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:h.name,onChange:P=>f(L=>({...L,name:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"排序"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:h.sort,onChange:P=>f(L=>({...L,sort:parseInt(P.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:h.avatar,onChange:P=>f(L=>({...L,avatar:P.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:w}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:y,onClick:()=>{var P;return(P=j.current)==null?void 0:P.click()},children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),y?"上传中...":"上传"]})]}),h.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:h.avatar.startsWith("http")?h.avatar:ho(h.avatar),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"简介"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:h.intro,onChange:P=>f(L=>({...L,intro:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:h.tags,onChange:P=>f(L=>({...L,tags:P.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(Z,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:h.priceSingle,onChange:P=>f(L=>({...L,priceSingle:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:h.priceHalfYear,onChange:P=>f(L=>({...L,priceHalfYear:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:h.priceYear,onChange:P=>f(L=>({...L,priceYear:P.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"引言"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:h.quote,onChange:P=>f(L=>({...L,quote:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.whyFind,onChange:P=>f(L=>({...L,whyFind:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.offering,onChange:P=>f(L=>({...L,offering:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:h.judgmentStyle,onChange:P=>f(L=>({...L,judgmentStyle:P.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:h.enabled,onChange:P=>f(L=>({...L,enabled:P.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(Z,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>o(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:I,disabled:m,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),m?"保存中...":"保存"]})]})]})})]})}function bV(){const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState("");async function o(){r(!0);try{const h=i?`/api/db/mentor-consultations?status=${i}`:"/api/db/mentor-consultations",f=await Le(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}v.useEffect(()=>{o()},[i]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(ih,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:i,onChange:h=>a(h.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>s.jsx("option",{value:h,children:f},h))]}),s.jsxs(ee,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(tr,{children:[t.map(h=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:h.id}),s.jsx(xe,{className:"text-gray-400",children:h.userId}),s.jsx(xe,{className:"text-gray-400",children:h.mentorId}),s.jsx(xe,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(xe,{className:"text-white",children:["¥",h.amount]}),s.jsx(xe,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(xe,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const Pc={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},vw={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:Pc},NV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function wV(){const t=ja(),[e,n]=v.useState(vw),[r,i]=v.useState(!0),[a,o]=v.useState(!1),[c,u]=v.useState(!1),[h,f]=v.useState(null),[m,g]=v.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,b]=v.useState(null),[j,w]=v.useState(!1),N=async()=>{w(!0);try{const L=await Le("/api/db/match-pool-counts");L!=null&&L.success&&L.data&&b(L.data)}catch(L){console.error("加载池子人数失败:",L)}finally{w(!1)}},C=async()=>{i(!0);try{const L=await Le("/api/db/config/full?key=match_config"),_=(L==null?void 0:L.data)??(L==null?void 0:L.config);if(_){let X=_.poolSettings??Pc;X.poolSource&&!Array.isArray(X.poolSource)&&(X={...X,poolSource:[X.poolSource]}),n({...vw,..._,poolSettings:X})}}catch(L){console.error("加载匹配配置失败:",L)}finally{i(!1)}};v.useEffect(()=>{C(),N()},[]);const E=async()=>{o(!0);try{const L=await Nt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});ie.error((L==null?void 0:L.success)!==!1?"配置保存成功!":"保存失败: "+((L==null?void 0:L.error)||"未知错误"))}catch(L){console.error(L),ie.error("保存失败")}finally{o(!1)}},M=L=>{f(L),g({...L}),u(!0)},I=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},O=()=>{if(!m.id||!m.label){ie.error("请填写类型ID和名称");return}const L=[...e.matchTypes];if(h){const _=L.findIndex(X=>X.id===h.id);_!==-1&&(L[_]={...m})}else{if(L.some(_=>_.id===m.id)){ie.error("类型ID已存在");return}L.push({...m})}n({...e,matchTypes:L}),u(!1)},D=L=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(_=>_.id!==L)})},P=L=>{n({...e,matchTypes:e.matchTypes.map(_=>_.id===L?{..._,enabled:!_.enabled}:_)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(ee,{variant:"outline",onClick:C,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(ee,{onClick:E,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"})," ",a?"保存中...":"保存配置"]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ww,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx($t,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs(Ae,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配来源池"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),s.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(L=>{const _=e.poolSettings??Pc,ne=(Array.isArray(_.poolSource)?_.poolSource:[_.poolSource]).includes(L.value),J=y==null?void 0:y[L.countKey],U=()=>{const R=Array.isArray(_.poolSource)?[..._.poolSource]:[_.poolSource],F=ne?R.filter(re=>re!==L.value):[...R,L.value];F.length===0&&F.push(L.value),n({...e,poolSettings:{..._,poolSource:F}})};return s.jsxs("button",{type:"button",onClick:U,className:`p-4 rounded-lg border text-left transition-all ${ne?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${ne?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:ne&&"✓"}),s.jsx("span",{className:"text-xl",children:L.icon}),s.jsx("span",{className:`text-sm font-medium ${ne?"text-[#38bdac]":"text-gray-300"}`,children:L.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[j?"...":J??"-",s.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:L.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:R=>{R.stopPropagation(),t(`/users?pool=${L.value}`)},onKeyDown:R=>{R.key==="Enter"&&(R.stopPropagation(),t(`/users?pool=${L.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},L.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(Z,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),s.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(L=>{const X=(e.poolSettings??Pc)[L.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(Et,{checked:X,onCheckedChange:ne=>n({...e,poolSettings:{...e.poolSettings??Pc,[L.key]:ne}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:L.icon}),s.jsx(Z,{className:"text-gray-300 text-sm",children:L.label})]})]},L.key)})})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ia,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx($t,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ae,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:L=>n({...e,freeMatchLimit:parseInt(L.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:L=>n({...e,matchPrice:parseFloat(L.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:L=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(L.target.value,10)||10}})})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:e.settings.enableFreeMatches,onCheckedChange:L=>n({...e,settings:{...e.settings,enableFreeMatches:L}})}),s.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:e.settings.enablePaidMatches,onCheckedChange:L=>n({...e,settings:{...e.settings,enablePaidMatches:L}})}),s.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx($t,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ee,{onClick:I,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(Ae,{children:s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(tr,{children:e.matchTypes.map(L=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx("span",{className:"text-2xl",children:L.icon})}),s.jsx(xe,{className:"font-mono text-gray-300",children:L.id}),s.jsx(xe,{className:"text-white font-medium",children:L.label}),s.jsx(xe,{className:"text-gray-300",children:L.matchLabel}),s.jsx(xe,{children:s.jsxs(Ue,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",L.price]})}),s.jsx(xe,{children:L.matchFromDB?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ue,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(xe,{children:s.jsx(Et,{checked:L.enabled,onCheckedChange:()=>P(L.id)})}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>M(L),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>D(L.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},L.id))})]})})]}),s.jsx(Kt,{open:c,onOpenChange:u,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(dn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:L=>g({...m,id:L.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:NV.map(L=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===L?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:L}),children:L},L))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:L=>g({...m,label:L.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:L=>g({...m,matchLabel:L.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:L=>g({...m,price:parseFloat(L.target.value)||1})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.matchFromDB,onCheckedChange:L=>g({...m,matchFromDB:L})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.showJoinAfterMatch,onCheckedChange:L=>g({...m,showJoinAfterMatch:L})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.enabled,onCheckedChange:L=>g({...m,enabled:L})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ee,{onClick:O,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const bw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function jV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(""),[f,m]=v.useState(!0),[g,y]=v.useState(null),[b,j]=v.useState(null);async function w(){m(!0),y(null);try{const E=new URLSearchParams({page:String(i),pageSize:String(o)});u&&E.set("matchType",u);const M=await Le(`/api/db/match-records?${E}`);M!=null&&M.success?(e(M.records||[]),r(M.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}v.useEffect(()=>{w()},[i,u]);const N=Math.ceil(n/o)||1,C=({userId:E,nickname:M,avatar:I})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>j(E),children:[s.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:[I?s.jsx("img",{src:I,alt:"",className:"w-full h-full object-cover",onError:O=>{O.currentTarget.style.display="none"}}):null,s.jsx("span",{className:I?"hidden":"",children:(M||E||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:M||E}),s.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 s.jsxs("div",{children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:E=>{h(E.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(bw).map(([E,M])=>s.jsx("option",{value:E,children:M},E))]}),s.jsxs("button",{type:"button",onClick:w,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:[s.jsx(Ge,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(tr,{children:[t.map(E=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx(C,{userId:E.userId,nickname:E.userNickname,avatar:E.userAvatar})}),s.jsx(xe,{children:E.matchedUserId?s.jsx(C,{userId:E.matchedUserId,nickname:E.matchedNickname,avatar:E.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(xe,{children:s.jsx(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:bw[E.matchType]||E.matchType})}),s.jsxs(xe,{className:"text-sm",children:[E.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&s.jsx("span",{className:"text-gray-600",children:"-"})]}),s.jsx(xe,{className:"text-gray-400",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"})]},E.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(gs,{page:i,totalPages:N,total:n,pageSize:o,onPageChange:a,onPageSizeChange:E=>{c(E),a(1)}})]})})}),s.jsx(Jx,{open:!!b,onClose:()=>j(null),userId:b,onUserUpdated:w})]})}function kV(){const[t,e]=v.useState("records");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"匹配记录"}),s.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"&&s.jsx(jV,{}),t==="pool"&&s.jsx(wV,{})]})}const Nw={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function SV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(!0),[f,m]=v.useState("investor"),[g,y]=v.useState(null);async function b(){h(!0);try{const C=new URLSearchParams({page:String(i),pageSize:String(o),matchType:f}),E=await Le(`/api/db/match-records?${C}`);E!=null&&E.success&&(e(E.records||[]),r(E.total??0))}catch(C){console.error(C)}finally{h(!1)}}v.useEffect(()=>{b()},[i,f]);const j=async C=>{if(!C.phone&&!C.wechatId){ie.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||""});ie.error((E==null?void 0:E.message)||(E!=null&&E.success?"推送成功":"推送失败"))}catch(E){ie.error("推送失败: "+(E instanceof Error?E.message:"网络错误"))}finally{y(null)}},w=Math.ceil(n/o)||1,N=C=>!!(C.phone||C.wechatId);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("select",{value:f,onChange:C=>{m(C.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(Nw).map(([C,E])=>s.jsx("option",{value:C,children:E},C))}),s.jsxs(ee,{onClick:b,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"}),s.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(C=>{var E,M;return s.jsxs(st,{className:`border-gray-700/50 ${N(C)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(xe,{className:"text-white",children:C.userNickname||((E=C.userId)==null?void 0:E.slice(0,12))}),s.jsx(xe,{className:"text-white",children:C.matchedNickname||((M=C.matchedUserId)==null?void 0:M.slice(0,12))}),s.jsx(xe,{children:s.jsx(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Nw[C.matchType]||C.matchType})}),s.jsxs(xe,{className:"text-sm",children:[C.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(xe,{className:"text-gray-400 text-sm",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"}),s.jsx(xe,{className:"text-right",children:N(C)?s.jsxs(ee,{size:"sm",onClick:()=>j(C),disabled:g===C.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(jA,{className:"w-3 h-3 mr-1"}),g===C.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},C.id)}),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(gs,{page:i,totalPages:w,total:n,pageSize:o,onPageChange:a,onPageSizeChange:C=>{c(C),a(1)}})]})})})]})}const ww={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},CV={single:"单次",half_year:"半年",year:"年度"};function EV(){const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState("");async function o(){r(!0);try{const c=i?`/api/db/mentor-consultations?status=${i}`:"/api/db/mentor-consultations",u=await Le(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return v.useEffect(()=>{o()},[i]),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:i,onChange:c=>a(c.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(ww).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(ee,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(tr,{children:[t.map(c=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:c.id}),s.jsx(xe,{className:"text-gray-400",children:c.userId}),s.jsx(xe,{className:"text-gray-400",children:c.mentorId}),s.jsx(xe,{className:"text-gray-400",children:CV[c.consultationType]||c.consultationType}),s.jsxs(xe,{className:"text-white",children:["¥",c.amount]}),s.jsx(xe,{className:"text-gray-400",children:ww[c.status]||c.status}),s.jsx(xe,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function TV(){const[t,e]=v.useState("booking");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"预约记录"}),s.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"&&s.jsx(EV,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(R4,{embedded:!0})})]})}function MV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(!0);async function f(){h(!0);try{const g=new URLSearchParams({page:String(i),pageSize:String(o),matchType:"team"}),y=await Le(`/api/db/match-records?${g}`);y!=null&&y.success&&(e(y.records||[]),r(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}v.useEffect(()=>{f()},[i]);const m=Math.ceil(n/o)||1;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),s.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),s.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:[s.jsx(Ge,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(tr,{children:[t.map(g=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{className:"text-white",children:g.userNickname||g.userId}),s.jsx(xe,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),s.jsxs(xe,{className:"text-gray-400 text-sm",children:[g.phone&&s.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&s.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),s.jsx(xe,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(gs,{page:i,totalPages:m,total:n,pageSize:o,onPageChange:a,onPageSizeChange:g=>{c(g),a(1)}})]})})})]})}const jw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"},kw={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮"};function AV({onSwitchTab:t,onOpenCKB:e}={}){const n=ja(),[r,i]=v.useState(null),[a,o]=v.useState(null),[c,u]=v.useState(!0),h=v.useCallback(async()=>{var m,g;u(!0);try{const[y,b]=await Promise.allSettled([Le("/api/db/match-records?stats=true"),Le("/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 w=await Le("/api/db/match-records?page=1&pageSize=200");if(w!=null&&w.success&&w.records){const N=new Set(w.records.map(C=>C.userId).filter(Boolean));j={...j,uniqueUsers:N.size}}}catch{}i(j)}b.status==="fulfilled"&&((g=b.value)!=null&&g.success)&&b.value.data&&o(b.value.data)}catch(y){console.error("加载统计失败:",y)}finally{u(!1)}},[]);v.useEffect(()=>{h()},[h]);const f=m=>c?"—":String(m??0);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"})," 找伙伴数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",children:[s.jsx(Me,{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:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"总匹配次数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.totalMatches)}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-3 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," 查看匹配记录"]})]})}),s.jsx(Me,{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:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"今日匹配"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.todayMatches)}),s.jsxs("p",{className:"text-yellow-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(ia,{className:"w-3 h-3"})," 今日实时"]})]})}),s.jsx(Me,{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:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"匹配用户数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.uniqueUsers)}),s.jsxs("p",{className:"text-blue-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," 查看用户管理"]})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"人均匹配"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":r!=null&&r.uniqueUsers?(r.totalMatches/r.uniqueUsers).toFixed(1):"0"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"付费匹配次数"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:f(r==null?void 0:r.paidMatchCount)})]})})]})]}),(r==null?void 0:r.byType)&&r.byType.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"各类型匹配分布"}),s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:r.byType.map(m=>{const g=r.totalMatches>0?m.count/r.totalMatches*100:0;return s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/40 rounded-xl p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("span",{className:"text-2xl",children:kw[m.matchType]||"📊"}),s.jsx("span",{className:"text-gray-300 font-medium",children:jw[m.matchType]||m.matchType})]}),s.jsx("p",{className:"text-3xl font-bold text-white mb-2",children:m.count}),s.jsx("div",{className:"w-full h-2 bg-gray-700/50 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full transition-all",style:{width:`${Math.min(g,100)}%`}})}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1.5",children:[g.toFixed(1),"%"]})]},m.matchType)})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx(ms,{className:"w-5 h-5 text-orange-400"})," AI 获客数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5 mb-6",children:[s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.ckbTotal)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("contact"),children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.withContact)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("test"),children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"AI 添加进度"}),s.jsx("p",{className:"text-xl font-bold text-orange-400",children:"查看详情 →"}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"添加成功率 · 回复率 · API 文档"})]})})]}),(a==null?void 0:a.byType)&&a.byType.length>0&&s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:a.byType.map(m=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-lg p-4 flex items-center gap-3",children:[s.jsx("span",{className:"text-xl",children:kw[m.matchType]||"📋"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-xs",children:jw[m.matchType]||m.matchType}),s.jsx("p",{className:"text-xl font-bold text-white",children:m.total})]})]},m.matchType))})]})]})}const IV=["partner","investor","mentor","team"],gg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Sw=`# 场景获客接口摘要 -- 地址:POST /v1/api/scenarios -- 必填:apiKey、sign、timestamp -- 主标识:phone 或 wechatId 至少一项 -- 可选:name、source、remark、tags、siteTags、portrait -- 签名:排除 sign/apiKey/portrait,键名升序拼接值后双重 MD5 -- 成功:code=200,message=新增成功 或 已存在`;function RV({initialTab:t="overview"}){const[e,n]=v.useState(t),[r,i]=v.useState("13800000000"),[a,o]=v.useState(""),[c,u]=v.useState(""),[h,f]=v.useState(Sw),[m,g]=v.useState(!1),[y,b]=v.useState(!1),[j,w]=v.useState([]),[N,C]=v.useState([]),[E,M]=v.useState({}),[I,O]=v.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"}]),D=v.useMemo(()=>{const R={};return gg.forEach(F=>{R[F.key]=E[F.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),R},[E]),P=R=>{const F=r.trim(),re=a.trim();return R<=3?{type:IV[R],phone:F||void 0,wechat:re||void 0,userId:"admin_test",name:"后台测试"}:R===4?{matchType:"partner",phone:F||void 0,wechat:re||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:R===5?{phone:F||void 0,wechatId:re||void 0,userId:"admin_test",name:"后台测试"}:{}};async function L(){b(!0);try{const[R,F,re]=await Promise.all([Le("/api/db/config/full?key=ckb_config"),Le("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Le("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),z=R==null?void 0:R.data;z!=null&&z.routes&&M(z.routes),z!=null&&z.docNotes&&u(z.docNotes),z!=null&&z.docContent&&f(z.docContent),F!=null&&F.success&&w(F.records||[]),re!=null&&re.success&&C(re.records||[])}finally{b(!1)}}v.useEffect(()=>{n(t)},[t]),v.useEffect(()=>{L()},[]);async function _(){g(!0);try{const R=await Nt("/api/db/config",{key:"ckb_config",value:{routes:D,docNotes:c,docContent:h},description:"存客宝接口配置"});ie.error((R==null?void 0:R.success)!==!1?"存客宝配置已保存":`保存失败: ${(R==null?void 0:R.error)||"未知错误"}`)}catch(R){ie.error(`保存失败: ${R instanceof Error?R.message:"网络错误"}`)}finally{g(!1)}}const X=(R,F)=>{M(re=>({...re,[R]:{...D[R],...F}}))},ne=async R=>{const F=I[R];if(F.method==="POST"&&!r.trim()&&!a.trim()){ie.error("请填写测试手机号");return}const re=[...I];re[R]={...F,status:"testing",message:void 0,responseTime:void 0},O(re);const z=performance.now();try{const ae=F.method==="GET"?await Le(F.endpoint):await Nt(F.endpoint,P(R)),G=Math.round(performance.now()-z),$=(ae==null?void 0:ae.message)||"",H=(ae==null?void 0:ae.success)===!0||$.includes("已存在")||$.includes("已加入")||$.includes("已提交"),ce=[...I];ce[R]={...F,status:H?"success":"error",message:$||(H?"正常":"异常"),responseTime:G},O(ce),await L()}catch(ae){const G=Math.round(performance.now()-z),$=[...I];$[R]={...F,status:"error",message:ae instanceof Error?ae.message:"失败",responseTime:G},O($)}},J=async()=>{if(!r.trim()&&!a.trim()){ie.error("请填写测试手机号");return}for(let R=0;Rs.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),s.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),s.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),s.jsx("tbody",{children:R.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:F})}):R.map(re=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:re.userNickname||re.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:re.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:re.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:re.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:re.createdAt?new Date(re.createdAt).toLocaleString():"—"})]},re.id))})]})});return s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs(Ae,{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),s.jsx(Ue,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),s.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ee,{onClick:()=>L(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),s.jsxs(ee,{onClick:_,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),s.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([R,F])=>s.jsx("button",{type:"button",onClick:()=>n(R),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===R?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:F},R))}),e==="overview"&&s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:j.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:N.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:gg.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),s.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&U(j,"暂无已提交线索"),e==="contact"&&U(N,"暂无有联系方式线索"),e==="config"&&s.jsx("div",{className:"space-y-4",children:gg.map(R=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white font-medium",children:R.label}),s.jsx(Ue,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:R.key})]}),s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].apiUrl,onChange:F=>X(R.key,{apiUrl:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].apiKey,onChange:F=>X(R.key,{apiKey:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].source,onChange:F=>X(R.key,{source:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].tags,onChange:F=>X(R.key,{tags:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].siteTags,onChange:F=>X(R.key,{siteTags:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].notes,onChange:F=>X(R.key,{notes:F.target.value})})]})]})]},R.key))}),e==="test"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex gap-3 mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(uo,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:R=>i(R.target.value)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:a,onChange:R=>o(R.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(ee,{onClick:J,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(ia,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:I.map((R,F)=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[R.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),R.status==="testing"&&s.jsx(Ge,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),R.status==="success"&&s.jsx(wg,{className:"w-3 h-3 text-green-400 shrink-0"}),R.status==="error"&&s.jsx(Vw,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:R.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[R.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[R.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>ne(F),disabled:R.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${R.endpoint}-${F}`))})]}),e==="doc"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),s.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:[s.jsx(_s,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Sw})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),s.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:R=>u(R.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const PV=[{id:"stats",label:"数据统计",icon:zT},{id:"partner",label:"找伙伴",icon:Un},{id:"resource",label:"资源对接",icon:NM},{id:"mentor",label:"导师预约",icon:yM},{id:"team",label:"团队招募",icon:Eg}];function OV(){const[t,e]=v.useState("stats"),[n,r]=v.useState(!1),[i,a]=v.useState("overview");return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-6 h-6 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"数据统计、匹配池与记录、资源对接、导师预约、团队招募"})]}),s.jsxs(ee,{type:"button",variant:"outline",onClick:()=>r(o=>!o),className:"border-orange-500/40 text-orange-300 hover:bg-orange-500/10 bg-transparent",children:[s.jsx(ms,{className:"w-4 h-4 mr-2"}),"存客宝"]})]}),n&&s.jsx(RV,{initialTab:i}),s.jsx("div",{className:"flex flex-wrap gap-1 mb-6 bg-[#0f2137] rounded-lg p-1 border border-gray-700/50",children:PV.map(o=>{const c=t===o.id;return s.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:[s.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id)})}),t==="stats"&&s.jsx(AV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{a(o||"overview"),r(!0)}}),t==="partner"&&s.jsx(kV,{}),t==="resource"&&s.jsx(SV,{}),t==="mentor"&&s.jsx(TV,{}),t==="team"&&s.jsx(MV,{})]})}function DV(){return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[s.jsx(ms,{className:"w-8 h-8 text-[#38bdac]"}),s.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"})]}),s.jsx("p",{className:"text-gray-400 mb-6",children:"API 风格:RESTful · 版本 v1.0 · 基础路径 /api · 简单、清晰、易用。"}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"1. 接口总览"})}),s.jsxs(Ae,{className:"space-y-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"接口分类"}),s.jsxs("ul",{className:"space-y-1 text-gray-300 font-mono",children:[s.jsx("li",{children:"/api/book — 书籍内容(章节列表、内容获取、同步)"}),s.jsx("li",{children:"/api/miniprogram/upload — 小程序上传(图片/视频、图片压缩)"}),s.jsx("li",{children:"/api/admin/content/upload — 管理端内容导入"}),s.jsx("li",{children:"/api/payment — 支付系统(订单创建、回调、状态查询)"}),s.jsx("li",{children:"/api/referral — 分销系统(邀请码、收益、提现)"}),s.jsx("li",{children:"/api/user — 用户系统(登录、注册、信息更新)"}),s.jsx("li",{children:"/api/match — 匹配系统(寻找匹配、匹配历史)"}),s.jsx("li",{children:"/api/admin — 管理后台(内容/订单/用户/分销管理)"}),s.jsx("li",{children:"/api/config — 配置系统"})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"认证方式"}),s.jsx("p",{className:"text-gray-300",children:"用户:Cookie session_id(可选)"}),s.jsx("p",{className:"text-gray-300",children:"管理端:Authorization: Bearer admin-token-secret"})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"2. 书籍内容"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET /api/book/all-chapters — 获取所有章节"}),s.jsx("p",{children:"GET /api/book/chapter/:id — 获取单章内容"}),s.jsx("p",{children:"POST /api/book/sync — 同步章节(需管理员认证)"})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"2.1 小程序上传接口"})}),s.jsxs(Ae,{className:"space-y-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-1",children:"POST /api/miniprogram/upload/image — 图片上传(支持压缩)"}),s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"表单:file(必填)、folder(可选,默认 images)、quality(可选 1-100,默认 85)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"支持 jpeg/png/gif,单张最大 5MB。JPEG 按 quality 压缩。"}),s.jsx("pre",{className:"mt-2 p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:'响应示例: { "success": true, "url": "/uploads/images/xxx.jpg", "data": { "url", "fileName", "size", "type", "quality" } }'})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-1",children:"POST /api/miniprogram/upload/video — 视频上传"}),s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"表单:file(必填)、folder(可选,默认 videos)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"支持 mp4/mov/avi,单个最大 100MB。"}),s.jsx("pre",{className:"mt-2 p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:'响应示例: { "success": true, "url": "/uploads/videos/xxx.mp4", "data": { "url", "fileName", "size", "type", "folder" } }'})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"2.2 管理端内容上传"})}),s.jsxs(Ae,{className:"space-y-3 text-sm",children:[s.jsx("p",{className:"text-gray-400",children:"POST /api/admin/content/upload — 内容导入(需 AdminAuth)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"通过 API 批量导入章节到内容管理,不直接操作数据库。"}),s.jsx("pre",{className:"p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:`请求体: { - "action": "import", - "data": [{ - "id": "ch-001", - "title": "章节标题", - "content": "正文内容", - "price": 1.0, - "isFree": false, - "partId": "part-1", - "partTitle": "第一篇", - "chapterId": "chapter-1", - "chapterTitle": "第1章" - }] -}`}),s.jsxs("p",{className:"text-gray-500 text-xs",children:["响应:",'{ "success": true, "message": "导入完成", "imported": N, "failed": M }']})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"3. 支付"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"POST /api/payment/create-order — 创建订单"}),s.jsx("p",{children:"POST /api/payment/alipay/notify — 支付宝回调"}),s.jsx("p",{children:"POST /api/payment/wechat/notify — 微信回调"})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"4. 分销与用户"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"/api/referral/* — 邀请码、收益查询、提现"}),s.jsx("p",{children:"/api/user/* — 登录、注册、信息更新"}),s.jsx("p",{children:"/api/match/* — 匹配、匹配历史"})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"5. 管理后台"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET/POST /api/admin/referral-settings — 推广/分销设置(含 VIP 配置)"}),s.jsx("p",{children:"GET /api/db/users、/api/db/book — 用户与章节数据"}),s.jsx("p",{children:"GET /api/admin/orders — 订单列表"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"完整说明见项目内 开发文档/5、接口/API接口完整文档.md"})]})}function LV(){const t=wa();return s.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:s.jsxs("div",{className:"text-center max-w-md",children:[s.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:s.jsx(KT,{className:"w-10 h-10"})}),s.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),s.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),s.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),s.jsx(ee,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(Ng,{to:"/",children:[s.jsx(AM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function _V(){return s.jsxs(pT,{children:[s.jsx(Wt,{path:"/login",element:s.jsx(Q5,{})}),s.jsxs(Wt,{path:"/",element:s.jsx(e5,{}),children:[s.jsx(Wt,{index:!0,element:s.jsx(Nm,{to:"/dashboard",replace:!0})}),s.jsx(Wt,{path:"dashboard",element:s.jsx(oP,{})}),s.jsx(Wt,{path:"orders",element:s.jsx(lP,{})}),s.jsx(Wt,{path:"users",element:s.jsx(cP,{})}),s.jsx(Wt,{path:"distribution",element:s.jsx(IP,{})}),s.jsx(Wt,{path:"withdrawals",element:s.jsx(RP,{})}),s.jsx(Wt,{path:"content",element:s.jsx(tV,{})}),s.jsx(Wt,{path:"referral-settings",element:s.jsx(Mk,{})}),s.jsx(Wt,{path:"author-settings",element:s.jsx(Nm,{to:"/settings?tab=author",replace:!0})}),s.jsx(Wt,{path:"vip-roles",element:s.jsx(vV,{})}),s.jsx(Wt,{path:"mentors",element:s.jsx(R4,{})}),s.jsx(Wt,{path:"mentor-consultations",element:s.jsx(bV,{})}),s.jsx(Wt,{path:"admin-users",element:s.jsx(Nm,{to:"/settings?tab=admin",replace:!0})}),s.jsx(Wt,{path:"settings",element:s.jsx(cV,{})}),s.jsx(Wt,{path:"payment",element:s.jsx(dV,{})}),s.jsx(Wt,{path:"site",element:s.jsx(pV,{})}),s.jsx(Wt,{path:"qrcodes",element:s.jsx(mV,{})}),s.jsx(Wt,{path:"find-partner",element:s.jsx(OV,{})}),s.jsx(Wt,{path:"match",element:s.jsx(xV,{})}),s.jsx(Wt,{path:"match-records",element:s.jsx(yV,{})}),s.jsx(Wt,{path:"api-doc",element:s.jsx(DV,{})})]}),s.jsx(Wt,{path:"*",element:s.jsx(LV,{})})]})}vE.createRoot(document.getElementById("root")).render(s.jsx(v.StrictMode,{children:s.jsx(wT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(_V,{})})})); diff --git a/soul-admin/dist/assets/index-DdPcz68r.css b/soul-admin/dist/assets/index-DdPcz68r.css new file mode 100644 index 00000000..ce23797e --- /dev/null +++ b/soul-admin/dist/assets/index-DdPcz68r.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:300px;max-height:500px;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}.mention-trigger-btn{color:#38bdac!important}.mention-trigger-btn:hover{background:#38bdac33!important}.upload-progress-bar{display:flex;align-items:center;gap:8px;padding:4px 10px;background:#0f1d32;border-bottom:1px solid #374151}.upload-progress-track{flex:1;height:4px;background:#1f2937;border-radius:2px;overflow:hidden}.upload-progress-fill{height:100%;background:linear-gradient(90deg,#38bdac,#4ae3ce);border-radius:2px;transition:width .3s ease}.upload-progress-text{font-size:11px;color:#38bdac;white-space:nowrap}/*! 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-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-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%}.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-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-auto{height:auto}.h-full{height:100%}.max-h-60{max-height:calc(var(--spacing)*60)}.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-\[450px\]{max-height:450px}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-8{min-height:calc(var(--spacing)*8)}.min-h-\[2rem\]{min-height:2rem}.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-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.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-\[200px\]{width:200px}.w-fit{width:fit-content}.w-full{width:100%}.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-\[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-\[250px\]{max-width:250px}.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-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-\[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-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-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-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-\[\#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-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\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,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\/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-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.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-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}.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\/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-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-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,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-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-400\/10:hover{background-color:#ff8b1a1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-400\/10:hover{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.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-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\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.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-7{grid-template-columns:repeat(7,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-d2VmvrcP.js b/soul-admin/dist/assets/index-d2VmvrcP.js new file mode 100644 index 00000000..1ca21ed6 --- /dev/null +++ b/soul-admin/dist/assets/index-d2VmvrcP.js @@ -0,0 +1,937 @@ +function gE(t,e){for(var n=0;nr[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();function Rw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wm={exports:{}},Ic={},jm={exports:{}},ht={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var vv;function xE(){if(vv)return ht;vv=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function g(F){return F===null||typeof F!="object"?null:(F=m&&F[m]||F["@@iterator"],typeof F=="function"?F:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,w={};function N(F,W,K){this.props=F,this.context=W,this.refs=w,this.updater=K||y}N.prototype.isReactComponent={},N.prototype.setState=function(F,W){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,W,"setState")},N.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function k(){}k.prototype=N.prototype;function C(F,W,K){this.props=F,this.context=W,this.refs=w,this.updater=K||y}var E=C.prototype=new k;E.constructor=C,v(E,N.prototype),E.isPureReactComponent=!0;var A=Array.isArray,I=Object.prototype.hasOwnProperty,D={current:null},_={key:!0,ref:!0,__self:!0,__source:!0};function P(F,W,K){var B,oe={},G=null,Q=null;if(W!=null)for(B in W.ref!==void 0&&(Q=W.ref),W.key!==void 0&&(G=""+W.key),W)I.call(W,B)&&!_.hasOwnProperty(B)&&(oe[B]=W[B]);var se=arguments.length-2;if(se===1)oe.children=K;else if(1>>1,W=$[F];if(0>>1;Fa(oe,Y))Ga(Q,oe)?($[F]=Q,$[G]=Y,F=G):($[F]=oe,$[B]=Y,F=B);else if(Ga(Q,Y))$[F]=Q,$[G]=Y,F=G;else break e}}return le}function a($,le){var Y=$.sortIndex-le.sortIndex;return Y!==0?Y:$.id-le.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,v=!1,w=!1,N=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($){for(var le=n(h);le!==null;){if(le.callback===null)r(h);else if(le.startTime<=$)r(h),le.sortIndex=le.expirationTime,e(u,le);else break;le=n(h)}}function A($){if(w=!1,E($),!v)if(n(u)!==null)v=!0,O(I);else{var le=n(h);le!==null&&X(A,le.startTime-$)}}function I($,le){v=!1,w&&(w=!1,k(P),P=-1),y=!0;var Y=g;try{for(E(le),m=n(u);m!==null&&(!(m.expirationTime>le)||$&&!ee());){var F=m.callback;if(typeof F=="function"){m.callback=null,g=m.priorityLevel;var W=F(m.expirationTime<=le);le=t.unstable_now(),typeof W=="function"?m.callback=W:m===n(u)&&r(u),E(le)}else r(u);m=n(u)}if(m!==null)var K=!0;else{var B=n(h);B!==null&&X(A,B.startTime-le),K=!1}return K}finally{m=null,g=Y,y=!1}}var D=!1,_=null,P=-1,L=5,z=-1;function ee(){return!(t.unstable_now()-z$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function($){switch(g){case 1:case 2:case 3:var le=3;break;default:le=g}var Y=g;g=le;try{return $()}finally{g=Y}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function($,le){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var Y=g;g=$;try{return le()}finally{g=Y}},t.unstable_scheduleCallback=function($,le,Y){var F=t.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0F?($.sortIndex=Y,e(h,$),n(u)===null&&$===n(h)&&(w?(k(P),P=-1):w=!0,X(A,Y-F))):($.sortIndex=W,e(u,$),v||y||(v=!0,O(I))),$},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function($){var le=g;return function(){var Y=g;g=le;try{return $.apply(this,arguments)}finally{g=Y}}}})(Cm)),Cm}var Sv;function NE(){return Sv||(Sv=1,Sm.exports=vE()),Sm.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Cv;function wE(){if(Cv)return Er;Cv=1;var t=Nd(),e=NE();function n(l){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;p"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 v(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 w(l,d,p,x,j,S,M){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=j,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=S,this.removeEmptyString=M}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){N[l]=new w(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var d=l[0];N[d]=new w(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){N[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){N[l]=new w(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){N[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){N[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){N[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){N[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){N[l]=new w(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);N[d]=new w(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);N[d]=new w(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);N[d]=new w(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){N[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),N.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){N[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function E(l,d,p,x){var j=N.hasOwnProperty(d)?N[d]:null;(j!==null?j.type!==0:x||!(2H||j[M]!==S[H]){var J=` +`+j[M].replace(" at new "," at ");return l.displayName&&J.includes("")&&(J=J.replace("",l.displayName)),J}while(1<=M&&0<=H);break}}}finally{K=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?W(l):""}function oe(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=B(l.type,!1),l;case 11:return l=B(l.type.render,!1),l;case 1:return l=B(l.type,!0),l;default:return""}}function G(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 _:return"Fragment";case D:return"Portal";case L:return"Profiler";case P:return"StrictMode";case he:return"Suspense";case me:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case ee:return(l.displayName||"Context")+".Consumer";case z:return(l._context.displayName||"Context")+".Provider";case U:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case R:return d=l.displayName||null,d!==null?d:G(l.type)||"Memo";case O:d=l._payload,l=l._init;try{return G(l(d))}catch{}}return null}function Q(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 G(d);case 8:return d===P?"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 se(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ye(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function Me(l){var d=ye(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 j=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return j.call(this)},set:function(M){x=""+M,S.call(this,M)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(M){x=""+M},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function Be(l){l._valueTracker||(l._valueTracker=Me(l))}function He(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=ye(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function gt(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 Dt(l,d){var p=d.checked;return Y({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function jn(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=se(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 it(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function Mt(l,d){it(l,d);var p=se(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")?Pe(l,d.type,p):d.hasOwnProperty("defaultValue")&&Pe(l,d.type,se(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function re(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 Pe(l,d,p){(d!=="number"||gt(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var et=Array.isArray;function xt(l,d,p,x){if(l=l.options,d){d={};for(var j=0;j"+d.valueOf().toString()+"",d=At.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function ts(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var or={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},ge=["Webkit","ms","Moz","O"];Object.keys(or).forEach(function(l){ge.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),or[d]=or[l]})});function Ne(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||or.hasOwnProperty(l)&&or[l]?(""+d).trim():d+"px"}function qn(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,j=Ne(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,j):l[p]=j}}var Cs=Y({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 Es(l,d){if(d){if(Cs[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 Ra(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 br=null;function Bi(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var vr=null,lr=null,Ts=null;function Pa(l){if(l=gc(l)){if(typeof vr!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Wd(d),vr(l.stateNode,l.type,d))}}function Vi(l){lr?Ts?Ts.push(l):Ts=[l]:lr=l}function Qs(){if(lr){var l=lr,d=Ts;if(Ts=lr=null,Pa(l),d)for(l=0;l>>=0,l===0?32:31-(Ho(l)/$a|0)|0}var Is=64,Rs=4194304;function Ps(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 Os(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,j=l.suspendedLanes,S=l.pingedLanes,M=p&268435455;if(M!==0){var H=M&~j;H!==0?x=Ps(H):(S&=M,S!==0&&(x=Ps(S)))}else M=p&~j,M!==0?x=Ps(M):S!==0&&(x=Ps(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&j)===0&&(j=x&-x,S=d&-d,j>=S||j===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 kn(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-$n(d),l[d]=p}function Wo(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=oc),fy=" ",py=!1;function my(l,d){switch(l){case"keyup":return u3.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Jo=!1;function f3(l,d){switch(l){case"compositionend":return gy(d);case"keypress":return d.which!==32?null:(py=!0,fy);case"textInput":return l=d.data,l===fy&&py?null:l;default:return null}}function p3(l,d){if(Jo)return l==="compositionend"||!np&&my(l,d)?(l=oy(),Pd=Yf=Ha=null,Jo=!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=jy(p)}}function Sy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?Sy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function Cy(){for(var l=window,d=gt();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=gt(l.document)}return d}function ap(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 j3(l){var d=Cy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&Sy(p.ownerDocument.documentElement,p)){if(x!==null&&ap(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 j=p.textContent.length,S=Math.min(x.start,j);x=x.end===void 0?S:Math.min(x.end,j),!l.extend&&S>x&&(j=x,x=S,S=j),j=ky(p,S);var M=ky(p,x);j&&M&&(l.rangeCount!==1||l.anchorNode!==j.node||l.anchorOffset!==j.offset||l.focusNode!==M.node||l.focusOffset!==M.offset)&&(d=d.createRange(),d.setStart(j.node,j.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(M.node,M.offset)):(d.setEnd(M.node,M.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,Yo=null,ip=null,uc=null,op=!1;function Ey(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;op||Yo==null||Yo!==gt(x)||(x=Yo,"selectionStart"in x&&ap(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}),uc&&dc(uc,x)||(uc=x,x=Bd(ip,"onSelect"),0tl||(l.current=bp[tl],bp[tl]=null,tl--)}function _t(l,d){tl++,bp[tl]=l.current,l.current=d}var qa={},Yn=Ka(qa),wr=Ka(!1),Qi=qa;function nl(l,d){var p=l.type.contextTypes;if(!p)return qa;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var j={},S;for(S in p)j[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=j),j}function jr(l){return l=l.childContextTypes,l!=null}function Ud(){qt(wr),qt(Yn)}function Vy(l,d,p){if(Yn.current!==qa)throw Error(n(168));_t(Yn,d),_t(wr,p)}function Hy(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var j in x)if(!(j in d))throw Error(n(108,Q(l)||"Unknown",j));return Y({},p,x)}function Kd(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||qa,Qi=Yn.current,_t(Yn,l),_t(wr,wr.current),!0}function Wy(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Hy(l,d,Qi),x.__reactInternalMemoizedMergedChildContext=l,qt(wr),qt(Yn),_t(Yn,l)):qt(wr),_t(wr,p)}var aa=null,qd=!1,vp=!1;function Uy(l){aa===null?aa=[l]:aa.push(l)}function D3(l){qd=!0,Uy(l)}function Ga(){if(!vp&&aa!==null){vp=!0;var l=0,d=st;try{var p=aa;for(st=1;l>=M,j-=M,ia=1<<32-$n(d)+j|p<rt?(On=Ze,Ze=null):On=Ze.sibling;var bt=ve(ae,Ze,ce[rt],Ae);if(bt===null){Ze===null&&(Ze=On);break}l&&Ze&&bt.alternate===null&&d(ae,Ze),Z=S(bt,Z,rt),Xe===null?Ve=bt:Xe.sibling=bt,Xe=bt,Ze=On}if(rt===ce.length)return p(ae,Ze),Jt&&Zi(ae,rt),Ve;if(Ze===null){for(;rtrt?(On=Ze,Ze=null):On=Ze.sibling;var ri=ve(ae,Ze,bt.value,Ae);if(ri===null){Ze===null&&(Ze=On);break}l&&Ze&&ri.alternate===null&&d(ae,Ze),Z=S(ri,Z,rt),Xe===null?Ve=ri:Xe.sibling=ri,Xe=ri,Ze=On}if(bt.done)return p(ae,Ze),Jt&&Zi(ae,rt),Ve;if(Ze===null){for(;!bt.done;rt++,bt=ce.next())bt=je(ae,bt.value,Ae),bt!==null&&(Z=S(bt,Z,rt),Xe===null?Ve=bt:Xe.sibling=bt,Xe=bt);return Jt&&Zi(ae,rt),Ve}for(Ze=x(ae,Ze);!bt.done;rt++,bt=ce.next())bt=Oe(Ze,ae,rt,bt.value,Ae),bt!==null&&(l&&bt.alternate!==null&&Ze.delete(bt.key===null?rt:bt.key),Z=S(bt,Z,rt),Xe===null?Ve=bt:Xe.sibling=bt,Xe=bt);return l&&Ze.forEach(function(mE){return d(ae,mE)}),Jt&&Zi(ae,rt),Ve}function fn(ae,Z,ce,Ae){if(typeof ce=="object"&&ce!==null&&ce.type===_&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case I:e:{for(var Ve=ce.key,Xe=Z;Xe!==null;){if(Xe.key===Ve){if(Ve=ce.type,Ve===_){if(Xe.tag===7){p(ae,Xe.sibling),Z=j(Xe,ce.props.children),Z.return=ae,ae=Z;break e}}else if(Xe.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===O&&Qy(Ve)===Xe.type){p(ae,Xe.sibling),Z=j(Xe,ce.props),Z.ref=xc(ae,Xe,ce),Z.return=ae,ae=Z;break e}p(ae,Xe);break}else d(ae,Xe);Xe=Xe.sibling}ce.type===_?(Z=oo(ce.props.children,ae.mode,Ae,ce.key),Z.return=ae,ae=Z):(Ae=Nu(ce.type,ce.key,ce.props,null,ae.mode,Ae),Ae.ref=xc(ae,Z,ce),Ae.return=ae,ae=Ae)}return M(ae);case D:e:{for(Xe=ce.key;Z!==null;){if(Z.key===Xe)if(Z.tag===4&&Z.stateNode.containerInfo===ce.containerInfo&&Z.stateNode.implementation===ce.implementation){p(ae,Z.sibling),Z=j(Z,ce.children||[]),Z.return=ae,ae=Z;break e}else{p(ae,Z);break}else d(ae,Z);Z=Z.sibling}Z=xm(ce,ae.mode,Ae),Z.return=ae,ae=Z}return M(ae);case O:return Xe=ce._init,fn(ae,Z,Xe(ce._payload),Ae)}if(et(ce))return _e(ae,Z,ce,Ae);if(le(ce))return Fe(ae,Z,ce,Ae);Qd(ae,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,Z!==null&&Z.tag===6?(p(ae,Z.sibling),Z=j(Z,ce),Z.return=ae,ae=Z):(p(ae,Z),Z=gm(ce,ae.mode,Ae),Z.return=ae,ae=Z),M(ae)):p(ae,Z)}return fn}var il=Xy(!0),Zy=Xy(!1),Xd=Ka(null),Zd=null,ol=null,Cp=null;function Ep(){Cp=ol=Zd=null}function Tp(l){var d=Xd.current;qt(Xd),l._currentValue=d}function Mp(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 ll(l,d){Zd=l,Cp=ol=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(kr=!0),l.firstContext=null)}function Ur(l){var d=l._currentValue;if(Cp!==l)if(l={context:l,memoizedValue:d,next:null},ol===null){if(Zd===null)throw Error(n(308));ol=l,Zd.dependencies={lanes:0,firstContext:l}}else ol=ol.next=l;return d}var eo=null;function Ap(l){eo===null?eo=[l]:eo.push(l)}function eb(l,d,p,x){var j=d.interleaved;return j===null?(p.next=p,Ap(d)):(p.next=j.next,j.next=p),d.interleaved=p,la(l,x)}function la(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 Ja=!1;function Ip(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function tb(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 ca(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function Ya(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(mt&2)!==0){var j=x.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),x.pending=d,la(l,p)}return j=x.interleaved,j===null?(d.next=d,Ap(x)):(d.next=j.next,j.next=d),x.interleaved=d,la(l,p)}function eu(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,Xt(l,p)}}function nb(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var j=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var M={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?j=S=M:S=S.next=M,p=p.next}while(p!==null);S===null?j=S=d:S=S.next=d}else j=S=d;p={baseState:x.baseState,firstBaseUpdate:j,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 tu(l,d,p,x){var j=l.updateQueue;Ja=!1;var S=j.firstBaseUpdate,M=j.lastBaseUpdate,H=j.shared.pending;if(H!==null){j.shared.pending=null;var J=H,pe=J.next;J.next=null,M===null?S=pe:M.next=pe,M=J;var we=l.alternate;we!==null&&(we=we.updateQueue,H=we.lastBaseUpdate,H!==M&&(H===null?we.firstBaseUpdate=pe:H.next=pe,we.lastBaseUpdate=J))}if(S!==null){var je=j.baseState;M=0,we=pe=J=null,H=S;do{var ve=H.lane,Oe=H.eventTime;if((x&ve)===ve){we!==null&&(we=we.next={eventTime:Oe,lane:0,tag:H.tag,payload:H.payload,callback:H.callback,next:null});e:{var _e=l,Fe=H;switch(ve=d,Oe=p,Fe.tag){case 1:if(_e=Fe.payload,typeof _e=="function"){je=_e.call(Oe,je,ve);break e}je=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Fe.payload,ve=typeof _e=="function"?_e.call(Oe,je,ve):_e,ve==null)break e;je=Y({},je,ve);break e;case 2:Ja=!0}}H.callback!==null&&H.lane!==0&&(l.flags|=64,ve=j.effects,ve===null?j.effects=[H]:ve.push(H))}else Oe={eventTime:Oe,lane:ve,tag:H.tag,payload:H.payload,callback:H.callback,next:null},we===null?(pe=we=Oe,J=je):we=we.next=Oe,M|=ve;if(H=H.next,H===null){if(H=j.shared.pending,H===null)break;ve=H,H=ve.next,ve.next=null,j.lastBaseUpdate=ve,j.shared.pending=null}}while(!0);if(we===null&&(J=je),j.baseState=J,j.firstBaseUpdate=pe,j.lastBaseUpdate=we,d=j.shared.interleaved,d!==null){j=d;do M|=j.lane,j=j.next;while(j!==d)}else S===null&&(j.shared.lanes=0);ro|=M,l.lanes=M,l.memoizedState=je}}function rb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Lp.transition;Lp.transition={};try{l(!1),d()}finally{st=p,Lp.transition=x}}function wb(){return Kr().memoizedState}function $3(l,d,p){var x=ei(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},jb(l))kb(d,p);else if(p=eb(l,d,p,x),p!==null){var j=hr();gs(p,l,x,j),Sb(p,d,x)}}function F3(l,d,p){var x=ei(l),j={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(jb(l))kb(d,j);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var M=d.lastRenderedState,H=S(M,p);if(j.hasEagerState=!0,j.eagerState=H,us(H,M)){var J=d.interleaved;J===null?(j.next=j,Ap(d)):(j.next=J.next,J.next=j),d.interleaved=j;return}}catch{}finally{}p=eb(l,d,j,x),p!==null&&(j=hr(),gs(p,l,x,j),Sb(p,d,x))}}function jb(l){var d=l.alternate;return l===en||d!==null&&d===en}function kb(l,d){Nc=su=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function Sb(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Xt(l,p)}}var ou={readContext:Ur,useCallback:Qn,useContext:Qn,useEffect:Qn,useImperativeHandle:Qn,useInsertionEffect:Qn,useLayoutEffect:Qn,useMemo:Qn,useReducer:Qn,useRef:Qn,useState:Qn,useDebugValue:Qn,useDeferredValue:Qn,useTransition:Qn,useMutableSource:Qn,useSyncExternalStore:Qn,useId:Qn,unstable_isNewReconciler:!1},B3={readContext:Ur,useCallback:function(l,d){return zs().memoizedState=[l,d===void 0?null:d],l},useContext:Ur,useEffect:pb,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,au(4194308,4,xb.bind(null,d,l),p)},useLayoutEffect:function(l,d){return au(4194308,4,l,d)},useInsertionEffect:function(l,d){return au(4,2,l,d)},useMemo:function(l,d){var p=zs();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=zs();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=$3.bind(null,en,l),[x.memoizedState,l]},useRef:function(l){var d=zs();return l={current:l},d.memoizedState=l},useState:hb,useDebugValue:Hp,useDeferredValue:function(l){return zs().memoizedState=l},useTransition:function(){var l=hb(!1),d=l[0];return l=z3.bind(null,l[1]),zs().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=en,j=zs();if(Jt){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),Pn===null)throw Error(n(349));(no&30)!==0||ob(x,d,p)}j.memoizedState=p;var S={value:p,getSnapshot:d};return j.queue=S,pb(cb.bind(null,x,S,l),[l]),x.flags|=2048,kc(9,lb.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=zs(),d=Pn.identifierPrefix;if(Jt){var p=oa,x=ia;p=(x&~(1<<32-$n(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=wc++,0<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=M.createElement(p,{is:x.is}):(l=M.createElement(p),p==="select"&&(M=l,x.multiple?M.multiple=!0:x.size&&(M.size=x.size))):l=M.createElementNS(l,p),l[Ls]=d,l[mc]=x,Ub(l,d,!1,!1),d.stateNode=l;e:{switch(M=Ra(p,x),p){case"dialog":Kt("cancel",l),Kt("close",l),j=x;break;case"iframe":case"object":case"embed":Kt("load",l),j=x;break;case"video":case"audio":for(j=0;jfl&&(d.flags|=128,x=!0,Sc(S,!1),d.lanes=4194304)}else{if(!x)if(l=nu(M),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Sc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!M.alternate&&!Jt)return Xn(d),null}else 2*It()-S.renderingStartTime>fl&&p!==1073741824&&(d.flags|=128,x=!0,Sc(S,!1),d.lanes=4194304);S.isBackwards?(M.sibling=d.child,d.child=M):(p=S.last,p!==null?p.sibling=M:d.child=M,S.last=M)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=It(),d.sibling=null,p=Zt.current,_t(Zt,x?p&1|2:p&1),d):(Xn(d),null);case 22:case 23:return fm(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Or&1073741824)!==0&&(Xn(d),d.subtreeFlags&6&&(d.flags|=8192)):Xn(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function J3(l,d){switch(wp(d),d.tag){case 1:return jr(d.type)&&Ud(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return cl(),qt(wr),qt(Yn),Dp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Pp(d),null;case 13:if(qt(Zt),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));al()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return qt(Zt),null;case 4:return cl(),null;case 10:return Tp(d.type._context),null;case 22:case 23:return fm(),null;case 24:return null;default:return null}}var uu=!1,Zn=!1,Y3=typeof WeakSet=="function"?WeakSet:Set,Le=null;function ul(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){sn(l,d,x)}else p.current=null}function tm(l,d,p){try{p()}catch(x){sn(l,d,x)}}var Gb=!1;function Q3(l,d){if(fp=Id,l=Cy(),ap(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 j=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var M=0,H=-1,J=-1,pe=0,we=0,je=l,ve=null;t:for(;;){for(var Oe;je!==p||j!==0&&je.nodeType!==3||(H=M+j),je!==S||x!==0&&je.nodeType!==3||(J=M+x),je.nodeType===3&&(M+=je.nodeValue.length),(Oe=je.firstChild)!==null;)ve=je,je=Oe;for(;;){if(je===l)break t;if(ve===p&&++pe===j&&(H=M),ve===S&&++we===x&&(J=M),(Oe=je.nextSibling)!==null)break;je=ve,ve=je.parentNode}je=Oe}p=H===-1||J===-1?null:{start:H,end:J}}else p=null}p=p||{start:0,end:0}}else p=null;for(pp={focusedElem:l,selectionRange:p},Id=!1,Le=d;Le!==null;)if(d=Le,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Le=l;else for(;Le!==null;){d=Le;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 Fe=_e.memoizedProps,fn=_e.memoizedState,ae=d.stateNode,Z=ae.getSnapshotBeforeUpdate(d.elementType===d.type?Fe:fs(d.type,Fe),fn);ae.__reactInternalSnapshotBeforeUpdate=Z}break;case 3:var ce=d.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ae){sn(d,d.return,Ae)}if(l=d.sibling,l!==null){l.return=d.return,Le=l;break}Le=d.return}return _e=Gb,Gb=!1,_e}function Cc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var j=x=x.next;do{if((j.tag&l)===l){var S=j.destroy;j.destroy=void 0,S!==void 0&&tm(d,p,S)}j=j.next}while(j!==x)}}function hu(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 nm(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 Jb(l){var d=l.alternate;d!==null&&(l.alternate=null,Jb(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Ls],delete d[mc],delete d[yp],delete d[P3],delete d[O3])),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 Yb(l){return l.tag===5||l.tag===3||l.tag===4}function Qb(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Yb(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 rm(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=Hd));else if(x!==4&&(l=l.child,l!==null))for(rm(l,d,p),l=l.sibling;l!==null;)rm(l,d,p),l=l.sibling}function sm(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(sm(l,d,p),l=l.sibling;l!==null;)sm(l,d,p),l=l.sibling}var Fn=null,ps=!1;function Qa(l,d,p){for(p=p.child;p!==null;)Xb(l,d,p),p=p.sibling}function Xb(l,d,p){if(dr&&typeof dr.onCommitFiberUnmount=="function")try{dr.onCommitFiberUnmount(za,p)}catch{}switch(p.tag){case 5:Zn||ul(p,d);case 6:var x=Fn,j=ps;Fn=null,Qa(l,d,p),Fn=x,ps=j,Fn!==null&&(ps?(l=Fn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):Fn.removeChild(p.stateNode));break;case 18:Fn!==null&&(ps?(l=Fn,p=p.stateNode,l.nodeType===8?xp(l.parentNode,p):l.nodeType===1&&xp(l,p),Va(l)):xp(Fn,p.stateNode));break;case 4:x=Fn,j=ps,Fn=p.stateNode.containerInfo,ps=!0,Qa(l,d,p),Fn=x,ps=j;break;case 0:case 11:case 14:case 15:if(!Zn&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){j=x=x.next;do{var S=j,M=S.destroy;S=S.tag,M!==void 0&&((S&2)!==0||(S&4)!==0)&&tm(p,d,M),j=j.next}while(j!==x)}Qa(l,d,p);break;case 1:if(!Zn&&(ul(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(H){sn(p,d,H)}Qa(l,d,p);break;case 21:Qa(l,d,p);break;case 22:p.mode&1?(Zn=(x=Zn)||p.memoizedState!==null,Qa(l,d,p),Zn=x):Qa(l,d,p);break;default:Qa(l,d,p)}}function Zb(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new Y3),d.forEach(function(x){var j=iE.bind(null,l,x);p.has(x)||(p.add(x),x.then(j,j))})}}function ms(l,d){var p=d.deletions;if(p!==null)for(var x=0;xj&&(j=M),x&=~S}if(x=j,x=It()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*Z3(x/1960))-x,10l?16:l,Za===null)var x=!1;else{if(l=Za,Za=null,xu=0,(mt&6)!==0)throw Error(n(331));var j=mt;for(mt|=4,Le=l.current;Le!==null;){var S=Le,M=S.child;if((Le.flags&16)!==0){var H=S.deletions;if(H!==null){for(var J=0;JIt()-om?ao(l,0):im|=p),Cr(l,d)}function hv(l,d){d===0&&((l.mode&1)===0?d=1:(d=Rs,Rs<<=1,(Rs&130023424)===0&&(Rs=4194304)));var p=hr();l=la(l,d),l!==null&&(kn(l,d,p),Cr(l,p))}function aE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),hv(l,p)}function iE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),hv(l,p)}var fv;fv=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||wr.current)kr=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return kr=!1,q3(l,d,p);kr=(l.flags&131072)!==0}else kr=!1,Jt&&(d.flags&1048576)!==0&&Ky(d,Jd,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;du(l,d),l=d.pendingProps;var j=nl(d,Yn.current);ll(d,p),j=zp(null,d,x,l,j,p);var S=$p();return d.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,jr(x)?(S=!0,Kd(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Ip(d),j.updater=lu,d.stateNode=j,j._reactInternals=d,Up(d,x,l,p),d=Jp(null,d,x,!0,S,p)):(d.tag=0,Jt&&S&&Np(d),ur(null,d,j,p),d=d.child),d;case 16:x=d.elementType;e:{switch(du(l,d),l=d.pendingProps,j=x._init,x=j(x._payload),d.type=x,j=d.tag=lE(x),l=fs(x,l),j){case 0:d=Gp(null,d,x,l,p);break e;case 1:d=$b(null,d,x,l,p);break e;case 11:d=Ob(null,d,x,l,p);break e;case 14:d=Db(null,d,x,fs(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:fs(x,j),Gp(l,d,x,j,p);case 1:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:fs(x,j),$b(l,d,x,j,p);case 3:e:{if(Fb(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,j=S.element,tb(l,d),tu(d,x,null,p);var M=d.memoizedState;if(x=M.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=dl(Error(n(423)),d),d=Bb(l,d,x,p,j);break e}else if(x!==j){j=dl(Error(n(424)),d),d=Bb(l,d,x,p,j);break e}else for(Pr=Ua(d.stateNode.containerInfo.firstChild),Rr=d,Jt=!0,hs=null,p=Zy(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(al(),x===j){d=da(l,d,p);break e}ur(l,d,x,p)}d=d.child}return d;case 5:return sb(d),l===null&&kp(d),x=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,M=j.children,mp(x,j)?M=null:S!==null&&mp(x,S)&&(d.flags|=32),zb(l,d),ur(l,d,M,p),d.child;case 6:return l===null&&kp(d),null;case 13:return Vb(l,d,p);case 4:return Rp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=il(d,null,x,p):ur(l,d,x,p),d.child;case 11:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:fs(x,j),Ob(l,d,x,j,p);case 7:return ur(l,d,d.pendingProps,p),d.child;case 8:return ur(l,d,d.pendingProps.children,p),d.child;case 12:return ur(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,j=d.pendingProps,S=d.memoizedProps,M=j.value,_t(Xd,x._currentValue),x._currentValue=M,S!==null)if(us(S.value,M)){if(S.children===j.children&&!wr.current){d=da(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var H=S.dependencies;if(H!==null){M=S.child;for(var J=H.firstContext;J!==null;){if(J.context===x){if(S.tag===1){J=ca(-1,p&-p),J.tag=2;var pe=S.updateQueue;if(pe!==null){pe=pe.shared;var we=pe.pending;we===null?J.next=J:(J.next=we.next,we.next=J),pe.pending=J}}S.lanes|=p,J=S.alternate,J!==null&&(J.lanes|=p),Mp(S.return,p,d),H.lanes|=p;break}J=J.next}}else if(S.tag===10)M=S.type===d.type?null:S.child;else if(S.tag===18){if(M=S.return,M===null)throw Error(n(341));M.lanes|=p,H=M.alternate,H!==null&&(H.lanes|=p),Mp(M,p,d),M=S.sibling}else M=S.child;if(M!==null)M.return=S;else for(M=S;M!==null;){if(M===d){M=null;break}if(S=M.sibling,S!==null){S.return=M.return,M=S;break}M=M.return}S=M}ur(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,x=d.pendingProps.children,ll(d,p),j=Ur(j),x=x(j),d.flags|=1,ur(l,d,x,p),d.child;case 14:return x=d.type,j=fs(x,d.pendingProps),j=fs(x.type,j),Db(l,d,x,j,p);case 15:return Lb(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:fs(x,j),du(l,d),d.tag=1,jr(x)?(l=!0,Kd(d)):l=!1,ll(d,p),Eb(d,x,j),Up(d,x,j,p),Jp(null,d,x,!0,l,p);case 19:return Wb(l,d,p);case 22:return _b(l,d,p)}throw Error(n(156,d.tag))};function pv(l,d){return un(l,d)}function oE(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 Gr(l,d,p,x){return new oE(l,d,p,x)}function mm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function lE(l){if(typeof l=="function")return mm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===U)return 11;if(l===R)return 14}return 2}function ni(l,d){var p=l.alternate;return p===null?(p=Gr(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 Nu(l,d,p,x,j,S){var M=2;if(x=l,typeof l=="function")mm(l)&&(M=1);else if(typeof l=="string")M=5;else e:switch(l){case _:return oo(p.children,j,S,d);case P:M=8,j|=8;break;case L:return l=Gr(12,p,d,j|2),l.elementType=L,l.lanes=S,l;case he:return l=Gr(13,p,d,j),l.elementType=he,l.lanes=S,l;case me:return l=Gr(19,p,d,j),l.elementType=me,l.lanes=S,l;case X:return wu(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case z:M=10;break e;case ee:M=9;break e;case U:M=11;break e;case R:M=14;break e;case O:M=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Gr(M,p,d,j),d.elementType=l,d.type=x,d.lanes=S,d}function oo(l,d,p,x){return l=Gr(7,l,x,d),l.lanes=p,l}function wu(l,d,p,x){return l=Gr(22,l,x,d),l.elementType=X,l.lanes=p,l.stateNode={isHidden:!1},l}function gm(l,d,p){return l=Gr(6,l,null,d),l.lanes=p,l}function xm(l,d,p){return d=Gr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function cE(l,d,p,x,j){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=xn(0),this.expirationTimes=xn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xn(0),this.identifierPrefix=x,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function ym(l,d,p,x,j,S,M,H,J){return l=new cE(l,d,p,H,J),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Gr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ip(S),l}function dE(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(),km.exports=wE(),km.exports}var Tv;function jE(){if(Tv)return Mu;Tv=1;var t=Pw();return Mu.createRoot=t.createRoot,Mu.hydrateRoot=t.hydrateRoot,Mu}var kE=jE(),wd=Pw();const Ow=Rw(wd);/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function sd(){return sd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function zx(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function CE(){return Math.random().toString(36).substr(2,8)}function Av(t,e){return{usr:t.state,key:t.key,idx:e}}function Sg(t,e,n,r){return n===void 0&&(n=null),sd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Wl(e):e,{state:n,key:e&&e.key||r||CE()})}function uh(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Wl(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function EE(t,e,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,c=mi.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(sd({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=mi.Pop;let N=f(),k=N==null?null:N-h;h=N,u&&u({action:c,location:w.location,delta:k})}function g(N,k){c=mi.Push;let C=Sg(w.location,N,k);h=f()+1;let E=Av(C,h),A=w.createHref(C);try{o.pushState(E,"",A)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;a.location.assign(A)}i&&u&&u({action:c,location:w.location,delta:1})}function y(N,k){c=mi.Replace;let C=Sg(w.location,N,k);h=f();let E=Av(C,h),A=w.createHref(C);o.replaceState(E,"",A),i&&u&&u({action:c,location:w.location,delta:0})}function v(N){let k=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof N=="string"?N:uh(N);return C=C.replace(/ $/,"%20"),gn(k,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,k)}let w={get action(){return c},get location(){return t(a,o)},listen(N){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(Mv,m),u=N,()=>{a.removeEventListener(Mv,m),u=null}},createHref(N){return e(a,N)},createURL:v,encodeLocation(N){let k=v(N);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(N){return o.go(N)}};return w}var Iv;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Iv||(Iv={}));function TE(t,e,n){return n===void 0&&(n="/"),ME(t,e,n)}function ME(t,e,n,r){let a=typeof e=="string"?Wl(e):e,i=$x(a.pathname||"/",n);if(i==null)return null;let o=Dw(t);AE(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("/")&&(gn(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let h=Ni([r,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(gn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Dw(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:_E(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 Lw(i.path))a(i,o,u)}),e}function Lw(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=Lw(r.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 AE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:zE(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const IE=/^:[\w-]+$/,RE=3,PE=2,OE=1,DE=10,LE=-2,Rv=t=>t==="*";function _E(t,e){let n=t.split("/"),r=n.length;return n.some(Rv)&&(r+=LE),e&&(r+=PE),n.filter(a=>!Rv(a)).reduce((a,i)=>a+(IE.test(i)?RE:i===""?OE:DE),r)}function zE(t,e){return t.length===e.length&&t.slice(0,-1).every((r,a)=>r===e[a])?t[t.length-1]-e[e.length-1]:0}function $E(t,e,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let w=c[m]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const v=c[m];return y&&!v?h[g]=void 0:h[g]=(v||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function BE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),zx(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 r=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(r.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,e?void 0:"i"),r]}function VE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return zx(!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 $x(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const HE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,WE=t=>HE.test(t);function UE(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?Wl(t):t,i;if(n)if(WE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),zx(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Pv(n.substring(1),"/"):i=Pv(n,e)}else i=e;return{pathname:i,search:GE(r),hash:JE(a)}}function Pv(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 Em(t,e,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. 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 KE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function Fx(t,e){let n=KE(t);return e?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Bx(t,e,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=Wl(t):(a=sd({},t),gn(!a.pathname||!a.pathname.includes("?"),Em("?","pathname","search",a)),gn(!a.pathname||!a.pathname.includes("#"),Em("#","pathname","hash",a)),gn(!a.search||!a.search.includes("#"),Em("#","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(!r&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=UE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Ni=t=>t.join("/").replace(/\/\/+/g,"/"),qE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),GE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,JE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function YE(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const _w=["post","put","patch","delete"];new Set(_w);const QE=["get",..._w];new Set(QE);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ad(){return ad=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"){r.go(h);return}let m=Bx(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Ni([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,i,t])}const tT=b.createContext(null);function nT(t){let e=b.useContext(Aa).outlet;return e&&b.createElement(tT.Provider,{value:t},e)}function Fw(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=b.useContext(Ri),{matches:a}=b.useContext(Aa),{pathname:i}=Pi(),o=JSON.stringify(Fx(a,r.v7_relativeSplatPath));return b.useMemo(()=>Bx(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function rT(t,e){return sT(t,e)}function sT(t,e,n,r){Ul()||gn(!1);let{navigator:a}=b.useContext(Ri),{matches:i}=b.useContext(Aa),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Pi(),f;if(e){var m;let N=typeof e=="string"?Wl(e):e;u==="/"||(m=N.pathname)!=null&&m.startsWith(u)||gn(!1),f=N}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let N=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(N.length).join("/")}let v=TE(t,{pathname:y}),w=cT(v&&v.map(N=>Object.assign({},N,{params:Object.assign({},c,N.params),pathname:Ni([u,a.encodeLocation?a.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?u:Ni([u,a.encodeLocation?a.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),i,n,r);return e&&w?b.createElement(gf.Provider,{value:{location:ad({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:mi.Pop}},w):w}function aT(){let t=fT(),e=YE(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 iT=b.createElement(aT,null);class oT 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(Aa.Provider,{value:this.props.routeContext},b.createElement(zw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function lT(t){let{routeContext:e,match:n,children:r}=t,a=b.useContext(Vx);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(Aa.Provider,{value:e},r)}function cT(t,e,n,r){var a;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=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||gn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&r&&r.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,v=!1,w=null,N=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||iT,u&&(h<0&&g===0?(mT("route-fallback"),v=!0,N=null):h===g&&(v=!0,N=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),C=()=>{let E;return y?E=w:v?E=N:m.route.Component?E=b.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,b.createElement(lT,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(oT,{location:n.location,revalidation:n.revalidation,component:w,error:y,children:C(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):C()},null)}var Bw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Bw||{}),Vw=(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})(Vw||{});function dT(t){let e=b.useContext(Vx);return e||gn(!1),e}function uT(t){let e=b.useContext(XE);return e||gn(!1),e}function hT(t){let e=b.useContext(Aa);return e||gn(!1),e}function Hw(t){let e=hT(),n=e.matches[e.matches.length-1];return n.route.id||gn(!1),n.route.id}function fT(){var t;let e=b.useContext(zw),n=uT(),r=Hw();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function pT(){let{router:t}=dT(Bw.UseNavigateStable),e=Hw(Vw.UseNavigateStable),n=b.useRef(!1);return $w(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,ad({fromRouteId:e},i)))},[t,e])}const Ov={};function mT(t,e,n){Ov[t]||(Ov[t]=!0)}function gT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Tm(t){let{to:e,replace:n,state:r,relative:a}=t;Ul()||gn(!1);let{future:i,static:o}=b.useContext(Ri),{matches:c}=b.useContext(Aa),{pathname:u}=Pi(),h=Oi(),f=Bx(e,Fx(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:a}),[h,m,a,n,r]),null}function xT(t){return nT(t.context)}function zt(t){gn(!1)}function yT(t){let{basename:e="/",children:n=null,location:r,navigationType:a=mi.Pop,navigator:i,static:o=!1,future:c}=t;Ul()&&gn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:i,static:o,future:ad({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof r=="string"&&(r=Wl(r));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:v="default"}=r,w=b.useMemo(()=>{let N=$x(f,u);return N==null?null:{location:{pathname:N,search:m,hash:g,state:y,key:v},navigationType:a}},[u,f,m,g,y,v,a]);return w==null?null:b.createElement(Ri.Provider,{value:h},b.createElement(gf.Provider,{children:n,value:w}))}function bT(t){let{children:e,location:n}=t;return rT(Cg(e),n)}new Promise(()=>{});function Cg(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(r,a)=>{if(!b.isValidElement(r))return;let i=[...e,a];if(r.type===b.Fragment){n.push.apply(n,Cg(r.props.children,i));return}r.type!==zt&&gn(!1),!r.props.index||!r.props.children||gn(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Cg(r.props.children,i)),n.push(o)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Eg(){return Eg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function NT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function wT(t,e){return t.button===0&&(!e||e==="_self")&&!NT(t)}function Tg(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function jT(t,e){let n=Tg(t);return e&&e.forEach((r,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const kT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],ST="6";try{window.__reactRouterVersion=ST}catch{}const CT="startTransition",Dv=mf[CT];function ET(t){let{basename:e,children:n,future:r,window:a}=t,i=b.useRef();i.current==null&&(i.current=SE({window:a,v5Compat:!0}));let o=i.current,[c,u]=b.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=b.useCallback(m=>{h&&Dv?Dv(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>gT(r),[r]),b.createElement(yT,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const TT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",MT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Mg=b.forwardRef(function(e,n){let{onClick:r,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=vT(e,kT),{basename:y}=b.useContext(Ri),v,w=!1;if(typeof h=="string"&&MT.test(h)&&(v=h,TT))try{let E=new URL(window.location.href),A=h.startsWith("//")?new URL(E.protocol+h):new URL(h),I=$x(A.pathname,y);A.origin===E.origin&&I!=null?h=I+A.search+A.hash:w=!0}catch{}let N=ZE(h,{relative:a}),k=AT(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function C(E){r&&r(E),E.defaultPrevented||k(E)}return b.createElement("a",Eg({},g,{href:v||N,onClick:w||i?r:C,ref:n,target:u}))});var Lv;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Lv||(Lv={}));var _v;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(_v||(_v={}));function AT(t,e){let{target:n,replace:r,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=Oi(),h=Pi(),f=Fw(t,{relative:o});return b.useCallback(m=>{if(wT(m,n)){m.preventDefault();let g=r!==void 0?r:uh(h)===uh(f);u(t,{replace:g,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,r,a,n,t,i,o,c])}function Ww(t){let e=b.useRef(Tg(t)),n=b.useRef(!1),r=Pi(),a=b.useMemo(()=>jT(r.search,n.current?null:e.current),[r.search]),i=Oi(),o=b.useCallback((c,u)=>{const h=Tg(typeof c=="function"?c(a):c);n.current=!0,i("?"+h,u)},[i,a]);return[a,o]}/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const IT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),RT=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),zv=t=>{const e=RT(t);return e.charAt(0).toUpperCase()+e.slice(1)},Uw=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),PT=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/** + * @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. + */var OT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @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 DT=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...OT,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Uw("lucide",a),...!i&&!PT(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 Te=(t,e)=>{const n=b.forwardRef(({className:r,...a},i)=>b.createElement(DT,{ref:i,iconNode:e,className:Uw(`lucide-${IT(zv(t))}`,`lucide-${t}`,r),...a}));return n.displayName=zv(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 LT=[["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"}]],Mm=Te("arrow-up-down",LT);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _T=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],zT=Te("at-sign",_T);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $T=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],$v=Te("bitcoin",$T);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const FT=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],BT=Te("bold",FT);/** + * @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 VT=[["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"}]],$r=Te("book-open",VT);/** + * @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 HT=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],hh=Te("calendar",HT);/** + * @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 WT=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Ag=Te("chart-column",WT);/** + * @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 UT=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],xf=Te("check",UT);/** + * @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 KT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],id=Te("chevron-down",KT);/** + * @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 qT=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],GT=Te("chevron-left",qT);/** + * @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 JT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Cl=Te("chevron-right",JT);/** + * @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 YT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Kw=Te("chevron-up",YT);/** + * @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 QT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],XT=Te("circle-alert",QT);/** + * @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 ZT=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Fv=Te("circle-check-big",ZT);/** + * @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 eM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ig=Te("circle-check",eM);/** + * @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 tM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],qw=Te("circle-question-mark",tM);/** + * @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 nM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],Am=Te("circle-user",nM);/** + * @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 rM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Gw=Te("circle-x",rM);/** + * @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 sM=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Rg=Te("clock",sM);/** + * @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 aM=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],iM=Te("cloud",aM);/** + * @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 oM=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],lM=Te("code",oM);/** + * @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 cM=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Jw=Te("copy",cM);/** + * @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 dM=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Bv=Te("credit-card",dM);/** + * @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 uM=[["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"}]],Ml=Te("crown",uM);/** + * @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 hM=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],fh=Te("dollar-sign",hM);/** + * @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=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],pM=Te("download",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 mM=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Us=Te("external-link",mM);/** + * @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 gM=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Pg=Te("eye",gM);/** + * @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 xM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],yM=Te("file-text",xM);/** + * @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 bM=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Yw=Te("funnel",bM);/** + * @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 vM=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],NM=Te("gift",vM);/** + * @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 wM=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],jM=Te("git-merge",wM);/** + * @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 kM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Og=Te("globe",kM);/** + * @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 SM=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],CM=Te("graduation-cap",SM);/** + * @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 EM=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],ha=Te("grip-vertical",EM);/** + * @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 TM=[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]],MM=Te("handshake",TM);/** + * @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 AM=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Vv=Te("hash",AM);/** + * @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 IM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],RM=Te("heading-1",IM);/** + * @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 PM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],OM=Te("heading-2",PM);/** + * @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 DM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],LM=Te("heading-3",DM);/** + * @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 _M=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],zM=Te("house",_M);/** + * @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 $M=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Qw=Te("image",$M);/** + * @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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],zc=Te("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 BM=[["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"}]],VM=Te("italic",BM);/** + * @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 HM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Xw=Te("key",HM);/** + * @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 WM=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],UM=Te("layout-dashboard",WM);/** + * @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 KM=[["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"}]],vs=Te("link-2",KM);/** + * @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 qM=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Dg=Te("link",qM);/** + * @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 GM=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],JM=Te("list-ordered",GM);/** + * @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 YM=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],QM=Te("list",YM);/** + * @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 XM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ZM=Te("lock",XM);/** + * @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 eA=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],tA=Te("log-out",eA);/** + * @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 nA=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Zw=Te("map-pin",nA);/** + * @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 rA=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],sA=Te("menu",rA);/** + * @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 aA=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],iA=Te("message-circle",aA);/** + * @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 oA=[["path",{d:"M5 12h14",key:"1ays0h"}]],lA=Te("minus",oA);/** + * @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 cA=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],El=Te("navigation",cA);/** + * @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 dA=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],uA=Te("palette",dA);/** + * @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 hA=[["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"}]],$t=Te("pen-line",hA);/** + * @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 fA=[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],pA=Te("pencil",fA);/** + * @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 mA=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],gA=Te("percent",mA);/** + * @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 xA=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],yA=Te("phone",xA);/** + * @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 bA=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],vA=Te("pin",bA);/** + * @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 NA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pn=Te("plus",NA);/** + * @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 wA=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Hv=Te("qr-code",wA);/** + * @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 jA=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],kA=Te("quote",jA);/** + * @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 SA=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],CA=Te("redo",SA);/** + * @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 EA=[["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"}]],Ue=Te("refresh-cw",EA);/** + * @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 TA=[["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"}]],mn=Te("save",TA);/** + * @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 MA=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ka=Te("search",MA);/** + * @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 AA=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],IA=Te("send",AA);/** + * @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 RA=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],yo=Te("settings",RA);/** + * @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 PA=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Au=Te("settings-2",PA);/** + * @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 OA=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Hx=Te("shield-check",OA);/** + * @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 DA=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],Lg=Te("shopping-bag",DA);/** + * @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 LA=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ol=Te("smartphone",LA);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _A=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],gi=Te("star",_A);/** + * @license lucide-react v0.562.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zA=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],$A=Te("strikethrough",zA);/** + * @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 FA=[["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"}]],BA=Te("table",FA);/** + * @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 VA=[["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"}]],Kc=Te("tag",VA);/** + * @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 HA=[["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"}]],er=Te("trash-2",HA);/** + * @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 WA=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],bo=Te("trending-up",WA);/** + * @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 UA=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],_g=Te("trophy",UA);/** + * @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 KA=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],ej=Te("undo-2",KA);/** + * @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 qA=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],GA=Te("undo",qA);/** + * @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 JA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ph=Te("upload",JA);/** + * @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 YA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],zg=Te("user-plus",YA);/** + * @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 QA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],vo=Te("user",QA);/** + * @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 XA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Mn=Te("users",XA);/** + * @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 ZA=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],e5=Te("video",ZA);/** + * @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 t5=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Dl=Te("wallet",t5);/** + * @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 n5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],nr=Te("x",n5);/** + * @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 r5=[["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"}]],xi=Te("zap",r5),Wx="admin_token";function Ux(){try{return localStorage.getItem(Wx)}catch{return null}}function s5(t){try{localStorage.setItem(Wx,t)}catch{}}function a5(){try{localStorage.removeItem(Wx)}catch{}}const i5="https://soulapi.quwanzhi.com",o5=15e3,l5=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):i5};function wa(t){const e=l5(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function yf(t,e={}){const{data:n,...r}=e,a=wa(t),i=new Headers(r.headers),o=Ux();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):r.body,u=new AbortController,h=setTimeout(()=>u.abort(),o5),f=await fetch(a,{...r,headers:i,body:c,credentials:"include",signal:u.signal}).finally(()=>clearTimeout(h)),g=(f.headers.get("Content-Type")||"").includes("application/json")?await f.json():f;if(!f.ok){const y=new Error((g==null?void 0:g.error)||`HTTP ${f.status}`);throw y.status=f.status,y.data=g,y}return g}function De(t,e){return yf(t,{...e,method:"GET"})}function Nt(t,e,n){return yf(t,{...n,method:"POST",data:e})}function Tt(t,e,n){return yf(t,{...n,method:"PUT",data:e})}function Na(t,e){return yf(t,{...e,method:"DELETE"})}const c5=[{icon:UM,label:"数据概览",href:"/dashboard"},{icon:$r,label:"内容管理",href:"/content"},{icon:Mn,label:"用户管理",href:"/users"},{icon:jM,label:"找伙伴",href:"/find-partner"},{icon:Dl,label:"推广中心",href:"/distribution"}];function d5(){const t=Pi(),e=Oi(),[n,r]=b.useState(!1),[a,i]=b.useState(!1);b.useEffect(()=>{r(!0)},[]),b.useEffect(()=>{if(!n)return;i(!1);let c=!1;return De("/api/admin").then(u=>{c||(u&&u.success!==!1?i(!0):e("/login",{replace:!0}))}).catch(()=>{c||e("/login",{replace:!0})}),()=>{c=!0}},[n,e]);const o=async()=>{a5();try{await Nt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!a?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsx("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:c5.map(c=>{const u=t.pathname===c.href;return s.jsxs(Mg,{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:[s.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:c.label})]},c.href)})}),s.jsxs("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:[s.jsxs(Mg,{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:[s.jsx(yo,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]}),s.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:[s.jsx(tA,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})]})]}),s.jsx("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0",children:s.jsx("div",{className:"w-full min-w-[1024px] min-h-full",children:s.jsx(xT,{})})})]})}function Wv(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Kx(...t){return e=>{let n=!1;const r=t.map(a=>{const i=Wv(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;tj(i)&&typeof mh=="function"&&(i=mh(i._payload));const c=b.Children.toArray(i),u=c.find(m5);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 s.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var rj=nj("Slot");function f5(t){const e=b.forwardRef((n,r)=>{let{children:a,...i}=n;if(tj(a)&&typeof mh=="function"&&(a=mh(a._payload)),b.isValidElement(a)){const o=x5(a),c=g5(i,a.props);return a.type!==b.Fragment&&(c.ref=r?Kx(r,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var p5=Symbol("radix.slottable");function m5(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===p5}function g5(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function x5(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.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 sj(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=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,Kv=aj,ij=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return Kv(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=Uv(f)||Uv(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||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(v=>{let[w,N]=v;return Array.isArray(N)?N.includes({...i,...c}[w]):{...i,...c}[w]===N})?[...h,m,g]:h},[]);return Kv(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},y5=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),oj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),gh="-",qv=[],v5="arbitrary..",N5=t=>{const e=j5(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return w5(o);const c=o.split(gh),u=c[0]===""&&c.length>1?1:0;return lj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?y5(h,u):u:h||qv}return n[o]||qv}}},lj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=lj(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(gh):t.slice(e).join(gh),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?v5+r:void 0})(),j5=t=>{const{theme:e,classGroups:n}=t;return k5(n,e)},k5=(t,e)=>{const n=oj();for(const r in t){const a=t[r];qx(a,n,r,e)}return n},qx=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){C5(t,e,n);return}if(typeof t=="function"){E5(t,e,n,r);return}T5(t,e,n,r)},C5=(t,e,n)=>{const r=t===""?e:cj(e,t);r.classGroupId=n},E5=(t,e,n,r)=>{if(M5(t)){qx(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(b5(n,t))},T5=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split(gh),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,A5=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const a=(i,o)=>{n[i]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(i){let o=n[i];if(o!==void 0)return o;if((o=r[i])!==void 0)return a(i,o),o},set(i,o){i in n?n[i]=o:a(i,o)}}},$g="!",Gv=":",I5=[],Jv=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),R5=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=a=>{const i=[];let o=0,c=0,u=0,h;const f=a.length;for(let w=0;wu?h-u:void 0;return Jv(i,y,g,v)};if(e){const a=e+Gv,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):Jv(I5,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},P5=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let a=[];for(let i=0;i0&&(a.sort(),r.push(...a),a=[]),r.push(o)):a.push(o)}return a.length>0&&(a.sort(),r.push(...a)),r}},O5=t=>({cache:A5(t.cacheSize),parseClassName:R5(t),sortModifiers:P5(t),...N5(t)}),D5=/\s+/,L5=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(D5);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:v,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let N=!!w,k=r(N?v.substring(0,w):v);if(!k){if(!N){u=f+(u.length>0?" "+u:u);continue}if(k=r(v),!k){u=f+(u.length>0?" "+u:u);continue}N=!1}const C=g.length===0?"":g.length===1?g[0]:i(g).join(":"),E=y?C+$g:C,A=E+k;if(o.indexOf(A)>-1)continue;o.push(A);const I=a(k,N);for(let D=0;D0?" "+u:u)}return u},_5=(...t)=>{let e=0,n,r,a="";for(;e{if(typeof t=="string")return t;let e,n="";for(let r=0;r{let n,r,a,i;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=O5(h),r=n.cache.get,a=n.cache.set,i=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=L5(u,n);return a(u,f),f};return i=o,(...u)=>i(_5(...u))},$5=[],En=t=>{const e=n=>n[t]||$5;return e.isThemeGetter=!0,e},uj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,hj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,F5=/^\d+\/\d+$/,B5=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,V5=/\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$/,H5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,W5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,U5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ml=t=>F5.test(t),dt=t=>!!t&&!Number.isNaN(Number(t)),si=t=>!!t&&Number.isInteger(Number(t)),Im=t=>t.endsWith("%")&&dt(t.slice(0,-1)),fa=t=>B5.test(t),K5=()=>!0,q5=t=>V5.test(t)&&!H5.test(t),fj=()=>!1,G5=t=>W5.test(t),J5=t=>U5.test(t),Y5=t=>!ze(t)&&!$e(t),Q5=t=>Kl(t,gj,fj),ze=t=>uj.test(t),lo=t=>Kl(t,xj,q5),Rm=t=>Kl(t,nI,dt),Yv=t=>Kl(t,pj,fj),X5=t=>Kl(t,mj,J5),Iu=t=>Kl(t,yj,G5),$e=t=>hj.test(t),Rc=t=>ql(t,xj),Z5=t=>ql(t,rI),Qv=t=>ql(t,pj),eI=t=>ql(t,gj),tI=t=>ql(t,mj),Ru=t=>ql(t,yj,!0),Kl=(t,e,n)=>{const r=uj.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},ql=(t,e,n=!1)=>{const r=hj.exec(t);return r?r[1]?e(r[1]):n:!1},pj=t=>t==="position"||t==="percentage",mj=t=>t==="image"||t==="url",gj=t=>t==="length"||t==="size"||t==="bg-size",xj=t=>t==="length",nI=t=>t==="number",rI=t=>t==="family-name",yj=t=>t==="shadow",sI=()=>{const t=En("color"),e=En("font"),n=En("text"),r=En("font-weight"),a=En("tracking"),i=En("leading"),o=En("breakpoint"),c=En("container"),u=En("spacing"),h=En("radius"),f=En("shadow"),m=En("inset-shadow"),g=En("text-shadow"),y=En("drop-shadow"),v=En("blur"),w=En("perspective"),N=En("aspect"),k=En("ease"),C=En("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...A(),$e,ze],D=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto","contain","none"],P=()=>[$e,ze,u],L=()=>[ml,"full","auto",...P()],z=()=>[si,"none","subgrid",$e,ze],ee=()=>["auto",{span:["full",si,$e,ze]},si,$e,ze],U=()=>[si,"auto",$e,ze],he=()=>["auto","min","max","fr",$e,ze],me=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],O=()=>["auto",...P()],X=()=>[ml,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],$=()=>[t,$e,ze],le=()=>[...A(),Qv,Yv,{position:[$e,ze]}],Y=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",eI,Q5,{size:[$e,ze]}],W=()=>[Im,Rc,lo],K=()=>["","none","full",h,$e,ze],B=()=>["",dt,Rc,lo],oe=()=>["solid","dashed","dotted","double"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[dt,Im,Qv,Yv],se=()=>["","none",v,$e,ze],ye=()=>["none",dt,$e,ze],Me=()=>["none",dt,$e,ze],Be=()=>[dt,$e,ze],He=()=>[ml,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[fa],breakpoint:[fa],color:[K5],container:[fa],"drop-shadow":[fa],ease:["in","out","in-out"],font:[Y5],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[fa],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[fa],shadow:[fa],spacing:["px",dt],text:[fa],"text-shadow":[fa],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ml,ze,$e,N]}],container:["container"],columns:[{columns:[dt,ze,$e,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:I()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:_()}],"overscroll-x":[{"overscroll-x":_()}],"overscroll-y":[{"overscroll-y":_()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[si,"auto",$e,ze]}],basis:[{basis:[ml,"full","auto",c,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[dt,ml,"auto","initial","none",ze]}],grow:[{grow:["",dt,$e,ze]}],shrink:[{shrink:["",dt,$e,ze]}],order:[{order:[si,"first","last","none",$e,ze]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:ee()}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:ee()}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":he()}],"auto-rows":[{"auto-rows":he()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...me(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...me()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":me()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:O()}],mx:[{mx:O()}],my:[{my:O()}],ms:[{ms:O()}],me:[{me:O()}],mt:[{mt:O()}],mr:[{mr:O()}],mb:[{mb:O()}],ml:[{ml:O()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:X()}],w:[{w:[c,"screen",...X()]}],"min-w":[{"min-w":[c,"screen","none",...X()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...X()]}],h:[{h:["screen","lh",...X()]}],"min-h":[{"min-h":["screen","lh","none",...X()]}],"max-h":[{"max-h":["screen","lh",...X()]}],"font-size":[{text:["base",n,Rc,lo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,$e,Rm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Im,ze]}],"font-family":[{font:[Z5,ze,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,$e,ze]}],"line-clamp":[{"line-clamp":[dt,"none",$e,Rm]}],leading:[{leading:[i,...P()]}],"list-image":[{"list-image":["none",$e,ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",$e,ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[dt,"from-font","auto",$e,lo]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[dt,"auto",$e,ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$e,ze]}],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",$e,ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:le()}],"bg-repeat":[{bg:Y()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},si,$e,ze],radial:["",$e,ze],conic:[si,$e,ze]},tI,X5]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:K()}],"rounded-s":[{"rounded-s":K()}],"rounded-e":[{"rounded-e":K()}],"rounded-t":[{"rounded-t":K()}],"rounded-r":[{"rounded-r":K()}],"rounded-b":[{"rounded-b":K()}],"rounded-l":[{"rounded-l":K()}],"rounded-ss":[{"rounded-ss":K()}],"rounded-se":[{"rounded-se":K()}],"rounded-ee":[{"rounded-ee":K()}],"rounded-es":[{"rounded-es":K()}],"rounded-tl":[{"rounded-tl":K()}],"rounded-tr":[{"rounded-tr":K()}],"rounded-br":[{"rounded-br":K()}],"rounded-bl":[{"rounded-bl":K()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[dt,$e,ze]}],"outline-w":[{outline:["",dt,Rc,lo]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",f,Ru,Iu]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",m,Ru,Iu]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[dt,lo]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",g,Ru,Iu]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[dt,$e,ze]}],"mix-blend":[{"mix-blend":[...G(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":G()}],"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":[dt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Q()}],"mask-image-linear-to-pos":[{"mask-linear-to":Q()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":Q()}],"mask-image-t-to-pos":[{"mask-t-to":Q()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":Q()}],"mask-image-r-to-pos":[{"mask-r-to":Q()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":Q()}],"mask-image-b-to-pos":[{"mask-b-to":Q()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":Q()}],"mask-image-l-to-pos":[{"mask-l-to":Q()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":Q()}],"mask-image-x-to-pos":[{"mask-x-to":Q()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":Q()}],"mask-image-y-to-pos":[{"mask-y-to":Q()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[$e,ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":Q()}],"mask-image-radial-to-pos":[{"mask-radial-to":Q()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"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":A()}],"mask-image-conic-pos":[{"mask-conic":[dt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Q()}],"mask-image-conic-to-pos":[{"mask-conic-to":Q()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:le()}],"mask-repeat":[{mask:Y()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",$e,ze]}],filter:[{filter:["","none",$e,ze]}],blur:[{blur:se()}],brightness:[{brightness:[dt,$e,ze]}],contrast:[{contrast:[dt,$e,ze]}],"drop-shadow":[{"drop-shadow":["","none",y,Ru,Iu]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",dt,$e,ze]}],"hue-rotate":[{"hue-rotate":[dt,$e,ze]}],invert:[{invert:["",dt,$e,ze]}],saturate:[{saturate:[dt,$e,ze]}],sepia:[{sepia:["",dt,$e,ze]}],"backdrop-filter":[{"backdrop-filter":["","none",$e,ze]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[dt,$e,ze]}],"backdrop-contrast":[{"backdrop-contrast":[dt,$e,ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",dt,$e,ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[dt,$e,ze]}],"backdrop-invert":[{"backdrop-invert":["",dt,$e,ze]}],"backdrop-opacity":[{"backdrop-opacity":[dt,$e,ze]}],"backdrop-saturate":[{"backdrop-saturate":[dt,$e,ze]}],"backdrop-sepia":[{"backdrop-sepia":["",dt,$e,ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",$e,ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[dt,"initial",$e,ze]}],ease:[{ease:["linear","initial",k,$e,ze]}],delay:[{delay:[dt,$e,ze]}],animate:[{animate:["none",C,$e,ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,$e,ze]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ye()}],"rotate-x":[{"rotate-x":ye()}],"rotate-y":[{"rotate-y":ye()}],"rotate-z":[{"rotate-z":ye()}],scale:[{scale:Me()}],"scale-x":[{"scale-x":Me()}],"scale-y":[{"scale-y":Me()}],"scale-z":[{"scale-z":Me()}],"scale-3d":["scale-3d"],skew:[{skew:Be()}],"skew-x":[{"skew-x":Be()}],"skew-y":[{"skew-y":Be()}],transform:[{transform:[$e,ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:He()}],"translate-x":[{"translate-x":He()}],"translate-y":[{"translate-y":He()}],"translate-z":[{"translate-z":He()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"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",$e,ze]}],"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":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"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",$e,ze]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[dt,Rc,lo,Rm]}],stroke:[{stroke:["none",...$()]}],"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"]}},aI=z5(sI);function Ct(...t){return aI(aj(t))}const iI=ij("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 ne({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?rj:"button";return s.jsx(i,{"data-slot":"button",className:Ct(iI({variant:e,size:n,className:t})),...a})}function ie({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:Ct("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 oI(){const t=Oi(),[e,n]=b.useState(""),[r,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:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){s5(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 s.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),s.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),s.jsxs("div",{className:"w-full max-w-md relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.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:s.jsx(Hx,{className:"w-8 h-8 text-[#38bdac]"})}),s.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),s.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),s.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[s.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),s.jsxs("div",{className:"relative",children:[s.jsx(vo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ie,{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]"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),s.jsxs("div",{className:"relative",children:[s.jsx(ZM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ie,{type:"password",value:r,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&&s.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:i}),s.jsx(ne,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),s.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Se=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Se.displayName="Card";const qe=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("flex flex-col space-y-1.5 p-6",t),...e}));qe.displayName="CardHeader";const Ge=b.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:Ct("font-semibold leading-none tracking-tight",t),...e}));Ge.displayName="CardTitle";const Ht=b.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:Ct("text-sm text-muted-foreground",t),...e}));Ht.displayName="CardDescription";const Ce=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("p-6 pt-0",t),...e}));Ce.displayName="CardContent";const lI=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("flex items-center p-6 pt-0",t),...e}));lI.displayName="CardFooter";const cI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Pm(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=cI[e],i=document.createElement("div");i.id=r,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(r),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 de={success:(t,e)=>Pm(t,"success",e),error:(t,e)=>Pm(t,"error",e),info:(t,e)=>Pm(t,"info",e)};function at(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 dI(t,e){const n=b.createContext(e),r=i=>{const{children:o,...c}=i,u=b.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.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[r,a]}function Di(t,e=[]){let n=[];function r(i,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:g,children:y,...v}=m,w=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,N=b.useMemo(()=>v,Object.values(v));return s.jsx(w.Provider,{value:N,children:y})};h.displayName=i+"Provider";function f(m,g){var w;const y=((w=g==null?void 0:g[t])==null?void 0:w[u])||c,v=b.useContext(y);if(v)return v;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,[r,uI(a,...e)]}function uI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.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 rr=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},hI=mf[" useId ".trim().toString()]||(()=>{}),fI=0;function wi(t){const[e,n]=b.useState(hI());return rr(()=>{n(r=>r??String(fI++))},[t]),e?`radix-${e}`:""}var pI=mf[" useInsertionEffect ".trim().toString()]||rr;function Co({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=mI({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(`${r} 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,r])}const h=b.useCallback(f=>{var m;if(c){const g=gI(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 mI({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return pI(()=>{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,r,i]}function gI(t){return typeof t=="function"}function od(t){const e=xI(t),n=b.forwardRef((r,a)=>{const{children:i,...o}=r,c=b.Children.toArray(i),u=c.find(bI);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 s.jsx(e,{...o,ref:a,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function xI(t){const e=b.forwardRef((n,r)=>{const{children:a,...i}=n;if(b.isValidElement(a)){const o=NI(a),c=vI(i,a.props);return a.type!==b.Fragment&&(c.ref=r?Kx(r,o):o),b.cloneElement(a,c)}return b.Children.count(a)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var yI=Symbol("radix.slottable");function bI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===yI}function vI(t,e){const n={...e};for(const r in e){const a=t[r],i=e[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const u=i(...c);return a(...c),u}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function NI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.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 wI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ut=wI.reduce((t,e)=>{const n=od(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function jI(t,e){t&&wd.flushSync(()=>t.dispatchEvent(e))}function Ei(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function kI(t,e=globalThis==null?void 0:globalThis.document){const n=Ei(t);b.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var SI="DismissableLayer",Fg="dismissableLayer.update",CI="dismissableLayer.pointerDownOutside",EI="dismissableLayer.focusOutside",Xv,bj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Gx=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(bj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),v=St(e,_=>m(_)),w=Array.from(h.layers),[N]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(N),C=f?w.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,A=C>=k,I=AI(_=>{const P=_.target,L=[...h.branches].some(z=>z.contains(P));!A||L||(a==null||a(_),o==null||o(_),_.defaultPrevented||c==null||c())},g),D=II(_=>{const P=_.target;[...h.branches].some(z=>z.contains(P))||(i==null||i(_),o==null||o(_),_.defaultPrevented||c==null||c())},g);return kI(_=>{C===h.layers.size-1&&(r==null||r(_),!_.defaultPrevented&&c&&(_.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(Xv=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),Zv(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Xv)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),Zv())},[f,h]),b.useEffect(()=>{const _=()=>y({});return document.addEventListener(Fg,_),()=>document.removeEventListener(Fg,_)},[]),s.jsx(ut.div,{...u,ref:v,style:{pointerEvents:E?A?"auto":"none":void 0,...t.style},onFocusCapture:at(t.onFocusCapture,D.onFocusCapture),onBlurCapture:at(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:at(t.onPointerDownCapture,I.onPointerDownCapture)})});Gx.displayName=SI;var TI="DismissableLayerBranch",MI=b.forwardRef((t,e)=>{const n=b.useContext(bj),r=b.useRef(null),a=St(e,r);return b.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(ut.div,{...t,ref:a})});MI.displayName=TI;function AI(t,e=globalThis==null?void 0:globalThis.document){const n=Ei(t),r=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){vj(CI,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);r.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:()=>r.current=!0}}function II(t,e=globalThis==null?void 0:globalThis.document){const n=Ei(t),r=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!r.current&&vj(EI,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Zv(){const t=new CustomEvent(Fg);document.dispatchEvent(t)}function vj(t,e,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),r?jI(a,i):a.dispatchEvent(i)}var Om="focusScope.autoFocusOnMount",Dm="focusScope.autoFocusOnUnmount",e1={bubbles:!1,cancelable:!0},RI="FocusScope",Jx=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=b.useState(null),h=Ei(a),f=Ei(i),m=b.useRef(null),g=St(e,w=>u(w)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let w=function(E){if(y.paused||!c)return;const A=E.target;c.contains(A)?m.current=A:oi(m.current,{select:!0})},N=function(E){if(y.paused||!c)return;const A=E.relatedTarget;A!==null&&(c.contains(A)||oi(m.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const I of E)I.removedNodes.length>0&&oi(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",N);const C=new MutationObserver(k);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",N),C.disconnect()}}},[r,c,y.paused]),b.useEffect(()=>{if(c){n1.add(y);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(Om,e1);c.addEventListener(Om,h),c.dispatchEvent(k),k.defaultPrevented||(PI(zI(Nj(c)),{select:!0}),document.activeElement===w&&oi(c))}return()=>{c.removeEventListener(Om,h),setTimeout(()=>{const k=new CustomEvent(Dm,e1);c.addEventListener(Dm,f),c.dispatchEvent(k),k.defaultPrevented||oi(w??document.body,{select:!0}),c.removeEventListener(Dm,f),n1.remove(y)},0)}}},[c,h,f,y]);const v=b.useCallback(w=>{if(!n&&!r||y.paused)return;const N=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(N&&k){const C=w.currentTarget,[E,A]=OI(C);E&&A?!w.shiftKey&&k===A?(w.preventDefault(),n&&oi(E,{select:!0})):w.shiftKey&&k===E&&(w.preventDefault(),n&&oi(A,{select:!0})):k===C&&w.preventDefault()}},[n,r,y.paused]);return s.jsx(ut.div,{tabIndex:-1,...o,ref:g,onKeyDown:v})});Jx.displayName=RI;function PI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(oi(r,{select:e}),document.activeElement!==n)return}function OI(t){const e=Nj(t),n=t1(e,t),r=t1(e.reverse(),t);return[n,r]}function Nj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function t1(t,e){for(const n of t)if(!DI(n,{upTo:e}))return n}function DI(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 LI(t){return t instanceof HTMLInputElement&&"select"in t}function oi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&LI(t)&&e&&t.select()}}var n1=_I();function _I(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=r1(t,e),t.unshift(e)},remove(e){var n;t=r1(t,e),(n=t[0])==null||n.resume()}}}function r1(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function zI(t){return t.filter(e=>e.tagName!=="A")}var $I="Portal",Yx=b.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=b.useState(!1);rr(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Ow.createPortal(s.jsx(ut.div,{...r,ref:e}),o):null});Yx.displayName=$I;function FI(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var jd=t=>{const{present:e,children:n}=t,r=BI(e),a=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),i=St(r.ref,VI(a));return typeof n=="function"||r.isPresent?b.cloneElement(a,{ref:i}):null};jd.displayName="Presence";function BI(t){const[e,n]=b.useState(),r=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=FI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=Pu(r.current);i.current=c==="mounted"?h:"none"},[c]),rr(()=>{const h=r.current,f=a.current;if(f!==t){const g=i.current,y=Pu(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]),rr(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const w=Pu(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(u("ANIMATION_END"),!a.current)){const N=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=N)})}},g=y=>{y.target===e&&(i.current=Pu(r.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=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function Pu(t){return(t==null?void 0:t.animationName)||"none"}function VI(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.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 Lm=0;function wj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??s1()),document.body.insertAdjacentElement("beforeend",t[1]??s1()),Lm++,()=>{Lm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Lm--}},[])}function s1(){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 Vs=function(){return Vs=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return aR;var e=iR(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},lR=Cj(),Al="data-scroll-locked",cR=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` + .`.concat(WI,` { + overflow: hidden `).concat(r,`; + padding-right: `).concat(c,"px ").concat(r,`; + } + body[`).concat(Al,`] { + overflow: hidden `).concat(r,`; + overscroll-behavior: contain; + `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&` + padding-left: `.concat(a,`px; + padding-top: `).concat(i,`px; + padding-right: `).concat(o,`px; + margin-left:0; + margin-top:0; + margin-right: `).concat(c,"px ").concat(r,`; + `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),` + } + + .`).concat(th,` { + right: `).concat(c,"px ").concat(r,`; + } + + .`).concat(nh,` { + margin-right: `).concat(c,"px ").concat(r,`; + } + + .`).concat(th," .").concat(th,` { + right: 0 `).concat(r,`; + } + + .`).concat(nh," .").concat(nh,` { + margin-right: 0 `).concat(r,`; + } + + body[`).concat(Al,`] { + `).concat(UI,": ").concat(c,`px; + } +`)},i1=function(){var t=parseInt(document.body.getAttribute(Al)||"0",10);return isFinite(t)?t:0},dR=function(){b.useEffect(function(){return document.body.setAttribute(Al,(i1()+1).toString()),function(){var t=i1()-1;t<=0?document.body.removeAttribute(Al):document.body.setAttribute(Al,t.toString())}},[])},uR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;dR();var i=b.useMemo(function(){return oR(a)},[a]);return b.createElement(lR,{styles:cR(i,!e,a,n?"":"!important")})},Bg=!1;if(typeof window<"u")try{var Ou=Object.defineProperty({},"passive",{get:function(){return Bg=!0,!0}});window.addEventListener("test",Ou,Ou),window.removeEventListener("test",Ou,Ou)}catch{Bg=!1}var gl=Bg?{passive:!1}:!1,hR=function(t){return t.tagName==="TEXTAREA"},Ej=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!hR(t)&&n[e]==="visible")},fR=function(t){return Ej(t,"overflowY")},pR=function(t){return Ej(t,"overflowX")},o1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Tj(t,r);if(a){var i=Mj(t,r),o=i[1],c=i[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},mR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},gR=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Tj=function(t,e){return t==="v"?fR(e):pR(e)},Mj=function(t,e){return t==="v"?mR(e):gR(e)},xR=function(t,e){return t==="h"&&e==="rtl"?-1:1},yR=function(t,e,n,r,a){var i=xR(t,window.getComputedStyle(e).direction),o=i*r,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=Mj(t,c),v=y[0],w=y[1],N=y[2],k=w-N-i*v;(v||k)&&Tj(t,c)&&(m+=k,g+=v);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},Du=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},l1=function(t){return[t.deltaX,t.deltaY]},c1=function(t){return t&&"current"in t?t.current:t},bR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},vR=function(t){return` + .block-interactivity-`.concat(t,` {pointer-events: none;} + .allow-interactivity-`).concat(t,` {pointer-events: all;} +`)},NR=0,xl=[];function wR(t){var e=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),a=b.useState(NR++)[0],i=b.useState(Cj)[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 w=HI([t.lockRef.current],(t.shards||[]).map(c1),!0).filter(Boolean);return w.forEach(function(N){return N.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(N){return N.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(w,N){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=Du(w),C=n.current,E="deltaX"in w?w.deltaX:C[0]-k[0],A="deltaY"in w?w.deltaY:C[1]-k[1],I,D=w.target,_=Math.abs(E)>Math.abs(A)?"h":"v";if("touches"in w&&_==="h"&&D.type==="range")return!1;var P=window.getSelection(),L=P&&P.anchorNode,z=L?L===D||L.contains(D):!1;if(z)return!1;var ee=o1(_,D);if(!ee)return!0;if(ee?I=_:(I=_==="v"?"h":"v",ee=o1(_,D)),!ee)return!1;if(!r.current&&"changedTouches"in w&&(E||A)&&(r.current=I),!I)return!0;var U=r.current||I;return yR(U,N,w,U==="h"?E:A)},[]),u=b.useCallback(function(w){var N=w;if(!(!xl.length||xl[xl.length-1]!==i)){var k="deltaY"in N?l1(N):Du(N),C=e.current.filter(function(I){return I.name===N.type&&(I.target===N.target||N.target===I.shadowParent)&&bR(I.delta,k)})[0];if(C&&C.should){N.cancelable&&N.preventDefault();return}if(!C){var E=(o.current.shards||[]).map(c1).filter(Boolean).filter(function(I){return I.contains(N.target)}),A=E.length>0?c(N,E[0]):!o.current.noIsolation;A&&N.cancelable&&N.preventDefault()}}},[]),h=b.useCallback(function(w,N,k,C){var E={name:w,delta:N,target:k,should:C,shadowParent:jR(k)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(A){return A!==E})},1)},[]),f=b.useCallback(function(w){n.current=Du(w),r.current=void 0},[]),m=b.useCallback(function(w){h(w.type,l1(w),w.target,c(w,t.lockRef.current))},[]),g=b.useCallback(function(w){h(w.type,Du(w),w.target,c(w,t.lockRef.current))},[]);b.useEffect(function(){return xl.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,gl),document.addEventListener("touchmove",u,gl),document.addEventListener("touchstart",f,gl),function(){xl=xl.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,gl),document.removeEventListener("touchmove",u,gl),document.removeEventListener("touchstart",f,gl)}},[]);var y=t.removeScrollBar,v=t.inert;return b.createElement(b.Fragment,null,v?b.createElement(i,{styles:vR(a)}):null,y?b.createElement(uR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function jR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const kR=XI(Sj,wR);var Qx=b.forwardRef(function(t,e){return b.createElement(bf,Vs({},t,{ref:e,sideCar:kR}))});Qx.classNames=bf.classNames;var SR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},yl=new WeakMap,Lu=new WeakMap,_u={},Fm=0,Aj=function(t){return t&&(t.host||Aj(t.parentNode))},CR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=Aj(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},ER=function(t,e,n,r){var a=CR(e,Array.isArray(t)?t:[t]);_u[n]||(_u[n]=new WeakMap);var i=_u[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(r),v=y!==null&&y!=="false",w=(yl.get(g)||0)+1,N=(i.get(g)||0)+1;yl.set(g,w),i.set(g,N),o.push(g),w===1&&v&&Lu.set(g,!0),N===1&&g.setAttribute(n,"true"),v||g.setAttribute(r,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return f(e),c.clear(),Fm++,function(){o.forEach(function(m){var g=yl.get(m)-1,y=i.get(m)-1;yl.set(m,g),i.set(m,y),g||(Lu.has(m)||m.removeAttribute(r),Lu.delete(m)),y||m.removeAttribute(n)}),Fm--,Fm||(yl=new WeakMap,yl=new WeakMap,Lu=new WeakMap,_u={})}},Ij=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=SR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),ER(r,a,n,"aria-hidden")):function(){return null}},vf="Dialog",[Rj]=Di(vf),[TR,ks]=Rj(vf),Pj=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=Co({prop:r,defaultProp:a??!1,onChange:i,caller:vf});return s.jsx(TR,{scope:e,triggerRef:c,contentRef:u,contentId:wi(),titleId:wi(),descriptionId:wi(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Pj.displayName=vf;var Oj="DialogTrigger",MR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ks(Oj,n),i=St(e,a.triggerRef);return s.jsx(ut.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":e0(a.open),...r,ref:i,onClick:at(t.onClick,a.onOpenToggle)})});MR.displayName=Oj;var Xx="DialogPortal",[AR,Dj]=Rj(Xx,{forceMount:void 0}),Lj=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=ks(Xx,e);return s.jsx(AR,{scope:e,forceMount:n,children:b.Children.map(r,o=>s.jsx(jd,{present:n||i.open,children:s.jsx(Yx,{asChild:!0,container:a,children:o})}))})};Lj.displayName=Xx;var xh="DialogOverlay",_j=b.forwardRef((t,e)=>{const n=Dj(xh,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=ks(xh,t.__scopeDialog);return i.modal?s.jsx(jd,{present:r||i.open,children:s.jsx(RR,{...a,ref:e})}):null});_j.displayName=xh;var IR=od("DialogOverlay.RemoveScroll"),RR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ks(xh,n);return s.jsx(Qx,{as:IR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(ut.div,{"data-state":e0(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Eo="DialogContent",zj=b.forwardRef((t,e)=>{const n=Dj(Eo,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=ks(Eo,t.__scopeDialog);return s.jsx(jd,{present:r||i.open,children:i.modal?s.jsx(PR,{...a,ref:e}):s.jsx(OR,{...a,ref:e})})});zj.displayName=Eo;var PR=b.forwardRef((t,e)=>{const n=ks(Eo,t.__scopeDialog),r=b.useRef(null),a=St(e,n.contentRef,r);return b.useEffect(()=>{const i=r.current;if(i)return Ij(i)},[]),s.jsx($j,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:at(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:at(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:at(t.onFocusOutside,i=>i.preventDefault())})}),OR=b.forwardRef((t,e)=>{const n=ks(Eo,t.__scopeDialog),r=b.useRef(!1),a=b.useRef(!1);return s.jsx($j,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,i),i.defaultPrevented||(r.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()}})}),$j=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=ks(Eo,n),u=b.useRef(null),h=St(e,u);return wj(),s.jsxs(s.Fragment,{children:[s.jsx(Jx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(Gx,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":e0(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(DR,{titleId:c.titleId}),s.jsx(_R,{contentRef:u,descriptionId:c.descriptionId})]})]})}),Zx="DialogTitle",Fj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ks(Zx,n);return s.jsx(ut.h2,{id:a.titleId,...r,ref:e})});Fj.displayName=Zx;var Bj="DialogDescription",Vj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ks(Bj,n);return s.jsx(ut.p,{id:a.descriptionId,...r,ref:e})});Vj.displayName=Bj;var Hj="DialogClose",Wj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=ks(Hj,n);return s.jsx(ut.button,{type:"button",...r,ref:e,onClick:at(t.onClick,()=>a.onOpenChange(!1))})});Wj.displayName=Hj;function e0(t){return t?"open":"closed"}var Uj="DialogTitleWarning",[YV,Kj]=dI(Uj,{contentName:Eo,titleName:Zx,docsSlug:"dialog"}),DR=({titleId:t})=>{const e=Kj(Uj),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},LR="DialogDescriptionWarning",_R=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Kj(LR).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(r))},[r,t,e]),null},zR=Pj,$R=Lj,FR=_j,BR=zj,VR=Fj,HR=Vj,WR=Wj;function Ft(t){return s.jsx(zR,{"data-slot":"dialog",...t})}function UR(t){return s.jsx($R,{...t})}const qj=b.forwardRef(({className:t,...e},n)=>s.jsx(FR,{ref:n,className:Ct("fixed inset-0 z-50 bg-black/50",t),...e}));qj.displayName="DialogOverlay";const Rt=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs(UR,{children:[s.jsx(qj,{}),s.jsxs(BR,{ref:a,"aria-describedby":void 0,className:Ct("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),...r,children:[e,n&&s.jsxs(WR,{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:[s.jsx(nr,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Rt.displayName="DialogContent";function Bt({className:t,...e}){return s.jsx("div",{className:Ct("flex flex-col gap-2 text-center sm:text-left",t),...e})}function ln({className:t,...e}){return s.jsx("div",{className:Ct("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Vt(t){return s.jsx(VR,{className:"text-lg font-semibold leading-none",...t})}function Gj(t){return s.jsx(HR,{className:"text-sm text-muted-foreground",...t})}const KR=ij("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,...r}){const a=n?rj:"span";return s.jsx(a,{className:Ct(KR({variant:e}),t),...r})}var qR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],GR=qR.reduce((t,e)=>{const n=nj(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...c}=a,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),JR="Label",Jj=b.forwardRef((t,e)=>s.jsx(GR.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())}}));Jj.displayName=JR;var Yj=Jj;const te=b.forwardRef(({className:t,...e},n)=>s.jsx(Yj,{ref:n,className:Ct("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));te.displayName=Yj.displayName;function t0(t){const e=t+"CollectionProvider",[n,r]=Di(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:N,children:k}=w,C=fr.useRef(null),E=fr.useRef(new Map).current;return s.jsx(a,{scope:N,itemMap:E,collectionRef:C,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=od(c),h=fr.forwardRef((w,N)=>{const{scope:k,children:C}=w,E=i(c,k),A=St(N,E.collectionRef);return s.jsx(u,{ref:A,children:C})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=od(f),y=fr.forwardRef((w,N)=>{const{scope:k,children:C,...E}=w,A=fr.useRef(null),I=St(N,A),D=i(f,k);return fr.useEffect(()=>(D.itemMap.set(A,{ref:A,...E}),()=>void D.itemMap.delete(A))),s.jsx(g,{[m]:"",ref:I,children:C})});y.displayName=f;function v(w){const N=i(t+"CollectionConsumer",w);return fr.useCallback(()=>{const C=N.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${m}]`));return Array.from(N.itemMap.values()).sort((D,_)=>E.indexOf(D.ref.current)-E.indexOf(_.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},v,r]}var YR=b.createContext(void 0);function Nf(t){const e=b.useContext(YR);return t||e||"ltr"}var Bm="rovingFocusGroup.onEntryFocus",QR={bubbles:!1,cancelable:!0},kd="RovingFocusGroup",[Vg,Qj,XR]=t0(kd),[ZR,Xj]=Di(kd,[XR]),[eP,tP]=ZR(kd),Zj=b.forwardRef((t,e)=>s.jsx(Vg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Vg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(nP,{...t,ref:e})})}));Zj.displayName=kd;var nP=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=St(e,g),v=Nf(i),[w,N]=Co({prop:o,defaultProp:c??null,onChange:u,caller:kd}),[k,C]=b.useState(!1),E=Ei(h),A=Qj(n),I=b.useRef(!1),[D,_]=b.useState(0);return b.useEffect(()=>{const P=g.current;if(P)return P.addEventListener(Bm,E),()=>P.removeEventListener(Bm,E)},[E]),s.jsx(eP,{scope:n,orientation:r,dir:v,loop:a,currentTabStopId:w,onItemFocus:b.useCallback(P=>N(P),[N]),onItemShiftTab:b.useCallback(()=>C(!0),[]),onFocusableItemAdd:b.useCallback(()=>_(P=>P+1),[]),onFocusableItemRemove:b.useCallback(()=>_(P=>P-1),[]),children:s.jsx(ut.div,{tabIndex:k||D===0?-1:0,"data-orientation":r,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:at(t.onMouseDown,()=>{I.current=!0}),onFocus:at(t.onFocus,P=>{const L=!I.current;if(P.target===P.currentTarget&&L&&!k){const z=new CustomEvent(Bm,QR);if(P.currentTarget.dispatchEvent(z),!z.defaultPrevented){const ee=A().filter(O=>O.focusable),U=ee.find(O=>O.active),he=ee.find(O=>O.id===w),R=[U,he,...ee].filter(Boolean).map(O=>O.ref.current);nk(R,f)}}I.current=!1}),onBlur:at(t.onBlur,()=>C(!1))})})}),ek="RovingFocusGroupItem",tk=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=wi(),h=i||u,f=tP(ek,n),m=f.currentTabStopId===h,g=Qj(n),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:w}=f;return b.useEffect(()=>{if(r)return y(),()=>v()},[r,y,v]),s.jsx(Vg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(ut.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:at(t.onMouseDown,N=>{r?f.onItemFocus(h):N.preventDefault()}),onFocus:at(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:at(t.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){f.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const k=aP(N,f.orientation,f.dir);if(k!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let E=g().filter(A=>A.focusable).map(A=>A.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const A=E.indexOf(N.currentTarget);E=f.loop?iP(E,A+1):E.slice(A+1)}setTimeout(()=>nk(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});tk.displayName=ek;var rP={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sP(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function aP(t,e,n){const r=sP(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return rP[r]}function nk(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function iP(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var oP=Zj,lP=tk,wf="Tabs",[cP]=Di(wf,[Xj]),rk=Xj(),[dP,n0]=cP(wf),sk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Nf(c),[m,g]=Co({prop:r,onChange:a,defaultProp:i??"",caller:wf});return s.jsx(dP,{scope:n,baseId:wi(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:s.jsx(ut.div,{dir:f,"data-orientation":o,...h,ref:e})})});sk.displayName=wf;var ak="TabsList",ik=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=n0(ak,n),o=rk(n);return s.jsx(oP,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(ut.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});ik.displayName=ak;var ok="TabsTrigger",lk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=n0(ok,n),c=rk(n),u=uk(o.baseId,r),h=hk(o.baseId,r),f=r===o.value;return s.jsx(lP,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(ut.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:at(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:at(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:at(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});lk.displayName=ok;var ck="TabsContent",dk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=n0(ck,n),u=uk(c.baseId,r),h=hk(c.baseId,r),f=r===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(jd,{present:a||f,children:({present:g})=>s.jsx(ut.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})})});dk.displayName=ck;function uk(t,e){return`${t}-trigger-${e}`}function hk(t,e){return`${t}-content-${e}`}var uP=sk,fk=ik,pk=lk,mk=dk;const Sd=uP,Gl=b.forwardRef(({className:t,...e},n)=>s.jsx(fk,{ref:n,className:Ct("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Gl.displayName=fk.displayName;const tn=b.forwardRef(({className:t,...e},n)=>s.jsx(pk,{ref:n,className:Ct("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}));tn.displayName=pk.displayName;const nn=b.forwardRef(({className:t,...e},n)=>s.jsx(mk,{ref:n,className:Ct("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));nn.displayName=mk.displayName;function r0(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 s0(t){const[e,n]=b.useState(void 0);return rr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=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 r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var jf="Switch",[hP]=Di(jf),[fP,pP]=hP(jf),gk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),v=St(e,E=>y(E)),w=b.useRef(!1),N=g?f||!!g.closest("form"):!0,[k,C]=Co({prop:a,defaultProp:i??!1,onChange:h,caller:jf});return s.jsxs(fP,{scope:n,checked:k,disabled:c,children:[s.jsx(ut.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":vk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:v,onClick:at(t.onClick,E=>{C(A=>!A),N&&(w.current=E.isPropagationStopped(),w.current||E.stopPropagation())})}),N&&s.jsx(bk,{control:g,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});gk.displayName=jf;var xk="SwitchThumb",yk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=pP(xk,n);return s.jsx(ut.span,{"data-state":vk(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});yk.displayName=xk;var mP="SwitchBubbleInput",bk=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=b.useRef(null),c=St(o,i),u=r0(n),h=s0(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 v=new Event("click",{bubbles:r});y.call(f,n),f.dispatchEvent(v)}},[u,n,r]),s.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}})});bk.displayName=mP;function vk(t){return t?"checked":"unchecked"}var Nk=gk,gP=yk;const Et=b.forwardRef(({className:t,...e},n)=>s.jsx(Nk,{className:Ct("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:s.jsx(gP,{className:Ct("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")})}));Et.displayName=Nk.displayName;function a0({open:t,onClose:e,userId:n,onUserUpdated:r}){var or;const[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState(!1),[g,y]=b.useState(!1),[v,w]=b.useState(!1),[N,k]=b.useState("info"),[C,E]=b.useState(""),[A,I]=b.useState(""),[D,_]=b.useState([]),[P,L]=b.useState(""),[z,ee]=b.useState(""),[U,he]=b.useState(""),[me,R]=b.useState(!1),[O,X]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[$,le]=b.useState([]),[Y,F]=b.useState(!1),[W,K]=b.useState(!1),[B,oe]=b.useState(null),[G,Q]=b.useState(null),[se,ye]=b.useState(""),[Me,Be]=b.useState(""),[He,gt]=b.useState(""),[Dt,jn]=b.useState(!1),[it,Mt]=b.useState(null),[re,Pe]=b.useState("");b.useEffect(()=>{t&&n&&(k("info"),oe(null),Q(null),Mt(null),Pe(""),ee(""),he(""),et(),De("/api/db/vip-roles").then(ge=>{ge!=null&&ge.success&&ge.data&&le(ge.data)}).catch(()=>{}))},[t,n]);async function et(){if(n){m(!0);try{const ge=await De(`/api/db/users?id=${encodeURIComponent(n)}`);if(ge!=null&&ge.success&&ge.user){const Ne=ge.user;i(Ne),E(Ne.phone||""),I(Ne.nickname||""),ye(Ne.phone||""),Be(Ne.wechatId||""),gt(Ne.openId||"");try{_(typeof Ne.tags=="string"?JSON.parse(Ne.tags||"[]"):[])}catch{_([])}X({isVip:!!(Ne.isVip??!1),vipExpireDate:Ne.vipExpireDate?String(Ne.vipExpireDate).slice(0,10):"",vipRole:String(Ne.vipRole??""),vipName:String(Ne.vipName??""),vipProject:String(Ne.vipProject??""),vipContact:String(Ne.vipContact??""),vipBio:String(Ne.vipBio??"")})}try{const Ne=await De(`/api/user/track?userId=${encodeURIComponent(n)}&limit=50`);Ne!=null&&Ne.success&&Ne.tracks&&c(Ne.tracks)}catch{c([])}try{const Ne=await De(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);Ne!=null&&Ne.success&&Ne.referrals&&h(Ne.referrals)}catch{h([])}}catch(ge){console.error("Load user detail error:",ge)}finally{m(!1)}}}async function xt(){if(!(a!=null&&a.phone)){de.info("用户未绑定手机号,无法同步");return}y(!0);try{const ge=await Nt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});ge!=null&&ge.success?(de.success("同步成功"),et()):de.error("同步失败: "+(ge==null?void 0:ge.error))}catch(ge){console.error("Sync CKB error:",ge),de.error("同步失败")}finally{y(!1)}}async function ft(){if(a){w(!0);try{const ge={id:a.id,phone:C||void 0,nickname:A||void 0,tags:JSON.stringify(D)},Ne=await Tt("/api/db/users",ge);Ne!=null&&Ne.success?(de.success("保存成功"),et(),r==null||r()):de.error("保存失败: "+(Ne==null?void 0:Ne.error))}catch(ge){console.error("Save user error:",ge),de.error("保存失败")}finally{w(!1)}}}const pt=()=>{P&&!D.includes(P)&&(_([...D,P]),L(""))},wt=ge=>_(D.filter(Ne=>Ne!==ge));async function Qt(){if(a){if(!z){de.error("请输入新密码");return}if(z!==U){de.error("两次密码不一致");return}if(z.length<6){de.error("密码至少 6 位");return}R(!0);try{const ge=await Tt("/api/db/users",{id:a.id,password:z});ge!=null&&ge.success?(de.success("修改成功"),ee(""),he("")):de.error("修改失败: "+((ge==null?void 0:ge.error)||""))}catch{de.error("修改失败")}finally{R(!1)}}}async function Lt(){if(a){if(O.isVip&&!O.vipExpireDate.trim()){de.error("开启 VIP 请填写有效到期日");return}F(!0);try{const ge={id:a.id,isVip:O.isVip,vipExpireDate:O.isVip?O.vipExpireDate:void 0,vipRole:O.vipRole||void 0,vipName:O.vipName||void 0,vipProject:O.vipProject||void 0,vipContact:O.vipContact||void 0,vipBio:O.vipBio||void 0},Ne=await Tt("/api/db/users",ge);Ne!=null&&Ne.success?(de.success("VIP 设置已保存"),et(),r==null||r()):de.error("保存失败: "+((Ne==null?void 0:Ne.error)||""))}catch{de.error("保存失败")}finally{F(!1)}}}async function An(){if(!se&&!He&&!Me){Q("请至少输入手机号、微信号或 OpenID 中的一项");return}K(!0),Q(null),oe(null);try{const ge=new URLSearchParams;se&&ge.set("phone",se),He&&ge.set("openId",He),Me&&ge.set("wechatId",Me);const Ne=await De(`/api/admin/shensheshou/query?${ge}`);Ne!=null&&Ne.success&&Ne.data?(oe(Ne.data),a&&await At(Ne.data)):Q((Ne==null?void 0:Ne.error)||"未查询到数据,该用户可能未在神射手收录")}catch(ge){console.error("SSS query error:",ge),Q("请求失败,请检查神射手接口配置")}finally{K(!1)}}async function At(ge){if(a)try{await Nt("/api/admin/shensheshou/enrich",{userId:a.id,phone:se||a.phone||"",openId:He||a.openId||"",wechatId:Me||a.wechatId||""}),et()}catch(Ne){console.error("SSS enrich error:",Ne)}}async function Kn(){if(a){jn(!0),Mt(null);try{const ge={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:D}]},Ne=await Nt("/api/admin/shensheshou/ingest",ge);Ne!=null&&Ne.success&&Ne.data?Mt(Ne.data):Mt({error:(Ne==null?void 0:Ne.error)||"推送失败"})}catch(ge){console.error("SSS ingest error:",ge),Mt({error:"请求失败"})}finally{jn(!1)}}}const ts=ge=>{const qn={view_chapter:$r,purchase:Lg,match:Mn,login:vo,register:vo,share:vs,bind_phone:yA,bind_wechat:iA,fill_profile:Kc,visit_page:El}[ge]||Rg;return s.jsx(qn,{className:"w-4 h-4"})};return t?s.jsx(Ft,{open:t,onOpenChange:()=>e(),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(vo,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),f?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):a?s.jsxs("div",{className:"flex flex-col min-h-0 flex-1 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[s.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?s.jsx("img",{src:a.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((or=a.nickname)==null?void 0:or.charAt(0))||"?"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-lg font-bold text-white",children:a.nickname}),a.isAdmin&&s.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),a.hasFullBook&&s.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),a.vipRole&&s.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0",children:a.vipRole})]}),s.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[a.phone?`📱 ${a.phone}`:"未绑定手机",a.wechatId&&` · 💬 ${a.wechatId}`,a.mbti&&` · ${a.mbti}`]}),s.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[s.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",a.id.slice(0,16),"…"]}),a.referralCode&&s.jsxs("p",{className:"text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"推广码:"}),s.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:a.referralCode})]})]})]}),s.jsxs("div",{className:"text-right shrink-0",children:[s.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(a.earnings||0).toFixed(2)]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),s.jsxs(Sd,{value:N,onValueChange:k,className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs(Gl,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[s.jsx(tn,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),s.jsx(tn,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),s.jsxs(tn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(El,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),s.jsx(tn,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),s.jsxs(tn,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(xi,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),s.jsxs(nn,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"手机号"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:C,onChange:ge=>E(ge.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:A,onChange:ge=>I(ge.target.value)})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.openId&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),s.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:a.openId})]}),a.region&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(Zw,{className:"w-4 h-4 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),s.jsx("p",{className:"text-white",children:a.region})]})]}),a.industry&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),s.jsx("p",{className:"text-white",children:a.industry})]}),a.position&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),s.jsx("p",{className:"text-white",children:a.position})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:a.referralCount??0})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),s.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(a.pendingEarnings??0).toFixed(2)]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),s.jsx("p",{className:"text-sm text-white",children:a.createdAt?new Date(a.createdAt).toLocaleDateString():"-"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Xw,{className:"w-4 h-4 text-yellow-400"}),s.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ie,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:z,onChange:ge=>ee(ge.target.value)}),s.jsx(ie,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:U,onChange:ge=>he(ge.target.value)}),s.jsx(ne,{size:"sm",onClick:Qt,disabled:me||!z||!U,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:me?"保存中...":"确认修改"})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Ml,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-400 text-sm",children:"VIP 会员"}),s.jsx(Et,{checked:O.isVip,onCheckedChange:ge=>X(Ne=>({...Ne,isVip:ge}))})]}),O.isVip&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"到期日"}),s.jsx(ie,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:O.vipExpireDate,onChange:ge=>X(Ne=>({...Ne,vipExpireDate:ge.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:O.vipRole,onChange:ge=>X(Ne=>({...Ne,vipRole:ge.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),$.map(ge=>s.jsx("option",{value:ge.name,children:ge.name},ge.id))]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"展示名"}),s.jsx(ie,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:O.vipName,onChange:ge=>X(Ne=>({...Ne,vipName:ge.target.value}))})]}),s.jsx(ne,{size:"sm",onClick:Lt,disabled:Y,className:"bg-amber-500/20 hover:bg-amber-500/30 text-amber-400 border border-amber-500/40",children:Y?"保存中...":"保存 VIP"})]})]})]}),a.isVip&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Ml,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),s.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:a.vipRole||"VIP"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[a.vipName&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"展示名:"}),s.jsx("span",{className:"text-white",children:a.vipName})]}),a.vipProject&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"项目:"}),s.jsx("span",{className:"text-white",children:a.vipProject})]}),a.vipContact&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"联系方式:"}),s.jsx("span",{className:"text-white",children:a.vipContact})]}),a.vipExpireDate&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"到期时间:"}),s.jsx("span",{className:"text-white",children:new Date(a.vipExpireDate).toLocaleDateString()})]})]}),a.vipBio&&s.jsx("p",{className:"text-gray-400 text-sm mt-2",children:a.vipBio})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Ol,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"微信归属"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(ie,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:re,onChange:ge=>Pe(ge.target.value)}),s.jsxs(ne,{size:"sm",onClick:async()=>{if(!(!re||!a))try{await Tt("/api/db/users",{id:a.id,wechatId:re}),de.success("已保存微信归属"),et()}catch{de.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[s.jsx(mn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),a.wechatId&&s.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",s.jsx("span",{className:"text-purple-400",children:a.wechatId})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(vs,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),s.jsx(ne,{size:"sm",onClick:xt,disabled:g||!a.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"同步状态:"}),a.ckbSyncedAt?s.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):s.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"最后同步:"}),s.jsx("span",{className:"text-gray-300 ml-1",children:a.ckbSyncedAt?new Date(a.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),s.jsxs(nn,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Kc,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),s.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:[s.jsx(Ig,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),s.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(ge=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:ge.category}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:ge.tags.map(Ne=>s.jsxs("button",{type:"button",onClick:()=>{D.includes(Ne)?wt(Ne):_([...D,Ne])},className:`px-2 py-0.5 rounded text-xs border transition-all ${D.includes(Ne)?"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:[D.includes(Ne)?"✓ ":"",Ne]},Ne))})]},ge.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[D.map((ge,Ne)=>s.jsxs(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[ge,s.jsx("button",{type:"button",onClick:()=>wt(ge),className:"ml-1 hover:text-red-400",children:s.jsx(nr,{className:"w-3 h-3"})})]},Ne)),D.length===0&&s.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ie,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:P,onChange:ge=>L(ge.target.value),onKeyDown:ge=>ge.key==="Enter"&&pt()}),s.jsx(ne,{onClick:pt,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),a.ckbTags&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Kc,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:(typeof a.ckbTags=="string"?a.ckbTags.split(","):[]).map((ge,Ne)=>s.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 border-0",children:ge.trim()},Ne))})]})]}),s.jsxs(nn,{value:"journey",className:"flex-1 overflow-auto",children:[s.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(El,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),s.jsx("div",{className:"space-y-2",children:o.length>0?o.map((ge,Ne)=>s.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:ts(ge.action)}),Ne0?u.map((ge,Ne)=>{var Cs;const qn=ge;return s.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((Cs=qn.nickname)==null?void 0:Cs.charAt(0))||"?"}),s.jsx("span",{className:"text-white text-sm",children:qn.nickname})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[qn.status==="vip"&&s.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-xs",children:qn.createdAt?new Date(qn.createdAt).toLocaleDateString():""})]})]},qn.id||Ne)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),s.jsxs(nn,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(xi,{className:"w-5 h-5 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),s.jsx(ie,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:se,onChange:ge=>ye(ge.target.value)})]}),s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),s.jsx(ie,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:Me,onChange:ge=>Be(ge.target.value)})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx(te,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),s.jsx(ie,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:He,onChange:ge=>gt(ge.target.value)})]})]}),s.jsx(ne,{onClick:An,disabled:W,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:W?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ka,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),s.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),G&&s.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:G}),B&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),s.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:B.rfm_score??"-"})]}),s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:B.user_level??"-"})]})]}),B.tags&&B.tags.length>0&&s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:B.tags.map((ge,Ne)=>s.jsx(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:ge},Ne))})]}),B.last_active&&s.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",B.last_active]})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx(xi,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),s.jsx(ne,{onClick:Kn,disabled:Dt||!a.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:Dt?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):s.jsxs(s.Fragment,{children:[s.jsx(xi,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!a.phone&&s.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),it&&s.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:it.error?s.jsx("p",{className:"text-red-400",children:String(it.error)}):s.jsxs("div",{className:"space-y-1",children:[s.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[s.jsx(Ig,{className:"w-4 h-4"})," 推送成功"]}),it.enriched!==void 0&&s.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(it.new_tags_added??0)]})]})})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(ne,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(ne,{onClick:ft,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}):null}function xP(){const t=Oi(),[e,n]=b.useState(!0),[r,a]=b.useState(!0),[i,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,v]=b.useState(0),[w,N]=b.useState(0),[k,C]=b.useState(0),[E,A]=b.useState(0),[I,D]=b.useState(null),[_,P]=b.useState(null),[L,z]=b.useState(!1),[ee,U]=b.useState("today"),[he,me]=b.useState(null),[R,O]=b.useState(!1),X=K=>{const B=K;if((B==null?void 0:B.status)===401)D("登录已过期,请重新登录");else{if((B==null?void 0:B.name)==="AbortError")return;D("加载失败,请检查网络或联系管理员")}};async function $(K){const B=K?{signal:K}:void 0;n(!0),D(null);try{const Q=await De("/api/admin/dashboard/stats",B);Q!=null&&Q.success&&(g(Q.totalUsers??0),v(Q.paidOrderCount??0),N(Q.totalRevenue??0),C(Q.conversionRate??0))}catch(Q){if((Q==null?void 0:Q.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",Q);try{const se=await De("/api/admin/dashboard/overview",B);se!=null&&se.success&&(g(se.totalUsers??0),v(se.paidOrderCount??0),N(se.totalRevenue??0),C(se.conversionRate??0))}catch(se){X(se)}}}finally{n(!1)}try{const Q=await De("/api/admin/balance/summary",B);Q!=null&&Q.success&&Q.data&&A(Q.data.totalGifted??0)}catch{}a(!0),o(!0);const oe=async()=>{try{const Q=await De("/api/admin/dashboard/recent-orders",B);if(Q!=null&&Q.success&&Q.recentOrders)f(Q.recentOrders);else throw new Error("no data")}catch(Q){if((Q==null?void 0:Q.name)!=="AbortError")try{const se=await De("/api/admin/orders?page=1&pageSize=20&status=paid",B),Me=((se==null?void 0:se.orders)??[]).filter(Be=>["paid","completed","success"].includes(Be.status||""));f(Me.slice(0,5))}catch{f([])}}finally{a(!1)}},G=async()=>{try{const Q=await De("/api/admin/dashboard/new-users",B);if(Q!=null&&Q.success&&Q.newUsers)u(Q.newUsers);else throw new Error("no data")}catch(Q){if((Q==null?void 0:Q.name)!=="AbortError")try{const se=await De("/api/db/users?page=1&pageSize=10",B);u((se==null?void 0:se.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([oe(),G()])}async function le(K){const B=K||ee;O(!0);try{const oe=await De(`/api/admin/track/stats?period=${B}`);oe!=null&&oe.success&&me({total:oe.total??0,byModule:oe.byModule??{}})}catch{me(null)}finally{O(!1)}}b.useEffect(()=>{const K=new AbortController;$(K.signal),le();const B=setInterval(()=>{$(),le()},3e4);return()=>{K.abort(),clearInterval(B)}},[]);const Y=m,F=K=>{const B=K.productType||"",oe=K.description||"";if(oe){if(B==="section"&&oe.includes("章节")){if(oe.includes("-")){const G=oe.split("-");if(G.length>=3)return{title:`第${G[1]}章 第${G[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:oe,subtitle:"章节购买"}}return B==="fullbook"||oe.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:B==="match"||oe.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:oe,subtitle:B==="section"?"单章":B==="fullbook"?"全书":"其他"}}return B==="section"?{title:`章节 ${K.productId||""}`,subtitle:"单章购买"}:B==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:B==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:B||"其他"}},W=[{title:"总用户数",value:e?null:Y,sub:null,icon:Mn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:E>0?`含代付 ¥${E.toFixed(2)}`:null,icon:bo,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,sub:null,icon:Lg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${k.toFixed(1)}%`,sub:null,icon:bo,color:"text-amber-400",bg:"bg-amber-500/20",link:"/users"}];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),I&&s.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:[s.jsx("span",{children:I}),s.jsx("button",{type:"button",onClick:()=>$(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6",children:W.map((K,B)=>s.jsxs(Se,{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:[s.jsxs(qe,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(Ge,{className:"text-sm font-medium text-gray-400",children:K.title}),s.jsx("div",{className:`p-2 rounded-lg ${K.bg}`,children:s.jsx(K.icon,{className:`w-4 h-4 ${K.color}`})})]}),s.jsx(Ce,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white min-h-8 flex items-center",children:K.value!=null?K.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Ue,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),K.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:K.sub})]}),s.jsx(Cl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},B))}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between",children:[s.jsx(Ge,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>$(),disabled:r||i,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[r||i?s.jsx(Ue,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ue,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),s.jsx(Ce,{children:s.jsx("div",{className:"space-y-3",children:r&&h.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ue,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,5).map(K=>{var se;const B=K.referrerId?c.find(ye=>ye.id===K.referrerId):void 0,oe=K.referralCode||(B==null?void 0:B.referralCode)||(B==null?void 0:B.nickname)||(K.referrerId?String(K.referrerId).slice(0,8):""),G=F(K),Q=K.userNickname||((se=c.find(ye=>ye.id===K.userId))==null?void 0:se.nickname)||"匿名用户";return s.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:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[K.userAvatar?s.jsx("img",{src:K.userAvatar,alt:Q,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:ye=>{ye.currentTarget.style.display="none";const Me=ye.currentTarget.nextElementSibling;Me&&Me.classList.remove("hidden")}}):null,s.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:Q.charAt(0)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("button",{type:"button",onClick:()=>{K.userId&&(P(K.userId),z(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:Q}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",children:G.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[G.subtitle&&G.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:G.subtitle}),s.jsx("span",{children:new Date(K.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),oe&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",oe]})]})]}),s.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(K.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:K.paymentMethod||"微信"})]})]},K.id)}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Lg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"新注册用户"})}),s.jsx(Ce,{children:s.jsx("div",{className:"space-y-3",children:i&&c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ue,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[c.slice(0,5).map(K=>{var B;return s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((B=K.nickname)==null?void 0:B.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{P(K.id),z(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:K.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:K.phone||"-"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:K.createdAt?new Date(K.createdAt).toLocaleDateString():"-"})]},K.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mt-8",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between",children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Ag,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(K=>s.jsx("button",{type:"button",onClick:()=>{U(K),le(K)},className:`px-3 py-1 text-xs rounded-full transition-colors ${ee===K?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[K]},K))})]}),s.jsx(Ce,{children:R&&!he?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ue,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):he&&Object.keys(he.byModule).length>0?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("p",{className:"text-sm text-gray-400",children:["总点击 ",s.jsx("span",{className:"text-white font-bold text-lg",children:he.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(he.byModule).sort((K,B)=>B[1].reduce((oe,G)=>oe+G.count,0)-K[1].reduce((oe,G)=>oe+G.count,0)).map(([K,B])=>{const oe=B.reduce((Q,se)=>Q+se.count,0),G={home:"首页",chapters:"目录",read:"阅读",my:"我的",vip:"VIP",wallet:"钱包",match:"找伙伴",referral:"推广",search:"搜索",settings:"设置",about:"关于",other:"其他"};return s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("span",{className:"text-sm font-medium text-[#38bdac]",children:G[K]||K}),s.jsxs("span",{className:"text-xs text-gray-500",children:[oe," 次"]})]}),s.jsx("div",{className:"space-y-2",children:B.sort((Q,se)=>se.count-Q.count).slice(0,8).map((Q,se)=>s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:`${Q.action}: ${Q.target}`,children:Q.target||Q.action}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("div",{className:"w-16 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full",style:{width:`${oe>0?Q.count/oe*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:Q.count})]})]},se))})]},K)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Ag,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无点击数据"}),s.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),s.jsx(a0,{open:L,onClose:()=>{z(!1),P(null)},userId:_,onUserUpdated:()=>$()})]})}const pr=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:Ct("w-full caption-bottom text-sm",t),...e})}));pr.displayName="Table";const mr=b.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:Ct("[&_tr]:border-b",t),...e}));mr.displayName="TableHeader";const gr=b.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:Ct("[&_tr:last-child]:border-0",t),...e}));gr.displayName="TableBody";const lt=b.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:Ct("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));lt.displayName="TableRow";const Ee=b.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:Ct("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));Ee.displayName="TableHead";const be=b.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:Ct("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));be.displayName="TableCell";function i0(t,e){const[n,r]=b.useState(t);return b.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function Ns({page:t,totalPages:e,total:n,pageSize:r,onPageChange:a,onPageSizeChange:i,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!i?null:s.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[s.jsxs("span",{children:["共 ",n," 条"]}),i&&s.jsx("select",{value:r,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=>s.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:"首页"}),s.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:"上一页"}),s.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),s.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:"下一页"}),s.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 yP(){const[t,e]=b.useState([]),[n,r]=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),[v,w]=b.useState(""),N=i0(v,300),[k,C]=b.useState("all"),[E,A]=b.useState(!0),[I,D]=b.useState(null),[_,P]=b.useState(null),[L,z]=b.useState(""),[ee,U]=b.useState(!1);async function he(){A(!0),D(null);try{const Y=k==="all"?"":k==="completed"?"completed":k,F=new URLSearchParams({page:String(f),pageSize:String(g),...Y&&{status:Y},...N&&{search:N}}),[W,K]=await Promise.all([De(`/api/admin/orders?${F}`),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)),K!=null&&K.success&&K.users&&r(K.users)}catch(Y){console.error("加载订单失败",Y),D("加载订单失败,请检查网络后重试")}finally{A(!1)}}b.useEffect(()=>{m(1)},[N,k]),b.useEffect(()=>{he()},[f,g,N,k]);const me=Y=>{var F;return Y.userNickname||((F=n.find(W=>W.id===Y.userId))==null?void 0:F.nickname)||"匿名用户"},R=Y=>{var F;return((F=n.find(W=>W.id===Y))==null?void 0:F.phone)||"-"},O=Y=>{const F=Y.productType||Y.type||"",W=Y.description||"";if(W){if(F==="section"&&W.includes("章节")){if(W.includes("-")){const K=W.split("-");if(K.length>=3)return{name:`第${K[1]}章 第${K[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return F==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:F==="vip"||W.includes("VIP")?{name:"VIP年度会员",type:"VIP"}:F==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return F==="section"?{name:`章节 ${Y.productId||Y.sectionId||""}`,type:"单章"}:F==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:F==="vip"?{name:"VIP年度会员",type:"VIP"}:F==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:F||"其他"}},X=Math.ceil(a/g)||1;async function $(){var Y;if(!(!(_!=null&&_.orderSn)&&!(_!=null&&_.id))){U(!0),D(null);try{const F=await Tt("/api/admin/orders/refund",{orderSn:_.orderSn||_.id,reason:L||void 0});F!=null&&F.success?(P(null),z(""),he()):D((F==null?void 0:F.error)||"退款失败")}catch(F){const W=F;D(((Y=W==null?void 0:W.data)==null?void 0:Y.error)||"退款失败,请检查网络后重试")}finally{U(!1)}}}function le(){if(t.length===0){de.info("暂无数据可导出");return}const Y=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],F=t.map(G=>{const Q=O(G);return[G.orderSn||G.id||"",me(G),R(G.userId),Q.name,Number(G.amount||0).toFixed(2),G.paymentMethod==="wechat"?"微信支付":G.paymentMethod==="alipay"?"支付宝":G.paymentMethod||"微信支付",G.status==="refunded"?"已退款":G.status==="paid"||G.status==="completed"?"已完成":G.status==="pending"||G.status==="created"?"待支付":"已失败",G.status==="refunded"&&G.refundReason?G.refundReason:"-",G.referrerEarnings?Number(G.referrerEarnings).toFixed(2):"-",G.createdAt?new Date(G.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[Y.join(","),...F].join(` +`),K=new Blob([W],{type:"text/csv;charset=utf-8"}),B=URL.createObjectURL(K),oe=document.createElement("a");oe.href=B,oe.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,oe.click(),URL.revokeObjectURL(B)}return s.jsxs("div",{className:"p-8 w-full",children:[I&&s.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:[s.jsx("span",{children:I}),s.jsx("button",{type:"button",onClick:()=>D(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(ne,{variant:"outline",onClick:he,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`}),"刷新"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"text-gray-400",children:"总收入:"}),s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),s.jsx("span",{className:"text-gray-600",children:"|"}),s.jsx("span",{className:"text-gray-400",children:"今日:"}),s.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(ka,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ie,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:v,onChange:Y=>w(Y.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yw,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:Y=>C(Y.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(ne,{variant:"outline",onClick:le,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(pM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:E?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"订单号"}),s.jsx(Ee,{className:"text-gray-400",children:"用户"}),s.jsx(Ee,{className:"text-gray-400",children:"商品"}),s.jsx(Ee,{className:"text-gray-400",children:"金额"}),s.jsx(Ee,{className:"text-gray-400",children:"支付方式"}),s.jsx(Ee,{className:"text-gray-400",children:"状态"}),s.jsx(Ee,{className:"text-gray-400",children:"退款原因"}),s.jsx(Ee,{className:"text-gray-400",children:"分销佣金"}),s.jsx(Ee,{className:"text-gray-400",children:"下单时间"}),s.jsx(Ee,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(gr,{children:[t.map(Y=>{const F=O(Y);return s.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(be,{className:"font-mono text-xs text-gray-400",children:[(Y.orderSn||Y.id||"").slice(0,12),"..."]}),s.jsx(be,{children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:me(Y)}),s.jsx("p",{className:"text-gray-500 text-xs",children:R(Y.userId)})]})}),s.jsx(be,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[F.name,(Y.productType||Y.type)==="vip"&&s.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"VIP"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:F.type})]})}),s.jsxs(be,{className:"text-[#38bdac] font-bold",children:["¥",Number(Y.amount||0).toFixed(2)]}),s.jsx(be,{className:"text-gray-300",children:Y.paymentMethod==="wechat"?"微信支付":Y.paymentMethod==="alipay"?"支付宝":Y.paymentMethod||"微信支付"}),s.jsx(be,{children:Y.status==="refunded"?s.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):Y.status==="paid"||Y.status==="completed"?s.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):Y.status==="pending"||Y.status==="created"?s.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),s.jsx(be,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:Y.refundReason,children:Y.status==="refunded"&&Y.refundReason?Y.refundReason:"-"}),s.jsx(be,{className:"text-[#FFD700]",children:Y.referrerEarnings?`¥${Number(Y.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(be,{className:"text-gray-400 text-sm",children:new Date(Y.createdAt).toLocaleString("zh-CN")}),s.jsx(be,{children:(Y.status==="paid"||Y.status==="completed")&&s.jsxs(ne,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{P(Y),z("")},children:[s.jsx(ej,{className:"w-3 h-3 mr-1"}),"退款"]})})]},Y.id)}),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(Ns,{page:f,totalPages:X,total:a,pageSize:g,onPageChange:m,onPageSizeChange:Y=>{y(Y),m(1)}})]})})}),s.jsx(Ft,{open:!!_,onOpenChange:Y=>!Y&&P(null),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Bt,{children:s.jsx(Vt,{className:"text-white",children:"订单退款"})}),_&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",_.orderSn||_.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(_.amount||0).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:L,onChange:Y=>z(Y.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>P(null),disabled:ee,children:"取消"}),s.jsx(ne,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:$,disabled:ee,children:ee?"退款中...":"确认退款"})]})]})})]})}const Jl=b.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:Ct("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}));Jl.displayName="Textarea";const Pc=[{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 bP(){var $a,ta,Is,Rs,Ps,Os;const[t,e]=Ww(),n=t.get("pool"),[r,a]=b.useState([]),[i,o]=b.useState(0),[c,u]=b.useState(1),[h,f]=b.useState(10),[m,g]=b.useState(""),y=i0(m,300),v=n==="vip"?"vip":n==="complete"?"complete":"all",[w,N]=b.useState(v),[k,C]=b.useState(!0),[E,A]=b.useState(!1),[I,D]=b.useState(null),[_,P]=b.useState(!1),[L,z]=b.useState("desc");b.useEffect(()=>{n==="vip"?N("vip"):n==="complete"?N("complete"):n==="all"&&N("all")},[n]);const[ee,U]=b.useState(!1),[he,me]=b.useState(null),[R,O]=b.useState(!1),[X,$]=b.useState(!1),[le,Y]=b.useState({referrals:[],stats:{}}),[F,W]=b.useState(!1),[K,B]=b.useState(null),[oe,G]=b.useState(!1),[Q,se]=b.useState(null),[ye,Me]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Be,He]=b.useState([]),[gt,Dt]=b.useState(!1),[jn,it]=b.useState(!1),[Mt,re]=b.useState(null),[Pe,et]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[xt,ft]=b.useState([]),[pt,wt]=b.useState(!1),[Qt,Lt]=b.useState(null),[An,At]=b.useState(null),[Kn,ts]=b.useState({}),[or,ge]=b.useState(!1),[Ne,qn]=b.useState(null),[Cs,Es]=b.useState([]),[Ra,br]=b.useState(!1),[Bi,vr]=b.useState(!1);async function lr(V=!1){var Ie;C(!0),V&&A(!0),D(null);try{if(_){const Ye=new URLSearchParams({search:y,limit:String(h*5)}),ct=await De(`/api/db/users/rfm?${Ye}`);if(ct!=null&&ct.success){let xn=ct.users||[];L==="asc"&&(xn=[...xn].reverse());const kn=(c-1)*h;a(xn.slice(kn,kn+h)),o(((Ie=ct.users)==null?void 0:Ie.length)??0),xn.length===0&&(P(!1),D("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else P(!1),D((ct==null?void 0:ct.error)||"RFM 加载失败,已切回普通模式")}else{const Ye=new URLSearchParams({page:String(c),pageSize:String(h),search:y,...w==="vip"&&{vip:"true"},...w==="complete"&&{pool:"complete"}}),ct=await De(`/api/db/users?${Ye}`);ct!=null&&ct.success?(a(ct.users||[]),o(ct.total??0)):D((ct==null?void 0:ct.error)||"加载失败")}}catch(Ye){console.error("Load users error:",Ye),D("网络错误")}finally{C(!1),V&&A(!1)}}b.useEffect(()=>{u(1)},[y,w,_]),b.useEffect(()=>{lr()},[c,h,y,w,_,L]);const Ts=Math.ceil(i/h)||1,Pa=()=>{_?L==="desc"?z("asc"):(P(!1),z("desc")):(P(!0),z("desc"))},Vi=V=>({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"})[V||""]||"bg-gray-500/20 text-gray-400";async function Qs(V){if(confirm("确定要删除这个用户吗?"))try{const Ie=await Na(`/api/db/users?id=${encodeURIComponent(V)}`);Ie!=null&&Ie.success?lr():de.error("删除失败: "+((Ie==null?void 0:Ie.error)||""))}catch{de.error("删除失败")}}const vt=V=>{me(V),Me({phone:V.phone||"",nickname:V.nickname||"",password:"",isAdmin:!!(V.isAdmin??!1),hasFullBook:!!(V.hasFullBook??!1)}),U(!0)},Gn=()=>{me(null),Me({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),U(!0)};async function Oa(){if(!ye.phone||!ye.nickname){de.error("请填写手机号和昵称");return}O(!0);try{if(he){const V=await Tt("/api/db/users",{id:he.id,nickname:ye.nickname,isAdmin:ye.isAdmin,hasFullBook:ye.hasFullBook,...ye.password&&{password:ye.password}});if(!(V!=null&&V.success)){de.error("更新失败: "+((V==null?void 0:V.error)||""));return}}else{const V=await Nt("/api/db/users",{phone:ye.phone,nickname:ye.nickname,password:ye.password,isAdmin:ye.isAdmin});if(!(V!=null&&V.success)){de.error("创建失败: "+((V==null?void 0:V.error)||""));return}}U(!1),lr()}catch{de.error("保存失败")}finally{O(!1)}}async function Ms(V){B(V),$(!0),W(!0);try{const Ie=await De(`/api/db/users/referrals?userId=${encodeURIComponent(V.id)}`);Ie!=null&&Ie.success?Y({referrals:Ie.referrals||[],stats:Ie.stats||{}}):Y({referrals:[],stats:{}})}catch{Y({referrals:[],stats:{}})}finally{W(!1)}}const Nr=b.useCallback(async()=>{Dt(!0);try{const V=await De("/api/db/user-rules");V!=null&&V.success&&He(V.rules||[])}catch{}finally{Dt(!1)}},[]);async function Hi(){if(!Pe.title){de.error("请填写规则标题");return}O(!0);try{if(Mt){const V=await Tt("/api/db/user-rules",{id:Mt.id,...Pe});if(!(V!=null&&V.success)){de.error("更新失败: "+((V==null?void 0:V.error)||""));return}}else{const V=await Nt("/api/db/user-rules",Pe);if(!(V!=null&&V.success)){de.error("创建失败: "+((V==null?void 0:V.error)||""));return}}it(!1),Nr()}catch{de.error("保存失败")}finally{O(!1)}}async function Xs(V){if(confirm("确定删除?"))try{const Ie=await Na(`/api/db/user-rules?id=${V}`);Ie!=null&&Ie.success&&Nr()}catch{}}async function tc(V){try{await Tt("/api/db/user-rules",{id:V.id,enabled:!V.enabled}),Nr()}catch{}}const Jn=b.useCallback(async()=>{wt(!0);try{const V=await De("/api/db/vip-members?limit=500");if(V!=null&&V.success&&V.data){const Ie=[...V.data].map((Ye,ct)=>({...Ye,vipSort:typeof Ye.vipSort=="number"?Ye.vipSort:ct+1}));Ie.sort((Ye,ct)=>(Ye.vipSort??999999)-(ct.vipSort??999999)),ft(Ie)}else V&&V.error&&de.error(V.error)}catch{de.error("加载超级个体列表失败")}finally{wt(!1)}},[]),[Zs,ns]=b.useState(!1),[Ar,Da]=b.useState(null),[ea,Wi]=b.useState(""),[cr,Ui]=b.useState(!1),rs=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],nc=V=>{Da(V),Wi(V.vipRole||""),ns(!0)},Bo=async V=>{const Ie=V.trim();if(Ar){if(!Ie){de.error("请选择或输入标签");return}Ui(!0);try{const Ye=await Tt("/api/db/users",{id:Ar.id,vipRole:Ie});if(!(Ye!=null&&Ye.success)){de.error((Ye==null?void 0:Ye.error)||"更新超级个体标签失败");return}de.success("已更新超级个体标签"),ns(!1),Da(null),await Jn()}catch{de.error("更新超级个体标签失败")}finally{Ui(!1)}}},[Ki,un]=b.useState(!1),[ss,As]=b.useState(null),[La,It]=b.useState(""),[zn,Vr]=b.useState(!1),Vo=V=>{As(V),It(V.vipSort!=null?String(V.vipSort):""),un(!0)},_a=async()=>{if(!ss)return;const V=Number(La);if(!Number.isFinite(V)){de.error("请输入有效的数字序号");return}Vr(!0);try{const Ie=await Tt("/api/db/users",{id:ss.id,vipSort:V});if(!(Ie!=null&&Ie.success)){de.error((Ie==null?void 0:Ie.error)||"更新排序序号失败");return}de.success("已更新排序序号"),un(!1),As(null),await Jn()}catch{de.error("更新排序序号失败")}finally{Vr(!1)}},rc=(V,Ie)=>{V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/plain",Ie),Lt(Ie)},qi=(V,Ie)=>{V.preventDefault(),An!==Ie&&At(Ie)},za=()=>{Lt(null),At(null)},dr=async(V,Ie)=>{V.preventDefault();const Ye=V.dataTransfer.getData("text/plain")||Qt;if(Lt(null),At(null),!Ye||Ye===Ie)return;const ct=xt.find(Xt=>Xt.id===Ye),xn=xt.find(Xt=>Xt.id===Ie);if(!ct||!xn)return;const kn=ct.vipSort??xt.findIndex(Xt=>Xt.id===Ye)+1,Wo=xn.vipSort??xt.findIndex(Xt=>Xt.id===Ie)+1;ft(Xt=>{const st=[...Xt],Fa=st.findIndex(na=>na.id===Ye),Ba=st.findIndex(na=>na.id===Ie);if(Fa===-1||Ba===-1)return Xt;const is=[...st],[Uo,Ko]=[is[Fa],is[Ba]];return is[Fa]={...Ko,vipSort:kn},is[Ba]={...Uo,vipSort:Wo},is});try{const[Xt,st]=await Promise.all([Tt("/api/db/users",{id:Ye,vipSort:Wo}),Tt("/api/db/users",{id:Ie,vipSort:kn})]);if(!(Xt!=null&&Xt.success)||!(st!=null&&st.success)){de.error((Xt==null?void 0:Xt.error)||(st==null?void 0:st.error)||"更新排序失败"),await Jn();return}de.success("已更新排序"),await Jn()}catch{de.error("更新排序失败"),await Jn()}},as=b.useCallback(async()=>{ge(!0);try{const V=await De("/api/db/users/journey-stats");V!=null&&V.success&&V.stats&&ts(V.stats)}catch{}finally{ge(!1)}},[]);async function $n(V){qn(V),br(!0);try{const Ie=await De(`/api/db/users/journey-users?stage=${encodeURIComponent(V)}&limit=20`);Ie!=null&&Ie.success&&Ie.users?Es(Ie.users):Es([])}catch{Es([])}finally{br(!1)}}async function Ho(V){if(!V.hasFullBook){de.error("仅 VIP 用户可置顶到超级个体");return}if(confirm("确定将该用户置顶到首页超级个体位?(最多4位)"))try{const Ie=await Tt("/api/db/users",{id:V.id,vipSort:1});if(!(Ie!=null&&Ie.success)){de.error((Ie==null?void 0:Ie.error)||"置顶失败");return}de.success("已置顶到超级个体"),lr()}catch{de.error("置顶失败")}}return s.jsxs("div",{className:"p-8 w-full",children:[I&&s.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:[s.jsx("span",{children:I}),s.jsx("button",{type:"button",onClick:()=>D(null),children:"×"})]}),s.jsx("div",{className:"flex justify-between items-center mb-6",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>vr(!0),className:"text-gray-500 hover:text-[#38bdac] h-8 w-8 p-0",title:"RFM 算法说明",children:s.jsx(zc,{className:"w-4 h-4"})})]}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",i," 位注册用户",_&&" · RFM 排序中"]})]})}),s.jsxs(Sd,{defaultValue:"users",className:"w-full",children:[s.jsxs(Gl,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(tn,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Mn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(tn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:as,children:[s.jsx(El,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(tn,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Nr,children:[s.jsx(yo,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(tn,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Jn,children:[s.jsx(Ml,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(nn,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(ne,{variant:"outline",onClick:()=>lr(!0),disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:w,onChange:V=>{const Ie=V.target.value;N(Ie),u(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:_,children:[s.jsx("option",{value:"all",children:"全部用户"}),s.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),s.jsx("option",{value:"complete",children:"完善资料用户"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(ka,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ie,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:m,onChange:V=>g(V.target.value)})]}),s.jsxs(ne,{onClick:Gn,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(zg,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:k?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"用户信息"}),s.jsx(Ee,{className:"text-gray-400",children:"绑定信息"}),s.jsx(Ee,{className:"text-gray-400",children:"购买状态"}),s.jsx(Ee,{className:"text-gray-400",children:"分销收益"}),s.jsx(Ee,{className:"text-gray-400",children:"余额/提现"}),s.jsxs(Ee,{className:"text-gray-400 cursor-pointer select-none",onClick:Pa,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(bo,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),_?L==="desc"?s.jsx(id,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Kw,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Mm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),_&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(Ee,{className:"text-gray-400",children:"注册时间"}),s.jsx(Ee,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(gr,{children:[r.map(V=>{var Ie,Ye,ct;return s.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:V.avatar?s.jsx("img",{src:V.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Ie=V.nickname)==null?void 0:Ie.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{se(V.id),G(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:V.nickname}),V.isAdmin&&s.jsx(Ke,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),V.openId&&!((Ye=V.id)!=null&&Ye.startsWith("user_"))&&s.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsx("p",{className:"text-xs text-gray-500 font-mono",children:V.openId?V.openId.slice(0,12)+"...":(ct=V.id)==null?void 0:ct.slice(0,12)})]})]})}),s.jsx(be,{children:s.jsxs("div",{className:"space-y-1",children:[V.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:V.phone})]}),V.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:V.wechatId})]}),V.openId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"🔗"}),s.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:V.openId,children:[V.openId.slice(0,12),"..."]})]}),!V.phone&&!V.wechatId&&!V.openId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(be,{children:V.hasFullBook?s.jsx(Ke,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):s.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),s.jsx(be,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(V.earnings||0)).toFixed(2)]}),parseFloat(String(V.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(V.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Ms(V),role:"button",tabIndex:0,onKeyDown:xn=>xn.key==="Enter"&&Ms(V),children:[s.jsx(Mn,{className:"w-3 h-3"})," 绑定",V.referralCount||0,"人"]})]})}),s.jsx(be,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(V.walletBalance||0)).toFixed(2)]}),parseFloat(String(V.withdrawnEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-gray-400",children:["已提现: ¥",parseFloat(String(V.withdrawnEarnings||0)).toFixed(2)]})]})}),s.jsx(be,{children:V.rfmScore!==void 0?s.jsx("div",{className:"flex flex-col gap-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:V.rfmScore}),s.jsx(Ke,{className:`border-0 text-xs ${Vi(V.rfmLevel)}`,children:V.rfmLevel})]})}):s.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",s.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),s.jsx(be,{className:"text-gray-400",children:V.createdAt?new Date(V.createdAt).toLocaleDateString():"-"}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>{se(V.id),G(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(Pg,{className:"w-4 h-4"})}),V.hasFullBook&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Ho(V),className:"text-gray-400 hover:text-orange-400 hover:bg-orange-400/10",title:"置顶超级个体",children:s.jsx(gi,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>vt(V),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx($t,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Qs(V.id),title:"删除",children:s.jsx(er,{className:"w-4 h-4"})})]})})]},V.id)}),r.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(Ns,{page:c,totalPages:Ts,total:i,pageSize:h,onPageChange:u,onPageSizeChange:V=>{f(V),u(1)}})]})})})]}),s.jsxs(nn,{value:"journey",children:[s.jsxs("div",{className:"flex items-center justify-between mb-5",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),s.jsxs(ne,{variant:"outline",onClick:as,disabled:or,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${or?"animate-spin":""}`})," 刷新数据"]})]}),s.jsxs("div",{className:"relative mb-8",children:[s.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"}),s.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:Pc.map((V,Ie)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{role:"button",tabIndex:0,className:`relative w-full p-3 rounded-xl border ${V.color} text-center cursor-pointer`,onClick:()=>$n(V.id),onKeyDown:Ye=>Ye.key==="Enter"&&$n(V.id),children:[s.jsx("div",{className:"text-2xl mb-1",children:V.icon}),s.jsx("div",{className:`text-xs font-medium ${V.color.split(" ").find(Ye=>Ye.startsWith("text-"))}`,children:V.label}),Kn[V.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Kn[V.id]})," 人"]}),s.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:Ie+1})]}),IeV.id===Ne))==null?void 0:$a.label," — 用户列表"]}),s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>qn(null),className:"text-gray-500 hover:text-white",children:[s.jsx(nr,{className:"w-4 h-4"})," 关闭"]})]}),Ra?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ue,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Cs.length>0?s.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:Cs.map(V=>s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-[#0a1628] rounded-lg hover:bg-[#0a1628]/80 cursor-pointer",onClick:()=>{se(V.id),G(!0)},onKeyDown:Ie=>Ie.key==="Enter"&&(se(V.id),G(!0)),role:"button",tabIndex:0,children:[s.jsx("span",{className:"text-white font-medium",children:V.nickname}),s.jsx("span",{className:"text-gray-400 text-sm",children:V.phone||"—"}),s.jsx("span",{className:"text-gray-500 text-xs",children:V.createdAt?new Date(V.createdAt).toLocaleDateString():"—"})]},V.id))}):s.jsx("p",{className:"text-gray-500 text-sm py-4",children:"暂无用户"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(El,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"旅程关键节点"})]}),s.jsx("div",{className:"space-y-2 text-sm",children:[{step:"① 注册",action:"微信 OAuth 或手机号注册",next:"引导填写头像"},{step:"② 浏览",action:"点击章节/阅读免费内容",next:"触发绑定手机"},{step:"③ 首付",action:"购买单章或全书",next:"推送分销功能"},{step:"④ VIP",action:"¥1980 购买全书",next:"进入 VIP 私域群"},{step:"⑤ 分销",action:"推广好友购买",next:"提现分销收益"}].map(V=>s.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:V.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:V.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",V.next]})]})]},V.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx($r,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),s.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),or?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ue,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Kn).length>0?s.jsx("div",{className:"space-y-2",children:Pc.map(V=>{const Ie=Kn[V.id]||0,Ye=Math.max(...Pc.map(xn=>Kn[xn.id]||0),1),ct=Math.round(Ie/Ye*100);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[V.icon," ",V.label]}),s.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${ct}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Ie})]},V.id)})}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),s.jsxs(nn,{value:"rules",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ne,{variant:"outline",onClick:Nr,disabled:gt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${gt?"animate-spin":""}`})," 刷新"]}),s.jsxs(ne,{onClick:()=>{re(null),et({title:"",description:"",trigger:"",sort:0,enabled:!0}),it(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(pn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),gt?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Be.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx($r,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),s.jsxs(ne,{onClick:Nr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:Be.map(V=>s.jsx("div",{className:`p-4 rounded-lg border transition-all ${V.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[s.jsx($t,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium",children:V.title}),V.trigger&&s.jsxs(Ke,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",V.trigger]}),s.jsx(Ke,{className:`text-xs border-0 ${V.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:V.enabled?"启用":"禁用"})]}),V.description&&s.jsx("p",{className:"text-gray-400 text-sm ml-6",children:V.description})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[s.jsx(Et,{checked:V.enabled,onCheckedChange:()=>tc(V)}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>{re(V),et({title:V.title,description:V.description,trigger:V.trigger,sort:V.sort,enabled:V.enabled}),it(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx($t,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Xs(V.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(er,{className:"w-4 h-4"})})]})]})},V.id))})]}),s.jsxs(nn,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(ne,{variant:"outline",onClick:Jn,disabled:pt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${pt?"animate-spin":""}`})," ","刷新"]})})]}),pt?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):xt.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Ml,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400 w-16",children:"序号"}),s.jsx(Ee,{className:"text-gray-400",children:"成员"}),s.jsx(Ee,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),s.jsx(Ee,{className:"text-gray-400 w-24",children:"排序值"}),s.jsx(Ee,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),s.jsx(gr,{children:xt.map((V,Ie)=>{var xn;const Ye=Qt===V.id,ct=An===V.id;return s.jsxs(lt,{draggable:!0,onDragStart:kn=>rc(kn,V.id),onDragOver:kn=>qi(kn,V.id),onDrop:kn=>dr(kn,V.id),onDragEnd:za,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${Ye?"opacity-60":""} ${ct?"bg-[#38bdac]/10":""}`,children:[s.jsx(be,{className:"text-gray-300",children:Ie+1}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[V.avatar?s.jsx("img",{src:V.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.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:((xn=V.name)==null?void 0:xn[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:V.name})})]})}),s.jsx(be,{className:"text-gray-300 whitespace-nowrap",children:V.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),s.jsx(be,{className:"text-gray-300",children:V.vipSort??Ie+1}),s.jsx(be,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>nc(V),title:"设置超级个体标签",children:s.jsx(Kc,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{se(V.id),G(!0)},title:"编辑资料",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Vo(V),title:"设置排序序号",children:s.jsx(Mm,{className:"w-3.5 h-3.5"})})]})})]},V.id)})})]})})})]})]}),s.jsx(Ft,{open:Ki,onOpenChange:V=>{un(V),V||As(null)},children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(Mm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",ss==null?void 0:ss.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:La,onChange:V=>It(V.target.value)})]}),s.jsxs(ln,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>un(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:_a,disabled:zn,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),zn?"保存中...":"保存"]})]})]})}),s.jsx(Ft,{open:Zs,onOpenChange:V=>{ns(V),V||Da(null)},children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ml,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",Ar==null?void 0:Ar.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:rs.map(V=>s.jsx(ne,{variant:ea===V?"default":"outline",size:"sm",className:ea===V?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Wi(V),children:V},V))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:ea,onChange:V=>Wi(V.target.value)})]})]}),s.jsxs(ln,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>ns(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:()=>Bo(ea),disabled:cr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),cr?"保存中...":"保存"]})]})]})}),s.jsx(Ft,{open:ee,onOpenChange:U,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[he?s.jsx($t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(zg,{className:"w-5 h-5 text-[#38bdac]"}),he?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"手机号"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:ye.phone,onChange:V=>Me({...ye,phone:V.target.value}),disabled:!!he})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:ye.nickname,onChange:V=>Me({...ye,nickname:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:he?"新密码 (留空则不修改)":"密码"}),s.jsx(ie,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:he?"留空则不修改":"请输入密码",value:ye.password,onChange:V=>Me({...ye,password:V.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Et,{checked:ye.isAdmin,onCheckedChange:V=>Me({...ye,isAdmin:V})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"已购全书"}),s.jsx(Et,{checked:ye.hasFullBook,onCheckedChange:V=>Me({...ye,hasFullBook:V})})]})]}),s.jsxs(ln,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>U(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:Oa,disabled:R,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),R?"保存中...":"保存"]})]})]})}),s.jsx(Ft,{open:jn,onOpenChange:it,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx($t,{className:"w-5 h-5 text-[#38bdac]"}),Mt?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Pe.title,onChange:V=>et({...Pe,title:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则描述"}),s.jsx(Jl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Pe.description,onChange:V=>et({...Pe,description:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"触发条件"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Pe.trigger,onChange:V=>et({...Pe,trigger:V.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(te,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Et,{checked:Pe.enabled,onCheckedChange:V=>et({...Pe,enabled:V})})]})]}),s.jsxs(ln,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>it(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:Hi,disabled:R,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),R?"保存中...":"保存"]})]})]})}),s.jsx(Ft,{open:X,onOpenChange:$,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",K==null?void 0:K.nickname]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((ta=le.stats)==null?void 0:ta.total)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Is=le.stats)==null?void 0:Is.purchased)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((Rs=le.stats)==null?void 0:Rs.earnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((Ps=le.stats)==null?void 0:Ps.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),F?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ue,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Os=le.referrals)==null?void 0:Os.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(le.referrals??[]).map((V,Ie)=>{var ct;const Ye=V;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((ct=Ye.nickname)==null?void 0:ct.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:Ye.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:Ye.phone||(Ye.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Ye.status==="vip"&&s.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Ye.status==="paid"&&s.jsxs(Ke,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Ye.purchasedSections,"章"]}),Ye.status==="free"&&s.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:Ye.createdAt?new Date(Ye.createdAt).toLocaleDateString():""})]})]},Ye.id||Ie)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(ln,{children:s.jsx(ne,{variant:"outline",onClick:()=>$(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(Ft,{open:Bi,onOpenChange:vr,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(bo,{className:"w-5 h-5 text-[#38bdac]"}),"RFM 算法说明"]})}),s.jsxs("div",{className:"space-y-3 py-4 text-sm text-gray-300",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-[#38bdac] font-medium",children:"R(Recency)"}),":距最近购买天数,越近分越高,权重 40%"]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-[#38bdac] font-medium",children:"F(Frequency)"}),":购买频次,越多分越高,权重 30%"]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-[#38bdac] font-medium",children:"M(Monetary)"}),":消费金额,越高分越高,权重 30%"]}),s.jsx("p",{className:"text-gray-400",children:"综合分 = R×40% + F×30% + M×30%,归一化到 0-100"}),s.jsxs("p",{className:"text-gray-400",children:["等级:",s.jsx("span",{className:"text-amber-400",children:"S"}),"(≥85)、",s.jsx("span",{className:"text-green-400",children:"A"}),"(≥70)、",s.jsx("span",{className:"text-blue-400",children:"B"}),"(≥50)、",s.jsx("span",{className:"text-gray-400",children:"C"}),"(≥30)、",s.jsx("span",{className:"text-red-400",children:"D"}),"(<30)"]})]}),s.jsx(ln,{children:s.jsx(ne,{variant:"outline",onClick:()=>vr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(a0,{open:oe,onClose:()=>G(!1),userId:Q,onUserUpdated:lr})]})}function yh(t,[e,n]){return Math.min(n,Math.max(e,t))}var wk=["PageUp","PageDown"],jk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],kk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Yl="Slider",[Hg,vP,NP]=t0(Yl),[Sk]=Di(Yl,[NP]),[wP,kf]=Sk(Yl),Ck=b.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:v,...w}=t,N=b.useRef(new Set),k=b.useRef(0),E=o==="horizontal"?jP:kP,[A=[],I]=Co({prop:f,defaultProp:h,onChange:ee=>{var he;(he=[...N.current][k.current])==null||he.focus(),m(ee)}}),D=b.useRef(A);function _(ee){const U=MP(A,ee);z(ee,U)}function P(ee){z(ee,k.current)}function L(){const ee=D.current[k.current];A[k.current]!==ee&&g(A)}function z(ee,U,{commit:he}={commit:!1}){const me=PP(i),R=OP(Math.round((ee-r)/i)*i+r,me),O=yh(R,[r,a]);I((X=[])=>{const $=EP(X,O,U);if(RP($,u*i)){k.current=$.indexOf(O);const le=String($)!==String(X);return le&&he&&g($),le?$:X}else return X})}return s.jsx(wP,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:k,thumbs:N.current,values:A,orientation:o,form:v,children:s.jsx(Hg.Provider,{scope:t.__scopeSlider,children:s.jsx(Hg.Slot,{scope:t.__scopeSlider,children:s.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:at(w.onPointerDown,()=>{c||(D.current=A)}),min:r,max:a,inverted:y,onSlideStart:c?void 0:_,onSlideMove:c?void 0:P,onSlideEnd:c?void 0:L,onHomeKeyDown:()=>!c&&z(r,0,{commit:!0}),onEndKeyDown:()=>!c&&z(a,A.length-1,{commit:!0}),onStepKeyDown:({event:ee,direction:U})=>{if(!c){const R=wk.includes(ee.key)||ee.shiftKey&&jk.includes(ee.key)?10:1,O=k.current,X=A[O],$=i*R*U;z(X+$,O,{commit:!0})}}})})})})});Ck.displayName=Yl;var[Ek,Tk]=Sk(Yl,{startEdge:"left",endEdge:"right",size:"width",direction:1}),jP=b.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=St(e,E=>g(E)),v=b.useRef(void 0),w=Nf(a),N=w==="ltr",k=N&&!i||!N&&i;function C(E){const A=v.current||m.getBoundingClientRect(),I=[0,A.width],_=o0(I,k?[n,r]:[r,n]);return v.current=A,_(E-A.left)}return s.jsx(Ek,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:s.jsx(Mk,{dir:w,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const A=C(E.clientX);o==null||o(A)},onSlideMove:E=>{const A=C(E.clientX);c==null||c(A)},onSlideEnd:()=>{v.current=void 0,u==null||u()},onStepKeyDown:E=>{const I=kk[k?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:I?-1:1})}})})}),kP=b.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=St(e,f),g=b.useRef(void 0),y=!a;function v(w){const N=g.current||f.current.getBoundingClientRect(),k=[0,N.height],E=o0(k,y?[r,n]:[n,r]);return g.current=N,E(w-N.top)}return s.jsx(Ek,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:s.jsx(Mk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const N=v(w.clientY);i==null||i(N)},onSlideMove:w=>{const N=v(w.clientY);o==null||o(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=kk[y?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),Mk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=kf(Yl,n);return s.jsx(ut.span,{...h,ref:e,onKeyDown:at(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):wk.concat(jk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:at(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():r(m)}),onPointerMove:at(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:at(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),i(m))})})}),Ak="SliderTrack",Ik=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=kf(Ak,n);return s.jsx(ut.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});Ik.displayName=Ak;var Wg="SliderRange",Rk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=kf(Wg,n),i=Tk(Wg,n),o=b.useRef(null),c=St(e,o),u=a.values.length,h=a.values.map(g=>Dk(g,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(ut.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});Rk.displayName=Wg;var Ug="SliderThumb",Pk=b.forwardRef((t,e)=>{const n=vP(t.__scopeSlider),[r,a]=b.useState(null),i=St(e,c=>a(c)),o=b.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(SP,{...t,ref:i,index:o})}),SP=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=kf(Ug,n),c=Tk(Ug,n),[u,h]=b.useState(null),f=St(e,C=>h(C)),m=u?o.form||!!u.closest("form"):!0,g=s0(u),y=o.values[r],v=y===void 0?0:Dk(y,o.min,o.max),w=TP(r,o.values.length),N=g==null?void 0:g[c.size],k=N?AP(N,v,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${v}% + ${k}px)`},children:[s.jsx(Hg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(ut.span,{role:"slider","aria-label":t["aria-label"]||w,"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:at(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(Ok,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},r)]})});Pk.displayName=Ug;var CP="RadioBubbleInput",Ok=b.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=b.useRef(null),i=St(a,r),o=r0(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]),s.jsx(ut.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});Ok.displayName=CP;function EP(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function Dk(t,e,n){const i=100/(n-e)*(t-e);return yh(i,[0,100])}function TP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function MP(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),r=Math.min(...n);return n.indexOf(r)}function AP(t,e,n){const r=t/2,i=o0([0,50],[0,r]);return(r-i(e)*n)*n}function IP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function RP(t,e){if(e>0){const n=IP(t);return Math.min(...n)>=e}return!0}function o0(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function PP(t){return(String(t).split(".")[1]||"").length}function OP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var DP=Ck,LP=Ik,_P=Rk,zP=Pk;function $P({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(DP,{defaultValue:e,value:n,min:r,max:a,className:Ct("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(LP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(_P,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(zP,{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 FP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Lk(t){const[e,n]=b.useState(FP),[r,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){de.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}de.success(`✅ 分销配置已保存成功! + +• 小程序与网站的推广规则会一起生效 +• 绑定关系会使用新的天数配置 +• 佣金比例会立即应用到新订单 + +如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),de.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 r?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Dl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),s.jsxs(ne,{onClick:c,disabled:i||r,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"flex items-center gap-2 text-white",children:[s.jsx(gA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(Ht,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(Ce,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(zc,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(ie,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Mn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx($P,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),s.jsx(ie,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(zc,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(ie,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(zc,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(ie,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Mn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(ie,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"flex items-center gap-2 text-white",children:[s.jsx(Dl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(Ht,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(Ce,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(ie,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Ke,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx(Et,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(qe,{children:s.jsxs(Ge,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(zc,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(Ce,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[s.jsxs("p",{children:["1. 以上配置会写入"," ",s.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),s.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),s.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function BP(){var Mt;const[t,e]=b.useState("overview"),[n,r]=b.useState([]),[a,i]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState([]),[g,y]=b.useState(!0),[v,w]=b.useState(null),[N,k]=b.useState(""),[C,E]=b.useState("all"),[A,I]=b.useState(1),[D,_]=b.useState(10),[P,L]=b.useState(0),[z,ee]=b.useState(new Set),[U,he]=b.useState(null),[me,R]=b.useState(""),[O,X]=b.useState(!1),[$,le]=b.useState(null),[Y,F]=b.useState(""),[W,K]=b.useState(!1);b.useEffect(()=>{B()},[]),b.useEffect(()=>{I(1)},[t,C]),b.useEffect(()=>{oe(t)},[t]),b.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&oe(t,!0)},[A,D,C,N]);async function B(){w(null);try{const re=await De("/api/admin/distribution/overview");re!=null&&re.success&&re.overview&&i(re.overview)}catch(re){console.error("[Admin] 概览接口异常:",re),w("加载概览失败")}try{const re=await De("/api/db/users");m((re==null?void 0:re.users)||[])}catch(re){console.error("[Admin] 用户数据加载失败:",re)}}async function oe(re,Pe=!1){var et;if(!(!Pe&&z.has(re))){y(!0);try{const xt=f;switch(re){case"overview":break;case"orders":{try{const ft=new URLSearchParams({page:String(A),pageSize:String(D),...C!=="all"&&{status:C},...N&&{search:N}}),pt=await De(`/api/admin/orders?${ft}`);if(pt!=null&&pt.success&&pt.orders){const wt=pt.orders.map(Qt=>{const Lt=xt.find(At=>At.id===Qt.userId),An=Qt.referrerId?xt.find(At=>At.id===Qt.referrerId):null;return{...Qt,amount:parseFloat(String(Qt.amount))||0,userNickname:(Lt==null?void 0:Lt.nickname)||Qt.userNickname||"未知用户",userPhone:(Lt==null?void 0:Lt.phone)||Qt.userPhone||"-",referrerNickname:(An==null?void 0:An.nickname)||null,referrerCode:(An==null?void 0:An.referralCode)??null,type:Qt.productType||Qt.type}});r(wt),L(pt.total??wt.length)}else r([]),L(0)}catch(ft){console.error(ft),w("加载订单失败"),r([])}break}case"bindings":{try{const ft=new URLSearchParams({page:String(A),pageSize:String(D),...C!=="all"&&{status:C}}),pt=await De(`/api/db/distribution?${ft}`);c((pt==null?void 0:pt.bindings)||[]),L((pt==null?void 0:pt.total)??((et=pt==null?void 0:pt.bindings)==null?void 0:et.length)??0)}catch(ft){console.error(ft),w("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const ft=C==="completed"?"success":C==="rejected"?"failed":C,pt=new URLSearchParams({...ft&&ft!=="all"&&{status:ft},page:String(A),pageSize:String(D)}),wt=await De(`/api/admin/withdrawals?${pt}`);if(wt!=null&&wt.success&&wt.withdrawals){const Qt=wt.withdrawals.map(Lt=>({...Lt,account:Lt.account??"未绑定微信号",status:Lt.status==="success"?"completed":Lt.status==="failed"?"rejected":Lt.status}));h(Qt),L((wt==null?void 0:wt.total)??Qt.length)}else wt!=null&&wt.success||w(`获取提现记录失败: ${(wt==null?void 0:wt.error)||"未知错误"}`),h([])}catch(ft){console.error(ft),w("加载提现数据失败"),h([])}break}}ee(ft=>new Set(ft).add(re))}catch(xt){console.error(xt)}finally{y(!1)}}}async function G(){w(null),ee(re=>{const Pe=new Set(re);return Pe.delete(t),Pe}),t==="overview"&&B(),await oe(t,!0)}async function Q(re){if(confirm("确认审核通过并打款?"))try{const Pe=await Tt("/api/admin/withdrawals",{id:re,action:"approve"});if(!(Pe!=null&&Pe.success)){const et=(Pe==null?void 0:Pe.message)||(Pe==null?void 0:Pe.error)||"操作失败";de.error(et);return}await G()}catch(Pe){console.error(Pe),de.error("操作失败")}}function se(re){le(re),F("")}async function ye(){const re=$;if(!re)return;const Pe=Y.trim();if(!Pe){de.error("请填写拒绝原因");return}K(!0);try{const et=await Tt("/api/admin/withdrawals",{id:re,action:"reject",errorMessage:Pe});if(!(et!=null&&et.success)){de.error((et==null?void 0:et.error)||"操作失败");return}de.success("已拒绝该提现申请"),le(null),F(""),await G()}catch(et){console.error(et),de.error("操作失败")}finally{K(!1)}}function Me(){$&&de.info("已取消操作"),le(null),F("")}async function Be(){var re;if(!(!(U!=null&&U.orderSn)&&!(U!=null&&U.id))){X(!0),w(null);try{const Pe=await Tt("/api/admin/orders/refund",{orderSn:U.orderSn||U.id,reason:me||void 0});Pe!=null&&Pe.success?(he(null),R(""),await oe("orders",!0)):w((Pe==null?void 0:Pe.error)||"退款失败")}catch(Pe){const et=Pe;w(((re=et==null?void 0:et.data)==null?void 0:re.error)||"退款失败,请检查网络后重试")}finally{X(!1)}}}function He(re){const Pe={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"},et={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Ke,{className:`${Pe[re]||"bg-gray-500/20 text-gray-400"} border-0`,children:et[re]||re})}const gt=Math.ceil(P/D)||1,Dt=n,jn=o.filter(re=>{var et,xt,ft,pt;if(!N)return!0;const Pe=N.toLowerCase();return((et=re.refereeNickname)==null?void 0:et.toLowerCase().includes(Pe))||((xt=re.refereePhone)==null?void 0:xt.includes(Pe))||((ft=re.referrerName)==null?void 0:ft.toLowerCase().includes(Pe))||((pt=re.referrerCode)==null?void 0:pt.toLowerCase().includes(Pe))}),it=u.filter(re=>{var et;if(!N)return!0;const Pe=N.toLowerCase();return((et=re.userName)==null?void 0:et.toLowerCase().includes(Pe))||re.account&&re.account.toLowerCase().includes(Pe)});return s.jsxs("div",{className:"p-8 w-full",children:[v&&s.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:[s.jsx("span",{children:v}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),s.jsxs(ne,{onClick:G,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),s.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:bo},{key:"orders",label:"订单管理",icon:fh},{key:"bindings",label:"绑定管理",icon:vs},{key:"withdrawals",label:"提现审核",icon:Dl},{key:"settings",label:"推广设置",icon:yo}].map(re=>s.jsxs("button",{type:"button",onClick:()=>{e(re.key),E("all"),k("")},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===re.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[s.jsx(re.icon,{className:"w-4 h-4"}),re.label]},re.key))}),g?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ue,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[t==="overview"&&a&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayClicks}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(Pg,{className:"w-6 h-6 text-blue-400"})})]})})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayUniqueVisitors??0}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:s.jsx(Mn,{className:"w-6 h-6 text-cyan-400"})})]})})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(a.todayClickRate??0).toFixed(2)}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:s.jsx(bo,{className:"w-6 h-6 text-amber-400"})})]})})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayBindings})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:s.jsx(vs,{className:"w-6 h-6 text-green-400"})})]})})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:a.todayConversions})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:s.jsx(Fv,{className:"w-6 h-6 text-purple-400"})})]})})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),s.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",a.todayEarnings.toFixed(2)]})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:s.jsx(fh,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((Mt=a.todayClicksByPage)==null?void 0:Mt.length)??0)>0&&s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Pg,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),s.jsx(Ce,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),s.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),s.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),s.jsx("tbody",{children:[...a.todayClicksByPage??[]].sort((re,Pe)=>Pe.clicks-re.clicks).map((re,Pe)=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:re.page||"(未区分)"}),s.jsx("td",{className:"py-2 pr-4 text-right text-white",children:re.clicks}),s.jsxs("td",{className:"py-2 text-right text-gray-400",children:[a.todayClicks>0?(re.clicks/a.todayClicks*100).toFixed(1):0,"%"]})]},Pe))})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Se,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:s.jsx(Rg,{className:"w-6 h-6 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.expiringBindings," 个"]}),s.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),s.jsx(Se,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(Ce,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(Dl,{className:"w-6 h-6 text-blue-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[a.pendingWithdrawals," 笔"]}),s.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",a.pendingWithdrawAmount.toFixed(2)]})]}),s.jsx(ne,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(qe,{children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(hh,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),s.jsx(Ce,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),s.jsx("p",{className:"text-xl font-bold text-white",children:a.monthClicks})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:a.monthBindings})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:a.monthConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.monthEarnings.toFixed(2)]})]})]})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(qe,{children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(bo,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),s.jsxs(Ce,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),s.jsx("p",{className:"text-xl font-bold text-white",children:a.totalClicks.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),s.jsx("p",{className:"text-xl font-bold text-white",children:a.totalBindings.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),s.jsx("p",{className:"text-xl font-bold text-white",children:a.totalConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",a.totalEarnings.toFixed(2)]})]})]}),s.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[s.jsx("span",{className:"text-gray-300",children:"点击转化率"}),s.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[a.conversionRate,"%"]})]})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(qe,{children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),s.jsx(Ce,{children:s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-white",children:a.totalDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-green-400",children:a.activeDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ka,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ie,{value:N,onChange:re=>k(re.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:re=>E(re.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ce,{className:"p-0",children:[n.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Dt.map(re=>{var Pe,et;return s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Pe=re.id)==null?void 0:Pe.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:re.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:re.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const xt=re.productType||re.type;return xt==="fullbook"?`${re.bookName||"《底层逻辑》"} - 全本`:xt==="match"?"匹配次数购买":`${re.bookName||"《底层逻辑》"} - ${re.sectionTitle||re.chapterTitle||`章节${re.productId||re.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const xt=re.productType||re.type;return xt==="fullbook"?"全书解锁":xt==="match"?"功能权益":re.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof re.amount=="number"?re.amount.toFixed(2):parseFloat(String(re.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:re.paymentMethod==="wechat"?"微信支付":re.paymentMethod==="alipay"?"支付宝":re.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:re.status==="refunded"?s.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):re.status==="completed"||re.status==="paid"?s.jsx(Ke,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):re.status==="pending"||re.status==="created"?s.jsx(Ke,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Ke,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:re.refundReason,children:re.status==="refunded"&&re.refundReason?re.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:re.referrerId||re.referralCode?s.jsxs("span",{title:re.referralCode||re.referrerCode||re.referrerId||"",children:[re.referrerNickname||re.referralCode||re.referrerCode||((et=re.referrerId)==null?void 0:et.slice(0,8)),(re.referralCode||re.referrerCode)&&` (${re.referralCode||re.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:re.referrerEarnings?`¥${(typeof re.referrerEarnings=="number"?re.referrerEarnings:parseFloat(String(re.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:re.createdAt?new Date(re.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(re.status==="paid"||re.status==="completed")&&s.jsxs(ne,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{he(re),R("")},children:[s.jsx(ej,{className:"w-3 h-3 mr-1"}),"退款"]})})]},re.id)})})]})}),t==="orders"&&s.jsx(Ns,{page:A,totalPages:gt,total:P,pageSize:D,onPageChange:I,onPageSizeChange:re=>{_(re),I(1)}})]})})]}),t==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ka,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ie,{value:N,onChange:re=>k(re.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:re=>E(re.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"有效"}),s.jsx("option",{value:"converted",children:"已转化"}),s.jsx("option",{value:"expired",children:"已过期"})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ce,{className:"p-0",children:[jn.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:jn.map(re=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:re.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:re.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:re.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:re.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:re.boundAt?new Date(re.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:re.expiresAt?new Date(re.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:He(re.status)}),s.jsx("td",{className:"p-4",children:re.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",re.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},re.id))})]})}),t==="bindings"&&s.jsx(Ns,{page:A,totalPages:gt,total:P,pageSize:D,onPageChange:I,onPageSizeChange:re=>{_(re),I(1)}})]})})]}),t==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ka,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ie,{value:N,onChange:re=>k(re.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:re=>E(re.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待审核"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"rejected",children:"已拒绝"})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ce,{className:"p-0",children:[it.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:it.map(re=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[re.userAvatar?s.jsx("img",{src:re.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(re.userName||re.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:re.userName||re.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",re.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Ke,{className:re.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:re.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:re.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:re.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:re.createdAt?new Date(re.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:He(re.status)}),s.jsx("td",{className:"p-4 text-right",children:re.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(ne,{size:"sm",onClick:()=>Q(re.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Fv,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>se(re.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(Gw,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},re.id))})]})}),t==="withdrawals"&&s.jsx(Ns,{page:A,totalPages:gt,total:P,pageSize:D,onPageChange:I,onPageSizeChange:re=>{_(re),I(1)}})]})})]})]}),s.jsx(Ft,{open:!!U,onOpenChange:re=>!re&&he(null),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Bt,{children:s.jsx(Vt,{className:"text-white",children:"订单退款"})}),U&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",U.orderSn||U.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof U.amount=="number"?U.amount.toFixed(2):parseFloat(String(U.amount||"0")).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:me,onChange:re=>R(re.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>he(null),disabled:O,children:"取消"}),s.jsx(ne,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Be,disabled:O,children:O?"退款中...":"确认退款"})]})]})}),s.jsx(Ft,{open:!!$,onOpenChange:re=>!re&&Me(),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Bt,{children:s.jsx(Vt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:Y,onChange:re=>F(re.target.value)})})]})]}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Me,disabled:W,children:"取消"}),s.jsx(ne,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ye,disabled:W||!Y.trim(),children:W?"提交中...":"确认拒绝"})]})]})}),t==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(Lk,{embedded:!0})})]})}function VP(){const[t,e]=b.useState([]),[n,r]=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),[v,w]=b.useState(0),[N,k]=b.useState(null),[C,E]=b.useState(null),[A,I]=b.useState(""),[D,_]=b.useState(!1);async function P(){var R,O,X,$,le,Y,F;i(!0),c(null);try{const W=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),K=await De(`/api/admin/withdrawals?${W}`);if(K!=null&&K.success){const B=K.withdrawals||[];e(B),w(K.total??((R=K.stats)==null?void 0:R.total)??B.length),r({total:((O=K.stats)==null?void 0:O.total)??K.total??B.length,pendingCount:((X=K.stats)==null?void 0:X.pendingCount)??0,pendingAmount:(($=K.stats)==null?void 0:$.pendingAmount)??0,successCount:((le=K.stats)==null?void 0:le.successCount)??0,successAmount:((Y=K.stats)==null?void 0:Y.successAmount)??0,failedCount:((F=K.stats)==null?void 0:F.failedCount)??0})}else c("加载提现记录失败")}catch(W){console.error("Load withdrawals error:",W),c("加载失败,请检查网络后重试")}finally{i(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{P()},[u,f,g]);const L=Math.ceil(v/g)||1;async function z(R){const O=t.find(X=>X.id===R);if(O!=null&&O.userCommissionInfo&&O.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${O.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 + +确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(R);try{const X=await Tt("/api/admin/withdrawals",{id:R,action:"approve"});X!=null&&X.success?P():de.error("操作失败: "+((X==null?void 0:X.error)??""))}catch{de.error("操作失败")}finally{k(null)}}function ee(R){E(R),I("")}async function U(){const R=C;if(!R)return;const O=A.trim();if(!O){de.error("请填写拒绝原因");return}_(!0);try{const X=await Tt("/api/admin/withdrawals",{id:R,action:"reject",errorMessage:O});X!=null&&X.success?(de.success("已拒绝该提现申请"),E(null),I(""),P()):de.error("操作失败: "+((X==null?void 0:X.error)??""))}catch{de.error("操作失败")}finally{_(!1)}}function he(){C&&de.info("已取消操作"),E(null),I("")}function me(R){switch(R){case"pending":return s.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Ke,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Ke,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Ke,{className:"bg-gray-500/20 text-gray-400 border-0",children:R})}}return s.jsxs("div",{className:"p-8 w-full",children:[o&&s.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:[s.jsx("span",{children:o}),s.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),s.jsxs(ne,{variant:"outline",onClick:P,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Se,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(Ce,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(fh,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),s.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",s.jsx("span",{className:"text-white font-medium",children:"90%"})]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准"]})]})]})]})})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ce,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),s.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ce,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),s.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ce,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),s.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ce,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(R=>s.jsx(ne,{variant:u===R?"default":"outline",size:"sm",onClick:()=>h(R),className:u===R?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:R==="all"?"全部":R==="pending"?"待处理":R==="success"?"已完成":"已拒绝"},R))}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Dl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(R=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(R.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[R.userAvatar?s.jsx("img",{src:R.userAvatar,alt:R.userName??"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(R.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:R.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:R.userPhone??R.referralCode??(R.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(R.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:R.userCommissionInfo?s.jsxs("div",{className:"text-xs space-y-1",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",R.userCommissionInfo.totalCommission.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"已提现:"}),s.jsxs("span",{className:"text-gray-400",children:["¥",R.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"待审核:"}),s.jsxs("span",{className:"text-orange-400",children:["¥",R.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[s.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),s.jsxs("span",{className:R.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",R.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsxs("td",{className:"p-4",children:[me(R.status),R.errorMessage&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:R.errorMessage})]}),s.jsx("td",{className:"p-4 text-gray-400",children:R.processedAt?new Date(R.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:R.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:R.userConfirmedAt,children:["已确认 ",new Date(R.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(R.status==="pending"||R.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(ne,{size:"sm",onClick:()=>z(R.id),disabled:N===R.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(xf,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>ee(R.id),disabled:N===R.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(nr,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(R.status==="success"||R.status==="completed")&&R.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:R.transactionId})]})]},R.id))})]})}),s.jsx(Ns,{page:f,totalPages:L,total:v,pageSize:g,onPageChange:m,onPageSizeChange:R=>{y(R),m(1)}})]})})}),s.jsx(Ft,{open:!!C,onOpenChange:R=>!R&&he(),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Bt,{children:s.jsx(Vt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:A,onChange:R=>I(R.target.value)})})]})]}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:he,disabled:D,children:"取消"}),s.jsx(ne,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:U,disabled:D||!A.trim(),children:D?"提交中...":"确认拒绝"})]})]})})]})}var Vm={exports:{}},Hm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var d1;function HP(){if(d1)return Hm;d1=1;var t=Nd();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,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),v=r({inst:{value:y,getSnapshot:g}}),w=v[0].inst,N=v[1];return i(function(){w.value=y,w.getSnapshot=g,u(w)&&N({inst:w})},[m,y,g]),a(function(){return u(w)&&N({inst:w}),m(function(){u(w)&&N({inst:w})})},[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 Hm.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Hm}var u1;function _k(){return u1||(u1=1,Vm.exports=HP()),Vm.exports}var zk=_k();function Vn(t){this.content=t}Vn.prototype={constructor:Vn,find:function(t){for(var e=0;e>1}};Vn.from=function(t){if(t instanceof Vn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Vn(e)};function $k(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(r),i=e.child(r);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=$k(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function Fk(t,e,n,r){for(let a=t.childCount,i=e.childCount;;){if(a==0||i==0)return a==i?null:{a:n,b:r};let o=t.child(--a),c=e.child(--i),u=o.nodeSize;if(o==c){n-=u,r-=u;continue}if(!o.sameMarkup(c))return{a:n,b:r};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;he&&r(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),r,a+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,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)&&r&&(o?o=!1:i+=r),i+=h},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,a=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.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))),r.push(c),a+=c.nodeSize),o=u}return new xe(r,a)}cutByIndex(e,n){return e==n?xe.empty:e==0&&n==this.content.length?this:new xe(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let a=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return a[e]=n,new xe(a,i)}addToStart(e){return new xe([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new xe(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,r=0;;n++){let a=this.child(n),i=r+a.nodeSize;if(i>=e)return i==e?zu(n+1,i):zu(n,r);r=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 xe.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new xe(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return xe.empty;let n,r=0;for(let a=0;athis.type.rank&&(n||(n=e.slice(0,a)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-a.type.rank),n}};Ot.none=[];class vh extends Error{}class Re{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Vk(this.content,e+this.openStart,n);return r&&new Re(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Re(Bk(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 Re.empty;let r=n.openStart||0,a=n.openEnd||0;if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Re(xe.fromJSON(e,n.content),r,a)}static maxOpen(e,n=!0){let r=0,a=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)a++;return new Re(e,r,a)}}Re.empty=new Re(xe.empty,0,0);function Bk(t,e,n){let{index:r,offset:a}=t.findIndex(e),i=t.maybeChild(r),{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(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Bk(i.content,e-a-1,n-a-1)))}function Vk(t,e,n,r){let{index:a,offset:i}=t.findIndex(e),o=t.maybeChild(a);if(i==e||o.isText)return r&&!r.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Vk(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function WP(t,e,n){if(n.openStart>t.depth)throw new vh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new vh("Inconsistent open depths");return Hk(t,e,n,0)}function Hk(t,e,n,r){let a=t.index(r),i=t.node(r);if(a==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function qc(t,e,n,r){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&&(No(t.nodeAfter,r),i++));for(let c=i;ca&&qg(t,e,a+1),o=r.depth>a&&qg(n,r,a+1),c=[];return qc(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(Wk(i,o),No(wo(i,Uk(t,e,n,r,a+1)),c)):(i&&No(wo(i,Nh(t,e,a+1)),c),qc(e,n,a,c),o&&No(wo(o,Nh(n,r,a+1)),c)),qc(r,null,a,c),new xe(c)}function Nh(t,e,n){let r=[];if(qc(null,t,n,r),t.depth>n){let a=qg(t,e,n+1);No(wo(a,Nh(t,e,n+1)),r)}return qc(e,null,n,r),new xe(r)}function UP(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(xe.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class ld{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,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 r=this.pos-this.path[this.path.length-1],a=e.child(n);return r?e.child(n).cut(r):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 r=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;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new wh(this,e,r);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 r=[],a=0,i=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(i),h=i-u;if(r.push(o,c,a+u),!h||(o=o.child(c),o.isText))break;i=h-1,a+=u+1}return new ld(n,r,i)}static resolveCached(e,n){let r=h1.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,n,i=>(r.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()+")"),Kk(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,r=xe.empty,a=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,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 r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let a=xe.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,r);return i.type.checkAttrs(i.attrs),i}};Sa.prototype.text=void 0;class jh extends Sa{constructor(e,n,r,a){if(super(e,n,null,a),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Kk(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 jh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new jh(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 Kk(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class To{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new JP(e,n);if(r.next==null)return To.empty;let a=qk(r);r.next&&r.err("Unexpected trailing text");let i=nO(tO(a));return rO(i,r),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(r){e.push(r);for(let a=0;a{let i=a+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return i}).join(` +`)}}To.empty=new To(!0);class JP{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 qk(t){let e=[];do e.push(YP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function YP(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=eO(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=XP(t,e);else break;return e}function f1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function XP(t,e){let n=f1(t),r=n;return t.eat(",")&&(t.next!="}"?r=f1(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function ZP(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];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 eO(t){if(t.eat("(")){let e=qk(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=ZP(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 tO(t){let e=[[]];return a(i(t,0),n()),e;function n(){return e.push([])-1}function r(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 r(c,u),a(i(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return a(i(o.expr,c),u),a(i(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(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[r.join(",")]=new To(r.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:Yk(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Sa(this,this.computeAttrs(e),xe.from(n),Ot.setFrom(r))}createChecked(e=null,n,r){return n=xe.from(n),this.checkContent(n),new Sa(this,this.computeAttrs(e),n,Ot.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=xe.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(xe.empty,!0);return i?new Sa(this,e,n.append(i),Ot.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new Zk(i,n,o));let a=n.spec.topNode||"doc";if(!r[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function sO(t,e,n){let r=n.split("|");return a=>{let i=a===null?"null":typeof a;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class aO{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?sO(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Sf{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=Xk(e,a.attrs),this.excluded=null;let i=Jk(this.attrs);this.instance=i?new Ot(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ot(this,Yk(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new Sf(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class eS{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=Vn.from(e.nodes),n.marks=Vn.from(e.marks||{}),this.nodes=m1.compile(this.spec.nodes,this),this.marks=Sf.compile(this.spec.marks,this);let r=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=r[o]||(r[o]=To.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?g1(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==""?[]:g1(this,o.split(" "))}this.nodeFromJSON=a=>Sa.fromJSON(this,a),this.markFromJSON=a=>Ot.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,a){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof m1){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,r,a)}text(e,n){let r=this.nodes.text;return new jh(r,r.defaultAttrs,e,Ot.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 g1(t,e){let n=[];for(let r=0;r-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function iO(t){return t.tag!=null}function oO(t){return t.style!=null}class ji{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(iO(a))this.tags.push(a);else if(oO(a)){let i=/[^=]*/.exec(a.style)[0];r.indexOf(i)<0&&r.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 r=new y1(this,n,!1);return r.addAll(e,Ot.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new y1(this,n,!0);return r.addAll(e,Ot.none,n.from,n.to),Re.maxOpen(r.finish())}matchTag(e,n,r){for(let a=r?this.tags.indexOf(r)+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 r(a){let i=a.priority==null?50:a.priority,o=0;for(;o{r(o=b1(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=>{r(o=b1(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ji(e,ji.schemaRules(e)))}}const tS={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},lO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},nS={ol:!0,ul:!0},cd=1,Jg=2,Gc=4;function x1(t,e,n){return e!=null?(e?cd:0)|(e==="full"?Jg:0):t&&t.whitespace=="pre"?cd|Jg:n&~Gc}class $u{constructor(e,n,r,a,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=a,this.options=o,this.content=[],this.activeMarks=Ot.none,this.match=i||(o&Gc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(xe.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,a;return(a=r.findWrapping(e.type))?(this.match=r,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&cd)){let r=this.content[this.content.length-1],a;if(r&&r.isText&&(a=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.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=xe.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(xe.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&&!tS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class y1{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let a=n.topNode,i,o=x1(null,n.preserveWhitespace,0)|(r?Gc:0);a?i=new $u(a.type,a.attrs,Ot.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new $u(null,null,Ot.none,!0,null,o):i=new $u(e.schema.topNodeType,null,Ot.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 r=e.nodeValue,a=this.top,i=a.options&Jg?"full":this.localPreserveWS||(a.options&cd)>0,{schema:o}=this.parser;if(i==="full"||a.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,` +`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=r.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,r,a){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(i=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(a)this.addElement(e,r,a);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!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,r),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,r,a){let i=r||0;for(let o=r?e.childNodes[r]: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,r){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(r)break;c+=2}}if(!a)return null;this.sync(i);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):v1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new $u(e,n,u,a,null,c)),this.open++,r}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|=cd)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let a=r.length-1;a>=0;a--)e+=r[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,a=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.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:r&&u>=i?r.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 r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function cO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&nS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function dO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function b1(t){let e={};for(let n in t)e[n]=t[n];return e}function v1(t,e){let n=e.schema.nodes;for(let r in n){let a=n[r];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(r),r=i.dom)}return r}serializeMark(e,n,r={}){let a=this.marks[e.type.name];return a&&rh(Um(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return rh(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new zo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=N1(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return N1(e.marks)}}function N1(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Um(t){return t.document||window.document}const w1=new WeakMap;function uO(t){let e=w1.get(t);return e===void 0&&w1.set(t,e=hO(t)),e}function hO(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);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:v}=rh(t,g,n,r);if(u.appendChild(y),v){if(c)throw new RangeError("Multiple content holes");c=v}}}return{dom:u,contentDOM:c}}const rS=65535,sS=Math.pow(2,16);function fO(t,e){return t+e*sS}function j1(t){return t&rS}function pO(t){return(t-(t&rS))/sS}const aS=1,iS=2,sh=4,oS=8;class Yg{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&oS)>0}get deletedBefore(){return(this.delInfo&(aS|sh))>0}get deletedAfter(){return(this.delInfo&(iS|sh))>0}get deletedAcross(){return(this.delInfo&sh)>0}}class _r{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&_r.empty)return _r.empty}recover(e){let n=0,r=j1(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(r)return y;let v=e==(n<0?u:m)?null:fO(c/3,e-u),w=e==u?iS:e==m?aS:sh;return(n<0?e!=u:e!=m)&&(w|=oS),new Yg(y,w,v)}a+=f-h}return r?e+a:new Yg(e+a,0,null)}touches(e,n){let r=0,a=j1(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;r+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,r=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?r-a-1:void 0)}}invert(){let e=new dd;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),a),n.openStart,n.openEnd);return vn.fromReplace(e,this.from,this.to,i)}invert(){return new bs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new yi(n.pos,r.pos,this.mark)}merge(e){return e instanceof yi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yi(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 yi(n.from,n.to,e.markFromJSON(n.mark))}}ir.jsonID("addMark",yi);class bs extends ir{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Re(l0(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return vn.fromReplace(e,this.from,this.to,r)}invert(){return new yi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new bs(n.pos,r.pos,this.mark)}merge(e){return e instanceof bs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new bs(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 bs(n.from,n.to,e.markFromJSON(n.mark))}}ir.jsonID("removeMark",bs);class bi extends ir{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return vn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return vn.fromReplace(e,this.pos,this.pos+1,new Re(xe.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let a=0;ar.pos?null:new Ln(n.pos,r.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 Ln(n.from,n.to,n.gapFrom,n.gapTo,Re.fromJSON(e,n.slice),n.insert,!!n.structure)}}ir.jsonID("replaceAround",Ln);function Qg(t,e,n){let r=t.resolve(e),a=n-e,i=r.depth;for(;a>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,a--;if(a>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;a>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,a--}}return!1}function mO(t,e,n,r){let a=[],i=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&f.type.allowsMarkType(r.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),v=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function gO(t,e,n,r){let a=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let u=null;if(r instanceof Sf){let h=o.marks,f;for(;f=r.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;ft.step(new bs(o.from,o.to,o.style)))}function c0(t,e,n,r=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 xO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ql(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,a=0,i=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+a,u=t.$to.indexAfter(r)-i;if(rn;v--)w||r.index(v)>0?(w=!0,f=xe.from(r.node(v).copy(f)),m++):u--;let g=xe.empty,y=0;for(let v=i,w=!1;v>n;v--)w||a.after(v+1)=0;o--){if(r.size){let c=n[o].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=xe.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new Ln(a,i,a,i,new Re(r,0,0),n.length,!0))}function wO(t,e,n,r,a){if(!r.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(r,u)&&jO(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",v=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!v?h=!1:!y&&v&&(h=!0)}h===!1&&cS(t,o,c,i),c0(t,t.mapping.slice(i).map(c,1),r,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 Ln(m,g,m+1,g-1,new Re(xe.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&lS(t,o,c,i),!1}})}function lS(t,e,n,r){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(r).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function cS(t,e,n,r){e.forEach((a,i)=>{if(a.type==a.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(` +`))}})}function jO(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function kO(t,e,n,r,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(r,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 Ln(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Re(xe.from(o),0,0),1,!0))}function Ca(t,e,n=1,r){let a=t.resolve(e),i=a.depth-n,o=r&&r[r.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),v=r&&r[f+1];v&&(y=y.replaceChild(0,v.type.create(v.attrs)));let w=r&&r[f]||m;if(!m.canReplace(g+1,m.childCount)||!w.type.validContent(y))return!1}let c=a.indexAfter(i),u=r&&r[0];return a.node(i).canReplaceWith(c,c,u?u.type:a.node(i+1).type)}function SO(t,e,n=1,r){let a=t.doc.resolve(e),i=xe.empty,o=xe.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=xe.from(a.node(c).copy(i));let f=r&&r[h];o=xe.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new Dn(e,e,new Re(i.append(o),n,n),!0))}function Li(t,e){let n=t.resolve(e),r=n.index();return dS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function CO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let a=0;a0?(i=r.node(a+1),c++,o=r.node(a).maybeChild(c)):(i=r.node(a).maybeChild(c-1),o=r.node(a+1)),i&&!i.isTextblock&&dS(i,o)&&r.node(a).canReplace(c,c+1))return e;if(a==0)break;e=n<0?r.before(a):r.after(a)}}function EO(t,e,n){let r=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?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);cS(t,f.node(),f.before(),c)}o.inlineContent&&c0(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new Dn(h,u.map(e+n,-1),Re.empty,!0)),r===!0){let f=t.doc.resolve(h);lS(t,f.node(),f.before(),t.steps.length)}return t}function TO(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let a=r.depth-1;a>=0;a--){let i=r.index(a);if(r.node(a).canReplaceWith(i,i,n))return r.before(a+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let a=r.depth-1;a>=0;a--){let i=r.indexAfter(a);if(r.node(a).canReplaceWith(i,i,n))return r.after(a+1);if(i=0;o--){let c=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(c>0?1:0),h=r.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?r.pos:c<0?r.before(o+1):r.after(o+1)}return null}function Ef(t,e,n=e,r=Re.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return hS(a,i,r)?new Dn(e,n,r):new MO(a,i,r).fit()}function hS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class MO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=xe.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=xe.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,r=this.$from,a=this.close(e<0?this.$to:r.doc.resolve(e));if(!a)return null;let i=this.placed,o=r.depth,c=a.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let u=new Re(i,o,c);return e>-1?new Ln(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new Dn(r.pos,a.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,a=this.unplaced.openEnd;r1&&(a=0),i.type.spec.isolating&&a<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let a,i=null;r?(i=qm(this.unplaced.content,r-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(xe.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:f};if(i&&h.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=qm(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Re(e,n+1,Math.max(r,a.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,a=qm(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new Re($c(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Re($c(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:a,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let w=0;w1||u==0||w.content.size)&&(m=N,f.push(fS(w.mark(g.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?y:-1)))}let v=h==c.childCount;v||(y=-1),this.placed=Fc(this.placed,n,xe.from(f)),this.frontier[n].match=m,v&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,N=c;w1&&a==this.$to.end(--r);)++a;return a}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:a}=this.frontier[n],i=n=0;c--){let{match:u,type:h}=this.frontier[c],f=Gm(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=Fc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let a=e.node(r),i=a.type.contentMatch.fillBefore(a.content,!0,e.index(r));this.openFrontierNode(a.type,a.attrs,i)}return e}openFrontierNode(e,n=null,r){let a=this.frontier[this.depth];a.match=a.match.matchType(e),this.placed=Fc(this.placed,this.depth,xe.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(xe.empty,!0);n.childCount&&(this.placed=Fc(this.placed,this.frontier.length,n))}}function $c(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy($c(t.firstChild.content,e-1,n)))}function Fc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Fc(t.lastChild.content,e-1,n)))}function qm(t,e){for(let n=0;n1&&(r=r.replaceChild(0,fS(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(xe.empty,!0)))),t.copy(r)}function Gm(t,e,n,r,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=r.fillBefore(i.content,!0,o);return c&&!AO(n,i.content,o)?c:null}function AO(t,e,n){for(let r=n;r0;g--,y--){let v=a.node(g).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;o.indexOf(g)>-1?c=g:a.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=r.openStart;for(let g=r.content,y=0;;y++){let v=g.firstChild;if(h.push(v),y==r.openStart)break;g=v.content}for(let g=f-1;g>=0;g--){let y=h[g],v=IO(y.type);if(v&&!y.sameMarkup(a.node(Math.abs(c)-1)))f=g;else if(v||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+f+1)%(r.openStart+1),v=h[y];if(v)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=a.before(y),n=i.after(y))}}function pS(t,e,n,r,a){if(er){let i=a.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(xe.empty,!0))}return t}function PO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=TO(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new Re(xe.from(r),0,0))}function OO(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=mS(r,a);for(let o=0;o0&&(u||r.node(c-1).canReplace(r.index(c-1),a.indexAfter(c-1))))return t.delete(r.before(c),a.after(c))}for(let o=1;o<=r.depth&&o<=a.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&a.end(o)-n!=a.depth-o&&r.start(o-1)==a.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),a.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function mS(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let a=r;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 Il extends ir{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return vn.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let a=n.type.create(r,null,n.marks);return vn.fromReplace(e,this.pos,this.pos+1,new Re(xe.from(a),0,n.isLeaf?0:1))}getMap(){return _r.empty}invert(e){return new Il(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 Il(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 Il(n.pos,n.attr,n.value)}}ir.jsonID("attr",Il);class ud extends ir{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 r=e.type.create(n,e.content,e.marks);return vn.ok(r)}getMap(){return _r.empty}invert(e){return new ud(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 ud(n.attr,n.value)}}ir.jsonID("docAttr",ud);let Ll=class extends Error{};Ll=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ll.prototype=Object.create(Error.prototype);Ll.prototype.constructor=Ll;Ll.prototype.name="TransformError";class u0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new dd}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ll(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 r=0;r{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,r=Re.empty){let a=Ef(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new Re(xe.from(r),0,0))}delete(e,n){return this.replace(e,n,Re.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return RO(this,e,n,r),this}replaceRangeWith(e,n,r){return PO(this,e,n,r),this}deleteRange(e,n){return OO(this,e,n),this}lift(e,n){return yO(this,e,n),this}join(e,n=1){return EO(this,e,n),this}wrap(e,n){return NO(this,e,n),this}setBlockType(e,n=e,r,a=null){return wO(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return kO(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new Il(e,n,r)),this}setDocAttribute(e,n){return this.step(new ud(e,n)),this}addNodeMark(e,n){return this.step(new bi(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Ot)n.isInSet(r.marks)&&this.step(new Mo(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new Mo(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,r){return SO(this,e,n,r),this}addMark(e,n,r){return mO(this,e,n,r),this}removeMark(e,n,r){return gO(this,e,n,r),this}clearIncompatible(e,n,r){return c0(this,e,n,r),this}}const Jm=Object.create(null);class tt{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new gS(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?Nl(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Nl(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Fr(e.node(0))}static atStart(e){return Nl(e,e,0,0,1)||new Fr(e)}static atEnd(e){return Nl(e,e,e.content.size,e.childCount,-1)||new Fr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Jm[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Jm)throw new RangeError("Duplicate use of selection JSON ID "+e);return Jm[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Qe.between(this.$anchor,this.$head).getBookmark()}}tt.prototype.visible=!0;class gS{constructor(e,n){this.$from=e,this.$to=n}}let S1=!1;function C1(t){!S1&&!t.parent.inlineContent&&(S1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Qe extends tt{constructor(e,n=e){C1(e),C1(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return tt.near(r);let a=e.resolve(n.map(this.anchor));return new Qe(a.parent.inlineContent?a:r,r)}replace(e,n=Re.empty){if(super.replace(e,n),n==Re.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Qe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Tf(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 Qe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let a=e.resolve(n);return new this(a,r==n?a:e.resolve(r))}static between(e,n,r){let a=e.pos-n.pos;if((!r||a)&&(r=a>=0?1:-1),!n.parent.inlineContent){let i=tt.findFrom(n,r,!0)||tt.findFrom(n,-r,!0);if(i)n=i.$head;else return tt.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(tt.findFrom(e,-r,!0)||tt.findFrom(e,r,!0)).$anchor,e.pos0?0:1);a>0?o=0;o+=a){let c=e.child(o);if(c.isAtom){if(!i&&Je.isSelectable(c))return Je.create(t,n-(a<0?c.nodeSize:0))}else{let u=Nl(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function E1(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(tt.near(t.doc.resolve(o),n))}const T1=1,Fu=2,M1=4;class LO extends u0{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|=Fu,this}ensureMarks(e){return Ot.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&Fu)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Fu,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ot.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let a=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(a.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,a.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(tt.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|=M1,this}get scrolledIntoView(){return(this.updated&M1)>0}}function A1(t,e){return!e||!t?t:t.bind(e)}class Bc{constructor(e,n,r){this.name=e,this.init=A1(n.init,r),this.apply=A1(n.apply,r)}}const _O=[new Bc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Bc("selection",{init(t,e){return t.selection||tt.atStart(e.doc)},apply(t){return t.selection}}),new Bc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Bc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Ym{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=_O.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Bc(r.key,r.spec.state,r))})}}class Tl{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 r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=e[r],i=a.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(a,this[a.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let a=new Ym(e.schema,e.plugins),i=new Tl(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=Sa.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=tt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[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 xS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=xS(a,e,{})),n[r]=a}return n}class Ut{constructor(e){this.spec=e,this.props={},e.props&&xS(e.props,this,this.props),this.key=e.key?e.key.key:yS("plugin")}getState(e){return e[this.key]}}const Qm=Object.create(null);function yS(t){return t in Qm?t+"$"+ ++Qm[t]:(Qm[t]=0,t+"$")}class Yt{constructor(e="key"){this.key=yS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const f0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function bS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const vS=(t,e,n)=>{let r=bS(t,n);if(!r)return!1;let a=p0(r);if(!a){let o=r.blockRange(),c=o&&Ql(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(MS(t,a,e,-1))return!0;if(r.parent.content.size==0&&(_l(i,"end")||Je.isSelectable(i)))for(let o=r.depth;;o--){let c=Ef(t.doc,r.before(o),r.after(o),Re.empty);if(c&&c.slice.size1)break}return i.isAtom&&a.depth==r.depth-1?(e&&e(t.tr.delete(a.pos-i.nodeSize,a.pos).scrollIntoView()),!0):!1},zO=(t,e,n)=>{let r=bS(t,n);if(!r)return!1;let a=p0(r);return a?NS(t,a,e):!1},$O=(t,e,n)=>{let r=jS(t,n);if(!r)return!1;let a=m0(r);return a?NS(t,a,e):!1};function NS(t,e,n){let r=e.nodeBefore,a=r,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=Ef(t.doc,i,u,Re.empty);if(!h||h.from!=i||h instanceof Dn&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(Qe.create(f.doc,i)),n(f.scrollIntoView())}return!0}function _l(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const wS=(t,e,n)=>{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=p0(r)}let o=i&&i.nodeBefore;return!o||!Je.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Je.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function p0(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 jS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=jS(t,n);if(!r)return!1;let a=m0(r);if(!a)return!1;let i=a.nodeAfter;if(MS(t,a,e,1))return!0;if(r.parent.content.size==0&&(_l(i,"start")||Je.isSelectable(i))){let o=Ef(t.doc,r.before(),r.after(),Re.empty);if(o&&o.slice.size{let{$head:r,empty:a}=t.selection,i=r;if(!a)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof Je,a;if(r){if(n.node.isTextblock||!Li(t.doc,n.from))return!1;a=n.from}else if(a=Cf(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(Je.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},BO=(t,e)=>{let n=t.selection,r;if(n instanceof Je){if(n.node.isTextblock||!Li(t.doc,n.to))return!1;r=n.to}else if(r=Cf(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},VO=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&Ql(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},CS=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` +`).scrollIntoView()),!0)};function g0(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let a=n.node(-1),i=n.indexAfter(-1),o=g0(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(tt.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},ES=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof Fr||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=g0(a.parent.contentMatchAt(a.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.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(Ca(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&Ql(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function WO(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof Je&&e.selection.node.isBlock)return!r.parentOffset||!Ca(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,c,u=!1,h=!1;for(let y=r.depth;;y--)if(r.node(y).isBlock){u=r.end(y)==r.pos+(r.depth-y),h=r.start(y)==r.pos-(r.depth-y),c=g0(r.node(y-1).contentMatchAt(r.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 Qe||e.selection instanceof Fr)&&f.deleteSelection();let m=f.mapping.map(r.pos),g=Ca(f.doc,m,i.length,i);if(g||(i[0]=c?{type:c}:null,g=Ca(f.doc,m,i.length,i)),!g)return!1;if(f.split(m,i.length,i),!u&&h&&r.node(o).type!=c){let y=f.mapping.map(r.before(o)),v=f.doc.resolve(y);c&&r.node(o-1).canReplaceWith(v.index(),v.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const UO=WO(),KO=(t,e)=>{let{$from:n,to:r}=t.selection,a,i=n.sharedDepth(r);return i==0?!1:(a=n.before(i),e&&e(t.tr.setSelection(Je.create(t.doc,a))),!0)};function qO(t,e,n){let r=e.nodeBefore,a=e.nodeAfter,i=e.index();return!r||!a||!r.type.compatibleContent(a.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(a.isTextblock||Li(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function MS(t,e,n,r){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&qO(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,v=xe.empty;for(let k=o.length-1;k>=0;k--)v=xe.from(o[k].create(null,v));v=xe.from(a.copy(v));let w=t.tr.step(new Ln(e.pos-1,y,e.pos,y,new Re(v,1,0),o.length,!0)),N=w.doc.resolve(y+2*o.length);N.nodeAfter&&N.nodeAfter.type==a.type&&Li(w.doc,N.pos)&&w.join(N.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:tt.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&Ql(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&_l(i,"start",!0)&&_l(a,"end")){let y=a,v=[];for(;v.push(y),!y.isTextblock;)y=y.lastChild;let w=i,N=1;for(;!w.isTextblock;w=w.firstChild)N++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){let k=xe.empty;for(let E=v.length-1;E>=0;E--)k=xe.from(v[E].copy(k));let C=t.tr.step(new Ln(e.pos-v.length,e.pos+i.nodeSize,e.pos+N,e.pos+i.nodeSize-N,new Re(k,v.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function AS(t){return function(e,n){let r=e.selection,a=t<0?r.$from:r.$to,i=a.depth;for(;a.node(i).isInline;){if(!i)return!1;i--}return a.node(i).isTextblock?(n&&n(e.tr.setSelection(Qe.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const GO=AS(-1),JO=AS(1);function YO(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&d0(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function I1(t,e=null){return function(n,r){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(r){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 wh(u,u,e.depth),e.endIndex=0;f--)i=xe.from(n[f].type.create(n[f].attrs,i));t.step(new Ln(e.start-(r?2:0),e.end,e.start,e.end,new Re(i,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?tD(e,n,t,i):nD(e,n,i):!0:!1}}function tD(t,e,n,r){let a=t.tr,i=r.end,o=r.$to.end(r.depth);iw;v--)y-=a.child(v).nodeSize,r.delete(y-1,y+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.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?xe.empty:xe.from(a))))return!1;let m=i.pos,g=m+o.nodeSize;return r.step(new Ln(m-(c?1:0),g+(u?1:0),m+1,g-1,new Re((c?xe.empty:xe.from(a.copy(xe.empty))).append(u?xe.empty:xe.from(a.copy(xe.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function rD(t){return function(e,n){let{$from:r,$to:a}=e.selection,i=r.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=xe.from(h?t.create():null),m=new Re(xe.from(t.create(null,xe.from(c.type.create(null,f)))),h?3:1,0),g=i.start,y=i.end;n(e.tr.step(new Ln(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Hn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},zl=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Xg=null;const ba=function(t,e,n){let r=Xg||(Xg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},sD=function(){Xg=null},Ao=function(t,e,n,r){return n&&(R1(t,e,n,r,-1)||R1(t,e,n,r,1))},aD=/^(img|br|input|textarea|hr)$/i;function R1(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:Xr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Cd(t)||aD.test(t.nodeName)||t.contentEditable=="false")return!1;e=Hn(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?Xr(t):0}else return!1}}function Xr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function iD(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=Xr(t)}else if(t.parentNode&&!Cd(t))e=Hn(t),t=t.parentNode;else return null}}function oD(t,e){for(;;){if(t.nodeType==3&&e2),Qr=$l||(Ks?/Mac/.test(Ks.platform):!1),PS=Ks?/Win/.test(Ks.platform):!1,ja=/Android \d/.test(_i),Ed=!!P1&&"webkitFontSmoothing"in P1.documentElement.style,uD=Ed?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hD(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 pa(t,e){return typeof t=="number"?t:t[e]}function fD(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function O1(t,e,n){let r=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=zl(o);continue}let c=o,u=c==i.body,h=u?hD(i):fD(c),f=0,m=0;if(e.toph.bottom-pa(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+pa(a,"top")-h.top:e.bottom-h.bottom+pa(a,"bottom")),e.lefth.right-pa(r,"right")&&(f=e.right-h.right+pa(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,v=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-y,N=c.scrollTop-v;e={left:e.left-w,top:e.top-N,right:e.right-w,bottom:e.bottom-N}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:zl(o)}}function pD(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,a;for(let i=(e.left+e.right)/2,o=n+1;o=n-20){r=c,a=u.top;break}}return{refDOM:r,refTop:a,stack:OS(t.dom)}}function OS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=zl(r));return e}function mD({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;DS(n,r==0?0:r-e)}function DS(t,e){for(let n=0;n=c){o=Math.max(v.bottom,o),c=Math.min(v.top,c);let w=v.left>e.left?v.left-e.left:v.right=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!u&&v.left<=e.left&&v.right>=e.left&&(u=f,h={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!n&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,r=0),n&&n.nodeType==3?xD(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:LS(n,a)}function xD(t,e){let n=t.nodeValue.length,r=document.createRange(),a;for(let i=0;i=(o.left+o.right)/2?1:0)};break}}return r.detach(),a||{node:t,offset:0}}function y0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function yD(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(r,a,i)}function vD(t,e,n,r){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>r.left||u.top>r.top?a=c.posBefore:(!o&&u.right-1?a:t.docView.posFromDOM(e,n,-1)}function _S(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;Ed&&a&&r.nodeType==1&&(h=r.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&a--,r==t.dom&&a==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(a==0||r.nodeType!=1||r.childNodes[a-1].nodeName!="BR")&&(c=vD(t,r,a,e))}c==null&&(c=bD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function D1(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,Oc(li(ba(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==Xr(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return Xm(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==Xr(r))){let u=r.childNodes[a-1],h=u.nodeType==3?ba(u,Xr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return Oc(li(h,1),!1)}if(i==null&&a=0)}function Oc(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 Xm(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 $S(t,e,n){let r=t.state,a=t.root.activeElement;r!=e&&t.updateState(e),a!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),a!=t.dom&&a&&a.focus()}}function jD(t,e,n){let r=e.selection,a=n=="up"?r.$from:r.$to;return $S(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=zS(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=ba(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 kD=/[\u0590-\u08ac]/;function SD(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let a=r.parentOffset,i=!a,o=a==r.parent.content.size,c=t.domSelection();return c?!kD.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:$S(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:v,focusOffset:w}=t.domSelectionRange(),N=v&&!y.contains(v.nodeType==1?v:v.parentNode)||u==v&&h==w;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return g!=null&&(c.caretBidiLevel=g),N}):r.pos==r.start()||r.pos==r.end()}let L1=null,_1=null,z1=!1;function CD(t,e,n){return L1==e&&_1==n?z1:(L1=e,_1=n,z1=n=="up"||n=="down"?jD(t,e,n):SD(t,e,n))}const es=0,$1=1,po=2,qs=3;class Td{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=es,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nHn(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??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,a=e;a;a=a.parentNode){let i=this.getDesc(a),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let a=e;a;a=a.parentNode){let i=this.getDesc(a);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof BS){a=e-i;break}i=c}if(a)return this.children[r].domFromPos(a-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof FS&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Hn(i.dom)+1:0}}else{let i,o=!0;for(;i=r=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=Hn(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;fv&&on){let v=c;c=u,u=v}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 r=0,a=0;a=r:er){let c=r+i.border,u=o-i.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?po:$1,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=qs:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?po:qs}r=o}this.dirty=po}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?po:$1;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==es&&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 ED extends Td{constructor(e,n,r,a){super(e,[],n,null),this.textDOM=r,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 Io extends Td{constructor(e,n,r,a,i){super(e,[],r,a),this.mark=n,this.spec=i}static create(e,n,r,a){let i=a.nodeViews[n.type.name],o=i&&i(n,a,r);return(!o||!o.dom)&&(o=zo.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Io(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&qs||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=qs&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=es){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=rx(i,0,e,r));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,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}=zo.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=WS(f,r,n),h?u=new TD(e,n,r,a,f,m||null,g,h,i,o+1):n.isText?new Af(e,n,r,a,f,g,i):new Si(e,n,r,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 r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>xe.empty)}return e}matchesNode(e,n,r){return this.dirty==es&&e.eq(this.node)&&kh(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=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 AD(this,o&&o.node,e);PD(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,r,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?Ot.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,a)},(h,f,m,g)=>{u.syncToMarks(h.marks,r,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([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==po)&&(o&&this.protectLocalComposition(e,o),VS(this.contentDOM,this.children,e),$l&&OD(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof Qe)||rn+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=DD(this.node.content,o,r-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:r,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 ED(this,i,n,a);e.input.compositionNodes.push(o),this.children=rx(this.children,r,r+a.length,e,o)}update(e,n,r,a){return this.dirty==qs||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,a),!0)}updateInner(e,n,r,a){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=es}updateOuterDeco(e){if(kh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=HS(this.dom,this.nodeDOM,nx(this.outerDeco,this.node,n),nx(e,this.node,n)),this.dom!=r&&(r.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 F1(t,e,n,r,a){WS(r,e,t);let i=new Si(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Af extends Si{constructor(e,n,r,a,i,o,c){super(e,n,r,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,r,a){return this.dirty==qs||this.dirty!=es&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=es||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=es,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let a=this.node.cut(e,n),i=document.createTextNode(a.text);return new Af(this.parent,a,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=qs)}get domAtom(){return!1}isText(e){return this.node.text==e}}class BS extends Td{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==es&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class TD extends Si{constructor(e,n,r,a,i,o,c,u,h,f){super(e,n,r,a,i,o,c,h,f),this.spec=u}update(e,n,r,a){if(this.dirty==qs)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,a),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,a){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,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 VS(t,e,n){let r=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=Io.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,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,r))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(r){let h=n.children[r-1];if(h instanceof Io)n=h,r=h.children.length;else{c=h,r--;break}}else{if(n==e)break e;r=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 RD(t,e){return t.type.side-e.type.side}function PD(t,e,n,r){let a=e.locals(t),i=0;if(a.length==0){for(let h=0;hi;)c.push(a[o++]);let v=i+g.nodeSize;if(g.isText){let N=v;o!N.inline):c.slice();r(g,w,e.forChild(i,g),y),i=v}}function OD(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 DD(t,e,n,r){for(let a=0,i=0;a=n){if(i>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let h=c=0&&h+e.length+c>=n)return c+h;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function rx(t,e,n,r,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,r)))}return i}function b0(t,e=null){let n=t.domSelectionRange(),r=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=r.resolve(o),u,h;if(Mf(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&Je.isSelectable(m)&&a.parent&&!(m.isInline&&lD(n.focusNode,n.focusOffset,a.dom))){let g=a.posBefore;h=new Je(o==g?c:r.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!=r||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!US(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function _D(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Hn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Mr&&ki<=11&&(n.disabled=!0,n.disabled=!1)}function KS(t,e){if(e instanceof Je){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(U1(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else U1(t)}function U1(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function v0(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||Qe.between(e,n,r)}function K1(t){return t.editable&&!t.hasFocus()?!1:qS(t)}function qS(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 zD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ao(e.node,e.offset,n.anchorNode,n.anchorOffset)}function sx(t,e){let{$anchor:n,$head:r}=t.selection,a=e>0?n.max(r):n.min(r),i=a.parent.inlineContent?a.depth?t.doc.resolve(e>0?a.after():a.before()):null:a;return i&&tt.findFrom(i,e)}function ci(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function q1(t,e,n){let r=t.state.selection;if(r instanceof Qe)if(n.indexOf("s")>-1){let{$head:a}=r,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 ci(t,new Qe(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=sx(t.state,e);return a&&a instanceof Je?ci(t,a):!1}else if(!(Qr&&n.indexOf("m")>-1)){let a=r.$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?Je.isSelectable(i)?ci(t,new Je(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Ed?ci(t,new Qe(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Je&&r.node.isInline)return ci(t,new Qe(e>0?r.$to:r.$from));{let a=sx(t.state,e);return a?ci(t,a):!1}}}function Sh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Yc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function vl(t,e){return e<0?$D(t):FD(t)}function $D(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for(Zr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(Yc(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(GS(n))break;{let c=n.previousSibling;for(;c&&Yc(c,-1);)a=n.parentNode,i=Hn(c),c=c.previousSibling;if(c)n=c,r=Sh(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ax(t,n,r):a&&ax(t,a,i)}function FD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=Sh(n),i,o;for(;;)if(r{t.state==a&&Ea(t)},50)}function G1(t,e){let n=t.state.doc.resolve(e);if(!(Un||PS)&&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 J1(t,e,n){let r=t.state.selection;if(r instanceof Qe&&!r.empty||n.indexOf("s")>-1||Qr&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=r;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=sx(t.state,e);if(o&&o instanceof Je)return ci(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof Fr?tt.near(o,e):tt.findFrom(o,e);return c?ci(t,c):!1}return!1}function Y1(t,e){if(!(t.state.selection instanceof Qe))return!0;let{$head:n,$anchor:r,empty:a}=t.state.selection;if(!n.sameParent(r))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 Q1(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function HD(t){if(!sr||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 r=e.firstChild;Q1(t,r,"true"),setTimeout(()=>Q1(t,r,"false"),20)}return!1}function WD(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function UD(t,e){let n=e.keyCode,r=WD(e);if(n==8||Qr&&n==72&&r=="c")return Y1(t,-1)||vl(t,-1);if(n==46&&!e.shiftKey||Qr&&n==68&&r=="c")return Y1(t,1)||vl(t,1);if(n==13||n==27)return!0;if(n==37||Qr&&n==66&&r=="c"){let a=n==37?G1(t,t.state.selection.from)=="ltr"?-1:1:-1;return q1(t,a,r)||vl(t,a)}else if(n==39||Qr&&n==70&&r=="c"){let a=n==39?G1(t,t.state.selection.from)=="ltr"?1:-1:1;return q1(t,a,r)||vl(t,a)}else{if(n==38||Qr&&n==80&&r=="c")return J1(t,-1,r)||vl(t,-1);if(n==40||Qr&&n==78&&r=="c")return HD(t)||J1(t,1,r)||vl(t,1);if(r==(Qr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function N0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:a,openEnd:i}=e;for(;a>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){a--,i--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let o=t.someProp("clipboardSerializer")||zo.fromSchema(t.state.schema),c=e2(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=ZS[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let v=c.createElement(f[y]);for(;u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),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 JS(t,e,n,r,a){let i=a.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,i||r,t)}),i)return c=new Re(xe.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,r,t));if(m)c=m;else{let g=a.marks(),{schema:y}=t.state,v=zo.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let N=o.appendChild(document.createElement("p"));w&&N.appendChild(v.serializeNode(y.text(w,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=JD(n),Ed&&YD(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")||ji.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!KD.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=QD(X1(c,+f[1],+f[2]),f[4]);else if(c=Re.maxOpen(qD(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 KD=/^(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 qD(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&&QS(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=XS(o[o.length-1],i.length));let f=YS(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return xe.from(o)}return t}function YS(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,xe.from(t));return t}function QS(t,e,n,r,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(xe.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function X1(t,e,n){return en})),eg.createHTML(t)):t}function JD(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=e2().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&ZS[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=GD(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;a=xe.from(u.create(r[c+1],a)),i++,o++}return new Re(a,i,o)}const xr={},yr={},XD={touchstart:!0,touchmove:!0};class ZD{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 eL(t){for(let e in xr){let n=xr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{nL(t,r)&&!w0(t,r)&&(t.editable||!(r.type in yr))&&n(t,r)},XD[e]?{passive:!0}:void 0)}sr&&t.dom.addEventListener("input",()=>null),ox(t)}function vi(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function tL(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 ox(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>w0(t,r))})}function w0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function nL(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 rL(t,e){!w0(t,e)&&xr[e.type]&&(t.editable||!(e.type in yr))&&xr[e.type](t,e)}yr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!n2(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ja&&Un&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),$l&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",a=>a(t,uo(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||UD(t,n)?n.preventDefault():vi(t,"key")};yr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};yr.keypress=(t,e)=>{let n=e;if(n2(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Qr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Qe)||!r.$from.sameParent(r.$to)){let a=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,a,i))&&t.dispatch(i()),n.preventDefault()}};function If(t){return{left:t.clientX,top:t.clientY}}function sL(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function j0(t,e,n,r,a){if(r==-1)return!1;let i=t.state.doc.resolve(r);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 Rl(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function aL(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Je.isSelectable(r)?(Rl(t,new Je(n)),!0):!1}function iL(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof Je&&(r=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(Je.isSelectable(c)){r&&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?(Rl(t,Je.create(t.state.doc,a)),!0):!1}function oL(t,e,n,r,a){return j0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?iL(t,n):aL(t,n))}function lL(t,e,n,r){return j0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function cL(t,e,n,r){return j0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||dL(t,n,r)}function dL(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Rl(t,Qe.create(r,0,r.content.size)),!0):!1;let a=r.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)Rl(t,Qe.create(r,c+1,c+1+o.content.size));else if(Je.isSelectable(o))Rl(t,Je.create(r,c));else continue;return!0}}function k0(t){return Ch(t)}const t2=Qr?"metaKey":"ctrlKey";xr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=k0(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&sL(n,t.input.lastClick)&&!n[t2]&&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(If(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new uL(t,o,n,!!r)):(i=="doubleClick"?lL:cL)(t,o.pos,o.inside,n)?n.preventDefault():vi(t,"pointer"))};class uL{constructor(e,n,r,a){this.view=e,this.pos=n,this.event=r,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[t2],this.allowDefault=r.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:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||h instanceof Je&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Zr&&!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)),vi(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(()=>Ea(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(If(e))),this.updateAllowDefault(e),this.allowDefault||!n?vi(this.view,"pointer"):oL(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||sr&&this.mightDrag&&!this.mightDrag.node.isAtom||Un&&!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)?(Rl(this.view,tt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):vi(this.view,"pointer")}move(e){this.updateAllowDefault(e),vi(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)}}xr.touchstart=t=>{t.input.lastTouch=Date.now(),k0(t),vi(t,"pointer")};xr.touchmove=t=>{t.input.lastTouch=Date.now(),vi(t,"pointer")};xr.contextmenu=t=>k0(t);function n2(t,e){return t.composing?!0:sr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const hL=ja?5e3:-1;yr.compositionstart=yr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Qe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Un&&PS&&fL(t)))t.markCursor=t.state.storedMarks||n.marks(),Ch(t,!0),t.markCursor=null;else if(Ch(t,!e.selection.empty),Zr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let a=r.focusNode,i=r.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}r2(t,hL)};function fL(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}yr.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++,r2(t,20))};function r2(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Ch(t),e))}function s2(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=mL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function pL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=iD(e.focusNode,e.focusOffset),r=oD(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let a=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!a||!a.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function mL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Ch(t,e=!1){if(!(ja&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),s2(t),e||t.docView&&t.docView.dirty){let n=b0(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function gL(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 r=getSelection(),a=document.createRange();a.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(a),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const hd=Mr&&ki<15||$l&&uD<604;xr.copy=yr.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=hd?null:n.clipboardData,o=r.content(),{dom:c,text:u}=N0(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):gL(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function xL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function yL(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?fd(t,r.value,null,a,e):fd(t,r.textContent,r.innerHTML,a,e)},50)}function fd(t,e,n,r,a){let i=JS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||Re.empty)))return!0;if(!i)return!1;let o=xL(i),c=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function a2(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," "):""}yr.paste=(t,e)=>{let n=e;if(t.composing&&!ja)return;let r=hd?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&fd(t,a2(r),r.getData("text/html"),a,n)?n.preventDefault():yL(t,n)};class i2{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const bL=Qr?"altKey":"ctrlKey";function o2(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[bL]}xr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let a=t.state.selection,i=a.empty?null:t.posAtCoords(If(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof Je?a.to-1:a.to))){if(r&&r.mightDrag)o=Je.create(t.state.doc,r.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=Je.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=N0(t,c);(!n.dataTransfer.files.length||!Un||RS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(hd?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",hd||n.dataTransfer.setData("text/plain",h),t.dragging=new i2(f,o2(t,n),o)};xr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};yr.dragover=yr.dragenter=(t,e)=>e.preventDefault();yr.drop=(t,e)=>{try{vL(t,e,t.dragging)}finally{t.dragging=null}};function vL(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(If(e));if(!r)return;let a=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=JS(t,a2(e.dataTransfer),hd?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&o2(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||Re.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?uS(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&&Je.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new Je(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,w,N,k)=>y=k),u.setSelection(v0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}xr.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())&&Ea(t)},20))};xr.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)};xr.beforeinput=(t,e)=>{if(Un&&ja&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,uo(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 yr)xr[t]=yr[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 Eh{constructor(e,n){this.toDOM=e,this.spec=n||jo,this.side=this.spec.side||0}map(e,n,r,a){let{pos:i,deleted:o}=e.mapResult(n.from+a,this.side<0?-1:1);return o?null:new Tn(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Eh&&(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 Ci{constructor(e,n){this.attrs=e,this.spec=n||jo}map(e,n,r,a){let i=e.map(n.from+a,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+a,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Tn(i,o,this)}valid(e,n){return n.from=e&&(!i||i(c.spec))&&r.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,r,a+c,i)}}map(e,n,r){return this==tr||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jo)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=c2(n,c,h)){for(a||(a=this.children.slice());ic&&m.to=e){this.children[c]==e&&(r=this.children[c+2]);break}let i=e+1,o=i+n.content.size;for(let c=0;ci&&u.type instanceof Ci){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,jo));return hi.from(r)}forChild(e,n){if(n.isLeaf)return Pt.empty;let r=[];for(let a=0;an instanceof Pt)?e:e.reduce((n,r)=>n.concat(r instanceof Pt?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let N=w-v-(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&&N&&(c[k]+=N,c[k+1]+=N)}m+=N}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let g=n.map(t[h+1]+i,-1),y=g-a,{index:v,offset:w}=r.content.findIndex(m),N=r.maybeChild(v);if(N&&w==m&&w+N.nodeSize==y){let k=c[h+2].mapInner(n,N,f+1,t[h]+i+1,o);k!=tr?(c[h]=m,c[h+1]=y,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=wL(c,t,e,n,a,i,o),f=Th(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=c2(t,c,u+n);if(h){i=!0;let f=Th(h,c,n+u+1,r);f!=tr&&a.push(u,u+c.nodeSize,f)}});let o=l2(i?d2(t):t,-n).sort(ko);for(let c=0;c0;)e++;t.splice(e,0,n)}function tg(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=tr&&e.push(r)}),t.cursorWrapper&&e.push(Pt.create(t.state.doc,[t.cursorWrapper.deco])),hi.from(e)}const jL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},kL=Mr&&ki<=11;class SL{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 CL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new SL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let a=0;aa.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():sr&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),kL&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,jL)),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(K1(this.view)){if(this.suppressingSelectionUpdates)return Ea(this.view);if(Mr&&ki<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ao(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,r;for(let i=e.focusNode;i;i=zl(i))n.add(i);for(let i=e.anchorNode;i;i=zl(i))if(n.has(i)){r=i;break}let a=r&&this.view.docView.nearestDesc(r);if(a&&a.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 r=e.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&K1(e)&&!this.ignoreSelectionChange(r),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(Zr&&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||ML(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),EL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,AL(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ea(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fa;N--){let k=r.childNodes[N-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){i=N;break}if(!C||C.size)break}let m=t.state.doc,g=t.someProp("domParser")||ji.fromSchema(t.state.schema),y=m.resolve(o),v=null,w=g.parse(r,{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:RL,context:y});if(h&&h[0].pos!=null){let N=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=N),v={anchor:N+o,head:k+o}}return{doc:w,sel:v,from:o,to:c}}function RL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(sr&&/^(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||sr&&/^(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 PL=/^(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 OL(t,e,n,r,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let _=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=b0(t,_);if(P&&!t.state.selection.eq(P)){if(Un&&ja&&t.input.lastKeyCode===13&&Date.now()-100z(t,uo(13,"Enter"))))return;let L=t.state.tr.setSelection(P);_=="pointer"?L.setMeta("pointer",!0):_=="key"&&L.scrollIntoView(),i&&L.setMeta("composition",i),t.dispatch(L)}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=IL(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||ja)&&a.some(_=>_.nodeType==1&&!PL.test(_.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",_=>_(t,uo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&u instanceof Qe&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))v={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let _=sN(t,t.state.doc,h.sel);if(_&&!_.eq(t.state.selection)){let P=t.state.tr.setSelection(_);i&&P.setMeta("composition",i),t.dispatch(P)}}return}t.state.selection.fromt.state.selection.from&&v.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?v.start=t.state.selection.from:v.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),Mr&&ki<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>h.from&&h.doc.textBetween(v.start-h.from-1,v.start-h.from+1)=="  "&&(v.start--,v.endA--,v.endB--);let w=h.doc.resolveNoCache(v.start-h.from),N=h.doc.resolveNoCache(v.endB-h.from),k=f.resolve(v.start),C=w.sameParent(N)&&w.parent.inlineContent&&k.end()>=v.endA;if(($l&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some(_=>_.nodeName=="DIV"||_.nodeName=="P"))||!C&&w.pos_(t,uo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&LL(f,v.start,v.endA,w,N)&&t.someProp("handleKeyDown",_=>_(t,uo(8,"Backspace")))){ja&&Un&&t.domObserver.suppressSelectionUpdates();return}Un&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),ja&&!C&&w.start()!=N.start()&&N.parentOffset==0&&w.depth==N.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==v.endA&&(v.endB-=2,N=h.doc.resolveNoCache(v.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(_){return _(t,uo(13,"Enter"))})},20));let E=v.start,A=v.endA,I=_=>{let P=_||t.state.tr.replace(E,A,h.doc.slice(v.start-h.from,v.endB-h.from));if(h.sel){let L=sN(t,P.doc,h.sel);L&&!(Un&&t.composing&&L.empty&&(v.start!=v.endB||t.input.lastChromeDeleteEa(t),20));let _=I(t.state.tr.delete(E,A)),P=f.resolve(v.start).marksAcross(f.resolve(v.endA));P&&_.ensureMarks(P),t.dispatch(_)}else if(v.endA==v.endB&&(D=DL(w.parent.content.cut(w.parentOffset,N.parentOffset),k.parent.content.cut(k.parentOffset,v.endA-k.start())))){let _=I(t.state.tr);D.type=="add"?_.addMark(E,A,D.mark):_.removeMark(E,A,D.mark),t.dispatch(_)}else if(w.parent.child(w.index()).isText&&w.index()==N.index()-(N.textOffset?0:1)){let _=w.parent.textBetween(w.parentOffset,N.parentOffset),P=()=>I(t.state.tr.insertText(_,E,A));t.someProp("handleTextInput",L=>L(t,E,A,_,P))||t.dispatch(P())}else t.dispatch(I());else t.dispatch(I())}function sN(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:v0(t,e.resolve(n.anchor),e.resolve(n.head))}function DL(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,a=n,i=r,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||ng(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,a++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,a++}return a}function _L(t,e,n,r,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));r-=o+u-i}if(o=o?i-r:0;i-=u,i&&i=c?i-r:0;i-=u,i&&i=56320&&e<=57343&&n>=55296&&n<=56319}class u2{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 ZD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(dN),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=lN(this),oN(this),this.nodeViews=cN(this),this.docView=F1(this.state.doc,iN(this),tg(this),this.dom,this),this.domObserver=new CL(this,(r,a,i,o)=>OL(this,r,a,i,o)),this.domObserver.start(),eL(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&&ox(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(dN),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let a=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(s2(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=cN(this);$L(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&ox(this),this.editable=lN(this),oN(this);let u=tg(this),h=iN(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&&pD(this);if(o){this.domObserver.stop();let y=m&&(Mr||Un)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&zL(a.selection,e.selection);if(m){let v=Un?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=pL(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=F1(e.doc,h,u,this.dom,this)),v&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&zD(this))?Ea(this,y):(KS(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((r=this.dragging)===null||r===void 0)&&r.node&&!a.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,a),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&mD(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 Je){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&O1(this,n.getBoundingClientRect(),e)}else O1(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))==r.node&&(a=i)}this.dragging=new i2(e.slice,e.move,a<0?void 0:Je.create(this.state.doc,a))}someProp(e,n){let r=this._props&&this._props[e],a;if(r!=null&&(a=n?n(r):r))return a;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ND(this,e)}coordsAtPos(e,n=1){return zS(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,r=-1){let a=this.docView.posFromDOM(e,n,r);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(e,n){return CD(this,n||this.state,e)}pasteHTML(e,n){return fd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return fd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return N0(this,e)}destroy(){this.docView&&(tL(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],tg(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,sD())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return rL(this,e)}domSelectionRange(){let e=this.domSelection();return e?sr&&this.root.nodeType===11&&cD(this.dom.ownerDocument)==this.dom&&TL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}u2.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function iN(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 r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Tn.node(0,t.state.doc.content.size,e)]}function oN(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:Tn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function lN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function zL(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 cN(t){let e=Object.create(null);function n(r){for(let a in r)Object.prototype.hasOwnProperty.call(e,a)||(e[a]=r[a])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function $L(t,e){let n=0,r=0;for(let a in t){if(t[a]!=e[a])return!0;n++}for(let a in e)r++;return n!=r}function dN(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 Ti={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:"'"},Mh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},FL=typeof navigator<"u"&&/Mac/.test(navigator.platform),BL=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Wn=0;Wn<10;Wn++)Ti[48+Wn]=Ti[96+Wn]=String(Wn);for(var Wn=1;Wn<=24;Wn++)Ti[Wn+111]="F"+Wn;for(var Wn=65;Wn<=90;Wn++)Ti[Wn]=String.fromCharCode(Wn+32),Mh[Wn]=String.fromCharCode(Wn);for(var rg in Ti)Mh.hasOwnProperty(rg)||(Mh[rg]=Ti[rg]);function VL(t){var e=FL&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||BL&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Mh:Ti)[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 HL=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),WL=typeof navigator<"u"&&/Win/.test(navigator.platform);function UL(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,a,i,o;for(let c=0;c{for(var n in e)GL(t,n,{get:e[n],enumerable:!0})};function Rf(t){const{state:e,transaction:n}=t;let{selection:r}=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 r},get doc(){return a},get tr(){return r=n.selection,a=n.doc,i=n.storedMarks,n}}}var Pf=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:r}=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&&r.dispatch(a),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:a}=this,{view:i}=r,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,(...v)=>{const w=this.buildProps(u,e),N=g(...v)(w);return o.push(N),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,r=!1,a=t||n.tr,i=this.buildProps(a,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...i,dispatch:void 0})])),chain:()=>this.createChain(a,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:a}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:Rf({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}},h2={};T0(h2,{blur:()=>JL,clearContent:()=>YL,clearNodes:()=>QL,command:()=>XL,createParagraphNear:()=>ZL,cut:()=>e8,deleteCurrentNode:()=>t8,deleteNode:()=>n8,deleteRange:()=>r8,deleteSelection:()=>s8,enter:()=>a8,exitCode:()=>i8,extendMarkRange:()=>o8,first:()=>l8,focus:()=>d8,forEach:()=>u8,insertContent:()=>h8,insertContentAt:()=>m8,joinBackward:()=>y8,joinDown:()=>x8,joinForward:()=>b8,joinItemBackward:()=>v8,joinItemForward:()=>N8,joinTextblockBackward:()=>w8,joinTextblockForward:()=>j8,joinUp:()=>g8,keyboardShortcut:()=>S8,lift:()=>C8,liftEmptyBlock:()=>E8,liftListItem:()=>T8,newlineInCode:()=>M8,resetAttributes:()=>A8,scrollIntoView:()=>I8,selectAll:()=>R8,selectNodeBackward:()=>P8,selectNodeForward:()=>O8,selectParentNode:()=>D8,selectTextblockEnd:()=>L8,selectTextblockStart:()=>_8,setContent:()=>z8,setMark:()=>s6,setMeta:()=>a6,setNode:()=>i6,setNodeSelection:()=>o6,setTextDirection:()=>l6,setTextSelection:()=>c6,sinkListItem:()=>d6,splitBlock:()=>u6,splitListItem:()=>h6,toggleList:()=>f6,toggleMark:()=>p6,toggleNode:()=>m6,toggleWrap:()=>g6,undoInputRule:()=>x6,unsetAllMarks:()=>y6,unsetMark:()=>b6,unsetTextDirection:()=>v6,updateAttributes:()=>N6,wrapIn:()=>w6,wrapInList:()=>j6});var JL=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),YL=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),QL=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:a}=r;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 v=Ql(y);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,w)}(v||v===0)&&e.lift(y,v)})}),!0},XL=t=>e=>t(e),ZL=()=>({state:t,dispatch:e})=>ES(t,e),e8=(t,e)=>({editor:n,tr:r})=>{const{state:a}=n,i=a.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new Qe(r.doc.resolve(Math.max(o-1,0)))),!0},t8=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const a=t.selection.$anchor;for(let i=a.depth;i>0;i-=1)if(a.node(i).type===r.type){if(e){const c=a.before(i),u=a.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1};function Nn(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 n8=t=>({tr:e,state:n,dispatch:r})=>{const a=Nn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===a){if(r){const u=i.before(o),h=i.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},r8=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},s8=()=>({state:t,dispatch:e})=>f0(t,e),a8=()=>({commands:t})=>t.keyboardShortcut("Enter"),i8=()=>({state:t,dispatch:e})=>HO(t,e);function M0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Ah(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:M0(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function f2(t,e,n={}){return t.find(r=>r.type===e&&Ah(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function uN(t,e,n={}){return!!f2(t,e,n)}function A0(t,e,n){var r;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||((r=a.node.marks[0])==null?void 0:r.attrs),!f2([...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&&uN([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u({tr:n,state:r,dispatch:a})=>{const i=Ia(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=A0(u,i,e);if(m&&m.from<=h&&m.to>=f){const g=Qe.create(o,m.from,m.to);n.setSelection(g)}}return!0},l8=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:a,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ih()||hN())&&r.dom.focus(),c8()&&!Ih()&&!hN()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!p2(n.state.selection))return o(),!0;const c=m2(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},u8=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),h8=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),g2=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&g2(r)}return t};function Bu(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 g2(n)}function md(t,e,n){if(t instanceof Sa||t instanceof xe)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,a=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return xe.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),md("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new eS({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?ji.fromSchema(u).parseSlice(Bu(t),n.parseOptions):ji.fromSchema(u).parse(Bu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=ji.fromSchema(e);return n.slice?i.parseSlice(Bu(t),n.parseOptions).content:i.parse(Bu(t),n.parseOptions)}return md("",e,n)}function f8(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(tt.near(t.doc.resolve(o),n))}var p8=t=>!("type"in t),m8=(t,e,n)=>({tr:r,dispatch:a,editor:i})=>{var o;if(a){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=N=>{i.emit("contentError",{editor:i,error:N,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{md(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(N){u(N)}try{c=md(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(N){return u(N),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((p8(c)?c:[c]).forEach(N=>{N.check(),g=g?N.isText&&N.marks.length===0:!1,y=y?N.isBlock:!1}),f===m&&y){const{parent:N}=r.doc.resolve(f);N.isTextblock&&!N.type.spec.code&&!N.childCount&&(f-=1,m+=1)}let w;if(g){if(Array.isArray(e))w=e.map(N=>N.text||"").join("");else if(e instanceof xe){let N="";e.forEach(k=>{k.text&&(N+=k.text)}),w=N}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,f,m)}else{w=c;const N=r.doc.resolve(f),k=N.node(),C=N.parentOffset===0,E=k.isText||k.isTextblock,A=k.content.size>0;C&&E&&A&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&f8(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:f,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:f,text:w})}return!0},g8=()=>({state:t,dispatch:e})=>FO(t,e),x8=()=>({state:t,dispatch:e})=>BO(t,e),y8=()=>({state:t,dispatch:e})=>vS(t,e),b8=()=>({state:t,dispatch:e})=>kS(t,e),v8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Cf(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},N8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Cf(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},w8=()=>({state:t,dispatch:e})=>zO(t,e),j8=()=>({state:t,dispatch:e})=>$O(t,e);function x2(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function k8(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,a,i,o;for(let c=0;c({editor:e,view:n,tr:r,dispatch:a})=>{const i=k8(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(r.mapping);f&&a&&r.maybeStep(f)}),!0};function Mi(t,e,n={}){const{from:r,to:a,empty:i}=t.selection,o=e?Nn(e,t.schema):null,c=[];t.doc.nodesBetween(r,a,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),v=Math.min(a,g+m.nodeSize);c.push({node:m,from:y,to:v})});const u=a-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Ah(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var C8=(t,e={})=>({state:n,dispatch:r})=>{const a=Nn(t,n.schema);return Mi(n,a,e)?VO(n,r):!1},E8=()=>({state:t,dispatch:e})=>TS(t,e),T8=t=>({state:e,dispatch:n})=>{const r=Nn(t,e.schema);return eD(r)(e,n)},M8=()=>({state:t,dispatch:e})=>CS(t,e);function Of(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function fN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,a)=>(n.includes(a)||(r[a]=t[a]),r),{})}var A8=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=Of(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Nn(t,r.schema)),c==="mark"&&(o=Ia(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{r.doc.nodesBetween(h.$from.pos,h.$to.pos,(f,m)=>{i&&i===f.type&&(u=!0,a&&n.setNodeMarkup(m,void 0,fN(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(fN(g.attrs,e))))})})}),u},I8=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),R8=()=>({tr:t,dispatch:e})=>{if(e){const n=new Fr(t.doc);t.setSelection(n)}return!0},P8=()=>({state:t,dispatch:e})=>wS(t,e),O8=()=>({state:t,dispatch:e})=>SS(t,e),D8=()=>({state:t,dispatch:e})=>KO(t,e),L8=()=>({state:t,dispatch:e})=>JO(t,e),_8=()=>({state:t,dispatch:e})=>GO(t,e);function lx(t,e,n={},r={}){return md(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var z8=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:a,tr:i,dispatch:o,commands:c})=>{const{doc:u}=i;if(r.preserveWhitespace!=="full"){const h=lx(t,a.schema,r,{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:r,errorOnInvalidContent:e??a.options.enableContentCheck})};function y2(t,e){const n=Ia(e,t.schema),{from:r,to:a,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,a,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function b2(t,e){const n=new u0(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function $8(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function v2(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Df(t){return e=>v2(e.$from,t)}function We(t,e,n){return t.config[e]===void 0&&t.parent?We(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?We(t.parent,e,n):null}):t.config[e]}function I0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=We(e,"addExtensions",n);return r?[e,...I0(r())]:e}).flat(10)}function R0(t,e){const n=zo.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function N2(t){return typeof t=="function"}function jt(t,e=void 0,...n){return N2(t)?e?t.bind(e)(...n):t(...n):t}function B8(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Fl(t){const e=t.filter(a=>a.type==="extension"),n=t.filter(a=>a.type==="node"),r=t.filter(a=>a.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function w2(t){const e=[],{nodeExtensions:n,markExtensions:r}=Fl(t),a=[...n,...r],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=r.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=We(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let v;Array.isArray(y.types)?v=y.types:y.types==="*"?v=u:y.types==="nodes"?v=o:y.types==="marks"?v=c:v=[],v.forEach(w=>{Object.entries(y.attributes).forEach(([N,k])=>{e.push({type:w,name:N,attribute:{...i,...k}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=We(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,v])=>{const w={...i,...v};typeof(w==null?void 0:w.default)=="function"&&(w.default=w.default()),w!=null&&w.isRequired&&(w==null?void 0:w.default)===void 0&&delete w.default,e.push({type:h.name,name:y,attribute:w})})}),e}function V8(t){const e=[];let n="",r=!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 pN(t){const e=[],n=V8(t||""),r=n.length;for(let a=0;a!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([a,i])=>{if(!r[a]){r[a]=i;return}if(a==="class"){const c=i?String(i).split(" "):[],u=r[a]?r[a].split(" "):[],h=c.filter(f=>!u.includes(f));r[a]=[...u,...h].join(" ")}else if(a==="style"){const c=new Map([...pN(r[a]),...pN(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function gd(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,r)=>kt(n,r),{})}function H8(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function mN(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const a=e.reduce((i,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):H8(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function gN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&B8(n)?!1:n!=null))}function xN(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function W8(t,e){var n;const r=w2(t),{nodeExtensions:a,markExtensions:i}=Fl(t),o=(n=a.find(h=>We(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(a.map(h=>{const f=r.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=We(C,"extendNodeSchema",m);return{...k,...E?E(h):{}}},{}),y=gN({...g,content:jt(We(h,"content",m)),marks:jt(We(h,"marks",m)),group:jt(We(h,"group",m)),inline:jt(We(h,"inline",m)),atom:jt(We(h,"atom",m)),selectable:jt(We(h,"selectable",m)),draggable:jt(We(h,"draggable",m)),code:jt(We(h,"code",m)),whitespace:jt(We(h,"whitespace",m)),linebreakReplacement:jt(We(h,"linebreakReplacement",m)),defining:jt(We(h,"defining",m)),isolating:jt(We(h,"isolating",m)),attrs:Object.fromEntries(f.map(xN))}),v=jt(We(h,"parseHTML",m));v&&(y.parseDOM=v.map(k=>mN(k,f)));const w=We(h,"renderHTML",m);w&&(y.toDOM=k=>w({node:k,HTMLAttributes:gd(k,f)}));const N=We(h,"renderText",m);return N&&(y.toText=N),[h.name,y]})),u=Object.fromEntries(i.map(h=>{const f=r.filter(N=>N.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((N,k)=>{const C=We(k,"extendMarkSchema",m);return{...N,...C?C(h):{}}},{}),y=gN({...g,inclusive:jt(We(h,"inclusive",m)),excludes:jt(We(h,"excludes",m)),group:jt(We(h,"group",m)),spanning:jt(We(h,"spanning",m)),code:jt(We(h,"code",m)),attrs:Object.fromEntries(f.map(xN))}),v=jt(We(h,"parseHTML",m));v&&(y.parseDOM=v.map(N=>mN(N,f)));const w=We(h,"renderHTML",m);return w&&(y.toDOM=N=>w({mark:N,HTMLAttributes:gd(N,f)})),[h.name,y]}));return new eS({topNode:o,nodes:c,marks:u})}function U8(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Qc(t){return t.sort((n,r)=>{const a=We(n,"priority")||100,i=We(r,"priority")||100;return a>i?-1:ar.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function k2(t,e,n){const{from:r,to:a}=e,{blockSeparator:i=` + +`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,a,(u,h,f,m)=>{var g;u.isBlock&&h>r&&(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(r,h)-h,a-h))}),c}function K8(t,e){const n={from:0,to:t.content.size};return k2(t,n,e)}function S2(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function q8(t,e){const n=Nn(e,t.schema),{from:r,to:a}=t.selection,i=[];t.doc.nodesBetween(r,a,c=>{i.push(c)});const o=i.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function C2(t,e){const n=Of(typeof e=="string"?e:e.name,t.schema);return n==="node"?q8(t,e):n==="mark"?y2(t,e):{}}function G8(t,e=JSON.stringify){const n={};return t.filter(r=>{const a=e(r);return Object.prototype.hasOwnProperty.call(n,a)?!1:n[a]=!0})}function J8(t){const e=G8(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).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 E2(t){const{mapping:e,steps:n}=t,r=[];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);r.push({oldRange:{from:m,to:g},newRange:{from:h,to:f}})})}),J8(r)}function P0(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=A0(i,a.type);o&&r.push({mark:a,...o})}):n.nodesBetween(t,e,(a,i)=>{!a||(a==null?void 0:a.nodeSize)===void 0||r.push(...a.marks.map(o=>({from:i,to:i+a.nodeSize,mark:o})))}),r}var Y8=(t,e,n,r=20)=>{const a=t.doc.resolve(n);let i=r,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 Dc(t,e){return e.nodes[t]||e.marks[t]||null}function ah(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const a=t.find(i=>i.type===e&&i.name===r);return a?a.attribute.keepOnSplit:!1}))}var Q8=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(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,r-i))}),n};function cx(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?Ia(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Ah(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:g})=>{const y=m.pos,v=g.pos;t.doc.nodesBetween(y,v,(w,N)=>{if(i&&w.inlineContent&&!w.type.allowsMarkType(i))return!1;if(!w.isText&&!w.marks.length)return;const k=Math.max(y,N),C=Math.min(v,N+w.nodeSize),E=C-k;o+=E,c.push(...w.marks.map(A=>({mark:A,from:k,to:C})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Ah(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 X8(t,e,n={}){if(!e)return Mi(t,null,n)||cx(t,null,n);const r=Of(e,t.schema);return r==="node"?Mi(t,e,n):r==="mark"?cx(t,e,n):!1}var Z8=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=Df(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!(r.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function yN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function bN(t,e){const{nodeExtensions:n}=Fl(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=jt(We(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function Lf(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}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&&(Lf(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function T2(t){return t instanceof Je}var M2=class A2{constructor(e){this.position=e}static fromJSON(e){return new A2(e.position)}toJSON(){return{position:this.position}}};function t6(t,e){const n=e.mapping.mapResult(t.position);return{position:new M2(n.pos),mapResult:n}}function n6(t){return new M2(t)}function r6(t,e,n){var r;const{selection:a}=e;let i=null;if(p2(a)&&(i=a.$cursor),i){const c=(r=t.storedMarks)!=null?r: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),v=!!n.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(n));h=y&&v}return!h}),h})}var s6=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=Ia(t,r.schema);if(a)if(o){const h=y2(r,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;r.doc.nodesBetween(f,m,(g,y)=>{const v=Math.max(y,f),w=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===u)?g.marks.forEach(k=>{u===k.type&&n.addMark(v,w,u.create({...k.attrs,...e}))}):n.addMark(v,w,u.create(e))})});return r6(r,n,u)},a6=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),i6=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=Nn(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})=>I1(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>I1(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},o6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=go(t,0,r.content.size),i=Je.create(r,a);e.setSelection(i)}return!0},l6=(t,e)=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=r;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},c6=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=Qe.atStart(r).from,c=Qe.atEnd(r).to,u=go(a,o,c),h=go(i,o,c),f=Qe.create(r,u,h);e.setSelection(f)}return!0},d6=t=>({state:e,dispatch:n})=>{const r=Nn(t,e.schema);return rD(r)(e,n)};function vN(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(a=>e==null?void 0:e.includes(a.type.name));t.tr.ensureMarks(r)}}var u6=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:a})=>{const{selection:i,doc:o}=e,{$from:c,$to:u}=i,h=a.extensionManager.attributes,f=ah(h,c.node().type.name,c.node().attrs);if(i instanceof Je&&i.node.isBlock)return!c.parentOffset||!Ca(o,c.pos)?!1:(r&&(t&&vN(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:$8(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,v=Ca(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!v&&Ca(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(v=!0,y=g?[{type:g,attrs:f}]:void 0),r){if(v&&(i instanceof Qe&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const w=e.mapping.map(c.before()),N=e.doc.resolve(w);c.node(-1).canReplaceWith(N.index(),N.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&vN(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return v},h6=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=Nn(t,r.schema),{$from:u,$to:h}=r.selection,f=r.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=xe.empty;const C=u.index(-1)?1:u.index(-2)?2:3;for(let P=u.depth-C;P>=u.depth-3;P-=1)k=xe.from(u.node(P).copy(k));const E=u.indexAfter(-1){if(_>-1)return!1;P.isTextblock&&P.content.size===0&&(_=L+1)}),_>-1&&n.setSelection(Qe.near(n.doc.resolve(_))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,v={...ah(g,m.type.name,m.attrs),...e},w={...ah(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const N=y?[{type:c,attrs:v},{type:y,attrs:w}]:[{type:c,attrs:v}];if(!Ca(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:C}=r,{splittableMarks:E}=i.extensionManager,A=C||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,N).scrollIntoView(),!A||!a)return!0;const I=A.filter(D=>E.includes(D.type.name));n.ensureMarks(I)}return!0},ag=(t,e)=>{const n=Df(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&Li(t.doc,n.pos)&&t.join(n.pos),!0},ig=(t,e)=>{const n=Df(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const a=t.doc.nodeAt(r);return n.node.type===(a==null?void 0:a.type)&&Li(t.doc,r)&&t.join(r),!0},f6=(t,e,n,r={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=a.extensionManager,y=Nn(t,o.schema),v=Nn(e,o.schema),{selection:w,storedMarks:N}=o,{$from:k,$to:C}=w,E=k.blockRange(C),A=N||w.$to.parentOffset&&w.$from.marks();if(!E)return!1;const I=Df(D=>bN(D.type.name,m))(w);if(E.depth>=1&&I&&E.depth-I.depth<=1){if(I.node.type===y)return h.liftListItem(v);if(bN(I.node.type.name,m)&&y.validContent(I.node.content)&&c)return u().command(()=>(i.setNodeMarkup(I.pos,y),!0)).command(()=>ag(i,y)).command(()=>ig(i,y)).run()}return!n||!A||!c?u().command(()=>f().wrapInList(y,r)?!0:h.clearNodes()).wrapInList(y,r).command(()=>ag(i,y)).command(()=>ig(i,y)).run():u().command(()=>{const D=f().wrapInList(y,r),_=A.filter(P=>g.includes(P.type.name));return i.ensureMarks(_),D?!0:h.clearNodes()}).wrapInList(y,r).command(()=>ag(i,y)).command(()=>ig(i,y)).run()},p6=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=Ia(t,r.schema);return cx(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},m6=(t,e,n={})=>({state:r,commands:a})=>{const i=Nn(t,r.schema),o=Nn(e,r.schema),c=Mi(r,i,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?a.setNode(o,u):a.setNode(i,{...u,...n})},g6=(t,e={})=>({state:n,commands:r})=>{const a=Nn(t,n.schema);return Mi(n,a,e)?r.lift(a):r.wrapIn(a,e)},x6=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=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},y6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:a}=n;return r||e&&a.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},b6=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=Ia(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:g,to:y}=c;const v=(i=h.marks().find(N=>N.type===u))==null?void 0:i.attrs,w=A0(h,u,v);w&&(g=w.from,y=w.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},v6=t=>({tr:e,state:n,dispatch:r})=>{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),r&&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},N6=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=Of(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Nn(t,r.schema)),c==="mark"&&(o=Ia(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,v,w;n.selection.empty?r.doc.nodesBetween(f,m,(N,k)=>{i&&i===N.type&&(u=!0,v=Math.max(k,f),w=Math.min(k+N.nodeSize,m),g=k,y=N)}):r.doc.nodesBetween(f,m,(N,k)=>{k=f&&k<=m&&(i&&i===N.type&&(u=!0,a&&n.setNodeMarkup(k,void 0,{...N.attrs,...e})),o&&N.marks.length&&N.marks.forEach(C=>{if(o===C.type&&(u=!0,a)){const E=Math.max(k,f),A=Math.min(k+N.nodeSize,m);n.addMark(E,A,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(N=>{o===N.type&&a&&n.addMark(v,w,o.create({...N.attrs,...e}))}))}),u},w6=(t,e={})=>({state:n,dispatch:r})=>{const a=Nn(t,n.schema);return YO(a,e)(n,r)},j6=(t,e={})=>({state:n,dispatch:r})=>{const a=Nn(t,n.schema);return QO(a,e)(n,r)},k6=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(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},_f=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},S6=(t,e)=>{if(M0(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Vu(t){var e;const{editor:n,from:r,to:a,text:i,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(r);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=S6(m,g.find);if(!y)return;const v=u.state.tr,w=Rf({state:u.state,transaction:v}),N={from:r-(y[0].length-i.length),to:a},{commands:k,chain:C,can:E}=new Pf({editor:n,state:w});g.handler({state:w,range:N,match:y,commands:k,chain:C,can:E})===null||!v.steps.length||(g.undoable&&v.setMeta(c,{transform:v,from:r,to:a,text:i}),u.dispatch(v),f=!0)}),f}function C6(t){const{editor:e,rules:n}=t,r=new Ut({state:{init(){return null},apply(a,i,o){const c=a.getMeta(r);if(c)return c;const u=a.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=R0(xe.from(f),o.schema);const{from:m}=u,g=m+f.length;Vu({editor:e,from:m,to:g,text:f,rules:n,plugin:r})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return Vu({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&Vu({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(a,i){if(i.key!=="Enter")return!1;const{$cursor:o}=a.state.selection;return o?Vu({editor:e,from:o.pos,to:o.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function E6(t){return Object.prototype.toString.call(t).slice(8,-1)}function Hu(t){return E6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function I2(t,e){const n={...t};return Hu(t)&&Hu(e)&&Object.keys(e).forEach(r=>{Hu(e[r])&&Hu(t[r])?n[r]=I2(t[r],e[r]):n[r]=e[r]}),n}var O0=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{...jt(We(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...jt(We(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>I2(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}},$o=class R2 extends O0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new R2(n)}static handleExit({editor:e,mark:n}){const{tr:r}=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&&r.removeStoredMark(u),r.insertText(" ",a.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function T6(t){return typeof t=="number"}var M6=class{constructor(t){this.find=t.find,this.handler=t.handler}},A6=(t,e,n)=>{if(M0(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.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 I6(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Pf({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(y,v)=>{var w,N,k,C,E;if((N=(w=y.type)==null?void 0:w.spec)!=null&&N.code||!(y.isText||y.isTextblock||y.isInline))return;const A=(E=(C=(k=y.content)==null?void 0:k.size)!=null?C:y.nodeSize)!=null?E:0,I=Math.max(r,v),D=Math.min(a,v+A);if(I>=D)return;const _=y.isText?y.text||"":y.textBetween(I-v,D-v,void 0,"");A6(_,i.find,o).forEach(L=>{if(L.index===void 0)return;const z=I+L.index+1,ee=z+L[0].length,U={from:n.tr.mapping.map(z),to:n.tr.mapping.map(ee)},he=i.handler({state:n,range:U,match:L,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(he)})}),m.every(y=>y!==null)}var Wu=null,R6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function P6(t){const{editor:e,rules:n}=t;let r=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:v})=>{const w=f.tr,N=Rf({state:f,transaction:w});if(!(!I6({editor:e,state:N,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:v,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(f=>new Ut({view(m){const g=v=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(v.target)?m.dom.parentElement:null,r&&(Wu=e)},y=()=>{Wu&&(Wu=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=r===m.dom.parentElement,c=g,!i){const y=Wu;y!=null&&y.isEditable&&setTimeout(()=>{const v=y.state.selection;v&&y.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(m,g)=>{var y;const v=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,a=!!(v!=null&&v.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const v=m[0],w=v.getMeta("uiEvent")==="paste"&&!a,N=v.getMeta("uiEvent")==="drop"&&!i,k=v.getMeta("applyPasteRules"),C=!!k;if(!w&&!N&&!C)return;if(C){let{text:I}=k;typeof I=="string"?I=I:I=R0(xe.from(I),y.schema);const{from:D}=k,_=D+I.length,P=R6(I);return u({rule:f,state:y,from:D,to:{b:_},pasteEvt:P})}const E=g.doc.content.findDiffStart(y.doc.content),A=g.doc.content.findDiffEnd(y.doc.content);if(!(!T6(E)||!A||E===A.b))return u({rule:f,state:y,from:E,to:A,pasteEvt:o})}}))}var zf=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=j2(t),this.schema=W8(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:Dc(e.name,this.schema)},r=We(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Qc([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Dc(r.name,this.schema)},i=[],o=We(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&We(r,"exitable",a)&&(c.ArrowRight=()=>$o.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,v])=>[y,()=>v({editor:t})]));c={...c,...g}}const u=qL(c);i.push(u);const h=We(r,"addInputRules",a);if(yN(r,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=C6({editor:t,rules:g}),v=Array.isArray(y)?y:[y];i.push(...v)}}const f=We(r,"addPasteRules",a);if(yN(r,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=P6({editor:t,rules:g});i.push(...y)}}const m=We(r,"addProseMirrorPlugins",a);if(m){const g=m();i.push(...g)}return i})}get attributes(){return w2(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Fl(this.extensions);return Object.fromEntries(e.filter(n=>!!We(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Nn(n.name,this.schema)},i=We(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,g)=>{const y=gd(u,r);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 Qc([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Dc(a.name,this.schema)},o=We(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Qc([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Dc(a.name,this.schema)},o=We(a,"transformPastedHTML",i);return o?(c,u)=>{const h=r(c,u);return o.call(i,h)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=Fl(this.extensions);return Object.fromEntries(e.filter(n=>!!We(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),a={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ia(n.name,this.schema)},i=We(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=gd(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{G6(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 r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Dc(e.name,this.schema)};e.type==="mark"&&((n=jt(We(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=We(e,"onBeforeCreate",r),i=We(e,"onCreate",r),o=We(e,"onUpdate",r),c=We(e,"onSelectionUpdate",r),u=We(e,"onTransaction",r),h=We(e,"onFocus",r),f=We(e,"onBlur",r),m=We(e,"onDestroy",r);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)})}};zf.resolve=j2;zf.sort=Qc;zf.flatten=I0;var O6={};T0(O6,{ClipboardTextSerializer:()=>O2,Commands:()=>D2,Delete:()=>L2,Drop:()=>_2,Editable:()=>z2,FocusEvents:()=>F2,Keymap:()=>B2,Paste:()=>V2,Tabindex:()=>H2,TextDirection:()=>W2,focusEventsPluginKey:()=>$2});var dn=class P2 extends O0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new P2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},O2=dn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ut({key:new Yt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,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=S2(n);return k2(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),D2=dn.create({name:"commands",addCommands(){return{...h2}}}),L2=dn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,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=b2(t.before,[t,...e]);E2(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,(v,w)=>{const N=w+v.nodeSize-2,k=y.oldRange.from<=w&&N<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:w,to:N,newFrom:f.mapping.map(w),newTo:f.mapping.map(N),deletedRange:y.oldRange,newRange:y.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,v)=>{var w,N;if(y instanceof bs){const k=g.slice(v).map(y.from,-1),C=g.slice(v).map(y.to),E=g.invert().map(k,-1),A=g.invert().map(C),I=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(_=>_.eq(y.mark)),D=(N=f.doc.nodeAt(C))==null?void 0:N.marks.some(_=>_.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:E,to:A},newRange:{from:k,to:C},partial:!!(D||I),editor:this.editor,transaction:t,combinedTransform:f})}})};(a=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||a?setTimeout(i,0):i()}}),_2=dn.create({name:"drop",addProseMirrorPlugins(){return[new Ut({key:new Yt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),z2=dn.create({name:"editable",addProseMirrorPlugins(){return[new Ut({key:new Yt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),$2=new Yt("focusEvents"),F2=dn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ut({key:$2,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),B2=dn.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,v=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,w=v.parent.type.spec.isolating,N=m.pos-m.parentOffset,k=w&&v.parent.childCount===1?N===m.pos:tt.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()]),r={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={...r},i={...r,"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 Ih()||x2()?i:a},addProseMirrorPlugins(){return[new Ut({key:new Yt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const r=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!r||a)return;const{empty:i,from:o,to:c}=e.selection,u=tt.atStart(e.doc).from,h=tt.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!Lf(n.doc))return;const g=n.tr,y=Rf({state:n,transaction:g}),{commands:v}=new Pf({editor:this.editor,state:y});if(v.clearNodes(),!!g.steps.length)return g}})]}}),V2=dn.create({name:"paste",addProseMirrorPlugins(){return[new Ut({key:new Yt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),H2=dn.create({name:"tabindex",addProseMirrorPlugins(){return[new Ut({key:new Yt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),W2=dn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Fl(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 Ut({key:new Yt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),D6=class Vc{constructor(e,n,r=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,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,r=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,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},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 Vc(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 Vc(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 Vc(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const a=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+r+(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 Vc(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 r=null,a=this.parent;for(;a&&!r;){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{r&&a.length>0||(o.node.type.name===e&&i.every(u=>n[u]===o.node.attrs[u])&&a.push(o),!(r&&a.length>0)&&(a=a.concat(o.querySelectorAll(e,n,r))))}),a}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},L6=`.ProseMirror { + position: relative; +} + +.ProseMirror { + word-wrap: break-word; + white-space: pre-wrap; + white-space: break-spaces; + -webkit-font-variant-ligatures: none; + font-variant-ligatures: none; + font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ +} + +.ProseMirror [contenteditable="false"] { + white-space: normal; +} + +.ProseMirror [contenteditable="false"] [contenteditable="true"] { + white-space: pre-wrap; +} + +.ProseMirror pre { + white-space: pre-wrap; +} + +img.ProseMirror-separator { + display: inline !important; + border: none !important; + margin: 0 !important; + width: 0 !important; + height: 0 !important; +} + +.ProseMirror-gapcursor { + display: none; + pointer-events: none; + position: absolute; + margin: 0; +} + +.ProseMirror-gapcursor:after { + content: ""; + display: block; + position: absolute; + top: -2px; + width: 20px; + border-top: 1px solid black; + animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; +} + +@keyframes ProseMirror-cursor-blink { + to { + visibility: hidden; + } +} + +.ProseMirror-hideselection *::selection { + background: transparent; +} + +.ProseMirror-hideselection *::-moz-selection { + background: transparent; +} + +.ProseMirror-hideselection * { + caret-color: transparent; +} + +.ProseMirror-focused .ProseMirror-gapcursor { + display: block; +}`;function _6(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;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 z6=class extends k6{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:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:t6,createMappablePosition:n6},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:r,slice:a,moved:i})=>this.options.onDrop(r,a,i)),this.on("paste",({event:r,slice:a})=>this.options.onPaste(r,a)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=m2(e,this.options.autofocus);this.editorState=Tl.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=_6(L6,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=N2(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}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 r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[z2,O2.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),D2,F2,B2,H2,_2,V2,L2,W2.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 zf(r,this)}createCommandManager(){this.commandManager=new Pf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=lx(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=lx(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),a=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new u2(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),r=!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)}),r&&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 C2(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return X8(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return R0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` + +`,textSerializers:n={}}=t||{};return K8(this.state.doc,{blockSeparator:e,textSerializers:{...S2(this.schema),...n}})}get isEmpty(){return Lf(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 D6(e,this)}get $doc(){return this.$pos(0)}};function Bl(t){return new _f({find:t.find,handler:({state:e,range:n,match:r})=>{const a=jt(t.getAttributes,void 0,r);if(a===!1||a===null)return null;const{tr:i}=e,o=r[r.length-1],c=r[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(P0(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(w=>w===t.type&&w!==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 U2(t){return new _f({find:t.find,handler:({state:e,range:n,match:r})=>{const a=jt(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let c=n.to;const u=t.type.create(a);if(r[1]){const h=r[0].lastIndexOf(r[1]);let f=o+h;f>c?f=c:c=f+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,o+r[0].length-1),i.replaceWith(f,c,u)}else if(r[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 dx(t){return new _f({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=jt(t.getAttributes,void 0,r)||{};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 Vl(t){return new _f({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=jt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&d0(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,v=g||m.$to.parentOffset&&m.$from.marks();if(v){const w=v.filter(N=>y.includes(N.type.name));o.ensureMarks(w)}}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&&Li(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var $6=t=>"touches"in t,F6=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,r,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),(r=t==null?void 0:t.options)!=null&&r.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"),r=e.includes("bottom"),a=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(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,$6(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:r,height:a}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,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 r=this.startWidth,a=this.startHeight;const i=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),c?a=this.startHeight+n:u&&(a=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(a=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,a,t):{width:r,height:a}}applyConstraints(t,e,n){var r,a,i,o;if(!n){let h=Math.max(this.minSize.width,t),f=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.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 r=n==="left"||n==="right",a=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:a?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function B6(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Je){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let a=r.depth;for(;a>=0;){const i=r.index(a);if(r.node(a).contentMatchAt(i).matchType(e))return!0;a-=1}return!1}function V6(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var H6={};T0(H6,{createAtomBlockMarkdownSpec:()=>W6,createBlockMarkdownSpec:()=>U6,createInlineMarkdownSpec:()=>K2,parseAttributes:()=>D0,parseIndentedBlocks:()=>ux,renderNestedMarkdownContent:()=>_0,serializeAttributes:()=>L0});function D0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),a=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(a){const h=a.map(f=>f.trim().slice(1));e.class=h.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.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=r.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 L0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function W6(t){const{nodeName:e,name:n,parseAttributes:r=D0,serializeAttributes:a=L0,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|$)`),v=f.match(y);if(!v)return;const w=v[1]||"",N=r(w);if(!o.find(C=>!(C in N)))return{type:e,raw:v[0],attributes:N}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=a(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function U6(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=D0,serializeAttributes:i=L0,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(r){const w=r(m);y=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const v={...o,...m.attributes};return g.createNode(e,v,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),v=(g=m.match(y))==null?void 0:g.index;return v!==void 0?v:-1},tokenize(m,g,y){var v;const w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),N=m.match(w);if(!N)return;const[k,C=""]=N,E=a(C);let A=1;const I=k.length;let D="";const _=/^:::([\w-]*)(\s.*)?/gm,P=m.slice(I);for(_.lastIndex=0;;){const L=_.exec(P);if(L===null)break;const z=L.index,ee=L[1];if(!((v=L[2])!=null&&v.endsWith(":::"))){if(ee)A+=1;else if(A-=1,A===0){const U=P.slice(0,z);D=U.trim();const he=m.slice(0,I+z+L[0].length);let me=[];if(D)if(c==="block")for(me=y.blockTokens(U),me.forEach(R=>{R.text&&(!R.tokens||R.tokens.length===0)&&(R.tokens=y.inlineTokens(R.text))});me.length>0;){const R=me[me.length-1];if(R.type==="paragraph"&&(!R.text||R.text.trim()===""))me.pop();else break}else me=y.inlineTokens(D);return{type:e,raw:he,attributes:E,content:D,tokens:me}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),v=i(y),w=v?` {${v}}`:"",N=g.renderChildren(m.content||[],` + +`);return`:::${h}${w} + +${N} + +:::`}}}function K6(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,a,i,o]=r;e[a]=i||o,r=n.exec(t)}return e}function q6(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function K2(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=K6,serializeAttributes:i=q6,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(v=>{const w=typeof v=="string"?v:v.name,N=typeof v=="string"?void 0:v.skipIfDefault;if(w in g){const k=g[w];if(N!==void 0&&k===N)return;y[w]=k}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const v={...o,...g.attributes};if(c)return y.createNode(e,v);const w=r?r(g):g.content||"";return w?y.createNode(e,v,[y.createTextNode(w)]):y.createNode(e,v,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),v=g.match(y),w=v==null?void 0:v.index;return w!==void 0?w:-1},tokenize(g,y,v){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),N=g.match(w);if(!N)return;let k="",C="";if(c){const[,A]=N;C=A}else{const[,A,I]=N;C=A,k=I||""}const E=a(C.trim());return{type:e,raw:N[0],content:k.trim(),attributes:E}}},renderMarkdown:g=>{let y="";r?y=r(g):g.content&&g.content.length>0&&(y=g.content.filter(k=>k.type==="text").map(k=>k.text).join(""));const v=f(g.attrs||{}),w=i(v),N=w?` ${w}`:"";return c?`[${h}${N}]`:`[${h}${N}]${y}[/${h}]`}}}function ux(t,e,n){var r,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 v=e.extractItemData(y),{indentLevel:w,mainContent:N}=v;h=`${h}${g} +`;const k=[N];for(f+=1;fz.trim()!=="");if(_===-1)break;if((((a=(r=c[f+1+_].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:a.length)||0)>w){k.push(I),h=`${h}${I} +`,f+=1;continue}else break}if((((o=(i=I.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>w)k.push(I),h=`${h}${I} +`,f+=1;else break}let C;const E=k.slice(1);if(E.length>0){const I=E.map(D=>D.slice(w+m)).join(` +`);I.trim()&&(e.customNestedParser?C=e.customNestedParser(I):C=n.blockTokens(I))}const A=e.createToken(v,C);u.push(A)}if(u.length!==0)return{items:u,raw:h}}function _0(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const a=typeof n=="function"?n(r):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 G6(t,e,n={}){const{state:r}=e,{doc:a,tr:i}=r,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 wn=class q2 extends O0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new q2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Ro(t){return new M6({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:a})=>{const i=jt(t.getAttributes,void 0,r,a);if(i===!1||i===null)return null;const{tr:o}=e,c=r[r.length-1],u=r[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),g=m+c.length;if(P0(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(N=>N===t.type&&N!==v.mark.type)).filter(v=>v.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:J6,getOwnPropertySymbols:Y6}=Object,{hasOwnProperty:Q6}=Object.prototype;function og(t,e){return function(r,a,i){return t(r,a,i)&&e(r,a,i)}}function Uu(t){return function(n,r,a){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,a);const{cache:i}=a,o=i.get(n),c=i.get(r);if(o&&c)return o===r&&c===n;i.set(n,r),i.set(r,n);const u=t(n,r,a);return i.delete(n),i.delete(r),u}}function X6(t){return t!=null?t[Symbol.toStringTag]:void 0}function NN(t){return J6(t).concat(Y6(t))}const Z6=Object.hasOwn||((t,e)=>Q6.call(t,e));function Fo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const e_="__v",t_="__o",n_="_owner",{getOwnPropertyDescriptor:wN,keys:jN}=Object;function r_(t,e){return t.byteLength===e.byteLength&&Rh(new Uint8Array(t),new Uint8Array(e))}function s_(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function a_(t,e){return t.byteLength===e.byteLength&&Rh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function i_(t,e){return Fo(t.getTime(),e.getTime())}function o_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function l_(t,e){return t===e}function kN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const a=new Array(r),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 c_=Fo;function d_(t,e,n){const r=jN(t);let a=r.length;if(jN(e).length!==a)return!1;for(;a-- >0;)if(!G2(t,e,n,r[a]))return!1;return!0}function Lc(t,e,n){const r=NN(t);let a=r.length;if(NN(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=r[a],!G2(t,e,n,i)||(o=wN(t,i),c=wN(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function u_(t,e){return Fo(t.valueOf(),e.valueOf())}function h_(t,e){return t.source===e.source&&t.flags===e.flags}function SN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const a=new Array(r),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 Rh(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 f_(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 G2(t,e,n,r){return(r===n_||r===t_||r===e_)&&(t.$$typeof||e.$$typeof)?!0:Z6(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const p_="[object ArrayBuffer]",m_="[object Arguments]",g_="[object Boolean]",x_="[object DataView]",y_="[object Date]",b_="[object Error]",v_="[object Map]",N_="[object Number]",w_="[object Object]",j_="[object RegExp]",k_="[object Set]",S_="[object String]",C_={"[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},E_="[object URL]",T_=Object.prototype.toString;function M_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:v}){return function(N,k,C){if(N===k)return!0;if(N==null||k==null)return!1;const E=typeof N;if(E!==typeof k)return!1;if(E!=="object")return E==="number"?c(N,k,C):E==="function"?i(N,k,C):!1;const A=N.constructor;if(A!==k.constructor)return!1;if(A===Object)return u(N,k,C);if(Array.isArray(N))return e(N,k,C);if(A===Date)return r(N,k,C);if(A===RegExp)return f(N,k,C);if(A===Map)return o(N,k,C);if(A===Set)return m(N,k,C);const I=T_.call(N);if(I===y_)return r(N,k,C);if(I===j_)return f(N,k,C);if(I===v_)return o(N,k,C);if(I===k_)return m(N,k,C);if(I===w_)return typeof N.then!="function"&&typeof k.then!="function"&&u(N,k,C);if(I===E_)return y(N,k,C);if(I===b_)return a(N,k,C);if(I===m_)return u(N,k,C);if(C_[I])return g(N,k,C);if(I===p_)return t(N,k,C);if(I===x_)return n(N,k,C);if(I===g_||I===N_||I===S_)return h(N,k,C);if(v){let D=v[I];if(!D){const _=X6(N);_&&(D=v[_])}if(D)return D(N,k,C)}return!1}}function A_({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:r_,areArraysEqual:n?Lc:s_,areDataViewsEqual:a_,areDatesEqual:i_,areErrorsEqual:o_,areFunctionsEqual:l_,areMapsEqual:n?og(kN,Lc):kN,areNumbersEqual:c_,areObjectsEqual:n?Lc:d_,arePrimitiveWrappersEqual:u_,areRegExpsEqual:h_,areSetsEqual:n?og(SN,Lc):SN,areTypedArraysEqual:n?og(Rh,Lc):Rh,areUrlsEqual:f_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const a=Uu(r.areArraysEqual),i=Uu(r.areMapsEqual),o=Uu(r.areObjectsEqual),c=Uu(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return r}function I_(t){return function(e,n,r,a,i,o,c){return t(e,n,c)}}function R_({circular:t,comparator:e,createState:n,equals:r,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:r,meta:f,strict:a})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:a})};const i={cache:void 0,equals:r,meta:void 0,strict:a};return function(c,u){return e(c,u,i)}}const P_=zi();zi({strict:!0});zi({circular:!0});zi({circular:!0,strict:!0});zi({createInternalComparator:()=>Fo});zi({strict:!0,createInternalComparator:()=>Fo});zi({circular:!0,createInternalComparator:()=>Fo});zi({circular:!0,createInternalComparator:()=>Fo,strict:!0});function zi(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:a=!1}=t,i=A_(t),o=M_(i),c=n?n(o):I_(o);return R_({circular:e,comparator:o,createState:r,equals:c,strict:a})}var lg={exports:{}},cg={};/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var CN;function O_(){if(CN)return cg;CN=1;var t=Nd(),e=_k();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:n,a=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return cg.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var v=i(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=c(function(){function k(D){if(!C){if(C=!0,E=D,D=g(D),y!==void 0&&w.hasValue){var _=w.value;if(y(_,D))return A=_}return A=D}if(_=A,r(E,D))return _;var P=g(D);return y!==void 0&&y(_,P)?(E=D,_):(E=D,A=P)}var C=!1,E,A,I=m===void 0?null:m;return[function(){return k(f())},I===null?void 0:function(){return k(I())}]},[f,m,g,y]);var N=a(h,v[0],v[1]);return o(function(){w.hasValue=!0,w.value=N},[N]),u(N),N},cg}var EN;function D_(){return EN||(EN=1,lg.exports=O_()),lg.exports}var L_=D_(),__=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},z_=({contentComponent:t})=>{const e=zk.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function $_(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Ow.createPortal(r.reactElement,r.element,n)},t.forEach(a=>a())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(a=>a())}}}var F_=class extends fr.Component{constructor(t){var e;super(t),this.editorContentRef=fr.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=$_(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:__(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(z_,{contentComponent:t.contentComponent})]})}},B_=b.forwardRef((t,e)=>{const n=fr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return fr.createElement(F_,{key:n,innerRef:e,...t})}),J2=fr.memo(B_),V_=typeof window<"u"?b.useLayoutEffect:b.useEffect,H_=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(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function W_(t){var e;const[n]=b.useState(()=>new H_(t.editor)),r=L_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:P_);return V_(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(r),r}var U_=!1,hx=typeof window>"u",K_=hx||!!(typeof window<"u"&&window.next),q_=class Y2{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?hx||K_?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var a,i;return(i=(a=this.options.current).onBeforeCreate)==null?void 0:i.call(a,...r)},onBlur:(...r)=>{var a,i;return(i=(a=this.options.current).onBlur)==null?void 0:i.call(a,...r)},onCreate:(...r)=>{var a,i;return(i=(a=this.options.current).onCreate)==null?void 0:i.call(a,...r)},onDestroy:(...r)=>{var a,i;return(i=(a=this.options.current).onDestroy)==null?void 0:i.call(a,...r)},onFocus:(...r)=>{var a,i;return(i=(a=this.options.current).onFocus)==null?void 0:i.call(a,...r)},onSelectionUpdate:(...r)=>{var a,i;return(i=(a=this.options.current).onSelectionUpdate)==null?void 0:i.call(a,...r)},onTransaction:(...r)=>{var a,i;return(i=(a=this.options.current).onTransaction)==null?void 0:i.call(a,...r)},onUpdate:(...r)=>{var a,i;return(i=(a=this.options.current).onUpdate)==null?void 0:i.call(a,...r)},onContentError:(...r)=>{var a,i;return(i=(a=this.options.current).onContentError)==null?void 0:i.call(a,...r)},onDrop:(...r)=>{var a,i;return(i=(a=this.options.current).onDrop)==null?void 0:i.call(a,...r)},onPaste:(...r)=>{var a,i;return(i=(a=this.options.current).onPaste)==null?void 0:i.call(a,...r)},onDelete:(...r)=>{var a,i;return(i=(a=this.options.current).onDelete)==null?void 0:i.call(a,...r)}};return new z6(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(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="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[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Y2.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((r,a)=>r===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 G_(t={},e=[]){const n=b.useRef(t);n.current=t;const[r]=b.useState(()=>new q_(n)),a=zk.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return b.useDebugValue(a),b.useEffect(r.onRender(e)),W_({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var Q2=b.createContext({editor:null});Q2.Consumer;var J_=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Y_=()=>b.useContext(J_);fr.forwardRef((t,e)=>{const{onDragStart:n}=Y_(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});fr.createContext({markViewContentRef:()=>{}});var z0=b.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});z0.displayName="TiptapContext";var Q_=()=>b.useContext(z0);function X2({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const a=b.useMemo(()=>({editor:r}),[r]),i=b.useMemo(()=>({editor:r}),[r]);return s.jsx(Q2.Provider,{value:i,children:s.jsx(z0.Provider,{value:a,children:n})})}X2.displayName="Tiptap";function Z2({...t}){const{editor:e}=Q_();return s.jsx(J2,{editor:e,...t})}Z2.displayName="Tiptap.Content";Object.assign(X2,{Content:Z2});var Ph=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},X_=/^\s*>\s$/,Z_=wn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ph("blockquote",{...kt(this.options.HTMLAttributes,t),children:Ph("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(a=>{const c=e.renderChildren([a]).split(` +`).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(c.join(` +`))}),r.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[Vl({find:X_,type:this.type})]}}),e7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,t7=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,n7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,r7=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,s7=$o.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 Ph("strong",{...kt(this.options.HTMLAttributes,t),children:Ph("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[Bl({find:e7,type:this.type}),Bl({find:n7,type:this.type})]},addPasteRules(){return[Ro({find:t7,type:this.type}),Ro({find:r7,type:this.type})]}}),a7=/(^|[^`])`([^`]+)`(?!`)$/,i7=/(^|[^`])`([^`]+)`(?!`)/g,o7=$o.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",kt(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[Bl({find:a7,type:this.type})]},addPasteRules(){return[Ro({find:i7,type:this.type})]}}),dg=4,l7=/^```([a-z]+)?[\s\n]$/,c7=/^~~~([a-z]+)?[\s\n]$/,d7=wn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:dg,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",kt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const a=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${a}`,e.renderChildren(t.content),"```"].join(` +`):r=`\`\`\`${a} + +\`\`\``,r},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:dg,{state:r}=t,{selection:a}=r,{$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=r.doc.textBetween(h,f,` +`,` +`).split(` +`).map(v=>c+v).join(` +`);return u.replaceWith(h,f,r.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:dg,{state:r}=t,{selection:a}=r,{$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=r.doc.textBetween(f,m,` +`,` +`).split(` +`);let v=0,w=0;const N=h-f;for(let D=0;D=N){v=D;break}w+=y[D].length+1}const C=((u=y[v].match(/^ */))==null?void 0:u[0])||"",E=Math.min(C.length,n);if(E===0)return!0;let A=f;for(let D=0;D{const{from:u,to:h}=a,g=r.doc.textBetween(u,h,` +`,` +`).split(` +`).map(y=>{var v;const w=((v=y.match(/^ */))==null?void 0:v[0])||"",N=Math.min(w.length,n);return y.slice(N)}).join(` +`);return c.replaceWith(u,h,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:a}=n;if(!a||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` + +`);return!i||!o?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=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:r.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(tt.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[dx({find:l7,type:this.type,getAttributes:t=>({language:t[1]})}),dx({find:c7,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ut({key:new Yt("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),a=r?JSON.parse(r):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(Qe.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),u7=wn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` + +`):""}),h7=wn.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",kt(this.options.HTMLAttributes,t)]},renderText(){return` +`},renderMarkdown:()=>` +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>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}=r.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()}}}),f7=wn.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]}`,kt(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 r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,a="#".repeat(r);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=>dx({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),p7=wn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",kt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!B6(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,a=t();return T2(n)?a.insertContentAt(r.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(Qe.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Je.create(o.doc,u.pos)):o.setSelection(Qe.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(Qe.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[U2({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),m7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,g7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,x7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,y7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,b7=$o.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",kt(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[Bl({find:m7,type:this.type}),Bl({find:x7,type:this.type})]},addPasteRules(){return[Ro({find:g7,type:this.type}),Ro({find:y7,type:this.type})]}});const v7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",N7="ελ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",fx="numeric",px="ascii",mx="alpha",Xc="asciinumeric",Hc="alphanumeric",gx="domain",eC="emoji",w7="scheme",j7="slashscheme",ug="whitespace";function k7(t,e){return t in e||(e[t]=[]),e[t]}function xo(t,e,n){e[fx]&&(e[Xc]=!0,e[Hc]=!0),e[px]&&(e[Xc]=!0,e[mx]=!0),e[Xc]&&(e[Hc]=!0),e[mx]&&(e[Hc]=!0),e[Hc]&&(e[gx]=!0),e[eC]&&(e[gx]=!0);for(const r in e){const a=k7(r,n);a.indexOf(t)<0&&a.push(t)}}function S7(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Tr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Tr.groups={};Tr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,a),an=(t,e,n,r,a)=>t.tr(e,n,r,a),TN=(t,e,n,r,a)=>t.ts(e,n,r,a),ke=(t,e,n,r,a)=>t.tt(e,n,r,a),xa="WORD",xx="UWORD",tC="ASCIINUMERICAL",nC="ALPHANUMERICAL",xd="LOCALHOST",yx="TLD",bx="UTLD",ih="SCHEME",jl="SLASH_SCHEME",$0="NUM",vx="WS",F0="NL",Zc="OPENBRACE",ed="CLOSEBRACE",Oh="OPENBRACKET",Dh="CLOSEBRACKET",Lh="OPENPAREN",_h="CLOSEPAREN",zh="OPENANGLEBRACKET",$h="CLOSEANGLEBRACKET",Fh="FULLWIDTHLEFTPAREN",Bh="FULLWIDTHRIGHTPAREN",Vh="LEFTCORNERBRACKET",Hh="RIGHTCORNERBRACKET",Wh="LEFTWHITECORNERBRACKET",Uh="RIGHTWHITECORNERBRACKET",Kh="FULLWIDTHLESSTHAN",qh="FULLWIDTHGREATERTHAN",Gh="AMPERSAND",Jh="APOSTROPHE",Yh="ASTERISK",di="AT",Qh="BACKSLASH",Xh="BACKTICK",Zh="CARET",fi="COLON",B0="COMMA",ef="DOLLAR",Fs="DOT",tf="EQUALS",V0="EXCLAMATION",Yr="HYPHEN",td="PERCENT",nf="PIPE",rf="PLUS",sf="POUND",nd="QUERY",H0="QUOTE",rC="FULLWIDTHMIDDLEDOT",W0="SEMI",Bs="SLASH",rd="TILDE",af="UNDERSCORE",sC="EMOJI",of="SYM";var aC=Object.freeze({__proto__:null,ALPHANUMERICAL:nC,AMPERSAND:Gh,APOSTROPHE:Jh,ASCIINUMERICAL:tC,ASTERISK:Yh,AT:di,BACKSLASH:Qh,BACKTICK:Xh,CARET:Zh,CLOSEANGLEBRACKET:$h,CLOSEBRACE:ed,CLOSEBRACKET:Dh,CLOSEPAREN:_h,COLON:fi,COMMA:B0,DOLLAR:ef,DOT:Fs,EMOJI:sC,EQUALS:tf,EXCLAMATION:V0,FULLWIDTHGREATERTHAN:qh,FULLWIDTHLEFTPAREN:Fh,FULLWIDTHLESSTHAN:Kh,FULLWIDTHMIDDLEDOT:rC,FULLWIDTHRIGHTPAREN:Bh,HYPHEN:Yr,LEFTCORNERBRACKET:Vh,LEFTWHITECORNERBRACKET:Wh,LOCALHOST:xd,NL:F0,NUM:$0,OPENANGLEBRACKET:zh,OPENBRACE:Zc,OPENBRACKET:Oh,OPENPAREN:Lh,PERCENT:td,PIPE:nf,PLUS:rf,POUND:sf,QUERY:nd,QUOTE:H0,RIGHTCORNERBRACKET:Hh,RIGHTWHITECORNERBRACKET:Uh,SCHEME:ih,SEMI:W0,SLASH:Bs,SLASH_SCHEME:jl,SYM:of,TILDE:rd,TLD:yx,UNDERSCORE:af,UTLD:bx,UWORD:xx,WORD:xa,WS:vx});const ma=/[a-z]/,_c=new RegExp("\\p{L}","u"),hg=new RegExp("\\p{Emoji}","u"),ga=/\d/,fg=/\s/,MN="\r",pg=` +`,C7="️",E7="‍",mg="";let Ku=null,qu=null;function T7(t=[]){const e={};Tr.groups=e;const n=new Tr;Ku==null&&(Ku=AN(v7)),qu==null&&(qu=AN(N7)),ke(n,"'",Jh),ke(n,"{",Zc),ke(n,"}",ed),ke(n,"[",Oh),ke(n,"]",Dh),ke(n,"(",Lh),ke(n,")",_h),ke(n,"<",zh),ke(n,">",$h),ke(n,"(",Fh),ke(n,")",Bh),ke(n,"「",Vh),ke(n,"」",Hh),ke(n,"『",Wh),ke(n,"』",Uh),ke(n,"<",Kh),ke(n,">",qh),ke(n,"&",Gh),ke(n,"*",Yh),ke(n,"@",di),ke(n,"`",Xh),ke(n,"^",Zh),ke(n,":",fi),ke(n,",",B0),ke(n,"$",ef),ke(n,".",Fs),ke(n,"=",tf),ke(n,"!",V0),ke(n,"-",Yr),ke(n,"%",td),ke(n,"|",nf),ke(n,"+",rf),ke(n,"#",sf),ke(n,"?",nd),ke(n,'"',H0),ke(n,"/",Bs),ke(n,";",W0),ke(n,"~",rd),ke(n,"_",af),ke(n,"\\",Qh),ke(n,"・",rC);const r=an(n,ga,$0,{[fx]:!0});an(r,ga,r);const a=an(r,ma,tC,{[Xc]:!0}),i=an(r,_c,nC,{[Hc]:!0}),o=an(n,ma,xa,{[px]:!0});an(o,ga,a),an(o,ma,o),an(a,ga,a),an(a,ma,a);const c=an(n,_c,xx,{[mx]:!0});an(c,ma),an(c,ga,i),an(c,_c,c),an(i,ga,i),an(i,ma),an(i,_c,i);const u=ke(n,pg,F0,{[ug]:!0}),h=ke(n,MN,vx,{[ug]:!0}),f=an(n,fg,vx,{[ug]:!0});ke(n,mg,f),ke(h,pg,u),ke(h,mg,f),an(h,fg,f),ke(f,MN),ke(f,pg),an(f,fg,f),ke(f,mg,f);const m=an(n,hg,sC,{[eC]:!0});ke(m,"#"),an(m,hg,m),ke(m,C7,m);const g=ke(m,E7);ke(g,"#"),an(g,hg,m);const y=[[ma,o],[ga,a]],v=[[ma,null],[_c,c],[ga,i]];for(let w=0;ww[0]>N[0]?1:-1);for(let w=0;w=0?C[gx]=!0:ma.test(N)?ga.test(N)?C[Xc]=!0:C[px]=!0:C[fx]=!0,TN(n,N,N,C)}return TN(n,"localhost",xd,{ascii:!0}),n.jd=new Tr(of),{start:n,tokens:Object.assign({groups:e},aC)}}function iC(t,e){const n=M7(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=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 M7(t){const e=[],n=t.length;let r=0;for(;r56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function ai(t,e,n,r,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(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const yd={defaultProtocol:"http",events:null,format:IN,formatHref:IN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function U0(t,e=null){let n=Object.assign({},yd);t&&(n=Object.assign(n,t instanceof U0?t.o:t));const r=n.ignoreTags,a=[];for(let i=0;in?r.substring(0,n)+"…":r},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=yd.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")),r=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=r,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 $f(t,e){class n extends oC{constructor(a,i){super(a,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const RN=$f("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),PN=$f("text"),A7=$f("nl"),Gu=$f("url",{isLink:!0,toHref(t=yd.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==xd&&t[1].t===fi}}),Jr=t=>new Tr(t);function I7({groups:t}){const e=t.domain.concat([Gh,Yh,di,Qh,Xh,Zh,ef,tf,Yr,$0,td,nf,rf,sf,Bs,of,rd,af]),n=[Jh,fi,B0,Fs,V0,td,nd,H0,W0,zh,$h,Zc,ed,Dh,Oh,Lh,_h,Fh,Bh,Vh,Hh,Wh,Uh,Kh,qh],r=[Gh,Jh,Yh,Qh,Xh,Zh,ef,tf,Yr,Zc,ed,td,nf,rf,sf,nd,Bs,of,rd,af],a=Jr(),i=ke(a,rd);ot(i,r,i),ot(i,t.domain,i);const o=Jr(),c=Jr(),u=Jr();ot(a,t.domain,o),ot(a,t.scheme,c),ot(a,t.slashscheme,u),ot(o,r,i),ot(o,t.domain,o);const h=ke(o,di);ke(i,di,h),ke(c,di,h),ke(u,di,h);const f=ke(i,Fs);ot(f,r,i),ot(f,t.domain,i);const m=Jr();ot(h,t.domain,m),ot(m,t.domain,m);const g=ke(m,Fs);ot(g,t.domain,m);const y=Jr(RN);ot(g,t.tld,y),ot(g,t.utld,y),ke(h,xd,y);const v=ke(m,Yr);ke(v,Yr,v),ot(v,t.domain,m),ot(y,t.domain,m),ke(y,Fs,g),ke(y,Yr,v);const w=ke(y,fi);ot(w,t.numeric,RN);const N=ke(o,Yr),k=ke(o,Fs);ke(N,Yr,N),ot(N,t.domain,o),ot(k,r,i),ot(k,t.domain,o);const C=Jr(Gu);ot(k,t.tld,C),ot(k,t.utld,C),ot(C,t.domain,o),ot(C,r,i),ke(C,Fs,k),ke(C,Yr,N),ke(C,di,h);const E=ke(C,fi),A=Jr(Gu);ot(E,t.numeric,A);const I=Jr(Gu),D=Jr();ot(I,e,I),ot(I,n,D),ot(D,e,I),ot(D,n,D),ke(C,Bs,I),ke(A,Bs,I);const _=ke(c,fi),P=ke(u,fi),L=ke(P,Bs),z=ke(L,Bs);ot(c,t.domain,o),ke(c,Fs,k),ke(c,Yr,N),ot(u,t.domain,o),ke(u,Fs,k),ke(u,Yr,N),ot(_,t.domain,I),ke(_,Bs,I),ke(_,nd,I),ot(z,t.domain,I),ot(z,e,I),ke(z,Bs,I);const ee=[[Zc,ed],[Oh,Dh],[Lh,_h],[zh,$h],[Fh,Bh],[Vh,Hh],[Wh,Uh],[Kh,qh]];for(let U=0;U=0&&g++,a++,f++;if(g<0)a-=f,a0&&(i.push(gg(PN,e,o)),o=[]),a-=g,f-=g;const y=m.t,v=n.slice(a-f,a);i.push(gg(y,e,v))}}return o.length>0&&i.push(gg(PN,e,o)),i}function gg(t,e,n){const r=n[0].s,a=n[n.length-1].e,i=e.slice(r,a);return new t(i,n)}const P7=typeof console<"u"&&console&&console.warn||(()=>{}),O7="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Gt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function D7(){return Tr.groups={},Gt.scanner=null,Gt.parser=null,Gt.tokenQueue=[],Gt.pluginQueue=[],Gt.customSchemes=[],Gt.initialized=!1,Gt}function ON(t,e=!1){if(Gt.initialized&&P7(`linkifyjs: already initialized - will not register custom scheme "${t}" ${O7}`),!/^[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`);Gt.customSchemes.push([t,e])}function L7(){Gt.scanner=T7(Gt.customSchemes);for(let t=0;t{const a=e.some(h=>h.docChanged)&&!n.doc.eq(r.doc),i=e.some(h=>h.getMeta("preventAutolink"));if(!a||i)return;const{tr:o}=r,c=b2(n.doc,[...e]);if(E2(c).forEach(({newRange:h})=>{const f=F8(r.doc,h,y=>y.isTextblock);let m,g;if(f.length>1)m=f[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const y=r.doc.textBetween(h.from,h.to," "," ");if(!z7.test(y))return;m=f[0],g=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(_7).filter(Boolean);if(y.length<=0)return!1;const v=y[y.length-1],w=m.pos+g.lastIndexOf(v);if(!v)return!1;const N=K0(v).map(k=>k.toObject(t.defaultProtocol));if(!F7(N))return!1;N.filter(k=>k.isLink).map(k=>({...k,from:w+k.start+1,to:w+k.end+1})).filter(k=>r.schema.marks.code?!r.doc.rangeHasMark(k.from,k.to,r.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{P0(k.from,k.to,r.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 V7(t){return new Ut({key:new Yt("handleClickLink"),props:{handleClick:(e,n,r)=>{var a,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const u=r.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=C2(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 H7(t){return new Ut({key:new Yt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:a}=t,{state:i}=e,{selection:o}=i,{empty:c}=o;if(c)return!1;let u="";r.content.forEach(f=>{u+=f.textContent});const h=lC(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 co(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const a=typeof r=="string"?r:r.scheme;a&&n.push(a)}),!t||t.replace($7,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var cC=$o.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"){ON(t);return}ON(t.scheme,t.optionalSlashes)})},onDestroy(){D7()},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)=>!!co(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=>!!co(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=>!!co(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",kt(this.options.HTMLAttributes,t),0]:["a",kt(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,r,a,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",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:r=>!!co(r,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:r=>!!co(r,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[Ro({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,a=lC(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!co(o,n),protocols:n,defaultProtocol:r}));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(B7({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:a=>!!co(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(V7({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(H7({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),W7=cC,U7=Object.defineProperty,K7=(t,e)=>{for(var n in e)U7(t,n,{get:e[n],enumerable:!0})},q7="listItem",DN="textStyle",LN=/^\s*([-+*])\s$/,dC=wn.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",kt(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(q7,this.editor.getAttributes(DN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Vl({find:LN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Vl({find:LN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(DN),editor:this.editor})),[t]}}),uC=wn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",kt(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)=>_0(t,e,r=>{var a,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(a=r.meta)==null?void 0:a.parentAttrs)==null?void 0:i.start)||1)+r.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)}}}),G7={};K7(G7,{findListItemPos:()=>Md,getNextListDepth:()=>G0,handleBackspace:()=>Nx,handleDelete:()=>wx,hasListBefore:()=>hC,hasListItemAfter:()=>J7,hasListItemBefore:()=>fC,listItemHasSubList:()=>pC,nextListIsDeeper:()=>mC,nextListIsHigher:()=>gC});var Md=(t,e)=>{const{$from:n}=e.selection,r=Nn(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===r?c=i:(i-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},G0=(t,e)=>{const n=Md(t,e);if(!n)return!1;const[,r]=Y8(e,t,n.$pos.pos+4);return r},hC=(t,e,n)=>{const{$anchor:r}=t.selection,a=Math.max(0,r.pos-2),i=t.doc.resolve(a).node();return!(!i||!n.includes(i.type.name))},fC=(t,e)=>{var n;const{$anchor:r}=e.selection,a=e.doc.resolve(r.pos-2);return!(a.index()===0||((n=a.nodeBefore)==null?void 0:n.type.name)!==t)},pC=(t,e,n)=>{if(!n)return!1;const r=Nn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===r&&(a=!0)}),a},Nx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Mi(t.state,e)&&hC(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(!Mi(t.state,e)||!e6(t.state))return!1;const r=Md(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=pC(e,t.state,i);return fC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},mC=(t,e)=>{const n=G0(t,e),r=Md(t,e);return!r||!n?!1:n>r.depth},gC=(t,e)=>{const n=G0(t,e),r=Md(t,e);return!r||!n?!1:n{if(!Mi(t.state,e)||!Z8(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:a}=n;return!n.empty&&r.sameParent(a)?!1:mC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():gC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},J7=(t,e)=>{var n;const{$anchor:r}=e.selection,a=e.doc.resolve(r.pos-r.parentOffset-2);return!(a.index()===a.parent.childCount-1||((n=a.nodeAfter)==null?void 0:n.type.name)!==t)},xC=dn.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&&wx(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&&wx(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Nx(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Nx(t,n,r)&&(e=!0)}),e}}}}),_N=/^(\s*)(\d+)\.\s+(.*)$/,Y7=/^\s/;function Q7(t){const e=[];let n=0,r=0;for(;ne;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(w=>w.indent)),v=yC(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:v,raw:g.map(w=>w.raw).join(` +`)})}a.push({type:"list_item",raw:o.raw,tokens:h}),i=m}else i+=1}return a}function X7(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(a=>{if(a.type==="paragraph"||a.type==="list"||a.type==="blockquote"||a.type==="code")r.push(...e.parseChildren([a]));else if(a.type==="text"&&a.tokens){const i=e.parseChildren([a]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([a]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var Z7="listItem",zN="textStyle",$N=/^(\d+)\.\s$/,bC=wn.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",kt(this.options.HTMLAttributes,n),0]:["ol",kt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?X7(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},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 r;const a=t.split(` +`),[i,o]=Q7(a);if(i.length===0)return;const c=yC(i,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.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(Z7,this.editor.getAttributes(zN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Vl({find:$N,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=Vl({find:$N,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(zN)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),ez=/^\s*(\[([( |x])?\])\s$/,tz=wn.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",kt(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 r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const a=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return _0(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:r})=>{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(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const v=n();if(typeof v!="number")return!1;const w=y.doc.nodeAt(v);return y.setNodeMarkup(v,void 0,{...w==null?void 0:w.attrs,checked:g}),!0}).run(),!r.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=r.extensionManager.attributes,y=gd(m,g),v=new Set(Object.keys(y)),w=this.options.HTMLAttributes;return f.forEach(N=>{v.has(N)||(N in w?a.setAttribute(N,w[N]):a.removeAttribute(N))}),Object.entries(y).forEach(([N,k])=>{k==null?N in w?a.setAttribute(N,w[N]):a.removeAttribute(N):a.setAttribute(N,k)}),f=v,!0}}}},addInputRules(){return[Vl({find:ez,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),nz=wn.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",kt(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 r=i=>{const o=ux(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:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},a=ux(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:r},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()}}});dn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(dC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(uC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(xC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(bC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(tz.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(nz.configure(this.options.taskList)),t}});var FN=" ",rz=" ",sz=wn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",kt(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 r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===FN||r[0].text===rz)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?FN:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),az=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,iz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,oz=$o.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",kt(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[Bl({find:az,type:this.type})]},addPasteRules(){return[Ro({find:iz,type:this.type})]}}),lz=wn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),cz=$o.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",kt(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 dz(t={}){return new Ut({view(e){return new uz(e,t)}})}class uz{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r: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,r,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 v=y.getBoundingClientRect(),w=m?v.bottom:v.top;m&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let N=this.width/2*c;r={left:v.left,right:v.right,top:w-N,bottom:w+N}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={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=(r.left-h)/o+"px",this.element.style.top=(r.top-f)/c+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.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}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),a=r&&r.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=uS(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 on extends tt{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return on.valid(r)?new on(r):tt.near(r)}content(){return Re.empty}eq(e){return e instanceof on&&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 on(e.resolve(n.pos))}getBookmark(){return new J0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!hz(e)||!fz(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let a=n.contentMatchAt(e.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&on.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(on.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Je.isSelectable(i)){e=e.doc.resolve(a+i.nodeSize*n),r=!1;continue e}break}i=o,a+=n;let c=e.doc.resolve(a);if(on.valid(c))return c}return null}}}on.prototype.visible=!1;on.findFrom=on.findGapCursorFrom;tt.jsonID("gapcursor",on);class J0{constructor(e){this.pos=e}map(e){return new J0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return on.valid(n)?new on(n):tt.near(n)}}function vC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function hz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let a=r.child(n-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||vC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function fz(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let a=r.child(n);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||vC(a.type))return!0;if(a.inlineContent)return!1}}return!0}function pz(){return new Ut({props:{decorations:yz,createSelectionBetween(t,e,n){return e.pos==n.pos&&on.valid(n)?new on(n):null},handleClick:gz,handleKeyDown:mz,handleDOMEvents:{beforeinput:xz}}})}const mz=E0({ArrowLeft:Ju("horiz",-1),ArrowRight:Ju("horiz",1),ArrowUp:Ju("vert",-1),ArrowDown:Ju("vert",1)});function Ju(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,a,i){let o=r.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof Qe){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=on.findGapCursorFrom(c,e,u);return h?(a&&a(r.tr.setSelection(new on(h))),!0):!1}}function gz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!on.valid(r))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&Je.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new on(r))),!0)}function xz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof on))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let a=xe.empty;for(let o=r.length-1;o>=0;o--)a=xe.from(r[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new Re(a,0,0));return i.setSelection(Qe.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function yz(t){if(!(t.selection instanceof on))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Pt.create(t.doc,[Tn.widget(t.selection.head,e,{key:"gapcursor"})])}var lf=200,_n=function(){};_n.prototype.append=function(e){return e.length?(e=_n.from(e),!this.length&&e||e.length=n?_n.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};_n.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};_n.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};_n.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var a=[];return this.forEach(function(i,o){return a.push(e(i,o))},n,r),a};_n.from=function(e){return e instanceof _n?e:e&&e.length?new NC(e):_n.empty};var NC=(function(t){function e(r){t.call(this),this.values=r}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<=lf)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=lf)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})(_n);_n.empty=new NC([]);var bz=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.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(r){return rc&&this.right.forEachInner(r,Math.max(a-c,0),Math.min(this.length,i)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,a,i,o){var c=this.left.length;if(a>c&&this.right.forEachInvertedInner(r,a-c,Math.max(i,c)-c,o+c)===!1||i=i?this.right.slice(r-i,a-i):this.left.slice(r,i).append(this.right.slice(0,a-i))},e.prototype.leafAppend=function(r){var a=this.right.leafAppend(r);if(a)return new e(this.left,a)},e.prototype.leafPrepend=function(r){var a=this.left.leafPrepend(r);if(a)return new e(a,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(_n);const vz=500;class ys{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let a,i;n&&(a=this.remapping(r,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(r,g+1),i=a.maps.length),i--,f.push(m);return}if(a){f.push(new ii(m.map));let y=m.step.map(a.slice(i)),v;y&&o.maybeStep(y).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],h.push(new ii(v,void 0,void 0,h.length+f.length))),i--,v&&a.appendMap(v,i)}else o.maybeStep(m.step);if(m.selection)return c=a?m.selection.map(a.slice(i)):m.selection,u=new ys(this.items.slice(0,r).append(f.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:c}}addTransform(e,n,r,a){let i=[],o=this.eventCount,c=this.items,u=!a&&c.length?c.get(c.length-1):null;for(let f=0;fwz&&(c=Nz(c,h),o-=h),new ys(c.append(i),o)}remapping(e,n){let r=new dd;return this.items.forEach((a,i)=>{let o=a.mirrorOffset!=null&&i-a.mirrorOffset>=e?r.maps.length-a.mirrorOffset:void 0;r.appendMap(a.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new ys(this.items.append(e.map(n=>new ii(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],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 v=i.maps[y];if(g.step){let w=e.steps[y].invert(e.docs[y]),N=g.selection&&g.selection.map(i.slice(u+1,y));N&&c++,r.push(new ii(v,w,N))}else r.push(new ii(v))},a);let h=[];for(let g=n;gvz&&(m=m.compress(this.items.length-r.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),r=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(r)),h=u&&u.getMap();if(r--,h&&n.appendMap(h,r),u){let f=o.selection&&o.selection.map(n.slice(r));f&&i++;let m=new ii(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&&r--},this.items.length,0),new ys(_n.from(a.reverse()),i)}}ys.empty=new ys(_n.empty,0);function Nz(t,e){let n;return t.forEach((r,a)=>{if(r.selection&&e--==0)return n=a,!1}),t.slice(n)}let ii=class wC{constructor(e,n,r,a){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=a}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new wC(n.getMap().invert(),n,this.selection)}}};class ui{constructor(e,n,r,a,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=a,this.prevComposition=i}}const wz=20;function jz(t,e,n,r){let a=n.getMeta(So),i;if(a)return a.historyState;n.getMeta(Cz)&&(t=new ui(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(So))return o.getMeta(So).redo?new ui(t.done.addTransform(n,void 0,r,oh(e)),t.undone,BN(n.mapping.maps),t.prevTime,t.prevComposition):new ui(t.done,t.undone.addTransform(n,void 0,r,oh(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)-r.newGroupDelay||!kz(n,t.prevRanges)),h=o?xg(t.prevRanges,n.mapping):BN(n.mapping.maps);return new ui(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,oh(e)),ys.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new ui(t.done.rebased(n,i),t.undone.rebased(n,i),xg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ui(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),xg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function kz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,a)=>{for(let i=0;i=e[i]&&(n=!0)}),n}function BN(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,a,i,o)=>e.push(i,o));return e}function xg(t,e){if(!t)return null;let n=[];for(let r=0;r{let a=So.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(r){let i=Sz(a,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const kC=jC(!1,!0),SC=jC(!0,!0);dn.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 r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}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 Ut({key:new Yt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const a=this.options.limit;if(a==null||a===0){t=!0;return}const i=this.storage.characters({node:r.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=r.tr.deleteRange(c,u);return t=!0,h}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const a=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||a>r&&i>r&&i<=a)return!0;if(a>r&&i>r&&i>a||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=i-r,h=c-u,f=c;return e.deleteRange(h,f),!(this.storage.characters({node:e.doc})>r)}})]}});var Tz=dn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[dz(this.options)]}});dn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ut({key:new Yt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:a}=e,i=[];if(!n||!r)return Pt.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(Tn.node(h,h+u.nodeSize,{class:this.options.className}))}),Pt.create(t,i)}}})]}});var Mz=dn.create({name:"gapCursor",addProseMirrorPlugins(){return[pz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=jt(We(t,"allowGapCursor",n)))!=null?e:null}}}),HN="placeholder";function Az(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Iz=dn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:HN,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Az(this.options.dataAttribute)}`:`data-${HN}`;return[new Ut({key:new Yt("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:a}=n,i=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=a>=u&&a<=u+c.nodeSize,f=!c.isLeaf&&Lf(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=Tn.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}),Pt.create(e,i)}}})]}});dn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ut({key:new Yt("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||T2(n.selection)||t.view.dragging?null:Pt.create(n.doc,[Tn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function WN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Rz=dn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Yt(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,a])=>a).filter(a=>(this.options.notAfter||[]).concat(n).includes(a.name));return[new Ut({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!WN({node:o,types:r})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!WN({node:o,types:r})}}})]}}),Pz=dn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>kC(t,e),redo:()=>({state:t,dispatch:e})=>SC(t,e)}},addProseMirrorPlugins(){return[Ez(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()}}}),Oz=dn.create({name:"starterKit",addExtensions(){var t,e,n,r;const a=[];return this.options.bold!==!1&&a.push(s7.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(Z_.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(dC.configure(this.options.bulletList)),this.options.code!==!1&&a.push(o7.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(d7.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(u7.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(Tz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Mz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(h7.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(f7.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(Pz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(p7.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(b7.configure(this.options.italic)),this.options.listItem!==!1&&a.push(uC.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(xC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(cC.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(bC.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(sz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(oz.configure(this.options.strike)),this.options.text!==!1&&a.push(lz.configure(this.options.text)),this.options.underline!==!1&&a.push(cz.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push(Rz.configure((r=this.options)==null?void 0:r.trailingNode)),a}}),Dz=Oz,Lz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,_z=wn.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",kt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,a,i,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(a=(r=t.attrs)==null?void 0:r.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:r}=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 F6({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:r===!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[U2({find:Lz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),zz=_z;function $z(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=r&&!a,h=V6(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"),v=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!v)return null;const w=c.pos-v.length,N=Array.from(v.matchAll(y)).pop();if(!N||N.input===void 0||N.index===void 0)return null;const k=N.input.slice(Math.max(0,N.index-1),N.index),C=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!C)return null;const E=w+N.index;let A=E+N[0].length;return u&&f.test(v.slice(A-1,A+1))&&(N[0]+=" ",A+=1),E=c.pos?{range:{from:E,to:A},query:N[0].slice(n.length),text:N[0]}:null}var Fz=new Yt("suggestion");function Bz({pluginKey:t=Fz,editor:e,char:n="@",allowSpaces:r=!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:v=()=>!0,findSuggestionMatch:w=$z,shouldShow:N}){let k;const C=y==null?void 0:y(),E=()=>{const _=e.state.selection.$anchor.pos,P=e.view.coordsAtPos(_),{top:L,right:z,bottom:ee,left:U}=P;try{return new DOMRect(U,L,z-U,ee-L)}catch{return null}},A=(_,P)=>P?()=>{const L=t.getState(e.state),z=L==null?void 0:L.decorationId,ee=_.dom.querySelector(`[data-decoration-id="${z}"]`);return(ee==null?void 0:ee.getBoundingClientRect())||null}:E;function I(_,P){var L;try{const ee=t.getState(_.state),U=ee!=null&&ee.decorationId?_.dom.querySelector(`[data-decoration-id="${ee.decorationId}"]`):null,he={editor:e,range:(ee==null?void 0:ee.range)||{from:0,to:0},query:(ee==null?void 0:ee.query)||null,text:(ee==null?void 0:ee.text)||null,items:[],command:me=>m({editor:e,range:(ee==null?void 0:ee.range)||{from:0,to:0},props:me}),decorationNode:U,clientRect:A(_,U)};(L=C==null?void 0:C.onExit)==null||L.call(C,he)}catch{}const z=_.state.tr.setMeta(P,{exit:!0});_.dispatch(z)}const D=new Ut({key:t,view(){return{update:async(_,P)=>{var L,z,ee,U,he,me,R;const O=(L=this.key)==null?void 0:L.getState(P),X=(z=this.key)==null?void 0:z.getState(_.state),$=O.active&&X.active&&O.range.from!==X.range.from,le=!O.active&&X.active,Y=O.active&&!X.active,F=!le&&!Y&&O.query!==X.query,W=le||$&&F,K=F||$,B=Y||$&&F;if(!W&&!K&&!B)return;const oe=B&&!W?O:X,G=_.dom.querySelector(`[data-decoration-id="${oe.decorationId}"]`);k={editor:e,range:oe.range,query:oe.query,text:oe.text,items:[],command:Q=>m({editor:e,range:oe.range,props:Q}),decorationNode:G,clientRect:A(_,G)},W&&((ee=C==null?void 0:C.onBeforeStart)==null||ee.call(C,k)),K&&((U=C==null?void 0:C.onBeforeUpdate)==null||U.call(C,k)),(K||W)&&(k.items=await g({editor:e,query:oe.query})),B&&((he=C==null?void 0:C.onExit)==null||he.call(C,k)),K&&((me=C==null?void 0:C.onUpdate)==null||me.call(C,k)),W&&((R=C==null?void 0:C.onStart)==null||R.call(C,k))},destroy:()=>{var _;k&&((_=C==null?void 0:C.onExit)==null||_.call(C,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(_,P,L,z){const{isEditable:ee}=e,{composing:U}=e.view,{selection:he}=_,{empty:me,from:R}=he,O={...P},X=_.getMeta(t);if(X&&X.exit)return O.active=!1,O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null,O;if(O.composing=U,ee&&(me||e.view.composing)){(RP.range.to)&&!U&&!P.composing&&(O.active=!1);const $=w({char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:he.$from}),le=`id_${Math.floor(Math.random()*4294967295)}`;$&&v({editor:e,state:z,range:$.range,isActive:P.active})&&(!N||N({editor:e,range:$.range,query:$.query,text:$.text,transaction:_}))?(O.active=!0,O.decorationId=P.decorationId?P.decorationId:le,O.range=$.range,O.query=$.query,O.text=$.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(_,P){var L,z,ee,U;const{active:he,range:me}=D.getState(_.state);if(!he)return!1;if(P.key==="Escape"||P.key==="Esc"){const O=D.getState(_.state),X=(L=k==null?void 0:k.decorationNode)!=null?L:null,$=X??(O!=null&&O.decorationId?_.dom.querySelector(`[data-decoration-id="${O.decorationId}"]`):null);if(((z=C==null?void 0:C.onKeyDown)==null?void 0:z.call(C,{view:_,event:P,range:O.range}))||!1)return!0;const Y={editor:e,range:O.range,query:O.query,text:O.text,items:[],command:F=>m({editor:e,range:O.range,props:F}),decorationNode:$,clientRect:$?()=>$.getBoundingClientRect()||null:null};return(ee=C==null?void 0:C.onExit)==null||ee.call(C,Y),I(_,t),!0}return((U=C==null?void 0:C.onKeyDown)==null?void 0:U.call(C,{view:_,event:P,range:me}))||!1},decorations(_){const{active:P,range:L,decorationId:z,query:ee}=D.getState(_);if(!P)return null;const U=!(ee!=null&&ee.length),he=[u];return U&&he.push(f),Pt.create(_.doc,[Tn.inline(L.from,L.to,{nodeName:c,class:he.join(" "),"data-decoration-id":z,"data-decoration-content":h})])}}});return D}function Vz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const a=new Yt;return{editor:t,char:r,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:r}},{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 CC(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Vz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function UN(t,e){const n=CC(t),r=n.find(a=>a.char===e);return r||(n.length?n[0]:null)}var Hz=wn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e==null?void 0:e.char)!=null?n:"@"}${(r=t.attrs.label)!=null?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,a;return["span",kt(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(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=UN(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",kt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=kt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof a=="string"?["span",kt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...K2({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,a,i,o]=r,c=i??o;e[a==="char"?"mentionSuggestionChar":a]=c,r=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:UN(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:r}=e,{empty:a,anchor:i}=r;if(!a)return!1;let o=new Sa,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 CC(this).map(Bz)}}),Wz=Hz,Uz=Iz;let jx,kx;if(typeof WeakMap<"u"){let t=new WeakMap;jx=e=>t.get(e),kx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;jx=r=>{for(let a=0;a(n==10&&(n=0),t[n++]=r,t[n++]=a)}var cn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:k-E});break}const A=a+E*e;for(let I=0;Ir&&(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 Gz(t,e,n){t.problems||(t.problems=[]);const r={};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 Yz(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 Ss(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 Ff(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=Po(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 r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Sx(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Xz(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Y0(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function EC(t,e,n){const r=t.node(-1),a=cn.get(r),i=t.start(-1),o=a.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Oo(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(a=>a>0)||(r.colwidth=null)),r}function TC(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let a=0;af!=n.pos-i);u.unshift(n.pos-i);const h=u.map(f=>{const m=r.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=i+f+1;return new gS(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 r=e.resolve(n.map(this.$anchorCell.pos)),a=e.resolve(n.map(this.$headCell.pos));if(Sx(r)&&Sx(a)&&Y0(r,a)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ya.rowSelection(r,a):i&&this.isColSelection()?ya.colSelection(r,a):new ya(r,a)}return Qe.between(r,a)}content(){const e=this.$anchorCell.node(-1),n=cn.get(e),r=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let u=a.top;u0||N>0){let k=v.attrs;if(w>0&&(k=Oo(k,0,w)),N>0&&(k=Oo(k,k.colspan-N,N)),y.lefta.bottom){const k={...v.attrs,rowspan:Math.min(y.bottom,a.bottom)-Math.max(y.top,a.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,a=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,a)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),a=cn.get(r),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 ya&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),a=cn.get(r),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(Tn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Pt.create(t.doc,e)}function n$({$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--,r--);return n==r&&/row|table/.test(t.node(a).type.spec.tableRole)}function r$({$from:t,$to:e}){let n,r;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"){r=i;break}}return n!==r&&e.parentOffset===0}function s$(t,e,n){const r=(e||t).selection,a=(e||t).doc;let i,o;if(r instanceof Je&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Wt.create(a,r.from);else if(o=="row"){const c=a.resolve(r.from+1);i=Wt.rowSelection(c,c)}else if(!n){const c=cn.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];i=Wt.create(a,u+1,h)}}else r instanceof Qe&&n$(r)?i=Qe.create(a,r.from):r instanceof Qe&&r$(r)&&(i=Qe.create(a,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const a$=new Yt("fix-tables");function AC(t,e,n,r){const a=t.childCount,i=e.childCount;e:for(let o=0,c=0;o{a.type.spec.tableRole=="table"&&(n=i$(t,a,i,n))};return e?e.doc!=t.doc&&AC(e.doc,t.doc,0,r):t.doc.descendants(r),n}function i$(t,e,n,r){const a=cn.get(e);if(!a.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const v=[];for(let N=0;N0?-1:0;Zz(e,r,a+i)&&(i=a==0||a==e.width?null:0);for(let o=0;o0&&a0&&e.map[c-1]==u||a0?-1:0;u$(e,r,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+r),null,{...g,rowspan:g.rowspan-1}),h+=g.colspan-1}else if(a0&&n[i]==n[i-1]||r.right0&&n[a]==n[a-t]||r.bottom0){const f=u+1+h.content.size,m=KN(h)?u+1:f;i.replaceWith(m+r.tableStart,f+r.tableStart,c)}i.setSelection(new Wt(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function GN(t,e){const n=ar(t.schema);return x$(({node:r})=>n[r.type.spec.tableRole])(t,e)}function x$(t){return(e,n)=>{const r=e.selection;let a,i;if(r instanceof Wt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;a=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(a=Yz(r.$from),!a)return!1;i=(o=Po(r.$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=Js(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}),r(i)}return!0}}function b$(t){return function(e,n){if(!Ss(e))return!1;if(n){const r=ar(e.schema),a=Js(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,v=o.doc.nodeAt(y);v&&o.setNodeMarkup(y,m,v.attrs)}),r(o)}return!0}}bd("row",{useDeprecatedLogic:!0});bd("column",{useDeprecatedLogic:!0});const v$=bd("cell",{useDeprecatedLogic:!0});function N$(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,a=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return a-1-o.nodeSize;a-=i.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Yu(t,e){const n=t.selection;if(!(n instanceof Wt))return!1;if(e){const r=t.tr,a=ar(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(a)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new Re(a,0,0))}),r.docChanged&&e(r)}return!0}function j$(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,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(xe.empty),n[a]r&&(g=g.type.createChecked(Oo(g.attrs,g.attrs.colspan,f+g.attrs.colspan-r),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(xe.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function C$(t,e,n,r,a,i,o){const c=t.doc.type.schema,u=ar(c);let h,f;if(a>e.width)for(let m=0,g=0;me.height){const m=[];for(let v=0,w=(e.height-1)*e.width;v=e.width?!1:n.nodeAt(e.map[w+v]).type==u.header_cell;m.push(N?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,xe.from(m)),y=[];for(let v=e.height;v{if(!a)return!1;const i=n.selection;if(i instanceof Wt)return lh(n,r,tt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=OC(a,t,e);if(o==null)return!1;if(t=="horiz")return lh(n,r,tt.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=EC(c,t,e);let h;return u?h=tt.near(u,1):e<0?h=tt.near(n.doc.resolve(c.before(-1)),-1):h=tt.near(n.doc.resolve(c.after(-1)),1),lh(n,r,h)}}}function Xu(t,e){return(n,r,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof Wt)o=i;else{const u=OC(a,t,e);if(u==null)return!1;o=new Wt(n.doc.resolve(u))}const c=EC(o.$headCell,t,e);return c?lh(n,r,new Wt(o.$anchorCell,c)):!1}}function T$(t,e){const n=t.state.doc,r=Po(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Wt(r))),!0):!1}function M$(t,e,n){if(!Ss(t.state))return!1;let r=j$(n);const a=t.state.selection;if(a instanceof Wt){r||(r={width:1,height:1,rows:[xe.from(Cx(ar(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=cn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return r=S$(r,c.right-c.left,c.bottom-c.top),ZN(t.state,t.dispatch,o,c,r),!0}else if(r){const i=Ff(t.state),o=i.start(-1);return ZN(t.state,t.dispatch,o,cn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function A$(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=ew(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof Wt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(a=Po(t.state.selection.$anchor))!=null&&((n=bg(t,e))===null||n===void 0?void 0:n.pos)!=a.pos)i(a,e),e.preventDefault();else if(!r)return;function i(u,h){let f=bg(t,h);const m=pi.getState(t.state)==null;if(!f||!Y0(u,f))if(m)f=u;else return;const g=new Wt(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(pi,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),pi.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(pi,-1))}function c(u){const h=u,f=pi.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(ew(t,h.target)!=r&&(m=bg(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 OC(t,e,n){if(!(t.state.selection instanceof Qe))return null;const{$head:r}=t.state.selection;for(let a=r.depth-1;a>=0;a--){const i=r.node(a);if((n<0?r.index(a):r.indexAfter(a))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(a),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function ew(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function bg(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:a}=n;return r>=0&&Po(t.state.doc.resolve(r))||Po(t.state.doc.resolve(a))}var I$=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")),Ex(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,Ex(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ex(t,e,n,r,a,i){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;mnew r(m,n,g)),new P$(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=zr.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{O$(o,c,t,a)},mouseleave:o=>{D$(o)},mousedown:(o,c)=>{L$(o,c,e,n)}},decorations:o=>{const c=zr.getState(o);if(c&&c.activeHandle>-1)return B$(o,c.activeHandle)},nodeViews:{}}});return i}var P$=class ch{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(zr);if(r&&r.setHandle!=null)return new ch(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ch(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return Sx(e.doc.resolve(a))||(a=-1),new ch(a,n.dragging)}return n}};function O$(t,e,n,r){if(!t.editable)return;const a=zr.getState(t.state);if(a&&!a.dragging){const i=z$(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=tw(t,e,"left",n):u-e.clientX<=n&&(o=tw(t,e,"right",n))}if(o!=a.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=cn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}DC(t,o)}}}function D$(t){if(!t.editable)return;const e=zr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&DC(t,-1)}function L$(t,e,n,r){var a;if(!t.editable)return!1;const i=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,o=zr.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=_$(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(zr,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const g=zr.getState(t.state);g!=null&&g.dragging&&($$(t,g.activeHandle,nw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(zr,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=zr.getState(t.state);if(g&&g.dragging){const y=nw(g.dragging,m,n);rw(t,g.activeHandle,y,r)}}return rw(t,o.activeHandle,u,r),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function _$(t,e,{colspan:n,colwidth:r}){const a=r&&r[r.length-1];if(a)return a;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,c=n;if(r)for(let u=0;u{var e,n;const r=t.getAttribute("colwidth"),a=r?r.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",kt(this.options.HTMLAttributes,t),0]}}),_C=wn.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(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",kt(this.options.HTMLAttributes,t),0]}}),zC=wn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",kt(this.options.HTMLAttributes,t),0]}});function Tx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function sw(t,e,n,r,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 r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function K$(t,e,n,r,a){const i=U$(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!q$(e))return!1;let n=0;const r=v2(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.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},G$="";function J$(t){return(t||"").replace(/\s+/g," ").trim()}function Y$(t,e,n={}){var r;const a=(r=n.cellLineSeparator)!=null?r:G$;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(v=>{const w=[];v.content&&v.content.forEach(N=>{let k="";N.content&&Array.isArray(N.content)&&N.content.length>1?k=N.content.map(I=>e.renderChildren(I)).join(a):k=N.content?e.renderChildren(N.content):"";const C=J$(k),E=N.type==="tableHeader";w.push({text:C,isHeader:E})}),i.push(w)});const o=i.reduce((v,w)=>Math.max(v,w.length),0);if(o===0)return"";const c=new Array(o).fill(0);i.forEach(v=>{var w;for(let N=0;Nc[N]&&(c[N]=C),c[N]<3&&(c[N]=3)}});const u=(v,w)=>v+" ".repeat(Math.max(0,w-v.length)),h=i[0],f=h.some(v=>v.isHeader);let m=` +`;const g=new Array(o).fill(0).map((v,w)=>f&&h[w]&&h[w].text||"");return m+=`| ${g.map((v,w)=>u(v,c[w])).join(" | ")} | +`,m+=`| ${c.map(v=>"-".repeat(Math.max(3,v))).join(" | ")} | +`,(f?i.slice(1):i).forEach(v=>{m+=`| ${new Array(o).fill(0).map((w,N)=>u(v[N]&&v[N].text||"",c[N])).join(" | ")} | +`}),m}var Q$=Y$,$C=wn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:H$,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:r,tableMinWidth:a}=W$(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${a}`)}const c=["table",kt(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 r=[];t.header.forEach(a=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const a=[];r.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:r,dispatch:a,editor:i})=>{const o=K$(i.schema,t,e,n);if(a){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Qe.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>o$(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>l$(t,e),deleteColumn:()=>({state:t,dispatch:e})=>d$(t,e),addRowBefore:()=>({state:t,dispatch:e})=>h$(t,e),addRowAfter:()=>({state:t,dispatch:e})=>f$(t,e),deleteRow:()=>({state:t,dispatch:e})=>m$(t,e),deleteTable:()=>({state:t,dispatch:e})=>w$(t,e),mergeCells:()=>({state:t,dispatch:e})=>qN(t,e),splitCell:()=>({state:t,dispatch:e})=>GN(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>bd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>bd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>v$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>qN(t,e)?!0:GN(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>y$(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>YN(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>YN(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&IC(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Wt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}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:Zu,"Mod-Backspace":Zu,Delete:Zu,"Mod-Delete":Zu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[R$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],V$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:jt(We(t,"tableRole",e))}}});dn.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push($C.configure(this.options.table)),this.options.tableCell!==!1&&t.push(LC.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(_C.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(zC.configure(this.options.tableRow)),t}});function cf(t){return(t||"").trim().toLowerCase()}function X$(t){return[t.name,...t.aliases?t.aliases.split(","):[]].map(cf).filter(Boolean)}function Z$(t){return[t.label,...t.aliases?t.aliases.split(","):[]].map(cf).filter(Boolean)}function vg(t,e,n){if(!t||!e.length&&!n.length||typeof document>"u")return t;const r=new Map,a=new Map;for(const u of e)for(const h of X$(u))r.has(h)||r.set(h,u);for(const u of n)for(const h of Z$(u))a.has(h)||a.set(h,u);const i=document.createElement("div");i.innerHTML=t;const o=u=>{const h=u.textContent||"";if(!h||!h.includes("@")&&!h.includes("@")&&!h.includes("#"))return;const f=u.parentNode;if(!f)return;const m=document.createDocumentFragment(),g=/([@@][^\s@#@#]+|#[^\s@#@#]+)/g;let y=0,v;for(;(v=g.exec(h))!==null;){const[w]=v,N=v.index;if(N>y&&m.appendChild(document.createTextNode(h.slice(y,N))),w.startsWith("@")||w.startsWith("@")){const k=r.get(cf(w.slice(1)));if(k){const C=document.createElement("span");C.setAttribute("data-type","mention"),C.setAttribute("data-id",k.id),C.setAttribute("data-label",k.name),C.className="mention-tag",C.textContent=`@${k.name}`,m.appendChild(C)}else m.appendChild(document.createTextNode(w))}else{const k=a.get(cf(w.slice(1)));if(k){const C=document.createElement("span");C.setAttribute("data-type","linkTag"),C.setAttribute("data-url",k.url||""),C.setAttribute("data-tag-type",k.type||"url"),C.setAttribute("data-tag-id",k.id||""),C.setAttribute("data-page-path",k.pagePath||""),C.setAttribute("data-app-id",k.appId||""),k.type==="miniprogram"&&k.appId&&C.setAttribute("data-mp-key",k.appId),C.className="link-tag-node",C.textContent=`#${k.label}`,m.appendChild(C)}else m.appendChild(document.createTextNode(w))}y=N+w.length}y{if(u.nodeType===globalThis.Node.ELEMENT_NODE){const h=u;if(h.matches('[data-type="mention"], [data-type="linkTag"], a, code, pre, script, style'))return;Array.from(h.childNodes).forEach(c);return}u.nodeType===globalThis.Node.TEXT_NODE&&o(u)};return Array.from(i.childNodes).forEach(c),i.innerHTML}function eF(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 + +`),e=e.replace(/]*>(.*?)<\/h2>/gi,`## $1 + +`),e=e.replace(/]*>(.*?)<\/h3>/gi,`### $1 + +`),e=e.replace(/]*>(.*?)<\/strong>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/b>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/em>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/i>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/s>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/del>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/code>/gi,"`$1`"),e=e.replace(/]*>(.*?)<\/blockquote>/gi,`> $1 + +`),e=e.replace(/]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*>/gi,"![$2]($1)"),e=e.replace(/]*src="([^"]*)"[^>]*>/gi,"![]($1)"),e=e.replace(/]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi,"[$2]($1)"),e=e.replace(/]*>(.*?)<\/li>/gi,`- $1 +`),e=e.replace(/<\/?[uo]l[^>]*>/gi,` +`),e=e.replace(//gi,` +`),e=e.replace(/]*>(.*?)<\/p>/gi,`$1 + +`),e=e.replace(//gi,`--- + +`),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 iw(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(new RegExp("(?$1"),e=e.replace(new RegExp("(?$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(` +`),r=[];for(const a of n){const i=a.trim();i&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(i)?r.push(i):r.push(`

    ${i}

    `))}return r.join("")}const tF=wn.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",kt(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}`]}}),nF=(t,e)=>({items:({query:n})=>{const r=t.current||[],a=n.toLowerCase().trim(),i=r.filter(o=>o.name.toLowerCase().includes(a)||o.id.includes(a)?!0:o.aliases?o.aliases.split(",").some(c=>c.trim().toLowerCase().includes(a)):!1).slice(0,8);return a.length>=1&&!r.some(o=>o.name.toLowerCase()===a)&&i.push({id:"__new__",name:`+ 新增「${n.trim()}」`,_newName:n.trim()}),i},render:()=>{let n=null,r=0,a=[],i=null;const o=async u=>{const h=a[u];if(!h||!i)return;const f=h;if(f.id==="__new__"&&f._newName&&e.current)try{const m=await e.current(f._newName);m&&i({id:m.id,label:m.name})}catch{}else i({id:h.id,label:h.name})},c=()=>{n&&(n.innerHTML=a.map((u,h)=>`
    + @${u.name} + ${u.id==="__new__"?"":u.label||u.id} +
    `).join(""),n.querySelectorAll(".mention-item").forEach(u=>{u.addEventListener("click",()=>{const h=parseInt(u.getAttribute("data-index")||"0");o(h)})}))};return{onStart:u=>{if(n=document.createElement("div"),n.className="mention-popup",document.body.appendChild(n),a=u.items,i=u.command,r=0,c(),u.clientRect){const h=u.clientRect();h&&(n.style.top=`${h.bottom+4}px`,n.style.left=`${h.left}px`)}},onUpdate:u=>{if(a=u.items,i=u.command,r=0,c(),u.clientRect&&n){const h=u.clientRect();h&&(n.style.top=`${h.bottom+4}px`,n.style.left=`${h.left}px`)}},onKeyDown:u=>u.event.key==="ArrowUp"?(r=Math.max(0,r-1),c(),!0):u.event.key==="ArrowDown"?(r=Math.min(a.length-1,r+1),c(),!0):u.event.key==="Enter"?(o(r),!0):u.event.key==="Escape"?(n==null||n.remove(),n=null,!0):!1,onExit:()=>{n==null||n.remove(),n=null}}}}),Mx=b.forwardRef(({content:t,onChange:e,onImageUpload:n,onVideoUpload:r,persons:a=[],linkTags:i=[],onPersonCreate:o,placeholder:c="开始编辑内容...",className:u},h)=>{const f=b.useRef(null),m=b.useRef(null),[g,y]=b.useState(!1),[v,w]=b.useState(""),[N,k]=b.useState(!1),[C,E]=b.useState(!1),[A,I]=b.useState(0),D=b.useRef(vg(iw(t),a,i)),_=b.useRef(e);_.current=e;const P=b.useRef(a);P.current=a;const L=b.useRef(i);L.current=i;const z=b.useRef(o);z.current=o;const ee=b.useRef(),U=G_({extensions:[Dz,zz.configure({inline:!0,allowBase64:!0}),W7.configure({openOnClick:!1,HTMLAttributes:{class:"rich-link"}}),Wz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:{...nF(P,z),allowedPrefixes:null}}),tF,Uz.configure({placeholder:c}),$C.configure({resizable:!0}),zC,LC,_C],content:D.current,onUpdate:({editor:$})=>{ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{const le=$.getHTML(),Y=vg(le,P.current||[],L.current||[]);if(Y!==le){$.commands.setContent(Y,{emitUpdate:!1}),_.current(Y);return}_.current(le)},300)},editorProps:{attributes:{class:"rich-editor-content"}}});b.useImperativeHandle(h,()=>({getHTML:()=>(U==null?void 0:U.getHTML())||"",getMarkdown:()=>eF((U==null?void 0:U.getHTML())||"")})),b.useEffect(()=>{if(!U)return;const $=vg(iw(t),P.current||[],L.current||[]);$!==U.getHTML()&&U.commands.setContent($,{emitUpdate:!1})},[t,U,a,i]);const he=b.useCallback(async $=>{var Y;const le=(Y=$.target.files)==null?void 0:Y[0];if(!(!le||!U)){if(n){E(!0),I(10);const F=setInterval(()=>{I(W=>Math.min(W+15,90))},300);try{const W=await n(le);clearInterval(F),I(100),W&&U.chain().focus().setImage({src:W}).run()}finally{clearInterval(F),setTimeout(()=>{E(!1),I(0)},500)}}else{const F=new FileReader;F.onload=()=>{typeof F.result=="string"&&U.chain().focus().setImage({src:F.result}).run()},F.readAsDataURL(le)}$.target.value=""}},[U,n]),me=b.useCallback(async $=>{var Y;const le=(Y=$.target.files)==null?void 0:Y[0];if(!(!le||!U)){if(r){y(!0),I(5);const F=setInterval(()=>{I(W=>Math.min(W+8,90))},500);try{const W=await r(le);clearInterval(F),I(100),W&&U.chain().focus().insertContent(`

    `).run()}finally{clearInterval(F),setTimeout(()=>{y(!1),I(0)},500)}}$.target.value=""}},[U,r]),R=b.useCallback(()=>{U&&U.chain().focus().insertContent("@").run()},[U]),O=b.useCallback($=>{U&&U.chain().focus().insertContent({type:"linkTag",attrs:{label:$.label,url:$.url||"",tagType:$.type||"url",tagId:$.id||"",pagePath:$.pagePath||"",appId:$.appId||"",mpKey:$.type==="miniprogram"&&$.appId||""}}).run()},[U]),X=b.useCallback(()=>{!U||!v||(U.chain().focus().setLink({href:v}).run(),w(""),k(!1))},[U,v]);return U?s.jsxs("div",{className:`rich-editor-wrapper ${u||""}`,children:[s.jsxs("div",{className:"rich-editor-toolbar",children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>U.chain().focus().toggleBold().run(),className:U.isActive("bold")?"is-active":"",type:"button",children:s.jsx(BT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().toggleItalic().run(),className:U.isActive("italic")?"is-active":"",type:"button",children:s.jsx(VM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().toggleStrike().run(),className:U.isActive("strike")?"is-active":"",type:"button",children:s.jsx($A,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().toggleCode().run(),className:U.isActive("code")?"is-active":"",type:"button",children:s.jsx(lM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>U.chain().focus().toggleHeading({level:1}).run(),className:U.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(RM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().toggleHeading({level:2}).run(),className:U.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(OM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().toggleHeading({level:3}).run(),className:U.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(LM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>U.chain().focus().toggleBulletList().run(),className:U.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(QM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().toggleOrderedList().run(),className:U.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(JM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().toggleBlockquote().run(),className:U.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(kA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(lA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:he,className:"hidden"}),s.jsx("button",{onClick:()=>{var $;return($=f.current)==null?void 0:$.click()},type:"button",title:"插入图片",children:s.jsx(Qw,{className:"w-4 h-4"})}),s.jsx("input",{ref:m,type:"file",accept:"video/mp4,video/quicktime,video/webm,.mp4,.mov,.webm",onChange:me,className:"hidden"}),s.jsx("button",{onClick:()=>{var $;return($=m.current)==null?void 0:$.click()},disabled:g||!r,type:"button",title:"插入视频",className:g?"opacity-50":"",children:s.jsx(e5,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>k(!N),className:U.isActive("link")?"is-active":"",type:"button",title:"插入链接",children:s.jsx(Dg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:R,type:"button",title:"@ 指定人物",className:"mention-trigger-btn",children:s.jsx(zT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",children:s.jsx(BA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>U.chain().focus().undo().run(),disabled:!U.can().undo(),type:"button",children:s.jsx(GA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>U.chain().focus().redo().run(),disabled:!U.can().redo(),type:"button",children:s.jsx(CA,{className:"w-4 h-4"})})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-divider"}),s.jsx("div",{className:"toolbar-group",children:s.jsxs("select",{className:"link-tag-select",onChange:$=>{const le=i.find(Y=>Y.id===$.target.value);le&&O(le),$.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map($=>s.jsx("option",{value:$.id,children:$.label},$.id))]})})]})]}),N&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:v,onChange:$=>w($.target.value),onKeyDown:$=>$.key==="Enter"&&X(),className:"link-input"}),s.jsx("button",{onClick:X,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{U.chain().focus().unsetLink().run(),k(!1)},className:"link-remove",type:"button",children:"移除"})]}),(C||g)&&s.jsxs("div",{className:"upload-progress-bar",children:[s.jsx("div",{className:"upload-progress-track",children:s.jsx("div",{className:"upload-progress-fill",style:{width:`${A}%`}})}),s.jsxs("span",{className:"upload-progress-text",children:[g?"视频":"图片","上传中 ",A,"%"]})]}),s.jsx(J2,{editor:U})]}):null});Mx.displayName="RichEditor";const rF=["top","right","bottom","left"],Ai=Math.min,Lr=Math.max,df=Math.round,eh=Math.floor,Ws=t=>({x:t,y:t}),sF={left:"right",right:"left",bottom:"top",top:"bottom"},aF={start:"end",end:"start"};function Ax(t,e,n){return Lr(t,Ai(e,n))}function Ta(t,e){return typeof t=="function"?t(e):t}function Ma(t){return t.split("-")[0]}function Xl(t){return t.split("-")[1]}function Q0(t){return t==="x"?"y":"x"}function X0(t){return t==="y"?"height":"width"}const iF=new Set(["top","bottom"]);function Hs(t){return iF.has(Ma(t))?"y":"x"}function Z0(t){return Q0(Hs(t))}function oF(t,e,n){n===void 0&&(n=!1);const r=Xl(t),a=Z0(t),i=X0(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=uf(o)),[o,uf(o)]}function lF(t){const e=uf(t);return[Ix(t),e,Ix(e)]}function Ix(t){return t.replace(/start|end/g,e=>aF[e])}const ow=["left","right"],lw=["right","left"],cF=["top","bottom"],dF=["bottom","top"];function uF(t,e,n){switch(t){case"top":case"bottom":return n?e?lw:ow:e?ow:lw;case"left":case"right":return e?cF:dF;default:return[]}}function hF(t,e,n,r){const a=Xl(t);let i=uF(Ma(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(Ix)))),i}function uf(t){return t.replace(/left|right|bottom|top/g,e=>sF[e])}function fF(t){return{top:0,right:0,bottom:0,left:0,...t}}function FC(t){return typeof t!="number"?fF(t):{top:t,right:t,bottom:t,left:t}}function hf(t){const{x:e,y:n,width:r,height:a}=t;return{width:r,height:a,top:n,left:e,right:e+r,bottom:n+a,x:e,y:n}}function cw(t,e,n){let{reference:r,floating:a}=t;const i=Hs(e),o=Z0(e),c=X0(o),u=Ma(e),h=i==="y",f=r.x+r.width/2-a.width/2,m=r.y+r.height/2-a.height/2,g=r[c]/2-a[c]/2;let y;switch(u){case"top":y={x:f,y:r.y-a.height};break;case"bottom":y={x:f,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:m};break;case"left":y={x:r.x-a.width,y:m};break;default:y={x:r.x,y:r.y}}switch(Xl(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 pF(t,e){var n;e===void 0&&(e={});const{x:r,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}=Ta(e,t),v=FC(y),N=c[g?m==="floating"?"reference":"floating":m],k=hf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(N)))==null||n?N:N.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),C=m==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),A=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},I=hf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:C,offsetParent:E,strategy:u}):C);return{top:(k.top-I.top+v.top)/A.y,bottom:(I.bottom-k.bottom+v.bottom)/A.y,left:(k.left-I.left+v.left)/A.x,right:(I.right-k.right+v.right)/A.x}}const mF=async(t,e,n)=>{const{placement:r="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}=cw(h,r,u),g=r,y={},v=0;for(let N=0;N({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:a,rects:i,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=Ta(t,e)||{};if(h==null)return{};const m=FC(f),g={x:n,y:r},y=Z0(a),v=X0(y),w=await o.getDimensions(h),N=y==="y",k=N?"top":"left",C=N?"bottom":"right",E=N?"clientHeight":"clientWidth",A=i.reference[v]+i.reference[y]-g[y]-i.floating[v],I=g[y]-i.reference[y],D=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let _=D?D[E]:0;(!_||!await(o.isElement==null?void 0:o.isElement(D)))&&(_=c.floating[E]||i.floating[v]);const P=A/2-I/2,L=_/2-w[v]/2-1,z=Ai(m[k],L),ee=Ai(m[C],L),U=z,he=_-w[v]-ee,me=_/2-w[v]/2+P,R=Ax(U,me,he),O=!u.arrow&&Xl(a)!=null&&me!==R&&i.reference[v]/2-(meme<=0)){var ee,U;const me=(((ee=i.flip)==null?void 0:ee.index)||0)+1,R=_[me];if(R&&(!(m==="alignment"?C!==Hs(R):!1)||z.every($=>Hs($.placement)===C?$.overflows[0]>0:!0)))return{data:{index:me,overflows:z},reset:{placement:R}};let O=(U=z.filter(X=>X.overflows[0]<=0).sort((X,$)=>X.overflows[1]-$.overflows[1])[0])==null?void 0:U.placement;if(!O)switch(y){case"bestFit":{var he;const X=(he=z.filter($=>{if(D){const le=Hs($.placement);return le===C||le==="y"}return!0}).map($=>[$.placement,$.overflows.filter(le=>le>0).reduce((le,Y)=>le+Y,0)]).sort(($,le)=>$[1]-le[1])[0])==null?void 0:he[0];X&&(O=X);break}case"initialPlacement":O=c;break}if(a!==O)return{reset:{placement:O}}}return{}}}};function dw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function uw(t){return rF.some(e=>t[e]>=0)}const yF=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:a="referenceHidden",...i}=Ta(t,e);switch(a){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),c=dw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:uw(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),c=dw(o,n.floating);return{data:{escapedOffsets:c,escaped:uw(c)}}}default:return{}}}}},BC=new Set(["left","top"]);async function bF(t,e){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=Ma(n),c=Xl(n),u=Hs(n)==="y",h=BC.has(o)?-1:1,f=i&&u?-1:1,m=Ta(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:v}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof v=="number"&&(y=c==="end"?v*-1:v),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const vF=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:a,y:i,placement:o,middlewareData:c}=e,u=await bF(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:a+u.x,y:i+u.y,data:{...u,placement:o}}}}},NF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,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}=Ta(t,e),f={x:n,y:r},m=await i.detectOverflow(e,h),g=Hs(Ma(a)),y=Q0(g);let v=f[y],w=f[g];if(o){const k=y==="y"?"top":"left",C=y==="y"?"bottom":"right",E=v+m[k],A=v-m[C];v=Ax(E,v,A)}if(c){const k=g==="y"?"top":"left",C=g==="y"?"bottom":"right",E=w+m[k],A=w-m[C];w=Ax(E,w,A)}const N=u.fn({...e,[y]:v,[g]:w});return{...N,data:{x:N.x-n,y:N.y-r,enabled:{[y]:o,[g]:c}}}}}},wF=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:a,rects:i,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=Ta(t,e),f={x:n,y:r},m=Hs(a),g=Q0(m);let y=f[g],v=f[m];const w=Ta(c,e),N=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const E=g==="y"?"height":"width",A=i.reference[g]-i.floating[E]+N.mainAxis,I=i.reference[g]+i.reference[E]-N.mainAxis;yI&&(y=I)}if(h){var k,C;const E=g==="y"?"width":"height",A=BC.has(Ma(a)),I=i.reference[m]-i.floating[E]+(A&&((k=o.offset)==null?void 0:k[m])||0)+(A?0:N.crossAxis),D=i.reference[m]+i.reference[E]+(A?0:((C=o.offset)==null?void 0:C[m])||0)-(A?N.crossAxis:0);vD&&(v=D)}return{[g]:y,[m]:v}}}},jF=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:a,rects:i,platform:o,elements:c}=e,{apply:u=()=>{},...h}=Ta(t,e),f=await o.detectOverflow(e,h),m=Ma(a),g=Xl(a),y=Hs(a)==="y",{width:v,height:w}=i.floating;let N,k;m==="top"||m==="bottom"?(N=m,k=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,N=g==="end"?"top":"bottom");const C=w-f.top-f.bottom,E=v-f.left-f.right,A=Ai(w-f[N],C),I=Ai(v-f[k],E),D=!e.middlewareData.shift;let _=A,P=I;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(P=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(_=C),D&&!g){const z=Lr(f.left,0),ee=Lr(f.right,0),U=Lr(f.top,0),he=Lr(f.bottom,0);y?P=v-2*(z!==0||ee!==0?z+ee:Lr(f.left,f.right)):_=w-2*(U!==0||he!==0?U+he:Lr(f.top,f.bottom))}await u({...e,availableWidth:P,availableHeight:_});const L=await o.getDimensions(c.floating);return v!==L.width||w!==L.height?{reset:{rects:!0}}:{}}}};function Bf(){return typeof window<"u"}function Zl(t){return VC(t)?(t.nodeName||"").toLowerCase():"#document"}function Br(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ys(t){var e;return(e=(VC(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function VC(t){return Bf()?t instanceof Node||t instanceof Br(t).Node:!1}function ws(t){return Bf()?t instanceof Element||t instanceof Br(t).Element:!1}function Gs(t){return Bf()?t instanceof HTMLElement||t instanceof Br(t).HTMLElement:!1}function hw(t){return!Bf()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Br(t).ShadowRoot}const kF=new Set(["inline","contents"]);function Ad(t){const{overflow:e,overflowX:n,overflowY:r,display:a}=js(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!kF.has(a)}const SF=new Set(["table","td","th"]);function CF(t){return SF.has(Zl(t))}const EF=[":popover-open",":modal"];function Vf(t){return EF.some(e=>{try{return t.matches(e)}catch{return!1}})}const TF=["transform","translate","scale","rotate","perspective"],MF=["transform","translate","scale","rotate","perspective","filter"],AF=["paint","layout","strict","content"];function ey(t){const e=ty(),n=ws(t)?js(t):t;return TF.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||MF.some(r=>(n.willChange||"").includes(r))||AF.some(r=>(n.contain||"").includes(r))}function IF(t){let e=Ii(t);for(;Gs(e)&&!Hl(e);){if(ey(e))return e;if(Vf(e))return null;e=Ii(e)}return null}function ty(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const RF=new Set(["html","body","#document"]);function Hl(t){return RF.has(Zl(t))}function js(t){return Br(t).getComputedStyle(t)}function Hf(t){return ws(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ii(t){if(Zl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||hw(t)&&t.host||Ys(t);return hw(e)?e.host:e}function HC(t){const e=Ii(t);return Hl(e)?t.ownerDocument?t.ownerDocument.body:t.body:Gs(e)&&Ad(e)?e:HC(e)}function vd(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=HC(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=Br(a);if(i){const c=Rx(o);return e.concat(o,o.visualViewport||[],Ad(a)?a:[],c&&n?vd(c):[])}return e.concat(a,vd(a,[],n))}function Rx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function WC(t){const e=js(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const a=Gs(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,c=df(n)!==i||df(r)!==o;return c&&(n=i,r=o),{width:n,height:r,$:c}}function ny(t){return ws(t)?t:t.contextElement}function Pl(t){const e=ny(t);if(!Gs(e))return Ws(1);const n=e.getBoundingClientRect(),{width:r,height:a,$:i}=WC(e);let o=(i?df(n.width):n.width)/r,c=(i?df(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const PF=Ws(0);function UC(t){const e=Br(t);return!ty()||!e.visualViewport?PF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function OF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Br(t)?!1:e}function Do(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=ny(t);let o=Ws(1);e&&(r?ws(r)&&(o=Pl(r)):o=Pl(t));const c=OF(i,n,r)?UC(i):Ws(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=Br(i),y=r&&ws(r)?Br(r):r;let v=g,w=Rx(v);for(;w&&r&&y!==v;){const N=Pl(w),k=w.getBoundingClientRect(),C=js(w),E=k.left+(w.clientLeft+parseFloat(C.paddingLeft))*N.x,A=k.top+(w.clientTop+parseFloat(C.paddingTop))*N.y;u*=N.x,h*=N.y,f*=N.x,m*=N.y,u+=E,h+=A,v=Br(w),w=Rx(v)}}return hf({width:f,height:m,x:u,y:h})}function Wf(t,e){const n=Hf(t).scrollLeft;return e?e.left+n:Do(Ys(t)).left+n}function KC(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Wf(t,n),a=n.top+e.scrollTop;return{x:r,y:a}}function DF(t){let{elements:e,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=Ys(r),c=e?Vf(e.floating):!1;if(r===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Ws(1);const f=Ws(0),m=Gs(r);if((m||!m&&!i)&&((Zl(r)!=="body"||Ad(o))&&(u=Hf(r)),Gs(r))){const y=Do(r);h=Pl(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const g=o&&!m&&!i?KC(o,u):Ws(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 LF(t){return Array.from(t.getClientRects())}function _F(t){const e=Ys(t),n=Hf(t),r=t.ownerDocument.body,a=Lr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Lr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Wf(t);const c=-n.scrollTop;return js(r).direction==="rtl"&&(o+=Lr(e.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:c}}const fw=25;function zF(t,e){const n=Br(t),r=Ys(t),a=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,c=0,u=0;if(a){i=a.width,o=a.height;const f=ty();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=Wf(r);if(h<=0){const f=r.ownerDocument,m=f.body,g=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,v=Math.abs(r.clientWidth-m.clientWidth-y);v<=fw&&(i-=v)}else h<=fw&&(i+=h);return{width:i,height:o,x:c,y:u}}const $F=new Set(["absolute","fixed"]);function FF(t,e){const n=Do(t,!0,e==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=Gs(t)?Pl(t):Ws(1),o=t.clientWidth*i.x,c=t.clientHeight*i.y,u=a*i.x,h=r*i.y;return{width:o,height:c,x:u,y:h}}function pw(t,e,n){let r;if(e==="viewport")r=zF(t,n);else if(e==="document")r=_F(Ys(t));else if(ws(e))r=FF(e,n);else{const a=UC(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return hf(r)}function qC(t,e){const n=Ii(t);return n===e||!ws(n)||Hl(n)?!1:js(n).position==="fixed"||qC(n,e)}function BF(t,e){const n=e.get(t);if(n)return n;let r=vd(t,[],!1).filter(c=>ws(c)&&Zl(c)!=="body"),a=null;const i=js(t).position==="fixed";let o=i?Ii(t):t;for(;ws(o)&&!Hl(o);){const c=js(o),u=ey(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&$F.has(a.position)||Ad(o)&&!u&&qC(t,o))?r=r.filter(f=>f!==o):a=c,o=Ii(o)}return e.set(t,r),r}function VF(t){let{element:e,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?Vf(e)?[]:BF(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=pw(e,f,a);return h.top=Lr(m.top,h.top),h.right=Ai(m.right,h.right),h.bottom=Ai(m.bottom,h.bottom),h.left=Lr(m.left,h.left),h},pw(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function HF(t){const{width:e,height:n}=WC(t);return{width:e,height:n}}function WF(t,e,n){const r=Gs(e),a=Ys(e),i=n==="fixed",o=Do(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Ws(0);function h(){u.x=Wf(a)}if(r||!r&&!i)if((Zl(e)!=="body"||Ad(a))&&(c=Hf(e)),r){const y=Do(e,!0,i,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else a&&h();i&&!r&&a&&h();const f=a&&!r&&!i?KC(a,c):Ws(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 Ng(t){return js(t).position==="static"}function mw(t,e){if(!Gs(t)||js(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ys(t)===n&&(n=n.ownerDocument.body),n}function GC(t,e){const n=Br(t);if(Vf(t))return n;if(!Gs(t)){let a=Ii(t);for(;a&&!Hl(a);){if(ws(a)&&!Ng(a))return a;a=Ii(a)}return n}let r=mw(t,e);for(;r&&CF(r)&&Ng(r);)r=mw(r,e);return r&&Hl(r)&&Ng(r)&&!ey(r)?n:r||IF(t)||n}const UF=async function(t){const e=this.getOffsetParent||GC,n=this.getDimensions,r=await n(t.floating);return{reference:WF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function KF(t){return js(t).direction==="rtl"}const qF={convertOffsetParentRelativeRectToViewportRelativeRect:DF,getDocumentElement:Ys,getClippingRect:VF,getOffsetParent:GC,getElementRects:UF,getClientRects:LF,getDimensions:HF,getScale:Pl,isElement:ws,isRTL:KF};function JC(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function GF(t,e){let n=null,r;const a=Ys(t);function i(){var c;clearTimeout(r),(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 v=eh(m),w=eh(a.clientWidth-(f+g)),N=eh(a.clientHeight-(m+y)),k=eh(f),E={rootMargin:-v+"px "+-w+"px "+-N+"px "+-k+"px",threshold:Lr(0,Ai(1,u))||1};let A=!0;function I(D){const _=D[0].intersectionRatio;if(_!==u){if(!A)return o();_?o(!1,_):r=setTimeout(()=>{o(!1,1e-7)},1e3)}_===1&&!JC(h,t.getBoundingClientRect())&&o(),A=!1}try{n=new IntersectionObserver(I,{...E,root:a.ownerDocument})}catch{n=new IntersectionObserver(I,E)}n.observe(t)}return o(!0),i}function JF(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,h=ny(t),f=a||i?[...h?vd(h):[],...vd(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?GF(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 v,w=u?Do(t):null;u&&N();function N(){const k=Do(t);w&&!JC(w,k)&&n(),w=k,v=requestAnimationFrame(N)}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(v)}}const YF=vF,QF=NF,XF=xF,ZF=jF,eB=yF,gw=gF,tB=wF,nB=(t,e,n)=>{const r=new Map,a={platform:qF,...n},i={...a.platform,_c:r};return mF(t,e,{...a,platform:i})};var rB=typeof document<"u",sB=function(){},dh=rB?b.useLayoutEffect:sB;function ff(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,r,a;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!ff(t[r],e[r]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,a[r]))return!1;for(r=n;r--!==0;){const i=a[r];if(!(i==="_owner"&&t.$$typeof)&&!ff(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function YC(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function xw(t,e){const n=YC(t);return Math.round(e*n)/n}function wg(t){const e=b.useRef(t);return dh(()=>{e.current=t}),e}function aB(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],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(r);ff(g,r)||y(r);const[v,w]=b.useState(null),[N,k]=b.useState(null),C=b.useCallback($=>{$!==D.current&&(D.current=$,w($))},[]),E=b.useCallback($=>{$!==_.current&&(_.current=$,k($))},[]),A=i||v,I=o||N,D=b.useRef(null),_=b.useRef(null),P=b.useRef(f),L=u!=null,z=wg(u),ee=wg(a),U=wg(h),he=b.useCallback(()=>{if(!D.current||!_.current)return;const $={placement:e,strategy:n,middleware:g};ee.current&&($.platform=ee.current),nB(D.current,_.current,$).then(le=>{const Y={...le,isPositioned:U.current!==!1};me.current&&!ff(P.current,Y)&&(P.current=Y,wd.flushSync(()=>{m(Y)}))})},[g,e,n,ee,U]);dh(()=>{h===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,m($=>({...$,isPositioned:!1})))},[h]);const me=b.useRef(!1);dh(()=>(me.current=!0,()=>{me.current=!1}),[]),dh(()=>{if(A&&(D.current=A),I&&(_.current=I),A&&I){if(z.current)return z.current(A,I,he);he()}},[A,I,he,z,L]);const R=b.useMemo(()=>({reference:D,floating:_,setReference:C,setFloating:E}),[C,E]),O=b.useMemo(()=>({reference:A,floating:I}),[A,I]),X=b.useMemo(()=>{const $={position:n,left:0,top:0};if(!O.floating)return $;const le=xw(O.floating,f.x),Y=xw(O.floating,f.y);return c?{...$,transform:"translate("+le+"px, "+Y+"px)",...YC(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:le,top:Y}},[n,c,O.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:he,refs:R,elements:O,floatingStyles:X}),[f,he,R,O,X])}const iB=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:a}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?gw({element:r.current,padding:a}).fn(n):{}:r?gw({element:r,padding:a}).fn(n):{}}}},oB=(t,e)=>({...YF(t),options:[t,e]}),lB=(t,e)=>({...QF(t),options:[t,e]}),cB=(t,e)=>({...tB(t),options:[t,e]}),dB=(t,e)=>({...XF(t),options:[t,e]}),uB=(t,e)=>({...ZF(t),options:[t,e]}),hB=(t,e)=>({...eB(t),options:[t,e]}),fB=(t,e)=>({...iB(t),options:[t,e]});var pB="Arrow",QC=b.forwardRef((t,e)=>{const{children:n,width:r=10,height:a=5,...i}=t;return s.jsx(ut.svg,{...i,ref:e,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});QC.displayName=pB;var mB=QC,ry="Popper",[XC,ZC]=Di(ry),[gB,e4]=XC(ry),t4=t=>{const{__scopePopper:e,children:n}=t,[r,a]=b.useState(null);return s.jsx(gB,{scope:e,anchor:r,onAnchorChange:a,children:n})};t4.displayName=ry;var n4="PopperAnchor",r4=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=e4(n4,n),o=b.useRef(null),c=St(e,o),u=b.useRef(null);return b.useEffect(()=>{const h=u.current;u.current=(r==null?void 0:r.current)||o.current,h!==u.current&&i.onAnchorChange(u.current)}),r?null:s.jsx(ut.div,{...a,ref:c})});r4.displayName=n4;var sy="PopperContent",[xB,yB]=XC(sy),s4=b.forwardRef((t,e)=>{var Q,se,ye,Me,Be,He;const{__scopePopper:n,side:r="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:v,...w}=t,N=e4(sy,n),[k,C]=b.useState(null),E=St(e,gt=>C(gt)),[A,I]=b.useState(null),D=s0(A),_=(D==null?void 0:D.width)??0,P=(D==null?void 0:D.height)??0,L=r+(i!=="center"?"-"+i:""),z=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},ee=Array.isArray(h)?h:[h],U=ee.length>0,he={padding:z,boundary:ee.filter(vB),altBoundary:U},{refs:me,floatingStyles:R,placement:O,isPositioned:X,middlewareData:$}=aB({strategy:"fixed",placement:L,whileElementsMounted:(...gt)=>JF(...gt,{animationFrame:y==="always"}),elements:{reference:N.anchor},middleware:[oB({mainAxis:a+P,alignmentAxis:o}),u&&lB({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?cB():void 0,...he}),u&&dB({...he}),uB({...he,apply:({elements:gt,rects:Dt,availableWidth:jn,availableHeight:it})=>{const{width:Mt,height:re}=Dt.reference,Pe=gt.floating.style;Pe.setProperty("--radix-popper-available-width",`${jn}px`),Pe.setProperty("--radix-popper-available-height",`${it}px`),Pe.setProperty("--radix-popper-anchor-width",`${Mt}px`),Pe.setProperty("--radix-popper-anchor-height",`${re}px`)}}),A&&fB({element:A,padding:c}),NB({arrowWidth:_,arrowHeight:P}),g&&hB({strategy:"referenceHidden",...he})]}),[le,Y]=o4(O),F=Ei(v);rr(()=>{X&&(F==null||F())},[X,F]);const W=(Q=$.arrow)==null?void 0:Q.x,K=(se=$.arrow)==null?void 0:se.y,B=((ye=$.arrow)==null?void 0:ye.centerOffset)!==0,[oe,G]=b.useState();return rr(()=>{k&&G(window.getComputedStyle(k).zIndex)},[k]),s.jsx("div",{ref:me.setFloating,"data-radix-popper-content-wrapper":"",style:{...R,transform:X?R.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(Me=$.transformOrigin)==null?void 0:Me.x,(Be=$.transformOrigin)==null?void 0:Be.y].join(" "),...((He=$.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(xB,{scope:n,placedSide:le,onArrowChange:I,arrowX:W,arrowY:K,shouldHideArrow:B,children:s.jsx(ut.div,{"data-side":le,"data-align":Y,...w,ref:E,style:{...w.style,animation:X?void 0:"none"}})})})});s4.displayName=sy;var a4="PopperArrow",bB={top:"bottom",right:"left",bottom:"top",left:"right"},i4=b.forwardRef(function(e,n){const{__scopePopper:r,...a}=e,i=yB(a4,r),o=bB[i.placedSide];return s.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:s.jsx(mB,{...a,ref:n,style:{...a.style,display:"block"}})})});i4.displayName=a4;function vB(t){return t!==null}var NB=t=>({name:"transformOrigin",options:t,fn(e){var N,k,C;const{placement:n,rects:r,middlewareData:a}=e,o=((N=a.arrow)==null?void 0:N.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=o4(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 v="",w="";return h==="bottom"?(v=o?m:`${g}px`,w=`${-u}px`):h==="top"?(v=o?m:`${g}px`,w=`${r.floating.height+u}px`):h==="right"?(v=`${-u}px`,w=o?m:`${y}px`):h==="left"&&(v=`${r.floating.width+u}px`,w=o?m:`${y}px`),{data:{x:v,y:w}}}});function o4(t){const[e,n="center"]=t.split("-");return[e,n]}var wB=t4,jB=r4,kB=s4,SB=i4,l4=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"}),CB="VisuallyHidden",EB=b.forwardRef((t,e)=>s.jsx(ut.span,{...t,ref:e,style:{...l4,...t.style}}));EB.displayName=CB;var TB=[" ","Enter","ArrowUp","ArrowDown"],MB=[" ","Enter"],Lo="Select",[Uf,Kf,AB]=t0(Lo),[ec]=Di(Lo,[AB,ZC]),qf=ZC(),[IB,$i]=ec(Lo),[RB,PB]=ec(Lo),c4=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:a,onOpenChange:i,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:v}=t,w=qf(e),[N,k]=b.useState(null),[C,E]=b.useState(null),[A,I]=b.useState(!1),D=Nf(h),[_,P]=Co({prop:r,defaultProp:a??!1,onChange:i,caller:Lo}),[L,z]=Co({prop:o,defaultProp:c,onChange:u,caller:Lo}),ee=b.useRef(null),U=N?v||!!N.closest("form"):!0,[he,me]=b.useState(new Set),R=Array.from(he).map(O=>O.props.value).join(";");return s.jsx(wB,{...w,children:s.jsxs(IB,{required:y,scope:e,trigger:N,onTriggerChange:k,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:A,onValueNodeHasChildrenChange:I,contentId:wi(),value:L,onValueChange:z,open:_,onOpenChange:P,dir:D,triggerPointerDownPosRef:ee,disabled:g,children:[s.jsx(Uf.Provider,{scope:e,children:s.jsx(RB,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback(O=>{me(X=>new Set(X).add(O))},[]),onNativeOptionRemove:b.useCallback(O=>{me(X=>{const $=new Set(X);return $.delete(O),$})},[]),children:n})}),U?s.jsxs(I4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:L,onChange:O=>z(O.target.value),disabled:g,form:v,children:[L===void 0?s.jsx("option",{value:""}):null,Array.from(he)]},R):null]})})};c4.displayName=Lo;var d4="SelectTrigger",u4=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=qf(n),o=$i(d4,n),c=o.disabled||r,u=St(e,o.onTriggerChange),h=Kf(n),f=b.useRef("touch"),[m,g,y]=P4(w=>{const N=h().filter(E=>!E.disabled),k=N.find(E=>E.value===o.value),C=O4(N,w,k);C!==void 0&&o.onValueChange(C.value)}),v=w=>{c||(o.onOpenChange(!0),y()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return s.jsx(jB,{asChild:!0,...i,children:s.jsx(ut.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":R4(o.value)?"":void 0,...a,ref:u,onClick:at(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&v(w)}),onPointerDown:at(a.onPointerDown,w=>{f.current=w.pointerType;const N=w.target;N.hasPointerCapture(w.pointerId)&&N.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(v(w),w.preventDefault())}),onKeyDown:at(a.onKeyDown,w=>{const N=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&g(w.key),!(N&&w.key===" ")&&TB.includes(w.key)&&(v(),w.preventDefault())})})})});u4.displayName=d4;var h4="SelectValue",f4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=t,u=$i(h4,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=St(e,u.onValueNodeChange);return rr(()=>{h(f)},[h,f]),s.jsx(ut.span,{...c,ref:m,style:{pointerEvents:"none"},children:R4(u.value)?s.jsx(s.Fragment,{children:o}):i})});f4.displayName=h4;var OB="SelectIcon",p4=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...a}=t;return s.jsx(ut.span,{"aria-hidden":!0,...a,ref:e,children:r||"▼"})});p4.displayName=OB;var DB="SelectPortal",m4=t=>s.jsx(Yx,{asChild:!0,...t});m4.displayName=DB;var _o="SelectContent",g4=b.forwardRef((t,e)=>{const n=$i(_o,t.__scopeSelect),[r,a]=b.useState();if(rr(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?wd.createPortal(s.jsx(x4,{scope:t.__scopeSelect,children:s.jsx(Uf.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),i):null}return s.jsx(y4,{...t,ref:e})});g4.displayName=_o;var xs=10,[x4,Fi]=ec(_o),LB="SelectContentImpl",_B=od("SelectContent.RemoveScroll"),y4=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:w,avoidCollisions:N,...k}=t,C=$i(_o,n),[E,A]=b.useState(null),[I,D]=b.useState(null),_=St(e,Q=>A(Q)),[P,L]=b.useState(null),[z,ee]=b.useState(null),U=Kf(n),[he,me]=b.useState(!1),R=b.useRef(!1);b.useEffect(()=>{if(E)return Ij(E)},[E]),wj();const O=b.useCallback(Q=>{const[se,...ye]=U().map(He=>He.ref.current),[Me]=ye.slice(-1),Be=document.activeElement;for(const He of Q)if(He===Be||(He==null||He.scrollIntoView({block:"nearest"}),He===se&&I&&(I.scrollTop=0),He===Me&&I&&(I.scrollTop=I.scrollHeight),He==null||He.focus(),document.activeElement!==Be))return},[U,I]),X=b.useCallback(()=>O([P,E]),[O,P,E]);b.useEffect(()=>{he&&X()},[he,X]);const{onOpenChange:$,triggerPointerDownPosRef:le}=C;b.useEffect(()=>{if(E){let Q={x:0,y:0};const se=Me=>{var Be,He;Q={x:Math.abs(Math.round(Me.pageX)-(((Be=le.current)==null?void 0:Be.x)??0)),y:Math.abs(Math.round(Me.pageY)-(((He=le.current)==null?void 0:He.y)??0))}},ye=Me=>{Q.x<=10&&Q.y<=10?Me.preventDefault():E.contains(Me.target)||$(!1),document.removeEventListener("pointermove",se),le.current=null};return le.current!==null&&(document.addEventListener("pointermove",se),document.addEventListener("pointerup",ye,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",se),document.removeEventListener("pointerup",ye,{capture:!0})}}},[E,$,le]),b.useEffect(()=>{const Q=()=>$(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[$]);const[Y,F]=P4(Q=>{const se=U().filter(Be=>!Be.disabled),ye=se.find(Be=>Be.ref.current===document.activeElement),Me=O4(se,Q,ye);Me&&setTimeout(()=>Me.ref.current.focus())}),W=b.useCallback((Q,se,ye)=>{const Me=!R.current&&!ye;(C.value!==void 0&&C.value===se||Me)&&(L(Q),Me&&(R.current=!0))},[C.value]),K=b.useCallback(()=>E==null?void 0:E.focus(),[E]),B=b.useCallback((Q,se,ye)=>{const Me=!R.current&&!ye;(C.value!==void 0&&C.value===se||Me)&&ee(Q)},[C.value]),oe=r==="popper"?Px:b4,G=oe===Px?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:w,avoidCollisions:N}:{};return s.jsx(x4,{scope:n,content:E,viewport:I,onViewportChange:D,itemRefCallback:W,selectedItem:P,onItemLeave:K,itemTextRefCallback:B,focusSelectedItem:X,selectedItemText:z,position:r,isPositioned:he,searchRef:Y,children:s.jsx(Qx,{as:_B,allowPinchZoom:!0,children:s.jsx(Jx,{asChild:!0,trapped:C.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:at(a,Q=>{var se;(se=C.trigger)==null||se.focus({preventScroll:!0}),Q.preventDefault()}),children:s.jsx(Gx,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:s.jsx(oe,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:Q=>Q.preventDefault(),...k,...G,onPlaced:()=>me(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:at(k.onKeyDown,Q=>{const se=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!se&&Q.key.length===1&&F(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let Me=U().filter(Be=>!Be.disabled).map(Be=>Be.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(Me=Me.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const Be=Q.target,He=Me.indexOf(Be);Me=Me.slice(He+1)}setTimeout(()=>O(Me)),Q.preventDefault()}})})})})})})});y4.displayName=LB;var zB="SelectItemAlignedPosition",b4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=$i(_o,n),o=Fi(_o,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=St(e,_=>f(_)),g=Kf(n),y=b.useRef(!1),v=b.useRef(!0),{viewport:w,selectedItem:N,selectedItemText:k,focusSelectedItem:C}=o,E=b.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&N&&k){const _=i.trigger.getBoundingClientRect(),P=h.getBoundingClientRect(),L=i.valueNode.getBoundingClientRect(),z=k.getBoundingClientRect();if(i.dir!=="rtl"){const Be=z.left-P.left,He=L.left-Be,gt=_.left-He,Dt=_.width+gt,jn=Math.max(Dt,P.width),it=window.innerWidth-xs,Mt=yh(He,[xs,Math.max(xs,it-jn)]);c.style.minWidth=Dt+"px",c.style.left=Mt+"px"}else{const Be=P.right-z.right,He=window.innerWidth-L.right-Be,gt=window.innerWidth-_.right-He,Dt=_.width+gt,jn=Math.max(Dt,P.width),it=window.innerWidth-xs,Mt=yh(He,[xs,Math.max(xs,it-jn)]);c.style.minWidth=Dt+"px",c.style.right=Mt+"px"}const ee=g(),U=window.innerHeight-xs*2,he=w.scrollHeight,me=window.getComputedStyle(h),R=parseInt(me.borderTopWidth,10),O=parseInt(me.paddingTop,10),X=parseInt(me.borderBottomWidth,10),$=parseInt(me.paddingBottom,10),le=R+O+he+$+X,Y=Math.min(N.offsetHeight*5,le),F=window.getComputedStyle(w),W=parseInt(F.paddingTop,10),K=parseInt(F.paddingBottom,10),B=_.top+_.height/2-xs,oe=U-B,G=N.offsetHeight/2,Q=N.offsetTop+G,se=R+O+Q,ye=le-se;if(se<=B){const Be=ee.length>0&&N===ee[ee.length-1].ref.current;c.style.bottom="0px";const He=h.clientHeight-w.offsetTop-w.offsetHeight,gt=Math.max(oe,G+(Be?K:0)+He+X),Dt=se+gt;c.style.height=Dt+"px"}else{const Be=ee.length>0&&N===ee[0].ref.current;c.style.top="0px";const gt=Math.max(B,R+w.offsetTop+(Be?W:0)+G)+ye;c.style.height=gt+"px",w.scrollTop=se-B+w.offsetTop}c.style.margin=`${xs}px 0`,c.style.minHeight=Y+"px",c.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[g,i.trigger,i.valueNode,c,h,w,N,k,i.dir,r]);rr(()=>E(),[E]);const[A,I]=b.useState();rr(()=>{h&&I(window.getComputedStyle(h).zIndex)},[h]);const D=b.useCallback(_=>{_&&v.current===!0&&(E(),C==null||C(),v.current=!1)},[E,C]);return s.jsx(FB,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:D,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:A},children:s.jsx(ut.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});b4.displayName=zB;var $B="SelectPopperPosition",Px=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=xs,...i}=t,o=qf(n);return s.jsx(kB,{...o,...i,ref:e,align:r,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)"}})});Px.displayName=$B;var[FB,ay]=ec(_o,{}),Ox="SelectViewport",v4=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=Fi(Ox,n),o=ay(Ox,n),c=St(e,i.onViewportChange),u=b.useRef(0);return s.jsxs(s.Fragment,{children:[s.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:r}),s.jsx(Uf.Slot,{scope:n,children:s.jsx(ut.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:at(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 v=window.innerHeight-xs*2,w=parseFloat(m.style.minHeight),N=parseFloat(m.style.height),k=Math.max(w,N);if(k0?A:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});v4.displayName=Ox;var N4="SelectGroup",[BB,VB]=ec(N4),HB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=wi();return s.jsx(BB,{scope:n,id:a,children:s.jsx(ut.div,{role:"group","aria-labelledby":a,...r,ref:e})})});HB.displayName=N4;var w4="SelectLabel",WB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=VB(w4,n);return s.jsx(ut.div,{id:a.id,...r,ref:e})});WB.displayName=w4;var pf="SelectItem",[UB,j4]=ec(pf),k4=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,c=$i(pf,n),u=Fi(pf,n),h=c.value===r,[f,m]=b.useState(i??""),[g,y]=b.useState(!1),v=St(e,C=>{var E;return(E=u.itemRefCallback)==null?void 0:E.call(u,C,r,a)}),w=wi(),N=b.useRef("touch"),k=()=>{a||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")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 s.jsx(UB,{scope:n,value:r,disabled:a,textId:w,isSelected:h,onItemTextChange:b.useCallback(C=>{m(E=>E||((C==null?void 0:C.textContent)??"").trim())},[]),children:s.jsx(Uf.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:s.jsx(ut.div,{role:"option","aria-labelledby":w,"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:v,onFocus:at(o.onFocus,()=>y(!0)),onBlur:at(o.onBlur,()=>y(!1)),onClick:at(o.onClick,()=>{N.current!=="mouse"&&k()}),onPointerUp:at(o.onPointerUp,()=>{N.current==="mouse"&&k()}),onPointerDown:at(o.onPointerDown,C=>{N.current=C.pointerType}),onPointerMove:at(o.onPointerMove,C=>{var E;N.current=C.pointerType,a?(E=u.onItemLeave)==null||E.call(u):N.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(o.onPointerLeave,C=>{var E;C.currentTarget===document.activeElement&&((E=u.onItemLeave)==null||E.call(u))}),onKeyDown:at(o.onKeyDown,C=>{var A;((A=u.searchRef)==null?void 0:A.current)!==""&&C.key===" "||(MB.includes(C.key)&&k(),C.key===" "&&C.preventDefault())})})})})});k4.displayName=pf;var Wc="SelectItemText",S4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=$i(Wc,n),c=Fi(Wc,n),u=j4(Wc,n),h=PB(Wc,n),[f,m]=b.useState(null),g=St(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,v=b.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:w,onNativeOptionRemove:N}=h;return rr(()=>(w(v),()=>N(v)),[w,N,v]),s.jsxs(s.Fragment,{children:[s.jsx(ut.span,{id:u.textId,...i,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?wd.createPortal(i.children,o.valueNode):null]})});S4.displayName=Wc;var C4="SelectItemIndicator",E4=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return j4(C4,n).isSelected?s.jsx(ut.span,{"aria-hidden":!0,...r,ref:e}):null});E4.displayName=C4;var Dx="SelectScrollUpButton",T4=b.forwardRef((t,e)=>{const n=Fi(Dx,t.__scopeSelect),r=ay(Dx,t.__scopeSelect),[a,i]=b.useState(!1),o=St(e,r.onScrollButtonChange);return rr(()=>{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?s.jsx(A4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});T4.displayName=Dx;var Lx="SelectScrollDownButton",M4=b.forwardRef((t,e)=>{const n=Fi(Lx,t.__scopeSelect),r=ay(Lx,t.__scopeSelect),[a,i]=b.useState(!1),o=St(e,r.onScrollButtonChange);return rr(()=>{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?s.jsx(A4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});M4.displayName=Lx;var A4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=Fi("SelectScrollButton",n),o=b.useRef(null),c=Kf(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),rr(()=>{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]),s.jsx(ut.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:at(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:at(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:at(a.onPointerLeave,()=>{u()})})}),KB="SelectSeparator",qB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(ut.div,{"aria-hidden":!0,...r,ref:e})});qB.displayName=KB;var _x="SelectArrow",GB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=qf(n),i=$i(_x,n),o=Fi(_x,n);return i.open&&o.position==="popper"?s.jsx(SB,{...a,...r,ref:e}):null});GB.displayName=_x;var JB="SelectBubbleInput",I4=b.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const a=b.useRef(null),i=St(r,a),o=r0(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]),s.jsx(ut.select,{...n,style:{...l4,...n.style},ref:i,defaultValue:e})});I4.displayName=JB;function R4(t){return t===""||t===void 0}function P4(t){const e=Ei(t),n=b.useRef(""),r=b.useRef(0),a=b.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),i=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function O4(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=YB(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 YB(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var QB=c4,D4=u4,XB=f4,ZB=p4,eV=m4,L4=g4,tV=v4,_4=k4,nV=S4,rV=E4,sV=T4,aV=M4;const kl=QB,Sl=XB,ho=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(D4,{ref:r,className:Ct("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,s.jsx(ZB,{asChild:!0,children:s.jsx(id,{className:"h-4 w-4 opacity-50"})})]}));ho.displayName=D4.displayName;const fo=b.forwardRef(({className:t,children:e,position:n="popper",...r},a)=>s.jsx(eV,{children:s.jsxs(L4,{ref:a,className:Ct("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,...r,children:[s.jsx(sV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Kw,{className:"h-4 w-4"})}),s.jsx(tV,{className:"p-1",children:e}),s.jsx(aV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(id,{className:"h-4 w-4"})})]})}));fo.displayName=L4.displayName;const Dr=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(_4,{ref:r,className:Ct("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(rV,{children:s.jsx(xf,{className:"h-4 w-4"})})}),s.jsx(nV,{children:e})]}));Dr.displayName=_4.displayName;const iV=["一","二","三","四","五","六","七","八","九","十"];function jg(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:r,onReadSection:a,onDeleteSection:i,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:v,pinnedSectionIds:w=[]}){const[N,k]=b.useState(null),[C,E]=b.useState(null),A=(z,ee)=>(N==null?void 0:N.type)===z&&(N==null?void 0:N.id)===ee,I=(z,ee)=>(C==null?void 0:C.type)===z&&(C==null?void 0:C.id)===ee,D=b.useCallback(()=>{const z=[];for(const ee of t)for(const U of ee.chapters)for(const he of U.sections)z.push({id:he.id,partId:ee.id,partTitle:ee.title,chapterId:U.id,chapterTitle:U.title});return z},[t]),_=b.useCallback(async(z,ee,U,he)=>{var $;z.preventDefault(),z.stopPropagation();const me=z.dataTransfer.getData("text/plain"),R=jg(me);if(!R||R.type===ee&&R.id===U)return;const O=D(),X=new Map(O.map(le=>[le.id,le]));if(R.type==="part"&&ee==="part"){const le=t.map(B=>B.id),Y=le.indexOf(R.id),F=le.indexOf(U);if(Y===-1||F===-1)return;const W=[...le];W.splice(Y,1),W.splice(YG.id===B);if(oe)for(const G of oe.chapters)for(const Q of G.sections){const se=X.get(Q.id);se&&K.push(se)}}await r(K);return}if(R.type==="chapter"&&(ee==="chapter"||ee==="section"||ee==="part")){const le=t.find(se=>se.chapters.some(ye=>ye.id===R.id)),Y=le==null?void 0:le.chapters.find(se=>se.id===R.id);if(!le||!Y)return;let F,W,K=null;if(ee==="section"){const se=X.get(U);if(!se)return;F=se.partId,W=se.partTitle,K=U}else if(ee==="chapter"){const se=t.find(Be=>Be.chapters.some(He=>He.id===U)),ye=se==null?void 0:se.chapters.find(Be=>Be.id===U);if(!se||!ye)return;F=se.id,W=se.title;const Me=O.filter(Be=>Be.chapterId===U).pop();K=(Me==null?void 0:Me.id)??null}else{const se=t.find(Me=>Me.id===U);if(!se||!se.chapters[0])return;F=se.id,W=se.title;const ye=O.filter(Me=>Me.partId===se.id&&Me.chapterId===se.chapters[0].id);K=(($=ye[ye.length-1])==null?void 0:$.id)??null}const B=Y.sections.map(se=>se.id),oe=O.filter(se=>!B.includes(se.id));let G=oe.length;if(K){const se=oe.findIndex(ye=>ye.id===K);se>=0&&(G=se+1)}const Q=B.map(se=>({...X.get(se),partId:F,partTitle:W,chapterId:Y.id,chapterTitle:Y.title}));await r([...oe.slice(0,G),...Q,...oe.slice(G)]);return}if(R.type==="section"&&(ee==="section"||ee==="chapter"||ee==="part")){if(!he)return;const{partId:le,partTitle:Y,chapterId:F,chapterTitle:W}=he;let K;if(ee==="section")K=O.findIndex(ye=>ye.id===U);else if(ee==="chapter"){const ye=O.filter(Me=>Me.chapterId===U).pop();K=ye?O.findIndex(Me=>Me.id===ye.id)+1:O.length}else{const ye=t.find(He=>He.id===U);if(!(ye!=null&&ye.chapters[0]))return;const Me=O.filter(He=>He.partId===ye.id&&He.chapterId===ye.chapters[0].id),Be=Me[Me.length-1];K=Be?O.findIndex(He=>He.id===Be.id)+1:0}const B=O.findIndex(ye=>ye.id===R.id);if(B===-1)return;const oe=O.filter(ye=>ye.id!==R.id),G=B({onDragEnter:he=>{he.preventDefault(),he.stopPropagation(),he.dataTransfer.dropEffect="move",E({type:z,id:ee})},onDragOver:he=>{he.preventDefault(),he.stopPropagation(),he.dataTransfer.dropEffect="move",E({type:z,id:ee})},onDragLeave:()=>E(null),onDrop:he=>{E(null);const me=jg(he.dataTransfer.getData("text/plain"));if(me&&!(z==="section"&&me.type==="section"&&me.id===ee))if(z==="part")if(me.type==="part")_(he,"part",ee);else{const R=t.find(X=>X.id===ee);(R==null?void 0:R.chapters[0])&&U&&_(he,"part",ee,U)}else z==="chapter"&&U?(me.type==="section"||me.type==="chapter")&&_(he,"chapter",ee,U):z==="section"&&U&&_(he,"section",ee,U)}}),L=z=>iV[z]??String(z+1);return s.jsx("div",{className:"space-y-3",children:t.map((z,ee)=>{var Y,F,W,K;const U=z.title==="序言"||z.title.includes("序言"),he=z.title==="尾声"||z.title.includes("尾声"),me=z.title==="附录"||z.title.includes("附录"),R=I("part",z.id),O=e.includes(z.id),X=z.chapters.length,$=z.chapters.reduce((B,oe)=>B+oe.sections.length,0);if(U&&z.chapters.length===1&&z.chapters[0].sections.length===1){const B=z.chapters[0].sections[0],oe=I("section",B.id),G={partId:z.id,partTitle:z.title,chapterId:z.chapters[0].id,chapterTitle:z.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","section:"+B.id),Q.dataTransfer.effectAllowed="move",k({type:"section",id:B.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] ${oe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${A("section",B.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",B.id,G),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(ha,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Q=>Q.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(B.id),onChange:()=>y(B.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx($r,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[z.chapters[0].title," | ",B.title]}),w.includes(B.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(gi,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>Q.stopPropagation(),children:[B.price===0||B.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",B.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",B.clickCount??0," · 付款 ",B.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(B.hotScore??0).toFixed(1)," · 第",B.hotRank&&B.hotRank>0?B.hotRank:"-","名"]}),v&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(B),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(B),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(B),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]})]},z.id)}if(z.title==="2026每日派对干货"||z.title.includes("2026每日派对干货")){const B=I("part",z.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${B?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...P("part",z.id,{partId:z.id,partTitle:z.title,chapterId:((Y=z.chapters[0])==null?void 0:Y.id)??"",chapterTitle:((F=z.chapters[0])==null?void 0:F.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:oe=>{oe.stopPropagation(),oe.dataTransfer.setData("text/plain","part:"+z.id),oe.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 ${A("part",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,onClick:()=>n(z.id),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ha,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:z.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",$," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:oe=>oe.stopPropagation(),onClick:oe=>oe.stopPropagation(),children:[o&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(z),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(er,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[X,"章"]}),O?s.jsx(id,{className:"w-5 h-5 text-gray-500"}):s.jsx(Cl,{className:"w-5 h-5 text-gray-500"})]})]}),O&&z.chapters.length>0&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:z.chapters.map(oe=>s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:oe.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:G=>G.stopPropagation(),children:[m&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>m(z,oe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>c(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>u(z,oe),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:oe.sections.map(G=>{const Q=I("section",G.id);return s.jsxs("div",{draggable:!0,onDragStart:se=>{se.stopPropagation(),se.dataTransfer.setData("text/plain","section:"+G.id),se.dataTransfer.effectAllowed="move",k({type:"section",id:G.id})},onDragEnd:()=>{k(null),E(null)},onClick:()=>a(G),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${A("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",G.id,{partId:z.id,partTitle:z.title,chapterId:oe.id,chapterTitle:oe.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ha,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:se=>se.stopPropagation(),children:s.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]"})}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[G.id," ",G.title]}),w.includes(G.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(gi,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onClick:se=>se.stopPropagation(),children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),v&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]},G.id)})})]},oe.id))})]},z.id)}if(me)return s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),s.jsx("div",{className:"space-y-3",children:z.chapters.map((B,oe)=>B.sections.length>0?B.sections.map(G=>{const Q=I("section",G.id);return s.jsxs("div",{draggable:!0,onDragStart:se=>{se.stopPropagation(),se.dataTransfer.setData("text/plain","section:"+G.id),se.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 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${A("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",G.id,{partId:z.id,partTitle:z.title,chapterId:B.id,chapterTitle:B.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ha,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:se=>se.stopPropagation(),children:s.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]"})}),s.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",oe+1," | ",B.title," | ",G.title]}),w.includes(G.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(gi,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),v&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Cl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},G.id)}):s.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[s.jsxs("span",{className:"text-sm text-gray-500",children:["附录",oe+1," | ",B.title,"(空)"]}),s.jsx(Cl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},B.id))})]},z.id);if(he&&z.chapters.length===1&&z.chapters[0].sections.length===1){const B=z.chapters[0].sections[0],oe=I("section",B.id),G={partId:z.id,partTitle:z.title,chapterId:z.chapters[0].id,chapterTitle:z.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","section:"+B.id),Q.dataTransfer.effectAllowed="move",k({type:"section",id:B.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] ${oe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${A("section",B.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",B.id,G),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(ha,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Q=>Q.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(B.id),onChange:()=>y(B.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx($r,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[z.chapters[0].title," | ",B.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>Q.stopPropagation(),children:[B.price===0||B.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",B.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",B.clickCount??0," · 付款 ",B.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(B.hotScore??0).toFixed(1)," · 第",B.hotRank&&B.hotRank>0?B.hotRank:"-","名"]}),v&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(B),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(B),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(B),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]})]},z.id)}return he?s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),s.jsx("div",{className:"space-y-3",children:z.chapters.map(B=>B.sections.map(oe=>{const G=I("section",oe.id);return s.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","section:"+oe.id),Q.dataTransfer.effectAllowed="move",k({type:"section",id:oe.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"} ${A("section",oe.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",oe.id,{partId:z.id,partTitle:z.title,chapterId:B.id,chapterTitle:B.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ha,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Q=>Q.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(oe.id),onChange:()=>y(oe.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-300",children:[B.title," | ",oe.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",oe.clickCount??0," · 付款 ",oe.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(oe.hotScore??0).toFixed(1)," · 第",oe.hotRank&&oe.hotRank>0?oe.hotRank:"-","名"]}),v&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(oe),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(oe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(oe),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]})]},oe.id)}))})]},z.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${R?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...P("part",z.id,{partId:z.id,partTitle:z.title,chapterId:((W=z.chapters[0])==null?void 0:W.id)??"",chapterTitle:((K=z.chapters[0])==null?void 0:K.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:B=>{B.stopPropagation(),B.dataTransfer.setData("text/plain","part:"+z.id),B.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 ${A("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:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ha,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.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:L(ee)}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:z.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",$," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:B=>B.stopPropagation(),onClick:B=>B.stopPropagation(),children:[o&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(z),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(er,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[X,"章"]}),O?s.jsx(id,{className:"w-5 h-5 text-gray-500"}):s.jsx(Cl,{className:"w-5 h-5 text-gray-500"})]})]}),O&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:z.chapters.map(B=>{const oe=I("chapter",B.id);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsxs("div",{draggable:!0,onDragStart:G=>{G.stopPropagation(),G.dataTransfer.setData("text/plain","chapter:"+B.id),G.dataTransfer.effectAllowed="move",k({type:"chapter",id:B.id})},onDragEnd:()=>{k(null),E(null)},onDragEnter:G=>{G.preventDefault(),G.stopPropagation(),G.dataTransfer.dropEffect="move",E({type:"chapter",id:B.id})},onDragOver:G=>{G.preventDefault(),G.stopPropagation(),G.dataTransfer.dropEffect="move",E({type:"chapter",id:B.id})},onDragLeave:()=>E(null),onDrop:G=>{E(null);const Q=jg(G.dataTransfer.getData("text/plain"));if(!Q)return;const se={partId:z.id,partTitle:z.title,chapterId:B.id,chapterTitle:B.title};(Q.type==="section"||Q.type==="chapter")&&_(G,"chapter",B.id,se)},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 ${oe?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${A("chapter",B.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(ha,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:B.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:G=>G.stopPropagation(),children:[m&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>m(z,B),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>c(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>u(z,B),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:B.sections.map(G=>{const Q=I("section",G.id);return s.jsxs("div",{draggable:!0,onDragStart:se=>{se.stopPropagation(),se.dataTransfer.setData("text/plain","section:"+G.id),se.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 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${A("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...P("section",G.id,{partId:z.id,partTitle:z.title,chapterId:B.id,chapterTitle:B.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:se=>se.stopPropagation(),children:s.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]"})}),s.jsx(ha,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.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"}`}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[G.id," ",G.title]}),w.includes(G.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(gi,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),children:[G.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),G.price===0||G.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",G.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),v&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),s.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx($t,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(er,{className:"w-3.5 h-3.5"})})]})]})]},G.id)})})]},B.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(),r=n?`/api/admin/ckb/devices?${n}`:"/api/admin/ckb/devices";return De(r)}function cV(t){return De(`/api/db/person?personId=${encodeURIComponent(t)}`)}const z4=11,yw={personId:"",name:"",aliases:"",label:"",sceneId:z4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"09:00",endTime:"18:00",deviceGroups:""};function dV({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){const a=!!n,[i,o]=b.useState(yw),[c,u]=b.useState(!1),[h,f]=b.useState(!1),[m,g]=b.useState([]),[y,v]=b.useState(!1),[w,N]=b.useState(""),[k,C]=b.useState({});b.useEffect(()=>{t&&(N(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",aliases:n.aliases??"",label:n.label??"",sceneId:z4,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??""}:{...yw}),C({}),m.length===0&&E(""))},[t,n]);const E=async I=>{v(!0);try{const D=await lV({page:1,limit:50,keyword:I});D!=null&&D.success&&Array.isArray(D.devices)?g(D.devices):D!=null&&D.error&&de.error(D.error)}catch(D){de.error(D instanceof Error?D.message:"加载设备列表失败")}finally{v(!1)}},A=async()=>{var P;const I={};(!i.name||!String(i.name).trim())&&(I.name="请填写名称");const D=i.addFriendInterval;if((typeof D!="number"||D<1)&&(I.addFriendInterval="添加间隔至少为 1 分钟"),(((P=i.deviceGroups)==null?void 0:P.split(",").map(L=>L.trim()).filter(Boolean))??[]).length===0&&(I.deviceGroups="请至少选择 1 台设备"),C(I),Object.keys(I).length>0){de.error(I.name||I.addFriendInterval||I.deviceGroups||"请完善必填项");return}u(!0);try{await r(i),e(!1)}catch(L){de.error(L instanceof Error?L.message:"保存失败")}finally{u(!1)}};return s.jsx(Ft,{open:t,onOpenChange:e,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(Bt,{children:[s.jsx(Vt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Gj,{className:"text-gray-400 text-sm",children:a?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),s.jsxs("div",{className:"space-y-6 py-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(te,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(ie,{className:`bg-[#0a1628] text-white ${k.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:i.name,onChange:I=>{o(D=>({...D,name:I.target.value})),k.name&&C(D=>({...D,name:void 0}))}}),k.name&&s.jsx("p",{className:"text-xs text-red-400",children:k.name})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:i.personId,onChange:I=>o(D=>({...D,personId:I.target.value})),disabled:a})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:i.label,onChange:I=>o(D=>({...D,label:I.target.value}))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 卡卡, 若若",value:i.aliases,onChange:I=>o(D=>({...D,aliases:I.target.value}))})]})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"存客宝密钥(计划 apiKey)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"创建计划成功后自动回填,不可手动修改",value:i.ckbApiKey,readOnly:!0}),s.jsx("p",{className:"text-xs text-gray-500",children:"由存客宝计划详情接口返回的 apiKey,用于小程序 @人物 时推送到对应获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(te,{className:"text-gray-400 text-xs",children:["选择设备 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:`flex gap-2 rounded-md border ${k.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(ie,{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)}),s.jsx(ne,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),k.deviceGroups?s.jsx("p",{className:"text-xs text-red-400",children:k.deviceGroups}):s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(kl,{value:i.remarkType,onValueChange:I=>o(D=>({...D,remarkType:I})),children:[s.jsx(ho,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Sl,{placeholder:"选择备注类型"})}),s.jsxs(fo,{children:[s.jsx(Dr,{value:"phone",children:"手机号"}),s.jsx(Dr,{value:"nickname",children:"昵称"}),s.jsx(Dr,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"备注格式"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 手机号+SOUL链接人与事-{名称},留空用默认",value:i.remarkFormat,onChange:I=>o(D=>({...D,remarkFormat:I.target.value}))})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:i.greeting,onChange:I=>o(D=>({...D,greeting:I.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(ie,{type:"number",min:1,className:`bg-[#0a1628] text-white ${k.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:i.addFriendInterval,onChange:I=>{o(D=>({...D,addFriendInterval:Number(I.target.value)||1})),k.addFriendInterval&&C(D=>({...D,addFriendInterval:void 0}))}}),k.addFriendInterval&&s.jsx("p",{className:"text-xs text-red-400",children:k.addFriendInterval})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ie,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.startTime,onChange:I=>o(D=>({...D,startTime:I.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(ie,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:i.endTime,onChange:I=>o(D=>({...D,endTime:I.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(Jl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:i.tips,onChange:I=>o(D=>({...D,tips:I.target.value}))})]})]})]})]})]}),s.jsxs(ln,{className:"gap-3 pt-2",children:[s.jsx(ne,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(ne,{onClick:A,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":a?"保存":"添加"})]}),h&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),s.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ie,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:w,onChange:I=>N(I.target.value),onKeyDown:I=>{I.key==="Enter"&&E(w)}}),s.jsx(ne,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>E(w),disabled:y,children:"刷新"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:y?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):s.jsx("div",{className:"p-4 space-y-2",children:m.map(I=>{const D=String(I.id??""),_=i.deviceGroups?i.deviceGroups.split(",").map(z=>z.trim()).filter(Boolean):[],P=_.includes(D),L=()=>{let z;P?z=_.filter(ee=>ee!==D):z=[..._,D],o(ee=>({...ee,deviceGroups:z.join(",")})),z.length>0&&C(ee=>({...ee,deviceGroups:void 0}))};return s.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:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-[#38bdac]",checked:P,onChange:L}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-white truncate max-w-xs",children:I.memo||I.wechatId||`设备 ${D}`}),I.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),I.status==="offline"&&s.jsx("span",{className:"rounded-full bg-gray-600/20 text-gray-400 text-[11px] px-2 py-0.5",children:"离线"})]}),s.jsxs("div",{className:"text-[11px] text-gray-400 mt-0.5",children:[s.jsxs("span",{className:"mr-3",children:["ID: ",D]}),I.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",I.wechatId]}),typeof I.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",I.totalFriend]})]})]})]},D)})})}),s.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[s.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",i.deviceGroups?i.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ne,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),s.jsx(ne,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function bw(t,e,n){if(!t||!t.includes("@")&&!t.includes("@")&&!t.includes("#")||typeof document>"u")return t;const r=document.createElement("div");r.innerHTML=t;const a=h=>h.trim().toLowerCase(),i=new Map;for(const h of e){const f=[h.name,...h.aliases?h.aliases.split(","):[]].map(m=>a(m)).filter(Boolean);for(const m of f)i.has(m)||i.set(m,h)}const o=new Map;for(const h of n){const f=[h.label,...h.aliases?h.aliases.split(","):[]].map(m=>a(m)).filter(Boolean);for(const m of f)o.has(m)||o.set(m,h)}const c=h=>{const f=h.textContent||"";if(!f||!f.includes("@")&&!f.includes("@")&&!f.includes("#"))return;const m=h.parentNode;if(!m)return;const g=document.createDocumentFragment(),y=/([@@][^\s@#@#]+|#[^\s@#@#]+)/g;let v=0,w;for(;w=y.exec(f);){const[N]=w,k=w.index;if(k>v&&g.appendChild(document.createTextNode(f.slice(v,k))),N.startsWith("@")||N.startsWith("@")){const C=i.get(a(N.slice(1)));if(C){const E=document.createElement("span");E.setAttribute("data-type","mention"),E.setAttribute("data-id",C.id),E.setAttribute("data-label",C.name),E.className="mention-tag",E.textContent=`@${C.name}`,g.appendChild(E)}else g.appendChild(document.createTextNode(N))}else if(N.startsWith("#")){const C=o.get(a(N.slice(1)));if(C){const E=document.createElement("span");E.setAttribute("data-type","linkTag"),E.setAttribute("data-url",C.url||""),E.setAttribute("data-tag-type",C.type||"url"),E.setAttribute("data-tag-id",C.id||""),E.setAttribute("data-page-path",C.pagePath||""),E.setAttribute("data-app-id",C.appId||""),C.type==="miniprogram"&&C.appId&&E.setAttribute("data-mp-key",C.appId),E.className="link-tag-node",E.textContent=`#${C.label}`,g.appendChild(E)}else g.appendChild(document.createTextNode(N))}else g.appendChild(document.createTextNode(N));v=k+N.length}v{if(h.nodeType===Node.ELEMENT_NODE){const m=h.getAttribute("data-type");if(m==="mention"||m==="linkTag")return;h.childNodes.forEach(g=>u(g));return}h.nodeType===Node.TEXT_NODE&&c(h)};return r.childNodes.forEach(h=>u(h)),r.innerHTML}function uV(t){const e=new Map;for(const c of t){const u=c.partId||"part-1",h=c.partTitle||"未分类",f=c.chapterId||"chapter-1",m=c.chapterTitle||"未分类";e.has(u)||e.set(u,{id:u,title:h,chapters:new Map});const g=e.get(u);g.chapters.has(f)||g.chapters.set(f,{id:f,title:m,sections:[]}),g.chapters.get(f).sections.push({id:c.id,title:c.title,price:c.price??1,filePath:c.filePath,isFree:c.isFree,isNew:c.isNew,clickCount:c.clickCount??0,payCount:c.payCount??0,hotScore:c.hotScore??0,hotRank:c.hotRank??0})}const n="part-2026-daily",r="2026每日派对干货";Array.from(e.values()).some(c=>c.title===r||c.title.includes(r))||e.set(n,{id:n,title:r,chapters:new Map([["chapter-2026-daily",{id:"chapter-2026-daily",title:r,sections:[]}]])});const i=Array.from(e.values()).map(c=>({...c,chapters:Array.from(c.chapters.values())})),o=c=>c.includes("序言")?0:c.includes(r)?1.5:c.includes("附录")?2:c.includes("尾声")?3:1;return i.sort((c,u)=>{const h=o(c.title),f=o(u.title);return h!==f?h-f:0})}function hV(){var ls,cs,ds;const[t,e]=b.useState([]),[n,r]=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),[v,w]=b.useState(""),[N,k]=b.useState([]),[C,E]=b.useState(!1),[A,I]=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}),[D,_]=b.useState(null),[P,L]=b.useState(!1),[z,ee]=b.useState(!1),[U,he]=b.useState(null),[me,R]=b.useState(!1),[O,X]=b.useState([]),[$,le]=b.useState(!1),[Y,F]=b.useState(""),[W,K]=b.useState(""),[B,oe]=b.useState(!1),[G,Q]=b.useState(""),[se,ye]=b.useState(!1),[Me,Be]=b.useState(null),[He,gt]=b.useState(!1),[Dt,jn]=b.useState(!1),[it,Mt]=b.useState({readWeight:50,recencyWeight:30,payWeight:20}),[re,Pe]=b.useState(!1),[et,xt]=b.useState(!1),[ft,pt]=b.useState(1),[wt,Qt]=b.useState([]),[Lt,An]=b.useState(!1),[At,Kn]=b.useState([]),[ts,or]=b.useState(!1),[ge,Ne]=b.useState(20),[qn,Cs]=b.useState(!1),[Es,Ra]=b.useState(!1),[br,Bi]=b.useState([]),[vr,lr]=b.useState([]),[Ts,Pa]=b.useState(!1),[Vi,Qs]=b.useState(null),[vt,Gn]=b.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",pagePath:""}),[Oa,Ms]=b.useState(null),Nr=b.useRef(null),[Hi,Xs]=b.useState({}),[tc,Jn]=b.useState(!1),[Zs,ns]=b.useState(""),[Ar,Da]=b.useState(""),[ea,Wi]=b.useState([]),[cr,Ui]=b.useState(0),[rs,nc]=b.useState(1),[Bo,Ki]=b.useState(!1),un=uV(t),ss=t.length,As=10,La=Math.max(1,Math.ceil(wt.length/As)),It=wt.slice((ft-1)*As,ft*As),zn=async()=>{r(!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{r(!1)}},Vr=async()=>{An(!0);try{const T=await De("/api/db/book?action=ranking",{cache:"no-store"}),q=Array.isArray(T==null?void 0:T.sections)?T.sections:[];Qt(q);const ue=q.filter(fe=>fe.isPinned).map(fe=>fe.id);Kn(ue)}catch(T){console.error(T),Qt([])}finally{An(!1)}};b.useEffect(()=>{zn(),Vr()},[]);const Vo=T=>{i(q=>q.includes(T)?q.filter(ue=>ue!==T):[...q,T])},_a=b.useCallback(T=>{const q=t,ue=T.flatMap(fe=>{const nt=q.find(yt=>yt.id===fe.id);return nt?[{...nt,partId:fe.partId,partTitle:fe.partTitle,chapterId:fe.chapterId,chapterTitle:fe.chapterTitle}]:[]});return e(ue),Tt("/api/db/book",{action:"reorder",items:T}).then(fe=>{fe&&fe.success===!1&&(e(q),de.error("排序失败: "+(fe&&typeof fe=="object"&&"error"in fe?fe.error:"未知错误")))}).catch(fe=>{e(q),console.error("排序失败:",fe),de.error("排序失败: "+(fe instanceof Error?fe.message:"网络或服务异常"))}),Promise.resolve()},[t]),rc=async T=>{if(confirm(`确定要删除章节「${T.title}」吗?此操作不可恢复。`))try{const q=await Na(`/api/db/book?id=${encodeURIComponent(T.id)}`);q&&q.success!==!1?(de.success("已删除"),zn(),Vr()):de.error("删除失败: "+(q&&typeof q=="object"&&"error"in q?q.error:"未知错误"))}catch(q){console.error(q),de.error("删除失败")}},qi=b.useCallback(async()=>{Pe(!0);try{const T=await De("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),q=T&&T.data;q&&typeof q.readWeight=="number"&&typeof q.recencyWeight=="number"&&typeof q.payWeight=="number"&&Mt({readWeight:Math.round(q.readWeight*100),recencyWeight:Math.round(q.recencyWeight*100),payWeight:Math.round(q.payWeight*100)})}catch{}finally{Pe(!1)}},[]);b.useEffect(()=>{Dt&&qi()},[Dt,qi]);const za=async()=>{const{readWeight:T,recencyWeight:q,payWeight:ue}=it,fe=T+q+ue;if(Math.abs(fe-100)>1){de.error("三个权重之和必须等于 100%");return}xt(!0);try{const nt=await Nt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:T/100,recencyWeight:q/100,payWeight:ue/100},description:"文章排名算法权重"});nt&&nt.success!==!1?(de.success("排名权重已保存,排行榜已刷新"),zn(),Vr()):de.error("保存失败: "+(nt&&typeof nt=="object"&&"error"in nt?nt.error:""))}catch(nt){console.error(nt),de.error("保存失败")}finally{xt(!1)}},dr=b.useCallback(async()=>{or(!0);try{const T=await De("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),q=T&&T.data;Array.isArray(q)&&Kn(q)}catch{}finally{or(!1)}},[]),as=b.useCallback(async()=>{try{const T=await De("/api/db/persons");T!=null&&T.success&&T.persons&&Bi(T.persons.map(q=>{const ue=q.deviceGroups,fe=Array.isArray(ue)?ue.join(","):ue??"";return{id:q.token??q.personId??"",personId:q.personId,name:q.name,aliases:q.aliases??"",label:q.label??"",ckbApiKey:q.ckbApiKey??"",ckbPlanId:q.ckbPlanId,remarkType:q.remarkType,remarkFormat:q.remarkFormat,addFriendInterval:q.addFriendInterval,startTime:q.startTime,endTime:q.endTime,deviceGroups:fe}}))}catch{}},[]),$n=b.useCallback(async T=>{const q=T==null?void 0:T.trim();if(!q)return null;try{const ue=await Nt("/api/db/persons",{name:q});if(!(ue!=null&&ue.success)||!ue.person)return null;const fe=ue.person;return as(),{id:fe.token??fe.personId??"",personId:fe.personId,name:fe.name??q,label:fe.label??""}}catch{return de.error("创建人物失败"),null}},[as]),Ho=b.useCallback(async()=>{try{const T=await De("/api/db/ckb-person-leads");if(T!=null&&T.success&&T.byPerson){const q={};for(const ue of T.byPerson)q[ue.token]=ue.total;Xs(q)}}catch{}},[]),$a=b.useCallback(async(T,q,ue=1)=>{ns(T),Da(q),Jn(!0),nc(ue),Ki(!0);try{const fe=await De(`/api/db/ckb-person-leads?token=${encodeURIComponent(T)}&page=${ue}&pageSize=20`);fe!=null&&fe.success&&(Wi(fe.records||[]),Ui(fe.total||0),fe.personName&&Da(fe.personName))}catch{}finally{Ki(!1)}},[]),ta=b.useCallback(async()=>{try{const T=await De("/api/db/link-tags");T!=null&&T.success&&T.linkTags&&lr(T.linkTags.map(q=>({id:q.tagId,label:q.label,aliases:q.aliases??"",url:q.url,type:q.type||"url",appId:q.appId||"",pagePath:q.pagePath||""})))}catch{}},[]),Is=async T=>{const q=At.includes(T)?At.filter(ue=>ue!==T):[...At,T];Kn(q);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:q,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),Vr()}catch{Kn(At)}},Rs=b.useCallback(async()=>{Cs(!0);try{const T=await De("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),q=T&&T.data;typeof q=="number"&&q>0&&q<=100&&Ne(q)}catch{}finally{Cs(!1)}},[]),Ps=async()=>{if(ge<1||ge>100){de.error("预览比例需在 1~100 之间");return}Ra(!0);try{const T=await Nt("/api/db/config",{key:"unpaid_preview_percent",value:ge,description:"小程序未付费内容默认预览比例(%)"});T&&T.success!==!1?de.success("预览比例已保存"):de.error("保存失败: "+(T.error||""))}catch{de.error("保存失败")}finally{Ra(!1)}};b.useEffect(()=>{dr(),Rs(),as(),ta(),Ho()},[dr,Rs,as,ta,Ho]);const Os=async T=>{Be({section:T,orders:[]}),gt(!0);try{const q=await De(`/api/db/book?action=section-orders&id=${encodeURIComponent(T.id)}`),ue=q!=null&&q.success&&Array.isArray(q.orders)?q.orders:[];Be(fe=>fe?{...fe,orders:ue}:null)}catch(q){console.error(q),Be(ue=>ue?{...ue,orders:[]}:null)}finally{gt(!1)}},V=async T=>{m(!0);try{const q=await De(`/api/db/book?action=read&id=${encodeURIComponent(T.id)}`);if(q!=null&&q.success&&q.section){const ue=q.section,fe=ue.editionPremium===!0;c({id:T.id,originalId:T.id,title:q.section.title??T.title,price:q.section.price??T.price,content:q.section.content??"",filePath:T.filePath,isFree:T.isFree||T.price===0,isNew:ue.isNew??T.isNew,isPinned:At.includes(T.id),hotScore:T.hotScore??0,editionStandard:fe?!1:ue.editionStandard??!0,editionPremium:fe,previewPercent:ue.previewPercent??null})}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:At.includes(T.id),hotScore:T.hotScore??0,editionStandard:!0,editionPremium:!1,previewPercent:null}),q&&!q.success&&de.error("无法读取文件内容: "+(q.error||"未知错误"))}catch(q){console.error(q),c({id:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree})}finally{m(!1)}},Ie=async()=>{var T;if(o){y(!0);try{let q=o.content||"";q=bw(q,br,vr);const ue=[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 Ds of ue)q=q.replace(Ds,"");q=q.replace(/^\s*\n+/,"").trim();const fe=o.originalId||o.id,nt=o.id!==fe,yt=o.previewPercent,In=yt!=null&&yt!==0&&Number(yt)>=1&&Number(yt)<=100,hn=await Tt("/api/db/book",{id:fe,...nt?{newId:o.id}:{},title:o.title,price:o.isFree?0:o.price,content:q,isFree:o.isFree||o.price===0,isNew:o.isNew,hotScore:o.hotScore,editionStandard:o.editionPremium?!1:o.editionStandard??!0,editionPremium:o.editionPremium??!1,...In?{previewPercent:Number(yt)}:{clearPreviewPercent:!0},saveToFile:!0}),ra=nt?o.id:fe;o.isPinned!==At.includes(ra)&&await Is(ra),hn&&hn.success!==!1?(de.success(`已保存:${o.title}`),c(null),zn()):de.error("保存失败: "+(hn&&typeof hn=="object"&&"error"in hn?hn.error:"未知错误"))}catch(q){console.error(q),de.error("保存失败")}finally{y(!1)}}},Ye=async()=>{if(!A.id||!A.title){de.error("请填写章节ID和标题");return}y(!0);try{const T=un.find(fe=>fe.id===A.partId),q=T==null?void 0:T.chapters.find(fe=>fe.id===A.chapterId),ue=await Tt("/api/db/book",{id:A.id,title:A.title,price:A.isFree?0:A.price,content:bw(A.content||"",br,vr),partId:A.partId,partTitle:(T==null?void 0:T.title)??"",chapterId:A.chapterId,chapterTitle:(q==null?void 0:q.title)??"",isFree:A.isFree,isNew:A.isNew,editionStandard:A.editionPremium?!1:A.editionStandard??!0,editionPremium:A.editionPremium??!1,hotScore:A.hotScore??0,saveToFile:!1});if(ue&&ue.success!==!1){if(A.isPinned){const fe=[...At,A.id];Kn(fe);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:fe,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}de.success(`章节创建成功:${A.title}`),h(!1),I({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),zn()}else de.error("创建失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(T){console.error(T),de.error("创建失败")}finally{y(!1)}},ct=T=>{I(q=>{var ue;return{...q,partId:T.id,chapterId:((ue=T.chapters[0])==null?void 0:ue.id)??"chapter-1"}}),h(!0)},xn=T=>{_({id:T.id,title:T.title})},kn=async()=>{var T;if((T=D==null?void 0:D.title)!=null&&T.trim()){L(!0);try{const q=t.map(fe=>({id:fe.id,partId:fe.partId||"part-1",partTitle:fe.partId===D.id?D.title.trim():fe.partTitle||"",chapterId:fe.chapterId||"chapter-1",chapterTitle:fe.chapterTitle||""})),ue=await Tt("/api/db/book",{action:"reorder",items:q});if(ue&&ue.success!==!1){const fe=D.title.trim();e(nt=>nt.map(yt=>yt.partId===D.id?{...yt,partTitle:fe}:yt)),_(null),zn()}else de.error("更新篇名失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(q){console.error(q),de.error("更新篇名失败")}finally{L(!1)}}},Wo=T=>{const q=T.chapters.length+1,ue=`chapter-${T.id}-${q}-${Date.now()}`;I({id:`${q}.1`,title:"新章节",price:1,partId:T.id,chapterId:ue,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),h(!0)},Xt=(T,q)=>{he({part:T,chapter:q,title:q.title})},st=async()=>{var T;if((T=U==null?void 0:U.title)!=null&&T.trim()){R(!0);try{const q=t.map(fe=>({id:fe.id,partId:fe.partId||U.part.id,partTitle:fe.partId===U.part.id?U.part.title:fe.partTitle||"",chapterId:fe.chapterId||U.chapter.id,chapterTitle:fe.partId===U.part.id&&fe.chapterId===U.chapter.id?U.title.trim():fe.chapterTitle||""})),ue=await Tt("/api/db/book",{action:"reorder",items:q});if(ue&&ue.success!==!1){const fe=U.title.trim(),nt=U.part.id,yt=U.chapter.id;e(In=>In.map(hn=>hn.partId===nt&&hn.chapterId===yt?{...hn,chapterTitle:fe}:hn)),he(null),zn()}else de.error("保存失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(q){console.error(q),de.error("保存失败")}finally{R(!1)}}},Fa=async(T,q)=>{const ue=q.sections.map(fe=>fe.id);if(ue.length===0){de.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${T.chapters.indexOf(q)+1}章 | ${q.title}」吗?将删除共 ${ue.length} 节,此操作不可恢复。`))try{for(const fe of ue)await Na(`/api/db/book?id=${encodeURIComponent(fe)}`);zn()}catch(fe){console.error(fe),de.error("删除失败")}},Ba=async()=>{if(!G.trim()){de.error("请输入篇名");return}ye(!0);try{const T=`part-new-${Date.now()}`,q="chapter-1",ue=`part-placeholder-${Date.now()}`,fe=await Tt("/api/db/book",{id:ue,title:"占位节(可编辑)",price:0,content:"",partId:T,partTitle:G.trim(),chapterId:q,chapterTitle:"第1章 | 待编辑",saveToFile:!1});fe&&fe.success!==!1?(de.success(`篇「${G}」创建成功`),ee(!1),Q(""),zn()):de.error("创建失败: "+(fe&&typeof fe=="object"&&"error"in fe?fe.error:"未知错误"))}catch(T){console.error(T),de.error("创建失败")}finally{ye(!1)}},is=async()=>{if(O.length===0){de.error("请先勾选要移动的章节");return}const T=un.find(ue=>ue.id===Y),q=T==null?void 0:T.chapters.find(ue=>ue.id===W);if(!T||!q||!Y||!W){de.error("请选择目标篇和章");return}oe(!0);try{const ue=()=>{const In=new Set(O),hn=t.map(rn=>({id:rn.id,partId:rn.partId||"",partTitle:rn.partTitle||"",chapterId:rn.chapterId||"",chapterTitle:rn.chapterTitle||""})),ra=hn.filter(rn=>In.has(rn.id)).map(rn=>({...rn,partId:Y,partTitle:T.title||Y,chapterId:W,chapterTitle:q.title||W})),Ds=hn.filter(rn=>!In.has(rn.id));let sc=Ds.length;for(let rn=Ds.length-1;rn>=0;rn-=1){const Va=Ds[rn];if(Va.partId===Y&&Va.chapterId===W){sc=rn+1;break}}return[...Ds.slice(0,sc),...ra,...Ds.slice(sc)]},fe=async()=>{const In=ue(),hn=await Tt("/api/db/book",{action:"reorder",items:In});return hn&&hn.success!==!1?(de.success(`已移动 ${O.length} 节到「${T.title}」-「${q.title}」`),le(!1),X([]),await zn(),!0):!1},nt={action:"move-sections",sectionIds:O,targetPartId:Y,targetChapterId:W,targetPartTitle:T.title||Y,targetChapterTitle:q.title||W},yt=await Tt("/api/db/book",nt);if(yt&&yt.success!==!1)de.success(`已移动 ${yt.count??O.length} 节到「${T.title}」-「${q.title}」`),le(!1),X([]),await zn();else{const In=yt&&typeof yt=="object"&&"error"in yt?yt.error||"":"未知错误";if((In.includes("缺少 id")||In.includes("无效的 action"))&&await fe())return;de.error("移动失败: "+In)}}catch(ue){console.error(ue),de.error("移动失败: "+(ue instanceof Error?ue.message:"网络或服务异常"))}finally{oe(!1)}},Uo=T=>{X(q=>q.includes(T)?q.filter(ue=>ue!==T):[...q,T])},Ko=async T=>{const q=t.filter(ue=>ue.partId===T.id).map(ue=>ue.id);if(q.length===0){de.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${T.title}」整篇吗?将删除共 ${q.length} 节内容,此操作不可恢复。`))try{for(const ue of q)await Na(`/api/db/book?id=${encodeURIComponent(ue)}`);zn()}catch(ue){console.error(ue),de.error("删除失败")}},na=async()=>{var T;if(v.trim()){E(!0);try{const q=await De(`/api/search?q=${encodeURIComponent(v)}`);q!=null&&q.success&&((T=q.data)!=null&&T.results)?k(q.data.results):(k([]),q&&!q.success&&de.error("搜索失败: "+q.error))}catch(q){console.error(q),k([]),de.error("搜索失败")}finally{E(!1)}}},Gi=un.find(T=>T.id===A.partId),Ji=(Gi==null?void 0:Gi.chapters)??[];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",un.length," 篇 · ",ss," 节内容"]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(ne,{onClick:()=>jn(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Au,{className:"w-4 h-4 mr-2"}),"排名算法"]}),s.jsxs(ne,{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:[s.jsx(vs,{className:"w-4 h-4 mr-2"}),"API 接口"]})]})]}),s.jsx(Ft,{open:u,onOpenChange:h,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(Bt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节ID *"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:A.id,onChange:T=>I({...A,id:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:A.isFree?0:A.price,onChange:T=>I({...A,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:A.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.isFree,onChange:T=>I({...A,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]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.isNew,onChange:T=>I({...A,isNew:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.isPinned,onChange:T=>I({...A,isPinned:T.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:A.editionPremium!==!0,onChange:()=>I({...A,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:A.editionPremium===!0,onChange:()=>I({...A,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"热度分"}),s.jsx(ie,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:A.hotScore??0,onChange:T=>I({...A,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:A.title,onChange:T=>I({...A,title:T.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"所属篇"}),s.jsxs(kl,{value:A.partId,onValueChange:T=>{var ue;const q=un.find(fe=>fe.id===T);I({...A,partId:T,chapterId:((ue=q==null?void 0:q.chapters[0])==null?void 0:ue.id)??"chapter-1"})},children:[s.jsx(ho,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Sl,{})}),s.jsxs(fo,{className:"bg-[#0f2137] border-gray-700",children:[un.map(T=>s.jsx(Dr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),un.length===0&&s.jsx(Dr,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"所属章"}),s.jsxs(kl,{value:A.chapterId,onValueChange:T=>I({...A,chapterId:T}),children:[s.jsx(ho,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Sl,{})}),s.jsxs(fo,{className:"bg-[#0f2137] border-gray-700",children:[Ji.map(T=>s.jsx(Dr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),Ji.length===0&&s.jsx(Dr,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(Mx,{content:A.content||"",onChange:T=>I({...A,content:T}),onImageUpload:async T=>{var nt;const q=new FormData;q.append("file",T),q.append("folder","book-images");const fe=await(await fetch(wa("/api/upload"),{method:"POST",body:q,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((nt=fe==null?void 0:fe.data)==null?void 0:nt.url)||(fe==null?void 0:fe.url)||""},onVideoUpload:async T=>{var nt;const q=new FormData;q.append("file",T),q.append("folder","book-videos");const fe=await(await fetch(wa("/api/upload/video"),{method:"POST",body:q,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((nt=fe==null?void 0:fe.data)==null?void 0:nt.url)||(fe==null?void 0:fe.url)||""},persons:br,linkTags:vr,onPersonCreate:$n,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(ln,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(ne,{variant:"outline",onClick:()=>h(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:Ye,disabled:g||!A.id||!A.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Ft,{open:!!D,onOpenChange:T=>!T&&_(null),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx($t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),D&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"篇名"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:D.title,onChange:T=>_({...D,title:T.target.value}),placeholder:"输入篇名"})]})}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",onClick:()=>_(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:kn,disabled:P||!((ls=D==null?void 0:D.title)!=null&&ls.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:P?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Ft,{open:!!U,onOpenChange:T=>!T&&he(null),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx($t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节名称"]})}),U&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:U.title,onChange:T=>he({...U,title:T.target.value}),placeholder:"输入章节名称"})]})}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",onClick:()=>he(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:st,disabled:me||!((cs=U==null?void 0:U.title)!=null&&cs.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Ft,{open:$,onOpenChange:T=>{var q;if(le(T),T&&un.length>0){const ue=un[0];F(ue.id),K(((q=ue.chapters[0])==null?void 0:q.id)??"")}},children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsx(Vt,{className:"text-white",children:"批量移动至指定目录"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",s.jsx("span",{className:"text-[#38bdac] font-medium",children:O.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目标篇"}),s.jsxs(kl,{value:Y,onValueChange:T=>{var ue;F(T);const q=un.find(fe=>fe.id===T);K(((ue=q==null?void 0:q.chapters[0])==null?void 0:ue.id)??"")},children:[s.jsx(ho,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Sl,{placeholder:"选择篇"})}),s.jsx(fo,{className:"bg-[#0f2137] border-gray-700",children:un.map(T=>s.jsx(Dr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目标章"}),s.jsxs(kl,{value:W,onValueChange:K,children:[s.jsx(ho,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Sl,{placeholder:"选择章"})}),s.jsx(fo,{className:"bg-[#0f2137] border-gray-700",children:(((ds=un.find(T=>T.id===Y))==null?void 0:ds.chapters)??[]).map(T=>s.jsx(Dr,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]})]}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",onClick:()=>le(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:is,disabled:B||O.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:B?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Ft,{open:!!Me,onOpenChange:T=>!T&&Be(null),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white",children:["付款记录 — ",(Me==null?void 0:Me.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:He?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Me&&Me.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):Me?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"py-2 pr-2",children:"订单号"}),s.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),s.jsx("th",{className:"py-2 pr-2",children:"金额"}),s.jsx("th",{className:"py-2 pr-2",children:"状态"}),s.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),s.jsx("tbody",{children:Me.orders.map(T=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-2",children:s.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:"-"})}),s.jsx("td",{className:"py-2 pr-2",children:s.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 q=T.userId??T.openId??"-";return q.length>12?q.slice(0,6)+"..."+q.slice(-4):q})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",T.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:T.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:T.payTime??T.createdAt??"-"})]},T.id??T.orderSn??""))})]}):null})]})}),s.jsx(Ft,{open:Dt,onOpenChange:jn,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(Au,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsx("p",{className:"text-sm text-gray-400",children:"排名积分制:三个维度各取前20名(第1名=20分,第20名=1分),乘以权重后求和(三权重之和须为 100%)"}),re?s.jsx("p",{className:"text-gray-500",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"阅读权重 (%)"}),s.jsx(ie,{type:"number",step:"5",min:"0",max:"100",className:"bg-[#0a1628] border-gray-700 text-white",value:it.readWeight,onChange:T=>Mt(q=>({...q,readWeight:Math.max(0,Math.min(100,parseInt(T.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"新度权重 (%)"}),s.jsx(ie,{type:"number",step:"5",min:"0",max:"100",className:"bg-[#0a1628] border-gray-700 text-white",value:it.recencyWeight,onChange:T=>Mt(q=>({...q,recencyWeight:Math.max(0,Math.min(100,parseInt(T.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"付款权重 (%)"}),s.jsx(ie,{type:"number",step:"5",min:"0",max:"100",className:"bg-[#0a1628] border-gray-700 text-white",value:it.payWeight,onChange:T=>Mt(q=>({...q,payWeight:Math.max(0,Math.min(100,parseInt(T.target.value)||0))}))})]})]}),s.jsxs("p",{className:`text-xs ${Math.abs(it.readWeight+it.recencyWeight+it.payWeight-100)>1?"text-red-400":"text-green-400"}`,children:["当前之和: ",it.readWeight+it.recencyWeight+it.payWeight,"%",Math.abs(it.readWeight+it.recencyWeight+it.payWeight-100)>1?"(须为 100%)":" ✓"]}),s.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[s.jsx("li",{children:"阅读量排名前20:第1名=20分 → 第20名=1分,其余0分"}),s.jsx("li",{children:"新度排名前20(按最近更新):同理20→1分"}),s.jsx("li",{children:"付款量排名前20:同理20→1分"}),s.jsx("li",{children:"热度 = 阅读排名分 × 阅读权重% + 新度排名分 × 新度权重% + 付款排名分 × 付款权重%"})]}),s.jsx(ne,{onClick:za,disabled:et||Math.abs(it.readWeight+it.recencyWeight+it.payWeight-100)>1,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:et?"保存中...":"保存权重"})]})]})]})}),s.jsx(Ft,{open:z,onOpenChange:ee,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:G,onChange:T=>Q(T.target.value),placeholder:"输入篇名"})]})}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",onClick:()=>{ee(!1),Q("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:Ba,disabled:se||!G.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:se?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Ft,{open:!!o,onOpenChange:()=>c(null),children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(Bt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx($t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),o&&s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节ID"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.id,onChange:T=>c({...o,id:T.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(ie,{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})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.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]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.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]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.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"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.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]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.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]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"热度分"}),s.jsx(ie,{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)})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"预览比例 (%)"}),s.jsx(ie,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"默认使用全局设置",value:o.previewPercent!=null&&o.previewPercent>=1&&o.previewPercent<=100?String(o.previewPercent):"",onChange:T=>{const q=T.target.value.trim(),ue=q===""?null:parseInt(q,10);c({...o,previewPercent:q!==""&&ue!==null&&!isNaN(ue)&&ue>=1&&ue<=100?ue:null})}}),s.jsx("span",{className:"text-xs text-gray-500",children:"未付费用户可见前 N% 内容,留空使用全局设置"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节标题"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.title,onChange:T=>c({...o,title:T.target.value})})]}),o.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文件路径"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:o.filePath,disabled:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),f?s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(Mx,{ref:Nr,content:o.content||"",onChange:T=>c({...o,content:T}),onImageUpload:async T=>{var nt;const q=new FormData;q.append("file",T),q.append("folder","book-images");const fe=await(await fetch(wa("/api/upload"),{method:"POST",body:q,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((nt=fe==null?void 0:fe.data)==null?void 0:nt.url)||(fe==null?void 0:fe.url)||""},onVideoUpload:async T=>{var nt;const q=new FormData;q.append("file",T),q.append("folder","book-videos");const fe=await(await fetch(wa("/api/upload/video"),{method:"POST",body:q,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((nt=fe==null?void 0:fe.data)==null?void 0:nt.url)||(fe==null?void 0:fe.url)||""},persons:br,linkTags:vr,onPersonCreate:$n,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(ln,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[o&&s.jsxs(ne,{variant:"outline",onClick:()=>Os({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:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(ne,{variant:"outline",onClick:()=>c(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(ne,{onClick:Ie,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(Sd,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Gl,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(tn,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(tn,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(_g,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(tn,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(ka,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(tn,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(vs,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),s.jsxs(tn,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(Vv,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),s.jsxs(nn,{value:"chapters",className:"space-y-4",children:[s.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.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:s.jsx($r,{className:"w-6 h-6"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),s.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),s.jsxs("div",{className:"text-center shrink-0",children:[s.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:ss}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(ne,{onClick:()=>h(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(ne,{onClick:()=>ee(!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:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(ne,{variant:"outline",onClick:()=>le(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",O.length," 节)"]})]}),n?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(oV,{parts:un,expandedParts:a,onTogglePart:Vo,onReorder:_a,onReadSection:V,onDeleteSection:rc,onAddSectionInPart:ct,onAddChapterInPart:Wo,onDeleteChapter:Fa,onEditPart:xn,onDeletePart:Ko,onEditChapter:Xt,selectedSectionIds:O,onToggleSectionSelect:Uo,onShowSectionOrders:Os,pinnedSectionIds:At})]}),s.jsx(nn,{value:"search",className:"space-y-4",children:s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"内容搜索"})}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:v,onChange:T=>w(T.target.value),onKeyDown:T=>T.key==="Enter"&&na()}),s.jsx(ne,{onClick:na,disabled:C||!v.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?s.jsx(Ue,{className:"w-4 h-4 animate-spin"}):s.jsx(ka,{className:"w-4 h-4"})})]}),N.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",N.length," 个结果"]}),N.filter(T=>T.matchType==="title").length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-amber-400 text-sm font-medium mb-2",children:"标题匹配"}),N.filter(T=>T.matchType==="title").slice(0,3).map(T=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors mb-2",onClick:()=>V({id:T.id,title:T.title,price:T.price??1,filePath:""}),children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:T.id}),s.jsx("span",{className:"text-white",children:T.title}),At.includes(T.id)&&s.jsx(gi,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]})}),(T.partTitle||T.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[T.partTitle," · ",T.chapterTitle]})]},T.id))]}),N.filter(T=>T.matchType==="content").length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"text-gray-400 text-sm font-medium mb-2",children:"内容匹配"}),N.filter(T=>T.matchType==="content").map(T=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors mb-2",onClick:()=>V({id:T.id,title:T.title,price:T.price??1,filePath:""}),children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:T.id}),s.jsx("span",{className:"text-white",children:T.title}),At.includes(T.id)&&s.jsx(gi,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]})}),T.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:T.snippet}),(T.partTitle||T.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[T.partTitle," · ",T.chapterTitle]})]},T.id))]})]})]})]})}),s.jsxs(nn,{value:"ranking",className:"space-y-4",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Au,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsx(Ce,{children:s.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(te,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(ie,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:ge,onChange:T=>Ne(Math.max(1,Math.min(100,Number(T.target.value)||20))),disabled:qn}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(ne,{size:"sm",onClick:Ps,disabled:Es,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Es?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",ge,"% 内容"]})]})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(Ge,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(_g,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",wt.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Vr(),disabled:Lt,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Ue,{className:`w-4 h-4 ${Lt?"animate-spin":""}`})}),s.jsx(ne,{variant:"ghost",size:"sm",disabled:ft<=1||Lt,onClick:()=>pt(T=>Math.max(1,T-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(GT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[ft," / ",La]}),s.jsx(ne,{variant:"ghost",size:"sm",disabled:ft>=La||Lt,onClick:()=>pt(T=>Math.min(La,T+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(Cl,{className:"w-4 h-4"})})]})]})}),s.jsx(Ce,{children:s.jsxs("div",{className:"space-y-0",children:[s.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:[s.jsx("span",{children:"排名"}),s.jsx("span",{children:"置顶"}),s.jsx("span",{children:"标题"}),s.jsx("span",{className:"text-right",children:"点击量"}),s.jsx("span",{className:"text-right",children:"付款数"}),s.jsx("span",{className:"text-right",children:"热度"}),s.jsx("span",{className:"text-right",children:"编辑"})]}),It.map((T,q)=>{const ue=(ft-1)*As+q+1,fe=T.isPinned??At.includes(T.id);return s.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 ${fe?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${ue<=3?"text-amber-400":"text-gray-500"}`,children:ue<=3?["🥇","🥈","🥉"][ue-1]:`#${ue}`}),s.jsx(ne,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${fe?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>Is(T.id),disabled:ts,title:fe?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:fe?s.jsx(gi,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(vA,{className:"w-3.5 h-3.5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-white text-sm truncate block",children:T.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[T.partTitle," · ",T.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:T.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:T.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(T.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>V({id:T.id,title:T.title,price:T.price,filePath:""}),title:"编辑文章",children:s.jsx($t,{className:"w-3 h-3"})})})]},T.id)}),It.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(nn,{value:"link-person",className:"space-y-4",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"pb-3",children:[s.jsxs(Ge,{className:"text-white text-base flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — 链接人与事(编辑器内输入 @ 可链接)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"添加时自动生成 32 位 token,文章 @ 时存 token;小程序点击 @ 时用 token 兑换真实密钥后加好友"})]}),s.jsxs(Ce,{className:"space-y-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("p",{className:"text-xs text-gray-500",children:"添加人物时同步创建存客宝场景获客计划,配置与存客宝 API 获客一致"}),s.jsxs(ne,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Qs(null),Pa(!0)},children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[br.length>0&&s.jsxs("div",{className:"flex items-center gap-4 px-3 py-1.5 text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("span",{className:"w-[200px] shrink-0",children:"token"}),s.jsx("span",{className:"w-24 shrink-0",children:"@的人"}),s.jsx("span",{className:"w-28 shrink-0",children:"别名"}),s.jsx("span",{className:"w-16 shrink-0 text-center",children:"获客数"}),s.jsx("span",{children:"获客计划活动名"})]}),br.map(T=>{const q=Hi[T.id]||0;return s.jsxs("div",{className:"bg-[#0a1628] rounded px-3 py-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm min-w-0",children:[s.jsx("span",{className:"text-gray-400 text-xs font-mono shrink-0 w-[200px] truncate",title:T.id,children:T.id}),s.jsx("span",{className:"text-amber-400 shrink-0 w-24 truncate",title:"@的人",children:T.name}),s.jsx("span",{className:"text-gray-500 shrink-0 w-28 truncate text-xs",title:"别名",children:T.aliases||"-"}),s.jsx("span",{className:`shrink-0 w-16 text-center text-xs font-bold ${q>0?"text-green-400":"text-gray-600"}`,title:"获客数",children:q}),s.jsxs("span",{className:"text-white truncate",title:"获客计划活动名",children:["SOUL链接人与事-",T.name]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const ue=await cV(T.personId||"");if(ue!=null&&ue.success&&ue.person){const fe=ue.person;Qs({id:fe.token??fe.personId,personId:fe.personId,name:fe.name,aliases:fe.aliases??"",label:fe.label??"",ckbApiKey:fe.ckbApiKey??"",remarkType:fe.remarkType,remarkFormat:fe.remarkFormat,addFriendInterval:fe.addFriendInterval,startTime:fe.startTime,endTime:fe.endTime,deviceGroups:fe.deviceGroups})}else Qs(T),ue!=null&&ue.error&&de.error(ue.error)}catch(ue){console.error(ue),Qs(T),de.error(ue instanceof Error?ue.message:"加载人物详情失败")}Pa(!0)},children:s.jsx(pA,{className:"w-3 h-3"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看获客详情",onClick:()=>$a(T.id,T.name),children:s.jsx(Mn,{className:"w-3 h-3"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-amber-400 h-6 px-2",title:"编辑计划(跳转存客宝)",onClick:()=>{const ue=T.ckbPlanId;ue?window.open(`https://h5.ckb.quwanzhi.com/#/scenarios/edit/${ue}`,"_blank"):de.info("该人物尚未同步存客宝计划,请先保存后等待同步完成")},children:s.jsx(Us,{className:"w-3 h-3"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:"删除(同时删除存客宝对应获客计划)",onClick:async()=>{confirm(`确定删除「SOUL链接人与事-${T.name}」?将同时删除存客宝对应获客计划。`)&&(await Na(`/api/db/persons?personId=${T.personId}`),as())},children:s.jsx(nr,{className:"w-3 h-3"})})]})]},T.id)}),br.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"pb-3",children:[s.jsxs(Ge,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Au,{className:"w-4 h-4 text-green-400"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs(Ce,{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",s.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]})]}),s.jsx(nn,{value:"link-tag",className:"space-y-4",children:s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"pb-3",children:[s.jsxs(Ge,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Vv,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),s.jsxs(Ce,{className:"space-y-3",children:[s.jsxs("div",{className:"flex gap-2 items-end flex-wrap",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"标签ID"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",placeholder:"如 team01",value:vt.tagId,onChange:T=>Gn({...vt,tagId:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"显示文字"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"如 神仙团队",value:vt.label,onChange:T=>Gn({...vt,label:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"别名"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"逗号分隔",value:vt.aliases,onChange:T=>Gn({...vt,aliases:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"类型"}),s.jsxs(kl,{value:vt.type,onValueChange:T=>Gn({...vt,type:T}),children:[s.jsx(ho,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",children:s.jsx(Sl,{})}),s.jsxs(fo,{children:[s.jsx(Dr,{value:"url",children:"网页链接"}),s.jsx(Dr,{value:"miniprogram",children:"小程序"}),s.jsx(Dr,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:vt.type==="url"?"URL地址":vt.type==="ckb"?"存客宝计划URL":"AppID"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-44",placeholder:vt.type==="url"?"https://...":vt.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"wx...",value:vt.type==="url"||vt.type==="ckb"?vt.url:vt.appId,onChange:T=>{vt.type==="url"||vt.type==="ckb"?Gn({...vt,url:T.target.value}):Gn({...vt,appId:T.target.value})}})]}),vt.type==="miniprogram"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"页面路径"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-36",placeholder:"pages/index/index",value:vt.pagePath,onChange:T=>Gn({...vt,pagePath:T.target.value})})]}),s.jsxs(ne,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:async()=>{if(!vt.tagId||!vt.label){de.error("标签ID和显示文字必填");return}const T={...vt};T.type==="miniprogram"&&(T.url=""),await Nt("/api/db/link-tags",T),Gn({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",pagePath:""}),Ms(null),ta()},children:[s.jsx(pn,{className:"w-3 h-3 mr-1"}),Oa?"保存":"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[vr.map(T=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsxs("button",{type:"button",className:"text-amber-400 font-bold text-base hover:underline",onClick:()=>{Gn({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",pagePath:T.pagePath??""}),Ms(T.id)},children:["#",T.label]}),s.jsx(Ke,{variant:"secondary",className:`text-[10px] ${T.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":"bg-gray-700 text-gray-300"}`,children:T.type==="url"?"网页":T.type==="ckb"?"存客宝":"小程序"}),T.type==="miniprogram"?s.jsxs("span",{className:"text-gray-400 text-xs font-mono",children:[T.appId," ",T.pagePath?`· ${T.pagePath}`:""]}):T.url?s.jsxs("a",{href:T.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[250px] hover:underline flex items-center gap-1",children:[T.url," ",s.jsx(Us,{className:"w-3 h-3 shrink-0"})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-6 px-2",onClick:()=>{Gn({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",pagePath:T.pagePath??""}),Ms(T.id)},children:"编辑"}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",onClick:async()=>{await Na(`/api/db/link-tags?tagId=${T.id}`),Oa===T.id&&(Ms(null),Gn({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",pagePath:""})),ta()},children:s.jsx(nr,{className:"w-3 h-3"})})]})]},T.id)),vr.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})]})]})]})})]}),s.jsx(dV,{open:Ts,onOpenChange:Pa,editingPerson:Vi,onSubmit:async T=>{var fe;const q={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:(fe=T.deviceGroups)!=null&&fe.trim()?T.deviceGroups.split(",").map(nt=>parseInt(nt.trim(),10)).filter(nt=>!Number.isNaN(nt)):void 0},ue=await Nt("/api/db/persons",q);if(ue&&ue.success===!1){const nt=ue;nt.ckbResponse&&console.log("存客宝返回",nt.ckbResponse);const yt=nt.error||"操作失败";throw new Error(yt)}if(as(),de.success(Vi?"已保存":"已添加"),ue!=null&&ue.ckbCreateResult&&Object.keys(ue.ckbCreateResult).length>0){const nt=ue.ckbCreateResult;console.log("存客宝创建结果",nt);const yt=nt.planId??nt.id,In=yt!=null?[`planId: ${yt}`]:[];nt.apiKey!=null&&In.push("apiKey: ***"),de.info(In.length?`存客宝创建结果:${In.join(",")}`:"存客宝创建结果见控制台")}}}),s.jsx(Ft,{open:tc,onOpenChange:Jn,children:s.jsxs(Rt,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{className:"w-5 h-5 text-green-400"}),Ar," — 获客详情(共 ",cr," 条)"]})}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:Bo?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ue,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):ea.length===0?s.jsx("div",{className:"text-gray-500 text-sm py-8 text-center",children:"暂无获客记录"}):s.jsxs(s.Fragment,{children:[s.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:[s.jsx("span",{children:"#"}),s.jsx("span",{children:"昵称/姓名"}),s.jsx("span",{children:"手机"}),s.jsx("span",{children:"微信"}),s.jsx("span",{children:"来源"}),s.jsx("span",{children:"时间"})]}),ea.map((T,q)=>s.jsxs("div",{className:"grid grid-cols-[60px_1fr_100px_100px_80px_120px] gap-2 px-3 py-2 bg-[#0a1628] rounded text-sm",children:[s.jsx("span",{className:"text-gray-500 text-xs",children:(rs-1)*20+q+1}),s.jsx("span",{className:"text-white truncate",children:T.nickname||T.name||T.userId||"-"}),s.jsx("span",{className:"text-gray-300 text-xs",children:T.phone||"-"}),s.jsx("span",{className:"text-gray-300 text-xs truncate",children:T.wechatId||"-"}),s.jsx("span",{className:"text-gray-500 text-xs",children:T.source==="article_mention"?"文章@":T.source==="index_lead"?"首页":T.source||"-"}),s.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))]})}),cr>20&&s.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[s.jsx(ne,{size:"sm",variant:"outline",disabled:rs<=1,onClick:()=>$a(Zs,Ar,rs-1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"上一页"}),s.jsxs("span",{className:"text-gray-400 text-xs",children:[rs," / ",Math.ceil(cr/20)]}),s.jsx(ne,{size:"sm",variant:"outline",disabled:rs>=Math.ceil(cr/20),onClick:()=>$a(Zs,Ar,rs+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const va={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 vw(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):va.stats}function Nw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):va.highlights}function fV(){const[t,e]=b.useState(va),[n,r]=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??va.name),avatar:String(C.avatar??va.avatar),avatarImg:String(C.avatarImg??""),title:String(C.title??va.title),bio:String(C.bio??va.bio),stats:vw(C.stats).length?vw(C.stats):va.stats,highlights:Nw(C.highlights).length?Nw(C.highlights):va.highlights})}).catch(console.error).finally(()=>r(!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(A=>A.label||A.value),highlights:t.highlights.filter(Boolean)},C=await Nt("/api/admin/author-settings",k);if(!C||C.success===!1){de.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),de.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 A=new FormData;A.append("file",C),A.append("folder","avatars");const I=Ux(),D={};I&&(D.Authorization=`Bearer ${I}`);const P=await(await fetch(wa("/api/upload"),{method:"POST",body:A,credentials:"include",headers:D})).json();P!=null&&P.success&&(P!=null&&P.url)?e(L=>({...L,avatarImg:P.url})):de.error("上传失败: "+((P==null?void 0:P.error)||"未知错误"))}catch(A){console.error(A),de.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,A)=>A!==k)})),y=(k,C,E)=>e(A=>({...A,stats:A.stats.map((I,D)=>D===k?{...I,[C]:E}:I)})),v=()=>e(k=>({...k,highlights:[...k.highlights,""]})),w=k=>e(C=>({...C,highlights:C.highlights.filter((E,A)=>A!==k)})),N=(k,C)=>e(E=>({...E,highlights:E.highlights.map((A,I)=>I===k?C:A)}));return n?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(vo,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(ne,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"flex items-center gap-2 text-white",children:[s.jsx(vo,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx(Ht,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"姓名"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(C=>({...C,name:k.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(ie,{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"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Qw,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ie,{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"}),s.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),s.jsxs(ne,{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:[s.jsx(ph,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:t.avatarImg.startsWith("http")?t.avatarImg:wa(t.avatarImg),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"头衔"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(C=>({...C,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"个人简介"}),s.jsx(Jl,{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点..."})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsx(Ge,{className:"text-white",children:"统计数据"}),s.jsx(Ht,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs(Ce,{className:"space-y-3",children:[t.stats.map((k,C)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ie,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:E=>y(C,"label",E.target.value),placeholder:"标签"}),s.jsx(ie,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:E=>y(C,"value",E.target.value),placeholder:"数值"}),s.jsx(ne,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(C),children:s.jsx(nr,{className:"w-4 h-4"})})]},C)),s.jsxs(ne,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsx(Ge,{className:"text-white",children:"亮点标签"}),s.jsx(Ht,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(Ce,{className:"space-y-3",children:[t.highlights.map((k,C)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ie,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:E=>N(C,E.target.value),placeholder:"5年私域运营经验"}),s.jsx(ne,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(C),children:s.jsx(nr,{className:"w-4 h-4"})})]},C)),s.jsxs(ne,{variant:"outline",size:"sm",onClick:v,className:"border-gray-600 text-gray-400",children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function pV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[a,i]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=i0(h,300),[g,y]=b.useState(!0),[v,w]=b.useState(null),[N,k]=b.useState(!1),[C,E]=b.useState(null),[A,I]=b.useState(""),[D,_]=b.useState(""),[P,L]=b.useState(""),[z,ee]=b.useState("admin"),[U,he]=b.useState("active"),[me,R]=b.useState(!1);async function O(){var W;y(!0),w(null);try{const K=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&K.set("search",m.trim());const B=await De(`/api/admin/users?${K}`);B!=null&&B.success?(e(B.records||[]),r(B.total??0),u(B.totalPages??0)):w(B.error||"加载失败")}catch(K){const B=K;w(B.status===403?"无权限访问":((W=B==null?void 0:B.data)==null?void 0:W.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{O()},[a,o,m]);const X=()=>{E(null),I(""),_(""),L(""),ee("admin"),he("active"),k(!0)},$=W=>{E(W),I(W.username),_(""),L(W.name||""),ee(W.role==="super_admin"?"super_admin":"admin"),he(W.status==="disabled"?"disabled":"active"),k(!0)},le=async()=>{var W;if(!A.trim()){w("用户名不能为空");return}if(!C&&!D){w("新建时密码必填,至少 6 位");return}if(D&&D.length<6){w("密码至少 6 位");return}w(null),R(!0);try{if(C){const K=await Tt("/api/admin/users",{id:C.id,password:D||void 0,name:P.trim(),role:z,status:U});K!=null&&K.success?(k(!1),O()):w((K==null?void 0:K.error)||"保存失败")}else{const K=await Nt("/api/admin/users",{username:A.trim(),password:D,name:P.trim(),role:z});K!=null&&K.success?(k(!1),O()):w((K==null?void 0:K.error)||"保存失败")}}catch(K){const B=K;w(((W=B==null?void 0:B.data)==null?void 0:W.error)||"保存失败")}finally{R(!1)}},Y=async W=>{var K;if(confirm("确定删除该管理员?"))try{const B=await Na(`/api/admin/users?id=${W}`);B!=null&&B.success?O():w((B==null?void 0:B.error)||"删除失败")}catch(B){const oe=B;w(((K=oe==null?void 0:oe.data)==null?void 0:K.error)||"删除失败")}},F=W=>{if(!W)return"-";try{const K=new Date(W);return isNaN(K.getTime())?W:K.toLocaleString("zh-CN")}catch{return W}};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Hx,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ie,{placeholder:"搜索用户名/昵称",value:h,onChange:W=>f(W.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(ne,{variant:"outline",size:"sm",onClick:O,disabled:g,className:"border-gray-600 text-gray-300",children:s.jsx(Ue,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),s.jsxs(ne,{onClick:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),v&&s.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:[s.jsx("span",{children:v}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-0",children:g?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"ID"}),s.jsx(Ee,{className:"text-gray-400",children:"用户名"}),s.jsx(Ee,{className:"text-gray-400",children:"昵称"}),s.jsx(Ee,{className:"text-gray-400",children:"角色"}),s.jsx(Ee,{className:"text-gray-400",children:"状态"}),s.jsx(Ee,{className:"text-gray-400",children:"创建时间"}),s.jsx(Ee,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(gr,{children:[t.map(W=>s.jsxs(lt,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:W.id}),s.jsx(be,{className:"text-white font-medium",children:W.username}),s.jsx(be,{className:"text-gray-400",children:W.name||"-"}),s.jsx(be,{children:s.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"?"超级管理员":"管理员"})}),s.jsx(be,{children:s.jsx(Ke,{variant:"outline",className:W.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:W.status==="active"?"正常":"已禁用"})}),s.jsx(be,{className:"text-gray-500 text-sm",children:F(W.createdAt)}),s.jsxs(be,{className:"text-right",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>$(W),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx($t,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Y(W.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(er,{className:"w-4 h-4"})})]})]},W.id)),t.length===0&&!g&&s.jsx(lt,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:v==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&s.jsx("div",{className:"p-4 border-t border-gray-700/50",children:s.jsx(Ns,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),s.jsx(Ft,{open:N,onOpenChange:k,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Bt,{children:s.jsx(Vt,{className:"text-white",children:C?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"用户名"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:A,onChange:W=>I(W.target.value),disabled:!!C}),C&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:C?"新密码(留空不改)":"密码"}),s.jsx(ie,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:C?"留空表示不修改":"至少 6 位",value:D,onChange:W=>_(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:P,onChange:W=>L(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:z,onChange:W=>ee(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"admin",children:"管理员"}),s.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),C&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:U,onChange:W=>he(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"active",children:"正常"}),s.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),s.jsxs(ln,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:le,disabled:me,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),me?"保存中...":"保存"]})]})]})})]})}function bn({method:t,url:e,desc:n,headers:r,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 s.jsxs("div",{className:"rounded-lg bg-[#0a1628]/60 border border-gray-700/50 p-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:`font-mono font-semibold ${o}`,children:t}),s.jsx("code",{className:"text-sm text-[#38bdac] break-all",children:e})]}),n&&s.jsx("p",{className:"text-gray-400 text-sm",children:n}),r&&r.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Headers"}),s.jsx("pre",{className:"text-xs text-gray-300 font-mono overflow-x-auto p-2 rounded bg-black/30",children:r.join(` +`)})]}),a&&s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Request Body (JSON)"}),s.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&&s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"Response Example"}),s.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 $4(){const t=["Authorization: Bearer {token}","Content-Type: application/json"];return s.jsxs("div",{className:"p-8 w-full bg-[#0a1628] text-white",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"内容管理相关接口 · RESTful · 基础路径 /api · 管理端需 Bearer Token"})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Xw,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),s.jsx(Ce,{className:"space-y-4",children:s.jsx(bn,{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" +}`})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx($r,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsx(bn,{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 } + ] +}`}),s.jsx(bn,{method:"GET",url:"/api/db/book?action=section&id={id}",desc:"获取单篇内容",headers:t,response:`{ + "success": true, + "data": { + "id": "section-1", + "title": "标题", + "content": "正文...", + "price": 1.0, + "isFree": false, + "partId": "part-1", + "chapterId": "ch-1" + } +}`}),s.jsx(bn,{method:"POST",url:"/api/db/book",desc:"新建章节 (action=create-section)",headers:t,body:`{ + "action": "create-section", + "title": "新章节标题", + "content": "正文内容", + "price": 0, + "isFree": true, + "partId": "part-1", + "chapterId": "ch-1", + "partTitle": "第一篇", + "chapterTitle": "第1章" +}`,response:`{ + "success": true, + "data": { "id": "section-new-id", "title": "新章节标题", ... } +}`}),s.jsx(bn,{method:"POST",url:"/api/db/book",desc:"更新章节内容 (action=update-section)",headers:t,body:`{ + "action": "update-section", + "id": "section-1", + "title": "更新后的标题", + "content": "更新后的正文", + "price": 1.0, + "isFree": false +}`,response:`{ + "success": true, + "data": { "id": "section-1", "title": "更新后的标题", ... } +}`}),s.jsx(bn,{method:"POST",url:"/api/db/book",desc:"删除章节 (action=delete-section)",headers:t,body:`{ + "action": "delete-section", + "id": "section-1" +}`,response:`{ + "success": true, + "message": "已删除" +}`}),s.jsx(bn,{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" } +}`})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(vo,{className:"w-5 h-5 text-[#38bdac]"}),"3. 人物管理 (@Mentions)"]})}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsx(bn,{method:"GET",url:"/api/db/persons",desc:"人物列表",headers:t,response:`{ + "success": true, + "data": [ + { "personId": "p1", "label": "张三", "aliases": ["老张"], ... } + ] +}`}),s.jsx(bn,{method:"GET",url:"/api/db/person?personId={id}",desc:"人物详情",headers:t,response:`{ + "success": true, + "data": { + "personId": "p1", + "label": "张三", + "aliases": ["老张"], + "description": "..." + } +}`}),s.jsx(bn,{method:"POST",url:"/api/db/persons",desc:"新增/更新人物(含 aliases 字段)",headers:t,body:`{ + "personId": "p1", + "label": "张三", + "aliases": ["老张", "张三丰"], + "description": "可选描述" +}`,response:`{ + "success": true, + "data": { "personId": "p1", "label": "张三", ... } +}`}),s.jsx(bn,{method:"DELETE",url:"/api/db/persons?personId={id}",desc:"删除人物",headers:t,response:`{ + "success": true, + "message": "已删除" +}`})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Kc,{className:"w-5 h-5 text-[#38bdac]"}),"4. 链接标签 (#LinkTags)"]})}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsx(bn,{method:"GET",url:"/api/db/link-tags",desc:"标签列表",headers:t,response:`{ + "success": true, + "data": [ + { "tagId": "t1", "label": "官网", "aliases": [], "type": "url", "url": "https://..." } + ] +}`}),s.jsx(bn,{method:"POST",url:"/api/db/link-tags",desc:"新增/更新标签(含 aliases, type: url/miniprogram/ckb)",headers:t,body:`{ + "tagId": "t1", + "label": "官网", + "aliases": ["官方网站"], + "type": "url", + "url": "https://example.com" +} + +// type 可选: url | miniprogram | ckb`,response:`{ + "success": true, + "data": { "tagId": "t1", "label": "官网", "type": "url", ... } +}`}),s.jsx(bn,{method:"DELETE",url:"/api/db/link-tags?tagId={id}",desc:"删除标签",headers:t,response:`{ + "success": true, + "message": "已删除" +}`})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(ka,{className:"w-5 h-5 text-[#38bdac]"}),"5. 内容搜索"]})}),s.jsx(Ce,{className:"space-y-4",children:s.jsx(bn,{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": "..." }] + } +}`})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(_g,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),s.jsx(Ce,{className:"space-y-4",children:s.jsx(bn,{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 } + ] +}`})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{className:"pb-3",children:s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Ol,{className:"w-5 h-5 text-[#38bdac]"}),"7. 小程序接口"]})}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsx(bn,{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 }, ... ] +}`}),s.jsx(bn,{method:"GET",url:"/api/miniprogram/balance?userId={id}",desc:"查余额",headers:["Content-Type: application/json"],response:`{ + "success": true, + "data": { "balance": 100.50, "userId": "xxx" } +}`}),s.jsx(bn,{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 } +}`}),s.jsx(bn,{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 } +}`})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-6",children:"管理端仅使用 /api/admin/*、/api/db/*;小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}const mV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},gV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},xV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...gV},ckbLeadApiKey:""},yV={endpoint:"",accessKeyId:"",accessKeySecret:"",bucket:"",region:""},bV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},vV=["system","author","admin","api-docs"];function NV(){const[t,e]=Ww(),n=t.get("tab")??"system",r=vV.includes(n)?n:"system",[a,i]=b.useState(xV),[o,c]=b.useState(bV),[u,h]=b.useState(mV),[f,m]=b.useState(yV),[g,y]=b.useState(!1),[v,w]=b.useState(!0),[N,k]=b.useState(!1),[C,E]=b.useState(""),[A,I]=b.useState(""),[D,_]=b.useState(!1),[P,L]=b.useState(!1),z=(R,O,X=!1)=>{E(R),I(O),_(X),k(!0)};b.useEffect(()=>{(async()=>{try{const O=await De("/api/admin/settings");if(!O||O.success===!1)return;if(O.featureConfig&&Object.keys(O.featureConfig).length&&c(X=>({...X,...O.featureConfig})),O.mpConfig&&typeof O.mpConfig=="object"&&h(X=>({...X,...O.mpConfig})),O.ossConfig&&typeof O.ossConfig=="object"&&m(X=>({...X,...O.ossConfig})),O.siteSettings&&typeof O.siteSettings=="object"){const X=O.siteSettings;i($=>({...$,...typeof X.sectionPrice=="number"&&{sectionPrice:X.sectionPrice},...typeof X.baseBookPrice=="number"&&{baseBookPrice:X.baseBookPrice},...typeof X.distributorShare=="number"&&{distributorShare:X.distributorShare},...X.authorInfo&&typeof X.authorInfo=="object"&&{authorInfo:{...$.authorInfo,...X.authorInfo}},...typeof X.ckbLeadApiKey=="string"&&{ckbLeadApiKey:X.ckbLeadApiKey}}))}}catch(O){console.error("Load settings error:",O)}finally{w(!1)}})()},[]);const ee=async(R,O)=>{L(!0);try{const X=await Nt("/api/admin/settings",{featureConfig:R});if(!X||X.success===!1){O(),z("保存失败",(X==null?void 0:X.error)??"未知错误",!0);return}z("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(X){console.error("Save feature config error:",X),O(),z("保存失败",X instanceof Error?X.message:String(X),!0)}finally{L(!1)}},U=(R,O)=>{const X=o,$={...X,[R]:O};c($),ee($,()=>c(X))},he=async()=>{y(!0);try{const R=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},ossConfig:{endpoint:f.endpoint||"",accessKeyId:f.accessKeyId||"",accessKeySecret:f.accessKeySecret||"",bucket:f.bucket||"",region:f.region||""}});if(!R||R.success===!1){z("保存失败",(R==null?void 0:R.error)??"未知错误",!0);return}z("已保存","设置已保存成功。")}catch(R){console.error("Save settings error:",R),z("保存失败",R instanceof Error?R.message:String(R),!0)}finally{y(!1)}},me=R=>{e(R==="system"?{}:{tab:R})};return v?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),r==="system"&&s.jsxs(ne,{onClick:he,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),g?"保存中...":"保存设置"]})]}),s.jsxs(Sd,{value:r,onValueChange:me,className:"w-full",children:[s.jsxs(Gl,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(tn,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(yo,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(tn,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(Am,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(tn,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(Hx,{className:"w-4 h-4 mr-2"}),"管理员"]}),s.jsxs(tn,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"API 文档"]})]}),s.jsx(nn,{value:"system",className:"mt-0",children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Am,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx(Ht,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Am,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(ie,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.name??"",onChange:R=>i(O=>({...O,authorInfo:{...O.authorInfo,name:R.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(hh,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(ie,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:a.authorInfo.startDate??"",onChange:R=>i(O=>({...O,authorInfo:{...O.authorInfo,startDate:R.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(hh,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(ie,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:a.authorInfo.liveTime??"",onChange:R=>i(O=>({...O,authorInfo:{...O.authorInfo,liveTime:R.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Zw,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(ie,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:a.authorInfo.platform??"",onChange:R=>i(O=>({...O,authorInfo:{...O.authorInfo,platform:R.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx($r,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(ie,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:a.authorInfo.description??"",onChange:R=>i(O=>({...O,authorInfo:{...O.authorInfo,description:R.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(Jl,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:a.authorInfo.bio??"",onChange:R=>i(O=>({...O,authorInfo:{...O.authorInfo,bio:R.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(vs,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(ie,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:a.ckbLeadApiKey??"",onChange:R=>i(O=>({...O,ckbLeadApiKey:R.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),s.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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)}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-semibold",children:a.authorInfo.name}),s.jsx("p",{className:"text-gray-400 text-xs",children:a.authorInfo.description}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",a.authorInfo.liveTime," · ",a.authorInfo.platform]})]})]})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(fh,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx(Ce,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.sectionPrice,onChange:R=>i(O=>({...O,sectionPrice:Number.parseFloat(R.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:a.baseBookPrice,onChange:R=>i(O=>({...O,baseBookPrice:Number.parseFloat(R.target.value)||9.9}))})]})]})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Ol,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsx(Ce,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:R=>h(O=>({...O,appId:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:R=>h(O=>({...O,withdrawSubscribeTmplId:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:R=>h(O=>({...O,mchId:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:R=>h(O=>({...O,minWithdraw:Number.parseFloat(R.target.value)||10}))})]})]})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(iM,{className:"w-5 h-5 text-[#38bdac]"}),"阿里云 OSS 配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置阿里云对象存储,用于图片和视频的云端存储(配置后将替代本地存储)"})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"Endpoint"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:f.endpoint??"",onChange:R=>m(O=>({...O,endpoint:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"Region"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:f.region??"",onChange:R=>m(O=>({...O,region:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"AccessKey ID"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"LTAI5t...",value:f.accessKeyId??"",onChange:R=>m(O=>({...O,accessKeyId:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"AccessKey Secret"}),s.jsx(ie,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"********",value:f.accessKeySecret??"",onChange:R=>m(O=>({...O,accessKeySecret:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2 col-span-2",children:[s.jsx(te,{className:"text-gray-300",children:"Bucket 名称"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"my-soul-bucket",value:f.bucket??"",onChange:R=>m(O=>({...O,bucket:R.target.value}))})]})]}),s.jsx("div",{className:`p-3 rounded-lg ${f.endpoint&&f.bucket&&f.accessKeyId?"bg-green-500/10 border border-green-500/30":"bg-amber-500/10 border border-amber-500/30"}`,children:s.jsx("p",{className:`text-xs ${f.endpoint&&f.bucket&&f.accessKeyId?"text-green-300":"text-amber-300"}`,children:f.endpoint&&f.bucket&&f.accessKeyId?`✅ OSS 已配置(${f.bucket}.${f.endpoint}),上传将自动使用云端存储`:"⚠ 未配置 OSS,当前上传存储在本地服务器。填写以上信息并保存后自动启用云端存储"})})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(yo,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx(Ht,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Mn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),s.jsx(Et,{id:"match-enabled",checked:o.matchEnabled,disabled:P,onCheckedChange:R=>U("matchEnabled",R)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(NM,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"})]}),s.jsx(Et,{id:"referral-enabled",checked:o.referralEnabled,disabled:P,onCheckedChange:R=>U("referralEnabled",R)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($r,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页搜索栏的显示"})]}),s.jsx(Et,{id:"search-enabled",checked:o.searchEnabled,disabled:P,onCheckedChange:R=>U("searchEnabled",R)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yo,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),s.jsx(Et,{id:"about-enabled",checked:o.aboutEnabled,disabled:P,onCheckedChange:R=>U("aboutEnabled",R)})]})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]})]})}),s.jsx(nn,{value:"author",className:"mt-0",children:s.jsx(fV,{})}),s.jsx(nn,{value:"admin",className:"mt-0",children:s.jsx(pV,{})}),s.jsx(nn,{value:"api-docs",className:"mt-0",children:s.jsx($4,{})})]}),s.jsx(Ft,{open:N,onOpenChange:k,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(Bt,{children:[s.jsx(Vt,{className:D?"text-red-400":"text-[#38bdac]",children:C}),s.jsx(Gj,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:A})]}),s.jsx(ln,{className:"mt-4",children:s.jsx(ne,{onClick:()=>k(!1),className:D?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const ww={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,r]=b.useState(ww),[a,i]=b.useState(""),o=async()=>{e(!0);try{const k=await De("/api/config");k!=null&&k.paymentMethods&&r({...ww,...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:"支付方式配置"}),de.success("配置已保存!")}catch(k){console.error("保存失败:",k),de.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)=>{r(E=>({...E,wechat:{...E.wechat,[k]:C}}))},f=(k,C)=>{r(E=>({...E,alipay:{...E.alipay,[k]:C}}))},m=(k,C)=>{r(E=>({...E,usdt:{...E.usdt,[k]:C}}))},g=(k,C)=>{r(E=>({...E,paypal:{...E.paypal,[k]:C}}))},y=n.wechat,v=n.alipay,w=n.usdt,N=n.paypal;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),s.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ne,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(ne,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(qw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),s.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[s.jsx("li",{children:"打开微信,进入目标微信群"}),s.jsx("li",{children:'点击右上角"..." → "群二维码"'}),s.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),s.jsx("li",{children:"在电脑上保存二维码图片,上传到图床获取URL"}),s.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示:微信群二维码7天后失效,建议使用活码工具"})]})]})}),s.jsxs(Sd,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Gl,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(tn,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(Ol,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(tn,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(Bv,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(tn,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx($v,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(tn,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(Og,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(nn,{value:"wechat",className:"space-y-4",children:s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(Ge,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(Ol,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(Et,{checked:!!y.enabled,onCheckedChange:k=>h("enabled",k)})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"网站AppID"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"商户号"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:k=>h("merchantId",k.target.value)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(Us,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(ie,{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)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),s.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[s.jsx(te,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(ie,{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)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(nn,{value:"alipay",className:"space-y-4",children:s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(Ge,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(Bv,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(Et,{checked:!!v.enabled,onCheckedChange:k=>f("enabled",k)})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(v.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),s.jsx(ne,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(v.partnerId??""),"pid"),children:a==="pid"?s.jsx(xf,{className:"w-4 h-4 text-green-500"}):s.jsx(Jw,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(ie,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(v.securityKey??""),onChange:k=>f("securityKey",k.target.value)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(Us,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(v.qrCode??""),onChange:k=>f("qrCode",k.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(nn,{value:"usdt",className:"space-y-4",children:s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(Ge,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx($v,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(Et,{checked:!!w.enabled,onCheckedChange:k=>m("enabled",k)})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"网络类型"}),s.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(w.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[s.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),s.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),s.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"收款地址"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(w.address??""),onChange:k=>m("address",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:k=>m("exchangeRate",Number.parseFloat(k.target.value)||7.2)})]})]})]})}),s.jsx(nn,{value:"paypal",className:"space-y-4",children:s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(Ge,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(Og,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(Et,{checked:!!N.enabled,onCheckedChange:k=>g("enabled",k)})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(N.email??""),onChange:k=>g("email",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(N.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,r]=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:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),de.success("配置已保存")}catch(f){console.error(f),de.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{i(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),s.jsxs(ne,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Og,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(ie,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(ie,{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}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(ie,{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}}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(ie,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(ie,{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}}))})]})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(uA,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx(Ce,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(te,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ie,{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}}))}),s.jsx(ie,{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}}))})]})]}),s.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(sA,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx(Ce,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[s.jsx(Et,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(ie,{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}}}))})]}),s.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(yM,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"首页标题"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"首页副标题"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目录页标题"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"我的页标题"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(ie,{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,r]=b.useState(""),[a,i]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,v,w,N;try{const k=await De("/api/config"),C=(v=(y=k==null?void 0:k.liveQRCodes)==null?void 0:y[0])==null?void 0:v.urls;Array.isArray(C)&&e(C.join(` +`));const E=(N=(w=k==null?void 0:k.paymentMethods)==null?void 0:w.wechat)==null?void 0:N.groupQrCode;E&&r(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,v)=>{navigator.clipboard.writeText(y),i(v),setTimeout(()=>i(""),2e3)},f=async()=>{try{const y=t.split(` +`).map(w=>w.trim()).filter(Boolean),v=[...o.liveQRCodes||[]];v[0]?v[0].urls=y:v.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Nt("/api/db/config",{key:"live_qr_codes",value:v,description:"群活码配置"}),de.success("群活码配置已保存!"),await u()}catch(y){console.error(y),de.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:"支付方式配置"}),de.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(v){console.error(v),de.error("保存失败: "+(v instanceof Error?v.message:String(v)))}},g=()=>{n?window.open(n,"_blank"):de.error("请先配置微信群链接")};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(qw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),s.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[s.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:"访问草料二维码创建活码"}),s.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),s.jsx("li",{children:"复制生成的短链接填入下方配置"}),s.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),s.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),s.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意:微信原生群二维码7天后失效,建议使用草料活码"})]})]})]})}),s.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(Hv,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx(Ht,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Dg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ie,{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=>r(y.target.value)}),s.jsx(ne,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?s.jsx(xf,{className:"w-4 h-4 text-green-500"}):s.jsx(Jw,{className:"w-4 h-4 text-gray-400"})})]}),s.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[s.jsx(Us,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ne,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(ph,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(ne,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(Us,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Hv,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs(Ce,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Dg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(Jl,{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)}),s.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),s.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),s.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` +`).filter(Boolean).length," 个"]})]}),s.jsxs(ne,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(ph,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),s.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[s.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),s.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接,群满后可直接在后台更换新群码,无需修改网站配置。微信原生群码7天失效。"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),s.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const jw={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(jw),[n,r]=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()=>{r(!0);try{const E=await De("/api/db/config/full?key=match_config"),A=(E==null?void 0:E.data)??(E==null?void 0:E.config);A&&e({...jw,...A})}catch(E){console.error("加载匹配配置失败:",E)}finally{r(!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?de.success("配置保存成功!"):de.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:"未知错误"))}catch(E){console.error("保存配置失败:",E),de.error("保存失败")}finally{i(!1)}},v=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)},w=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},N=()=>{if(!f.id||!f.label){de.error("请填写类型ID和名称");return}const E=[...t.matchTypes];if(u){const A=E.findIndex(I=>I.id===u.id);A!==-1&&(E[A]={...f})}else{if(E.some(A=>A.id===f.id)){de.error("类型ID已存在");return}E.push({...f})}e({...t,matchTypes:E}),c(!1)},k=E=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(A=>A.id!==E)})},C=E=>{e({...t,matchTypes:t.matchTypes.map(A=>A.id===E?{...A,enabled:!A.enabled}:A)})};return s.jsxs("div",{className:"p-8 w-full space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(yo,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ne,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(ne,{onClick:y,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(xi,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ce,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(ie,{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})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(ie,{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})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(ie,{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}})}),s.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:t.settings.enableFreeMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enableFreeMatches:E}})}),s.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:t.settings.enablePaidMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enablePaidMatches:E}})}),s.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ne,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(pn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(Ce,{children:s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"图标"}),s.jsx(Ee,{className:"text-gray-400",children:"类型ID"}),s.jsx(Ee,{className:"text-gray-400",children:"显示名称"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配标签"}),s.jsx(Ee,{className:"text-gray-400",children:"价格"}),s.jsx(Ee,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(Ee,{className:"text-gray-400",children:"状态"}),s.jsx(Ee,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(gr,{children:t.matchTypes.map(E=>s.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx("span",{className:"text-2xl",children:E.icon})}),s.jsx(be,{className:"font-mono text-gray-300",children:E.id}),s.jsx(be,{className:"text-white font-medium",children:E.label}),s.jsx(be,{className:"text-gray-300",children:E.matchLabel}),s.jsx(be,{children:s.jsxs(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",E.price]})}),s.jsx(be,{children:E.matchFromDB?s.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(be,{children:s.jsx(Et,{checked:E.enabled,onCheckedChange:()=>C(E.id)})}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(E),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx($t,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>k(E.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(er,{className:"w-4 h-4"})})]})})]},E.id))})]})})]}),s.jsx(Ft,{open:o,onOpenChange:c,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[u?s.jsx($t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:E=>m({...f,id:E.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:TV.map(E=>s.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))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"显示名称"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:E=>m({...f,label:E.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"匹配标签"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:E=>m({...f,matchLabel:E.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(ie,{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})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.matchFromDB,onCheckedChange:E=>m({...f,matchFromDB:E})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.showJoinAfterMatch,onCheckedChange:E=>m({...f,showJoinAfterMatch:E})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.enabled,onCheckedChange:E=>m({...f,enabled:E})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ne,{onClick:N,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const kw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function AV(){const[t,e]=b.useState([]),[n,r]=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 v(){m(!0),y(null);try{const N=new URLSearchParams({page:String(a),pageSize:String(o)});u&&N.set("matchType",u);const k=await De(`/api/db/match-records?${N}`);k!=null&&k.success?(e(k.records||[]),r(k.total??0)):y("加载匹配记录失败")}catch(N){console.error("加载匹配记录失败",N),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{v()},[a,u]);const w=Math.ceil(n/o)||1;return s.jsxs("div",{className:"p-8 w-full",children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:N=>{h(N.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(kw).map(([N,k])=>s.jsx("option",{value:N,children:k},N))]}),s.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:[s.jsx(Ue,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"发起人"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配到"}),s.jsx(Ee,{className:"text-gray-400",children:"类型"}),s.jsx(Ee,{className:"text-gray-400",children:"联系方式"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(gr,{children:[t.map(N=>s.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:[N.userAvatar?s.jsx("img",{src:N.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,s.jsx("span",{className:N.userAvatar?"hidden":"",children:(N.userNickname||N.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:N.userNickname||N.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[N.userId.slice(0,16),"..."]})]})]})}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:[N.matchedUserAvatar?s.jsx("img",{src:N.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,s.jsx("span",{className:N.matchedUserAvatar?"hidden":"",children:(N.matchedNickname||N.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:N.matchedNickname||N.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[N.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(be,{children:s.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:kw[N.matchType]||N.matchType})}),s.jsxs(be,{className:"text-gray-400 text-sm",children:[N.phone&&s.jsxs("div",{children:["📱 ",N.phone]}),N.wechatId&&s.jsxs("div",{children:["💬 ",N.wechatId]}),!N.phone&&!N.wechatId&&"-"]}),s.jsx(be,{className:"text-gray-400",children:N.createdAt?new Date(N.createdAt).toLocaleString():"-"})]},N.id)),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(Ns,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:N=>{c(N),i(1)}})]})})})]})}function IV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0);async function a(){r(!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),de.error("加载 VIP 成员失败")}finally{r(!1)}}return b.useEffect(()=>{a()},[]),s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("div",{className:"flex justify-between items-center mb-8",children:s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Ml,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(Ee,{className:"text-gray-400",children:"成员"}),s.jsx(Ee,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(Ee,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(gr,{children:[t.map((i,o)=>{var c;return s.jsxs(lt,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:o+1}),s.jsx(be,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?s.jsx("img",{src:i.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.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])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:i.name})})]})}),s.jsx(be,{className:"text-gray-300",children:i.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(be,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function F4(t){const[e,n]=b.useState([]),[r,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,v]=b.useState(!1),w=b.useRef(null),N=async P=>{var z;const L=(z=P.target.files)==null?void 0:z[0];if(L){v(!0);try{const ee=new FormData;ee.append("file",L),ee.append("folder","mentors");const U=Ux(),he={};U&&(he.Authorization=`Bearer ${U}`);const R=await(await fetch(wa("/api/upload"),{method:"POST",body:ee,credentials:"include",headers:he})).json();R!=null&&R.success&&(R!=null&&R.url)?f(O=>({...O,avatar:R.url})):de.error("上传失败: "+((R==null?void 0:R.error)||"未知错误"))}catch(ee){console.error(ee),de.error("上传失败")}finally{v(!1),w.current&&(w.current.value="")}}};async function k(){a(!0);try{const P=await De("/api/db/mentors");P!=null&&P.success&&P.data&&n(P.data)}catch(P){console.error("Load mentors error:",P)}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(P=>P.sort))+1:0,enabled:!0})},E=()=>{u(null),C(),o(!0)},A=P=>{u(P),f({name:P.name,avatar:P.avatar||"",intro:P.intro||"",tags:P.tags||"",priceSingle:P.priceSingle!=null?String(P.priceSingle):"",priceHalfYear:P.priceHalfYear!=null?String(P.priceHalfYear):"",priceYear:P.priceYear!=null?String(P.priceYear):"",quote:P.quote||"",whyFind:P.whyFind||"",offering:P.offering||"",judgmentStyle:P.judgmentStyle||"",sort:P.sort,enabled:P.enabled??!0}),o(!0)},I=async()=>{if(!h.name.trim()){de.error("导师姓名不能为空");return}g(!0);try{const P=z=>z===""?void 0:parseFloat(z),L={name:h.name.trim(),avatar:h.avatar.trim()||void 0,intro:h.intro.trim()||void 0,tags:h.tags.trim()||void 0,priceSingle:P(h.priceSingle),priceHalfYear:P(h.priceHalfYear),priceYear:P(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 z=await Tt("/api/db/mentors",{id:c.id,...L});z!=null&&z.success?(o(!1),k()):de.error("更新失败: "+(z==null?void 0:z.error))}else{const z=await Nt("/api/db/mentors",L);z!=null&&z.success?(o(!1),k()):de.error("新增失败: "+(z==null?void 0:z.error))}}catch(P){console.error("Save error:",P),de.error("保存失败")}finally{g(!1)}},D=async P=>{if(confirm("确定删除该导师?"))try{const L=await Na(`/api/db/mentors?id=${P}`);L!=null&&L.success?k():de.error("删除失败: "+(L==null?void 0:L.error))}catch(L){console.error("Delete error:",L),de.error("删除失败")}},_=P=>P!=null?`¥${P}`:"-";return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Mn,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),s.jsxs(ne,{onClick:E,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(pn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-0",children:r?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"ID"}),s.jsx(Ee,{className:"text-gray-400",children:"姓名"}),s.jsx(Ee,{className:"text-gray-400",children:"简介"}),s.jsx(Ee,{className:"text-gray-400",children:"单次"}),s.jsx(Ee,{className:"text-gray-400",children:"半年"}),s.jsx(Ee,{className:"text-gray-400",children:"年度"}),s.jsx(Ee,{className:"text-gray-400",children:"排序"}),s.jsx(Ee,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(gr,{children:[e.map(P=>s.jsxs(lt,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:P.id}),s.jsx(be,{className:"text-white",children:P.name}),s.jsx(be,{className:"text-gray-400 max-w-[200px] truncate",children:P.intro||"-"}),s.jsx(be,{className:"text-gray-400",children:_(P.priceSingle)}),s.jsx(be,{className:"text-gray-400",children:_(P.priceHalfYear)}),s.jsx(be,{className:"text-gray-400",children:_(P.priceYear)}),s.jsx(be,{className:"text-gray-400",children:P.sort}),s.jsxs(be,{className:"text-right",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>A(P),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx($t,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>D(P.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(er,{className:"w-4 h-4"})})]})]},P.id)),e.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Ft,{open:i,onOpenChange:o,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(Bt,{children:s.jsx(Vt,{className:"text-white",children:c?"编辑导师":"新增导师"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"姓名 *"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:h.name,onChange:P=>f(L=>({...L,name:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"排序"}),s.jsx(ie,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:h.sort,onChange:P=>f(L=>({...L,sort:parseInt(P.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ie,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:h.avatar,onChange:P=>f(L=>({...L,avatar:P.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:w,type:"file",accept:"image/*",className:"hidden",onChange:N}),s.jsxs(ne,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:y,onClick:()=>{var P;return(P=w.current)==null?void 0:P.click()},children:[s.jsx(ph,{className:"w-4 h-4 mr-2"}),y?"上传中...":"上传"]})]}),h.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:h.avatar.startsWith("http")?h.avatar:wa(h.avatar),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"简介"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:h.intro,onChange:P=>f(L=>({...L,intro:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:h.tags,onChange:P=>f(L=>({...L,tags:P.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(te,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(ie,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:h.priceSingle,onChange:P=>f(L=>({...L,priceSingle:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(ie,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:h.priceHalfYear,onChange:P=>f(L=>({...L,priceHalfYear:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(ie,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:h.priceYear,onChange:P=>f(L=>({...L,priceYear:P.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"引言"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:h.quote,onChange:P=>f(L=>({...L,quote:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.whyFind,onChange:P=>f(L=>({...L,whyFind:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.offering,onChange:P=>f(L=>({...L,offering:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:h.judgmentStyle,onChange:P=>f(L=>({...L,judgmentStyle:P.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:h.enabled,onChange:P=>f(L=>({...L,enabled:P.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(te,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(ln,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>o(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(nr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:I,disabled:m,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"}),m?"保存中...":"保存"]})]})]})})]})}function RV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[a,i]=b.useState("");async function o(){r(!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{r(!1)}}b.useEffect(()=>{o()},[a]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(hh,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>s.jsx("option",{value:h,children:f},h))]}),s.jsxs(ne,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"ID"}),s.jsx(Ee,{className:"text-gray-400",children:"用户ID"}),s.jsx(Ee,{className:"text-gray-400",children:"导师ID"}),s.jsx(Ee,{className:"text-gray-400",children:"类型"}),s.jsx(Ee,{className:"text-gray-400",children:"金额"}),s.jsx(Ee,{className:"text-gray-400",children:"状态"}),s.jsx(Ee,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(gr,{children:[t.map(h=>s.jsxs(lt,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:h.id}),s.jsx(be,{className:"text-gray-400",children:h.userId}),s.jsx(be,{className:"text-gray-400",children:h.mentorId}),s.jsx(be,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(be,{className:"text-white",children:["¥",h.amount]}),s.jsx(be,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(be,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const Uc={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},Sw={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:Uc},PV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function OV(){const t=Oi(),[e,n]=b.useState(Sw),[r,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,v]=b.useState(null),[w,N]=b.useState(!1),k=async()=>{N(!0);try{const L=await De("/api/db/match-pool-counts");L!=null&&L.success&&L.data&&v(L.data)}catch(L){console.error("加载池子人数失败:",L)}finally{N(!1)}},C=async()=>{a(!0);try{const L=await De("/api/db/config/full?key=match_config"),z=(L==null?void 0:L.data)??(L==null?void 0:L.config);if(z){let ee=z.poolSettings??Uc;ee.poolSource&&!Array.isArray(ee.poolSource)&&(ee={...ee,poolSource:[ee.poolSource]}),n({...Sw,...z,poolSettings:ee})}}catch(L){console.error("加载匹配配置失败:",L)}finally{a(!1)}};b.useEffect(()=>{C(),k()},[]);const E=async()=>{o(!0);try{const L=await Nt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});de.error((L==null?void 0:L.success)!==!1?"配置保存成功!":"保存失败: "+((L==null?void 0:L.error)||"未知错误"))}catch(L){console.error(L),de.error("保存失败")}finally{o(!1)}},A=L=>{f(L),g({...L}),u(!0)},I=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},D=()=>{if(!m.id||!m.label){de.error("请填写类型ID和名称");return}const L=[...e.matchTypes];if(h){const z=L.findIndex(ee=>ee.id===h.id);z!==-1&&(L[z]={...m})}else{if(L.some(z=>z.id===m.id)){de.error("类型ID已存在");return}L.push({...m})}n({...e,matchTypes:L}),u(!1)},_=L=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(z=>z.id!==L)})},P=L=>{n({...e,matchTypes:e.matchTypes.map(z=>z.id===L?{...z,enabled:!z.enabled}:z)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(ne,{variant:"outline",onClick:C,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(ne,{onClick:E,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Yw,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx(Ht,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs(Ce,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(te,{className:"text-gray-300",children:"匹配来源池"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),s.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(L=>{const z=e.poolSettings??Uc,U=(Array.isArray(z.poolSource)?z.poolSource:[z.poolSource]).includes(L.value),he=y==null?void 0:y[L.countKey],me=()=>{const R=Array.isArray(z.poolSource)?[...z.poolSource]:[z.poolSource],O=U?R.filter(X=>X!==L.value):[...R,L.value];O.length===0&&O.push(L.value),n({...e,poolSettings:{...z,poolSource:O}})};return s.jsxs("button",{type:"button",onClick:me,className:`p-4 rounded-lg border text-left transition-all ${U?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${U?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:U&&"✓"}),s.jsx("span",{className:"text-xl",children:L.icon}),s.jsx("span",{className:`text-sm font-medium ${U?"text-[#38bdac]":"text-gray-300"}`,children:L.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":he??"-",s.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:L.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:R=>{R.stopPropagation(),t(`/users?pool=${L.value}`)},onKeyDown:R=>{R.key==="Enter"&&(R.stopPropagation(),t(`/users?pool=${L.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},L.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(te,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),s.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(L=>{const ee=(e.poolSettings??Uc)[L.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(Et,{checked:ee,onCheckedChange:U=>n({...e,poolSettings:{...e.poolSettings??Uc,[L.key]:U}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:L.icon}),s.jsx(te,{className:"text-gray-300 text-sm",children:L.label})]})]},L.key)})})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(qe,{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(xi,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ce,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(ie,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:L=>n({...e,freeMatchLimit:parseInt(L.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(ie,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:L=>n({...e,matchPrice:parseFloat(L.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(ie,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:L=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(L.target.value,10)||10}})})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:e.settings.enableFreeMatches,onCheckedChange:L=>n({...e,settings:{...e.settings,enableFreeMatches:L}})}),s.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:e.settings.enablePaidMatches,onCheckedChange:L=>n({...e,settings:{...e.settings,enablePaidMatches:L}})}),s.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(qe,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(Ge,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(Ht,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ne,{onClick:I,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(pn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(Ce,{children:s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"图标"}),s.jsx(Ee,{className:"text-gray-400",children:"类型ID"}),s.jsx(Ee,{className:"text-gray-400",children:"显示名称"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配标签"}),s.jsx(Ee,{className:"text-gray-400",children:"价格"}),s.jsx(Ee,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(Ee,{className:"text-gray-400",children:"状态"}),s.jsx(Ee,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(gr,{children:e.matchTypes.map(L=>s.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx("span",{className:"text-2xl",children:L.icon})}),s.jsx(be,{className:"font-mono text-gray-300",children:L.id}),s.jsx(be,{className:"text-white font-medium",children:L.label}),s.jsx(be,{className:"text-gray-300",children:L.matchLabel}),s.jsx(be,{children:s.jsxs(Ke,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",L.price]})}),s.jsx(be,{children:L.matchFromDB?s.jsx(Ke,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ke,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(be,{children:s.jsx(Et,{checked:L.enabled,onCheckedChange:()=>P(L.id)})}),s.jsx(be,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>A(L),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx($t,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>_(L.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(er,{className:"w-4 h-4"})})]})})]},L.id))})]})})]}),s.jsx(Ft,{open:c,onOpenChange:u,children:s.jsxs(Rt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Bt,{children:s.jsxs(Vt,{className:"text-white flex items-center gap-2",children:[h?s.jsx($t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:L=>g({...m,id:L.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:PV.map(L=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===L?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:L}),children:L},L))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"显示名称"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:L=>g({...m,label:L.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"匹配标签"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:L=>g({...m,matchLabel:L.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(ie,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:L=>g({...m,price:parseFloat(L.target.value)||1})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.matchFromDB,onCheckedChange:L=>g({...m,matchFromDB:L})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.showJoinAfterMatch,onCheckedChange:L=>g({...m,showJoinAfterMatch:L})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.enabled,onCheckedChange:L=>g({...m,enabled:L})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(ln,{children:[s.jsx(ne,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ne,{onClick:D,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const Cw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function DV(){const[t,e]=b.useState([]),[n,r]=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),[v,w]=b.useState(null);async function N(){m(!0),y(null);try{const E=new URLSearchParams({page:String(a),pageSize:String(o)});u&&E.set("matchType",u);const A=await De(`/api/db/match-records?${E}`);A!=null&&A.success?(e(A.records||[]),r(A.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{N()},[a,u]);const k=Math.ceil(n/o)||1,C=({userId:E,nickname:A,avatar:I})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>w(E),children:[s.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:[I?s.jsx("img",{src:I,alt:"",className:"w-full h-full object-cover",onError:D=>{D.currentTarget.style.display="none"}}):null,s.jsx("span",{className:I?"hidden":"",children:(A||E||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:A||E}),s.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 s.jsxs("div",{children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.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:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(Cw).map(([E,A])=>s.jsx("option",{value:E,children:A},E))]}),s.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:[s.jsx(Ue,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"发起人"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配到"}),s.jsx(Ee,{className:"text-gray-400",children:"类型"}),s.jsx(Ee,{className:"text-gray-400",children:"联系方式"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(gr,{children:[t.map(E=>s.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{children:s.jsx(C,{userId:E.userId,nickname:E.userNickname,avatar:E.userAvatar})}),s.jsx(be,{children:E.matchedUserId?s.jsx(C,{userId:E.matchedUserId,nickname:E.matchedNickname,avatar:E.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(be,{children:s.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Cw[E.matchType]||E.matchType})}),s.jsxs(be,{className:"text-sm",children:[E.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&s.jsx("span",{className:"text-gray-600",children:"-"})]}),s.jsx(be,{className:"text-gray-400",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"})]},E.id)),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(Ns,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})}),s.jsx(a0,{open:!!v,onClose:()=>w(null),userId:v,onUserUpdated:N})]})}function LV(){const[t,e]=b.useState("records");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"匹配记录"}),s.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"&&s.jsx(DV,{}),t==="pool"&&s.jsx(OV,{})]})}const Ew={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function _V(){const[t,e]=b.useState([]),[n,r]=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 v(){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||[]),r(E.total??0))}catch(C){console.error(C)}finally{h(!1)}}b.useEffect(()=>{v()},[a,f]);const w=async C=>{if(!C.phone&&!C.wechatId){de.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||""});de.error((E==null?void 0:E.message)||(E!=null&&E.success?"推送成功":"推送失败"))}catch(E){de.error("推送失败: "+(E instanceof Error?E.message:"网络错误"))}finally{y(null)}},N=Math.ceil(n/o)||1,k=C=>!!(C.phone||C.wechatId);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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(Ew).map(([C,E])=>s.jsx("option",{value:C,children:E},C))}),s.jsxs(ne,{onClick:v,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"发起人"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配到"}),s.jsx(Ee,{className:"text-gray-400",children:"类型"}),s.jsx(Ee,{className:"text-gray-400",children:"联系方式"}),s.jsx(Ee,{className:"text-gray-400",children:"时间"}),s.jsx(Ee,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(gr,{children:[t.map(C=>{var E,A;return s.jsxs(lt,{className:`border-gray-700/50 ${k(C)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(be,{className:"text-white",children:C.userNickname||((E=C.userId)==null?void 0:E.slice(0,12))}),s.jsx(be,{className:"text-white",children:C.matchedNickname||((A=C.matchedUserId)==null?void 0:A.slice(0,12))}),s.jsx(be,{children:s.jsx(Ke,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Ew[C.matchType]||C.matchType})}),s.jsxs(be,{className:"text-sm",children:[C.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(be,{className:"text-gray-400 text-sm",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"}),s.jsx(be,{className:"text-right",children:k(C)?s.jsxs(ne,{size:"sm",onClick:()=>w(C),disabled:g===C.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(IA,{className:"w-3 h-3 mr-1"}),g===C.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},C.id)}),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(Ns,{page:a,totalPages:N,total:n,pageSize:o,onPageChange:i,onPageSizeChange:C=>{c(C),i(1)}})]})})})]})}const Tw={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},zV={single:"单次",half_year:"半年",year:"年度"};function $V(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[a,i]=b.useState("");async function o(){r(!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{r(!1)}}return b.useEffect(()=>{o()},[a]),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(Tw).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(ne,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ce,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"ID"}),s.jsx(Ee,{className:"text-gray-400",children:"用户ID"}),s.jsx(Ee,{className:"text-gray-400",children:"导师ID"}),s.jsx(Ee,{className:"text-gray-400",children:"类型"}),s.jsx(Ee,{className:"text-gray-400",children:"金额"}),s.jsx(Ee,{className:"text-gray-400",children:"状态"}),s.jsx(Ee,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(gr,{children:[t.map(c=>s.jsxs(lt,{className:"border-gray-700/50",children:[s.jsx(be,{className:"text-gray-300",children:c.id}),s.jsx(be,{className:"text-gray-400",children:c.userId}),s.jsx(be,{className:"text-gray-400",children:c.mentorId}),s.jsx(be,{className:"text-gray-400",children:zV[c.consultationType]||c.consultationType}),s.jsxs(be,{className:"text-white",children:["¥",c.amount]}),s.jsx(be,{className:"text-gray-400",children:Tw[c.status]||c.status}),s.jsx(be,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function FV(){const[t,e]=b.useState("booking");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"预约记录"}),s.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"&&s.jsx($V,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(F4,{embedded:!0})})]})}function BV(){const[t,e]=b.useState([]),[n,r]=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||[]),r(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}b.useEffect(()=>{f()},[a]);const m=Math.ceil(n/o)||1;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),s.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),s.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:[s.jsx(Ue,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ce,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ue,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(pr,{children:[s.jsx(mr,{children:s.jsxs(lt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Ee,{className:"text-gray-400",children:"发起人"}),s.jsx(Ee,{className:"text-gray-400",children:"匹配到"}),s.jsx(Ee,{className:"text-gray-400",children:"联系方式"}),s.jsx(Ee,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(gr,{children:[t.map(g=>s.jsxs(lt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(be,{className:"text-white",children:g.userNickname||g.userId}),s.jsx(be,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),s.jsxs(be,{className:"text-gray-400 text-sm",children:[g.phone&&s.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&s.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),s.jsx(be,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&s.jsx(lt,{children:s.jsx(be,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(Ns,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:g=>{c(g),i(1)}})]})})})]})}const Mw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"},Aw={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮"};function VV({onSwitchTab:t,onOpenCKB:e}={}){const n=Oi(),[r,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,v]=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 w=y.value.data;if(w.totalMatches>0&&(!w.uniqueUsers||w.uniqueUsers===0))try{const N=await De("/api/db/match-records?page=1&pageSize=200");if(N!=null&&N.success&&N.records){const k=new Set(N.records.map(C=>C.userId).filter(Boolean));w={...w,uniqueUsers:k.size}}}catch{}a(w)}v.status==="fulfilled"&&((g=v.value)!=null&&g.success)&&v.value.data&&o(v.value.data)}catch(y){console.error("加载统计失败:",y)}finally{u(!1)}},[]);b.useEffect(()=>{h()},[h]);const f=m=>c?"—":String(m??0);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx(Mn,{className:"w-5 h-5 text-[#38bdac]"})," 找伙伴数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",children:[s.jsx(Se,{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:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"总匹配次数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.totalMatches)}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-3 flex items-center gap-1",children:[s.jsx(Us,{className:"w-3 h-3"})," 查看匹配记录"]})]})}),s.jsx(Se,{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:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"今日匹配"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.todayMatches)}),s.jsxs("p",{className:"text-yellow-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(xi,{className:"w-3 h-3"})," 今日实时"]})]})}),s.jsx(Se,{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:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"匹配用户数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.uniqueUsers)}),s.jsxs("p",{className:"text-blue-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(Us,{className:"w-3 h-3"})," 查看用户管理"]})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"人均匹配"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":r!=null&&r.uniqueUsers?(r.totalMatches/r.uniqueUsers).toFixed(1):"0"})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"付费匹配次数"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:f(r==null?void 0:r.paidMatchCount)})]})})]})]}),(r==null?void 0:r.byType)&&r.byType.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"各类型匹配分布"}),s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:r.byType.map(m=>{const g=r.totalMatches>0?m.count/r.totalMatches*100:0;return s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/40 rounded-xl p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("span",{className:"text-2xl",children:Aw[m.matchType]||"📊"}),s.jsx("span",{className:"text-gray-300 font-medium",children:Mw[m.matchType]||m.matchType})]}),s.jsx("p",{className:"text-3xl font-bold text-white mb-2",children:m.count}),s.jsx("div",{className:"w-full h-2 bg-gray-700/50 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full transition-all",style:{width:`${Math.min(g,100)}%`}})}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1.5",children:[g.toFixed(1),"%"]})]},m.matchType)})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx(vs,{className:"w-5 h-5 text-orange-400"})," AI 获客数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5 mb-6",children:[s.jsx(Se,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(i==null?void 0:i.ckbTotal)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("contact"),children:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(i==null?void 0:i.withContact)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Se,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("test"),children:s.jsxs(Ce,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"AI 添加进度"}),s.jsx("p",{className:"text-xl font-bold text-orange-400",children:"查看详情 →"}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"添加成功率 · 回复率 · API 文档"})]})})]}),(i==null?void 0:i.byType)&&i.byType.length>0&&s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:i.byType.map(m=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-lg p-4 flex items-center gap-3",children:[s.jsx("span",{className:"text-xl",children:Aw[m.matchType]||"📋"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-xs",children:Mw[m.matchType]||m.matchType}),s.jsx("p",{className:"text-xl font-bold text-white",children:m.total})]})]},m.matchType))})]})]})}const HV=["partner","investor","mentor","team"],kg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Iw=`# 场景获客接口摘要 +- 地址: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),[r,a]=b.useState("13800000000"),[i,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(Iw),[m,g]=b.useState(!1),[y,v]=b.useState(!1),[w,N]=b.useState([]),[k,C]=b.useState([]),[E,A]=b.useState({}),[I,D]=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"}]),_=b.useMemo(()=>{const R={};return kg.forEach(O=>{R[O.key]=E[O.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),R},[E]),P=R=>{const O=r.trim(),X=i.trim();return R<=3?{type:HV[R],phone:O||void 0,wechat:X||void 0,userId:"admin_test",name:"后台测试"}:R===4?{matchType:"partner",phone:O||void 0,wechat:X||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:R===5?{phone:O||void 0,wechatId:X||void 0,userId:"admin_test",name:"后台测试"}:{}};async function L(){v(!0);try{const[R,O,X]=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")]),$=R==null?void 0:R.data;$!=null&&$.routes&&A($.routes),$!=null&&$.docNotes&&u($.docNotes),$!=null&&$.docContent&&f($.docContent),O!=null&&O.success&&N(O.records||[]),X!=null&&X.success&&C(X.records||[])}finally{v(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{L()},[]);async function z(){g(!0);try{const R=await Nt("/api/db/config",{key:"ckb_config",value:{routes:_,docNotes:c,docContent:h},description:"存客宝接口配置"});de.error((R==null?void 0:R.success)!==!1?"存客宝配置已保存":`保存失败: ${(R==null?void 0:R.error)||"未知错误"}`)}catch(R){de.error(`保存失败: ${R instanceof Error?R.message:"网络错误"}`)}finally{g(!1)}}const ee=(R,O)=>{A(X=>({...X,[R]:{..._[R],...O}}))},U=async R=>{const O=I[R];if(O.method==="POST"&&!r.trim()&&!i.trim()){de.error("请填写测试手机号");return}const X=[...I];X[R]={...O,status:"testing",message:void 0,responseTime:void 0},D(X);const $=performance.now();try{const le=O.method==="GET"?await De(O.endpoint):await Nt(O.endpoint,P(R)),Y=Math.round(performance.now()-$),F=(le==null?void 0:le.message)||"",W=(le==null?void 0:le.success)===!0||F.includes("已存在")||F.includes("已加入")||F.includes("已提交"),K=[...I];K[R]={...O,status:W?"success":"error",message:F||(W?"正常":"异常"),responseTime:Y},D(K),await L()}catch(le){const Y=Math.round(performance.now()-$),F=[...I];F[R]={...O,status:"error",message:le instanceof Error?le.message:"失败",responseTime:Y},D(F)}},he=async()=>{if(!r.trim()&&!i.trim()){de.error("请填写测试手机号");return}for(let R=0;Rs.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),s.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),s.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),s.jsx("tbody",{children:R.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:O})}):R.map(X=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:X.userNickname||X.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:X.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:X.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:X.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:X.createdAt?new Date(X.createdAt).toLocaleString():"—"})]},X.id))})]})});return s.jsx(Se,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs(Ce,{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),s.jsx(Ke,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),s.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[s.jsx(Us,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ne,{onClick:()=>L(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ue,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),s.jsxs(ne,{onClick:z,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(mn,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),s.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([R,O])=>s.jsx("button",{type:"button",onClick:()=>n(R),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===R?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:O},R))}),e==="overview"&&s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:w.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:k.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:kg.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),s.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&me(w,"暂无已提交线索"),e==="contact"&&me(k,"暂无有联系方式线索"),e==="config"&&s.jsx("div",{className:"space-y-4",children:kg.map(R=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white font-medium",children:R.label}),s.jsx(Ke,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:R.key})]}),s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(ie,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[R.key].apiUrl,onChange:O=>ee(R.key,{apiUrl:O.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(ie,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[R.key].apiKey,onChange:O=>ee(R.key,{apiKey:O.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(ie,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[R.key].source,onChange:O=>ee(R.key,{source:O.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(ie,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[R.key].tags,onChange:O=>ee(R.key,{tags:O.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(ie,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[R.key].siteTags,onChange:O=>ee(R.key,{siteTags:O.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(ie,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:_[R.key].notes,onChange:O=>ee(R.key,{notes:O.target.value})})]})]})]},R.key))}),e==="test"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex gap-3 mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(Ol,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:R=>a(R.target.value)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(ie,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:R=>o(R.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(ne,{onClick:he,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(xi,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:I.map((R,O)=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[R.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),R.status==="testing"&&s.jsx(Ue,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),R.status==="success"&&s.jsx(Ig,{className:"w-3 h-3 text-green-400 shrink-0"}),R.status==="error"&&s.jsx(Gw,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:R.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[R.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[R.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>U(O),disabled:R.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${R.endpoint}-${O}`))})]}),e==="doc"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),s.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:[s.jsx(Us,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Iw})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),s.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:R=>u(R.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const UV=[{id:"stats",label:"数据统计",icon:Ag},{id:"partner",label:"找伙伴",icon:Mn},{id:"resource",label:"资源对接",icon:MM},{id:"mentor",label:"导师预约",icon:CM},{id:"team",label:"团队招募",icon:zg}];function KV(){const[t,e]=b.useState("stats"),[n,r]=b.useState(!1),[a,i]=b.useState("overview");return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Mn,{className:"w-6 h-6 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"数据统计、匹配池与记录、资源对接、导师预约、团队招募"})]}),s.jsxs(ne,{type:"button",variant:"outline",onClick:()=>r(o=>!o),className:"border-orange-500/40 text-orange-300 hover:bg-orange-500/10 bg-transparent",children:[s.jsx(vs,{className:"w-4 h-4 mr-2"}),"存客宝"]})]}),n&&s.jsx(WV,{initialTab:a}),s.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 s.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:[s.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id)})}),t==="stats"&&s.jsx(VV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{i(o||"overview"),r(!0)}}),t==="partner"&&s.jsx(LV,{}),t==="resource"&&s.jsx(_V,{}),t==="mentor"&&s.jsx(FV,{}),t==="team"&&s.jsx(BV,{})]})}function qV(){return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[s.jsx(vs,{className:"w-8 h-8 text-[#38bdac]"}),s.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"})]}),s.jsx("p",{className:"text-gray-400 mb-6",children:"API 风格:RESTful · 版本 v1.0 · 基础路径 /api · 简单、清晰、易用。"}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"1. 接口总览"})}),s.jsxs(Ce,{className:"space-y-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"接口分类"}),s.jsxs("ul",{className:"space-y-1 text-gray-300 font-mono",children:[s.jsx("li",{children:"/api/book — 书籍内容(章节列表、内容获取、同步)"}),s.jsx("li",{children:"/api/miniprogram/upload — 小程序上传(图片/视频、图片压缩)"}),s.jsx("li",{children:"/api/admin/content/upload — 管理端内容导入"}),s.jsx("li",{children:"/api/payment — 支付系统(订单创建、回调、状态查询)"}),s.jsx("li",{children:"/api/referral — 分销系统(邀请码、收益、提现)"}),s.jsx("li",{children:"/api/user — 用户系统(登录、注册、信息更新)"}),s.jsx("li",{children:"/api/match — 匹配系统(寻找匹配、匹配历史)"}),s.jsx("li",{children:"/api/admin — 管理后台(内容/订单/用户/分销管理)"}),s.jsx("li",{children:"/api/config — 配置系统"})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"认证方式"}),s.jsx("p",{className:"text-gray-300",children:"用户:Cookie session_id(可选)"}),s.jsx("p",{className:"text-gray-300",children:"管理端:Authorization: Bearer admin-token-secret"})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"2. 书籍内容"})}),s.jsxs(Ce,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET /api/book/all-chapters — 获取所有章节"}),s.jsx("p",{children:"GET /api/book/chapter/:id — 获取单章内容"}),s.jsx("p",{children:"POST /api/book/sync — 同步章节(需管理员认证)"})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"2.1 小程序上传接口"})}),s.jsxs(Ce,{className:"space-y-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-1",children:"POST /api/miniprogram/upload/image — 图片上传(支持压缩)"}),s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"表单:file(必填)、folder(可选,默认 images)、quality(可选 1-100,默认 85)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"支持 jpeg/png/gif,单张最大 5MB。JPEG 按 quality 压缩。"}),s.jsx("pre",{className:"mt-2 p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:'响应示例: { "success": true, "url": "/uploads/images/xxx.jpg", "data": { "url", "fileName", "size", "type", "quality" } }'})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-1",children:"POST /api/miniprogram/upload/video — 视频上传"}),s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"表单:file(必填)、folder(可选,默认 videos)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"支持 mp4/mov/avi,单个最大 100MB。"}),s.jsx("pre",{className:"mt-2 p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:'响应示例: { "success": true, "url": "/uploads/videos/xxx.mp4", "data": { "url", "fileName", "size", "type", "folder" } }'})]})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"2.2 管理端内容上传"})}),s.jsxs(Ce,{className:"space-y-3 text-sm",children:[s.jsx("p",{className:"text-gray-400",children:"POST /api/admin/content/upload — 内容导入(需 AdminAuth)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"通过 API 批量导入章节到内容管理,不直接操作数据库。"}),s.jsx("pre",{className:"p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:`请求体: { + "action": "import", + "data": [{ + "id": "ch-001", + "title": "章节标题", + "content": "正文内容", + "price": 1.0, + "isFree": false, + "partId": "part-1", + "partTitle": "第一篇", + "chapterId": "chapter-1", + "chapterTitle": "第1章" + }] +}`}),s.jsxs("p",{className:"text-gray-500 text-xs",children:["响应:",'{ "success": true, "message": "导入完成", "imported": N, "failed": M }']})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"3. 支付"})}),s.jsxs(Ce,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"POST /api/payment/create-order — 创建订单"}),s.jsx("p",{children:"POST /api/payment/alipay/notify — 支付宝回调"}),s.jsx("p",{children:"POST /api/payment/wechat/notify — 微信回调"})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"4. 分销与用户"})}),s.jsxs(Ce,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"/api/referral/* — 邀请码、收益查询、提现"}),s.jsx("p",{children:"/api/user/* — 登录、注册、信息更新"}),s.jsx("p",{children:"/api/match/* — 匹配、匹配历史"})]})]}),s.jsxs(Se,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(qe,{children:s.jsx(Ge,{className:"text-white",children:"5. 管理后台"})}),s.jsxs(Ce,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET/POST /api/admin/referral-settings — 推广/分销设置(含 VIP 配置)"}),s.jsx("p",{children:"GET /api/db/users、/api/db/book — 用户与章节数据"}),s.jsx("p",{children:"GET /api/admin/orders — 订单列表"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"完整说明见项目内 开发文档/5、接口/API接口完整文档.md"})]})}function GV(){const t=Pi();return s.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:s.jsxs("div",{className:"text-center max-w-md",children:[s.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:s.jsx(XT,{className:"w-10 h-10"})}),s.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),s.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),s.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),s.jsx(ne,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(Mg,{to:"/",children:[s.jsx(zM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function JV(){return s.jsxs(bT,{children:[s.jsx(zt,{path:"/login",element:s.jsx(oI,{})}),s.jsxs(zt,{path:"/",element:s.jsx(d5,{}),children:[s.jsx(zt,{index:!0,element:s.jsx(Tm,{to:"/dashboard",replace:!0})}),s.jsx(zt,{path:"dashboard",element:s.jsx(xP,{})}),s.jsx(zt,{path:"orders",element:s.jsx(yP,{})}),s.jsx(zt,{path:"users",element:s.jsx(bP,{})}),s.jsx(zt,{path:"distribution",element:s.jsx(BP,{})}),s.jsx(zt,{path:"withdrawals",element:s.jsx(VP,{})}),s.jsx(zt,{path:"content",element:s.jsx(hV,{})}),s.jsx(zt,{path:"referral-settings",element:s.jsx(Lk,{})}),s.jsx(zt,{path:"author-settings",element:s.jsx(Tm,{to:"/settings?tab=author",replace:!0})}),s.jsx(zt,{path:"vip-roles",element:s.jsx(IV,{})}),s.jsx(zt,{path:"mentors",element:s.jsx(F4,{})}),s.jsx(zt,{path:"mentor-consultations",element:s.jsx(RV,{})}),s.jsx(zt,{path:"admin-users",element:s.jsx(Tm,{to:"/settings?tab=admin",replace:!0})}),s.jsx(zt,{path:"settings",element:s.jsx(NV,{})}),s.jsx(zt,{path:"payment",element:s.jsx(wV,{})}),s.jsx(zt,{path:"site",element:s.jsx(CV,{})}),s.jsx(zt,{path:"qrcodes",element:s.jsx(EV,{})}),s.jsx(zt,{path:"find-partner",element:s.jsx(KV,{})}),s.jsx(zt,{path:"match",element:s.jsx(MV,{})}),s.jsx(zt,{path:"match-records",element:s.jsx(AV,{})}),s.jsx(zt,{path:"api-doc",element:s.jsx(qV,{})}),s.jsx(zt,{path:"api-docs",element:s.jsx($4,{})})]}),s.jsx(zt,{path:"*",element:s.jsx(GV,{})})]})}kE.createRoot(document.getElementById("root")).render(s.jsx(b.StrictMode,{children:s.jsx(ET,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(JV,{})})})); diff --git a/soul-admin/dist/index.html b/soul-admin/dist/index.html index 973bfaa1..7d7a3029 100644 --- a/soul-admin/dist/index.html +++ b/soul-admin/dist/index.html @@ -4,8 +4,8 @@ 管理后台 - Soul创业派对 - - + +
    diff --git a/soul-admin/src/pages/dashboard/DashboardPage.tsx b/soul-admin/src/pages/dashboard/DashboardPage.tsx index 77075fbe..391452bb 100644 --- a/soul-admin/src/pages/dashboard/DashboardPage.tsx +++ b/soul-admin/src/pages/dashboard/DashboardPage.tsx @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' -import { Users, Eye, ShoppingBag, TrendingUp, RefreshCw, ChevronRight } from 'lucide-react' +import { Users, ShoppingBag, TrendingUp, RefreshCw, ChevronRight, BarChart3 } from 'lucide-react' import { get } from '@/api/client' import { UserDetailModal } from '@/components/modules/user/UserDetailModal' @@ -71,11 +71,19 @@ export function DashboardPage() { const [totalUsersCount, setTotalUsersCount] = useState(0) const [paidOrderCount, setPaidOrderCount] = useState(0) const [totalRevenue, setTotalRevenue] = useState(0) - const [todayClicks, setTodayClicks] = useState(0) + const [conversionRate, setConversionRate] = useState(0) + const [giftedTotal, setGiftedTotal] = useState(0) const [loadError, setLoadError] = useState(null) const [detailUserId, setDetailUserId] = useState(null) const [showDetailModal, setShowDetailModal] = useState(false) + const [trackPeriod, setTrackPeriod] = useState('today') + const [trackStats, setTrackStats] = useState<{ + total: number + byModule: Record + } | null>(null) + const [trackLoading, setTrackLoading] = useState(false) + const showError = (err: unknown) => { const e = err as Error & { status?: number; name?: string } if (e?.status === 401) setLoadError('登录已过期,请重新登录') @@ -95,6 +103,7 @@ export function DashboardPage() { setTotalUsersCount(stats.totalUsers ?? 0) setPaidOrderCount(stats.paidOrderCount ?? 0) setTotalRevenue(stats.totalRevenue ?? 0) + setConversionRate(stats.conversionRate ?? 0) } } catch (e) { if ((e as Error)?.name !== 'AbortError') { @@ -105,6 +114,7 @@ export function DashboardPage() { setTotalUsersCount(overview.totalUsers ?? 0) setPaidOrderCount(overview.paidOrderCount ?? 0) setTotalRevenue(overview.totalRevenue ?? 0) + setConversionRate(overview.conversionRate ?? 0) } } catch (e2) { showError(e2) @@ -114,14 +124,14 @@ export function DashboardPage() { setStatsLoading(false) } - // 加载今日点击(从推广中心接口) + // 加载代付总额(仅用于收入标签展示) try { - const distOverview = await get<{ success?: boolean; todayClicks?: number }>('/api/admin/distribution/overview', init) - if (distOverview?.success) { - setTodayClicks(distOverview.todayClicks ?? 0) + const balRes = await get<{ success?: boolean; data?: { totalGifted?: number } }>('/api/admin/balance/summary', init) + if (balRes?.success && balRes.data) { + setGiftedTotal(balRes.data.totalGifted ?? 0) } } catch { - // 推广数据加载失败不影响主面板 + // 不影响主面板 } // 2. 并行加载订单和用户 @@ -174,10 +184,28 @@ export function DashboardPage() { await Promise.all([loadOrders(), loadUsers()]) } + async function loadTrackStats(period?: string) { + const p = period || trackPeriod + setTrackLoading(true) + try { + const res = await get<{ success?: boolean; total?: number; byModule?: Record }>( + `/api/admin/track/stats?period=${p}` + ) + if (res?.success) { + setTrackStats({ total: res.total ?? 0, byModule: res.byModule ?? {} }) + } + } catch { + setTrackStats(null) + } finally { + setTrackLoading(false) + } + } + useEffect(() => { const ctrl = new AbortController() loadAll(ctrl.signal) - const timer = setInterval(() => loadAll(), 30000) + loadTrackStats() + const timer = setInterval(() => { loadAll(); loadTrackStats() }, 30000) return () => { ctrl.abort() clearInterval(timer) @@ -223,6 +251,7 @@ export function DashboardPage() { { title: '总用户数', value: statsLoading ? null : totalUsers, + sub: null as string | null, icon: Users, color: 'text-blue-400', bg: 'bg-blue-500/20', @@ -231,6 +260,7 @@ export function DashboardPage() { { title: '总收入', value: statsLoading ? null : `¥${(totalRevenue ?? 0).toFixed(2)}`, + sub: giftedTotal > 0 ? `含代付 ¥${giftedTotal.toFixed(2)}` : null, icon: TrendingUp, color: 'text-[#38bdac]', bg: 'bg-[#38bdac]/20', @@ -239,18 +269,20 @@ export function DashboardPage() { { title: '订单数', value: statsLoading ? null : paidOrderCount, + sub: null as string | null, icon: ShoppingBag, color: 'text-purple-400', bg: 'bg-purple-500/20', link: '/orders', }, { - title: '今日点击', - value: statsLoading ? null : todayClicks, - icon: Eye, - color: 'text-blue-400', - bg: 'bg-blue-500/20', - link: '/distribution', + title: '转化率', + value: statsLoading ? null : `${conversionRate.toFixed(1)}%`, + sub: null as string | null, + icon: TrendingUp, + color: 'text-amber-400', + bg: 'bg-amber-500/20', + link: '/users', }, ] @@ -269,7 +301,7 @@ export function DashboardPage() { )} -
    +
    {stats.map((stat, index) => (
    -
    - {stat.value != null ? ( - stat.value - ) : ( - - - 加载中 - +
    +
    + {stat.value != null ? ( + stat.value + ) : ( + + + 加载中 + + )} +
    + {stat.sub && ( +

    {stat.sub}

    )}
    @@ -480,6 +517,95 @@ export function DashboardPage() {
    + {/* 分类标签点击统计 */} + + + + + 分类标签点击统计 + +
    + {(['today', 'week', 'month', 'all'] as const).map((p) => ( + + ))} +
    +
    + + {trackLoading && !trackStats ? ( +
    + + 加载中... +
    + ) : trackStats && Object.keys(trackStats.byModule).length > 0 ? ( +
    +

    + 总点击 {trackStats.total} 次 +

    +
    + {Object.entries(trackStats.byModule) + .sort((a, b) => b[1].reduce((s, i) => s + i.count, 0) - a[1].reduce((s, i) => s + i.count, 0)) + .map(([mod, items]) => { + const moduleTotal = items.reduce((s, i) => s + i.count, 0) + const moduleLabels: Record = { + home: '首页', chapters: '目录', read: '阅读', my: '我的', + vip: 'VIP', wallet: '钱包', match: '找伙伴', referral: '推广', + search: '搜索', settings: '设置', about: '关于', other: '其他', + } + return ( +
    +
    + + {moduleLabels[mod] || mod} + + {moduleTotal} 次 +
    +
    + {items + .sort((a, b) => b.count - a.count) + .slice(0, 8) + .map((item, i) => ( +
    + + {item.target || item.action} + +
    +
    +
    0 ? (item.count / moduleTotal) * 100 : 0}%` }} + /> +
    + {item.count} +
    +
    + ))} +
    +
    + ) + })} +
    +
    + ) : ( +
    + +

    暂无点击数据

    +

    小程序端接入埋点后,数据将在此实时展示

    +
    + )} + + + { setShowDetailModal(false); setDetailUserId(null) }} diff --git a/soul-admin/src/pages/users/UsersPage.tsx b/soul-admin/src/pages/users/UsersPage.tsx index 7c26322f..2236c93a 100644 --- a/soul-admin/src/pages/users/UsersPage.tsx +++ b/soul-admin/src/pages/users/UsersPage.tsx @@ -44,6 +44,8 @@ import { ChevronUp, Crown, Tag, + Star, + Info, } from 'lucide-react' import { UserDetailModal } from '@/components/modules/user/UserDetailModal' import { Pagination } from '@/components/ui/Pagination' @@ -64,10 +66,10 @@ interface User { earnings: number | string pendingEarnings?: number | string withdrawnEarnings?: number | string + walletBalance?: number | string referralCount?: number createdAt: string updatedAt?: string | null - // RFM(排序模式时有值) rfmScore?: number rfmLevel?: string } @@ -155,6 +157,12 @@ export function UsersPage() { // ===== 用户旅程总览 ===== const [journeyStats, setJourneyStats] = useState>({}) const [journeyLoading, setJourneyLoading] = useState(false) + const [journeySelectedStage, setJourneySelectedStage] = useState(null) + const [journeyUsers, setJourneyUsers] = useState<{ id: string; nickname: string; phone?: string; createdAt?: string }[]>([]) + const [journeyUsersLoading, setJourneyUsersLoading] = useState(false) + + // RFM 算法说明 + const [showRfmInfo, setShowRfmInfo] = useState(false) // ===== 用户列表 ===== async function loadUsers(fromRefresh = false) { @@ -488,6 +496,41 @@ export function UsersPage() { } catch { } finally { setJourneyLoading(false) } }, []) + async function loadJourneyUsers(stageId: string) { + setJourneySelectedStage(stageId) + setJourneyUsersLoading(true) + try { + const data = await get<{ success?: boolean; users?: { id: string; nickname: string; phone?: string; createdAt?: string }[] }>( + `/api/db/users/journey-users?stage=${encodeURIComponent(stageId)}&limit=20` + ) + if (data?.success && data.users) setJourneyUsers(data.users) + else setJourneyUsers([]) + } catch { + setJourneyUsers([]) + } finally { + setJourneyUsersLoading(false) + } + } + + async function handleSetSuperMember(user: User) { + if (!user.hasFullBook) { + toast.error('仅 VIP 用户可置顶到超级个体') + return + } + if (!confirm('确定将该用户置顶到首页超级个体位?(最多4位)')) return + try { + const res = await put<{ success?: boolean; error?: string }>('/api/db/users', { id: user.id, vipSort: 1 }) + if (!res?.success) { + toast.error(res?.error || '置顶失败') + return + } + toast.success('已置顶到超级个体') + loadUsers() + } catch { + toast.error('置顶失败') + } + } + return (
    {error && ( @@ -499,7 +542,12 @@ export function UsersPage() {
    -

    用户管理

    +
    +

    用户管理

    + +

    共 {total} 位注册用户{rfmSortMode && ' · RFM 排序中'}

    @@ -576,6 +624,7 @@ export function UsersPage() { 绑定信息 购买状态 分销收益 + 余额/提现
    @@ -650,6 +699,14 @@ export function UsersPage() {
    + +
    +
    ¥{parseFloat(String(user.walletBalance || 0)).toFixed(2)}
    + {parseFloat(String(user.withdrawnEarnings || 0)) > 0 && ( +
    已提现: ¥{parseFloat(String(user.withdrawnEarnings || 0)).toFixed(2)}
    + )} +
    +
    {/* RFM 分值列 */} {user.rfmScore !== undefined ? ( @@ -669,6 +726,9 @@ export function UsersPage() {
    + {user.hasFullBook && ( + + )}
    @@ -706,7 +766,13 @@ export function UsersPage() { {JOURNEY_STAGES.map((stage, idx) => (
    {/* 阶段卡片 */} -
    +
    loadJourneyUsers(stage.id)} + onKeyDown={(e) => e.key === 'Enter' && loadJourneyUsers(stage.id)} + >
    {stage.icon}
    c.startsWith('text-'))}`}>{stage.label}
    {journeyStats[stage.id] !== undefined && ( @@ -732,6 +798,44 @@ export function UsersPage() {
    + {/* 选中阶段的用户列表 */} + {journeySelectedStage && ( +
    +
    + + {JOURNEY_STAGES.find((s) => s.id === journeySelectedStage)?.label} — 用户列表 + + +
    + {journeyUsersLoading ? ( +
    + +
    + ) : journeyUsers.length > 0 ? ( +
    + {journeyUsers.map((u) => ( +
    { setSelectedUserIdForDetail(u.id); setShowDetailModal(true) }} + onKeyDown={(e) => e.key === 'Enter' && (setSelectedUserIdForDetail(u.id), setShowDetailModal(true))} + role="button" + tabIndex={0} + > + {u.nickname} + {u.phone || '—'} + {u.createdAt ? new Date(u.createdAt).toLocaleDateString() : '—'} +
    + ))} +
    + ) : ( +

    暂无用户

    + )} +
    + )} + {/* 旅程说明 */}
    @@ -1125,6 +1229,28 @@ export function UsersPage() { + {/* RFM 算法说明 */} + + + + + + RFM 算法说明 + + +
    +

    R(Recency):距最近购买天数,越近分越高,权重 40%

    +

    F(Frequency):购买频次,越多分越高,权重 30%

    +

    M(Monetary):消费金额,越高分越高,权重 30%

    +

    综合分 = R×40% + F×30% + M×30%,归一化到 0-100

    +

    等级:S(≥85)、A(≥70)、B(≥50)、C(≥30)、D(<30)

    +
    + + + +
    +
    + setShowDetailModal(false)} userId={selectedUserIdForDetail} onUserUpdated={loadUsers} />
    ) diff --git a/soul-api/internal/handler/admin_rfm.go b/soul-api/internal/handler/admin_rfm.go index f7041c2d..7778db74 100644 --- a/soul-api/internal/handler/admin_rfm.go +++ b/soul-api/internal/handler/admin_rfm.go @@ -304,3 +304,70 @@ func DBUsersJourneyStats(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"success": true, "stats": stats}) } +// journeyUserItem 用户旅程列表项 +type journeyUserItem struct { + ID string `json:"id"` + Nickname string `json:"nickname"` + Phone string `json:"phone"` + CreatedAt string `json:"createdAt"` +} + +// DBUsersJourneyUsers GET /api/db/users/journey-users?stage=xxx&limit=20 — 按阶段查用户 +func DBUsersJourneyUsers(c *gin.Context) { + db := database.DB() + stage := strings.TrimSpace(c.Query("stage")) + limitStr := c.DefaultQuery("limit", "20") + limit := 20 + if n, err := strconv.Atoi(limitStr); err == nil && n > 0 { + limit = n + } + if limit > 100 { + limit = 100 + } + + var users []model.User + switch stage { + case "register": + db.Order("created_at DESC").Limit(limit).Find(&users) + case "browse": + subq := db.Table("user_tracks").Select("user_id").Where("action = ?", "view_chapter").Distinct("user_id") + db.Where("id IN (?)", subq).Order("created_at DESC").Limit(limit).Find(&users) + case "bind_phone": + db.Where("phone IS NOT NULL AND phone != ''").Order("created_at DESC").Limit(limit).Find(&users) + case "first_pay": + db.Where("id IN (?)", db.Model(&model.Order{}).Select("user_id"). + Where("status IN ?", []string{"paid", "success", "completed"})). + Order("created_at DESC").Limit(limit).Find(&users) + case "fill_profile": + db.Where("mbti IS NOT NULL OR industry IS NOT NULL").Order("created_at DESC").Limit(limit).Find(&users) + case "match": + subq := db.Table("user_tracks").Select("user_id").Where("action = ?", "match").Distinct("user_id") + db.Where("id IN (?)", subq).Order("created_at DESC").Limit(limit).Find(&users) + case "vip": + db.Where("is_vip = ?", true).Order("created_at DESC").Limit(limit).Find(&users) + case "distribution": + db.Where("referral_code IS NOT NULL AND referral_code != ''").Where("COALESCE(earnings, 0) > ?", 0). + Order("created_at DESC").Limit(limit).Find(&users) + default: + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "无效的 stage 参数"}) + return + } + + list := make([]journeyUserItem, 0, len(users)) + for _, u := range users { + nick, phone := "", "" + if u.Nickname != nil { + nick = *u.Nickname + } + if u.Phone != nil { + phone = *u.Phone + } + list = append(list, journeyUserItem{ + ID: u.ID, + Nickname: nick, + Phone: phone, + CreatedAt: u.CreatedAt.Format(time.RFC3339), + }) + } + c.JSON(http.StatusOK, gin.H{"success": true, "users": list}) +} diff --git a/soul-api/internal/handler/admin_track.go b/soul-api/internal/handler/admin_track.go new file mode 100644 index 00000000..c00d1bd2 --- /dev/null +++ b/soul-api/internal/handler/admin_track.go @@ -0,0 +1,93 @@ +package handler + +import ( + "encoding/json" + "net/http" + "time" + + "soul-api/internal/database" + + "github.com/gin-gonic/gin" +) + +// AdminTrackStats GET /api/admin/track/stats 管理端-按钮/标签点击统计(按模块+action聚合) +// 查询参数:period=today|week|month|all(默认 today) +func AdminTrackStats(c *gin.Context) { + period := c.DefaultQuery("period", "today") + db := database.DB() + + now := time.Now() + var since time.Time + switch period { + case "today": + since = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) + case "week": + since = now.AddDate(0, 0, -7) + case "month": + since = now.AddDate(0, -1, 0) + default: + since = time.Time{} + } + + type trackRow struct { + Action string `gorm:"column:action"` + Target string `gorm:"column:target"` + ExtraData []byte `gorm:"column:extra_data"` + Count int64 `gorm:"column:count"` + } + + query := db.Table("user_tracks"). + Select("action, COALESCE(target, '') as target, extra_data, COUNT(*) as count"). + Group("action, COALESCE(target, ''), extra_data"). + Order("count DESC") + + if !since.IsZero() { + query = query.Where("created_at >= ?", since) + } + + var rows []trackRow + query.Find(&rows) + + type statItem struct { + Action string `json:"action"` + Target string `json:"target"` + Module string `json:"module"` + Page string `json:"page"` + Count int64 `json:"count"` + } + + byModule := make(map[string][]statItem) + total := int64(0) + + for _, r := range rows { + module := "other" + page := "" + if len(r.ExtraData) > 0 { + var extra map[string]interface{} + if json.Unmarshal(r.ExtraData, &extra) == nil { + if m, ok := extra["module"].(string); ok && m != "" { + module = m + } + if p, ok := extra["page"].(string); ok && p != "" { + page = p + } + } + } + item := statItem{ + Action: r.Action, + Target: r.Target, + Module: module, + Page: page, + Count: r.Count, + } + byModule[module] = append(byModule[module], item) + total += r.Count + } + + c.JSON(http.StatusOK, gin.H{ + "success": true, + "period": period, + "total": total, + "byModule": byModule, + }) +} diff --git a/soul-api/internal/handler/balance.go b/soul-api/internal/handler/balance.go index 20f8507d..44033d87 100644 --- a/soul-api/internal/handler/balance.go +++ b/soul-api/internal/handler/balance.go @@ -308,7 +308,7 @@ func BalanceRefund(c *gin.Context) { }}) } -// GET /api/miniprogram/balance/transactions 交易记录 +// GET /api/miniprogram/balance/transactions 交易记录(含余额变动 + 阅读消费订单) func BalanceTransactions(c *gin.Context) { userID := c.Query("userId") if userID == "" { @@ -317,10 +317,81 @@ func BalanceTransactions(c *gin.Context) { } db := database.DB() + var txns []model.BalanceTransaction db.Where("user_id = ?", userID).Order("created_at DESC").Limit(50).Find(&txns) - c.JSON(http.StatusOK, gin.H{"success": true, "data": txns}) + var orders []model.Order + db.Where("user_id = ? AND product_type = ? AND status IN ?", userID, "section", []string{"paid", "completed", "success"}). + Order("created_at DESC").Limit(50).Find(&orders) + + type txRow struct { + ID string `json:"id"` + Type string `json:"type"` + Amount float64 `json:"amount"` + Description string `json:"description"` + CreatedAt interface{} `json:"createdAt"` + } + + merged := make([]txRow, 0, len(txns)+len(orders)) + for _, t := range txns { + merged = append(merged, txRow{ + ID: fmt.Sprintf("bal_%d", t.ID), Type: t.Type, Amount: t.Amount, + Description: t.Description, CreatedAt: t.CreatedAt, + }) + } + for _, o := range orders { + desc := "阅读消费" + if o.Description != nil && *o.Description != "" { + desc = *o.Description + } + merged = append(merged, txRow{ + ID: o.ID, Type: "consume", Amount: -o.Amount, + Description: desc, CreatedAt: o.CreatedAt, + }) + } + + // 按时间倒序排列 + for i := 0; i < len(merged); i++ { + for j := i + 1; j < len(merged); j++ { + ti := fmt.Sprintf("%v", merged[i].CreatedAt) + tj := fmt.Sprintf("%v", merged[j].CreatedAt) + if ti < tj { + merged[i], merged[j] = merged[j], merged[i] + } + } + } + if len(merged) > 50 { + merged = merged[:50] + } + + c.JSON(http.StatusOK, gin.H{"success": true, "data": merged}) +} + +// GET /api/admin/balance/summary 管理端-余额统计 +func BalanceSummary(c *gin.Context) { + db := database.DB() + + type Summary struct { + TotalUsers int64 `json:"totalUsers"` + TotalBalance float64 `json:"totalBalance"` + TotalRecharged float64 `json:"totalRecharged"` + TotalGifted float64 `json:"totalGifted"` + TotalRefunded float64 `json:"totalRefunded"` + GiftCount int64 `json:"giftCount"` + PendingGifts int64 `json:"pendingGifts"` + } + + var s Summary + db.Model(&model.UserBalance{}).Count(&s.TotalUsers) + db.Model(&model.UserBalance{}).Select("COALESCE(SUM(balance),0)").Scan(&s.TotalBalance) + db.Model(&model.UserBalance{}).Select("COALESCE(SUM(total_recharged),0)").Scan(&s.TotalRecharged) + db.Model(&model.UserBalance{}).Select("COALESCE(SUM(total_gifted),0)").Scan(&s.TotalGifted) + db.Model(&model.UserBalance{}).Select("COALESCE(SUM(total_refunded),0)").Scan(&s.TotalRefunded) + db.Model(&model.GiftUnlock{}).Count(&s.GiftCount) + db.Model(&model.GiftUnlock{}).Where("status = ?", "pending").Count(&s.PendingGifts) + + c.JSON(200, gin.H{"success": true, "data": s}) } // GET /api/miniprogram/balance/gift/info 查询礼物码信息 diff --git a/soul-api/internal/handler/book.go b/soul-api/internal/handler/book.go index ced16dbc..73148f6d 100644 --- a/soul-api/internal/handler/book.go +++ b/soul-api/internal/handler/book.go @@ -147,17 +147,58 @@ func checkUserChapterAccess(db *gorm.DB, userID, chapterID string, isPremium boo return cnt > 0 } -// previewContent 取内容的前 50%(不少于 100 个字符),并追加省略提示 -func previewContent(content string) string { +// getUnpaidPreviewPercent 从 system_config 读取 unpaid_preview_percent,默认 20 +func getUnpaidPreviewPercent(db *gorm.DB) int { + var row model.SystemConfig + if err := db.Where("config_key = ?", "unpaid_preview_percent").First(&row).Error; err != nil || len(row.ConfigValue) == 0 { + return 20 + } + var val interface{} + if err := json.Unmarshal(row.ConfigValue, &val); err != nil { + return 20 + } + switch v := val.(type) { + case float64: + p := int(v) + if p < 1 { + p = 1 + } + if p > 100 { + p = 100 + } + return p + case int: + if v < 1 { + return 1 + } + if v > 100 { + return 100 + } + return v + } + return 20 +} + +// previewContent 取内容的前 percent%,上限 500 字(手动设置 percent 也受此限制),不少于 100 字 +func previewContent(content string, percent int) string { total := utf8.RuneCountInString(content) if total == 0 { return "" } - // 截取前 50% 的内容,保证有足够的预览长度 - limit := total / 2 + if percent < 1 { + percent = 1 + } + if percent > 100 { + percent = 100 + } + limit := total * percent / 100 if limit < 100 { limit = 100 } + const maxPreview = 500 + if limit > maxPreview { + limit = maxPreview + } if limit > total { limit = total } @@ -198,7 +239,11 @@ func findChapterAndRespond(c *gin.Context, whereFn func(*gorm.DB) *gorm.DB) { } else if checkUserChapterAccess(db, userID, ch.ID, isPremium) { returnContent = ch.Content } else { - returnContent = previewContent(ch.Content) + percent := getUnpaidPreviewPercent(db) + if ch.PreviewPercent != nil && *ch.PreviewPercent >= 1 && *ch.PreviewPercent <= 100 { + percent = *ch.PreviewPercent + } + returnContent = previewContent(ch.Content, percent) } // data 中的 content 必须与外层 content 一致,避免泄露完整内容给未授权用户 @@ -289,7 +334,7 @@ func BookChapters(c *gin.Context) { updates := map[string]interface{}{ "part_title": body.PartTitle, "chapter_title": body.ChapterTitle, "section_title": body.SectionTitle, "content": body.Content, "word_count": body.WordCount, "is_free": body.IsFree, "price": body.Price, - "sort_order": body.SortOrder, "status": body.Status, + "sort_order": body.SortOrder, "status": body.Status, "hot_score": body.HotScore, } if body.EditionStandard != nil { updates["edition_standard"] = body.EditionStandard @@ -368,18 +413,59 @@ func bookHotChaptersSorted(db *gorm.DB, limit int) []model.Chapter { return out } -// BookHot GET /api/book/hot 热门章节(按阅读量排序,排除序言/尾声/附录) +// BookHot GET /api/book/hot 热门章节(按 hot_score 降序,使用与管理端相同的排名算法) +// 支持 ?limit=N 参数,默认 20,最大 100 func BookHot(c *gin.Context) { - list := bookHotChaptersSorted(database.DB(), 10) - if len(list) == 0 { - // 兜底:按 sort_order 取前 10,同样排除序言/尾声/附录 - q := database.DB().Model(&model.Chapter{}) + db := database.DB() + + sections, err := computeArticleRankingSections(db) + if err != nil || len(sections) == 0 { + var list []model.Chapter + q := db.Model(&model.Chapter{}). + Select("mid, id, part_id, part_title, chapter_id, chapter_title, section_title, is_free, price, sort_order, hot_score, updated_at") for _, p := range excludeParts { q = q.Where("part_title NOT LIKE ?", "%"+p+"%") } - q.Order("sort_order ASC, id ASC").Limit(10).Find(&list) + q.Order("hot_score DESC, sort_order ASC, id ASC").Limit(20).Find(&list) + c.JSON(http.StatusOK, gin.H{"success": true, "data": list}) + return } - c.JSON(http.StatusOK, gin.H{"success": true, "data": list}) + + limit := 20 + if l, err := strconv.Atoi(c.Query("limit")); err == nil && l > 0 { + limit = l + if limit > 100 { + limit = 100 + } + } + if len(sections) < limit { + limit = len(sections) + } + tags := []string{"热门", "推荐", "精选"} + result := make([]gin.H, 0, limit) + for i := 0; i < limit; i++ { + s := sections[i] + tag := "" + if i < len(tags) { + tag = tags[i] + } + result = append(result, gin.H{ + "id": s.ID, + "mid": s.MID, + "sectionTitle": s.Title, + "partTitle": s.PartTitle, + "chapterTitle": s.ChapterTitle, + "price": s.Price, + "isFree": s.IsFree, + "clickCount": s.ClickCount, + "payCount": s.PayCount, + "hotScore": s.HotScore, + "hotRank": i + 1, + "isPinned": s.IsPinned, + "tag": tag, + }) + } + c.JSON(http.StatusOK, gin.H{"success": true, "data": result}) } // BookRecommended GET /api/book/recommended 精选推荐(首页「为你推荐」前 3 章) @@ -498,9 +584,21 @@ func BookSearch(c *gin.Context) { // BookStats GET /api/book/stats func BookStats(c *gin.Context) { + db := database.DB() var total int64 - database.DB().Model(&model.Chapter{}).Count(&total) - c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"totalChapters": total}}) + db.Model(&model.Chapter{}).Count(&total) + var freeCount int64 + db.Model(&model.Chapter{}).Where("is_free = ?", true).Count(&freeCount) + var totalWords struct{ S int64 } + db.Model(&model.Chapter{}).Select("COALESCE(SUM(word_count),0) as s").Scan(&totalWords) + var userCount int64 + db.Model(&model.User{}).Count(&userCount) + c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{ + "totalChapters": total, + "freeChapters": freeCount, + "totalWordCount": totalWords.S, + "totalUsers": userCount, + }}) } // BookSync GET/POST /api/book/sync diff --git a/soul-api/internal/handler/db.go b/soul-api/internal/handler/db.go index 665d7968..9731b5f9 100644 --- a/soul-api/internal/handler/db.go +++ b/soul-api/internal/handler/db.go @@ -177,8 +177,9 @@ func AdminSettingsGet(c *gin.Context) { "featureConfig": gin.H{"matchEnabled": true, "referralEnabled": true, "searchEnabled": true, "aboutEnabled": true}, "siteSettings": gin.H{"sectionPrice": float64(1), "baseBookPrice": 9.9, "distributorShare": float64(90), "authorInfo": gin.H{}}, "mpConfig": defaultMp, + "ossConfig": gin.H{}, } - keys := []string{"feature_config", "site_settings", "mp_config"} + keys := []string{"feature_config", "site_settings", "mp_config", "oss_config"} for _, k := range keys { var row model.SystemConfig if err := db.Where("config_key = ?", k).First(&row).Error; err != nil { @@ -208,6 +209,10 @@ func AdminSettingsGet(c *gin.Context) { } out["mpConfig"] = merged } + case "oss_config": + if m, ok := val.(map[string]interface{}); ok && len(m) > 0 { + out["ossConfig"] = m + } } } c.JSON(http.StatusOK, out) @@ -219,6 +224,7 @@ func AdminSettingsPost(c *gin.Context) { FeatureConfig map[string]interface{} `json:"featureConfig"` SiteSettings map[string]interface{} `json:"siteSettings"` MpConfig map[string]interface{} `json:"mpConfig"` + OssConfig map[string]interface{} `json:"ossConfig"` } if err := c.ShouldBindJSON(&body); err != nil { c.JSON(http.StatusOK, gin.H{"success": false, "error": "请求体无效"}) @@ -260,6 +266,12 @@ func AdminSettingsPost(c *gin.Context) { return } } + if body.OssConfig != nil { + if err := saveKey("oss_config", "阿里云 OSS 配置", body.OssConfig); err != nil { + c.JSON(http.StatusOK, gin.H{"success": false, "error": "保存 OSS 配置失败: " + err.Error()}) + return + } + } c.JSON(http.StatusOK, gin.H{"success": true, "message": "设置已保存"}) } @@ -667,6 +679,17 @@ func DBUsersList(c *gin.Context) { referralCountMap[r.ReferrerID] = int(r.Count) } + // 4. 用户余额:从 user_balances 查询 + balanceMap := make(map[string]float64) + var balRows []struct { + UserID string + Balance float64 + } + db.Table("user_balances").Select("user_id, COALESCE(balance, 0) as balance").Find(&balRows) + for _, r := range balRows { + balanceMap[r.UserID] = r.Balance + } + // 填充每个用户的实时计算字段 for i := range users { uid := users[i].ID @@ -687,7 +710,9 @@ func DBUsersList(c *gin.Context) { } users[i].Earnings = ptrFloat64(totalE) users[i].PendingEarnings = ptrFloat64(available) + users[i].WithdrawnEarnings = ptrFloat64(withdrawn) users[i].ReferralCount = ptrInt(referralCountMap[uid]) + users[i].WalletBalance = ptrFloat64(balanceMap[uid]) } c.JSON(http.StatusOK, gin.H{ @@ -745,6 +770,7 @@ func DBUsersAction(c *gin.Context) { Phone *string `json:"phone"` WechatID *string `json:"wechatId"` Avatar *string `json:"avatar"` + Tags *string `json:"tags"` HasFullBook *bool `json:"hasFullBook"` IsAdmin *bool `json:"isAdmin"` Earnings *float64 `json:"earnings"` @@ -789,6 +815,9 @@ func DBUsersAction(c *gin.Context) { if body.Avatar != nil { updates["avatar"] = *body.Avatar } + if body.Tags != nil { + updates["tags"] = *body.Tags + } if body.HasFullBook != nil { updates["has_full_book"] = *body.HasFullBook } @@ -847,6 +876,9 @@ func DBUsersAction(c *gin.Context) { if body.VipBio != nil { updates["vip_bio"] = *body.VipBio } + if body.Tags != nil { + updates["tags"] = *body.Tags + } if len(updates) == 0 { c.JSON(http.StatusOK, gin.H{"success": true, "message": "没有需要更新的字段"}) return diff --git a/soul-api/internal/handler/db_book.go b/soul-api/internal/handler/db_book.go index fb58df50..c260d460 100644 --- a/soul-api/internal/handler/db_book.go +++ b/soul-api/internal/handler/db_book.go @@ -38,6 +38,7 @@ type sectionListItem struct { ClickCount int64 `json:"clickCount"` // 阅读次数(reading_progress) PayCount int64 `json:"payCount"` // 付款笔数(orders.product_type=section) HotScore float64 `json:"hotScore"` // 热度积分(加权计算) + HotRank int `json:"hotRank"` // 热度排名(按 hotScore 降序) IsPinned bool `json:"isPinned,omitempty"` // 是否置顶(仅 ranking 返回) } @@ -156,47 +157,132 @@ func computeSectionsWithHotScore(db *gorm.DB, setPinned bool) ([]sectionListItem pinnedSet[id] = true } } - now := time.Now() - sections := make([]sectionListItem, 0, len(rows)) + const rankTop = 20 + + // 构建基础 section 数据 + type rawSection struct { + item sectionListItem + readCnt int64 + payCnt int64 + updatedAt time.Time + } + raws := make([]rawSection, 0, len(rows)) for _, r := range rows { price := 1.0 if r.Price != nil { price = *r.Price } - readCnt := readCountMap[r.ID] - payCnt := payCountMap[r.ID] - recencyScore := 0.0 - if !r.UpdatedAt.IsZero() { - days := now.Sub(r.UpdatedAt).Hours() / 24 - recencyScore = math.Max(0, (30-days)/30) - if recencyScore > 1 { - recencyScore = 1 - } - } - hot := float64(readCnt)*readWeight + float64(payCnt)*payWeight + recencyScore*recencyWeight - item := sectionListItem{ - ID: r.ID, - MID: r.MID, - Title: r.SectionTitle, - Price: price, - IsFree: r.IsFree, - IsNew: r.IsNew, - PartID: r.PartID, - PartTitle: r.PartTitle, - ChapterID: r.ChapterID, - ChapterTitle: r.ChapterTitle, - ClickCount: readCnt, - PayCount: payCnt, - HotScore: hot, - } - if setPinned { - item.IsPinned = pinnedSet[r.ID] - } - sections = append(sections, item) + raws = append(raws, rawSection{ + item: sectionListItem{ + ID: r.ID, + MID: r.MID, + Title: r.SectionTitle, + Price: price, + IsFree: r.IsFree, + IsNew: r.IsNew, + PartID: r.PartID, + PartTitle: r.PartTitle, + ChapterID: r.ChapterID, + ChapterTitle: r.ChapterTitle, + ClickCount: readCountMap[r.ID], + PayCount: payCountMap[r.ID], + }, + readCnt: readCountMap[r.ID], + payCnt: payCountMap[r.ID], + updatedAt: r.UpdatedAt, + }) } + + // 排名积分:前 rankTop 名分别得 rankTop ~ 1 分,其余 0 分 + readRankScore := make(map[string]float64, len(raws)) + payRankScore := make(map[string]float64, len(raws)) + recencyRankScore := make(map[string]float64, len(raws)) + + // 阅读量排名 + sorted := make([]int, len(raws)) + for i := range sorted { + sorted[i] = i + } + sort.Slice(sorted, func(a, b int) bool { + return raws[sorted[a]].readCnt > raws[sorted[b]].readCnt + }) + for rank, idx := range sorted { + if rank >= rankTop || raws[idx].readCnt == 0 { + break + } + readRankScore[raws[idx].item.ID] = float64(rankTop - rank) + } + + // 付款量排名 + for i := range sorted { + sorted[i] = i + } + sort.Slice(sorted, func(a, b int) bool { + return raws[sorted[a]].payCnt > raws[sorted[b]].payCnt + }) + for rank, idx := range sorted { + if rank >= rankTop || raws[idx].payCnt == 0 { + break + } + payRankScore[raws[idx].item.ID] = float64(rankTop - rank) + } + + // 新度排名(按 updated_at 最近排序) + for i := range sorted { + sorted[i] = i + } + sort.Slice(sorted, func(a, b int) bool { + return raws[sorted[a]].updatedAt.After(raws[sorted[b]].updatedAt) + }) + for rank, idx := range sorted { + if rank >= rankTop { + break + } + recencyRankScore[raws[idx].item.ID] = float64(rankTop - rank) + } + + // 计算最终热度分 + sections := make([]sectionListItem, 0, len(raws)) + hotUpdates := make(map[string]float64, len(raws)) + for i := range raws { + id := raws[i].item.ID + hot := readRankScore[id]*readWeight + recencyRankScore[id]*recencyWeight + payRankScore[id]*payWeight + hot = math.Round(hot*100) / 100 + hotUpdates[id] = hot + raws[i].item.HotScore = hot + if setPinned { + raws[i].item.IsPinned = pinnedSet[id] + } + sections = append(sections, raws[i].item) + } + + // 计算排名序号 + ranked := make([]sectionListItem, len(sections)) + copy(ranked, sections) + sort.Slice(ranked, func(i, j int) bool { + return ranked[i].HotScore > ranked[j].HotScore + }) + rankMap := make(map[string]int, len(ranked)) + for i, s := range ranked { + rankMap[s.ID] = i + 1 + } + for i := range sections { + sections[i].HotRank = rankMap[sections[i].ID] + } + go persistHotScores(db, hotUpdates) return sections, nil } +// persistHotScores writes computed hot_score values back to the chapters table +func persistHotScores(db *gorm.DB, scores map[string]float64) { + for id, score := range scores { + _ = db.WithContext(context.Background()). + Model(&model.Chapter{}). + Where("id = ?", id). + UpdateColumn("hot_score", score).Error + } +} + // DBBookAction GET/POST/PUT /api/db/book func DBBookAction(c *gin.Context) { db := database.DB() @@ -255,6 +341,7 @@ func DBBookAction(c *gin.Context) { "chapterTitle": ch.ChapterTitle, "editionStandard": ch.EditionStandard, "editionPremium": ch.EditionPremium, + "previewPercent": ch.PreviewPercent, }, }) return @@ -386,6 +473,8 @@ func DBBookAction(c *gin.Context) { ChapterID string `json:"chapterId"` ChapterTitle string `json:"chapterTitle"` HotScore *float64 `json:"hotScore"` + PreviewPercent *int `json:"previewPercent"` // 章节级预览比例(%),1-100 + ClearPreviewPercent *bool `json:"clearPreviewPercent"` // true 表示清除覆盖、使用全局 } if err := c.ShouldBindJSON(&body); err != nil { c.JSON(http.StatusOK, gin.H{"success": false, "error": "请求体无效"}) @@ -494,6 +583,14 @@ func DBBookAction(c *gin.Context) { if body.HotScore != nil { updates["hot_score"] = *body.HotScore } + if body.ClearPreviewPercent != nil && *body.ClearPreviewPercent { + updates["preview_percent"] = nil + } else if body.PreviewPercent != nil { + p := *body.PreviewPercent + if p >= 1 && p <= 100 { + updates["preview_percent"] = p + } + } if body.PartID != "" { updates["part_id"] = body.PartID } diff --git a/soul-api/internal/handler/db_ckb_leads.go b/soul-api/internal/handler/db_ckb_leads.go index 702062f6..7738a112 100644 --- a/soul-api/internal/handler/db_ckb_leads.go +++ b/soul-api/internal/handler/db_ckb_leads.go @@ -108,6 +108,74 @@ func DBCKBLeadList(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"success": true, "records": out, "total": total, "page": page, "pageSize": pageSize}) } +// CKBPersonLeadStats GET /api/db/ckb-person-leads 每个人物的获客线索统计及明细 +func CKBPersonLeadStats(c *gin.Context) { + db := database.DB() + personToken := c.Query("token") + + if personToken != "" { + // 返回某人物的线索明细(通过 token → Person.PersonID → CkbLeadRecord.TargetPersonID) + var person model.Person + if err := db.Where("token = ?", personToken).First(&person).Error; err != nil { + c.JSON(http.StatusOK, gin.H{"success": false, "error": "人物不存在"}) + return + } + page, _ := strconv.Atoi(c.DefaultQuery("page", "1")) + pageSize, _ := strconv.Atoi(c.DefaultQuery("pageSize", "20")) + if page < 1 { + page = 1 + } + if pageSize < 1 || pageSize > 100 { + pageSize = 20 + } + q := db.Model(&model.CkbLeadRecord{}).Where("target_person_id = ?", person.Token) + var total int64 + q.Count(&total) + var records []model.CkbLeadRecord + q.Order("created_at DESC").Offset((page - 1) * pageSize).Limit(pageSize).Find(&records) + out := make([]gin.H, 0, len(records)) + for _, r := range records { + out = append(out, gin.H{ + "id": r.ID, + "userId": r.UserID, + "nickname": r.Nickname, + "phone": r.Phone, + "wechatId": r.WechatID, + "name": r.Name, + "source": r.Source, + "createdAt": r.CreatedAt, + }) + } + c.JSON(http.StatusOK, gin.H{ + "success": true, + "personName": person.Name, + "records": out, + "total": total, + "page": page, + "pageSize": pageSize, + }) + return + } + + // 无 token 参数:返回所有人物的获客数量汇总 + type PersonLeadStat struct { + Token string `gorm:"column:target_person_id" json:"token"` + Total int64 `gorm:"column:total" json:"total"` + } + var stats []PersonLeadStat + db.Raw("SELECT target_person_id, COUNT(*) as total FROM ckb_lead_records WHERE target_person_id != '' GROUP BY target_person_id").Scan(&stats) + + // 同时统计全局(无特定人物的)线索 + var globalTotal int64 + db.Model(&model.CkbLeadRecord{}).Where("target_person_id = '' OR target_person_id IS NULL").Count(&globalTotal) + + c.JSON(http.StatusOK, gin.H{ + "success": true, + "byPerson": stats, + "globalLeads": globalTotal, + }) +} + // CKBPlanStats GET /api/db/ckb-plan-stats 存客宝获客计划统计(基于 ckb_submit_records + ckb_lead_records) func CKBPlanStats(c *gin.Context) { db := database.DB() diff --git a/soul-api/internal/handler/db_link_tag.go b/soul-api/internal/handler/db_link_tag.go index ca756e5f..054a8e86 100644 --- a/soul-api/internal/handler/db_link_tag.go +++ b/soul-api/internal/handler/db_link_tag.go @@ -24,6 +24,7 @@ func DBLinkTagSave(c *gin.Context) { var body struct { TagID string `json:"tagId"` Label string `json:"label"` + Aliases string `json:"aliases"` URL string `json:"url"` Type string `json:"type"` AppID string `json:"appId"` @@ -48,6 +49,7 @@ func DBLinkTagSave(c *gin.Context) { var existing model.LinkTag if db.Where("tag_id = ?", body.TagID).First(&existing).Error == nil { existing.Label = body.Label + existing.Aliases = body.Aliases existing.URL = body.URL existing.Type = body.Type existing.AppID = body.AppID @@ -57,7 +59,7 @@ func DBLinkTagSave(c *gin.Context) { return } // body.URL 已在 miniprogram 类型时置空 - t := model.LinkTag{TagID: body.TagID, Label: body.Label, URL: body.URL, Type: body.Type, AppID: body.AppID, PagePath: body.PagePath} + t := model.LinkTag{TagID: body.TagID, Label: body.Label, Aliases: body.Aliases, URL: body.URL, Type: body.Type, AppID: body.AppID, PagePath: body.PagePath} if err := db.Create(&t).Error; err != nil { c.JSON(http.StatusOK, gin.H{"success": false, "error": err.Error()}) return diff --git a/soul-api/internal/handler/db_person.go b/soul-api/internal/handler/db_person.go index 47f07efd..bbe02ffa 100644 --- a/soul-api/internal/handler/db_person.go +++ b/soul-api/internal/handler/db_person.go @@ -45,6 +45,7 @@ func DBPersonSave(c *gin.Context) { var body struct { PersonID string `json:"personId"` Name string `json:"name"` + Aliases string `json:"aliases"` Label string `json:"label"` CkbApiKey string `json:"ckbApiKey"` // 存客宝真实密钥,留空则 fallback 全局 Key Greeting string `json:"greeting"` @@ -71,6 +72,7 @@ func DBPersonSave(c *gin.Context) { var existing model.Person if db.Where("person_id = ?", body.PersonID).First(&existing).Error == nil { existing.Name = body.Name + existing.Aliases = body.Aliases existing.Label = body.Label existing.CkbApiKey = body.CkbApiKey existing.Greeting = body.Greeting @@ -175,6 +177,7 @@ func DBPersonSave(c *gin.Context) { PersonID: body.PersonID, Token: tok, Name: body.Name, + Aliases: body.Aliases, Label: body.Label, CkbApiKey: apiKey, CkbPlanID: planID, diff --git a/soul-api/internal/handler/miniprogram.go b/soul-api/internal/handler/miniprogram.go index 59a0d9fb..608ce4e8 100644 --- a/soul-api/internal/handler/miniprogram.go +++ b/soul-api/internal/handler/miniprogram.go @@ -98,6 +98,9 @@ func MiniprogramLogin(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "创建用户失败"}) return } + // 记录注册行为到 user_tracks + trackID := fmt.Sprintf("track_%d", time.Now().UnixNano()%100000000) + db.Create(&model.UserTrack{ID: trackID, UserID: user.ID, Action: "register"}) // 新用户:异步调用神射手自动打标(手机号尚未绑定,phone 为空时暂不调用) AdminShensheShouAutoTag(userID, "") } else { @@ -723,6 +726,9 @@ func MiniprogramPhone(c *gin.Context) { if req.UserID != "" { db := database.DB() db.Model(&model.User{}).Where("id = ?", req.UserID).Update("phone", phoneNumber) + // 记录绑定手机号行为到 user_tracks + trackID := fmt.Sprintf("track_%d", time.Now().UnixNano()%100000000) + db.Create(&model.UserTrack{ID: trackID, UserID: req.UserID, Action: "bind_phone"}) fmt.Printf("[MiniprogramPhone] 手机号已绑定到用户: %s\n", req.UserID) // 绑定手机号后,异步调用神射手自动完善标签 AdminShensheShouAutoTag(req.UserID, phoneNumber) diff --git a/soul-api/internal/handler/oss.go b/soul-api/internal/handler/oss.go new file mode 100644 index 00000000..aa8180f9 --- /dev/null +++ b/soul-api/internal/handler/oss.go @@ -0,0 +1,137 @@ +package handler + +import ( + "encoding/json" + "fmt" + "io" + "mime/multipart" + "strings" + "time" + + "github.com/aliyun/aliyun-oss-go-sdk/oss" + + "soul-api/internal/database" + "soul-api/internal/model" +) + +type ossConfigCache struct { + Endpoint string `json:"endpoint"` + AccessKeyID string `json:"accessKeyId"` + AccessKeySecret string `json:"accessKeySecret"` + Bucket string `json:"bucket"` + Region string `json:"region"` +} + +func getOssConfig() *ossConfigCache { + db := database.DB() + var row model.SystemConfig + if err := db.Where("config_key = ?", "oss_config").First(&row).Error; err != nil { + return nil + } + var cfg ossConfigCache + if err := json.Unmarshal(row.ConfigValue, &cfg); err != nil { + return nil + } + if cfg.Endpoint == "" || cfg.AccessKeyID == "" || cfg.AccessKeySecret == "" || cfg.Bucket == "" { + return nil + } + return &cfg +} + +func ossUploadFile(file multipart.File, folder, filename string) (string, error) { + cfg := getOssConfig() + if cfg == nil { + return "", fmt.Errorf("OSS 未配置") + } + + endpoint := cfg.Endpoint + if !strings.HasPrefix(endpoint, "http://") && !strings.HasPrefix(endpoint, "https://") { + endpoint = "https://" + endpoint + } + + client, err := oss.New(endpoint, cfg.AccessKeyID, cfg.AccessKeySecret) + if err != nil { + return "", fmt.Errorf("创建 OSS 客户端失败: %w", err) + } + + bucket, err := client.Bucket(cfg.Bucket) + if err != nil { + return "", fmt.Errorf("获取 Bucket 失败: %w", err) + } + + objectKey := fmt.Sprintf("%s/%s/%s", folder, time.Now().Format("2006-01"), filename) + + data, err := io.ReadAll(file) + if err != nil { + return "", fmt.Errorf("读取文件失败: %w", err) + } + + err = bucket.PutObject(objectKey, strings.NewReader(string(data))) + if err != nil { + return "", fmt.Errorf("上传 OSS 失败: %w", err) + } + + signedURL, err := bucket.SignURL(objectKey, oss.HTTPGet, 3600*24*365*10) + if err != nil { + host := cfg.Bucket + "." + cfg.Endpoint + if !strings.HasPrefix(cfg.Endpoint, "http://") && !strings.HasPrefix(cfg.Endpoint, "https://") { + host = cfg.Bucket + "." + cfg.Endpoint + } else { + host = strings.Replace(cfg.Endpoint, "://", "://"+cfg.Bucket+".", 1) + } + if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") { + host = "https://" + host + } + return host + "/" + objectKey, nil + } + return signedURL, nil +} + +func ossUploadBytes(data []byte, folder, filename, contentType string) (string, error) { + cfg := getOssConfig() + if cfg == nil { + return "", fmt.Errorf("OSS 未配置") + } + + endpoint := cfg.Endpoint + if !strings.HasPrefix(endpoint, "http://") && !strings.HasPrefix(endpoint, "https://") { + endpoint = "https://" + endpoint + } + + client, err := oss.New(endpoint, cfg.AccessKeyID, cfg.AccessKeySecret) + if err != nil { + return "", fmt.Errorf("创建 OSS 客户端失败: %w", err) + } + + bucket, err := client.Bucket(cfg.Bucket) + if err != nil { + return "", fmt.Errorf("获取 Bucket 失败: %w", err) + } + + objectKey := fmt.Sprintf("%s/%s/%s", folder, time.Now().Format("2006-01"), filename) + + var opts []oss.Option + if contentType != "" { + opts = append(opts, oss.ContentType(contentType)) + } + + err = bucket.PutObject(objectKey, strings.NewReader(string(data)), opts...) + if err != nil { + return "", fmt.Errorf("上传 OSS 失败: %w", err) + } + + signedURL, err := bucket.SignURL(objectKey, oss.HTTPGet, 3600*24*365*10) + if err != nil { + host := cfg.Bucket + "." + cfg.Endpoint + if !strings.HasPrefix(cfg.Endpoint, "http://") && !strings.HasPrefix(cfg.Endpoint, "https://") { + host = cfg.Bucket + "." + cfg.Endpoint + } else { + host = strings.Replace(cfg.Endpoint, "://", "://"+cfg.Bucket+".", 1) + } + if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") { + host = "https://" + host + } + return host + "/" + objectKey, nil + } + return signedURL, nil +} diff --git a/soul-api/internal/handler/search.go b/soul-api/internal/handler/search.go index 41bdbec2..69c36745 100644 --- a/soul-api/internal/handler/search.go +++ b/soul-api/internal/handler/search.go @@ -46,7 +46,7 @@ func SearchGet(c *gin.Context) { Select("id, mid, section_title, part_title, chapter_title, price, is_free, '' as snippet"). Where("section_title LIKE ?", pattern). Order("sort_order ASC, id ASC"). - Limit(30). + Limit(3). Find(&titleMatches) titleIDs := make(map[string]bool, len(titleMatches)) @@ -55,7 +55,7 @@ func SearchGet(c *gin.Context) { } // 第二步:内容匹配(排除已命中标题的,用 SQL 提取摘要避免加载完整 content) - remaining := 50 - len(titleMatches) + remaining := 20 - len(titleMatches) var contentMatches []searchRow if remaining > 0 { contentQ := db.Model(&model.Chapter{}). diff --git a/soul-api/internal/handler/upload.go b/soul-api/internal/handler/upload.go index b8ff1fa7..0ca4e7c4 100644 --- a/soul-api/internal/handler/upload.go +++ b/soul-api/internal/handler/upload.go @@ -16,7 +16,7 @@ const uploadDir = "uploads" const maxUploadBytes = 5 * 1024 * 1024 // 5MB var allowedTypes = map[string]bool{"image/jpeg": true, "image/png": true, "image/gif": true, "image/webp": true} -// UploadPost POST /api/upload 上传图片(表单 file) +// UploadPost POST /api/upload 上传图片(表单 file),优先 OSS func UploadPost(c *gin.Context) { file, err := c.FormFile("file") if err != nil { @@ -40,16 +40,30 @@ func UploadPost(c *gin.Context) { if folder == "" { folder = "avatars" } + name := fmt.Sprintf("%d_%s%s", time.Now().UnixNano(), randomStrUpload(6), ext) + + // 尝试 OSS 上传 + if ossCfg := getOssConfig(); ossCfg != nil { + src, err := file.Open() + if err == nil { + defer src.Close() + if ossURL, err := ossUploadFile(src, folder, name); err == nil { + c.JSON(http.StatusOK, gin.H{"success": true, "url": ossURL, "data": gin.H{"url": ossURL, "fileName": name, "size": file.Size, "type": ct, "storage": "oss"}}) + return + } + } + } + + // 回退本地存储 dir := filepath.Join(uploadDir, folder) _ = os.MkdirAll(dir, 0755) - name := fmt.Sprintf("%d_%s%s", time.Now().UnixNano(), randomStrUpload(6), ext) dst := filepath.Join(dir, name) if err := c.SaveUploadedFile(file, dst); err != nil { c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "保存失败"}) return } url := "/" + filepath.ToSlash(filepath.Join(uploadDir, folder, name)) - c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": file.Size, "type": ct}}) + c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": file.Size, "type": ct, "storage": "local"}}) } func randomStrUpload(n int) string { diff --git a/soul-api/internal/handler/upload_content.go b/soul-api/internal/handler/upload_content.go index aefc9cb1..d54c5623 100644 --- a/soul-api/internal/handler/upload_content.go +++ b/soul-api/internal/handler/upload_content.go @@ -34,11 +34,11 @@ var ( "image/jpeg": true, "image/png": true, "image/gif": true, "image/webp": true, } allowedVideoTypes = map[string]bool{ - "video/mp4": true, "video/quicktime": true, "video/x-msvideo": true, + "video/mp4": true, "video/quicktime": true, "video/webm": true, "video/x-msvideo": true, } ) -// UploadImagePost POST /api/miniprogram/upload/image 小程序-图片上传(支持压缩) +// UploadImagePost POST /api/miniprogram/upload/image 小程序-图片上传(支持压缩),优先 OSS // 表单:file(必填), folder(可选,默认 images), quality(可选 1-100,默认 85) func UploadImagePost(c *gin.Context) { file, err := c.FormFile("file") @@ -65,14 +65,11 @@ func UploadImagePost(c *gin.Context) { if folder == "" { folder = "images" } - dir := filepath.Join(uploadDirContent, folder) - _ = os.MkdirAll(dir, 0755) ext := filepath.Ext(file.Filename) if ext == "" { ext = ".jpg" } name := fmt.Sprintf("%d_%s%s", time.Now().UnixNano(), randomStrContent(6), ext) - dst := filepath.Join(dir, name) src, err := file.Open() if err != nil { @@ -85,61 +82,58 @@ func UploadImagePost(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "读取文件失败"}) return } - // JPEG:支持质量压缩 + + // JPEG 压缩 + var finalData []byte + finalCt := ct if strings.Contains(ct, "jpeg") || strings.Contains(ct, "jpg") { - img, err := jpeg.Decode(bytes.NewReader(data)) - if err == nil { + if img, err := jpeg.Decode(bytes.NewReader(data)); err == nil { var buf bytes.Buffer if err := jpeg.Encode(&buf, img, &jpeg.Options{Quality: quality}); err == nil { - if err := os.WriteFile(dst, buf.Bytes(), 0644); err == nil { - url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) - c.JSON(http.StatusOK, gin.H{ - "success": true, "url": url, - "data": gin.H{"url": url, "fileName": name, "size": int64(buf.Len()), "type": ct, "quality": quality}, - }) - return - } + finalData = buf.Bytes() } } - } - // PNG/GIF:解码后原样保存 - if strings.Contains(ct, "png") { - img, err := png.Decode(bytes.NewReader(data)) - if err == nil { + } else if strings.Contains(ct, "png") { + if img, err := png.Decode(bytes.NewReader(data)); err == nil { var buf bytes.Buffer if err := png.Encode(&buf, img); err == nil { - if err := os.WriteFile(dst, buf.Bytes(), 0644); err == nil { - url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) - c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": int64(buf.Len()), "type": ct}}) - return - } + finalData = buf.Bytes() } } - } - if strings.Contains(ct, "gif") { - img, err := gif.Decode(bytes.NewReader(data)) - if err == nil { + } else if strings.Contains(ct, "gif") { + if img, err := gif.Decode(bytes.NewReader(data)); err == nil { var buf bytes.Buffer if err := gif.Encode(&buf, img, nil); err == nil { - if err := os.WriteFile(dst, buf.Bytes(), 0644); err == nil { - url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) - c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": int64(buf.Len()), "type": ct}}) - return - } + finalData = buf.Bytes() } } } + if finalData == nil { + finalData = data + } - // 其他格式或解析失败时直接写入 - if err := os.WriteFile(dst, data, 0644); err != nil { + // 优先 OSS 上传 + if ossURL, err := ossUploadBytes(finalData, folder, name, finalCt); err == nil { + c.JSON(http.StatusOK, gin.H{ + "success": true, "url": ossURL, + "data": gin.H{"url": ossURL, "fileName": name, "size": int64(len(finalData)), "type": ct, "quality": quality, "storage": "oss"}, + }) + return + } + + // 回退本地存储 + dir := filepath.Join(uploadDirContent, folder) + _ = os.MkdirAll(dir, 0755) + dst := filepath.Join(dir, name) + if err := os.WriteFile(dst, finalData, 0644); err != nil { c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "保存失败"}) return } url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) - c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": int64(len(data)), "type": ct}}) + c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": int64(len(finalData)), "type": ct, "quality": quality, "storage": "local"}}) } -// UploadVideoPost POST /api/miniprogram/upload/video 小程序-视频上传(指定目录) +// UploadVideoPost POST /api/miniprogram/upload/video 小程序-视频上传,优先 OSS // 表单:file(必填), folder(可选,默认 videos) func UploadVideoPost(c *gin.Context) { file, err := c.FormFile("file") @@ -160,13 +154,30 @@ func UploadVideoPost(c *gin.Context) { if folder == "" { folder = "videos" } - dir := filepath.Join(uploadDirContent, folder) - _ = os.MkdirAll(dir, 0755) ext := filepath.Ext(file.Filename) if ext == "" { ext = ".mp4" } name := fmt.Sprintf("%d_%s%s", time.Now().UnixNano(), randomStrContent(8), ext) + + // 优先 OSS 上传 + if ossCfg := getOssConfig(); ossCfg != nil { + src, err := file.Open() + if err == nil { + defer src.Close() + if ossURL, err := ossUploadFile(src, folder, name); err == nil { + c.JSON(http.StatusOK, gin.H{ + "success": true, "url": ossURL, + "data": gin.H{"url": ossURL, "fileName": name, "size": file.Size, "type": ct, "folder": folder, "storage": "oss"}, + }) + return + } + } + } + + // 回退本地存储 + dir := filepath.Join(uploadDirContent, folder) + _ = os.MkdirAll(dir, 0755) dst := filepath.Join(dir, name) if err := c.SaveUploadedFile(file, dst); err != nil { c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "保存失败"}) @@ -175,7 +186,7 @@ func UploadVideoPost(c *gin.Context) { url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) c.JSON(http.StatusOK, gin.H{ "success": true, "url": url, - "data": gin.H{"url": url, "fileName": name, "size": file.Size, "type": ct, "folder": folder}, + "data": gin.H{"url": url, "fileName": name, "size": file.Size, "type": ct, "folder": folder, "storage": "local"}, }) } diff --git a/soul-api/internal/handler/user.go b/soul-api/internal/handler/user.go index c194aed2..adef0e8a 100644 --- a/soul-api/internal/handler/user.go +++ b/soul-api/internal/handler/user.go @@ -1,6 +1,7 @@ package handler import ( + "encoding/json" "fmt" "net/http" "strconv" @@ -595,6 +596,11 @@ func UserTrackPost(c *gin.Context) { if body.Target != "" { t.ChapterID = &chID } + if body.ExtraData != nil { + if raw, err := json.Marshal(body.ExtraData); err == nil { + t.ExtraData = raw + } + } if err := db.Create(&t).Error; err != nil { c.JSON(http.StatusOK, gin.H{"success": false, "error": err.Error()}) return diff --git a/soul-api/internal/model/chapter.go b/soul-api/internal/model/chapter.go index f6bc182e..0d189b44 100644 --- a/soul-api/internal/model/chapter.go +++ b/soul-api/internal/model/chapter.go @@ -21,7 +21,8 @@ type Chapter struct { // 普通版/增值版:两者分开互斥,添加文章时勾选归属 EditionStandard *bool `gorm:"column:edition_standard" json:"editionStandard,omitempty"` // 是否属于普通版 EditionPremium *bool `gorm:"column:edition_premium" json:"editionPremium,omitempty"` // 是否属于增值版 - HotScore int `gorm:"column:hot_score;default:0" json:"hotScore"` // 热度分,用于排名算法 + HotScore float64 `gorm:"column:hot_score;type:decimal(10,2);default:0" json:"hotScore"` // 热度分(加权计算),用于排名算法 + PreviewPercent *int `gorm:"column:preview_percent" json:"previewPercent,omitempty"` // 章节级预览比例(%),nil 表示使用全局设置 CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` } diff --git a/soul-api/internal/model/link_tag.go b/soul-api/internal/model/link_tag.go index 5f9f1bd5..2eb45f01 100644 --- a/soul-api/internal/model/link_tag.go +++ b/soul-api/internal/model/link_tag.go @@ -7,6 +7,7 @@ type LinkTag struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` TagID string `gorm:"column:tag_id;size:50;uniqueIndex" json:"tagId"` Label string `gorm:"column:label;size:200" json:"label"` + Aliases string `gorm:"column:aliases;size:500;default:''" json:"aliases"` // comma-separated alternative labels URL string `gorm:"column:url;size:500" json:"url"` Type string `gorm:"column:type;size:20" json:"type"` AppID string `gorm:"column:app_id;size:100" json:"appId,omitempty"` diff --git a/soul-api/internal/model/person.go b/soul-api/internal/model/person.go index f6790935..8e86ab96 100644 --- a/soul-api/internal/model/person.go +++ b/soul-api/internal/model/person.go @@ -9,8 +9,9 @@ type Person struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` PersonID string `gorm:"column:person_id;size:50;uniqueIndex" json:"personId"` - Token string `gorm:"column:token;size:36;uniqueIndex" json:"token"` // 32 位唯一 token,文章/小程序传此值 + Token string `gorm:"column:token;size:36;index" json:"token"` // 32 位唯一 token,文章/小程序传此值 Name string `gorm:"column:name;size:100" json:"name"` + Aliases string `gorm:"column:aliases;size:500;default:''" json:"aliases"` // comma-separated alternative names (马甲) Label string `gorm:"column:label;size:200" json:"label"` CkbApiKey string `gorm:"column:ckb_api_key;size:100;default:''" json:"ckbApiKey"` // 存客宝真实密钥,不对外暴露 diff --git a/soul-api/internal/model/user.go b/soul-api/internal/model/user.go index 066f8aef..397c8e49 100644 --- a/soul-api/internal/model/user.go +++ b/soul-api/internal/model/user.go @@ -11,6 +11,7 @@ type User struct { Avatar *string `gorm:"column:avatar;size:500" json:"avatar,omitempty"` Phone *string `gorm:"column:phone;size:20" json:"phone,omitempty"` WechatID *string `gorm:"column:wechat_id;size:100" json:"wechatId,omitempty"` + Tags *string `gorm:"column:tags;type:text" json:"tags,omitempty"` // P3 资料扩展(stitch_soul) Mbti *string `gorm:"column:mbti;size:16" json:"mbti,omitempty"` Region *string `gorm:"column:region;size:100" json:"region,omitempty"` @@ -49,7 +50,8 @@ type User struct { VipBio *string `gorm:"column:vip_bio;type:text" json:"vipBio,omitempty"` // 以下为接口返回时从订单/绑定表实时计算的字段,不入库 - PurchasedSectionCount int `gorm:"-" json:"purchasedSectionCount,omitempty"` + PurchasedSectionCount int `gorm:"-" json:"purchasedSectionCount,omitempty"` + WalletBalance *float64 `gorm:"-" json:"walletBalance,omitempty"` } func (User) TableName() string { return "users" } diff --git a/soul-api/internal/router/router.go b/soul-api/internal/router/router.go index 678a76b1..23f9cb19 100644 --- a/soul-api/internal/router/router.go +++ b/soul-api/internal/router/router.go @@ -49,6 +49,7 @@ func Setup(cfg *config.Config) *gin.Engine { admin.PUT("/content", handler.AdminContent) admin.DELETE("/content", handler.AdminContent) admin.GET("/dashboard/stats", handler.AdminDashboardStats) + admin.GET("/track/stats", handler.AdminTrackStats) admin.GET("/dashboard/recent-orders", handler.AdminDashboardRecentOrders) admin.GET("/dashboard/new-users", handler.AdminDashboardNewUsers) admin.GET("/dashboard/overview", handler.AdminDashboardOverview) @@ -85,6 +86,7 @@ func Setup(cfg *config.Config) *gin.Engine { admin.PUT("/users", handler.AdminUsersAction) admin.DELETE("/users", handler.AdminUsersAction) admin.GET("/orders", handler.OrdersList) + admin.GET("/balance/summary", handler.BalanceSummary) } // ----- 鉴权 ----- @@ -148,6 +150,10 @@ func Setup(cfg *config.Config) *gin.Engine { db.GET("/migrate", handler.DBMigrateGet) db.POST("/migrate", handler.DBMigratePost) db.GET("/users", handler.DBUsersList) + db.GET("/users/journey-stats", handler.DBUsersJourneyStats) + db.GET("/users/journey-users", handler.DBUsersJourneyUsers) + db.GET("/users/rfm", handler.DBUsersRFM) + db.GET("/users/rfm-single", handler.DBUserRFMSingle) db.POST("/users", handler.DBUsersAction) db.PUT("/users", handler.DBUsersAction) db.DELETE("/users", handler.DBUsersDelete) @@ -171,8 +177,9 @@ func Setup(cfg *config.Config) *gin.Engine { db.GET("/link-tags", handler.DBLinkTagList) db.POST("/link-tags", handler.DBLinkTagSave) db.DELETE("/link-tags", handler.DBLinkTagDelete) - db.GET("/ckb-leads", handler.DBCKBLeadList) - db.GET("/ckb-plan-stats", handler.CKBPlanStats) + db.GET("/ckb-leads", handler.DBCKBLeadList) + db.GET("/ckb-person-leads", handler.CKBPersonLeadStats) + db.GET("/ckb-plan-stats", handler.CKBPlanStats) } // ----- 分销 ----- @@ -225,6 +232,7 @@ func Setup(cfg *config.Config) *gin.Engine { // ----- 上传 ----- api.POST("/upload", handler.UploadPost) + api.POST("/upload/video", handler.UploadVideoPost) api.DELETE("/upload", handler.UploadDelete) // ----- 用户 ----- @@ -294,6 +302,7 @@ func Setup(cfg *config.Config) *gin.Engine { miniprogram.GET("/user/purchase-status", handler.UserPurchaseStatus) miniprogram.GET("/user/reading-progress", handler.UserReadingProgressGet) miniprogram.POST("/user/reading-progress", handler.UserReadingProgressPost) + miniprogram.POST("/track", handler.UserTrackPost) miniprogram.POST("/user/update", handler.UserUpdate) miniprogram.POST("/withdraw", handler.WithdrawPost) miniprogram.GET("/withdraw/records", handler.WithdrawRecords)