diff --git a/.cursor/agent/智能体-技能-经验总索引.md b/.cursor/agent/智能体-技能-经验总索引.md new file mode 100644 index 00000000..e779b6c0 --- /dev/null +++ b/.cursor/agent/智能体-技能-经验总索引.md @@ -0,0 +1,88 @@ +# 智能体技能&经验总索引 + +用途:让任何智能体在“开始实现或回答”之前,先快速匹配“有没有相关经验”和“应该用哪个 Skill”,再综合处理。 + +--- + +## 1. 经验索引(按角色) + +- 助理橙子:`agent/开发助理/evolution/索引.md` + - 2026-03-21:MBTI 头像小程序全链路兜底 + 匹配接口回填 + - 2026-03-16:用户交互习惯分析(基于 agent-transcripts) +- 小程序开发工程师:`agent/小程序开发工程师/evolution/索引.md` + - 2026-03-30:阅读页 `navigateToMiniProgram` 时 path 追加 `phone` + - 2026-03-17:代付美团式流程与目录 loading/折叠 + - 2026-03-16:编辑资料页分享名片(Canvas 封面) +- 管理端开发工程师:`agent/管理端开发工程师/evolution/索引.md` + - 2026-03-16:链接人与事(复制/删除 Dialog、planId/apiKey 列) + - 2026-03-10:迁移 Mycontent-temp(主导航收敛/Settings 承载) + - 2026-03-05:文章详情@某人(编辑页插入 @ 用户) +- 后端工程师:`agent/后端工程师/evolution/索引.md` + - 2026-03-24:router 缺失四 handler 补齐(BookRanking 等) + - 2026-03-17:PayNotify 权益归属发起人 + - 2026-03-14:内容排名算法修正(rank 分公式) +- 产品经理:`agent/产品经理/evolution/索引.md` + - 2026-03-24:开发进度同步会议(文档同步原则/项目索引补齐) + - 2026-03-10:需求同步(管理端迁移入口策略) + - 2026-03-05:文章详情@某人(验收标准与待确认) +- 软件测试:`agent/软件测试/evolution/索引.md` + - 2026-03-16:scripts/test/process 流程测试目录 + - 2026-03-05:文章详情@某人(用例、联调与回归点) + - 2026-03-10:管理端迁移回归(鉴权/跳转可达性) +- 安全工程师:`agent/安全工程师/evolution/索引.md` + - 2026-03-20:挖矿病毒排查经验转化为 Skills + - 2026-03-20:部署 API / 部署触发词(环境与脚本映射) +- 团队(跨角色共享):`agent/团队/evolution/索引.md` + - 2026-03-16:TipTap Mention 需 data-label + - 2026-03-17:代付美团式流程与权益归属约定 + - 2026-03-24:文档同步原则(实现变更后同步需求/运营/索引) +- 老板分身:`agent/老板分身/evolution/索引.md` + +--- + +## 2. 技能索引(按任务类型/触发) + +- 小程序开发(WXML/WXSS/JS、`/api/miniprogram/*`):`skills/miniprogram-dev/SKILL.md` + - 触发:`miniprogram/`、小程序、微信原生、C 端能力改动 +- 管理端开发(React/Vite、`/api/admin/*`、`/api/db/*`、禁止 `alert`):`skills/admin-dev/SKILL.md` + - 触发:`soul-admin/`、管理端、React 后台、调用 admin/db 接口 +- 后端开发(Go/Gin/GORM、路由分组):`skills/api-dev/SKILL.md` + - 触发:`soul-api`、API、Go、GORM、新增接口/路由分组 +- 产品经理(需求分析/验收/加个需求):`skills/product-manager/SKILL.md` + - 触发:需求分析、需求文档、验收、加个需求 +- 测试(功能/回归/三端联调):`skills/testing/SKILL.md` + - 触发:测试、测试用例、回归测试、QA +- 助理橙子(文档同步/经验入库/会议结束/日志):`skills/assistant-doc-sync/SKILL.md` + - 触发:小橙/橙子/橙橙/🍊、讨论完毕、吸收经验、保存进度、会议结束、出日志 +- 团队会议(多角色发言、决议、纪要):`skills/team-meeting/SKILL.md` + - 触发:开个会、团队会议、需求评审、方案讨论 +- 变更关联检查(防漏改,改完必过):`skills/change-checklist/SKILL.md` + - 触发:变更完成、检查一下、准备提交 +- 跨端协同流程(职责分工/联想补齐):`skills/role-flow-control/SKILL.md` + - 触发:跨端功能开发、三端联动优化 +- 三端架构分析/迁移拆解约束:`skills/three-tier-arch/SKILL.md` + - 触发:拆解、迁移、框架选择、三端架构 +- 新版快速分析(甲方/第三方改版补齐逻辑与接口规范):`skills/new-version-analyze/SKILL.md` + - 触发:新版分析、版本对比、迁移分析、甲方代码分析 +- next-project 仅预览说明:`skills/next-preview/SKILL.md` + - 触发:区分线上后端与 next-project 预览 +- Next.js 拆解为前后端分离+小程序:`skills/next-split/SKILL.md` + - 触发:Next 全栈拆解、架构迁移 +- MySQL 直连操作(MCP 不通时执行 DDL/DML):`skills/mysql-direct/SKILL.md` + - 触发:数据库操作、增减字段、紧急迁移、MCP 连接失败 +- 挖矿病毒排查与防护(xmrig/miner_guard 等):`skills/security-miner-guard/SKILL.md` + - 触发:挖矿病毒、xmrig、服务器被入侵、杀挖矿 +- 服务器操作与部署(SSH/宝塔/Cunkebao):`skills/security-server-ops/SKILL.md` + - 触发:部署、服务器操作、SSH、devloy、master +- 卡若创业派对运营(报表/切片/分发/飞书视频文字下载):`skills/karuo-party/SKILL.md` + - 触发:运营报表、视频切片、多平台分发、飞书视频下载、派对运营 + +--- + +## 3. 使用流程(任何智能体都照做) + +1. 先归类:根据编辑目录或触发词判断“可能涉及哪些角色/任务类型”。 +2. 再查经验:打开对应角色的 `evolution/索引.md`,找最近且最贴近的经验条目。 +3. 再查技能:打开对应 Skill 的 `SKILL.md`,按其执行流程/约束落地。 +4. 再综合:若命中多个条目,按“边界规则 + 变更闭环(如 change-checklist)+ 必要的联动(如会议/跨端)”合并决策。 + diff --git a/.cursor/plans/vip-members-person-文章绑定超级个体.md b/.cursor/plans/vip-members-person-文章绑定超级个体.md new file mode 100644 index 00000000..e8f0764e --- /dev/null +++ b/.cursor/plans/vip-members-person-文章绑定超级个体.md @@ -0,0 +1,26 @@ +--- +name: vip-members Person 聚合 + 文章绑定超级个体 +overview: 见 Cursor 计划「vip-members_person_聚合」;含文章绑定超级个体与白名单 Webhook。执行前以本文件与 Cursor plan 同步为准。 +--- + +完整内容与 todos 见 IDE 内计划:`vip-members_person_聚合_2b9cac41.plan.md`(或从命令面板打开 Current Plan)。 + +要点摘要: + +1. **原有三项**:vip-members 聚合 Person、UsersPage @列、ContentPage `?tab=link-person`。 +2. **新增**:`chapters.bound_super_user_id`;管理端章节绑定超级个体;读文接口返回绑定信息。 +3. **Webhook**:仅**白名单**埋点(分享/朋友圈/购买/单页解锁引导 + 补 `view_chapter`);`MiniprogramTrackPost` 后推送,使用 `loadLeadWebhookURL`,**独立去重**勿与获客日去重混用。 +4. **留资**:`ckb/lead` 按章节绑定合并 `TargetMemberID`,新增来源文案。 + +用户已选推送策略:**白名单关键事件**(非全量节流、非定时摘要)。 + +--- + +## 补充:找伙伴(终身 1 次免费 + ¥9.9 划线 / ¥1) + +- **规则与 UI**:后端 `match.go` 与小程序 `match` 页已基本实现「终身 1 次免费、不按天重置」及划线原价 + 现价展示。 +- **支付对齐**:`getStandardPrice(match)` 当前误读 `chapter_config` 且兜底 **¥68**,需改为读 **`match_config.matchPrice`**、兜底 **¥1**(详见 Cursor 主计划文末章节与 todo `match-quota-pay-align`)。 + +- **#标签·内部跳转**:与现有 `type=internal`(管理端现名「本小程序页面」)为同一能力;执行时可将文案统一为「内部跳转」(todo `linktag-internal-label`)。 + +- **行为/Webhook 中文化**:飞书「最近行为」里英文 action、英文 module、技术 target 串,需在 `user.go` 补映射与人话化 target(todo `track-webhook-cn-labels`)。 diff --git a/.cursor/rules/智能体-先查经验-技能索引.mdc b/.cursor/rules/智能体-先查经验-技能索引.mdc new file mode 100644 index 00000000..2c4d17d0 --- /dev/null +++ b/.cursor/rules/智能体-先查经验-技能索引.mdc @@ -0,0 +1,17 @@ +--- +description: 所有智能体处理任务前先查经验与技能索引 +globs: ["**"] +alwaysApply: true +--- + +# 强制流程:先查经验与技能再处理 + +当任何智能体接到“问题/需求/变更/执行”任务时,必须按以下顺序完成(不能跳过): + +1. 归类角色:根据编辑目录或触发词判断可能涉及的角色/任务类型。 +2. 查总索引:先打开 `.cursor/agent/智能体-技能-经验总索引.md` 找匹配的“经验索引文件”和“主 Skill 文件”。 +3. 查经验+查 Skill:对每个匹配条目,先读对应角色 `agent/*/evolution/索引.md`,再按边界规则读取对应主 `skills/*/SKILL.md` 完整内容。 +4. 再综合落地:确认是否还需 `change-checklist`、`team-meeting`、`role-flow-control` 等跨层 Skill 后,再回答/执行。 + +注:本规则不替代现有 project boundary 的“必须 Read 主 Skill 完整内容”的约束,只是增加“先查索引再读 Skill”的前置步骤。 + diff --git a/miniprogram/app.js b/miniprogram/app.js index c5a2914e..0e08b6ea 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -12,8 +12,8 @@ const DEFAULT_MCH_ID = '1318592501' const DEFAULT_WITHDRAW_TMPL_ID = 'u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE' // baseUrl 手动切换(注释方式): // const API_BASE_URL = 'http://localhost:9090' -// const API_BASE_URL = 'https://soulapi.quwanzhi.com' -const API_BASE_URL = 'https://souldev.quwanzhi.com' +const API_BASE_URL = 'https://soulapi.quwanzhi.com' +// const API_BASE_URL = 'https://souldev.quwanzhi.com' const CONFIG_CACHE_KEY = 'mpConfigCacheV1' /** 新用户未完成头像+昵称前,强制留在资料引导(与 avatar-nickname 页配合) */ diff --git a/miniprogram/pages/read/read.js b/miniprogram/pages/read/read.js index 3e1466bd..4ac823d5 100644 --- a/miniprogram/pages/read/read.js +++ b/miniprogram/pages/read/read.js @@ -71,7 +71,8 @@ function getContentParseConfig() { aliases: p.aliases != null ? String(p.aliases) : '', })) const linkTags = Array.isArray(g.linkTagsConfig) ? g.linkTagsConfig : [] - return { persons, linkTags } + const assetBase = String(g.baseUrl || '').replace(/\/$/, '') + return { persons, linkTags, assetBase } } /** 补全 mentionDisplay,避免旧数据无字段;昵称去空白防「@ 名」 */ diff --git a/miniprogram/utils/contentParser.js b/miniprogram/utils/contentParser.js index fa52b740..717a2898 100644 --- a/miniprogram/utils/contentParser.js +++ b/miniprogram/utils/contentParser.js @@ -27,6 +27,35 @@ function decodeEntities(str) { .replace(/'/g, "'") } +/** + * 正文里 img 的 src:管理端常见为 /uploads/...(相对 API 根),浏览器会自动补全域名; + * 小程序 不会拼接 baseUrl,需在此用 assetBase 转成可请求的绝对地址。 + * @param {string} src + * @param {string} [assetBase] - 如 https://soulapi.example.com(无末尾 /) + */ +function resolveArticleImageSrc(src, assetBase) { + if (!src || typeof src !== 'string') return src + const s = src.trim() + if (!s) return s + if (/^(https?:|wxfile:|data:|blob:)/i.test(s)) return s + if (s.startsWith('//')) return 'https:' + s + if (s.startsWith('/')) { + const base = String(assetBase || '').replace(/\/$/, '') + if (!base) return s + return base + s + } + return s +} + +/** 从 标签取出 src(双引号/单引号) */ +function extractImgSrcFromTag(tag) { + const d = tag.match(/src\s*=\s*"([^"]*)"/i) + if (d && d[1] != null) return d[1] + const q = tag.match(/src\s*=\s*'([^']*)'/i) + if (q && q[1] != null) return q[1] + return '' +} + /** * 单行展示用:昵称、#标签文案、章节外标题类字段 — 合并换行、
、连续空白(避免 TipTap/粘贴带入异常断行) */ @@ -118,11 +147,16 @@ function parseBlockToSegments(block, config) { segs.push({ type: 'linkTag', label: label || '#', url, tagType: '', pagePath: '', tagId: '' }) } else if (/^r[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 $j(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Cx={exports:{}},Kd={},Ex={exports:{}},Ct={};/** +function J5(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 $j(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Cx={exports:{}},Kd={},Ex={exports:{}},Et={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ function J5(t,e){for(var n=0;n>>1,K=V[H];if(0>>1;Ha(ue,ee))$a(Q,ue)?(V[H]=Q,V[$]=ee,H=$):(V[H]=ue,V[he]=ee,H=he);else if($a(Q,ee))V[H]=Q,V[$]=ee,H=$;else break e}}return xe}function a(V,xe){var ee=V.sortIndex-xe.sortIndex;return ee!==0?ee:V.id-xe.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,x=3,b=!1,N=!1,w=!1,v=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,M=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(V){for(var xe=n(h);xe!==null;){if(xe.callback===null)r(h);else if(xe.startTime<=V)r(h),xe.sortIndex=xe.expirationTime,e(u,xe);else break;xe=n(h)}}function L(V){if(w=!1,E(V),!N)if(n(u)!==null)N=!0,I(R);else{var xe=n(h);xe!==null&&X(L,xe.startTime-V)}}function R(V,xe){N=!1,w&&(w=!1,k(B),B=-1),b=!0;var ee=x;try{for(E(xe),m=n(u);m!==null&&(!(m.expirationTime>xe)||V&&!ae());){var H=m.callback;if(typeof H=="function"){m.callback=null,x=m.priorityLevel;var K=H(m.expirationTime<=xe);xe=t.unstable_now(),typeof K=="function"?m.callback=K:m===n(u)&&r(u),E(xe)}else r(u);m=n(u)}if(m!==null)var fe=!0;else{var he=n(h);he!==null&&X(L,he.startTime-xe),fe=!1}return fe}finally{m=null,x=ee,b=!1}}var W=!1,P=null,B=-1,O=5,Y=-1;function ae(){return!(t.unstable_now()-YV||125H?(V.sortIndex=ee,e(h,V),n(u)===null&&V===n(h)&&(w?(k(B),B=-1):w=!0,X(L,ee-H))):(V.sortIndex=K,e(u,V),N||b||(N=!0,I(R))),V},t.unstable_shouldYield=ae,t.unstable_wrapCallback=function(V){var xe=x;return function(){var ee=x;x=xe;try{return V.apply(this,arguments)}finally{x=ee}}}})(Ax)),Ax}var g1;function eE(){return g1||(g1=1,Mx.exports=Z5()),Mx.exports}/** + */var x1;function Z5(){return x1||(x1=1,(function(t){function e(V,xe){var ee=V.length;V.push(xe);e:for(;0>>1,K=V[H];if(0>>1;Ha(ue,ee))$a(Q,ue)?(V[H]=Q,V[$]=ee,H=$):(V[H]=ue,V[he]=ee,H=he);else if($a(Q,ee))V[H]=Q,V[$]=ee,H=$;else break e}}return xe}function a(V,xe){var ee=V.sortIndex-xe.sortIndex;return ee!==0?ee:V.id-xe.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,x=3,b=!1,N=!1,w=!1,v=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,M=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(V){for(var xe=n(h);xe!==null;){if(xe.callback===null)r(h);else if(xe.startTime<=V)r(h),xe.sortIndex=xe.expirationTime,e(u,xe);else break;xe=n(h)}}function L(V){if(w=!1,E(V),!N)if(n(u)!==null)N=!0,I(R);else{var xe=n(h);xe!==null&&Z(L,xe.startTime-V)}}function R(V,xe){N=!1,w&&(w=!1,k(B),B=-1),b=!0;var ee=x;try{for(E(xe),m=n(u);m!==null&&(!(m.expirationTime>xe)||V&&!ae());){var H=m.callback;if(typeof H=="function"){m.callback=null,x=m.priorityLevel;var K=H(m.expirationTime<=xe);xe=t.unstable_now(),typeof K=="function"?m.callback=K:m===n(u)&&r(u),E(xe)}else r(u);m=n(u)}if(m!==null)var fe=!0;else{var he=n(h);he!==null&&Z(L,he.startTime-xe),fe=!1}return fe}finally{m=null,x=ee,b=!1}}var W=!1,P=null,B=-1,O=5,X=-1;function ae(){return!(t.unstable_now()-XV||125H?(V.sortIndex=ee,e(h,V),n(u)===null&&V===n(h)&&(w?(k(B),B=-1):w=!0,Z(L,ee-H))):(V.sortIndex=K,e(u,V),N||b||(N=!0,I(R))),V},t.unstable_shouldYield=ae,t.unstable_wrapCallback=function(V){var xe=x;return function(){var ee=x;x=xe;try{return V.apply(this,arguments)}finally{x=ee}}}})(Ax)),Ax}var g1;function eE(){return g1||(g1=1,Mx.exports=Z5()),Mx.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ function J5(t,e){for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function x(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function b(l,d,p,y){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return y?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,d,p,y){if(d===null||typeof d>"u"||b(l,d,p,y))return!0;if(y)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,y,j,C,A){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=y,this.attributeNamespace=j,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=C,this.removeEmptyString=A}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){v[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];v[d]=new w(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){v[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){v[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){v[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){v[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){v[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){v[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){v[l]=new w(l,5,!1,l.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function M(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,M);v[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,M);v[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,M);v[d]=new w(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){v[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),v.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){v[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function E(l,d,p,y){var j=v.hasOwnProperty(d)?v[d]:null;(j!==null?j.type!==0:y||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function x(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function b(l,d,p,y){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return y?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,d,p,y){if(d===null||typeof d>"u"||b(l,d,p,y))return!0;if(y)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,y,j,C,A){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=y,this.attributeNamespace=j,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=C,this.removeEmptyString=A}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){v[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];v[d]=new w(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){v[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){v[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){v[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){v[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){v[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){v[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){v[l]=new w(l,5,!1,l.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function M(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,M);v[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,M);v[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,M);v[d]=new w(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){v[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),v.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){v[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function E(l,d,p,y){var j=v.hasOwnProperty(d)?v[d]:null;(j!==null?j.type!==0:y||!(2q||j[A]!==C[q]){var re=` -`+j[A].replace(" at new "," at ");return l.displayName&&re.includes("")&&(re=re.replace("",l.displayName)),re}while(1<=A&&0<=q);break}}}finally{fe=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?K(l):""}function ue(l){switch(l.tag){case 5:return K(l.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return l=he(l.type,!1),l;case 11:return l=he(l.type.render,!1),l;case 1:return l=he(l.type,!0),l;default:return""}}function $(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 P:return"Fragment";case W:return"Portal";case O:return"Profiler";case B:return"StrictMode";case se:return"Suspense";case ce:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case ae:return(l.displayName||"Context")+".Consumer";case Y:return(l._context.displayName||"Context")+".Provider";case _:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case me:return d=l.displayName||null,d!==null?d:$(l.type)||"Memo";case I:d=l._payload,l=l._init;try{return $(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 $(d);case 8:return d===B?"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 z(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function te(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ie(l){var d=te(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),y=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var j=p.get,C=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return j.call(this)},set:function(A){y=""+A,C.call(this,A)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return y},setValue:function(A){y=""+A},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function we(l){l._valueTracker||(l._valueTracker=ie(l))}function Be(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),y="";return l&&(y=te(l)?l.checked?"true":"false":l.value),l=y,l!==p?(d.setValue(l),!0):!1}function Ue(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 yt(l,d){var p=d.checked;return ee({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function vn(l,d){var p=d.defaultValue==null?"":d.defaultValue,y=d.checked!=null?d.checked:d.defaultChecked;p=z(d.value!=null?d.value:p),l._wrapperState={initialChecked:y,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function dt(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function Et(l,d){dt(l,d);var p=z(d.value),y=d.type;if(p!=null)y==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(y==="submit"||y==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?Dn(l,d.type,p):d.hasOwnProperty("defaultValue")&&Dn(l,d.type,z(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function on(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var y=d.type;if(!(y!=="submit"&&y!=="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 Dn(l,d,p){(d!=="number"||Ue(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var ln=Array.isArray;function Ut(l,d,p,y){if(l=l.options,d){d={};for(var j=0;j"+d.valueOf().toString()+"",d=Ne.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function We(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var tt={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},Ot=["Webkit","ms","Moz","O"];Object.keys(tt).forEach(function(l){Ot.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),tt[d]=tt[l]})});function wt(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||tt.hasOwnProperty(l)&&tt[l]?(""+d).trim():d+"px"}function ze(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var y=p.indexOf("--")===0,j=wt(p,d[p],y);p==="float"&&(p="cssFloat"),y?l.setProperty(p,j):l[p]=j}}var U=ee({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 qe(l,d){if(d){if(U[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 gt(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 _t=null;function pt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var lt=null,Tt=null,Wt=null;function Nn(l){if(l=Pd(l)){if(typeof lt!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Xu(d),lt(l.stateNode,l.type,d))}}function ks(l){Tt?Wt?Wt.push(l):Wt=[l]:Tt=l}function Ss(){if(Tt){var l=Tt,d=Wt;if(Wt=Tt=null,Nn(l),d)for(l=0;l>>=0,l===0?32:31-(Ur(l)/Qo|0)|0}var zs=64,Js=4194304;function ma(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 xa(l,d){var p=l.pendingLanes;if(p===0)return 0;var y=0,j=l.suspendedLanes,C=l.pingedLanes,A=p&268435455;if(A!==0){var q=A&~j;q!==0?y=ma(q):(C&=A,C!==0&&(y=ma(C)))}else A=p&~j,A!==0?y=ma(A):C!==0&&(y=ma(C));if(y===0)return 0;if(d!==0&&d!==y&&(d&j)===0&&(j=y&-y,C=d&-d,j>=C||j===16&&(C&4194240)!==0))return d;if((y&4)!==0&&(y|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=y;0p;p++)d.push(l);return d}function Wa(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-es(d),l[d]=p}function ga(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 y=l.eventTimes;for(l=l.expirationTimes;0=ye),mt=" ",Le=!1;function vt(l,d){switch(l){case"keyup":return D.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ft(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Fn=!1;function fl(l,d){switch(l){case"compositionend":return Ft(d);case"keypress":return d.which!==32?null:(Le=!0,mt);case"textInput":return l=d.data,l===mt&&Le?null:l;default:return null}}function am(l,d){if(Fn)return l==="compositionend"||!Z&&vt(l,d)?(l=ya(),Cr=zi=Ys=null,Fn=!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=y}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=mb(p)}}function gb(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?gb(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function yb(){for(var l=window,d=Ue();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=Ue(l.document)}return d}function cm(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 n5(l){var d=yb(),p=l.focusedElem,y=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&gb(p.ownerDocument.documentElement,p)){if(y!==null&&cm(p)){if(d=y.start,l=y.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,C=Math.min(y.start,j);y=y.end===void 0?C:Math.min(y.end,j),!l.extend&&C>y&&(j=y,y=C,C=j),j=xb(p,C);var A=xb(p,y);j&&A&&(l.rangeCount!==1||l.anchorNode!==j.node||l.anchorOffset!==j.offset||l.focusNode!==A.node||l.focusOffset!==A.offset)&&(d=d.createRange(),d.setStart(j.node,j.offset),l.removeAllRanges(),C>y?(l.addRange(d),l.extend(A.node,A.offset)):(d.setEnd(A.node,A.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,uc=null,dm=null,Cd=null,um=!1;function bb(l,d,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;um||uc==null||uc!==Ue(y)||(y=uc,"selectionStart"in y&&cm(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Cd&&Sd(Cd,y)||(Cd=y,y=Ju(dm,"onSelect"),0xc||(l.current=jm[xc],jm[xc]=null,xc--)}function sn(l,d){xc++,jm[xc]=l.current,l.current=d}var Ji={},Ts=Gi(Ji),er=Gi(!1),ml=Ji;function gc(l,d){var p=l.type.contextTypes;if(!p)return Ji;var y=l.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===d)return y.__reactInternalMemoizedMaskedChildContext;var j={},C;for(C in p)j[C]=d[C];return y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=j),j}function tr(l){return l=l.childContextTypes,l!=null}function Zu(){hn(er),hn(Ts)}function Lb(l,d,p){if(Ts.current!==Ji)throw Error(n(168));sn(Ts,d),sn(er,p)}function Ob(l,d,p){var y=l.stateNode;if(d=d.childContextTypes,typeof y.getChildContext!="function")return p;y=y.getChildContext();for(var j in y)if(!(j in d))throw Error(n(108,Q(l)||"Unknown",j));return ee({},p,y)}function eh(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Ji,ml=Ts.current,sn(Ts,l),sn(er,er.current),!0}function Db(l,d,p){var y=l.stateNode;if(!y)throw Error(n(169));p?(l=Ob(l,d,ml),y.__reactInternalMemoizedMergedChildContext=l,hn(er),hn(Ts),sn(Ts,l)):hn(er),sn(er,p)}var ni=null,th=!1,km=!1;function _b(l){ni===null?ni=[l]:ni.push(l)}function p5(l){th=!0,_b(l)}function Qi(){if(!km&&ni!==null){km=!0;var l=0,d=ft;try{var p=ni;for(ft=1;l>=A,j-=A,si=1<<32-es(d)+j|p<ut?(as=at,at=null):as=at.sibling;var zt=Te(pe,at,ge[ut],Oe);if(zt===null){at===null&&(at=as);break}l&&at&&zt.alternate===null&&d(pe,at),oe=C(zt,oe,ut),rt===null?Ze=zt:rt.sibling=zt,rt=zt,at=as}if(ut===ge.length)return p(pe,at),yn&&gl(pe,ut),Ze;if(at===null){for(;utut?(as=at,at=null):as=at.sibling;var ao=Te(pe,at,zt.value,Oe);if(ao===null){at===null&&(at=as);break}l&&at&&ao.alternate===null&&d(pe,at),oe=C(ao,oe,ut),rt===null?Ze=ao:rt.sibling=ao,rt=ao,at=as}if(zt.done)return p(pe,at),yn&&gl(pe,ut),Ze;if(at===null){for(;!zt.done;ut++,zt=ge.next())zt=Pe(pe,zt.value,Oe),zt!==null&&(oe=C(zt,oe,ut),rt===null?Ze=zt:rt.sibling=zt,rt=zt);return yn&&gl(pe,ut),Ze}for(at=y(pe,at);!zt.done;ut++,zt=ge.next())zt=Ke(at,pe,ut,zt.value,Oe),zt!==null&&(l&&zt.alternate!==null&&at.delete(zt.key===null?ut:zt.key),oe=C(zt,oe,ut),rt===null?Ze=zt:rt.sibling=zt,rt=zt);return l&&at.forEach(function(G5){return d(pe,G5)}),yn&&gl(pe,ut),Ze}function Rn(pe,oe,ge,Oe){if(typeof ge=="object"&&ge!==null&&ge.type===P&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case R:e:{for(var Ze=ge.key,rt=oe;rt!==null;){if(rt.key===Ze){if(Ze=ge.type,Ze===P){if(rt.tag===7){p(pe,rt.sibling),oe=j(rt,ge.props.children),oe.return=pe,pe=oe;break e}}else if(rt.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===I&&Hb(Ze)===rt.type){p(pe,rt.sibling),oe=j(rt,ge.props),oe.ref=Id(pe,rt,ge),oe.return=pe,pe=oe;break e}p(pe,rt);break}else d(pe,rt);rt=rt.sibling}ge.type===P?(oe=Sl(ge.props.children,pe.mode,Oe,ge.key),oe.return=pe,pe=oe):(Oe=Mh(ge.type,ge.key,ge.props,null,pe.mode,Oe),Oe.ref=Id(pe,oe,ge),Oe.return=pe,pe=Oe)}return A(pe);case W:e:{for(rt=ge.key;oe!==null;){if(oe.key===rt)if(oe.tag===4&&oe.stateNode.containerInfo===ge.containerInfo&&oe.stateNode.implementation===ge.implementation){p(pe,oe.sibling),oe=j(oe,ge.children||[]),oe.return=pe,pe=oe;break e}else{p(pe,oe);break}else d(pe,oe);oe=oe.sibling}oe=Nx(ge,pe.mode,Oe),oe.return=pe,pe=oe}return A(pe);case I:return rt=ge._init,Rn(pe,oe,rt(ge._payload),Oe)}if(ln(ge))return Je(pe,oe,ge,Oe);if(xe(ge))return Xe(pe,oe,ge,Oe);ah(pe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,oe!==null&&oe.tag===6?(p(pe,oe.sibling),oe=j(oe,ge),oe.return=pe,pe=oe):(p(pe,oe),oe=vx(ge,pe.mode,Oe),oe.return=pe,pe=oe),A(pe)):p(pe,oe)}return Rn}var Nc=Ub(!0),Wb=Ub(!1),ih=Gi(null),oh=null,wc=null,Am=null;function Pm(){Am=wc=oh=null}function Im(l){var d=ih.current;hn(ih),l._currentValue=d}function Rm(l,d,p){for(;l!==null;){var y=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,y!==null&&(y.childLanes|=d)):y!==null&&(y.childLanes&d)!==d&&(y.childLanes|=d),l===p)break;l=l.return}}function jc(l,d){oh=l,Am=wc=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(nr=!0),l.firstContext=null)}function Ar(l){var d=l._currentValue;if(Am!==l)if(l={context:l,memoizedValue:d,next:null},wc===null){if(oh===null)throw Error(n(308));wc=l,oh.dependencies={lanes:0,firstContext:l}}else wc=wc.next=l;return d}var yl=null;function Lm(l){yl===null?yl=[l]:yl.push(l)}function Kb(l,d,p,y){var j=d.interleaved;return j===null?(p.next=p,Lm(d)):(p.next=j.next,j.next=p),d.interleaved=p,ai(l,y)}function ai(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 Yi=!1;function Om(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function qb(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 ii(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function Xi(l,d,p){var y=l.updateQueue;if(y===null)return null;if(y=y.shared,($t&2)!==0){var j=y.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),y.pending=d,ai(l,p)}return j=y.interleaved,j===null?(d.next=d,Lm(y)):(d.next=j.next,j.next=d),y.interleaved=d,ai(l,p)}function lh(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Xo(l,p)}}function Gb(l,d){var p=l.updateQueue,y=l.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var j=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var A={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?j=C=A:C=C.next=A,p=p.next}while(p!==null);C===null?j=C=d:C=C.next=d}else j=C=d;p={baseState:y.baseState,firstBaseUpdate:j,lastBaseUpdate:C,shared:y.shared,effects:y.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function ch(l,d,p,y){var j=l.updateQueue;Yi=!1;var C=j.firstBaseUpdate,A=j.lastBaseUpdate,q=j.shared.pending;if(q!==null){j.shared.pending=null;var re=q,be=re.next;re.next=null,A===null?C=be:A.next=be,A=re;var Ae=l.alternate;Ae!==null&&(Ae=Ae.updateQueue,q=Ae.lastBaseUpdate,q!==A&&(q===null?Ae.firstBaseUpdate=be:q.next=be,Ae.lastBaseUpdate=re))}if(C!==null){var Pe=j.baseState;A=0,Ae=be=re=null,q=C;do{var Te=q.lane,Ke=q.eventTime;if((y&Te)===Te){Ae!==null&&(Ae=Ae.next={eventTime:Ke,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var Je=l,Xe=q;switch(Te=d,Ke=p,Xe.tag){case 1:if(Je=Xe.payload,typeof Je=="function"){Pe=Je.call(Ke,Pe,Te);break e}Pe=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=Xe.payload,Te=typeof Je=="function"?Je.call(Ke,Pe,Te):Je,Te==null)break e;Pe=ee({},Pe,Te);break e;case 2:Yi=!0}}q.callback!==null&&q.lane!==0&&(l.flags|=64,Te=j.effects,Te===null?j.effects=[q]:Te.push(q))}else Ke={eventTime:Ke,lane:Te,tag:q.tag,payload:q.payload,callback:q.callback,next:null},Ae===null?(be=Ae=Ke,re=Pe):Ae=Ae.next=Ke,A|=Te;if(q=q.next,q===null){if(q=j.shared.pending,q===null)break;Te=q,q=Te.next,Te.next=null,j.lastBaseUpdate=Te,j.shared.pending=null}}while(!0);if(Ae===null&&(re=Pe),j.baseState=re,j.firstBaseUpdate=be,j.lastBaseUpdate=Ae,d=j.shared.interleaved,d!==null){j=d;do A|=j.lane,j=j.next;while(j!==d)}else C===null&&(j.shared.lanes=0);Nl|=A,l.lanes=A,l.memoizedState=Pe}}function Jb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var y=Fm.transition;Fm.transition={};try{l(!1),d()}finally{ft=p,Fm.transition=y}}function pv(){return Pr().memoizedState}function y5(l,d,p){var y=no(l);if(p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},mv(l))xv(d,p);else if(p=Kb(l,d,p,y),p!==null){var j=Hs();ea(p,l,y,j),gv(p,d,y)}}function b5(l,d,p){var y=no(l),j={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(mv(l))xv(d,j);else{var C=l.alternate;if(l.lanes===0&&(C===null||C.lanes===0)&&(C=d.lastRenderedReducer,C!==null))try{var A=d.lastRenderedState,q=C(A,p);if(j.hasEagerState=!0,j.eagerState=q,Jr(q,A)){var re=d.interleaved;re===null?(j.next=j,Lm(d)):(j.next=re.next,re.next=j),d.interleaved=j;return}}catch{}finally{}p=Kb(l,d,j,y),p!==null&&(j=Hs(),ea(p,l,y,j),gv(p,d,y))}}function mv(l){var d=l.alternate;return l===jn||d!==null&&d===jn}function xv(l,d){Dd=hh=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function gv(l,d,p){if((p&4194240)!==0){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Xo(l,p)}}var mh={readContext:Ar,useCallback:Ms,useContext:Ms,useEffect:Ms,useImperativeHandle:Ms,useInsertionEffect:Ms,useLayoutEffect:Ms,useMemo:Ms,useReducer:Ms,useRef:Ms,useState:Ms,useDebugValue:Ms,useDeferredValue:Ms,useTransition:Ms,useMutableSource:Ms,useSyncExternalStore:Ms,useId:Ms,unstable_isNewReconciler:!1},v5={readContext:Ar,useCallback:function(l,d){return ja().memoizedState=[l,d===void 0?null:d],l},useContext:Ar,useEffect:iv,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,fh(4194308,4,cv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return fh(4194308,4,l,d)},useInsertionEffect:function(l,d){return fh(4,2,l,d)},useMemo:function(l,d){var p=ja();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var y=ja();return d=p!==void 0?p(d):d,y.memoizedState=y.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},y.queue=l,l=l.dispatch=y5.bind(null,jn,l),[y.memoizedState,l]},useRef:function(l){var d=ja();return l={current:l},d.memoizedState=l},useState:rv,useDebugValue:qm,useDeferredValue:function(l){return ja().memoizedState=l},useTransition:function(){var l=rv(!1),d=l[0];return l=g5.bind(null,l[1]),ja().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var y=jn,j=ja();if(yn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),rs===null)throw Error(n(349));(vl&30)!==0||Zb(y,d,p)}j.memoizedState=p;var C={value:p,getSnapshot:d};return j.queue=C,iv(tv.bind(null,y,C,l),[l]),y.flags|=2048,zd(9,ev.bind(null,y,C,p,d),void 0,null),p},useId:function(){var l=ja(),d=rs.identifierPrefix;if(yn){var p=ri,y=si;p=(y&~(1<<32-es(y)-1)).toString(32)+p,d=":"+d+"R"+p,p=_d++,0")&&(re=re.replace("",l.displayName)),re}while(1<=A&&0<=q);break}}}finally{fe=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?K(l):""}function ue(l){switch(l.tag){case 5:return K(l.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return l=he(l.type,!1),l;case 11:return l=he(l.type.render,!1),l;case 1:return l=he(l.type,!0),l;default:return""}}function $(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 P:return"Fragment";case W:return"Portal";case O:return"Profiler";case B:return"StrictMode";case se:return"Suspense";case ce:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case ae:return(l.displayName||"Context")+".Consumer";case X:return(l._context.displayName||"Context")+".Provider";case _:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case me:return d=l.displayName||null,d!==null?d:$(l.type)||"Memo";case I:d=l._payload,l=l._init;try{return $(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 $(d);case 8:return d===B?"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 z(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function te(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ie(l){var d=te(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),y=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var j=p.get,C=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return j.call(this)},set:function(A){y=""+A,C.call(this,A)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return y},setValue:function(A){y=""+A},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function we(l){l._valueTracker||(l._valueTracker=ie(l))}function Be(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),y="";return l&&(y=te(l)?l.checked?"true":"false":l.value),l=y,l!==p?(d.setValue(l),!0):!1}function Ue(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 bt(l,d){var p=d.checked;return ee({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function vn(l,d){var p=d.defaultValue==null?"":d.defaultValue,y=d.checked!=null?d.checked:d.defaultChecked;p=z(d.value!=null?d.value:p),l._wrapperState={initialChecked:y,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function dt(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function Tt(l,d){dt(l,d);var p=z(d.value),y=d.type;if(p!=null)y==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(y==="submit"||y==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?Dn(l,d.type,p):d.hasOwnProperty("defaultValue")&&Dn(l,d.type,z(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function ln(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var y=d.type;if(!(y!=="submit"&&y!=="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 Dn(l,d,p){(d!=="number"||Ue(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Zt=Array.isArray;function Dt(l,d,p,y){if(l=l.options,d){d={};for(var j=0;j"+d.valueOf().toString()+"",d=Ne.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function We(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var tt={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},vt=["Webkit","ms","Moz","O"];Object.keys(tt).forEach(function(l){vt.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),tt[d]=tt[l]})});function ft(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||tt.hasOwnProperty(l)&&tt[l]?(""+d).trim():d+"px"}function _e(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var y=p.indexOf("--")===0,j=ft(p,d[p],y);p==="float"&&(p="cssFloat"),y?l.setProperty(p,j):l[p]=j}}var U=ee({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 qe(l,d){if(d){if(U[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 yt(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 $t=null;function mt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var lt=null,Mt=null,Wt=null;function Nn(l){if(l=Pd(l)){if(typeof lt!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Zu(d),lt(l.stateNode,l.type,d))}}function ks(l){Mt?Wt?Wt.push(l):Wt=[l]:Mt=l}function Ss(){if(Mt){var l=Mt,d=Wt;if(Wt=Mt=null,Nn(l),d)for(l=0;l>>=0,l===0?32:31-(Ur(l)/Qo|0)|0}var zs=64,Js=4194304;function ma(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 xa(l,d){var p=l.pendingLanes;if(p===0)return 0;var y=0,j=l.suspendedLanes,C=l.pingedLanes,A=p&268435455;if(A!==0){var q=A&~j;q!==0?y=ma(q):(C&=A,C!==0&&(y=ma(C)))}else A=p&~j,A!==0?y=ma(A):C!==0&&(y=ma(C));if(y===0)return 0;if(d!==0&&d!==y&&(d&j)===0&&(j=y&-y,C=d&-d,j>=C||j===16&&(C&4194240)!==0))return d;if((y&4)!==0&&(y|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=y;0p;p++)d.push(l);return d}function Wa(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-es(d),l[d]=p}function ga(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 y=l.eventTimes;for(l=l.expirationTimes;0=ge),xt=" ",Le=!1;function wt(l,d){switch(l){case"keyup":return D.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ht(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Fn=!1;function fl(l,d){switch(l){case"compositionend":return Ht(d);case"keypress":return d.which!==32?null:(Le=!0,xt);case"textInput":return l=d.data,l===xt&&Le?null:l;default:return null}}function am(l,d){if(Fn)return l==="compositionend"||!Y&&wt(l,d)?(l=ya(),Cr=$i=Ys=null,Fn=!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=y}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=mb(p)}}function gb(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?gb(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function yb(){for(var l=window,d=Ue();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=Ue(l.document)}return d}function cm(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 n5(l){var d=yb(),p=l.focusedElem,y=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&gb(p.ownerDocument.documentElement,p)){if(y!==null&&cm(p)){if(d=y.start,l=y.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,C=Math.min(y.start,j);y=y.end===void 0?C:Math.min(y.end,j),!l.extend&&C>y&&(j=y,y=C,C=j),j=xb(p,C);var A=xb(p,y);j&&A&&(l.rangeCount!==1||l.anchorNode!==j.node||l.anchorOffset!==j.offset||l.focusNode!==A.node||l.focusOffset!==A.offset)&&(d=d.createRange(),d.setStart(j.node,j.offset),l.removeAllRanges(),C>y?(l.addRange(d),l.extend(A.node,A.offset)):(d.setEnd(A.node,A.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,uc=null,dm=null,Cd=null,um=!1;function bb(l,d,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;um||uc==null||uc!==Ue(y)||(y=uc,"selectionStart"in y&&cm(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Cd&&Sd(Cd,y)||(Cd=y,y=Qu(dm,"onSelect"),0xc||(l.current=jm[xc],jm[xc]=null,xc--)}function rn(l,d){xc++,jm[xc]=l.current,l.current=d}var Gi={},Ts=qi(Gi),er=qi(!1),ml=Gi;function gc(l,d){var p=l.type.contextTypes;if(!p)return Gi;var y=l.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===d)return y.__reactInternalMemoizedMaskedChildContext;var j={},C;for(C in p)j[C]=d[C];return y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=j),j}function tr(l){return l=l.childContextTypes,l!=null}function eh(){hn(er),hn(Ts)}function Lb(l,d,p){if(Ts.current!==Gi)throw Error(n(168));rn(Ts,d),rn(er,p)}function Ob(l,d,p){var y=l.stateNode;if(d=d.childContextTypes,typeof y.getChildContext!="function")return p;y=y.getChildContext();for(var j in y)if(!(j in d))throw Error(n(108,Q(l)||"Unknown",j));return ee({},p,y)}function th(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Gi,ml=Ts.current,rn(Ts,l),rn(er,er.current),!0}function Db(l,d,p){var y=l.stateNode;if(!y)throw Error(n(169));p?(l=Ob(l,d,ml),y.__reactInternalMemoizedMergedChildContext=l,hn(er),hn(Ts),rn(Ts,l)):hn(er),rn(er,p)}var ni=null,nh=!1,km=!1;function _b(l){ni===null?ni=[l]:ni.push(l)}function p5(l){nh=!0,_b(l)}function Ji(){if(!km&&ni!==null){km=!0;var l=0,d=pt;try{var p=ni;for(pt=1;l>=A,j-=A,si=1<<32-es(d)+j|p<ut?(as=at,at=null):as=at.sibling;var Ft=Me(pe,at,ye[ut],De);if(Ft===null){at===null&&(at=as);break}l&&at&&Ft.alternate===null&&d(pe,at),oe=C(Ft,oe,ut),rt===null?Ze=Ft:rt.sibling=Ft,rt=Ft,at=as}if(ut===ye.length)return p(pe,at),yn&&gl(pe,ut),Ze;if(at===null){for(;utut?(as=at,at=null):as=at.sibling;var ro=Me(pe,at,Ft.value,De);if(ro===null){at===null&&(at=as);break}l&&at&&ro.alternate===null&&d(pe,at),oe=C(ro,oe,ut),rt===null?Ze=ro:rt.sibling=ro,rt=ro,at=as}if(Ft.done)return p(pe,at),yn&&gl(pe,ut),Ze;if(at===null){for(;!Ft.done;ut++,Ft=ye.next())Ft=Pe(pe,Ft.value,De),Ft!==null&&(oe=C(Ft,oe,ut),rt===null?Ze=Ft:rt.sibling=Ft,rt=Ft);return yn&&gl(pe,ut),Ze}for(at=y(pe,at);!Ft.done;ut++,Ft=ye.next())Ft=Ke(at,pe,ut,Ft.value,De),Ft!==null&&(l&&Ft.alternate!==null&&at.delete(Ft.key===null?ut:Ft.key),oe=C(Ft,oe,ut),rt===null?Ze=Ft:rt.sibling=Ft,rt=Ft);return l&&at.forEach(function(G5){return d(pe,G5)}),yn&&gl(pe,ut),Ze}function Rn(pe,oe,ye,De){if(typeof ye=="object"&&ye!==null&&ye.type===P&&ye.key===null&&(ye=ye.props.children),typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case R:e:{for(var Ze=ye.key,rt=oe;rt!==null;){if(rt.key===Ze){if(Ze=ye.type,Ze===P){if(rt.tag===7){p(pe,rt.sibling),oe=j(rt,ye.props.children),oe.return=pe,pe=oe;break e}}else if(rt.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===I&&Hb(Ze)===rt.type){p(pe,rt.sibling),oe=j(rt,ye.props),oe.ref=Id(pe,rt,ye),oe.return=pe,pe=oe;break e}p(pe,rt);break}else d(pe,rt);rt=rt.sibling}ye.type===P?(oe=Sl(ye.props.children,pe.mode,De,ye.key),oe.return=pe,pe=oe):(De=Ah(ye.type,ye.key,ye.props,null,pe.mode,De),De.ref=Id(pe,oe,ye),De.return=pe,pe=De)}return A(pe);case W:e:{for(rt=ye.key;oe!==null;){if(oe.key===rt)if(oe.tag===4&&oe.stateNode.containerInfo===ye.containerInfo&&oe.stateNode.implementation===ye.implementation){p(pe,oe.sibling),oe=j(oe,ye.children||[]),oe.return=pe,pe=oe;break e}else{p(pe,oe);break}else d(pe,oe);oe=oe.sibling}oe=Nx(ye,pe.mode,De),oe.return=pe,pe=oe}return A(pe);case I:return rt=ye._init,Rn(pe,oe,rt(ye._payload),De)}if(Zt(ye))return Je(pe,oe,ye,De);if(xe(ye))return Xe(pe,oe,ye,De);ih(pe,ye)}return typeof ye=="string"&&ye!==""||typeof ye=="number"?(ye=""+ye,oe!==null&&oe.tag===6?(p(pe,oe.sibling),oe=j(oe,ye),oe.return=pe,pe=oe):(p(pe,oe),oe=vx(ye,pe.mode,De),oe.return=pe,pe=oe),A(pe)):p(pe,oe)}return Rn}var Nc=Ub(!0),Wb=Ub(!1),oh=qi(null),lh=null,wc=null,Am=null;function Pm(){Am=wc=lh=null}function Im(l){var d=oh.current;hn(oh),l._currentValue=d}function Rm(l,d,p){for(;l!==null;){var y=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,y!==null&&(y.childLanes|=d)):y!==null&&(y.childLanes&d)!==d&&(y.childLanes|=d),l===p)break;l=l.return}}function jc(l,d){lh=l,Am=wc=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(nr=!0),l.firstContext=null)}function Ar(l){var d=l._currentValue;if(Am!==l)if(l={context:l,memoizedValue:d,next:null},wc===null){if(lh===null)throw Error(n(308));wc=l,lh.dependencies={lanes:0,firstContext:l}}else wc=wc.next=l;return d}var yl=null;function Lm(l){yl===null?yl=[l]:yl.push(l)}function Kb(l,d,p,y){var j=d.interleaved;return j===null?(p.next=p,Lm(d)):(p.next=j.next,j.next=p),d.interleaved=p,ai(l,y)}function ai(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 Qi=!1;function Om(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function qb(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 ii(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function Yi(l,d,p){var y=l.updateQueue;if(y===null)return null;if(y=y.shared,(zt&2)!==0){var j=y.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),y.pending=d,ai(l,p)}return j=y.interleaved,j===null?(d.next=d,Lm(y)):(d.next=j.next,j.next=d),y.interleaved=d,ai(l,p)}function ch(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Xo(l,p)}}function Gb(l,d){var p=l.updateQueue,y=l.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var j=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var A={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?j=C=A:C=C.next=A,p=p.next}while(p!==null);C===null?j=C=d:C=C.next=d}else j=C=d;p={baseState:y.baseState,firstBaseUpdate:j,lastBaseUpdate:C,shared:y.shared,effects:y.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function dh(l,d,p,y){var j=l.updateQueue;Qi=!1;var C=j.firstBaseUpdate,A=j.lastBaseUpdate,q=j.shared.pending;if(q!==null){j.shared.pending=null;var re=q,be=re.next;re.next=null,A===null?C=be:A.next=be,A=re;var Ae=l.alternate;Ae!==null&&(Ae=Ae.updateQueue,q=Ae.lastBaseUpdate,q!==A&&(q===null?Ae.firstBaseUpdate=be:q.next=be,Ae.lastBaseUpdate=re))}if(C!==null){var Pe=j.baseState;A=0,Ae=be=re=null,q=C;do{var Me=q.lane,Ke=q.eventTime;if((y&Me)===Me){Ae!==null&&(Ae=Ae.next={eventTime:Ke,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var Je=l,Xe=q;switch(Me=d,Ke=p,Xe.tag){case 1:if(Je=Xe.payload,typeof Je=="function"){Pe=Je.call(Ke,Pe,Me);break e}Pe=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=Xe.payload,Me=typeof Je=="function"?Je.call(Ke,Pe,Me):Je,Me==null)break e;Pe=ee({},Pe,Me);break e;case 2:Qi=!0}}q.callback!==null&&q.lane!==0&&(l.flags|=64,Me=j.effects,Me===null?j.effects=[q]:Me.push(q))}else Ke={eventTime:Ke,lane:Me,tag:q.tag,payload:q.payload,callback:q.callback,next:null},Ae===null?(be=Ae=Ke,re=Pe):Ae=Ae.next=Ke,A|=Me;if(q=q.next,q===null){if(q=j.shared.pending,q===null)break;Me=q,q=Me.next,Me.next=null,j.lastBaseUpdate=Me,j.shared.pending=null}}while(!0);if(Ae===null&&(re=Pe),j.baseState=re,j.firstBaseUpdate=be,j.lastBaseUpdate=Ae,d=j.shared.interleaved,d!==null){j=d;do A|=j.lane,j=j.next;while(j!==d)}else C===null&&(j.shared.lanes=0);Nl|=A,l.lanes=A,l.memoizedState=Pe}}function Jb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var y=Fm.transition;Fm.transition={};try{l(!1),d()}finally{pt=p,Fm.transition=y}}function pv(){return Pr().memoizedState}function y5(l,d,p){var y=to(l);if(p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},mv(l))xv(d,p);else if(p=Kb(l,d,p,y),p!==null){var j=Hs();ea(p,l,y,j),gv(p,d,y)}}function b5(l,d,p){var y=to(l),j={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(mv(l))xv(d,j);else{var C=l.alternate;if(l.lanes===0&&(C===null||C.lanes===0)&&(C=d.lastRenderedReducer,C!==null))try{var A=d.lastRenderedState,q=C(A,p);if(j.hasEagerState=!0,j.eagerState=q,Jr(q,A)){var re=d.interleaved;re===null?(j.next=j,Lm(d)):(j.next=re.next,re.next=j),d.interleaved=j;return}}catch{}finally{}p=Kb(l,d,j,y),p!==null&&(j=Hs(),ea(p,l,y,j),gv(p,d,y))}}function mv(l){var d=l.alternate;return l===jn||d!==null&&d===jn}function xv(l,d){Dd=fh=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function gv(l,d,p){if((p&4194240)!==0){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Xo(l,p)}}var xh={readContext:Ar,useCallback:Ms,useContext:Ms,useEffect:Ms,useImperativeHandle:Ms,useInsertionEffect:Ms,useLayoutEffect:Ms,useMemo:Ms,useReducer:Ms,useRef:Ms,useState:Ms,useDebugValue:Ms,useDeferredValue:Ms,useTransition:Ms,useMutableSource:Ms,useSyncExternalStore:Ms,useId:Ms,unstable_isNewReconciler:!1},v5={readContext:Ar,useCallback:function(l,d){return ja().memoizedState=[l,d===void 0?null:d],l},useContext:Ar,useEffect:iv,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,ph(4194308,4,cv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return ph(4194308,4,l,d)},useInsertionEffect:function(l,d){return ph(4,2,l,d)},useMemo:function(l,d){var p=ja();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var y=ja();return d=p!==void 0?p(d):d,y.memoizedState=y.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},y.queue=l,l=l.dispatch=y5.bind(null,jn,l),[y.memoizedState,l]},useRef:function(l){var d=ja();return l={current:l},d.memoizedState=l},useState:rv,useDebugValue:qm,useDeferredValue:function(l){return ja().memoizedState=l},useTransition:function(){var l=rv(!1),d=l[0];return l=g5.bind(null,l[1]),ja().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var y=jn,j=ja();if(yn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),rs===null)throw Error(n(349));(vl&30)!==0||Zb(y,d,p)}j.memoizedState=p;var C={value:p,getSnapshot:d};return j.queue=C,iv(tv.bind(null,y,C,l),[l]),y.flags|=2048,zd(9,ev.bind(null,y,C,p,d),void 0,null),p},useId:function(){var l=ja(),d=rs.identifierPrefix;if(yn){var p=ri,y=si;p=(y&~(1<<32-es(y)-1)).toString(32)+p,d=":"+d+"R"+p,p=_d++,0<\/script>",l=l.removeChild(l.firstChild)):typeof y.is=="string"?l=A.createElement(p,{is:y.is}):(l=A.createElement(p),p==="select"&&(A=l,y.multiple?A.multiple=!0:y.size&&(A.size=y.size))):l=A.createElementNS(l,p),l[Na]=d,l[Ad]=y,_v(l,d,!1,!1),d.stateNode=l;e:{switch(A=gt(p,y),p){case"dialog":un("cancel",l),un("close",l),j=y;break;case"iframe":case"object":case"embed":un("load",l),j=y;break;case"video":case"audio":for(j=0;jTc&&(d.flags|=128,y=!0,Fd(C,!1),d.lanes=4194304)}else{if(!y)if(l=dh(A),l!==null){if(d.flags|=128,y=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Fd(C,!0),C.tail===null&&C.tailMode==="hidden"&&!A.alternate&&!yn)return As(d),null}else 2*cn()-C.renderingStartTime>Tc&&p!==1073741824&&(d.flags|=128,y=!0,Fd(C,!1),d.lanes=4194304);C.isBackwards?(A.sibling=d.child,d.child=A):(p=C.last,p!==null?p.sibling=A:d.child=A,C.last=A)}return C.tail!==null?(d=C.tail,C.rendering=d,C.tail=d.sibling,C.renderingStartTime=cn(),d.sibling=null,p=wn.current,sn(wn,y?p&1|2:p&1),d):(As(d),null);case 22:case 23:return gx(),y=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(d.flags|=8192),y&&(d.mode&1)!==0?(mr&1073741824)!==0&&(As(d),d.subtreeFlags&6&&(d.flags|=8192)):As(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function T5(l,d){switch(Cm(d),d.tag){case 1:return tr(d.type)&&Zu(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return kc(),hn(er),hn(Ts),zm(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return _m(d),null;case 13:if(hn(wn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));vc()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return hn(wn),null;case 4:return kc(),null;case 10:return Im(d.type._context),null;case 22:case 23:return gx(),null;case 24:return null;default:return null}}var bh=!1,Ps=!1,M5=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function Cc(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){Cn(l,d,y)}else p.current=null}function ax(l,d,p){try{p()}catch(y){Cn(l,d,y)}}var Fv=!1;function A5(l,d){if(gm=$i,l=yb(),cm(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var j=y.anchorOffset,C=y.focusNode;y=y.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var A=0,q=-1,re=-1,be=0,Ae=0,Pe=l,Te=null;t:for(;;){for(var Ke;Pe!==p||j!==0&&Pe.nodeType!==3||(q=A+j),Pe!==C||y!==0&&Pe.nodeType!==3||(re=A+y),Pe.nodeType===3&&(A+=Pe.nodeValue.length),(Ke=Pe.firstChild)!==null;)Te=Pe,Pe=Ke;for(;;){if(Pe===l)break t;if(Te===p&&++be===j&&(q=A),Te===C&&++Ae===y&&(re=A),(Ke=Pe.nextSibling)!==null)break;Pe=Te,Te=Pe.parentNode}Pe=Ke}p=q===-1||re===-1?null:{start:q,end:re}}else p=null}p=p||{start:0,end:0}}else p=null;for(ym={focusedElem:l,selectionRange:p},$i=!1,Ge=d;Ge!==null;)if(d=Ge,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ge=l;else for(;Ge!==null;){d=Ge;try{var Je=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var Xe=Je.memoizedProps,Rn=Je.memoizedState,pe=d.stateNode,oe=pe.getSnapshotBeforeUpdate(d.elementType===d.type?Xe:Yr(d.type,Xe),Rn);pe.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var ge=d.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Oe){Cn(d,d.return,Oe)}if(l=d.sibling,l!==null){l.return=d.return,Ge=l;break}Ge=d.return}return Je=Fv,Fv=!1,Je}function Bd(l,d,p){var y=d.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var j=y=y.next;do{if((j.tag&l)===l){var C=j.destroy;j.destroy=void 0,C!==void 0&&ax(d,p,C)}j=j.next}while(j!==y)}}function vh(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 y=p.create;p.destroy=y()}p=p.next}while(p!==d)}}function ix(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 Bv(l){var d=l.alternate;d!==null&&(l.alternate=null,Bv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Na],delete d[Ad],delete d[wm],delete d[h5],delete d[f5])),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 Vv(l){return l.tag===5||l.tag===3||l.tag===4}function Hv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Vv(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 ox(l,d,p){var y=l.tag;if(y===5||y===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=Yu));else if(y!==4&&(l=l.child,l!==null))for(ox(l,d,p),l=l.sibling;l!==null;)ox(l,d,p),l=l.sibling}function lx(l,d,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(y!==4&&(l=l.child,l!==null))for(lx(l,d,p),l=l.sibling;l!==null;)lx(l,d,p),l=l.sibling}var ys=null,Xr=!1;function Zi(l,d,p){for(p=p.child;p!==null;)Uv(l,d,p),p=p.sibling}function Uv(l,d,p){if(zn&&typeof zn.onCommitFiberUnmount=="function")try{zn.onCommitFiberUnmount($s,p)}catch{}switch(p.tag){case 5:Ps||Cc(p,d);case 6:var y=ys,j=Xr;ys=null,Zi(l,d,p),ys=y,Xr=j,ys!==null&&(Xr?(l=ys,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):ys.removeChild(p.stateNode));break;case 18:ys!==null&&(Xr?(l=ys,p=p.stateNode,l.nodeType===8?Nm(l.parentNode,p):l.nodeType===1&&Nm(l,p),Ya(l)):Nm(ys,p.stateNode));break;case 4:y=ys,j=Xr,ys=p.stateNode.containerInfo,Xr=!0,Zi(l,d,p),ys=y,Xr=j;break;case 0:case 11:case 14:case 15:if(!Ps&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var C=j,A=C.destroy;C=C.tag,A!==void 0&&((C&2)!==0||(C&4)!==0)&&ax(p,d,A),j=j.next}while(j!==y)}Zi(l,d,p);break;case 1:if(!Ps&&(Cc(p,d),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(q){Cn(p,d,q)}Zi(l,d,p);break;case 21:Zi(l,d,p);break;case 22:p.mode&1?(Ps=(y=Ps)||p.memoizedState!==null,Zi(l,d,p),Ps=y):Zi(l,d,p);break;default:Zi(l,d,p)}}function Wv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new M5),d.forEach(function(y){var j=z5.bind(null,l,y);p.has(y)||(p.add(y),y.then(j,j))})}}function Zr(l,d){var p=d.deletions;if(p!==null)for(var y=0;yj&&(j=A),y&=~C}if(y=j,y=cn()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*I5(y/1960))-y,10l?16:l,to===null)var y=!1;else{if(l=to,to=null,Sh=0,($t&6)!==0)throw Error(n(331));var j=$t;for($t|=4,Ge=l.current;Ge!==null;){var C=Ge,A=C.child;if((Ge.flags&16)!==0){var q=C.deletions;if(q!==null){for(var re=0;recn()-ux?jl(l,0):dx|=p),rr(l,d)}function r1(l,d){d===0&&((l.mode&1)===0?d=1:(d=Js,Js<<=1,(Js&130023424)===0&&(Js=4194304)));var p=Hs();l=ai(l,d),l!==null&&(Wa(l,d,p),rr(l,p))}function $5(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),r1(l,p)}function z5(l,d){var p=0;switch(l.tag){case 13:var y=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:y=l.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(d),r1(l,p)}var a1;a1=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||er.current)nr=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return nr=!1,C5(l,d,p);nr=(l.flags&131072)!==0}else nr=!1,yn&&(d.flags&1048576)!==0&&$b(d,sh,d.index);switch(d.lanes=0,d.tag){case 2:var y=d.type;yh(l,d),l=d.pendingProps;var j=gc(d,Ts.current);jc(d,p),j=Vm(null,d,y,l,j,p);var C=Hm();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,tr(y)?(C=!0,eh(d)):C=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Om(d),j.updater=xh,d.stateNode=j,j._reactInternals=d,Jm(d,y,l,p),d=Zm(null,d,y,!0,C,p)):(d.tag=0,yn&&C&&Sm(d),Vs(null,d,j,p),d=d.child),d;case 16:y=d.elementType;e:{switch(yh(l,d),l=d.pendingProps,j=y._init,y=j(y._payload),d.type=y,j=d.tag=B5(y),l=Yr(y,l),j){case 0:d=Xm(null,d,y,l,p);break e;case 1:d=Pv(null,d,y,l,p);break e;case 11:d=Cv(null,d,y,l,p);break e;case 14:d=Ev(null,d,y,Yr(y.type,l),p);break e}throw Error(n(306,y,""))}return d;case 0:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),Xm(l,d,y,j,p);case 1:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),Pv(l,d,y,j,p);case 3:e:{if(Iv(d),l===null)throw Error(n(387));y=d.pendingProps,C=d.memoizedState,j=C.element,qb(l,d),ch(d,y,null,p);var A=d.memoizedState;if(y=A.element,C.isDehydrated)if(C={element:y,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},d.updateQueue.baseState=C,d.memoizedState=C,d.flags&256){j=Sc(Error(n(423)),d),d=Rv(l,d,y,p,j);break e}else if(y!==j){j=Sc(Error(n(424)),d),d=Rv(l,d,y,p,j);break e}else for(pr=qi(d.stateNode.containerInfo.firstChild),fr=d,yn=!0,Qr=null,p=Wb(d,null,y,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(vc(),y===j){d=oi(l,d,p);break e}Vs(l,d,y,p)}d=d.child}return d;case 5:return Qb(d),l===null&&Tm(d),y=d.type,j=d.pendingProps,C=l!==null?l.memoizedProps:null,A=j.children,bm(y,j)?A=null:C!==null&&bm(y,C)&&(d.flags|=32),Av(l,d),Vs(l,d,A,p),d.child;case 6:return l===null&&Tm(d),null;case 13:return Lv(l,d,p);case 4:return Dm(d,d.stateNode.containerInfo),y=d.pendingProps,l===null?d.child=Nc(d,null,y,p):Vs(l,d,y,p),d.child;case 11:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),Cv(l,d,y,j,p);case 7:return Vs(l,d,d.pendingProps,p),d.child;case 8:return Vs(l,d,d.pendingProps.children,p),d.child;case 12:return Vs(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(y=d.type._context,j=d.pendingProps,C=d.memoizedProps,A=j.value,sn(ih,y._currentValue),y._currentValue=A,C!==null)if(Jr(C.value,A)){if(C.children===j.children&&!er.current){d=oi(l,d,p);break e}}else for(C=d.child,C!==null&&(C.return=d);C!==null;){var q=C.dependencies;if(q!==null){A=C.child;for(var re=q.firstContext;re!==null;){if(re.context===y){if(C.tag===1){re=ii(-1,p&-p),re.tag=2;var be=C.updateQueue;if(be!==null){be=be.shared;var Ae=be.pending;Ae===null?re.next=re:(re.next=Ae.next,Ae.next=re),be.pending=re}}C.lanes|=p,re=C.alternate,re!==null&&(re.lanes|=p),Rm(C.return,p,d),q.lanes|=p;break}re=re.next}}else if(C.tag===10)A=C.type===d.type?null:C.child;else if(C.tag===18){if(A=C.return,A===null)throw Error(n(341));A.lanes|=p,q=A.alternate,q!==null&&(q.lanes|=p),Rm(A,p,d),A=C.sibling}else A=C.child;if(A!==null)A.return=C;else for(A=C;A!==null;){if(A===d){A=null;break}if(C=A.sibling,C!==null){C.return=A.return,A=C;break}A=A.return}C=A}Vs(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,y=d.pendingProps.children,jc(d,p),j=Ar(j),y=y(j),d.flags|=1,Vs(l,d,y,p),d.child;case 14:return y=d.type,j=Yr(y,d.pendingProps),j=Yr(y.type,j),Ev(l,d,y,j,p);case 15:return Tv(l,d,d.type,d.pendingProps,p);case 17:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),yh(l,d),d.tag=1,tr(y)?(l=!0,eh(d)):l=!1,jc(d,p),bv(d,y,j),Jm(d,y,j,p),Zm(null,d,y,!0,l,p);case 19:return Dv(l,d,p);case 22:return Mv(l,d,p)}throw Error(n(156,d.tag))};function i1(l,d){return bt(l,d)}function F5(l,d,p,y){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=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Rr(l,d,p,y){return new F5(l,d,p,y)}function bx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function B5(l){if(typeof l=="function")return bx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===_)return 11;if(l===me)return 14}return 2}function ro(l,d){var p=l.alternate;return p===null?(p=Rr(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 Mh(l,d,p,y,j,C){var A=2;if(y=l,typeof l=="function")bx(l)&&(A=1);else if(typeof l=="string")A=5;else e:switch(l){case P:return Sl(p.children,j,C,d);case B:A=8,j|=8;break;case O:return l=Rr(12,p,d,j|2),l.elementType=O,l.lanes=C,l;case se:return l=Rr(13,p,d,j),l.elementType=se,l.lanes=C,l;case ce:return l=Rr(19,p,d,j),l.elementType=ce,l.lanes=C,l;case X:return Ah(p,j,C,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case Y:A=10;break e;case ae:A=9;break e;case _:A=11;break e;case me:A=14;break e;case I:A=16,y=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Rr(A,p,d,j),d.elementType=l,d.type=y,d.lanes=C,d}function Sl(l,d,p,y){return l=Rr(7,l,y,d),l.lanes=p,l}function Ah(l,d,p,y){return l=Rr(22,l,y,d),l.elementType=X,l.lanes=p,l.stateNode={isHidden:!1},l}function vx(l,d,p){return l=Rr(6,l,null,d),l.lanes=p,l}function Nx(l,d,p){return d=Rr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function V5(l,d,p,y,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=Di(0),this.expirationTimes=Di(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Di(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function wx(l,d,p,y,j,C,A,q,re){return l=new V5(l,d,p,q,re),d===1?(d=1,C===!0&&(d|=8)):d=0,C=Rr(3,null,null,d),l.current=C,C.stateNode=l,C.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Om(C),l}function H5(l,d,p){var y=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Tx.exports=tE(),Tx.exports}var v1;function nE(){if(v1)return _h;v1=1;var t=zj();return _h.createRoot=t.createRoot,_h.hydrateRoot=t.hydrateRoot,_h}var sE=nE(),id=zj();const Fj=$j(id);/** +`+C.stack}return{value:l,source:d,stack:j,digest:null}}function Qm(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function Ym(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var j5=typeof WeakMap=="function"?WeakMap:Map;function Nv(l,d,p){p=ii(-1,p),p.tag=3,p.payload={element:null};var y=d.value;return p.callback=function(){kh||(kh=!0,hx=y),Ym(l,d)},p}function wv(l,d,p){p=ii(-1,p),p.tag=3;var y=l.type.getDerivedStateFromError;if(typeof y=="function"){var j=d.value;p.payload=function(){return y(j)},p.callback=function(){Ym(l,d)}}var C=l.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(p.callback=function(){Ym(l,d),typeof y!="function"&&(Zi===null?Zi=new Set([this]):Zi.add(this));var A=d.stack;this.componentDidCatch(d.value,{componentStack:A!==null?A:""})}),p}function jv(l,d,p){var y=l.pingCache;if(y===null){y=l.pingCache=new j5;var j=new Set;y.set(d,j)}else j=y.get(d),j===void 0&&(j=new Set,y.set(d,j));j.has(p)||(j.add(p),l=_5.bind(null,l,d,p),d.then(l,l))}function kv(l){do{var d;if((d=l.tag===13)&&(d=l.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return l;l=l.return}while(l!==null);return null}function Sv(l,d,p,y,j){return(l.mode&1)===0?(l===d?l.flags|=65536:(l.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(d=ii(-1,1),d.tag=2,Yi(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=j,l)}var k5=L.ReactCurrentOwner,nr=!1;function Vs(l,d,p,y){d.child=l===null?Wb(d,null,p,y):Nc(d,l.child,p,y)}function Cv(l,d,p,y,j){p=p.render;var C=d.ref;return jc(d,j),y=Vm(l,d,p,y,C,j),p=Hm(),l!==null&&!nr?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,oi(l,d,j)):(yn&&p&&Sm(d),d.flags|=1,Vs(l,d,y,j),d.child)}function Ev(l,d,p,y,j){if(l===null){var C=p.type;return typeof C=="function"&&!bx(C)&&C.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=C,Tv(l,d,C,y,j)):(l=Ah(p.type,null,y,d,d.mode,j),l.ref=d.ref,l.return=d,d.child=l)}if(C=l.child,(l.lanes&j)===0){var A=C.memoizedProps;if(p=p.compare,p=p!==null?p:Sd,p(A,y)&&l.ref===d.ref)return oi(l,d,j)}return d.flags|=1,l=so(C,y),l.ref=d.ref,l.return=d,d.child=l}function Tv(l,d,p,y,j){if(l!==null){var C=l.memoizedProps;if(Sd(C,y)&&l.ref===d.ref)if(nr=!1,d.pendingProps=y=C,(l.lanes&j)!==0)(l.flags&131072)!==0&&(nr=!0);else return d.lanes=l.lanes,oi(l,d,j)}return Xm(l,d,p,y,j)}function Mv(l,d,p){var y=d.pendingProps,j=y.children,C=l!==null?l.memoizedState:null;if(y.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},rn(Ec,mr),mr|=p;else{if((p&1073741824)===0)return l=C!==null?C.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,rn(Ec,mr),mr|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=C!==null?C.baseLanes:p,rn(Ec,mr),mr|=y}else C!==null?(y=C.baseLanes|p,d.memoizedState=null):y=p,rn(Ec,mr),mr|=y;return Vs(l,d,j,p),d.child}function Av(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function Xm(l,d,p,y,j){var C=tr(p)?ml:Ts.current;return C=gc(d,C),jc(d,j),p=Vm(l,d,p,y,C,j),y=Hm(),l!==null&&!nr?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,oi(l,d,j)):(yn&&y&&Sm(d),d.flags|=1,Vs(l,d,p,j),d.child)}function Pv(l,d,p,y,j){if(tr(p)){var C=!0;th(d)}else C=!1;if(jc(d,j),d.stateNode===null)bh(l,d),bv(d,p,y),Jm(d,p,y,j),y=!0;else if(l===null){var A=d.stateNode,q=d.memoizedProps;A.props=q;var re=A.context,be=p.contextType;typeof be=="object"&&be!==null?be=Ar(be):(be=tr(p)?ml:Ts.current,be=gc(d,be));var Ae=p.getDerivedStateFromProps,Pe=typeof Ae=="function"||typeof A.getSnapshotBeforeUpdate=="function";Pe||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(q!==y||re!==be)&&vv(d,A,y,be),Qi=!1;var Me=d.memoizedState;A.state=Me,dh(d,y,A,j),re=d.memoizedState,q!==y||Me!==re||er.current||Qi?(typeof Ae=="function"&&(Gm(d,p,Ae,y),re=d.memoizedState),(q=Qi||yv(d,p,q,y,Me,re,be))?(Pe||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(d.flags|=4194308)):(typeof A.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=y,d.memoizedState=re),A.props=y,A.state=re,A.context=be,y=q):(typeof A.componentDidMount=="function"&&(d.flags|=4194308),y=!1)}else{A=d.stateNode,qb(l,d),q=d.memoizedProps,be=d.type===d.elementType?q:Yr(d.type,q),A.props=be,Pe=d.pendingProps,Me=A.context,re=p.contextType,typeof re=="object"&&re!==null?re=Ar(re):(re=tr(p)?ml:Ts.current,re=gc(d,re));var Ke=p.getDerivedStateFromProps;(Ae=typeof Ke=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(q!==Pe||Me!==re)&&vv(d,A,y,re),Qi=!1,Me=d.memoizedState,A.state=Me,dh(d,y,A,j);var Je=d.memoizedState;q!==Pe||Me!==Je||er.current||Qi?(typeof Ke=="function"&&(Gm(d,p,Ke,y),Je=d.memoizedState),(be=Qi||yv(d,p,be,y,Me,Je,re)||!1)?(Ae||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(y,Je,re),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(y,Je,re)),typeof A.componentDidUpdate=="function"&&(d.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof A.componentDidUpdate!="function"||q===l.memoizedProps&&Me===l.memoizedState||(d.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||q===l.memoizedProps&&Me===l.memoizedState||(d.flags|=1024),d.memoizedProps=y,d.memoizedState=Je),A.props=y,A.state=Je,A.context=re,y=be):(typeof A.componentDidUpdate!="function"||q===l.memoizedProps&&Me===l.memoizedState||(d.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||q===l.memoizedProps&&Me===l.memoizedState||(d.flags|=1024),y=!1)}return Zm(l,d,p,y,C,j)}function Zm(l,d,p,y,j,C){Av(l,d);var A=(d.flags&128)!==0;if(!y&&!A)return j&&Db(d,p,!1),oi(l,d,C);y=d.stateNode,k5.current=d;var q=A&&typeof p.getDerivedStateFromError!="function"?null:y.render();return d.flags|=1,l!==null&&A?(d.child=Nc(d,l.child,null,C),d.child=Nc(d,null,q,C)):Vs(l,d,q,C),d.memoizedState=y.state,j&&Db(d,p,!0),d.child}function Iv(l){var d=l.stateNode;d.pendingContext?Lb(l,d.pendingContext,d.pendingContext!==d.context):d.context&&Lb(l,d.context,!1),Dm(l,d.containerInfo)}function Rv(l,d,p,y,j){return vc(),Mm(j),d.flags|=256,Vs(l,d,p,y),d.child}var ex={dehydrated:null,treeContext:null,retryLane:0};function tx(l){return{baseLanes:l,cachePool:null,transitions:null}}function Lv(l,d,p){var y=d.pendingProps,j=wn.current,C=!1,A=(d.flags&128)!==0,q;if((q=A)||(q=l!==null&&l.memoizedState===null?!1:(j&2)!==0),q?(C=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(j|=1),rn(wn,j&1),l===null)return Tm(d),l=d.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((d.mode&1)===0?d.lanes=1:l.data==="$!"?d.lanes=8:d.lanes=1073741824,null):(A=y.children,l=y.fallback,C?(y=d.mode,C=d.child,A={mode:"hidden",children:A},(y&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=A):C=Ph(A,y,0,null),l=Sl(l,y,p,null),C.return=d,l.return=d,C.sibling=l,d.child=C,d.child.memoizedState=tx(p),d.memoizedState=ex,l):nx(d,A));if(j=l.memoizedState,j!==null&&(q=j.dehydrated,q!==null))return S5(l,d,A,y,q,j,p);if(C){C=y.fallback,A=d.mode,j=l.child,q=j.sibling;var re={mode:"hidden",children:y.children};return(A&1)===0&&d.child!==j?(y=d.child,y.childLanes=0,y.pendingProps=re,d.deletions=null):(y=so(j,re),y.subtreeFlags=j.subtreeFlags&14680064),q!==null?C=so(q,C):(C=Sl(C,A,p,null),C.flags|=2),C.return=d,y.return=d,y.sibling=C,d.child=y,y=C,C=d.child,A=l.child.memoizedState,A=A===null?tx(p):{baseLanes:A.baseLanes|p,cachePool:null,transitions:A.transitions},C.memoizedState=A,C.childLanes=l.childLanes&~p,d.memoizedState=ex,y}return C=l.child,l=C.sibling,y=so(C,{mode:"visible",children:y.children}),(d.mode&1)===0&&(y.lanes=p),y.return=d,y.sibling=null,l!==null&&(p=d.deletions,p===null?(d.deletions=[l],d.flags|=16):p.push(l)),d.child=y,d.memoizedState=null,y}function nx(l,d){return d=Ph({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function yh(l,d,p,y){return y!==null&&Mm(y),Nc(d,l.child,null,p),l=nx(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function S5(l,d,p,y,j,C,A){if(p)return d.flags&256?(d.flags&=-257,y=Qm(Error(n(422))),yh(l,d,A,y)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(C=y.fallback,j=d.mode,y=Ph({mode:"visible",children:y.children},j,0,null),C=Sl(C,j,A,null),C.flags|=2,y.return=d,C.return=d,y.sibling=C,d.child=y,(d.mode&1)!==0&&Nc(d,l.child,null,A),d.child.memoizedState=tx(A),d.memoizedState=ex,C);if((d.mode&1)===0)return yh(l,d,A,null);if(j.data==="$!"){if(y=j.nextSibling&&j.nextSibling.dataset,y)var q=y.dgst;return y=q,C=Error(n(419)),y=Qm(C,y,void 0),yh(l,d,A,y)}if(q=(A&l.childLanes)!==0,nr||q){if(y=rs,y!==null){switch(A&-A){case 4:j=2;break;case 16:j=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(y.suspendedLanes|A))!==0?0:j,j!==0&&j!==C.retryLane&&(C.retryLane=j,ai(l,j),ea(y,l,j,-1))}return yx(),y=Qm(Error(n(421))),yh(l,d,A,y)}return j.data==="$?"?(d.flags|=128,d.child=l.child,d=$5.bind(null,l),j._reactRetry=d,null):(l=C.treeContext,pr=Ki(j.nextSibling),fr=d,yn=!0,Qr=null,l!==null&&(Tr[Mr++]=si,Tr[Mr++]=ri,Tr[Mr++]=xl,si=l.id,ri=l.overflow,xl=d),d=nx(d,y.children),d.flags|=4096,d)}function Ov(l,d,p){l.lanes|=d;var y=l.alternate;y!==null&&(y.lanes|=d),Rm(l.return,d,p)}function sx(l,d,p,y,j){var C=l.memoizedState;C===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:j}:(C.isBackwards=d,C.rendering=null,C.renderingStartTime=0,C.last=y,C.tail=p,C.tailMode=j)}function Dv(l,d,p){var y=d.pendingProps,j=y.revealOrder,C=y.tail;if(Vs(l,d,y.children,p),y=wn.current,(y&2)!==0)y=y&1|2,d.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=d.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&Ov(l,p,d);else if(l.tag===19)Ov(l,p,d);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===d)break e;for(;l.sibling===null;){if(l.return===null||l.return===d)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}y&=1}if(rn(wn,y),(d.mode&1)===0)d.memoizedState=null;else switch(j){case"forwards":for(p=d.child,j=null;p!==null;)l=p.alternate,l!==null&&uh(l)===null&&(j=p),p=p.sibling;p=j,p===null?(j=d.child,d.child=null):(j=p.sibling,p.sibling=null),sx(d,!1,j,p,C);break;case"backwards":for(p=null,j=d.child,d.child=null;j!==null;){if(l=j.alternate,l!==null&&uh(l)===null){d.child=j;break}l=j.sibling,j.sibling=p,p=j,j=l}sx(d,!0,p,null,C);break;case"together":sx(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function bh(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function oi(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),Nl|=d.lanes,(p&d.childLanes)===0)return null;if(l!==null&&d.child!==l.child)throw Error(n(153));if(d.child!==null){for(l=d.child,p=so(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=so(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function C5(l,d,p){switch(d.tag){case 3:Iv(d),vc();break;case 5:Qb(d);break;case 1:tr(d.type)&&th(d);break;case 4:Dm(d,d.stateNode.containerInfo);break;case 10:var y=d.type._context,j=d.memoizedProps.value;rn(oh,y._currentValue),y._currentValue=j;break;case 13:if(y=d.memoizedState,y!==null)return y.dehydrated!==null?(rn(wn,wn.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?Lv(l,d,p):(rn(wn,wn.current&1),l=oi(l,d,p),l!==null?l.sibling:null);rn(wn,wn.current&1);break;case 19:if(y=(p&d.childLanes)!==0,(l.flags&128)!==0){if(y)return Dv(l,d,p);d.flags|=128}if(j=d.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),rn(wn,wn.current),y)break;return null;case 22:case 23:return d.lanes=0,Mv(l,d,p)}return oi(l,d,p)}var _v,rx,$v,zv;_v=function(l,d){for(var p=d.child;p!==null;){if(p.tag===5||p.tag===6)l.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},rx=function(){},$v=function(l,d,p,y){var j=l.memoizedProps;if(j!==y){l=d.stateNode,bl(wa.current);var C=null;switch(p){case"input":j=bt(l,j),y=bt(l,y),C=[];break;case"select":j=ee({},j,{value:void 0}),y=ee({},y,{value:void 0}),C=[];break;case"textarea":j=mn(l,j),y=mn(l,y),C=[];break;default:typeof j.onClick!="function"&&typeof y.onClick=="function"&&(l.onclick=Xu)}qe(p,y);var A;p=null;for(be in j)if(!y.hasOwnProperty(be)&&j.hasOwnProperty(be)&&j[be]!=null)if(be==="style"){var q=j[be];for(A in q)q.hasOwnProperty(A)&&(p||(p={}),p[A]="")}else be!=="dangerouslySetInnerHTML"&&be!=="children"&&be!=="suppressContentEditableWarning"&&be!=="suppressHydrationWarning"&&be!=="autoFocus"&&(a.hasOwnProperty(be)?C||(C=[]):(C=C||[]).push(be,null));for(be in y){var re=y[be];if(q=j!=null?j[be]:void 0,y.hasOwnProperty(be)&&re!==q&&(re!=null||q!=null))if(be==="style")if(q){for(A in q)!q.hasOwnProperty(A)||re&&re.hasOwnProperty(A)||(p||(p={}),p[A]="");for(A in re)re.hasOwnProperty(A)&&q[A]!==re[A]&&(p||(p={}),p[A]=re[A])}else p||(C||(C=[]),C.push(be,p)),p=re;else be==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,q=q?q.__html:void 0,re!=null&&q!==re&&(C=C||[]).push(be,re)):be==="children"?typeof re!="string"&&typeof re!="number"||(C=C||[]).push(be,""+re):be!=="suppressContentEditableWarning"&&be!=="suppressHydrationWarning"&&(a.hasOwnProperty(be)?(re!=null&&be==="onScroll"&&un("scroll",l),C||q===re||(C=[])):(C=C||[]).push(be,re))}p&&(C=C||[]).push("style",p);var be=C;(d.updateQueue=be)&&(d.flags|=4)}},zv=function(l,d,p,y){p!==y&&(d.flags|=4)};function Fd(l,d){if(!yn)switch(l.tailMode){case"hidden":d=l.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var y=null;p!==null;)p.alternate!==null&&(y=p),p=p.sibling;y===null?d||l.tail===null?l.tail=null:l.tail.sibling=null:y.sibling=null}}function As(l){var d=l.alternate!==null&&l.alternate.child===l.child,p=0,y=0;if(d)for(var j=l.child;j!==null;)p|=j.lanes|j.childLanes,y|=j.subtreeFlags&14680064,y|=j.flags&14680064,j.return=l,j=j.sibling;else for(j=l.child;j!==null;)p|=j.lanes|j.childLanes,y|=j.subtreeFlags,y|=j.flags,j.return=l,j=j.sibling;return l.subtreeFlags|=y,l.childLanes=p,d}function E5(l,d,p){var y=d.pendingProps;switch(Cm(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return As(d),null;case 1:return tr(d.type)&&eh(),As(d),null;case 3:return y=d.stateNode,kc(),hn(er),hn(Ts),zm(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(l===null||l.child===null)&&(ah(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,Qr!==null&&(mx(Qr),Qr=null))),rx(l,d),As(d),null;case 5:_m(d);var j=bl(Od.current);if(p=d.type,l!==null&&d.stateNode!=null)$v(l,d,p,y,j),l.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!y){if(d.stateNode===null)throw Error(n(166));return As(d),null}if(l=bl(wa.current),ah(d)){y=d.stateNode,p=d.type;var C=d.memoizedProps;switch(y[Na]=d,y[Ad]=C,l=(d.mode&1)!==0,p){case"dialog":un("cancel",y),un("close",y);break;case"iframe":case"object":case"embed":un("load",y);break;case"video":case"audio":for(j=0;j<\/script>",l=l.removeChild(l.firstChild)):typeof y.is=="string"?l=A.createElement(p,{is:y.is}):(l=A.createElement(p),p==="select"&&(A=l,y.multiple?A.multiple=!0:y.size&&(A.size=y.size))):l=A.createElementNS(l,p),l[Na]=d,l[Ad]=y,_v(l,d,!1,!1),d.stateNode=l;e:{switch(A=yt(p,y),p){case"dialog":un("cancel",l),un("close",l),j=y;break;case"iframe":case"object":case"embed":un("load",l),j=y;break;case"video":case"audio":for(j=0;jTc&&(d.flags|=128,y=!0,Fd(C,!1),d.lanes=4194304)}else{if(!y)if(l=uh(A),l!==null){if(d.flags|=128,y=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Fd(C,!0),C.tail===null&&C.tailMode==="hidden"&&!A.alternate&&!yn)return As(d),null}else 2*cn()-C.renderingStartTime>Tc&&p!==1073741824&&(d.flags|=128,y=!0,Fd(C,!1),d.lanes=4194304);C.isBackwards?(A.sibling=d.child,d.child=A):(p=C.last,p!==null?p.sibling=A:d.child=A,C.last=A)}return C.tail!==null?(d=C.tail,C.rendering=d,C.tail=d.sibling,C.renderingStartTime=cn(),d.sibling=null,p=wn.current,rn(wn,y?p&1|2:p&1),d):(As(d),null);case 22:case 23:return gx(),y=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(d.flags|=8192),y&&(d.mode&1)!==0?(mr&1073741824)!==0&&(As(d),d.subtreeFlags&6&&(d.flags|=8192)):As(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function T5(l,d){switch(Cm(d),d.tag){case 1:return tr(d.type)&&eh(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return kc(),hn(er),hn(Ts),zm(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return _m(d),null;case 13:if(hn(wn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));vc()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return hn(wn),null;case 4:return kc(),null;case 10:return Im(d.type._context),null;case 22:case 23:return gx(),null;case 24:return null;default:return null}}var vh=!1,Ps=!1,M5=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function Cc(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){Cn(l,d,y)}else p.current=null}function ax(l,d,p){try{p()}catch(y){Cn(l,d,y)}}var Fv=!1;function A5(l,d){if(gm=_i,l=yb(),cm(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var j=y.anchorOffset,C=y.focusNode;y=y.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var A=0,q=-1,re=-1,be=0,Ae=0,Pe=l,Me=null;t:for(;;){for(var Ke;Pe!==p||j!==0&&Pe.nodeType!==3||(q=A+j),Pe!==C||y!==0&&Pe.nodeType!==3||(re=A+y),Pe.nodeType===3&&(A+=Pe.nodeValue.length),(Ke=Pe.firstChild)!==null;)Me=Pe,Pe=Ke;for(;;){if(Pe===l)break t;if(Me===p&&++be===j&&(q=A),Me===C&&++Ae===y&&(re=A),(Ke=Pe.nextSibling)!==null)break;Pe=Me,Me=Pe.parentNode}Pe=Ke}p=q===-1||re===-1?null:{start:q,end:re}}else p=null}p=p||{start:0,end:0}}else p=null;for(ym={focusedElem:l,selectionRange:p},_i=!1,Ge=d;Ge!==null;)if(d=Ge,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ge=l;else for(;Ge!==null;){d=Ge;try{var Je=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var Xe=Je.memoizedProps,Rn=Je.memoizedState,pe=d.stateNode,oe=pe.getSnapshotBeforeUpdate(d.elementType===d.type?Xe:Yr(d.type,Xe),Rn);pe.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var ye=d.stateNode.containerInfo;ye.nodeType===1?ye.textContent="":ye.nodeType===9&&ye.documentElement&&ye.removeChild(ye.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(De){Cn(d,d.return,De)}if(l=d.sibling,l!==null){l.return=d.return,Ge=l;break}Ge=d.return}return Je=Fv,Fv=!1,Je}function Bd(l,d,p){var y=d.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var j=y=y.next;do{if((j.tag&l)===l){var C=j.destroy;j.destroy=void 0,C!==void 0&&ax(d,p,C)}j=j.next}while(j!==y)}}function Nh(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 y=p.create;p.destroy=y()}p=p.next}while(p!==d)}}function ix(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 Bv(l){var d=l.alternate;d!==null&&(l.alternate=null,Bv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Na],delete d[Ad],delete d[wm],delete d[h5],delete d[f5])),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 Vv(l){return l.tag===5||l.tag===3||l.tag===4}function Hv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Vv(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 ox(l,d,p){var y=l.tag;if(y===5||y===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=Xu));else if(y!==4&&(l=l.child,l!==null))for(ox(l,d,p),l=l.sibling;l!==null;)ox(l,d,p),l=l.sibling}function lx(l,d,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(y!==4&&(l=l.child,l!==null))for(lx(l,d,p),l=l.sibling;l!==null;)lx(l,d,p),l=l.sibling}var ys=null,Xr=!1;function Xi(l,d,p){for(p=p.child;p!==null;)Uv(l,d,p),p=p.sibling}function Uv(l,d,p){if(zn&&typeof zn.onCommitFiberUnmount=="function")try{zn.onCommitFiberUnmount($s,p)}catch{}switch(p.tag){case 5:Ps||Cc(p,d);case 6:var y=ys,j=Xr;ys=null,Xi(l,d,p),ys=y,Xr=j,ys!==null&&(Xr?(l=ys,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):ys.removeChild(p.stateNode));break;case 18:ys!==null&&(Xr?(l=ys,p=p.stateNode,l.nodeType===8?Nm(l.parentNode,p):l.nodeType===1&&Nm(l,p),Ya(l)):Nm(ys,p.stateNode));break;case 4:y=ys,j=Xr,ys=p.stateNode.containerInfo,Xr=!0,Xi(l,d,p),ys=y,Xr=j;break;case 0:case 11:case 14:case 15:if(!Ps&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var C=j,A=C.destroy;C=C.tag,A!==void 0&&((C&2)!==0||(C&4)!==0)&&ax(p,d,A),j=j.next}while(j!==y)}Xi(l,d,p);break;case 1:if(!Ps&&(Cc(p,d),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(q){Cn(p,d,q)}Xi(l,d,p);break;case 21:Xi(l,d,p);break;case 22:p.mode&1?(Ps=(y=Ps)||p.memoizedState!==null,Xi(l,d,p),Ps=y):Xi(l,d,p);break;default:Xi(l,d,p)}}function Wv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new M5),d.forEach(function(y){var j=z5.bind(null,l,y);p.has(y)||(p.add(y),y.then(j,j))})}}function Zr(l,d){var p=d.deletions;if(p!==null)for(var y=0;yj&&(j=A),y&=~C}if(y=j,y=cn()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*I5(y/1960))-y,10l?16:l,eo===null)var y=!1;else{if(l=eo,eo=null,Ch=0,(zt&6)!==0)throw Error(n(331));var j=zt;for(zt|=4,Ge=l.current;Ge!==null;){var C=Ge,A=C.child;if((Ge.flags&16)!==0){var q=C.deletions;if(q!==null){for(var re=0;recn()-ux?jl(l,0):dx|=p),rr(l,d)}function r1(l,d){d===0&&((l.mode&1)===0?d=1:(d=Js,Js<<=1,(Js&130023424)===0&&(Js=4194304)));var p=Hs();l=ai(l,d),l!==null&&(Wa(l,d,p),rr(l,p))}function $5(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),r1(l,p)}function z5(l,d){var p=0;switch(l.tag){case 13:var y=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:y=l.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(d),r1(l,p)}var a1;a1=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||er.current)nr=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return nr=!1,C5(l,d,p);nr=(l.flags&131072)!==0}else nr=!1,yn&&(d.flags&1048576)!==0&&$b(d,rh,d.index);switch(d.lanes=0,d.tag){case 2:var y=d.type;bh(l,d),l=d.pendingProps;var j=gc(d,Ts.current);jc(d,p),j=Vm(null,d,y,l,j,p);var C=Hm();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,tr(y)?(C=!0,th(d)):C=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Om(d),j.updater=gh,d.stateNode=j,j._reactInternals=d,Jm(d,y,l,p),d=Zm(null,d,y,!0,C,p)):(d.tag=0,yn&&C&&Sm(d),Vs(null,d,j,p),d=d.child),d;case 16:y=d.elementType;e:{switch(bh(l,d),l=d.pendingProps,j=y._init,y=j(y._payload),d.type=y,j=d.tag=B5(y),l=Yr(y,l),j){case 0:d=Xm(null,d,y,l,p);break e;case 1:d=Pv(null,d,y,l,p);break e;case 11:d=Cv(null,d,y,l,p);break e;case 14:d=Ev(null,d,y,Yr(y.type,l),p);break e}throw Error(n(306,y,""))}return d;case 0:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),Xm(l,d,y,j,p);case 1:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),Pv(l,d,y,j,p);case 3:e:{if(Iv(d),l===null)throw Error(n(387));y=d.pendingProps,C=d.memoizedState,j=C.element,qb(l,d),dh(d,y,null,p);var A=d.memoizedState;if(y=A.element,C.isDehydrated)if(C={element:y,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},d.updateQueue.baseState=C,d.memoizedState=C,d.flags&256){j=Sc(Error(n(423)),d),d=Rv(l,d,y,p,j);break e}else if(y!==j){j=Sc(Error(n(424)),d),d=Rv(l,d,y,p,j);break e}else for(pr=Ki(d.stateNode.containerInfo.firstChild),fr=d,yn=!0,Qr=null,p=Wb(d,null,y,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(vc(),y===j){d=oi(l,d,p);break e}Vs(l,d,y,p)}d=d.child}return d;case 5:return Qb(d),l===null&&Tm(d),y=d.type,j=d.pendingProps,C=l!==null?l.memoizedProps:null,A=j.children,bm(y,j)?A=null:C!==null&&bm(y,C)&&(d.flags|=32),Av(l,d),Vs(l,d,A,p),d.child;case 6:return l===null&&Tm(d),null;case 13:return Lv(l,d,p);case 4:return Dm(d,d.stateNode.containerInfo),y=d.pendingProps,l===null?d.child=Nc(d,null,y,p):Vs(l,d,y,p),d.child;case 11:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),Cv(l,d,y,j,p);case 7:return Vs(l,d,d.pendingProps,p),d.child;case 8:return Vs(l,d,d.pendingProps.children,p),d.child;case 12:return Vs(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(y=d.type._context,j=d.pendingProps,C=d.memoizedProps,A=j.value,rn(oh,y._currentValue),y._currentValue=A,C!==null)if(Jr(C.value,A)){if(C.children===j.children&&!er.current){d=oi(l,d,p);break e}}else for(C=d.child,C!==null&&(C.return=d);C!==null;){var q=C.dependencies;if(q!==null){A=C.child;for(var re=q.firstContext;re!==null;){if(re.context===y){if(C.tag===1){re=ii(-1,p&-p),re.tag=2;var be=C.updateQueue;if(be!==null){be=be.shared;var Ae=be.pending;Ae===null?re.next=re:(re.next=Ae.next,Ae.next=re),be.pending=re}}C.lanes|=p,re=C.alternate,re!==null&&(re.lanes|=p),Rm(C.return,p,d),q.lanes|=p;break}re=re.next}}else if(C.tag===10)A=C.type===d.type?null:C.child;else if(C.tag===18){if(A=C.return,A===null)throw Error(n(341));A.lanes|=p,q=A.alternate,q!==null&&(q.lanes|=p),Rm(A,p,d),A=C.sibling}else A=C.child;if(A!==null)A.return=C;else for(A=C;A!==null;){if(A===d){A=null;break}if(C=A.sibling,C!==null){C.return=A.return,A=C;break}A=A.return}C=A}Vs(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,y=d.pendingProps.children,jc(d,p),j=Ar(j),y=y(j),d.flags|=1,Vs(l,d,y,p),d.child;case 14:return y=d.type,j=Yr(y,d.pendingProps),j=Yr(y.type,j),Ev(l,d,y,j,p);case 15:return Tv(l,d,d.type,d.pendingProps,p);case 17:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:Yr(y,j),bh(l,d),d.tag=1,tr(y)?(l=!0,th(d)):l=!1,jc(d,p),bv(d,y,j),Jm(d,y,j,p),Zm(null,d,y,!0,l,p);case 19:return Dv(l,d,p);case 22:return Mv(l,d,p)}throw Error(n(156,d.tag))};function i1(l,d){return Nt(l,d)}function F5(l,d,p,y){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=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Rr(l,d,p,y){return new F5(l,d,p,y)}function bx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function B5(l){if(typeof l=="function")return bx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===_)return 11;if(l===me)return 14}return 2}function so(l,d){var p=l.alternate;return p===null?(p=Rr(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 Ah(l,d,p,y,j,C){var A=2;if(y=l,typeof l=="function")bx(l)&&(A=1);else if(typeof l=="string")A=5;else e:switch(l){case P:return Sl(p.children,j,C,d);case B:A=8,j|=8;break;case O:return l=Rr(12,p,d,j|2),l.elementType=O,l.lanes=C,l;case se:return l=Rr(13,p,d,j),l.elementType=se,l.lanes=C,l;case ce:return l=Rr(19,p,d,j),l.elementType=ce,l.lanes=C,l;case Z:return Ph(p,j,C,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case X:A=10;break e;case ae:A=9;break e;case _:A=11;break e;case me:A=14;break e;case I:A=16,y=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Rr(A,p,d,j),d.elementType=l,d.type=y,d.lanes=C,d}function Sl(l,d,p,y){return l=Rr(7,l,y,d),l.lanes=p,l}function Ph(l,d,p,y){return l=Rr(22,l,y,d),l.elementType=Z,l.lanes=p,l.stateNode={isHidden:!1},l}function vx(l,d,p){return l=Rr(6,l,null,d),l.lanes=p,l}function Nx(l,d,p){return d=Rr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function V5(l,d,p,y,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=Oi(0),this.expirationTimes=Oi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Oi(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function wx(l,d,p,y,j,C,A,q,re){return l=new V5(l,d,p,q,re),d===1?(d=1,C===!0&&(d|=8)):d=0,C=Rr(3,null,null,d),l.current=C,C.stateNode=l,C.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Om(C),l}function H5(l,d,p){var y=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Tx.exports=tE(),Tx.exports}var v1;function nE(){if(v1)return $h;v1=1;var t=zj();return $h.createRoot=t.createRoot,$h.hydrateRoot=t.hydrateRoot,$h}var sE=nE(),id=zj();const Fj=$j(id);/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. @@ -46,7 +46,7 @@ Error generating stack: `+C.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function bu(){return bu=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function V0(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function aE(){return Math.random().toString(36).substr(2,8)}function w1(t,e){return{usr:t.state,key:t.key,idx:e}}function Pg(t,e,n,r){return n===void 0&&(n=null),bu({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?od(e):e,{state:n,key:e&&e.key||r||aE()})}function jf(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 od(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 iE(t,e,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,c=vo.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(bu({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=vo.Pop;let v=f(),k=v==null?null:v-h;h=v,u&&u({action:c,location:w.location,delta:k})}function x(v,k){c=vo.Push;let M=Pg(w.location,v,k);h=f()+1;let E=w1(M,h),L=w.createHref(M);try{o.pushState(E,"",L)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(L)}i&&u&&u({action:c,location:w.location,delta:1})}function b(v,k){c=vo.Replace;let M=Pg(w.location,v,k);h=f();let E=w1(M,h),L=w.createHref(M);o.replaceState(E,"",L),i&&u&&u({action:c,location:w.location,delta:0})}function N(v){let k=a.location.origin!=="null"?a.location.origin:a.location.href,M=typeof v=="string"?v:jf(v);return M=M.replace(/ $/,"%20"),Ln(k,"No window.location.(origin|href) available to create URL for href: "+M),new URL(M,k)}let w={get action(){return c},get location(){return t(a,o)},listen(v){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(N1,m),u=v,()=>{a.removeEventListener(N1,m),u=null}},createHref(v){return e(a,v)},createURL:N,encodeLocation(v){let k=N(v);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:x,replace:b,go(v){return o.go(v)}};return w}var j1;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(j1||(j1={}));function oE(t,e,n){return n===void 0&&(n="/"),lE(t,e,n)}function lE(t,e,n,r){let a=typeof e=="string"?od(e):e,i=H0(a.pathname||"/",n);if(i==null)return null;let o=Bj(t);cE(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("/")&&(Ln(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=Co([r,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(Ln(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Bj(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:xE(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 Vj(i.path))a(i,o,u)}),e}function Vj(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=Vj(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 cE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:gE(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const dE=/^:[\w-]+$/,uE=3,hE=2,fE=1,pE=10,mE=-2,k1=t=>t==="*";function xE(t,e){let n=t.split("/"),r=n.length;return n.some(k1)&&(r+=mE),e&&(r+=hE),n.filter(a=>!k1(a)).reduce((a,i)=>a+(dE.test(i)?uE:i===""?fE:pE),r)}function gE(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 yE(t,e,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:x,isOptional:b}=f;if(x==="*"){let w=c[m]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const N=c[m];return b&&!N?h[x]=void 0:h[x]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function vE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),V0(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 NE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return V0(!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 H0(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 wE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,jE=t=>wE.test(t);function kE(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?od(t):t,i;if(n)if(jE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),V0(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=S1(n.substring(1),"/"):i=S1(n,e)}else i=e;return{pathname:i,search:EE(r),hash:TE(a)}}function S1(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 Px(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 SE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function U0(t,e){let n=SE(t);return e?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function W0(t,e,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=od(t):(a=bu({},t),Ln(!a.pathname||!a.pathname.includes("?"),Px("?","pathname","search",a)),Ln(!a.pathname||!a.pathname.includes("#"),Px("#","pathname","hash",a)),Ln(!a.search||!a.search.includes("#"),Px("#","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 x=o.split("/");for(;x[0]==="..";)x.shift(),m-=1;a.pathname=x.join("/")}c=m>=0?e[m]:"/"}let u=kE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Co=t=>t.join("/").replace(/\/\/+/g,"/"),CE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),EE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,TE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function ME(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Hj=["post","put","patch","delete"];new Set(Hj);const AE=["get",...Hj];new Set(AE);/** + */function vu(){return vu=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function V0(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function aE(){return Math.random().toString(36).substr(2,8)}function w1(t,e){return{usr:t.state,key:t.key,idx:e}}function Pg(t,e,n,r){return n===void 0&&(n=null),vu({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?od(e):e,{state:n,key:e&&e.key||r||aE()})}function jf(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 od(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 iE(t,e,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,c=bo.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(vu({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=bo.Pop;let v=f(),k=v==null?null:v-h;h=v,u&&u({action:c,location:w.location,delta:k})}function x(v,k){c=bo.Push;let M=Pg(w.location,v,k);h=f()+1;let E=w1(M,h),L=w.createHref(M);try{o.pushState(E,"",L)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(L)}i&&u&&u({action:c,location:w.location,delta:1})}function b(v,k){c=bo.Replace;let M=Pg(w.location,v,k);h=f();let E=w1(M,h),L=w.createHref(M);o.replaceState(E,"",L),i&&u&&u({action:c,location:w.location,delta:0})}function N(v){let k=a.location.origin!=="null"?a.location.origin:a.location.href,M=typeof v=="string"?v:jf(v);return M=M.replace(/ $/,"%20"),Ln(k,"No window.location.(origin|href) available to create URL for href: "+M),new URL(M,k)}let w={get action(){return c},get location(){return t(a,o)},listen(v){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(N1,m),u=v,()=>{a.removeEventListener(N1,m),u=null}},createHref(v){return e(a,v)},createURL:N,encodeLocation(v){let k=N(v);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:x,replace:b,go(v){return o.go(v)}};return w}var j1;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(j1||(j1={}));function oE(t,e,n){return n===void 0&&(n="/"),lE(t,e,n)}function lE(t,e,n,r){let a=typeof e=="string"?od(e):e,i=H0(a.pathname||"/",n);if(i==null)return null;let o=Bj(t);cE(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("/")&&(Ln(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=So([r,u.relativePath]),f=n.concat(u);i.children&&i.children.length>0&&(Ln(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Bj(i.children,e,f,h)),!(i.path==null&&!i.index)&&e.push({path:h,score:xE(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 Vj(i.path))a(i,o,u)}),e}function Vj(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=Vj(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 cE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:gE(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const dE=/^:[\w-]+$/,uE=3,hE=2,fE=1,pE=10,mE=-2,k1=t=>t==="*";function xE(t,e){let n=t.split("/"),r=n.length;return n.some(k1)&&(r+=mE),e&&(r+=hE),n.filter(a=>!k1(a)).reduce((a,i)=>a+(dE.test(i)?uE:i===""?fE:pE),r)}function gE(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 yE(t,e,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let c=0;c{let{paramName:x,isOptional:b}=f;if(x==="*"){let w=c[m]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const N=c[m];return b&&!N?h[x]=void 0:h[x]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:i,pathnameBase:o,pattern:t}}function vE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),V0(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 NE(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return V0(!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 H0(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 wE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,jE=t=>wE.test(t);function kE(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?od(t):t,i;if(n)if(jE(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),V0(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=S1(n.substring(1),"/"):i=S1(n,e)}else i=e;return{pathname:i,search:EE(r),hash:TE(a)}}function S1(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 Px(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 SE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function U0(t,e){let n=SE(t);return e?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function W0(t,e,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=od(t):(a=vu({},t),Ln(!a.pathname||!a.pathname.includes("?"),Px("?","pathname","search",a)),Ln(!a.pathname||!a.pathname.includes("#"),Px("#","pathname","hash",a)),Ln(!a.search||!a.search.includes("#"),Px("#","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 x=o.split("/");for(;x[0]==="..";)x.shift(),m-=1;a.pathname=x.join("/")}c=m>=0?e[m]:"/"}let u=kE(a,c),h=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const So=t=>t.join("/").replace(/\/\/+/g,"/"),CE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),EE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,TE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function ME(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Hj=["post","put","patch","delete"];new Set(Hj);const AE=["get",...Hj];new Set(AE);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. @@ -55,7 +55,7 @@ Error generating stack: `+C.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function vu(){return vu=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),g.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=W0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Co([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,i,t])}const LE=g.createContext(null);function OE(t){let e=g.useContext(Ii).outlet;return e&&g.createElement(LE.Provider,{value:t},e)}function Kj(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=g.useContext(Bo),{matches:a}=g.useContext(Ii),{pathname:i}=Vo(),o=JSON.stringify(U0(a,r.v7_relativeSplatPath));return g.useMemo(()=>W0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function DE(t,e){return _E(t,e)}function _E(t,e,n,r){ld()||Ln(!1);let{navigator:a}=g.useContext(Bo),{matches:i}=g.useContext(Ii),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Vo(),f;if(e){var m;let v=typeof e=="string"?od(e):e;u==="/"||(m=v.pathname)!=null&&m.startsWith(u)||Ln(!1),f=v}else f=h;let x=f.pathname||"/",b=x;if(u!=="/"){let v=u.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(v.length).join("/")}let N=oE(t,{pathname:b}),w=VE(N&&N.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:Co([u,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:Co([u,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,n,r);return e&&w?g.createElement(Ep.Provider,{value:{location:vu({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:vo.Pop}},w):w}function $E(){let t=KE(),e=ME(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 g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},e),n?g.createElement("pre",{style:a},n):null,null)}const zE=g.createElement($E,null);class FE extends g.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?g.createElement(Ii.Provider,{value:this.props.routeContext},g.createElement(Uj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function BE(t){let{routeContext:e,match:n,children:r}=t,a=g.useContext(K0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Ii.Provider,{value:e},r)}function VE(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||Ln(!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,x)=>{let b,N=!1,w=null,v=null;n&&(b=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||zE,u&&(h<0&&x===0?(GE("route-fallback"),N=!0,v=null):h===x&&(N=!0,v=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,x+1)),M=()=>{let E;return b?E=w:N?E=v:m.route.Component?E=g.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,g.createElement(BE,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||x===0)?g.createElement(FE,{location:n.location,revalidation:n.revalidation,component:w,error:b,children:M(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):M()},null)}var qj=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(qj||{}),Gj=(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})(Gj||{});function HE(t){let e=g.useContext(K0);return e||Ln(!1),e}function UE(t){let e=g.useContext(PE);return e||Ln(!1),e}function WE(t){let e=g.useContext(Ii);return e||Ln(!1),e}function Jj(t){let e=WE(),n=e.matches[e.matches.length-1];return n.route.id||Ln(!1),n.route.id}function KE(){var t;let e=g.useContext(Uj),n=UE(),r=Jj();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function qE(){let{router:t}=HE(qj.UseNavigateStable),e=Jj(Gj.UseNavigateStable),n=g.useRef(!1);return Wj(()=>{n.current=!0}),g.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,vu({fromRouteId:e},i)))},[t,e])}const C1={};function GE(t,e,n){C1[t]||(C1[t]=!0)}function JE(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function $h(t){let{to:e,replace:n,state:r,relative:a}=t;ld()||Ln(!1);let{future:i,static:o}=g.useContext(Bo),{matches:c}=g.useContext(Ii),{pathname:u}=Vo(),h=_a(),f=W0(e,U0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return g.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:a}),[h,m,a,n,r]),null}function QE(t){return OE(t.context)}function en(t){Ln(!1)}function YE(t){let{basename:e="/",children:n=null,location:r,navigationType:a=vo.Pop,navigator:i,static:o=!1,future:c}=t;ld()&&Ln(!1);let u=e.replace(/^\/*/,"/"),h=g.useMemo(()=>({basename:u,navigator:i,static:o,future:vu({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof r=="string"&&(r=od(r));let{pathname:f="/",search:m="",hash:x="",state:b=null,key:N="default"}=r,w=g.useMemo(()=>{let v=H0(f,u);return v==null?null:{location:{pathname:v,search:m,hash:x,state:b,key:N},navigationType:a}},[u,f,m,x,b,N,a]);return w==null?null:g.createElement(Bo.Provider,{value:h},g.createElement(Ep.Provider,{children:n,value:w}))}function XE(t){let{children:e,location:n}=t;return DE(Ig(e),n)}new Promise(()=>{});function Ig(t,e){e===void 0&&(e=[]);let n=[];return g.Children.forEach(t,(r,a)=>{if(!g.isValidElement(r))return;let i=[...e,a];if(r.type===g.Fragment){n.push.apply(n,Ig(r.props.children,i));return}r.type!==en&&Ln(!1),!r.props.index||!r.props.children||Ln(!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=Ig(r.props.children,i)),n.push(o)}),n}/** + */function Nu(){return Nu=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),g.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=W0(h,JSON.parse(o),i,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:So([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,i,t])}const LE=g.createContext(null);function OE(t){let e=g.useContext(Pi).outlet;return e&&g.createElement(LE.Provider,{value:t},e)}function Kj(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=g.useContext(Bo),{matches:a}=g.useContext(Pi),{pathname:i}=Vo(),o=JSON.stringify(U0(a,r.v7_relativeSplatPath));return g.useMemo(()=>W0(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function DE(t,e){return _E(t,e)}function _E(t,e,n,r){ld()||Ln(!1);let{navigator:a}=g.useContext(Bo),{matches:i}=g.useContext(Pi),o=i[i.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=Vo(),f;if(e){var m;let v=typeof e=="string"?od(e):e;u==="/"||(m=v.pathname)!=null&&m.startsWith(u)||Ln(!1),f=v}else f=h;let x=f.pathname||"/",b=x;if(u!=="/"){let v=u.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(v.length).join("/")}let N=oE(t,{pathname:b}),w=VE(N&&N.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:So([u,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:So([u,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,n,r);return e&&w?g.createElement(Ep.Provider,{value:{location:Nu({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:bo.Pop}},w):w}function $E(){let t=KE(),e=ME(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 g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},e),n?g.createElement("pre",{style:a},n):null,null)}const zE=g.createElement($E,null);class FE extends g.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?g.createElement(Pi.Provider,{value:this.props.routeContext},g.createElement(Uj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function BE(t){let{routeContext:e,match:n,children:r}=t,a=g.useContext(K0);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Pi.Provider,{value:e},r)}function VE(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||Ln(!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,x)=>{let b,N=!1,w=null,v=null;n&&(b=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||zE,u&&(h<0&&x===0?(GE("route-fallback"),N=!0,v=null):h===x&&(N=!0,v=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,x+1)),M=()=>{let E;return b?E=w:N?E=v:m.route.Component?E=g.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,g.createElement(BE,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||x===0)?g.createElement(FE,{location:n.location,revalidation:n.revalidation,component:w,error:b,children:M(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):M()},null)}var qj=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(qj||{}),Gj=(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})(Gj||{});function HE(t){let e=g.useContext(K0);return e||Ln(!1),e}function UE(t){let e=g.useContext(PE);return e||Ln(!1),e}function WE(t){let e=g.useContext(Pi);return e||Ln(!1),e}function Jj(t){let e=WE(),n=e.matches[e.matches.length-1];return n.route.id||Ln(!1),n.route.id}function KE(){var t;let e=g.useContext(Uj),n=UE(),r=Jj();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function qE(){let{router:t}=HE(qj.UseNavigateStable),e=Jj(Gj.UseNavigateStable),n=g.useRef(!1);return Wj(()=>{n.current=!0}),g.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Nu({fromRouteId:e},i)))},[t,e])}const C1={};function GE(t,e,n){C1[t]||(C1[t]=!0)}function JE(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function qd(t){let{to:e,replace:n,state:r,relative:a}=t;ld()||Ln(!1);let{future:i,static:o}=g.useContext(Bo),{matches:c}=g.useContext(Pi),{pathname:u}=Vo(),h=_a(),f=W0(e,U0(c,i.v7_relativeSplatPath),u,a==="path"),m=JSON.stringify(f);return g.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:a}),[h,m,a,n,r]),null}function QE(t){return OE(t.context)}function tn(t){Ln(!1)}function YE(t){let{basename:e="/",children:n=null,location:r,navigationType:a=bo.Pop,navigator:i,static:o=!1,future:c}=t;ld()&&Ln(!1);let u=e.replace(/^\/*/,"/"),h=g.useMemo(()=>({basename:u,navigator:i,static:o,future:Nu({v7_relativeSplatPath:!1},c)}),[u,c,i,o]);typeof r=="string"&&(r=od(r));let{pathname:f="/",search:m="",hash:x="",state:b=null,key:N="default"}=r,w=g.useMemo(()=>{let v=H0(f,u);return v==null?null:{location:{pathname:v,search:m,hash:x,state:b,key:N},navigationType:a}},[u,f,m,x,b,N,a]);return w==null?null:g.createElement(Bo.Provider,{value:h},g.createElement(Ep.Provider,{children:n,value:w}))}function XE(t){let{children:e,location:n}=t;return DE(Ig(e),n)}new Promise(()=>{});function Ig(t,e){e===void 0&&(e=[]);let n=[];return g.Children.forEach(t,(r,a)=>{if(!g.isValidElement(r))return;let i=[...e,a];if(r.type===g.Fragment){n.push.apply(n,Ig(r.props.children,i));return}r.type!==tn&&Ln(!1),!r.props.index||!r.props.children||Ln(!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=Ig(r.props.children,i)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. @@ -64,7 +64,7 @@ Error generating stack: `+C.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function Rg(){return Rg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function eT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function tT(t,e){return t.button===0&&(!e||e==="_self")&&!eT(t)}function Lg(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 nT(t,e){let n=Lg(t);return e&&e.forEach((r,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const sT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],rT="6";try{window.__reactRouterVersion=rT}catch{}const aT="startTransition",E1=Cp[aT];function iT(t){let{basename:e,children:n,future:r,window:a}=t,i=g.useRef();i.current==null&&(i.current=rE({window:a,v5Compat:!0}));let o=i.current,[c,u]=g.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=g.useCallback(m=>{h&&E1?E1(()=>u(m)):u(m)},[u,h]);return g.useLayoutEffect(()=>o.listen(f),[o,f]),g.useEffect(()=>JE(r),[r]),g.createElement(YE,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const oT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",lT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Si=g.forwardRef(function(e,n){let{onClick:r,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,x=ZE(e,sT),{basename:b}=g.useContext(Bo),N,w=!1;if(typeof h=="string"&&lT.test(h)&&(N=h,oT))try{let E=new URL(window.location.href),L=h.startsWith("//")?new URL(E.protocol+h):new URL(h),R=H0(L.pathname,b);L.origin===E.origin&&R!=null?h=R+L.search+L.hash:w=!0}catch{}let v=IE(h,{relative:a}),k=cT(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function M(E){r&&r(E),E.defaultPrevented||k(E)}return g.createElement("a",Rg({},x,{href:N||v,onClick:w||i?r:M,ref:n,target:u}))});var T1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(T1||(T1={}));var M1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(M1||(M1={}));function cT(t,e){let{target:n,replace:r,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=_a(),h=Vo(),f=Kj(t,{relative:o});return g.useCallback(m=>{if(tT(m,n)){m.preventDefault();let x=r!==void 0?r:jf(h)===jf(f);u(t,{replace:x,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,r,a,n,t,i,o,c])}function q0(t){let e=g.useRef(Lg(t)),n=g.useRef(!1),r=Vo(),a=g.useMemo(()=>nT(r.search,n.current?null:e.current),[r.search]),i=_a(),o=g.useCallback((c,u)=>{const h=Lg(typeof c=="function"?c(a):c);n.current=!0,i("?"+h,u)},[i,a]);return[a,o]}/** + */function Rg(){return Rg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[a]=t[a]);return n}function eT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function tT(t,e){return t.button===0&&(!e||e==="_self")&&!eT(t)}function Lg(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 nT(t,e){let n=Lg(t);return e&&e.forEach((r,a)=>{n.has(a)||e.getAll(a).forEach(i=>{n.append(a,i)})}),n}const sT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],rT="6";try{window.__reactRouterVersion=rT}catch{}const aT="startTransition",E1=Cp[aT];function iT(t){let{basename:e,children:n,future:r,window:a}=t,i=g.useRef();i.current==null&&(i.current=rE({window:a,v5Compat:!0}));let o=i.current,[c,u]=g.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=g.useCallback(m=>{h&&E1?E1(()=>u(m)):u(m)},[u,h]);return g.useLayoutEffect(()=>o.listen(f),[o,f]),g.useEffect(()=>JE(r),[r]),g.createElement(YE,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const oT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",lT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Po=g.forwardRef(function(e,n){let{onClick:r,relative:a,reloadDocument:i,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,x=ZE(e,sT),{basename:b}=g.useContext(Bo),N,w=!1;if(typeof h=="string"&&lT.test(h)&&(N=h,oT))try{let E=new URL(window.location.href),L=h.startsWith("//")?new URL(E.protocol+h):new URL(h),R=H0(L.pathname,b);L.origin===E.origin&&R!=null?h=R+L.search+L.hash:w=!0}catch{}let v=IE(h,{relative:a}),k=cT(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:m});function M(E){r&&r(E),E.defaultPrevented||k(E)}return g.createElement("a",Rg({},x,{href:N||v,onClick:w||i?r:M,ref:n,target:u}))});var T1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(T1||(T1={}));var M1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(M1||(M1={}));function cT(t,e){let{target:n,replace:r,state:a,preventScrollReset:i,relative:o,viewTransition:c}=e===void 0?{}:e,u=_a(),h=Vo(),f=Kj(t,{relative:o});return g.useCallback(m=>{if(tT(m,n)){m.preventDefault();let x=r!==void 0?r:jf(h)===jf(f);u(t,{replace:x,state:a,preventScrollReset:i,relative:o,viewTransition:c})}},[h,u,f,r,a,n,t,i,o,c])}function q0(t){let e=g.useRef(Lg(t)),n=g.useRef(!1),r=Vo(),a=g.useMemo(()=>nT(r.search,n.current?null:e.current),[r.search]),i=_a(),o=g.useCallback((c,u)=>{const h=Lg(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. @@ -124,7 +124,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ST=[["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"}]],qd=Ee("chart-column",ST);/** + */const ST=[["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"}]],Gd=Ee("chart-column",ST);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -134,7 +134,7 @@ Error generating stack: `+C.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ET=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Mi=Ee("chevron-down",ET);/** + */const ET=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ti=Ee("chevron-down",ET);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -329,7 +329,7 @@ Error generating stack: `+C.message+` * * 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:"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"}]],Nu=Ee("key",CM);/** + */const CM=[["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"}]],wu=Ee("key",CM);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -484,7 +484,7 @@ Error generating stack: `+C.message+` * * 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:"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"}]],No=Ee("settings",yA);/** + */const yA=[["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"}]],vo=Ee("settings",yA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -504,7 +504,7 @@ Error generating stack: `+C.message+` * * 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 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"}]],iu=Ee("shopping-bag",jA);/** + */const jA=[["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"}]],ou=Ee("shopping-bag",jA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -539,7 +539,7 @@ Error generating stack: `+C.message+` * * 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:"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"}]],ou=Ee("tag",LA);/** + */const LA=[["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"}]],lu=Ee("tag",LA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -614,7 +614,7 @@ Error generating stack: `+C.message+` * * 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:"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"}]],Ro=Ee("zap",XA),J0="admin_token";function _u(){try{return localStorage.getItem(J0)}catch{return null}}function ZA(t){try{localStorage.setItem(J0,t)}catch{}}function Lx(){try{localStorage.removeItem(J0)}catch{}}const eP="https://soulapi.quwanzhi.com",tP=15e3,z1=6e4,nP=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return eP};function zl(t){const e=nP(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Mp(t,e={}){const{data:n,...r}=e,a=zl(t),i=new Headers(r.headers),o=_u();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=r.timeout??tP,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...r,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),x=m.headers.get("Content-Type")||"";let b;if(x.includes("application/json"))try{b=await m.json()}catch{throw new Error(`API 响应解析失败 (${m.status})`)}else{const w=await m.text();throw new Error(`API 返回非 JSON 响应 (${m.status}): ${w.slice(0,100)}`)}const N=w=>{const v=w,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(b);const w=new Error((b==null?void 0:b.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=b,w}return N(b),b}function Re(t,e){return Mp(t,{...e,method:"GET"})}function xt(t,e,n){return Mp(t,{...n,method:"POST",data:e})}function Yt(t,e,n){return Mp(t,{...n,method:"PUT",data:e})}function bi(t,e){return Mp(t,{...e,method:"DELETE"})}function sP(){const[t,e]=g.useState(!1),[n,r]=g.useState("");return g.useEffect(()=>{const a=i=>{const o=i.detail;r(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?s.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Yj,{className:"w-5 h-5 shrink-0 text-red-400"}),s.jsxs("span",{className:"text-sm font-medium",children:[n,s.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),s.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:s.jsx(Qn,{className:"w-4 h-4"})})]}):null}const rP=[{icon:TM,label:"数据概览",href:"/dashboard"},{icon:or,label:"内容管理",href:"/content"},{icon:Vn,label:"用户管理",href:"/users"},{icon:iM,label:"找伙伴",href:"/find-partner"},{icon:Yc,label:"推广中心",href:"/distribution"}];function aP(){const t=Vo(),e=g.useRef(t.pathname);e.current=t.pathname;const n=_a(),[r,a]=g.useState(!1),[i,o]=g.useState(!1);g.useEffect(()=>{a(!0)},[]),g.useEffect(()=>{if(!r)return;let u=!1;if(!_u()){n("/login",{replace:!0});return}return Re("/api/admin").then(h=>{u||(h&&h.success!==!1?o(!0):(Lx(),n("/login",{replace:!0,state:{from:e.current}})))}).catch(()=>{u||(Lx(),n("/login",{replace:!0,state:{from:e.current}}))}),()=>{u=!0}},[r,n]);const c=async()=>{Lx();try{await xt("/api/admin/logout",{})}catch{}n("/login",{replace:!0})};return!r||!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:[rP.map(u=>{const h=t.pathname===u.href;return s.jsxs(Si,{to:u.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${h?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(u.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:u.label})]},u.href)}),s.jsxs("div",{className:"pt-4 mt-4 border-t border-gray-700/50 space-y-1",children:[s.jsxs(Si,{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(No,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]}),s.jsxs(Si,{to:"/open-platform",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/open-platform"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(YT,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"API开放平台"})]})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.jsxs("button",{type:"button",onClick:c,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(zM,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[s.jsx(sP,{}),s.jsx("div",{className:"w-full min-w-0 min-h-full flex-1",children:s.jsx(QE,{})})]})]})}function F1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Q0(...t){return e=>{let n=!1;const r=t.map(a=>{const i=F1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;lk(i)&&typeof Tf=="function"&&(i=Tf(i._payload));const c=g.Children.toArray(i),u=c.find(dP);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var dk=ck("Slot");function lP(t){const e=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(lk(a)&&typeof Tf=="function"&&(a=Tf(a._payload)),g.isValidElement(a)){const o=hP(a),c=uP(i,a.props);return a.type!==g.Fragment&&(c.ref=r?Q0(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var cP=Symbol("radix.slottable");function dP(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===cP}function uP(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 hP(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 uk(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,V1=hk,fk=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return V1(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 x=B1(f)||B1(m);return a[h][x]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,x]=f;return x===void 0||(h[m]=x),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:x,...b}=f;return Object.entries(b).every(N=>{let[w,v]=N;return Array.isArray(v)?v.includes({...i,...c}[w]):{...i,...c}[w]===v})?[...h,m,x]:h},[]);return V1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},fP=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),pk=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Mf="-",H1=[],mP="arbitrary..",xP=t=>{const e=yP(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return gP(o);const c=o.split(Mf),u=c[0]===""&&c.length>1?1:0;return mk(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?fP(h,u):u:h||H1}return n[o]||H1}}},mk=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=mk(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Mf):t.slice(e).join(Mf),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?mP+r:void 0})(),yP=t=>{const{theme:e,classGroups:n}=t;return bP(n,e)},bP=(t,e)=>{const n=pk();for(const r in t){const a=t[r];Y0(a,n,r,e)}return n},Y0=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){NP(t,e,n);return}if(typeof t=="function"){wP(t,e,n,r);return}jP(t,e,n,r)},NP=(t,e,n)=>{const r=t===""?e:xk(e,t);r.classGroupId=n},wP=(t,e,n,r)=>{if(kP(t)){Y0(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(pP(n,t))},jP=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split(Mf),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,SP=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)}}},Hg="!",U1=":",CP=[],W1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),EP=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 W1(i,b,x,N)};if(e){const a=e+U1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):W1(CP,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},TP=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}},MP=t=>({cache:SP(t.cacheSize),parseClassName:EP(t),sortModifiers:TP(t),...xP(t)}),AP=/\s+/,PP=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(AP);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:x,hasImportantModifier:b,baseClassName:N,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!w,k=r(v?N.substring(0,w):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=r(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const M=x.length===0?"":x.length===1?x[0]:i(x).join(":"),E=b?M+Hg:M,L=E+k;if(o.indexOf(L)>-1)continue;o.push(L);const R=a(k,v);for(let W=0;W0?" "+u:u)}return u},IP=(...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=MP(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=PP(u,n);return a(u,f),f};return i=o,(...u)=>i(IP(...u))},LP=[],qn=t=>{const e=n=>n[t]||LP;return e.isThemeGetter=!0,e},yk=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,bk=/^\((?:(\w[\w-]*):)?(.+)\)$/i,OP=/^\d+\/\d+$/,DP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_P=/\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$/,$P=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,zP=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,FP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ac=t=>OP.test(t),kt=t=>!!t&&!Number.isNaN(Number(t)),io=t=>!!t&&Number.isInteger(Number(t)),Ox=t=>t.endsWith("%")&&kt(t.slice(0,-1)),di=t=>DP.test(t),BP=()=>!0,VP=t=>_P.test(t)&&!$P.test(t),vk=()=>!1,HP=t=>zP.test(t),UP=t=>FP.test(t),WP=t=>!Qe(t)&&!Ye(t),KP=t=>cd(t,jk,vk),Qe=t=>yk.test(t),Cl=t=>cd(t,kk,VP),Dx=t=>cd(t,YP,kt),K1=t=>cd(t,Nk,vk),qP=t=>cd(t,wk,UP),Vh=t=>cd(t,Sk,HP),Ye=t=>bk.test(t),Gd=t=>dd(t,kk),GP=t=>dd(t,XP),q1=t=>dd(t,Nk),JP=t=>dd(t,jk),QP=t=>dd(t,wk),Hh=t=>dd(t,Sk,!0),cd=(t,e,n)=>{const r=yk.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},dd=(t,e,n=!1)=>{const r=bk.exec(t);return r?r[1]?e(r[1]):n:!1},Nk=t=>t==="position"||t==="percentage",wk=t=>t==="image"||t==="url",jk=t=>t==="length"||t==="size"||t==="bg-size",kk=t=>t==="length",YP=t=>t==="number",XP=t=>t==="family-name",Sk=t=>t==="shadow",ZP=()=>{const t=qn("color"),e=qn("font"),n=qn("text"),r=qn("font-weight"),a=qn("tracking"),i=qn("leading"),o=qn("breakpoint"),c=qn("container"),u=qn("spacing"),h=qn("radius"),f=qn("shadow"),m=qn("inset-shadow"),x=qn("text-shadow"),b=qn("drop-shadow"),N=qn("blur"),w=qn("perspective"),v=qn("aspect"),k=qn("ease"),M=qn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...L(),Ye,Qe],W=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],B=()=>[Ye,Qe,u],O=()=>[Ac,"full","auto",...B()],Y=()=>[io,"none","subgrid",Ye,Qe],ae=()=>["auto",{span:["full",io,Ye,Qe]},io,Ye,Qe],_=()=>[io,"auto",Ye,Qe],se=()=>["auto","min","max","fr",Ye,Qe],ce=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],me=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...B()],X=()=>[Ac,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],V=()=>[t,Ye,Qe],xe=()=>[...L(),q1,K1,{position:[Ye,Qe]}],ee=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",JP,KP,{size:[Ye,Qe]}],K=()=>[Ox,Gd,Cl],fe=()=>["","none","full",h,Ye,Qe],he=()=>["",kt,Gd,Cl],ue=()=>["solid","dashed","dotted","double"],$=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[kt,Ox,q1,K1],z=()=>["","none",N,Ye,Qe],te=()=>["none",kt,Ye,Qe],ie=()=>["none",kt,Ye,Qe],we=()=>[kt,Ye,Qe],Be=()=>[Ac,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[di],breakpoint:[di],color:[BP],container:[di],"drop-shadow":[di],ease:["in","out","in-out"],font:[WP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[di],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[di],shadow:[di],spacing:["px",kt],text:[di],"text-shadow":[di],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ac,Qe,Ye,v]}],container:["container"],columns:[{columns:[kt,Qe,Ye,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:R()}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[io,"auto",Ye,Qe]}],basis:[{basis:[Ac,"full","auto",c,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[kt,Ac,"auto","initial","none",Qe]}],grow:[{grow:["",kt,Ye,Qe]}],shrink:[{shrink:["",kt,Ye,Qe]}],order:[{order:[io,"first","last","none",Ye,Qe]}],"grid-cols":[{"grid-cols":Y()}],"col-start-end":[{col:ae()}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":Y()}],"row-start-end":[{row:ae()}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":se()}],"auto-rows":[{"auto-rows":se()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...ce(),"normal"]}],"justify-items":[{"justify-items":[...me(),"normal"]}],"justify-self":[{"justify-self":["auto",...me()]}],"align-content":[{content:["normal",...ce()]}],"align-items":[{items:[...me(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...me(),{baseline:["","last"]}]}],"place-content":[{"place-content":ce()}],"place-items":[{"place-items":[...me(),"baseline"]}],"place-self":[{"place-self":["auto",...me()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"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,Gd,Cl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ye,Dx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ox,Qe]}],"font-family":[{font:[GP,Qe,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,Ye,Qe]}],"line-clamp":[{"line-clamp":[kt,"none",Ye,Dx]}],leading:[{leading:[i,...B()]}],"list-image":[{"list-image":["none",Ye,Qe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ye,Qe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ue(),"wavy"]}],"text-decoration-thickness":[{decoration:[kt,"from-font","auto",Ye,Cl]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[kt,"auto",Ye,Qe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ye,Qe]}],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",Ye,Qe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:ee()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},io,Ye,Qe],radial:["",Ye,Qe],conic:[io,Ye,Qe]},QP,qP]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:fe()}],"rounded-s":[{"rounded-s":fe()}],"rounded-e":[{"rounded-e":fe()}],"rounded-t":[{"rounded-t":fe()}],"rounded-r":[{"rounded-r":fe()}],"rounded-b":[{"rounded-b":fe()}],"rounded-l":[{"rounded-l":fe()}],"rounded-ss":[{"rounded-ss":fe()}],"rounded-se":[{"rounded-se":fe()}],"rounded-ee":[{"rounded-ee":fe()}],"rounded-es":[{"rounded-es":fe()}],"rounded-tl":[{"rounded-tl":fe()}],"rounded-tr":[{"rounded-tr":fe()}],"rounded-br":[{"rounded-br":fe()}],"rounded-bl":[{"rounded-bl":fe()}],"border-w":[{border:he()}],"border-w-x":[{"border-x":he()}],"border-w-y":[{"border-y":he()}],"border-w-s":[{"border-s":he()}],"border-w-e":[{"border-e":he()}],"border-w-t":[{"border-t":he()}],"border-w-r":[{"border-r":he()}],"border-w-b":[{"border-b":he()}],"border-w-l":[{"border-l":he()}],"divide-x":[{"divide-x":he()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":he()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ue(),"hidden","none"]}],"divide-style":[{divide:[...ue(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...ue(),"none","hidden"]}],"outline-offset":[{"outline-offset":[kt,Ye,Qe]}],"outline-w":[{outline:["",kt,Gd,Cl]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",f,Hh,Vh]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",m,Hh,Vh]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:he()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[kt,Cl]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",x,Hh,Vh]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[kt,Ye,Qe]}],"mix-blend":[{"mix-blend":[...$(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":$()}],"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":[kt]}],"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":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"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":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"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":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"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":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"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":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"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":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"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":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[Ye,Qe]}],"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":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"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":L()}],"mask-image-conic-pos":[{"mask-conic":[kt]}],"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":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:ee()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ye,Qe]}],filter:[{filter:["","none",Ye,Qe]}],blur:[{blur:z()}],brightness:[{brightness:[kt,Ye,Qe]}],contrast:[{contrast:[kt,Ye,Qe]}],"drop-shadow":[{"drop-shadow":["","none",b,Hh,Vh]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",kt,Ye,Qe]}],"hue-rotate":[{"hue-rotate":[kt,Ye,Qe]}],invert:[{invert:["",kt,Ye,Qe]}],saturate:[{saturate:[kt,Ye,Qe]}],sepia:[{sepia:["",kt,Ye,Qe]}],"backdrop-filter":[{"backdrop-filter":["","none",Ye,Qe]}],"backdrop-blur":[{"backdrop-blur":z()}],"backdrop-brightness":[{"backdrop-brightness":[kt,Ye,Qe]}],"backdrop-contrast":[{"backdrop-contrast":[kt,Ye,Qe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",kt,Ye,Qe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[kt,Ye,Qe]}],"backdrop-invert":[{"backdrop-invert":["",kt,Ye,Qe]}],"backdrop-opacity":[{"backdrop-opacity":[kt,Ye,Qe]}],"backdrop-saturate":[{"backdrop-saturate":[kt,Ye,Qe]}],"backdrop-sepia":[{"backdrop-sepia":["",kt,Ye,Qe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ye,Qe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[kt,"initial",Ye,Qe]}],ease:[{ease:["linear","initial",k,Ye,Qe]}],delay:[{delay:[kt,Ye,Qe]}],animate:[{animate:["none",M,Ye,Qe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Ye,Qe]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:ie()}],"scale-x":[{"scale-x":ie()}],"scale-y":[{"scale-y":ie()}],"scale-z":[{"scale-z":ie()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[Ye,Qe,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Be()}],"translate-x":[{"translate-x":Be()}],"translate-y":[{"translate-y":Be()}],"translate-z":[{"translate-z":Be()}],"translate-none":["translate-none"],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"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",Ye,Qe]}],"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":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"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",Ye,Qe]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[kt,Gd,Cl,Dx]}],stroke:[{stroke:["none",...V()]}],"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"]}},eI=RP(ZP);function Dt(...t){return eI(hk(t))}function aa(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const tI=fk("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 J({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?dk:"button";return s.jsx(i,{"data-slot":"button",className:Dt(tI({variant:e,size:n,className:t})),...a})}function le({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:Dt("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 nI(){const t=_a(),[e,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(""),[c,u]=g.useState(!1);g.useEffect(()=>{_u()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await xt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){ZA(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(Vc,{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(yi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(le,{type:"text",value:e,onChange:f=>{n(f.target.value),i&&o("")},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(_M,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(le,{type:"password",value:r,onChange:f=>{a(f.target.value),i&&o("")},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(J,{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 _e=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Dt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));_e.displayName="Card";const it=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Dt("flex flex-col space-y-1.5 p-6",t),...e}));it.displayName="CardHeader";const ot=g.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:Dt("font-semibold leading-none tracking-tight",t),...e}));ot.displayName="CardTitle";const qt=g.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:Dt("text-sm text-muted-foreground",t),...e}));qt.displayName="CardDescription";const $e=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Dt("p-6 pt-0",t),...e}));$e.displayName="CardContent";const sI=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Dt("flex items-center p-6 pt-0",t),...e}));sI.displayName="CardFooter";const rI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function _x(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=rI[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 x;return(x=m.parentNode)==null?void 0:x.removeChild(m)},250))}}const G={success:(t,e)=>_x(t,"success",e),error:(t,e)=>_x(t,"error",e),info:(t,e)=>_x(t,"info",e)};function Nt(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 aI(t,e){const n=g.createContext(e),r=i=>{const{children:o,...c}=i,u=g.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function a(i){const o=g.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 Ho(t,e=[]){let n=[];function r(i,o){const c=g.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:x,children:b,...N}=m,w=((k=x==null?void 0:x[t])==null?void 0:k[u])||c,v=g.useMemo(()=>N,Object.values(N));return s.jsx(w.Provider,{value:v,children:b})};h.displayName=i+"Provider";function f(m,x){var w;const b=((w=x==null?void 0:x[t])==null?void 0:w[u])||c,N=g.useContext(b);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[r,iI(a,...e)]}function iI(...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 g.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Rs=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},oI=Cp[" useId ".trim().toString()]||(()=>{}),lI=0;function Eo(t){const[e,n]=g.useState(oI());return Rs(()=>{n(r=>r??String(lI++))},[t]),e?`radix-${e}`:""}var cI=Cp[" useInsertionEffect ".trim().toString()]||Rs;function Fl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=dI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=g.useRef(t!==void 0);g.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=g.useCallback(f=>{var m;if(c){const x=uI(f)?f(t):f;x!==t&&((m=o.current)==null||m.call(o,x))}else i(f)},[c,t,i,o]);return[u,h]}function dI({defaultProp:t,onChange:e}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(e);return cI(()=>{i.current=e},[e]),g.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function uI(t){return typeof t=="function"}function wu(t){const e=hI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,c=g.Children.toArray(i),u=c.find(pI);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function hI(t){const e=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=xI(a),c=mI(i,a.props);return a.type!==g.Fragment&&(c.ref=r?Q0(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var fI=Symbol("radix.slottable");function pI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===fI}function mI(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 xI(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 gI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],St=gI.reduce((t,e)=>{const n=wu(`Primitive.${e}`),r=g.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 yI(t,e){t&&id.flushSync(()=>t.dispatchEvent(e))}function Lo(t){const e=g.useRef(t);return g.useEffect(()=>{e.current=t}),g.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function bI(t,e=globalThis==null?void 0:globalThis.document){const n=Lo(t);g.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 vI="DismissableLayer",Ug="dismissableLayer.update",NI="dismissableLayer.pointerDownOutside",wI="dismissableLayer.focusOutside",G1,Ck=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),X0=g.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=g.useContext(Ck),[f,m]=g.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=g.useState({}),N=Jt(e,P=>m(P)),w=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(v),M=f?w.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,L=M>=k,R=SI(P=>{const B=P.target,O=[...h.branches].some(Y=>Y.contains(B));!L||O||(a==null||a(P),o==null||o(P),P.defaultPrevented||c==null||c())},x),W=CI(P=>{const B=P.target;[...h.branches].some(Y=>Y.contains(B))||(i==null||i(P),o==null||o(P),P.defaultPrevented||c==null||c())},x);return bI(P=>{M===h.layers.size-1&&(r==null||r(P),!P.defaultPrevented&&c&&(P.preventDefault(),c()))},x),g.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(G1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),J1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=G1)}},[f,x,n,h]),g.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),J1())},[f,h]),g.useEffect(()=>{const P=()=>b({});return document.addEventListener(Ug,P),()=>document.removeEventListener(Ug,P)},[]),s.jsx(St.div,{...u,ref:N,style:{pointerEvents:E?L?"auto":"none":void 0,...t.style},onFocusCapture:Nt(t.onFocusCapture,W.onFocusCapture),onBlurCapture:Nt(t.onBlurCapture,W.onBlurCapture),onPointerDownCapture:Nt(t.onPointerDownCapture,R.onPointerDownCapture)})});X0.displayName=vI;var jI="DismissableLayerBranch",kI=g.forwardRef((t,e)=>{const n=g.useContext(Ck),r=g.useRef(null),a=Jt(e,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(St.div,{...t,ref:a})});kI.displayName=jI;function SI(t,e=globalThis==null?void 0:globalThis.document){const n=Lo(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Ek(NI,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 CI(t,e=globalThis==null?void 0:globalThis.document){const n=Lo(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&Ek(wI,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 J1(){const t=new CustomEvent(Ug);document.dispatchEvent(t)}function Ek(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?yI(a,i):a.dispatchEvent(i)}var $x="focusScope.autoFocusOnMount",zx="focusScope.autoFocusOnUnmount",Q1={bubbles:!1,cancelable:!0},EI="FocusScope",Z0=g.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=g.useState(null),h=Lo(a),f=Lo(i),m=g.useRef(null),x=Jt(e,w=>u(w)),b=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let w=function(E){if(b.paused||!c)return;const L=E.target;c.contains(L)?m.current=L:co(m.current,{select:!0})},v=function(E){if(b.paused||!c)return;const L=E.relatedTarget;L!==null&&(c.contains(L)||co(m.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const R of E)R.removedNodes.length>0&&co(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",v);const M=new MutationObserver(k);return c&&M.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",v),M.disconnect()}}},[r,c,b.paused]),g.useEffect(()=>{if(c){X1.add(b);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent($x,Q1);c.addEventListener($x,h),c.dispatchEvent(k),k.defaultPrevented||(TI(RI(Tk(c)),{select:!0}),document.activeElement===w&&co(c))}return()=>{c.removeEventListener($x,h),setTimeout(()=>{const k=new CustomEvent(zx,Q1);c.addEventListener(zx,f),c.dispatchEvent(k),k.defaultPrevented||co(w??document.body,{select:!0}),c.removeEventListener(zx,f),X1.remove(b)},0)}}},[c,h,f,b]);const N=g.useCallback(w=>{if(!n&&!r||b.paused)return;const v=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(v&&k){const M=w.currentTarget,[E,L]=MI(M);E&&L?!w.shiftKey&&k===L?(w.preventDefault(),n&&co(E,{select:!0})):w.shiftKey&&k===E&&(w.preventDefault(),n&&co(L,{select:!0})):k===M&&w.preventDefault()}},[n,r,b.paused]);return s.jsx(St.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});Z0.displayName=EI;function TI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(co(r,{select:e}),document.activeElement!==n)return}function MI(t){const e=Tk(t),n=Y1(e,t),r=Y1(e.reverse(),t);return[n,r]}function Tk(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 Y1(t,e){for(const n of t)if(!AI(n,{upTo:e}))return n}function AI(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 PI(t){return t instanceof HTMLInputElement&&"select"in t}function co(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&PI(t)&&e&&t.select()}}var X1=II();function II(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=Z1(t,e),t.unshift(e)},remove(e){var n;t=Z1(t,e),(n=t[0])==null||n.resume()}}}function Z1(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function RI(t){return t.filter(e=>e.tagName!=="A")}var LI="Portal",ey=g.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=g.useState(!1);Rs(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Fj.createPortal(s.jsx(St.div,{...r,ref:e}),o):null});ey.displayName=LI;function OI(t,e){return g.useReducer((n,r)=>e[n][r]??n,t)}var $u=t=>{const{present:e,children:n}=t,r=DI(e),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Jt(r.ref,_I(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};$u.displayName="Presence";function DI(t){const[e,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[c,u]=OI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const h=Uh(r.current);i.current=c==="mounted"?h:"none"},[c]),Rs(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,b=Uh(h);t?u("MOUNT"):b==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&x!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),Rs(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=b=>{const w=Uh(r.current).includes(CSS.escape(b.animationName));if(b.target===e&&w&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},x=b=>{b.target===e&&(i.current=Uh(r.current))};return e.addEventListener("animationstart",x),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",x),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:g.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function Uh(t){return(t==null?void 0:t.animationName)||"none"}function _I(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 Fx=0;function Mk(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??eN()),document.body.insertAdjacentElement("beforeend",t[1]??eN()),Fx++,()=>{Fx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Fx--}},[])}function eN(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Ta=function(){return Ta=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return eR;var e=tR(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])}},sR=Rk(),qc="data-scroll-locked",rR=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` + */const XA=[["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"}]],Ro=Ee("zap",XA),J0="admin_token";function $u(){try{return localStorage.getItem(J0)}catch{return null}}function ZA(t){try{localStorage.setItem(J0,t)}catch{}}function Lx(){try{localStorage.removeItem(J0)}catch{}}const eP="https://soulapi.quwanzhi.com",tP=15e3,z1=6e4,nP=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return eP};function zl(t){const e=nP(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Mp(t,e={}){const{data:n,...r}=e,a=zl(t),i=new Headers(r.headers),o=$u();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=r.timeout??tP,h=new AbortController,f=setTimeout(()=>h.abort(),u),m=await fetch(a,{...r,headers:i,body:c,credentials:"include",signal:h.signal}).finally(()=>clearTimeout(f)),x=m.headers.get("Content-Type")||"";let b;if(x.includes("application/json"))try{b=await m.json()}catch{throw new Error(`API 响应解析失败 (${m.status})`)}else{const w=await m.text();throw new Error(`API 返回非 JSON 响应 (${m.status}): ${w.slice(0,100)}`)}const N=w=>{const v=w,k=((v==null?void 0:v.message)||(v==null?void 0:v.error)||"").toString();(k.includes("可提现金额不足")||k.includes("可提现不足")||k.includes("余额不足"))&&window.dispatchEvent(new CustomEvent("recharge-alert",{detail:k}))};if(!m.ok){N(b);const w=new Error((b==null?void 0:b.error)||`HTTP ${m.status}`);throw w.status=m.status,w.data=b,w}return N(b),b}function Re(t,e){return Mp(t,{...e,method:"GET"})}function gt(t,e,n){return Mp(t,{...n,method:"POST",data:e})}function Yt(t,e,n){return Mp(t,{...n,method:"PUT",data:e})}function bi(t,e){return Mp(t,{...e,method:"DELETE"})}function sP(){const[t,e]=g.useState(!1),[n,r]=g.useState("");return g.useEffect(()=>{const a=i=>{const o=i.detail;r(o||"可提现/余额不足,请及时充值商户号"),e(!0)};return window.addEventListener("recharge-alert",a),()=>window.removeEventListener("recharge-alert",a)},[]),t?s.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3 bg-red-900/80 border-b border-red-600/50 text-red-100",role:"alert",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Yj,{className:"w-5 h-5 shrink-0 text-red-400"}),s.jsxs("span",{className:"text-sm font-medium",children:[n,s.jsx("span",{className:"ml-2 text-red-300",children:"请及时充值商户号或核对账户后重试。"})]})]}),s.jsx("button",{type:"button",onClick:()=>e(!1),className:"shrink-0 p-1 rounded hover:bg-red-800/50 transition-colors","aria-label":"关闭告警",children:s.jsx(Qn,{className:"w-4 h-4"})})]}):null}const rP=[{icon:TM,label:"数据概览",href:"/dashboard"},{icon:or,label:"内容管理",href:"/content"},{icon:Vn,label:"用户管理",href:"/users"},{icon:iM,label:"找伙伴",href:"/find-partner"},{icon:Yc,label:"推广中心",href:"/distribution"}];function aP(){const t=Vo(),e=g.useRef(t.pathname);e.current=t.pathname;const n=_a(),[r,a]=g.useState(!1),[i,o]=g.useState(!1);g.useEffect(()=>{a(!0)},[]),g.useEffect(()=>{if(!r)return;let u=!1;if(!$u()){n("/login",{replace:!0});return}return Re("/api/admin").then(h=>{u||(h&&h.success!==!1?o(!0):(Lx(),n("/login",{replace:!0,state:{from:e.current}})))}).catch(()=>{u||(Lx(),n("/login",{replace:!0,state:{from:e.current}}))}),()=>{u=!0}},[r,n]);const c=async()=>{Lx();try{await gt("/api/admin/logout",{})}catch{}n("/login",{replace:!0})};return!r||!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:[rP.map(u=>{const h=t.pathname===u.href;return s.jsxs(Po,{to:u.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${h?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[s.jsx(u.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:u.label})]},u.href)}),s.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50 space-y-1",children:s.jsxs(Po,{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(vo,{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:c,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(zM,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0 flex flex-col",children:[s.jsx(sP,{}),s.jsx("div",{className:"w-full min-w-0 min-h-full flex-1",children:s.jsx(QE,{})})]})]})}function F1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Q0(...t){return e=>{let n=!1;const r=t.map(a=>{const i=F1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;lk(i)&&typeof Tf=="function"&&(i=Tf(i._payload));const c=g.Children.toArray(i),u=c.find(dP);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var dk=ck("Slot");function lP(t){const e=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(lk(a)&&typeof Tf=="function"&&(a=Tf(a._payload)),g.isValidElement(a)){const o=hP(a),c=uP(i,a.props);return a.type!==g.Fragment&&(c.ref=r?Q0(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var cP=Symbol("radix.slottable");function dP(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===cP}function uP(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 hP(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 uk(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,V1=hk,fk=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return V1(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 x=B1(f)||B1(m);return a[h][x]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,x]=f;return x===void 0||(h[m]=x),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:x,...b}=f;return Object.entries(b).every(N=>{let[w,v]=N;return Array.isArray(v)?v.includes({...i,...c}[w]):{...i,...c}[w]===v})?[...h,m,x]:h},[]);return V1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},fP=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),pk=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Mf="-",H1=[],mP="arbitrary..",xP=t=>{const e=yP(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return gP(o);const c=o.split(Mf),u=c[0]===""&&c.length>1?1:0;return mk(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?fP(h,u):u:h||H1}return n[o]||H1}}},mk=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=mk(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Mf):t.slice(e).join(Mf),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?mP+r:void 0})(),yP=t=>{const{theme:e,classGroups:n}=t;return bP(n,e)},bP=(t,e)=>{const n=pk();for(const r in t){const a=t[r];Y0(a,n,r,e)}return n},Y0=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){NP(t,e,n);return}if(typeof t=="function"){wP(t,e,n,r);return}jP(t,e,n,r)},NP=(t,e,n)=>{const r=t===""?e:xk(e,t);r.classGroupId=n},wP=(t,e,n,r)=>{if(kP(t)){Y0(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(pP(n,t))},jP=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split(Mf),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,SP=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)}}},Hg="!",U1=":",CP=[],W1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),EP=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 W1(i,b,x,N)};if(e){const a=e+U1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):W1(CP,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},TP=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}},MP=t=>({cache:SP(t.cacheSize),parseClassName:EP(t),sortModifiers:TP(t),...xP(t)}),AP=/\s+/,PP=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(AP);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:x,hasImportantModifier:b,baseClassName:N,maybePostfixModifierPosition:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!w,k=r(v?N.substring(0,w):N);if(!k){if(!v){u=f+(u.length>0?" "+u:u);continue}if(k=r(N),!k){u=f+(u.length>0?" "+u:u);continue}v=!1}const M=x.length===0?"":x.length===1?x[0]:i(x).join(":"),E=b?M+Hg:M,L=E+k;if(o.indexOf(L)>-1)continue;o.push(L);const R=a(k,v);for(let W=0;W0?" "+u:u)}return u},IP=(...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=MP(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=PP(u,n);return a(u,f),f};return i=o,(...u)=>i(IP(...u))},LP=[],qn=t=>{const e=n=>n[t]||LP;return e.isThemeGetter=!0,e},yk=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,bk=/^\((?:(\w[\w-]*):)?(.+)\)$/i,OP=/^\d+\/\d+$/,DP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_P=/\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$/,$P=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,zP=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,FP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ac=t=>OP.test(t),St=t=>!!t&&!Number.isNaN(Number(t)),ao=t=>!!t&&Number.isInteger(Number(t)),Ox=t=>t.endsWith("%")&&St(t.slice(0,-1)),di=t=>DP.test(t),BP=()=>!0,VP=t=>_P.test(t)&&!$P.test(t),vk=()=>!1,HP=t=>zP.test(t),UP=t=>FP.test(t),WP=t=>!Qe(t)&&!Ye(t),KP=t=>cd(t,jk,vk),Qe=t=>yk.test(t),Cl=t=>cd(t,kk,VP),Dx=t=>cd(t,YP,St),K1=t=>cd(t,Nk,vk),qP=t=>cd(t,wk,UP),Vh=t=>cd(t,Sk,HP),Ye=t=>bk.test(t),Jd=t=>dd(t,kk),GP=t=>dd(t,XP),q1=t=>dd(t,Nk),JP=t=>dd(t,jk),QP=t=>dd(t,wk),Hh=t=>dd(t,Sk,!0),cd=(t,e,n)=>{const r=yk.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},dd=(t,e,n=!1)=>{const r=bk.exec(t);return r?r[1]?e(r[1]):n:!1},Nk=t=>t==="position"||t==="percentage",wk=t=>t==="image"||t==="url",jk=t=>t==="length"||t==="size"||t==="bg-size",kk=t=>t==="length",YP=t=>t==="number",XP=t=>t==="family-name",Sk=t=>t==="shadow",ZP=()=>{const t=qn("color"),e=qn("font"),n=qn("text"),r=qn("font-weight"),a=qn("tracking"),i=qn("leading"),o=qn("breakpoint"),c=qn("container"),u=qn("spacing"),h=qn("radius"),f=qn("shadow"),m=qn("inset-shadow"),x=qn("text-shadow"),b=qn("drop-shadow"),N=qn("blur"),w=qn("perspective"),v=qn("aspect"),k=qn("ease"),M=qn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...L(),Ye,Qe],W=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],B=()=>[Ye,Qe,u],O=()=>[Ac,"full","auto",...B()],X=()=>[ao,"none","subgrid",Ye,Qe],ae=()=>["auto",{span:["full",ao,Ye,Qe]},ao,Ye,Qe],_=()=>[ao,"auto",Ye,Qe],se=()=>["auto","min","max","fr",Ye,Qe],ce=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],me=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...B()],Z=()=>[Ac,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],V=()=>[t,Ye,Qe],xe=()=>[...L(),q1,K1,{position:[Ye,Qe]}],ee=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",JP,KP,{size:[Ye,Qe]}],K=()=>[Ox,Jd,Cl],fe=()=>["","none","full",h,Ye,Qe],he=()=>["",St,Jd,Cl],ue=()=>["solid","dashed","dotted","double"],$=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[St,Ox,q1,K1],z=()=>["","none",N,Ye,Qe],te=()=>["none",St,Ye,Qe],ie=()=>["none",St,Ye,Qe],we=()=>[St,Ye,Qe],Be=()=>[Ac,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[di],breakpoint:[di],color:[BP],container:[di],"drop-shadow":[di],ease:["in","out","in-out"],font:[WP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[di],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[di],shadow:[di],spacing:["px",St],text:[di],"text-shadow":[di],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ac,Qe,Ye,v]}],container:["container"],columns:[{columns:[St,Qe,Ye,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:R()}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[ao,"auto",Ye,Qe]}],basis:[{basis:[Ac,"full","auto",c,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[St,Ac,"auto","initial","none",Qe]}],grow:[{grow:["",St,Ye,Qe]}],shrink:[{shrink:["",St,Ye,Qe]}],order:[{order:[ao,"first","last","none",Ye,Qe]}],"grid-cols":[{"grid-cols":X()}],"col-start-end":[{col:ae()}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":X()}],"row-start-end":[{row:ae()}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":se()}],"auto-rows":[{"auto-rows":se()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...ce(),"normal"]}],"justify-items":[{"justify-items":[...me(),"normal"]}],"justify-self":[{"justify-self":["auto",...me()]}],"align-content":[{content:["normal",...ce()]}],"align-items":[{items:[...me(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...me(),{baseline:["","last"]}]}],"place-content":[{"place-content":ce()}],"place-items":[{"place-items":[...me(),"baseline"]}],"place-self":[{"place-self":["auto",...me()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],w:[{w:[c,"screen",...Z()]}],"min-w":[{"min-w":[c,"screen","none",...Z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",n,Jd,Cl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ye,Dx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ox,Qe]}],"font-family":[{font:[GP,Qe,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,Ye,Qe]}],"line-clamp":[{"line-clamp":[St,"none",Ye,Dx]}],leading:[{leading:[i,...B()]}],"list-image":[{"list-image":["none",Ye,Qe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ye,Qe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ue(),"wavy"]}],"text-decoration-thickness":[{decoration:[St,"from-font","auto",Ye,Cl]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[St,"auto",Ye,Qe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ye,Qe]}],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",Ye,Qe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:ee()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ao,Ye,Qe],radial:["",Ye,Qe],conic:[ao,Ye,Qe]},QP,qP]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:fe()}],"rounded-s":[{"rounded-s":fe()}],"rounded-e":[{"rounded-e":fe()}],"rounded-t":[{"rounded-t":fe()}],"rounded-r":[{"rounded-r":fe()}],"rounded-b":[{"rounded-b":fe()}],"rounded-l":[{"rounded-l":fe()}],"rounded-ss":[{"rounded-ss":fe()}],"rounded-se":[{"rounded-se":fe()}],"rounded-ee":[{"rounded-ee":fe()}],"rounded-es":[{"rounded-es":fe()}],"rounded-tl":[{"rounded-tl":fe()}],"rounded-tr":[{"rounded-tr":fe()}],"rounded-br":[{"rounded-br":fe()}],"rounded-bl":[{"rounded-bl":fe()}],"border-w":[{border:he()}],"border-w-x":[{"border-x":he()}],"border-w-y":[{"border-y":he()}],"border-w-s":[{"border-s":he()}],"border-w-e":[{"border-e":he()}],"border-w-t":[{"border-t":he()}],"border-w-r":[{"border-r":he()}],"border-w-b":[{"border-b":he()}],"border-w-l":[{"border-l":he()}],"divide-x":[{"divide-x":he()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":he()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ue(),"hidden","none"]}],"divide-style":[{divide:[...ue(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...ue(),"none","hidden"]}],"outline-offset":[{"outline-offset":[St,Ye,Qe]}],"outline-w":[{outline:["",St,Jd,Cl]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",f,Hh,Vh]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",m,Hh,Vh]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:he()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[St,Cl]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",x,Hh,Vh]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[St,Ye,Qe]}],"mix-blend":[{"mix-blend":[...$(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":$()}],"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":[St]}],"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":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"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":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"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":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"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":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"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":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"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":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"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":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[Ye,Qe]}],"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":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"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":L()}],"mask-image-conic-pos":[{"mask-conic":[St]}],"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":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:ee()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ye,Qe]}],filter:[{filter:["","none",Ye,Qe]}],blur:[{blur:z()}],brightness:[{brightness:[St,Ye,Qe]}],contrast:[{contrast:[St,Ye,Qe]}],"drop-shadow":[{"drop-shadow":["","none",b,Hh,Vh]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",St,Ye,Qe]}],"hue-rotate":[{"hue-rotate":[St,Ye,Qe]}],invert:[{invert:["",St,Ye,Qe]}],saturate:[{saturate:[St,Ye,Qe]}],sepia:[{sepia:["",St,Ye,Qe]}],"backdrop-filter":[{"backdrop-filter":["","none",Ye,Qe]}],"backdrop-blur":[{"backdrop-blur":z()}],"backdrop-brightness":[{"backdrop-brightness":[St,Ye,Qe]}],"backdrop-contrast":[{"backdrop-contrast":[St,Ye,Qe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",St,Ye,Qe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[St,Ye,Qe]}],"backdrop-invert":[{"backdrop-invert":["",St,Ye,Qe]}],"backdrop-opacity":[{"backdrop-opacity":[St,Ye,Qe]}],"backdrop-saturate":[{"backdrop-saturate":[St,Ye,Qe]}],"backdrop-sepia":[{"backdrop-sepia":["",St,Ye,Qe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ye,Qe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[St,"initial",Ye,Qe]}],ease:[{ease:["linear","initial",k,Ye,Qe]}],delay:[{delay:[St,Ye,Qe]}],animate:[{animate:["none",M,Ye,Qe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Ye,Qe]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:ie()}],"scale-x":[{"scale-x":ie()}],"scale-y":[{"scale-y":ie()}],"scale-z":[{"scale-z":ie()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[Ye,Qe,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Be()}],"translate-x":[{"translate-x":Be()}],"translate-y":[{"translate-y":Be()}],"translate-z":[{"translate-z":Be()}],"translate-none":["translate-none"],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"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",Ye,Qe]}],"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":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"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",Ye,Qe]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[St,Jd,Cl,Dx]}],stroke:[{stroke:["none",...V()]}],"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"]}},eI=RP(ZP);function _t(...t){return eI(hk(t))}function aa(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const tI=fk("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 J({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?dk:"button";return s.jsx(i,{"data-slot":"button",className:_t(tI({variant:e,size:n,className:t})),...a})}function le({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:_t("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 nI(){const t=_a(),[e,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(""),[c,u]=g.useState(!1);g.useEffect(()=>{$u()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await gt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){ZA(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(Vc,{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(yi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(le,{type:"text",value:e,onChange:f=>{n(f.target.value),i&&o("")},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(_M,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(le,{type:"password",value:r,onChange:f=>{a(f.target.value),i&&o("")},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(J,{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 $e=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:_t("rounded-xl border bg-card text-card-foreground shadow",t),...e}));$e.displayName="Card";const it=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:_t("flex flex-col space-y-1.5 p-6",t),...e}));it.displayName="CardHeader";const ot=g.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:_t("font-semibold leading-none tracking-tight",t),...e}));ot.displayName="CardTitle";const qt=g.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:_t("text-sm text-muted-foreground",t),...e}));qt.displayName="CardDescription";const ze=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:_t("p-6 pt-0",t),...e}));ze.displayName="CardContent";const sI=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:_t("flex items-center p-6 pt-0",t),...e}));sI.displayName="CardFooter";const rI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function _x(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=rI[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 x;return(x=m.parentNode)==null?void 0:x.removeChild(m)},250))}}const G={success:(t,e)=>_x(t,"success",e),error:(t,e)=>_x(t,"error",e),info:(t,e)=>_x(t,"info",e)};function jt(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 aI(t,e){const n=g.createContext(e),r=i=>{const{children:o,...c}=i,u=g.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function a(i){const o=g.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 Ho(t,e=[]){let n=[];function r(i,o){const c=g.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:x,children:b,...N}=m,w=((k=x==null?void 0:x[t])==null?void 0:k[u])||c,v=g.useMemo(()=>N,Object.values(N));return s.jsx(w.Provider,{value:v,children:b})};h.displayName=i+"Provider";function f(m,x){var w;const b=((w=x==null?void 0:x[t])==null?void 0:w[u])||c,N=g.useContext(b);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${i}\``)}return[h,f]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(c){const u=(c==null?void 0:c[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return a.scopeName=t,[r,iI(a,...e)]}function iI(...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 g.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Rs=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},oI=Cp[" useId ".trim().toString()]||(()=>{}),lI=0;function Co(t){const[e,n]=g.useState(oI());return Rs(()=>{n(r=>r??String(lI++))},[t]),e?`radix-${e}`:""}var cI=Cp[" useInsertionEffect ".trim().toString()]||Rs;function Fl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=dI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:a;{const f=g.useRef(t!==void 0);g.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=g.useCallback(f=>{var m;if(c){const x=uI(f)?f(t):f;x!==t&&((m=o.current)==null||m.call(o,x))}else i(f)},[c,t,i,o]);return[u,h]}function dI({defaultProp:t,onChange:e}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(e);return cI(()=>{i.current=e},[e]),g.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function uI(t){return typeof t=="function"}function ju(t){const e=hI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,c=g.Children.toArray(i),u=c.find(pI);if(u){const h=u.props.children,f=c.map(m=>m===u?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:a,children:g.isValidElement(h)?g.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function hI(t){const e=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=xI(a),c=mI(i,a.props);return a.type!==g.Fragment&&(c.ref=r?Q0(r,o):o),g.cloneElement(a,c)}return g.Children.count(a)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var fI=Symbol("radix.slottable");function pI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===fI}function mI(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 xI(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 gI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ct=gI.reduce((t,e)=>{const n=ju(`Primitive.${e}`),r=g.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 yI(t,e){t&&id.flushSync(()=>t.dispatchEvent(e))}function Lo(t){const e=g.useRef(t);return g.useEffect(()=>{e.current=t}),g.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function bI(t,e=globalThis==null?void 0:globalThis.document){const n=Lo(t);g.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 vI="DismissableLayer",Ug="dismissableLayer.update",NI="dismissableLayer.pointerDownOutside",wI="dismissableLayer.focusOutside",G1,Ck=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),X0=g.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=g.useContext(Ck),[f,m]=g.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=g.useState({}),N=Jt(e,P=>m(P)),w=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(v),M=f?w.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,L=M>=k,R=SI(P=>{const B=P.target,O=[...h.branches].some(X=>X.contains(B));!L||O||(a==null||a(P),o==null||o(P),P.defaultPrevented||c==null||c())},x),W=CI(P=>{const B=P.target;[...h.branches].some(X=>X.contains(B))||(i==null||i(P),o==null||o(P),P.defaultPrevented||c==null||c())},x);return bI(P=>{M===h.layers.size-1&&(r==null||r(P),!P.defaultPrevented&&c&&(P.preventDefault(),c()))},x),g.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(G1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),J1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=G1)}},[f,x,n,h]),g.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),J1())},[f,h]),g.useEffect(()=>{const P=()=>b({});return document.addEventListener(Ug,P),()=>document.removeEventListener(Ug,P)},[]),s.jsx(Ct.div,{...u,ref:N,style:{pointerEvents:E?L?"auto":"none":void 0,...t.style},onFocusCapture:jt(t.onFocusCapture,W.onFocusCapture),onBlurCapture:jt(t.onBlurCapture,W.onBlurCapture),onPointerDownCapture:jt(t.onPointerDownCapture,R.onPointerDownCapture)})});X0.displayName=vI;var jI="DismissableLayerBranch",kI=g.forwardRef((t,e)=>{const n=g.useContext(Ck),r=g.useRef(null),a=Jt(e,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Ct.div,{...t,ref:a})});kI.displayName=jI;function SI(t,e=globalThis==null?void 0:globalThis.document){const n=Lo(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Ek(NI,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 CI(t,e=globalThis==null?void 0:globalThis.document){const n=Lo(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&Ek(wI,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 J1(){const t=new CustomEvent(Ug);document.dispatchEvent(t)}function Ek(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?yI(a,i):a.dispatchEvent(i)}var $x="focusScope.autoFocusOnMount",zx="focusScope.autoFocusOnUnmount",Q1={bubbles:!1,cancelable:!0},EI="FocusScope",Z0=g.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=g.useState(null),h=Lo(a),f=Lo(i),m=g.useRef(null),x=Jt(e,w=>u(w)),b=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let w=function(E){if(b.paused||!c)return;const L=E.target;c.contains(L)?m.current=L:lo(m.current,{select:!0})},v=function(E){if(b.paused||!c)return;const L=E.relatedTarget;L!==null&&(c.contains(L)||lo(m.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const R of E)R.removedNodes.length>0&&lo(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",v);const M=new MutationObserver(k);return c&&M.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",v),M.disconnect()}}},[r,c,b.paused]),g.useEffect(()=>{if(c){X1.add(b);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent($x,Q1);c.addEventListener($x,h),c.dispatchEvent(k),k.defaultPrevented||(TI(RI(Tk(c)),{select:!0}),document.activeElement===w&&lo(c))}return()=>{c.removeEventListener($x,h),setTimeout(()=>{const k=new CustomEvent(zx,Q1);c.addEventListener(zx,f),c.dispatchEvent(k),k.defaultPrevented||lo(w??document.body,{select:!0}),c.removeEventListener(zx,f),X1.remove(b)},0)}}},[c,h,f,b]);const N=g.useCallback(w=>{if(!n&&!r||b.paused)return;const v=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(v&&k){const M=w.currentTarget,[E,L]=MI(M);E&&L?!w.shiftKey&&k===L?(w.preventDefault(),n&&lo(E,{select:!0})):w.shiftKey&&k===E&&(w.preventDefault(),n&&lo(L,{select:!0})):k===M&&w.preventDefault()}},[n,r,b.paused]);return s.jsx(Ct.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});Z0.displayName=EI;function TI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(lo(r,{select:e}),document.activeElement!==n)return}function MI(t){const e=Tk(t),n=Y1(e,t),r=Y1(e.reverse(),t);return[n,r]}function Tk(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 Y1(t,e){for(const n of t)if(!AI(n,{upTo:e}))return n}function AI(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 PI(t){return t instanceof HTMLInputElement&&"select"in t}function lo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&PI(t)&&e&&t.select()}}var X1=II();function II(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=Z1(t,e),t.unshift(e)},remove(e){var n;t=Z1(t,e),(n=t[0])==null||n.resume()}}}function Z1(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function RI(t){return t.filter(e=>e.tagName!=="A")}var LI="Portal",ey=g.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=g.useState(!1);Rs(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Fj.createPortal(s.jsx(Ct.div,{...r,ref:e}),o):null});ey.displayName=LI;function OI(t,e){return g.useReducer((n,r)=>e[n][r]??n,t)}var zu=t=>{const{present:e,children:n}=t,r=DI(e),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Jt(r.ref,_I(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};zu.displayName="Presence";function DI(t){const[e,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[c,u]=OI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const h=Uh(r.current);i.current=c==="mounted"?h:"none"},[c]),Rs(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,b=Uh(h);t?u("MOUNT"):b==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&x!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,u]),Rs(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=b=>{const w=Uh(r.current).includes(CSS.escape(b.animationName));if(b.target===e&&w&&(u("ANIMATION_END"),!a.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},x=b=>{b.target===e&&(i.current=Uh(r.current))};return e.addEventListener("animationstart",x),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",x),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:g.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function Uh(t){return(t==null?void 0:t.animationName)||"none"}function _I(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 Fx=0;function Mk(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??eN()),document.body.insertAdjacentElement("beforeend",t[1]??eN()),Fx++,()=>{Fx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Fx--}},[])}function eN(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Ta=function(){return Ta=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return eR;var e=tR(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])}},sR=Rk(),qc="data-scroll-locked",rR=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(zI,` { overflow: hidden `).concat(r,`; padding-right: `).concat(c,"px ").concat(r,`; @@ -654,12 +654,12 @@ Error generating stack: `+C.message+` `)},nN=function(){var t=parseInt(document.body.getAttribute(qc)||"0",10);return isFinite(t)?t:0},aR=function(){g.useEffect(function(){return document.body.setAttribute(qc,(nN()+1).toString()),function(){var t=nN()-1;t<=0?document.body.removeAttribute(qc):document.body.setAttribute(qc,t.toString())}},[])},iR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;aR();var i=g.useMemo(function(){return nR(a)},[a]);return g.createElement(sR,{styles:rR(i,!e,a,n?"":"!important")})},Wg=!1;if(typeof window<"u")try{var Wh=Object.defineProperty({},"passive",{get:function(){return Wg=!0,!0}});window.addEventListener("test",Wh,Wh),window.removeEventListener("test",Wh,Wh)}catch{Wg=!1}var Pc=Wg?{passive:!1}:!1,oR=function(t){return t.tagName==="TEXTAREA"},Lk=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!oR(t)&&n[e]==="visible")},lR=function(t){return Lk(t,"overflowY")},cR=function(t){return Lk(t,"overflowX")},sN=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Ok(t,r);if(a){var i=Dk(t,r),o=i[1],c=i[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},dR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},uR=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Ok=function(t,e){return t==="v"?lR(e):cR(e)},Dk=function(t,e){return t==="v"?dR(e):uR(e)},hR=function(t,e){return t==="h"&&e==="rtl"?-1:1},fR=function(t,e,n,r,a){var i=hR(t,window.getComputedStyle(e).direction),o=i*r,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,x=0;do{if(!c)break;var b=Dk(t,c),N=b[0],w=b[1],v=b[2],k=w-v-i*N;(N||k)&&Ok(t,c)&&(m+=k,x+=N);var M=c.parentNode;c=M&&M.nodeType===Node.DOCUMENT_FRAGMENT_NODE?M.host:M}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(x)<1)&&(h=!0),h},Kh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},rN=function(t){return[t.deltaX,t.deltaY]},aN=function(t){return t&&"current"in t?t.current:t},pR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},mR=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} -`)},xR=0,Ic=[];function gR(t){var e=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(xR++)[0],i=g.useState(Rk)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=$I([t.lockRef.current],(t.shards||[]).map(aN),!0).filter(Boolean);return w.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=g.useCallback(function(w,v){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=Kh(w),M=n.current,E="deltaX"in w?w.deltaX:M[0]-k[0],L="deltaY"in w?w.deltaY:M[1]-k[1],R,W=w.target,P=Math.abs(E)>Math.abs(L)?"h":"v";if("touches"in w&&P==="h"&&W.type==="range")return!1;var B=window.getSelection(),O=B&&B.anchorNode,Y=O?O===W||O.contains(W):!1;if(Y)return!1;var ae=sN(P,W);if(!ae)return!0;if(ae?R=P:(R=P==="v"?"h":"v",ae=sN(P,W)),!ae)return!1;if(!r.current&&"changedTouches"in w&&(E||L)&&(r.current=R),!R)return!0;var _=r.current||R;return fR(_,v,w,_==="h"?E:L)},[]),u=g.useCallback(function(w){var v=w;if(!(!Ic.length||Ic[Ic.length-1]!==i)){var k="deltaY"in v?rN(v):Kh(v),M=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&pR(R.delta,k)})[0];if(M&&M.should){v.cancelable&&v.preventDefault();return}if(!M){var E=(o.current.shards||[]).map(aN).filter(Boolean).filter(function(R){return R.contains(v.target)}),L=E.length>0?c(v,E[0]):!o.current.noIsolation;L&&v.cancelable&&v.preventDefault()}}},[]),h=g.useCallback(function(w,v,k,M){var E={name:w,delta:v,target:k,should:M,shadowParent:yR(k)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(L){return L!==E})},1)},[]),f=g.useCallback(function(w){n.current=Kh(w),r.current=void 0},[]),m=g.useCallback(function(w){h(w.type,rN(w),w.target,c(w,t.lockRef.current))},[]),x=g.useCallback(function(w){h(w.type,Kh(w),w.target,c(w,t.lockRef.current))},[]);g.useEffect(function(){return Ic.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,Pc),document.addEventListener("touchmove",u,Pc),document.addEventListener("touchstart",f,Pc),function(){Ic=Ic.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,Pc),document.removeEventListener("touchmove",u,Pc),document.removeEventListener("touchstart",f,Pc)}},[]);var b=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:mR(a)}):null,b?g.createElement(iR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function yR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const bR=qI(Ik,gR);var ty=g.forwardRef(function(t,e){return g.createElement(Ap,Ta({},t,{ref:e,sideCar:bR}))});ty.classNames=Ap.classNames;var vR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Rc=new WeakMap,qh=new WeakMap,Gh={},Ux=0,_k=function(t){return t&&(t.host||_k(t.parentNode))},NR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=_k(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})},wR=function(t,e,n,r){var a=NR(e,Array.isArray(t)?t:[t]);Gh[n]||(Gh[n]=new WeakMap);var i=Gh[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(x){if(c.has(x))f(x);else try{var b=x.getAttribute(r),N=b!==null&&b!=="false",w=(Rc.get(x)||0)+1,v=(i.get(x)||0)+1;Rc.set(x,w),i.set(x,v),o.push(x),w===1&&N&&qh.set(x,!0),v===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(k){console.error("aria-hidden: cannot operate on ",x,k)}})};return f(e),c.clear(),Ux++,function(){o.forEach(function(m){var x=Rc.get(m)-1,b=i.get(m)-1;Rc.set(m,x),i.set(m,b),x||(qh.has(m)||m.removeAttribute(r),qh.delete(m)),b||m.removeAttribute(n)}),Ux--,Ux||(Rc=new WeakMap,Rc=new WeakMap,qh=new WeakMap,Gh={})}},$k=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=vR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),wR(r,a,n,"aria-hidden")):function(){return null}},Pp="Dialog",[zk]=Ho(Pp),[jR,la]=zk(Pp),Fk=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=g.useRef(null),u=g.useRef(null),[h,f]=Fl({prop:r,defaultProp:a??!1,onChange:i,caller:Pp});return s.jsx(jR,{scope:e,triggerRef:c,contentRef:u,contentId:Eo(),titleId:Eo(),descriptionId:Eo(),open:h,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Fk.displayName=Pp;var Bk="DialogTrigger",kR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Bk,n),i=Jt(e,a.triggerRef);return s.jsx(St.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":ry(a.open),...r,ref:i,onClick:Nt(t.onClick,a.onOpenToggle)})});kR.displayName=Bk;var ny="DialogPortal",[SR,Vk]=zk(ny,{forceMount:void 0}),Hk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=la(ny,e);return s.jsx(SR,{scope:e,forceMount:n,children:g.Children.map(r,o=>s.jsx($u,{present:n||i.open,children:s.jsx(ey,{asChild:!0,container:a,children:o})}))})};Hk.displayName=ny;var Af="DialogOverlay",Uk=g.forwardRef((t,e)=>{const n=Vk(Af,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=la(Af,t.__scopeDialog);return i.modal?s.jsx($u,{present:r||i.open,children:s.jsx(ER,{...a,ref:e})}):null});Uk.displayName=Af;var CR=wu("DialogOverlay.RemoveScroll"),ER=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Af,n);return s.jsx(ty,{as:CR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(St.div,{"data-state":ry(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Bl="DialogContent",Wk=g.forwardRef((t,e)=>{const n=Vk(Bl,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=la(Bl,t.__scopeDialog);return s.jsx($u,{present:r||i.open,children:i.modal?s.jsx(TR,{...a,ref:e}):s.jsx(MR,{...a,ref:e})})});Wk.displayName=Bl;var TR=g.forwardRef((t,e)=>{const n=la(Bl,t.__scopeDialog),r=g.useRef(null),a=Jt(e,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return $k(i)},[]),s.jsx(Kk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Nt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Nt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:Nt(t.onFocusOutside,i=>i.preventDefault())})}),MR=g.forwardRef((t,e)=>{const n=la(Bl,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return s.jsx(Kk,{...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()}})}),Kk=g.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=la(Bl,n),u=g.useRef(null),h=Jt(e,u);return Mk(),s.jsxs(s.Fragment,{children:[s.jsx(Z0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(X0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ry(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(AR,{titleId:c.titleId}),s.jsx(IR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),sy="DialogTitle",qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(sy,n);return s.jsx(St.h2,{id:a.titleId,...r,ref:e})});qk.displayName=sy;var Gk="DialogDescription",Jk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Gk,n);return s.jsx(St.p,{id:a.descriptionId,...r,ref:e})});Jk.displayName=Gk;var Qk="DialogClose",Yk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Qk,n);return s.jsx(St.button,{type:"button",...r,ref:e,onClick:Nt(t.onClick,()=>a.onOpenChange(!1))})});Yk.displayName=Qk;function ry(t){return t?"open":"closed"}var Xk="DialogTitleWarning",[MH,Zk]=aI(Xk,{contentName:Bl,titleName:sy,docsSlug:"dialog"}),AR=({titleId:t})=>{const e=Zk(Xk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. +`)},xR=0,Ic=[];function gR(t){var e=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(xR++)[0],i=g.useState(Rk)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=$I([t.lockRef.current],(t.shards||[]).map(aN),!0).filter(Boolean);return w.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var c=g.useCallback(function(w,v){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=Kh(w),M=n.current,E="deltaX"in w?w.deltaX:M[0]-k[0],L="deltaY"in w?w.deltaY:M[1]-k[1],R,W=w.target,P=Math.abs(E)>Math.abs(L)?"h":"v";if("touches"in w&&P==="h"&&W.type==="range")return!1;var B=window.getSelection(),O=B&&B.anchorNode,X=O?O===W||O.contains(W):!1;if(X)return!1;var ae=sN(P,W);if(!ae)return!0;if(ae?R=P:(R=P==="v"?"h":"v",ae=sN(P,W)),!ae)return!1;if(!r.current&&"changedTouches"in w&&(E||L)&&(r.current=R),!R)return!0;var _=r.current||R;return fR(_,v,w,_==="h"?E:L)},[]),u=g.useCallback(function(w){var v=w;if(!(!Ic.length||Ic[Ic.length-1]!==i)){var k="deltaY"in v?rN(v):Kh(v),M=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&pR(R.delta,k)})[0];if(M&&M.should){v.cancelable&&v.preventDefault();return}if(!M){var E=(o.current.shards||[]).map(aN).filter(Boolean).filter(function(R){return R.contains(v.target)}),L=E.length>0?c(v,E[0]):!o.current.noIsolation;L&&v.cancelable&&v.preventDefault()}}},[]),h=g.useCallback(function(w,v,k,M){var E={name:w,delta:v,target:k,should:M,shadowParent:yR(k)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(L){return L!==E})},1)},[]),f=g.useCallback(function(w){n.current=Kh(w),r.current=void 0},[]),m=g.useCallback(function(w){h(w.type,rN(w),w.target,c(w,t.lockRef.current))},[]),x=g.useCallback(function(w){h(w.type,Kh(w),w.target,c(w,t.lockRef.current))},[]);g.useEffect(function(){return Ic.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,Pc),document.addEventListener("touchmove",u,Pc),document.addEventListener("touchstart",f,Pc),function(){Ic=Ic.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,Pc),document.removeEventListener("touchmove",u,Pc),document.removeEventListener("touchstart",f,Pc)}},[]);var b=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:mR(a)}):null,b?g.createElement(iR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function yR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const bR=qI(Ik,gR);var ty=g.forwardRef(function(t,e){return g.createElement(Ap,Ta({},t,{ref:e,sideCar:bR}))});ty.classNames=Ap.classNames;var vR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Rc=new WeakMap,qh=new WeakMap,Gh={},Ux=0,_k=function(t){return t&&(t.host||_k(t.parentNode))},NR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=_k(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})},wR=function(t,e,n,r){var a=NR(e,Array.isArray(t)?t:[t]);Gh[n]||(Gh[n]=new WeakMap);var i=Gh[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(x){if(c.has(x))f(x);else try{var b=x.getAttribute(r),N=b!==null&&b!=="false",w=(Rc.get(x)||0)+1,v=(i.get(x)||0)+1;Rc.set(x,w),i.set(x,v),o.push(x),w===1&&N&&qh.set(x,!0),v===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(k){console.error("aria-hidden: cannot operate on ",x,k)}})};return f(e),c.clear(),Ux++,function(){o.forEach(function(m){var x=Rc.get(m)-1,b=i.get(m)-1;Rc.set(m,x),i.set(m,b),x||(qh.has(m)||m.removeAttribute(r),qh.delete(m)),b||m.removeAttribute(n)}),Ux--,Ux||(Rc=new WeakMap,Rc=new WeakMap,qh=new WeakMap,Gh={})}},$k=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=vR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),wR(r,a,n,"aria-hidden")):function(){return null}},Pp="Dialog",[zk]=Ho(Pp),[jR,la]=zk(Pp),Fk=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,c=g.useRef(null),u=g.useRef(null),[h,f]=Fl({prop:r,defaultProp:a??!1,onChange:i,caller:Pp});return s.jsx(jR,{scope:e,triggerRef:c,contentRef:u,contentId:Co(),titleId:Co(),descriptionId:Co(),open:h,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Fk.displayName=Pp;var Bk="DialogTrigger",kR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Bk,n),i=Jt(e,a.triggerRef);return s.jsx(Ct.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":ry(a.open),...r,ref:i,onClick:jt(t.onClick,a.onOpenToggle)})});kR.displayName=Bk;var ny="DialogPortal",[SR,Vk]=zk(ny,{forceMount:void 0}),Hk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=la(ny,e);return s.jsx(SR,{scope:e,forceMount:n,children:g.Children.map(r,o=>s.jsx(zu,{present:n||i.open,children:s.jsx(ey,{asChild:!0,container:a,children:o})}))})};Hk.displayName=ny;var Af="DialogOverlay",Uk=g.forwardRef((t,e)=>{const n=Vk(Af,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=la(Af,t.__scopeDialog);return i.modal?s.jsx(zu,{present:r||i.open,children:s.jsx(ER,{...a,ref:e})}):null});Uk.displayName=Af;var CR=ju("DialogOverlay.RemoveScroll"),ER=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Af,n);return s.jsx(ty,{as:CR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Ct.div,{"data-state":ry(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Bl="DialogContent",Wk=g.forwardRef((t,e)=>{const n=Vk(Bl,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=la(Bl,t.__scopeDialog);return s.jsx(zu,{present:r||i.open,children:i.modal?s.jsx(TR,{...a,ref:e}):s.jsx(MR,{...a,ref:e})})});Wk.displayName=Bl;var TR=g.forwardRef((t,e)=>{const n=la(Bl,t.__scopeDialog),r=g.useRef(null),a=Jt(e,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return $k(i)},[]),s.jsx(Kk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:jt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:jt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:jt(t.onFocusOutside,i=>i.preventDefault())})}),MR=g.forwardRef((t,e)=>{const n=la(Bl,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return s.jsx(Kk,{...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()}})}),Kk=g.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=la(Bl,n),u=g.useRef(null),h=Jt(e,u);return Mk(),s.jsxs(s.Fragment,{children:[s.jsx(Z0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(X0,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ry(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(AR,{titleId:c.titleId}),s.jsx(IR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),sy="DialogTitle",qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(sy,n);return s.jsx(Ct.h2,{id:a.titleId,...r,ref:e})});qk.displayName=sy;var Gk="DialogDescription",Jk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Gk,n);return s.jsx(Ct.p,{id:a.descriptionId,...r,ref:e})});Jk.displayName=Gk;var Qk="DialogClose",Yk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=la(Qk,n);return s.jsx(Ct.button,{type:"button",...r,ref:e,onClick:jt(t.onClick,()=>a.onOpenChange(!1))})});Yk.displayName=Qk;function ry(t){return t?"open":"closed"}var Xk="DialogTitleWarning",[MH,Zk]=aI(Xk,{contentName:Bl,titleName:sy,docsSlug:"dialog"}),AR=({titleId:t})=>{const e=Zk(Xk),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 g.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},PR="DialogDescriptionWarning",IR=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zk(PR).contentName}}.`;return g.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},RR=Fk,LR=Hk,OR=Uk,DR=Wk,_R=qk,$R=Jk,zR=Yk;function Pt(t){return s.jsx(RR,{"data-slot":"dialog",...t})}function FR(t){return s.jsx(LR,{...t})}const e2=g.forwardRef(({className:t,...e},n)=>s.jsx(OR,{ref:n,className:Dt("fixed inset-0 z-50 bg-black/50",t),...e}));e2.displayName="DialogOverlay";const Mt=g.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs(FR,{children:[s.jsx(e2,{}),s.jsxs(DR,{ref:a,"aria-describedby":void 0,className:Dt("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(zR,{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(Qn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mt.displayName="DialogContent";function It({className:t,...e}){return s.jsx("div",{className:Dt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function Xt({className:t,...e}){return s.jsx("div",{className:Dt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Rt(t){return s.jsx(_R,{className:"text-lg font-semibold leading-none",...t})}function Oo(t){return s.jsx($R,{className:"text-sm text-muted-foreground",...t})}const BR=fk("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 Ve({className:t,variant:e,asChild:n=!1,...r}){const a=n?dk:"span";return s.jsx(a,{className:Dt(BR({variant:e}),t),...r})}var VR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],HR=VR.reduce((t,e)=>{const n=ck(`Primitive.${e}`),r=g.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}},{}),UR="Label",t2=g.forwardRef((t,e)=>s.jsx(HR.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())}}));t2.displayName=UR;var n2=t2;const ne=g.forwardRef(({className:t,...e},n)=>s.jsx(n2,{ref:n,className:Dt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));ne.displayName=n2.displayName;function ay(t){const e=t+"CollectionProvider",[n,r]=Ho(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:v,children:k}=w,M=Us.useRef(null),E=Us.useRef(new Map).current;return s.jsx(a,{scope:v,itemMap:E,collectionRef:M,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=wu(c),h=Us.forwardRef((w,v)=>{const{scope:k,children:M}=w,E=i(c,k),L=Jt(v,E.collectionRef);return s.jsx(u,{ref:L,children:M})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=wu(f),b=Us.forwardRef((w,v)=>{const{scope:k,children:M,...E}=w,L=Us.useRef(null),R=Jt(v,L),W=i(f,k);return Us.useEffect(()=>(W.itemMap.set(L,{ref:L,...E}),()=>void W.itemMap.delete(L))),s.jsx(x,{[m]:"",ref:R,children:M})});b.displayName=f;function N(w){const v=i(t+"CollectionConsumer",w);return Us.useCallback(()=>{const M=v.collectionRef.current;if(!M)return[];const E=Array.from(M.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((W,P)=>E.indexOf(W.ref.current)-E.indexOf(P.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:b},N,r]}var WR=g.createContext(void 0);function Ip(t){const e=g.useContext(WR);return t||e||"ltr"}var Wx="rovingFocusGroup.onEntryFocus",KR={bubbles:!1,cancelable:!0},zu="RovingFocusGroup",[Kg,s2,qR]=ay(zu),[GR,r2]=Ho(zu,[qR]),[JR,QR]=GR(zu),a2=g.forwardRef((t,e)=>s.jsx(Kg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Kg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(YR,{...t,ref:e})})}));a2.displayName=zu;var YR=g.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,x=g.useRef(null),b=Jt(e,x),N=Ip(i),[w,v]=Fl({prop:o,defaultProp:c??null,onChange:u,caller:zu}),[k,M]=g.useState(!1),E=Lo(h),L=s2(n),R=g.useRef(!1),[W,P]=g.useState(0);return g.useEffect(()=>{const B=x.current;if(B)return B.addEventListener(Wx,E),()=>B.removeEventListener(Wx,E)},[E]),s.jsx(JR,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:g.useCallback(B=>v(B),[v]),onItemShiftTab:g.useCallback(()=>M(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(B=>B+1),[]),onFocusableItemRemove:g.useCallback(()=>P(B=>B-1),[]),children:s.jsx(St.div,{tabIndex:k||W===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:Nt(t.onMouseDown,()=>{R.current=!0}),onFocus:Nt(t.onFocus,B=>{const O=!R.current;if(B.target===B.currentTarget&&O&&!k){const Y=new CustomEvent(Wx,KR);if(B.currentTarget.dispatchEvent(Y),!Y.defaultPrevented){const ae=L().filter(I=>I.focusable),_=ae.find(I=>I.active),se=ae.find(I=>I.id===w),me=[_,se,...ae].filter(Boolean).map(I=>I.ref.current);l2(me,f)}}R.current=!1}),onBlur:Nt(t.onBlur,()=>M(!1))})})}),i2="RovingFocusGroupItem",o2=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=Eo(),h=i||u,f=QR(i2,n),m=f.currentTabStopId===h,x=s2(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:w}=f;return g.useEffect(()=>{if(r)return b(),()=>N()},[r,b,N]),s.jsx(Kg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(St.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:Nt(t.onMouseDown,v=>{r?f.onItemFocus(h):v.preventDefault()}),onFocus:Nt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:Nt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=e8(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=x().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const L=E.indexOf(v.currentTarget);E=f.loop?t8(E,L+1):E.slice(L+1)}setTimeout(()=>l2(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});o2.displayName=i2;var XR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ZR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function e8(t,e,n){const r=ZR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return XR[r]}function l2(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function t8(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var n8=a2,s8=o2,Rp="Tabs",[r8]=Ho(Rp,[r2]),c2=r2(),[a8,iy]=r8(Rp),d2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Ip(c),[m,x]=Fl({prop:r,onChange:a,defaultProp:i??"",caller:Rp});return s.jsx(a8,{scope:n,baseId:Eo(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(St.div,{dir:f,"data-orientation":o,...h,ref:e})})});d2.displayName=Rp;var u2="TabsList",h2=g.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=iy(u2,n),o=c2(n);return s.jsx(n8,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(St.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});h2.displayName=u2;var f2="TabsTrigger",p2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=iy(f2,n),c=c2(n),u=g2(o.baseId,r),h=y2(o.baseId,r),f=r===o.value;return s.jsx(s8,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(St.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:Nt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:Nt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:Nt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});p2.displayName=f2;var m2="TabsContent",x2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=iy(m2,n),u=g2(c.baseId,r),h=y2(c.baseId,r),f=r===c.value,m=g.useRef(f);return g.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx($u,{present:a||f,children:({present:x})=>s.jsx(St.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});x2.displayName=m2;function g2(t,e){return`${t}-trigger-${e}`}function y2(t,e){return`${t}-content-${e}`}var i8=d2,b2=h2,v2=p2,N2=x2;const Vl=i8,Do=g.forwardRef(({className:t,...e},n)=>s.jsx(b2,{ref:n,className:Dt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Do.displayName=b2.displayName;const Bt=g.forwardRef(({className:t,...e},n)=>s.jsx(v2,{ref:n,className:Dt("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}));Bt.displayName=v2.displayName;const Vt=g.forwardRef(({className:t,...e},n)=>s.jsx(N2,{ref:n,className:Dt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Vt.displayName=N2.displayName;function oy(t){const e=g.useRef({value:t,previous:t});return g.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function ly(t){const[e,n]=g.useState(void 0);return Rs(()=>{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 Lp="Switch",[o8]=Ho(Lp),[l8,c8]=o8(Lp),w2=g.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,[x,b]=g.useState(null),N=Jt(e,E=>b(E)),w=g.useRef(!1),v=x?f||!!x.closest("form"):!0,[k,M]=Fl({prop:a,defaultProp:i??!1,onChange:h,caller:Lp});return s.jsxs(l8,{scope:n,checked:k,disabled:c,children:[s.jsx(St.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":C2(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:Nt(t.onClick,E=>{M(L=>!L),v&&(w.current=E.isPropagationStopped(),w.current||E.stopPropagation())})}),v&&s.jsx(S2,{control:x,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});w2.displayName=Lp;var j2="SwitchThumb",k2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=c8(j2,n);return s.jsx(St.span,{"data-state":C2(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});k2.displayName=j2;var d8="SwitchBubbleInput",S2=g.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),c=Jt(o,i),u=oy(n),h=ly(e);return g.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&b){const N=new Event("click",{bubbles:r});b.call(f,n),f.dispatchEvent(N)}},[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}})});S2.displayName=d8;function C2(t){return t?"checked":"unchecked"}var E2=w2,u8=k2;const Ht=g.forwardRef(({className:t,...e},n)=>s.jsx(E2,{className:Dt("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(u8,{className:Dt("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")})}));Ht.displayName=E2.displayName;const h8={view_chapter:"浏览章节",purchase:"购买",match:"派对匹配",login:"登录",register:"注册",share:"分享",bind_phone:"绑定手机",bind_wechat:"绑定微信",fill_profile:"完善资料",fill_avatar:"设置头像",visit_page:"访问页面",first_pay:"首次付款",vip_activate:"开通会员",click_super:"点击超级个体",lead_submit:"提交留资",withdraw:"申请提现",referral_bind:"绑定推荐人",card_click:"点击名片",btn_click:"按钮点击",tab_click:"切换标签",nav_click:"导航点击",page_view:"页面浏览",search:"搜索"};function f8(t){return h8[t]||t||"行为"}function p8(t,e){const n=new Set,r=a=>(t[a]??0)>0;return(r("purchase")||r("first_pay")||r("vip_activate"))&&n.add("已付费"),(r("lead_submit")||r("click_super"))&&n.add("高意向"),r("view_chapter")&&n.add("想学习"),r("match")&&n.add("找合伙人"),r("withdraw")&&n.add("有提现行为"),r("referral_bind")&&n.add("推广参与"),(r("fill_profile")||r("fill_avatar")||r("bind_phone"))&&n.add("资料完善中"),e!=null&&e.hasFullBook&&n.add("全书读者"),e!=null&&e.isVip&&n.add("VIP会员"),e!=null&&e.mbti&&/^[EI][NS][FT][JP]$/i.test(e.mbti)&&n.add(String(e.mbti).toUpperCase()),Array.from(n)}function cy({open:t,onClose:e,userId:n,onUserUpdated:r}){var Fr,_s,qs,dr,Gs,ua;const[a,i]=g.useState(null),[o,c]=g.useState([]),[u,h]=g.useState({}),[f,m]=g.useState([]),[x,b]=g.useState(null),[N,w]=g.useState(null),[v,k]=g.useState(!1),[M,E]=g.useState(!1),[L,R]=g.useState(!1),[W,P]=g.useState("info"),[B,O]=g.useState(""),[Y,ae]=g.useState(""),[_,se]=g.useState(""),[ce,me]=g.useState([]),[I,X]=g.useState(""),[V,xe]=g.useState(""),[ee,H]=g.useState(""),[K,fe]=g.useState(!1),[he,ue]=g.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[$,Q]=g.useState([]),[z,te]=g.useState(!1),[ie,we]=g.useState(""),[Be,Ue]=g.useState(""),[yt,vn]=g.useState(!1),[dt,Et]=g.useState(!1),[on,Dn]=g.useState(null),[ln,Ut]=g.useState(null),[mn,Sn]=g.useState(""),[_n,Xn]=g.useState(""),[Lt,xn]=g.useState(""),[Ne,Me]=g.useState(!1),[We,tt]=g.useState(null),[Ot,wt]=g.useState(!1),[ze,U]=g.useState({}),[qe,gt]=g.useState([]);g.useEffect(()=>{t&&n&&(wt(!1),P("info"),Dn(null),Ut(null),tt(null),xe(""),H(""),pt(),Re("/api/db/vip-roles").then(de=>{de!=null&&de.success&&de.data&&Q(de.data)}).catch(()=>{}))},[t,n]),g.useEffect(()=>{t&&Re("/api/admin/mbti-avatars").then(de=>{de!=null&&de.avatars&&typeof de.avatars=="object"?U(de.avatars):U({})}).catch(()=>U({}))},[t]);const _t=(de,ve)=>{const At=(de||"").trim();if(At)return aa(At);const Qt=(ve||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Qt)?(ze[Qt]||"").trim():""};async function pt(){if(n){k(!0);try{const de=await Re(`/api/db/users?id=${encodeURIComponent(n)}`);if(de!=null&&de.success&&de.user){const ve=de.user;i(ve),O(ve.phone||""),ae(ve.wechatId||""),se(ve.nickname||""),Sn(ve.phone||""),Xn(ve.wechatId||""),xn(ve.openId||"");try{me(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{me([])}ue({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 Re(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ve!=null&&ve.success){h(ve.stats&&typeof ve.stats=="object"?ve.stats:{});const At=ve.tracks||[];c(At.map(Qt=>({...Qt,actionLabel:Qt.actionLabel||Qt.action,timeAgo:Qt.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ve=await Re(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success?(m(ve.referrals||[]),b(ve.inboundSource||null)):(m([]),b(null))}catch{m([]),b(null)}try{const ve=await Re(`/api/admin/users/${encodeURIComponent(n)}/balance`);ve!=null&&ve.success&&ve.data?w(ve.data):w(null)}catch{w(null)}try{const ve=await Re(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ve!=null&&ve.success&&ve.orders?gt(ve.orders):gt([])}catch{gt([])}}catch(de){console.error("Load user detail error:",de)}finally{k(!1)}}}async function lt(){if(!(a!=null&&a.phone)){G.info("用户未绑定手机号,无法同步");return}E(!0);try{const de=await xt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});de!=null&&de.success?(G.success("同步成功"),pt()):G.error("同步失败: "+(de==null?void 0:de.error))}catch(de){console.error("Sync CKB error:",de),G.error("同步失败")}finally{E(!1)}}async function Tt(){if(a){if(he.isVip&&!he.vipExpireDate.trim()){G.error("开启 VIP 请填写有效到期日");return}R(!0);try{const de={id:a.id,phone:B.trim()||void 0,wechatId:Y.trim(),nickname:_||void 0,tags:JSON.stringify(ce),isVip:he.isVip,vipExpireDate:he.isVip?he.vipExpireDate:void 0,vipRole:he.vipRole||void 0,vipName:he.vipName||void 0,vipProject:he.vipProject||void 0,vipContact:he.vipContact||void 0,vipBio:he.vipBio||void 0},ve=await Yt("/api/db/users",de);ve!=null&&ve.success?(G.success("保存成功"),pt(),r==null||r()):G.error("保存失败: "+(ve==null?void 0:ve.error))}catch(de){console.error("Save user error:",de),G.error("保存失败")}finally{R(!1)}}}const Wt=()=>{I&&!ce.includes(I)&&(me([...ce,I]),X(""))},Nn=de=>me(ce.filter(ve=>ve!==de));async function ks(){if(a){if(!V){G.error("请输入新密码");return}if(V!==ee){G.error("两次密码不一致");return}if(V.length<6){G.error("密码至少 6 位");return}fe(!0);try{const de=await Yt("/api/db/users",{id:a.id,password:V});de!=null&&de.success?(G.success("修改成功"),xe(""),H("")):G.error("修改失败: "+((de==null?void 0:de.error)||""))}catch{G.error("修改失败")}finally{fe(!1)}}}async function Ss(){if(!a)return;const de=parseFloat(ie);if(Number.isNaN(de)||de===0){G.error("请输入有效金额(正数增加、负数扣减)");return}vn(!0);try{const ve=await xt(`/api/admin/users/${a.id}/balance/adjust`,{amount:de,remark:Be||void 0});ve!=null&&ve.success?(G.success("余额已调整"),te(!1),we(""),Ue(""),pt(),r==null||r()):G.error("调整失败: "+((ve==null?void 0:ve.error)||""))}catch{G.error("调整失败")}finally{vn(!1)}}async function Li(){if(!mn&&!Lt&&!_n){Ut("请至少输入手机号、微信号或 OpenID 中的一项");return}Et(!0),Ut(null),Dn(null);try{const de=new URLSearchParams;mn&&de.set("phone",mn),Lt&&de.set("openId",Lt),_n&&de.set("wechatId",_n);const ve=await Re(`/api/admin/shensheshou/query?${de}`);ve!=null&&ve.success&&ve.data?(Dn(ve.data),a&&await da(ve.data)):Ut((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(de){console.error("SSS query error:",de),Ut("请求失败,请检查神射手接口配置")}finally{Et(!1)}}async function da(de){if(a)try{await xt("/api/admin/shensheshou/enrich",{userId:a.id,phone:mn||a.phone||"",openId:Lt||a.openId||"",wechatId:_n||a.wechatId||""}),pt()}catch(ve){console.error("SSS enrich error:",ve)}}async function Fa(){if(a){Me(!0),tt(null);try{const de=Array.from(new Set(o.filter(Zn=>Zn.action==="view_chapter"||Zn.action==="purchase"||Zn.action==="first_pay").map(Zn=>(Zn.chapterTitle||Zn.target||"").trim()).filter(Boolean))).slice(0,12),ve={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},At=de.length>0?`意向章节:${de.join("、")}`:"",Qt={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:ce,purchaseIntent:ve,purchaseIntentChapters:de,remark:At}]},Zt=await xt("/api/admin/shensheshou/ingest",Qt);Zt!=null&&Zt.success&&Zt.data?tt(Zt.data):tt({error:(Zt==null?void 0:Zt.error)||"推送失败"})}catch(de){console.error("SSS ingest error:",de),tt({error:"请求失败"})}finally{Me(!1)}}}const Ba=de=>{const At={view_chapter:or,purchase:iu,match:Vn,login:yi,register:yi,share:Aa,bind_phone:O1,bind_wechat:UM,fill_profile:ou,fill_avatar:yi,visit_page:na,first_pay:iu,vip_activate:Kc,click_super:Vn,lead_submit:O1,withdraw:Nu,referral_bind:Aa,card_click:yi,btn_click:Ro,tab_click:na,nav_click:na,page_view:na,search:na}[de]||_g;return s.jsx(At,{className:"w-4 h-4"})};function Nr(de){const ve=String(de||"").trim();return ve.length>22&&/^[a-zA-Z0-9_-]+$/.test(ve)}const wr=g.useMemo(()=>p8(u,a),[u,a]);function jr(){const de=[...ce];for(const ve of wr)de.includes(ve)||de.push(ve);me(de),G.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Pt,{open:t,onOpenChange:()=>e(),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[92vh] overflow-hidden flex flex-col p-4 sm:p-5",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(yi,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(He,{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 flex-col sm:flex-row gap-2.5 p-2.5 bg-[#0a1628] rounded-lg mb-2 shrink-0",children:[s.jsxs("div",{className:"flex gap-2.5 min-w-0 flex-1",children:[s.jsx("div",{className:"w-11 h-11 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-lg text-[#38bdac] shrink-0",children:_t(a.avatar,a.mbti)&&!Ot?s.jsx("img",{src:_t(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>wt(!0)}):((Fr=a.nickname)==null?void 0:Fr.charAt(0))||"?"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),a.referralCode&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:["推荐码 ",s.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]}),s.jsxs("div",{className:"mt-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"昵称"}),s.jsx("p",{className:"text-white truncate",children:_||a.nickname||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"手机号"}),s.jsx("p",{className:"text-white truncate",children:B||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"微信标识"}),s.jsx("p",{className:"text-white truncate",children:Y||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"画像"}),s.jsx("p",{className:"text-[#38bdac] truncate",children:[a.region,a.industry,a.position,a.mbti?`MBTI ${a.mbti}`:""].filter(Boolean).join(" · ")||"未完善"})]})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-2 gap-1.5 shrink-0 sm:w-[220px]",children:[s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wide",children:"累计佣金"}),s.jsxs("p",{className:"text-sm font-bold text-[#38bdac] leading-tight",children:["¥",(a.earnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"推广/分佣入账"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"待提现"}),s.jsxs("p",{className:"text-sm font-bold text-yellow-400 leading-tight",children:["¥",(a.pendingEarnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"未打款部分"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsxs("div",{className:"flex items-center justify-between gap-1",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"账户余额"}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{we(""),Ue(""),te(!0)},children:"调整"})]}),s.jsxs("p",{className:"text-sm font-bold text-white leading-tight",children:["¥",((N==null?void 0:N.balance)??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"可消费/抵扣"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"推荐人数"}),s.jsx("p",{className:"text-sm font-bold text-white leading-tight",children:a.referralCount??0}),s.jsx("p",{className:"text-[9px] text-gray-600",children:a.createdAt?`注册 ${new Date(a.createdAt).toLocaleDateString()}`:"—"})]})]})]}),s.jsxs(Vl,{value:W,onValueChange:P,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(Do,{className:"bg-[#0a1628] border border-gray-700/50 p-0.5 mb-2 flex-wrap h-auto gap-0.5 shrink-0",children:[s.jsx(Bt,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"用户信息"}),s.jsxs(Bt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:[s.jsx(na,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Bt,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"关系链路"}),s.jsx(Bt,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"标签体系"})]}),s.jsxs(Vt,{value:"info",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[s.jsxs("details",{className:"rounded-lg bg-[#0a1628] border border-gray-700/40 p-2 text-[11px] group",children:[s.jsxs("summary",{className:"cursor-pointer text-gray-400 select-none list-none flex items-center gap-1",children:[s.jsx("span",{className:"group-open:text-[#38bdac]",children:"技术标识"}),s.jsx("span",{className:"text-gray-600",children:"(用户ID / OpenID,默认折叠)"})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 text-gray-300 font-mono text-[10px] break-all border-t border-gray-700/30 pt-2",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"用户ID"})," ",a.id]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"OpenID"})," ",a.openId||"—"]}),s.jsx("p",{className:"text-gray-500 not-italic font-sans leading-snug",children:"OpenID 为微信用户标识;下方「微信标识」为微信号/wxid,供存客宝归属,与 OpenID 不同。"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:_,onChange:de=>se(de.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:B,onChange:de=>O(de.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:Y,onChange:de=>ae(de.target.value)})]})]}),(a.region||a.industry||a.position||a.mbti)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px]",children:[a.region&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:[s.jsx(ak,{className:"w-3 h-3 inline mr-0.5"}),a.region]}),a.industry&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["行业 ",a.industry]}),a.position&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["职位 ",a.position]}),a.mbti&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#38bdac]/15 text-[#38bdac]",children:["MBTI ",a.mbti]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-amber-500/25",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Kc,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx(Ht,{className:"scale-90",checked:he.isVip,onCheckedChange:de=>ue(ve=>({...ve,isVip:de}))})]}),he.isVip&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mt-2",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(le,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:he.vipExpireDate,onChange:de=>ue(ve=>({...ve,vipExpireDate:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-1.5 h-7 text-xs",value:he.vipRole,onChange:de=>ue(ve=>({...ve,vipRole:de.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),$.map(de=>s.jsx("option",{value:de.name,children:de.name},de.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:he.vipName,onChange:de=>ue(ve=>({...ve,vipName:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:he.vipProject,onChange:de=>ue(ve=>({...ve,vipProject:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:he.vipContact,onChange:de=>ue(ve=>({...ve,vipContact:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:he.vipBio,onChange:de=>ue(ve=>({...ve,vipBio:de.target.value}))})]})]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-[#38bdac]/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Ro,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"外部资料 · 神射手 / 存客宝(与上方基础信息联动)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-1.5 mb-1.5",children:[s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:mn,onChange:de=>Sn(de.target.value)}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:_n,onChange:de=>Xn(de.target.value)}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:Lt,onChange:de=>xn(de.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(J,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:Li,disabled:dt,children:[dt?s.jsx(He,{className:"w-3 h-3 animate-spin"}):s.jsx(lr,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(J,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:Fa,disabled:Ne||!a.phone,children:Ne?"推送…":"推神射手"}),s.jsx(J,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:lt,disabled:M||!a.phone,children:M?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),ln&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:ln}),on&&s.jsxs("div",{className:"mt-1.5 grid grid-cols-2 gap-1.5",children:[s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"RFM"})," ",s.jsx("span",{className:"text-[#38bdac] font-semibold",children:on.rfm_score??"—"})]}),s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"等级"})," ",s.jsx("span",{className:"text-white font-semibold",children:on.user_level??"—"})]})]}),We&&s.jsx("p",{className:"mt-1 text-[11px]",children:We.error?s.jsx("span",{className:"text-red-400",children:String(We.error)}):s.jsx("span",{className:"text-green-400",children:"推送成功"})})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Nu,{className:"w-3.5 h-3.5 text-yellow-400"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-1.5 sm:items-center",children:[s.jsx(le,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:V,onChange:de=>xe(de.target.value)}),s.jsx(le,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:ee,onChange:de=>H(de.target.value)}),s.jsx(J,{size:"sm",className:"h-7 text-[11px] shrink-0 bg-yellow-500/20 text-yellow-300 border border-yellow-500/35 hover:bg-yellow-500/30",onClick:ks,disabled:K||!V||!ee,children:K?"保存中":"确认修改"})]})]})]}),s.jsxs(Vt,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[qe.length>0&&s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(iu,{className:"w-3.5 h-3.5 text-amber-400"}),s.jsxs("span",{className:"text-white text-xs font-medium",children:["购买清单(",qe.length," 笔)"]})]}),s.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:qe.map((de,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-amber-300",children:de.productType==="fullbook"||de.productType==="vip"?"全书/VIP":`章节 ${de.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(de.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:de.createdAt?new Date(de.createdAt).toLocaleString("zh-CN"):""})]},de.orderSn||ve))})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg flex flex-col gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400",children:[s.jsx(na,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsxs("span",{children:["全站埋点共 ",o.length," 条;用于 RFM 与「标签体系」旅程推断"]})]}),Object.keys(u).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 pt-1 border-t border-gray-700/40",children:Object.entries(u).sort((de,ve)=>ve[1]-de[1]).map(([de,ve])=>s.jsxs(Ve,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[f8(de)," ×",ve]},de))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((de,ve)=>s.jsxs("div",{className:"flex items-start gap-2 p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:Ba(de.action)}),ve0?((x==null?void 0:x.visits)||[]).map((de,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"text-white truncate",children:["第 ",de.seq||ve+1," 次 · ",de.referrerNickname||"微信用户",de.referrerId?`(${de.referrerId})`:""]}),de.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:de.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:de.visitedAt?new Date(de.visitedAt).toLocaleString():""})]},`${de.referrerId||"unknown"}_${ve}`)):s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"暂无来源点击记录"})})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Aa,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),s.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((de,ve)=>{var Qt;const At=de;return s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[10px] text-[#38bdac] shrink-0",children:((Qt=At.nickname)==null?void 0:Qt.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:At.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[At.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-[10px]",children:At.createdAt?new Date(At.createdAt).toLocaleDateString():""})]})]},At.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Vt,{value:"tags",className:"flex-1 min-h-0 overflow-y-auto space-y-3 pr-0.5",children:[s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[s.jsx(ou,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-[11px]",children:"《一场 Soul 的创业实验》维度"})]}),s.jsxs("div",{className:"mb-2 p-2 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-start gap-2 text-[11px] text-gray-400",children:[s.jsx(Xj,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0 mt-0.5"}),"预设可点选;下方「旅程推断」由轨迹+资料自动算出,可一键并入已选后点弹窗底部保存。"]}),s.jsxs("div",{className:"mb-3 p-2 rounded-lg bg-[#162840]/80 border border-cyan-500/20",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-1.5",children:[s.jsx("span",{className:"text-cyan-300/90 text-xs font-medium",children:"旅程推断标签"}),s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:wr.length===0,onClick:jr,children:"合并到已选"})]}),wr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:wr.map(de=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${ce.includes(de)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[ce.includes(de)?"✓ ":"",de]},de))}):s.jsx("p",{className:"text-[11px] text-gray-500",children:"暂无推断(无轨迹或行为未命中规则)"})]}),s.jsx("div",{className:"mb-3 space-y-2",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(de=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:de.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:de.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{ce.includes(ve)?Nn(ve):me([...ce,ve])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${ce.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:[ce.includes(ve)?"✓ ":"",ve]},ve))})]},de.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-2",children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1.5",children:"已选标签(需保存修改写入库)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:[ce.map((de,ve)=>s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[de,s.jsx("button",{type:"button",onClick:()=>Nn(de),className:"ml-1 hover:text-red-400",children:s.jsx(Qn,{className:"w-3 h-3"})})]},ve)),ce.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:I,onChange:de=>X(de.target.value),onKeyDown:de=>de.key==="Enter"&&Wt()}),s.jsx(J,{onClick:Wt,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const de=a.tags||a.ckbTags||"";let ve=[];try{const Qt=typeof de=="string"?JSON.parse(de||"[]"):[];ve=Array.isArray(Qt)?Qt:typeof de=="string"?de.split(","):[]}catch{ve=typeof de=="string"?de.split(","):[]}const At=ve.map(Qt=>String(Qt).trim()).filter(Boolean);return At.length===0?null:s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(ou,{className:"w-3.5 h-3.5 text-purple-400"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:At.map((Qt,Zt)=>s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:Qt},Zt))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(J,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(J,{onClick:Tt,disabled:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),L?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Pt,{open:z,onOpenChange:te,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(It,{children:s.jsx(Rt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ie,onChange:de=>we(de.target.value)})]}),s.jsxs("div",{children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Be,onChange:de=>Ue(de.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(J,{variant:"outline",onClick:()=>te(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(J,{onClick:Ss,disabled:yt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:yt?"提交中...":"确认调整"})]})]})})]}):null}function m8(){const t=_a(),[e,n]=g.useState(!0),[r,a]=g.useState(!0),[i,o]=g.useState(!0),[c,u]=g.useState([]),[h,f]=g.useState([]),[m,x]=g.useState(0),[b,N]=g.useState(0),[w,v]=g.useState(0),[k,M]=g.useState(0),[E,L]=g.useState(null),[R,W]=g.useState(null),[P,B]=g.useState(!1),[O,Y]=g.useState(0),[ae,_]=g.useState(!1),[se,ce]=g.useState(null),[me,I]=g.useState("overview"),[X,V]=g.useState([]),[xe,ee]=g.useState(!1),[H,K]=g.useState("today"),[fe,he]=g.useState(null),[ue,$]=g.useState(!1),[Q,z]=g.useState(!0),[te,ie]=g.useState(null),[we,Be]=g.useState(null),[Ue,yt]=g.useState([]),vn=Ne=>{const Me=Ne;if((Me==null?void 0:Me.status)===401)L("登录已过期,请重新登录");else{if((Me==null?void 0:Me.name)==="AbortError")return;L("加载失败,请检查网络或联系管理员")}};async function dt(Ne){var Ot,wt;const Me=Ne?{signal:Ne}:void 0;n(!0),L(null);try{const ze=await Re("/api/admin/dashboard/stats",Me);ze!=null&&ze.success&&(x(ze.totalUsers??0),N(ze.paidOrderCount??0),v(ze.totalRevenue??0),M(ze.conversionRate??0))}catch(ze){if((ze==null?void 0:ze.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",ze);try{const U=await Re("/api/admin/dashboard/overview",Me);U!=null&&U.success&&(x(U.totalUsers??0),N(U.paidOrderCount??0),v(U.totalRevenue??0),M(U.conversionRate??0))}catch(U){vn(U)}}}finally{n(!1)}try{const ze=await Re("/api/admin/balance/summary",Me);ze!=null&&ze.success&&ze.data&&Y(ze.data.totalGifted??0)}catch{}try{const ze=await Re("/api/db/ckb-plan-stats",Me);ze!=null&&ze.success&&ze.data?ce({ckbTotal:ze.data.ckbTotal??0,withContact:ze.data.withContact??0}):ce(null)}catch{ce(null)}z(!0);try{const[ze,U]=await Promise.allSettled([Re("/api/db/match-records?stats=true",Me),Re("/api/admin/distribution/overview",Me)]);ze.status==="fulfilled"&&((Ot=ze.value)!=null&&Ot.success)&&ze.value.data?ie({totalMatches:ze.value.data.totalMatches??0,todayMatches:ze.value.data.todayMatches??0,uniqueUsers:ze.value.data.uniqueUsers??0,paidMatchCount:ze.value.data.paidMatchCount??0}):ie(null),U.status==="fulfilled"&&((wt=U.value)!=null&&wt.success)&&U.value.overview?Be({todayClicks:U.value.overview.todayClicks??0,todayBindings:U.value.overview.todayBindings??0,todayConversions:U.value.overview.todayConversions??0,monthClicks:U.value.overview.monthClicks??0,monthBindings:U.value.overview.monthBindings??0,monthConversions:U.value.overview.monthConversions??0,totalClicks:U.value.overview.totalClicks??0,totalBindings:U.value.overview.totalBindings??0,totalConversions:U.value.overview.totalConversions??0,conversionRate:U.value.overview.conversionRate}):Be(null)}catch{ie(null),Be(null)}finally{z(!1)}try{const ze=await Re("/api/db/vip-members?limit=500",Me);ze!=null&&ze.success&&Array.isArray(ze.data)?yt(ze.data):yt([])}catch{yt([])}a(!0),o(!0);const We=async()=>{try{const ze=await Re("/api/admin/dashboard/recent-orders?limit=10",Me);if(ze!=null&&ze.success&&ze.recentOrders)f(ze.recentOrders);else throw new Error("no data")}catch(ze){if((ze==null?void 0:ze.name)!=="AbortError")try{const U=await Re("/api/admin/orders?page=1&pageSize=20&status=paid",Me),gt=((U==null?void 0:U.orders)??[]).filter(_t=>["paid","completed","success"].includes(_t.status||""));f(gt.slice(0,5))}catch{f([])}}finally{a(!1)}},tt=async()=>{try{const ze=await Re("/api/admin/dashboard/new-users",Me);if(ze!=null&&ze.success&&ze.newUsers)u(ze.newUsers);else throw new Error("no data")}catch(ze){if((ze==null?void 0:ze.name)!=="AbortError")try{const U=await Re("/api/db/users?page=1&pageSize=10",Me);u((U==null?void 0:U.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([We(),tt()])}async function Et(Ne){const Me=Ne||H;$(!0);try{const We=await Re(`/api/admin/track/stats?period=${Me}`);We!=null&&We.success&&he({total:We.total??0,byModule:We.byModule??{}})}catch{he(null)}finally{$(!1)}}const on={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},Dn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},ln=Ne=>Ne?Ne.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",Ut=Ne=>{if(!Ne)return"";const Me=Ne.trim().toLowerCase();if(!Me)return"";const We=Ue.find(Ot=>{const wt=String(Ot.id||"").toLowerCase();return wt===Me||wt.includes(Me)||Me.includes(wt)});if(We)return We.name||We.nickname||"";const tt=Ue.find(Ot=>{const wt=String(Ot.token||"").toLowerCase();return wt&&(wt===Me||wt.includes(Me)||Me.includes(wt))});return tt&&(tt.name||tt.nickname)||""},mn=Ne=>{if(!Ne)return"未命名点击";const Me=Ne.trim(),We=Me.toLowerCase();if(/^链接头像[_-]/.test(Me)){const Ot=ln(Me.replace(/^链接头像[_-]/,""));return Ot?`头像:${Ot}`:"头像点击"}if(/^member[_-]?detail$/i.test(We)||We.includes("member detail"))return"成员详情";if(/^giftpay$/i.test(We)||We.includes("gift pay"))return"代付入口";if(/^part[-_]/i.test(We))return`章节:${ln(Me)}`;if(We.includes("soulvip")||We.includes("super")){const Ot=Me.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),wt=Ut(Ot)||Ut(ln(Ot));return wt?`超级个体:${wt}`:`超级个体:${ln(Ot)}`}if(We.includes("qgdtw")||We.includes("token")||We.includes("0000"))return`对象:${ln(Me)}`;const tt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return tt[Me]?tt[Me]:/^[a-z0-9_-]+$/i.test(Me)&&ln(Me)||Me},Sn=Ne=>{const Me=on[Ne.module]||on[Ne.page]||Ne.module||Ne.page||"其他",We=Dn[Ne.action]||Ne.action||"点击",tt=mn(Ne.target);return`${Me} · ${We} · ${tt}`};async function _n(){ee(!0);try{const Ne=await Re("/api/admin/super-individual/stats");Ne!=null&&Ne.success&&Array.isArray(Ne.data)&&V(Ne.data)}catch{}finally{ee(!1)}}g.useEffect(()=>{const Ne=new AbortController;return dt(Ne.signal),Et(),_n(),()=>{Ne.abort()}},[]);const Xn=m,Lt=Ne=>{const Me=Ne.productType||"",We=Ne.description||"";if(Me==="balance_recharge")return{title:`余额充值 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(Me==="gift_pay")return{title:`代付 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(Me==="gift_pay_batch"){const tt=typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2);return{title:We||`代付分享 ¥${tt}`,subtitle:"代付分享"}}if(Me==="section"&&We.includes("代付领取"))return{title:We.replace("代付领取 - ",""),subtitle:"代付领取"};if(We){if(Me==="section"&&We.includes("章节")){if(We.includes("-")){const tt=We.split("-");if(tt.length>=3)return{title:`第${tt[1]}章 第${tt[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:We,subtitle:"章节购买"}}return Me==="fullbook"||We.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Me==="vip"||We.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:Me==="match"||We.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:We,subtitle:Me==="section"?"单章":Me==="fullbook"?"全书":"其他"}}return Me==="section"?{title:`章节 ${Ne.productId||""}`,subtitle:"单章购买"}:Me==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Me==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:Me==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:Me||"其他"}},xn=[{title:"总用户数",value:e?null:Xn,sub:null,icon:Vn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:Cf,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:b,sub:null,icon:iu,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:or,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:se?se.ckbTotal??0:null,sub:(se==null?void 0:se.withContact)!=null?`含联系方式 ${se.withContact} 人`:null,icon:Uc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:Q?null:((te==null?void 0:te.totalMatches)??0)+((we==null?void 0:we.totalClicks)??0),sub:Q?null:`找伙伴 ${(te==null?void 0:te.totalMatches)??0} / 推广 ${(we==null?void 0:we.totalClicks)??0}`,icon:qd,color:"text-emerald-400",bg:"bg-emerald-500/20",link:"/find-partner"}];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:()=>dt(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid gap-6 mb-8 grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6",children:xn.map((Ne,Me)=>s.jsxs(_e,{className:"min-w-0 bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>Ne.link&&t(Ne.link),children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(ot,{className:"text-sm font-medium text-gray-400",children:Ne.title}),s.jsx("div",{className:`p-2 rounded-lg ${Ne.bg}`,children:s.jsx(Ne.icon,{className:`w-4 h-4 ${Ne.color}`})})]}),s.jsx($e,{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:Ne.value!=null?Ne.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(He,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),Ne.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:Ne.sub})]}),s.jsx(wi,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},Me))}),s.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[s.jsx("button",{type:"button",onClick:()=>I("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="overview"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"数据概览"}),s.jsx("button",{type:"button",onClick:()=>I("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="tags"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"用户标签点击统计"}),s.jsx("button",{type:"button",onClick:()=>I("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),me==="overview"&&s.jsxs("div",{className:"space-y-8",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsx(ot,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>dt(),disabled:Q,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(He,{className:`w-3.5 h-3.5 ${Q?"animate-spin":""}`}),"刷新"]})]}),s.jsxs($e,{children:[Q&&!te&&!we?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(He,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-4",children:[s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴总匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(te==null?void 0:te.totalMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴今日"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(te==null?void 0:te.todayMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴用户数"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(te==null?void 0:te.uniqueUsers)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalClicks)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalBindings)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalConversions)??0})]})]}),(we==null?void 0:we.conversionRate)&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["推广转化率:",we.conversionRate]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsx(ot,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>dt(),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(He,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(He,{className:"w-3.5 h-3.5"}),"刷新"]})]}),s.jsx($e,{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(He,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,ae?10:4).map(Ne=>{var wt;const Me=Ne.referrerId?c.find(ze=>ze.id===Ne.referrerId):void 0,We=Ne.referralCode||(Me==null?void 0:Me.referralCode)||(Me==null?void 0:Me.nickname)||(Ne.referrerId?String(Ne.referrerId).slice(0,8):""),tt=Lt(Ne),Ot=Ne.userNickname||((wt=c.find(ze=>ze.id===Ne.userId))==null?void 0:wt.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:[Ne.userAvatar?s.jsx("img",{src:Ne.userAvatar,alt:Ot,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:ze=>{ze.currentTarget.style.display="none";const U=ze.currentTarget.nextElementSibling;U&&U.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] shrink-0 mt-0.5 ${Ne.userAvatar?"hidden":""}`,children:Ot.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:()=>{Ne.userId&&(W(Ne.userId),B(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:Ot}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:tt.title,children:tt.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[tt.subtitle&&tt.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:tt.subtitle}),s.jsx("span",{children:new Date(Ne.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),We&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",We]})]})]}),s.jsxs("div",{className:"text-right ml-4 shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(Ne.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Ne.paymentMethod||"微信"})]})]},Ne.id)}),h.length>4&&!ae&&s.jsx("button",{type:"button",onClick:()=>_(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(iu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{children:s.jsx(ot,{className:"text-white",children:"新注册用户"})}),s.jsx($e,{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(He,{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(Ne=>{var Me;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:((Me=Ne.nickname)==null?void 0:Me.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{W(Ne.id),B(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:Ne.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:Ne.phone||"未绑定手机"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:Ne.createdAt?new Date(Ne.createdAt).toLocaleDateString():"-"})]},Ne.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]})]}),me==="tags"&&s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(qd,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(Ne=>s.jsx("button",{type:"button",onClick:()=>{K(Ne),Et(Ne)},className:`px-3 py-1 text-xs rounded-full transition-colors ${H===Ne?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[Ne]},Ne))})]}),s.jsx($e,{children:ue&&!fe?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(He,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):fe&&Object.keys(fe.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:fe.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(fe.byModule).sort((Ne,Me)=>Me[1].reduce((We,tt)=>We+tt.count,0)-Ne[1].reduce((We,tt)=>We+tt.count,0)).slice(0,5).map(([Ne,Me])=>{const We=Me.reduce((tt,Ot)=>tt+Ot.count,0);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:on[Ne]||Ne}),s.jsxs("span",{className:"text-xs text-gray-500",children:[We," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Me.sort((tt,Ot)=>Ot.count-tt.count).slice(0,8).map((tt,Ot)=>{const wt=Sn(tt);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:wt,children:wt}),s.jsxs("div",{className:"flex items-center gap-2 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:`${We>0?tt.count/We*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:tt.count})]})]},Ot)})})]},Ne)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(qd,{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:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),me==="super"&&s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(qd,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:_n,disabled:xe,children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1 ${xe?"animate-spin":""}`}),"刷新"]})]}),s.jsx($e,{children:xe&&X.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(He,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):X.length>0?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:"text-xs text-gray-400 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"排名"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"超级个体"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"总点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"独立访客"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"人均点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",title:"该用户绑定 @人物 后,指向其 person 的留资独立人数",children:"获客(去重)"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"手机号"})]})}),s.jsx("tbody",{children:X.map((Ne,Me)=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[s.jsx("td",{className:"py-2 px-3 text-gray-500 text-xs",children:Me+1}),s.jsx("td",{className:"py-2 px-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[Ne.avatar?s.jsx("img",{src:Ne.avatar,alt:"",className:"w-7 h-7 rounded-full object-cover"}):s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-700 flex items-center justify-center text-xs text-gray-400",children:"?"}),s.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left text-sm truncate max-w-[160px]",onClick:()=>t(`/users?search=${encodeURIComponent(Ne.nickname||Ne.userId)}`),title:"点击跳转用户管理",children:Ne.nickname||Ne.userId})]})}),s.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:Ne.clicks}),s.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:Ne.uniqueClicks}),s.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:Ne.uniqueClicks>0?(Ne.clicks/Ne.uniqueClicks).toFixed(1):"-"}),s.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof Ne.leadCount=="number"?Ne.leadCount:0}),s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:Ne.phone||"-"})]},Ne.userId))})]})}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(qd,{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(cy,{open:P,onClose:()=>{B(!1),W(null)},userId:R,onUserUpdated:()=>dt()})]})}const ls=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:Dt("w-full caption-bottom text-sm",t),...e})}));ls.displayName="Table";const cs=g.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:Dt("[&_tr]:border-b",t),...e}));cs.displayName="TableHeader";const ds=g.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:Dt("[&_tr:last-child]:border-0",t),...e}));ds.displayName="TableBody";const ht=g.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:Dt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));ht.displayName="TableRow";const ke=g.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:Dt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));ke.displayName="TableHead";const je=g.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:Dt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableCell";function Ra(t,e){const[n,r]=g.useState(t);return g.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function us({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 x8(){const[t,e]=g.useState([]),[n,r]=g.useState([]),[a,i]=g.useState(0),[o,c]=g.useState(0),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=Ra(N,300),[k,M]=g.useState("all"),[E,L]=g.useState(!0),[R,W]=g.useState(null),[P,B]=g.useState(null),[O,Y]=g.useState(""),[ae,_]=g.useState(!1);async function se(){L(!0),W(null);try{const ee=k==="all"?"":k==="completed"?"completed":k,H=new URLSearchParams({page:String(f),pageSize:String(x),...ee&&{status:ee},...v&&{search:v}}),[K,fe]=await Promise.all([Re(`/api/admin/orders?${H}`),Re("/api/db/users?page=1&pageSize=500")]);K!=null&&K.success&&(e(K.orders||[]),i(K.total??0),c(K.totalRevenue??0),h(K.todayRevenue??0)),fe!=null&&fe.success&&fe.users&&r(fe.users)}catch(ee){console.error("加载订单失败",ee),W("加载订单失败,请检查网络后重试")}finally{L(!1)}}g.useEffect(()=>{m(1)},[v,k]),g.useEffect(()=>{se()},[f,x,v,k]);const ce=ee=>{var H;return ee.userNickname||((H=n.find(K=>K.id===ee.userId))==null?void 0:H.nickname)||"匿名用户"},me=ee=>{var H;return((H=n.find(K=>K.id===ee))==null?void 0:H.phone)||"-"},I=ee=>{const H=ee.productType||ee.type||"",K=ee.description||"";if(H==="balance_recharge")return{name:`余额充值 ¥${Number(ee.amount||0).toFixed(2)}`,type:"余额充值"};if(K){if(H==="section"&&(K.includes("章节")||K.includes("代付领取"))){if(K.includes("代付领取"))return{name:K.replace("代付领取 - ",""),type:"代付领取"};if(K.includes("-")){const fe=K.split("-");if(fe.length>=3)return{name:`第${fe[1]}章 第${fe[2]}节`,type:"《一场Soul的创业实验》"}}return{name:K,type:"章节购买"}}return H==="fullbook"||K.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:H==="vip"||K.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:H==="match"||K.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:K,type:"其他"}}return H==="section"?{name:`章节 ${ee.productId||ee.sectionId||""}`,type:"单章"}:H==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:H==="vip"?{name:"超级个体开通费用",type:"超级个体"}:H==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:H||"其他"}},X=Math.ceil(a/x)||1;async function V(){var ee;if(!(!(P!=null&&P.orderSn)&&!(P!=null&&P.id))){_(!0),W(null);try{const H=await Yt("/api/admin/orders/refund",{orderSn:P.orderSn||P.id,reason:O||void 0});H!=null&&H.success?(B(null),Y(""),se()):W((H==null?void 0:H.error)||"退款失败")}catch(H){const K=H;W(((ee=K==null?void 0:K.data)==null?void 0:ee.error)||"退款失败,请检查网络后重试")}finally{_(!1)}}}function xe(){if(t.length===0){G.info("暂无数据可导出");return}const ee=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],H=t.map($=>{const Q=I($);return[$.orderSn||$.id||"",ce($),me($.userId),Q.name,Number($.amount||0).toFixed(2),$.paymentMethod==="wechat"?"微信支付":$.paymentMethod==="balance"?"余额支付":$.paymentMethod==="alipay"?"支付宝":$.paymentMethod||"微信支付",$.status==="refunded"?"已退款":$.status==="paid"||$.status==="completed"?"已完成":$.status==="pending"||$.status==="created"?"待支付":"已失败",$.status==="refunded"&&$.refundReason?$.refundReason:"-",$.referrerEarnings?Number($.referrerEarnings).toFixed(2):"-",$.createdAt?new Date($.createdAt).toLocaleString("zh-CN"):""].join(",")}),K="\uFEFF"+[ee.join(","),...H].join(` -`),fe=new Blob([K],{type:"text/csv;charset=utf-8"}),he=URL.createObjectURL(fe),ue=document.createElement("a");ue.href=he,ue.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,ue.click(),URL.revokeObjectURL(he)}return s.jsxs("div",{className:"p-8 w-full",children:[R&&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:R}),s.jsx("button",{type:"button",onClick:()=>W(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(J,{variant:"outline",onClick:se,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{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(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:ee=>w(ee.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nk,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:ee=>M(ee.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(J,{variant:"outline",onClick:xe,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(JT,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:E?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"订单号"}),s.jsx(ke,{className:"text-gray-400",children:"用户"}),s.jsx(ke,{className:"text-gray-400",children:"商品"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"支付方式"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"退款原因"}),s.jsx(ke,{className:"text-gray-400",children:"分销佣金"}),s.jsx(ke,{className:"text-gray-400",children:"下单时间"}),s.jsx(ke,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[t.map(ee=>{const H=I(ee);return s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(je,{className:"font-mono text-xs text-gray-400",children:[(ee.orderSn||ee.id||"").slice(0,12),"..."]}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[ce(ee),ee.paymentMethod==="gift_pay"&&s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),ee.payerUserId&&ee.paymentMethod!=="gift_pay"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:me(ee.userId)}),ee.payerUserId&&ee.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[ee.paymentMethod==="gift_pay"?"赠送人:":"代付人:",ee.payerNickname]})]})}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[H.name,(ee.productType||ee.type)==="vip"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.type})]})}),s.jsxs(je,{className:"text-[#38bdac] font-bold",children:["¥",Number(ee.amount||0).toFixed(2)]}),s.jsx(je,{className:"text-gray-300",children:ee.paymentMethod==="wechat"?"微信支付":ee.paymentMethod==="balance"?"余额支付":ee.paymentMethod==="alipay"?"支付宝":ee.paymentMethod||"微信支付"}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ee.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):ee.status==="paid"||ee.status==="completed"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):ee.status==="pending"||ee.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(ee.status==="paid"||ee.status==="completed")&&(ee.webhookPushStatus==="sent"?s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 hover:bg-orange-500/20 border-0",children:"待补推"}))]})}),s.jsx(je,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:ee.refundReason,children:ee.status==="refunded"&&ee.refundReason?ee.refundReason:"-"}),s.jsx(je,{className:"text-[#FFD700]",children:ee.referrerEarnings?`¥${Number(ee.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(je,{className:"text-gray-400 text-sm",children:new Date(ee.createdAt).toLocaleString("zh-CN")}),s.jsx(je,{children:(ee.status==="paid"||ee.status==="completed")&&ee.paymentMethod!=="balance"&&s.jsxs(J,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{B(ee),Y("")},children:[s.jsx(ok,{className:"w-3 h-3 mr-1"}),"退款"]})})]},ee.id)}),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(us,{page:f,totalPages:X,total:a,pageSize:x,onPageChange:m,onPageSizeChange:ee=>{b(ee),m(1)}})]})})}),s.jsx(Pt,{open:!!P,onOpenChange:ee=>!ee&&B(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(It,{children:s.jsx(Rt,{className:"text-white",children:"订单退款"})}),P&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",P.orderSn||P.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(P.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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:ee=>Y(ee.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>B(null),disabled:ae,children:"取消"}),s.jsx(J,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:V,disabled:ae,children:ae?"退款中...":"确认退款"})]})]})})]})}const Uo=g.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:Dt("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}));Uo.displayName="Textarea";const iN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],T2={INTJ:{title:"战略家",group:"NT",mood:"sharp"},INTP:{title:"逻辑学家",group:"NT",mood:"calm"},ENTJ:{title:"指挥官",group:"NT",mood:"sharp"},ENTP:{title:"辩论家",group:"NT",mood:"playful"},INFJ:{title:"提倡者",group:"NF",mood:"warm"},INFP:{title:"调停者",group:"NF",mood:"warm"},ENFJ:{title:"主人公",group:"NF",mood:"warm"},ENFP:{title:"竞选者",group:"NF",mood:"playful"},ISTJ:{title:"物流师",group:"SJ",mood:"calm"},ISFJ:{title:"守卫者",group:"SJ",mood:"warm"},ESTJ:{title:"总经理",group:"SJ",mood:"sharp"},ESFJ:{title:"执政官",group:"SJ",mood:"warm"},ISTP:{title:"鉴赏家",group:"SP",mood:"sharp"},ISFP:{title:"探险家",group:"SP",mood:"playful"},ESTP:{title:"企业家",group:"SP",mood:"playful"},ESFP:{title:"表演者",group:"SP",mood:"playful"}};function g8(t){switch(t){case"NT":return{bg:"#0d1424",body:"#c89a2c",accent:"#ffd66b",hair:"#6d540f",line:"#111827"};case"NF":return{bg:"#0a1721",body:"#2e9f7c",accent:"#84e9c9",hair:"#2d6a4f",line:"#11212a"};case"SJ":return{bg:"#101828",body:"#4f8cb8",accent:"#9bd4ff",hair:"#2e4a66",line:"#111f2d"};case"SP":return{bg:"#161225",body:"#8b6bc0",accent:"#ccb3ff",hair:"#574183",line:"#211832"};default:return{bg:"#0e1422",body:"#38bdac",accent:"#7ee7db",hair:"#1f6f66",line:"#10202d"}}}function y8(t){switch(t){case"sharp":return{eye:"M222 222 L242 220 M270 220 L290 222",brow:"M218 210 L244 202 M268 202 L294 210",mouth:"M234 256 Q256 246 278 256",tilt:-5};case"warm":return{eye:"M222 224 Q232 230 242 224 M270 224 Q280 230 290 224",brow:"M220 210 Q232 206 244 210 M268 210 Q280 206 292 210",mouth:"M232 254 Q256 272 280 254",tilt:2};case"playful":return{eye:"M222 224 Q232 236 242 224 M270 224 Q280 236 290 224",brow:"M220 210 Q234 200 246 208 M266 208 Q278 200 292 210",mouth:"M232 256 Q256 266 280 250",tilt:8};default:return{eye:"M222 224 Q232 220 242 224 M270 224 Q280 220 290 224",brow:"M220 210 Q232 208 244 210 M268 210 Q280 208 292 210",mouth:"M236 256 Q256 260 276 256",tilt:0}}}function b8(t){switch(t){case"sharp":return"M168 370 L206 300 L256 332 L306 300 L344 370 L306 392 L256 374 L206 392 Z";case"warm":return"M166 368 Q188 318 226 314 L256 340 L286 314 Q324 318 346 368 L314 392 Q286 404 256 396 Q226 404 198 392 Z";case"playful":return"M164 370 L198 304 L252 332 L318 300 L350 374 L316 394 L258 378 L196 396 Z";default:return"M166 370 L202 306 L256 336 L310 306 L346 370 L310 392 L256 380 L202 392 Z"}}function oN(t){const e=T2[t],n=g8(e.group),r=y8(e.mood),a=b8(e.mood),i=` +For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return g.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},PR="DialogDescriptionWarning",IR=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zk(PR).contentName}}.`;return g.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},RR=Fk,LR=Hk,OR=Uk,DR=Wk,_R=qk,$R=Jk,zR=Yk;function It(t){return s.jsx(RR,{"data-slot":"dialog",...t})}function FR(t){return s.jsx(LR,{...t})}const e2=g.forwardRef(({className:t,...e},n)=>s.jsx(OR,{ref:n,className:_t("fixed inset-0 z-50 bg-black/50",t),...e}));e2.displayName="DialogOverlay";const At=g.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs(FR,{children:[s.jsx(e2,{}),s.jsxs(DR,{ref:a,"aria-describedby":void 0,className:_t("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(zR,{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(Qn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));At.displayName="DialogContent";function Rt({className:t,...e}){return s.jsx("div",{className:_t("flex flex-col gap-2 text-center sm:text-left",t),...e})}function Xt({className:t,...e}){return s.jsx("div",{className:_t("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Lt(t){return s.jsx(_R,{className:"text-lg font-semibold leading-none",...t})}function Oo(t){return s.jsx($R,{className:"text-sm text-muted-foreground",...t})}const BR=fk("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 Ve({className:t,variant:e,asChild:n=!1,...r}){const a=n?dk:"span";return s.jsx(a,{className:_t(BR({variant:e}),t),...r})}var VR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],HR=VR.reduce((t,e)=>{const n=ck(`Primitive.${e}`),r=g.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}},{}),UR="Label",t2=g.forwardRef((t,e)=>s.jsx(HR.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())}}));t2.displayName=UR;var n2=t2;const ne=g.forwardRef(({className:t,...e},n)=>s.jsx(n2,{ref:n,className:_t("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));ne.displayName=n2.displayName;function ay(t){const e=t+"CollectionProvider",[n,r]=Ho(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:v,children:k}=w,M=Us.useRef(null),E=Us.useRef(new Map).current;return s.jsx(a,{scope:v,itemMap:E,collectionRef:M,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=ju(c),h=Us.forwardRef((w,v)=>{const{scope:k,children:M}=w,E=i(c,k),L=Jt(v,E.collectionRef);return s.jsx(u,{ref:L,children:M})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=ju(f),b=Us.forwardRef((w,v)=>{const{scope:k,children:M,...E}=w,L=Us.useRef(null),R=Jt(v,L),W=i(f,k);return Us.useEffect(()=>(W.itemMap.set(L,{ref:L,...E}),()=>void W.itemMap.delete(L))),s.jsx(x,{[m]:"",ref:R,children:M})});b.displayName=f;function N(w){const v=i(t+"CollectionConsumer",w);return Us.useCallback(()=>{const M=v.collectionRef.current;if(!M)return[];const E=Array.from(M.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((W,P)=>E.indexOf(W.ref.current)-E.indexOf(P.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:b},N,r]}var WR=g.createContext(void 0);function Ip(t){const e=g.useContext(WR);return t||e||"ltr"}var Wx="rovingFocusGroup.onEntryFocus",KR={bubbles:!1,cancelable:!0},Fu="RovingFocusGroup",[Kg,s2,qR]=ay(Fu),[GR,r2]=Ho(Fu,[qR]),[JR,QR]=GR(Fu),a2=g.forwardRef((t,e)=>s.jsx(Kg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Kg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(YR,{...t,ref:e})})}));a2.displayName=Fu;var YR=g.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,x=g.useRef(null),b=Jt(e,x),N=Ip(i),[w,v]=Fl({prop:o,defaultProp:c??null,onChange:u,caller:Fu}),[k,M]=g.useState(!1),E=Lo(h),L=s2(n),R=g.useRef(!1),[W,P]=g.useState(0);return g.useEffect(()=>{const B=x.current;if(B)return B.addEventListener(Wx,E),()=>B.removeEventListener(Wx,E)},[E]),s.jsx(JR,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:g.useCallback(B=>v(B),[v]),onItemShiftTab:g.useCallback(()=>M(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(B=>B+1),[]),onFocusableItemRemove:g.useCallback(()=>P(B=>B-1),[]),children:s.jsx(Ct.div,{tabIndex:k||W===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:jt(t.onMouseDown,()=>{R.current=!0}),onFocus:jt(t.onFocus,B=>{const O=!R.current;if(B.target===B.currentTarget&&O&&!k){const X=new CustomEvent(Wx,KR);if(B.currentTarget.dispatchEvent(X),!X.defaultPrevented){const ae=L().filter(I=>I.focusable),_=ae.find(I=>I.active),se=ae.find(I=>I.id===w),me=[_,se,...ae].filter(Boolean).map(I=>I.ref.current);l2(me,f)}}R.current=!1}),onBlur:jt(t.onBlur,()=>M(!1))})})}),i2="RovingFocusGroupItem",o2=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=Co(),h=i||u,f=QR(i2,n),m=f.currentTabStopId===h,x=s2(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:w}=f;return g.useEffect(()=>{if(r)return b(),()=>N()},[r,b,N]),s.jsx(Kg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(Ct.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:jt(t.onMouseDown,v=>{r?f.onItemFocus(h):v.preventDefault()}),onFocus:jt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:jt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=e8(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let E=x().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const L=E.indexOf(v.currentTarget);E=f.loop?t8(E,L+1):E.slice(L+1)}setTimeout(()=>l2(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});o2.displayName=i2;var XR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ZR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function e8(t,e,n){const r=ZR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return XR[r]}function l2(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function t8(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var n8=a2,s8=o2,Rp="Tabs",[r8]=Ho(Rp,[r2]),c2=r2(),[a8,iy]=r8(Rp),d2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Ip(c),[m,x]=Fl({prop:r,onChange:a,defaultProp:i??"",caller:Rp});return s.jsx(a8,{scope:n,baseId:Co(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(Ct.div,{dir:f,"data-orientation":o,...h,ref:e})})});d2.displayName=Rp;var u2="TabsList",h2=g.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=iy(u2,n),o=c2(n);return s.jsx(n8,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Ct.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});h2.displayName=u2;var f2="TabsTrigger",p2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=iy(f2,n),c=c2(n),u=g2(o.baseId,r),h=y2(o.baseId,r),f=r===o.value;return s.jsx(s8,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(Ct.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:jt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:jt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:jt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});p2.displayName=f2;var m2="TabsContent",x2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=iy(m2,n),u=g2(c.baseId,r),h=y2(c.baseId,r),f=r===c.value,m=g.useRef(f);return g.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(zu,{present:a||f,children:({present:x})=>s.jsx(Ct.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});x2.displayName=m2;function g2(t,e){return`${t}-trigger-${e}`}function y2(t,e){return`${t}-content-${e}`}var i8=d2,b2=h2,v2=p2,N2=x2;const Vl=i8,Do=g.forwardRef(({className:t,...e},n)=>s.jsx(b2,{ref:n,className:_t("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Do.displayName=b2.displayName;const Bt=g.forwardRef(({className:t,...e},n)=>s.jsx(v2,{ref:n,className:_t("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}));Bt.displayName=v2.displayName;const Vt=g.forwardRef(({className:t,...e},n)=>s.jsx(N2,{ref:n,className:_t("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Vt.displayName=N2.displayName;function oy(t){const e=g.useRef({value:t,previous:t});return g.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function ly(t){const[e,n]=g.useState(void 0);return Rs(()=>{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 Lp="Switch",[o8]=Ho(Lp),[l8,c8]=o8(Lp),w2=g.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,[x,b]=g.useState(null),N=Jt(e,E=>b(E)),w=g.useRef(!1),v=x?f||!!x.closest("form"):!0,[k,M]=Fl({prop:a,defaultProp:i??!1,onChange:h,caller:Lp});return s.jsxs(l8,{scope:n,checked:k,disabled:c,children:[s.jsx(Ct.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":C2(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:jt(t.onClick,E=>{M(L=>!L),v&&(w.current=E.isPropagationStopped(),w.current||E.stopPropagation())})}),v&&s.jsx(S2,{control:x,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});w2.displayName=Lp;var j2="SwitchThumb",k2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=c8(j2,n);return s.jsx(Ct.span,{"data-state":C2(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});k2.displayName=j2;var d8="SwitchBubbleInput",S2=g.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),c=Jt(o,i),u=oy(n),h=ly(e);return g.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&b){const N=new Event("click",{bubbles:r});b.call(f,n),f.dispatchEvent(N)}},[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}})});S2.displayName=d8;function C2(t){return t?"checked":"unchecked"}var E2=w2,u8=k2;const Ut=g.forwardRef(({className:t,...e},n)=>s.jsx(E2,{className:_t("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(u8,{className:_t("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")})}));Ut.displayName=E2.displayName;const h8={view_chapter:"浏览章节",purchase:"购买",match:"派对匹配",login:"登录",register:"注册",share:"分享",bind_phone:"绑定手机",bind_wechat:"绑定微信",fill_profile:"完善资料",fill_avatar:"设置头像",visit_page:"访问页面",first_pay:"首次付款",vip_activate:"开通会员",click_super:"点击超级个体",lead_submit:"提交留资",withdraw:"申请提现",referral_bind:"绑定推荐人",card_click:"点击名片",btn_click:"按钮点击",tab_click:"切换标签",nav_click:"导航点击",page_view:"页面浏览",search:"搜索"};function f8(t){return h8[t]||t||"行为"}function p8(t,e){const n=new Set,r=a=>(t[a]??0)>0;return(r("purchase")||r("first_pay")||r("vip_activate"))&&n.add("已付费"),(r("lead_submit")||r("click_super"))&&n.add("高意向"),r("view_chapter")&&n.add("想学习"),r("match")&&n.add("找合伙人"),r("withdraw")&&n.add("有提现行为"),r("referral_bind")&&n.add("推广参与"),(r("fill_profile")||r("fill_avatar")||r("bind_phone"))&&n.add("资料完善中"),e!=null&&e.hasFullBook&&n.add("全书读者"),e!=null&&e.isVip&&n.add("VIP会员"),e!=null&&e.mbti&&/^[EI][NS][FT][JP]$/i.test(e.mbti)&&n.add(String(e.mbti).toUpperCase()),Array.from(n)}function cy({open:t,onClose:e,userId:n,onUserUpdated:r}){var Fr,_s,qs,dr,Gs,ua;const[a,i]=g.useState(null),[o,c]=g.useState([]),[u,h]=g.useState({}),[f,m]=g.useState([]),[x,b]=g.useState(null),[N,w]=g.useState(null),[v,k]=g.useState(!1),[M,E]=g.useState(!1),[L,R]=g.useState(!1),[W,P]=g.useState("info"),[B,O]=g.useState(""),[X,ae]=g.useState(""),[_,se]=g.useState(""),[ce,me]=g.useState([]),[I,Z]=g.useState(""),[V,xe]=g.useState(""),[ee,H]=g.useState(""),[K,fe]=g.useState(!1),[he,ue]=g.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[$,Q]=g.useState([]),[z,te]=g.useState(!1),[ie,we]=g.useState(""),[Be,Ue]=g.useState(""),[bt,vn]=g.useState(!1),[dt,Tt]=g.useState(!1),[ln,Dn]=g.useState(null),[Zt,Dt]=g.useState(null),[mn,Sn]=g.useState(""),[_n,Xn]=g.useState(""),[Ot,xn]=g.useState(""),[Ne,Te]=g.useState(!1),[We,tt]=g.useState(null),[vt,ft]=g.useState(!1),[_e,U]=g.useState({}),[qe,yt]=g.useState([]);g.useEffect(()=>{t&&n&&(ft(!1),P("info"),Dn(null),Dt(null),tt(null),xe(""),H(""),mt(),Re("/api/db/vip-roles").then(de=>{de!=null&&de.success&&de.data&&Q(de.data)}).catch(()=>{}))},[t,n]),g.useEffect(()=>{t&&Re("/api/admin/mbti-avatars").then(de=>{de!=null&&de.avatars&&typeof de.avatars=="object"?U(de.avatars):U({})}).catch(()=>U({}))},[t]);const $t=(de,ve)=>{const Pt=(de||"").trim();if(Pt)return aa(Pt);const Qt=(ve||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Qt)?(_e[Qt]||"").trim():""};async function mt(){if(n){k(!0);try{const de=await Re(`/api/db/users?id=${encodeURIComponent(n)}`);if(de!=null&&de.success&&de.user){const ve=de.user;i(ve),O(ve.phone||""),ae(ve.wechatId||""),se(ve.nickname||""),Sn(ve.phone||""),Xn(ve.wechatId||""),xn(ve.openId||"");try{me(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{me([])}ue({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 Re(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ve!=null&&ve.success){h(ve.stats&&typeof ve.stats=="object"?ve.stats:{});const Pt=ve.tracks||[];c(Pt.map(Qt=>({...Qt,actionLabel:Qt.actionLabel||Qt.action,timeAgo:Qt.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ve=await Re(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success?(m(ve.referrals||[]),b(ve.inboundSource||null)):(m([]),b(null))}catch{m([]),b(null)}try{const ve=await Re(`/api/admin/users/${encodeURIComponent(n)}/balance`);ve!=null&&ve.success&&ve.data?w(ve.data):w(null)}catch{w(null)}try{const ve=await Re(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ve!=null&&ve.success&&ve.orders?yt(ve.orders):yt([])}catch{yt([])}}catch(de){console.error("Load user detail error:",de)}finally{k(!1)}}}async function lt(){if(!(a!=null&&a.phone)){G.info("用户未绑定手机号,无法同步");return}E(!0);try{const de=await gt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});de!=null&&de.success?(G.success("同步成功"),mt()):G.error("同步失败: "+(de==null?void 0:de.error))}catch(de){console.error("Sync CKB error:",de),G.error("同步失败")}finally{E(!1)}}async function Mt(){if(a){if(he.isVip&&!he.vipExpireDate.trim()){G.error("开启 VIP 请填写有效到期日");return}R(!0);try{const de={id:a.id,phone:B.trim()||void 0,wechatId:X.trim(),nickname:_||void 0,tags:JSON.stringify(ce),isVip:he.isVip,vipExpireDate:he.isVip?he.vipExpireDate:void 0,vipRole:he.vipRole||void 0,vipName:he.vipName||void 0,vipProject:he.vipProject||void 0,vipContact:he.vipContact||void 0,vipBio:he.vipBio||void 0},ve=await Yt("/api/db/users",de);ve!=null&&ve.success?(G.success("保存成功"),mt(),r==null||r()):G.error("保存失败: "+(ve==null?void 0:ve.error))}catch(de){console.error("Save user error:",de),G.error("保存失败")}finally{R(!1)}}}const Wt=()=>{I&&!ce.includes(I)&&(me([...ce,I]),Z(""))},Nn=de=>me(ce.filter(ve=>ve!==de));async function ks(){if(a){if(!V){G.error("请输入新密码");return}if(V!==ee){G.error("两次密码不一致");return}if(V.length<6){G.error("密码至少 6 位");return}fe(!0);try{const de=await Yt("/api/db/users",{id:a.id,password:V});de!=null&&de.success?(G.success("修改成功"),xe(""),H("")):G.error("修改失败: "+((de==null?void 0:de.error)||""))}catch{G.error("修改失败")}finally{fe(!1)}}}async function Ss(){if(!a)return;const de=parseFloat(ie);if(Number.isNaN(de)||de===0){G.error("请输入有效金额(正数增加、负数扣减)");return}vn(!0);try{const ve=await gt(`/api/admin/users/${a.id}/balance/adjust`,{amount:de,remark:Be||void 0});ve!=null&&ve.success?(G.success("余额已调整"),te(!1),we(""),Ue(""),mt(),r==null||r()):G.error("调整失败: "+((ve==null?void 0:ve.error)||""))}catch{G.error("调整失败")}finally{vn(!1)}}async function Ri(){if(!mn&&!Ot&&!_n){Dt("请至少输入手机号、微信号或 OpenID 中的一项");return}Tt(!0),Dt(null),Dn(null);try{const de=new URLSearchParams;mn&&de.set("phone",mn),Ot&&de.set("openId",Ot),_n&&de.set("wechatId",_n);const ve=await Re(`/api/admin/shensheshou/query?${de}`);ve!=null&&ve.success&&ve.data?(Dn(ve.data),a&&await da(ve.data)):Dt((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(de){console.error("SSS query error:",de),Dt("请求失败,请检查神射手接口配置")}finally{Tt(!1)}}async function da(de){if(a)try{await gt("/api/admin/shensheshou/enrich",{userId:a.id,phone:mn||a.phone||"",openId:Ot||a.openId||"",wechatId:_n||a.wechatId||""}),mt()}catch(ve){console.error("SSS enrich error:",ve)}}async function Fa(){if(a){Te(!0),tt(null);try{const de=Array.from(new Set(o.filter(Zn=>Zn.action==="view_chapter"||Zn.action==="purchase"||Zn.action==="first_pay").map(Zn=>(Zn.chapterTitle||Zn.target||"").trim()).filter(Boolean))).slice(0,12),ve={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Pt=de.length>0?`意向章节:${de.join("、")}`:"",Qt={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:ce,purchaseIntent:ve,purchaseIntentChapters:de,remark:Pt}]},en=await gt("/api/admin/shensheshou/ingest",Qt);en!=null&&en.success&&en.data?tt(en.data):tt({error:(en==null?void 0:en.error)||"推送失败"})}catch(de){console.error("SSS ingest error:",de),tt({error:"请求失败"})}finally{Te(!1)}}}const Ba=de=>{const Pt={view_chapter:or,purchase:ou,match:Vn,login:yi,register:yi,share:Aa,bind_phone:O1,bind_wechat:UM,fill_profile:lu,fill_avatar:yi,visit_page:na,first_pay:ou,vip_activate:Kc,click_super:Vn,lead_submit:O1,withdraw:wu,referral_bind:Aa,card_click:yi,btn_click:Ro,tab_click:na,nav_click:na,page_view:na,search:na}[de]||_g;return s.jsx(Pt,{className:"w-4 h-4"})};function Nr(de){const ve=String(de||"").trim();return ve.length>22&&/^[a-zA-Z0-9_-]+$/.test(ve)}const wr=g.useMemo(()=>p8(u,a),[u,a]);function jr(){const de=[...ce];for(const ve of wr)de.includes(ve)||de.push(ve);me(de),G.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(It,{open:t,onOpenChange:()=>e(),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[92vh] overflow-hidden flex flex-col p-4 sm:p-5",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(yi,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(He,{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 flex-col sm:flex-row gap-2.5 p-2.5 bg-[#0a1628] rounded-lg mb-2 shrink-0",children:[s.jsxs("div",{className:"flex gap-2.5 min-w-0 flex-1",children:[s.jsx("div",{className:"w-11 h-11 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-lg text-[#38bdac] shrink-0",children:$t(a.avatar,a.mbti)&&!vt?s.jsx("img",{src:$t(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>ft(!0)}):((Fr=a.nickname)==null?void 0:Fr.charAt(0))||"?"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("h3",{className:"text-base font-bold text-white leading-tight",children:a.nickname}),a.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0",children:a.vipRole})]}),a.referralCode&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:["推荐码 ",s.jsx("code",{className:"text-[#38bdac]",children:a.referralCode})]}),s.jsxs("div",{className:"mt-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"昵称"}),s.jsx("p",{className:"text-white truncate",children:_||a.nickname||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"手机号"}),s.jsx("p",{className:"text-white truncate",children:B||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"微信标识"}),s.jsx("p",{className:"text-white truncate",children:X||"—"})]}),s.jsxs("div",{className:"px-2 py-1 rounded bg-[#162840] border border-gray-700/50",children:[s.jsx("span",{className:"text-gray-500",children:"画像"}),s.jsx("p",{className:"text-[#38bdac] truncate",children:[a.region,a.industry,a.position,a.mbti?`MBTI ${a.mbti}`:""].filter(Boolean).join(" · ")||"未完善"})]})]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-2 gap-1.5 shrink-0 sm:w-[220px]",children:[s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wide",children:"累计佣金"}),s.jsxs("p",{className:"text-sm font-bold text-[#38bdac] leading-tight",children:["¥",(a.earnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"推广/分佣入账"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"待提现"}),s.jsxs("p",{className:"text-sm font-bold text-yellow-400 leading-tight",children:["¥",(a.pendingEarnings??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"未打款部分"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsxs("div",{className:"flex items-center justify-between gap-1",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"账户余额"}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{we(""),Ue(""),te(!0)},children:"调整"})]}),s.jsxs("p",{className:"text-sm font-bold text-white leading-tight",children:["¥",((N==null?void 0:N.balance)??0).toFixed(2)]}),s.jsx("p",{className:"text-[9px] text-gray-600",children:"可消费/抵扣"})]}),s.jsxs("div",{className:"rounded-md bg-[#162840] px-2 py-1.5 border border-gray-700/40",children:[s.jsx("p",{className:"text-[9px] text-gray-500",children:"推荐人数"}),s.jsx("p",{className:"text-sm font-bold text-white leading-tight",children:a.referralCount??0}),s.jsx("p",{className:"text-[9px] text-gray-600",children:a.createdAt?`注册 ${new Date(a.createdAt).toLocaleDateString()}`:"—"})]})]})]}),s.jsxs(Vl,{value:W,onValueChange:P,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(Do,{className:"bg-[#0a1628] border border-gray-700/50 p-0.5 mb-2 flex-wrap h-auto gap-0.5 shrink-0",children:[s.jsx(Bt,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"用户信息"}),s.jsxs(Bt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:[s.jsx(na,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Bt,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"关系链路"}),s.jsx(Bt,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-[11px] px-2 py-1 h-7",children:"标签体系"})]}),s.jsxs(Vt,{value:"info",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[s.jsxs("details",{className:"rounded-lg bg-[#0a1628] border border-gray-700/40 p-2 text-[11px] group",children:[s.jsxs("summary",{className:"cursor-pointer text-gray-400 select-none list-none flex items-center gap-1",children:[s.jsx("span",{className:"group-open:text-[#38bdac]",children:"技术标识"}),s.jsx("span",{className:"text-gray-600",children:"(用户ID / OpenID,默认折叠)"})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 text-gray-300 font-mono text-[10px] break-all border-t border-gray-700/30 pt-2",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"用户ID"})," ",a.id]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-gray-500 not-italic font-sans",children:"OpenID"})," ",a.openId||"—"]}),s.jsx("p",{className:"text-gray-500 not-italic font-sans leading-snug",children:"OpenID 为微信用户标识;下方「微信标识」为微信号/wxid,供存客宝归属,与 OpenID 不同。"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:_,onChange:de=>se(de.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:B,onChange:de=>O(de.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:X,onChange:de=>ae(de.target.value)})]})]}),(a.region||a.industry||a.position||a.mbti)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px]",children:[a.region&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:[s.jsx(ak,{className:"w-3 h-3 inline mr-0.5"}),a.region]}),a.industry&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["行业 ",a.industry]}),a.position&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#162840] text-gray-300",children:["职位 ",a.position]}),a.mbti&&s.jsxs("span",{className:"px-2 py-0.5 rounded bg-[#38bdac]/15 text-[#38bdac]",children:["MBTI ",a.mbti]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-amber-500/25",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(Kc,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"超级个体"}),a.isVip&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx(Ut,{className:"scale-90",checked:he.isVip,onCheckedChange:de=>ue(ve=>({...ve,isVip:de}))})]}),he.isVip&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mt-2",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(le,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:he.vipExpireDate,onChange:de=>ue(ve=>({...ve,vipExpireDate:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-1.5 h-7 text-xs",value:he.vipRole,onChange:de=>ue(ve=>({...ve,vipRole:de.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),$.map(de=>s.jsx("option",{value:de.name,children:de.name},de.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:he.vipName,onChange:de=>ue(ve=>({...ve,vipName:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:he.vipProject,onChange:de=>ue(ve=>({...ve,vipProject:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:he.vipContact,onChange:de=>ue(ve=>({...ve,vipContact:de.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(ne,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:he.vipBio,onChange:de=>ue(ve=>({...ve,vipBio:de.target.value}))})]})]})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-[#38bdac]/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(Ro,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"外部资料 · 神射手 / 存客宝(与上方基础信息联动)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-1.5 mb-1.5",children:[s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:mn,onChange:de=>Sn(de.target.value)}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:_n,onChange:de=>Xn(de.target.value)}),s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:Ot,onChange:de=>xn(de.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(J,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:Ri,disabled:dt,children:[dt?s.jsx(He,{className:"w-3 h-3 animate-spin"}):s.jsx(lr,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(J,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:Fa,disabled:Ne||!a.phone,children:Ne?"推送…":"推神射手"}),s.jsx(J,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:lt,disabled:M||!a.phone,children:M?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),Zt&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:Zt}),ln&&s.jsxs("div",{className:"mt-1.5 grid grid-cols-2 gap-1.5",children:[s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"RFM"})," ",s.jsx("span",{className:"text-[#38bdac] font-semibold",children:ln.rfm_score??"—"})]}),s.jsxs("div",{className:"p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsx("span",{className:"text-gray-500",children:"等级"})," ",s.jsx("span",{className:"text-white font-semibold",children:ln.user_level??"—"})]})]}),We&&s.jsx("p",{className:"mt-1 text-[11px]",children:We.error?s.jsx("span",{className:"text-red-400",children:String(We.error)}):s.jsx("span",{className:"text-green-400",children:"推送成功"})})]}),s.jsxs("div",{className:"p-2 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(wu,{className:"w-3.5 h-3.5 text-yellow-400"}),s.jsx("span",{className:"text-white text-xs font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"flex flex-col sm:flex-row gap-1.5 sm:items-center",children:[s.jsx(le,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:V,onChange:de=>xe(de.target.value)}),s.jsx(le,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:ee,onChange:de=>H(de.target.value)}),s.jsx(J,{size:"sm",className:"h-7 text-[11px] shrink-0 bg-yellow-500/20 text-yellow-300 border border-yellow-500/35 hover:bg-yellow-500/30",onClick:ks,disabled:K||!V||!ee,children:K?"保存中":"确认修改"})]})]})]}),s.jsxs(Vt,{value:"journey",className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-0.5",children:[qe.length>0&&s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx(ou,{className:"w-3.5 h-3.5 text-amber-400"}),s.jsxs("span",{className:"text-white text-xs font-medium",children:["购买清单(",qe.length," 笔)"]})]}),s.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:qe.map((de,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-[11px]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-amber-300",children:de.productType==="fullbook"||de.productType==="vip"?"全书/VIP":`章节 ${de.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(de.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:de.createdAt?new Date(de.createdAt).toLocaleString("zh-CN"):""})]},de.orderSn||ve))})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg flex flex-col gap-1.5 text-[11px]",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400",children:[s.jsx(na,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsxs("span",{children:["全站埋点共 ",o.length," 条;用于 RFM 与「标签体系」旅程推断"]})]}),Object.keys(u).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 pt-1 border-t border-gray-700/40",children:Object.entries(u).sort((de,ve)=>ve[1]-de[1]).map(([de,ve])=>s.jsxs(Ve,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[f8(de)," ×",ve]},de))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((de,ve)=>s.jsxs("div",{className:"flex items-start gap-2 p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[s.jsx("div",{className:"w-7 h-7 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:Ba(de.action)}),ve0?((x==null?void 0:x.visits)||[]).map((de,ve)=>s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"text-white truncate",children:["第 ",de.seq||ve+1," 次 · ",de.referrerNickname||"微信用户",de.referrerId?`(${de.referrerId})`:""]}),de.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:de.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:de.visitedAt?new Date(de.visitedAt).toLocaleString():""})]},`${de.referrerId||"unknown"}_${ve}`)):s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"暂无来源点击记录"})})]}),s.jsxs("div",{className:"p-2 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Aa,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 text-[10px]",children:["共 ",f.length," 人"]})]}),s.jsx("div",{className:"space-y-1 max-h-[min(280px,40vh)] overflow-y-auto",children:f.length>0?f.map((de,ve)=>{var Qt;const Pt=de;return s.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-[#162840] rounded text-xs",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[10px] text-[#38bdac] shrink-0",children:((Qt=Pt.nickname)==null?void 0:Qt.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Pt.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Pt.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-[10px]",children:Pt.createdAt?new Date(Pt.createdAt).toLocaleDateString():""})]})]},Pt.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Vt,{value:"tags",className:"flex-1 min-h-0 overflow-y-auto space-y-3 pr-0.5",children:[s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[s.jsx(lu,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-[11px]",children:"《一场 Soul 的创业实验》维度"})]}),s.jsxs("div",{className:"mb-2 p-2 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-start gap-2 text-[11px] text-gray-400",children:[s.jsx(Xj,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0 mt-0.5"}),"预设可点选;下方「旅程推断」由轨迹+资料自动算出,可一键并入已选后点弹窗底部保存。"]}),s.jsxs("div",{className:"mb-3 p-2 rounded-lg bg-[#162840]/80 border border-cyan-500/20",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-1.5",children:[s.jsx("span",{className:"text-cyan-300/90 text-xs font-medium",children:"旅程推断标签"}),s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:wr.length===0,onClick:jr,children:"合并到已选"})]}),wr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:wr.map(de=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${ce.includes(de)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[ce.includes(de)?"✓ ":"",de]},de))}):s.jsx("p",{className:"text-[11px] text-gray-500",children:"暂无推断(无轨迹或行为未命中规则)"})]}),s.jsx("div",{className:"mb-3 space-y-2",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(de=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:de.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:de.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{ce.includes(ve)?Nn(ve):me([...ce,ve])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${ce.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:[ce.includes(ve)?"✓ ":"",ve]},ve))})]},de.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-2",children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1.5",children:"已选标签(需保存修改写入库)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:[ce.map((de,ve)=>s.jsxs(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[de,s.jsx("button",{type:"button",onClick:()=>Nn(de),className:"ml-1 hover:text-red-400",children:s.jsx(Qn,{className:"w-3 h-3"})})]},ve)),ce.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:I,onChange:de=>Z(de.target.value),onKeyDown:de=>de.key==="Enter"&&Wt()}),s.jsx(J,{onClick:Wt,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const de=a.tags||a.ckbTags||"";let ve=[];try{const Qt=typeof de=="string"?JSON.parse(de||"[]"):[];ve=Array.isArray(Qt)?Qt:typeof de=="string"?de.split(","):[]}catch{ve=typeof de=="string"?de.split(","):[]}const Pt=ve.map(Qt=>String(Qt).trim()).filter(Boolean);return Pt.length===0?null:s.jsxs("div",{className:"p-2.5 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(lu,{className:"w-3.5 h-3.5 text-purple-400"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Pt.map((Qt,en)=>s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:Qt},en))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(J,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(J,{onClick:Mt,disabled:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),L?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(It,{open:z,onOpenChange:te,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsx(Lt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ie,onChange:de=>we(de.target.value)})]}),s.jsxs("div",{children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Be,onChange:de=>Ue(de.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(J,{variant:"outline",onClick:()=>te(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(J,{onClick:Ss,disabled:bt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:bt?"提交中...":"确认调整"})]})]})})]}):null}function m8(){const t=_a(),[e,n]=g.useState(!0),[r,a]=g.useState(!0),[i,o]=g.useState(!0),[c,u]=g.useState([]),[h,f]=g.useState([]),[m,x]=g.useState(0),[b,N]=g.useState(0),[w,v]=g.useState(0),[k,M]=g.useState(0),[E,L]=g.useState(null),[R,W]=g.useState(null),[P,B]=g.useState(!1),[O,X]=g.useState(0),[ae,_]=g.useState(!1),[se,ce]=g.useState(null),[me,I]=g.useState("overview"),[Z,V]=g.useState([]),[xe,ee]=g.useState(!1),[H,K]=g.useState("today"),[fe,he]=g.useState(null),[ue,$]=g.useState(!1),[Q,z]=g.useState(!0),[te,ie]=g.useState(null),[we,Be]=g.useState(null),[Ue,bt]=g.useState([]),vn=Ne=>{const Te=Ne;if((Te==null?void 0:Te.status)===401)L("登录已过期,请重新登录");else{if((Te==null?void 0:Te.name)==="AbortError")return;L("加载失败,请检查网络或联系管理员")}};async function dt(Ne){var vt,ft;const Te=Ne?{signal:Ne}:void 0;n(!0),L(null);try{const _e=await Re("/api/admin/dashboard/stats",Te);_e!=null&&_e.success&&(x(_e.totalUsers??0),N(_e.paidOrderCount??0),v(_e.totalRevenue??0),M(_e.conversionRate??0))}catch(_e){if((_e==null?void 0:_e.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",_e);try{const U=await Re("/api/admin/dashboard/overview",Te);U!=null&&U.success&&(x(U.totalUsers??0),N(U.paidOrderCount??0),v(U.totalRevenue??0),M(U.conversionRate??0))}catch(U){vn(U)}}}finally{n(!1)}try{const _e=await Re("/api/admin/balance/summary",Te);_e!=null&&_e.success&&_e.data&&X(_e.data.totalGifted??0)}catch{}try{const _e=await Re("/api/db/ckb-plan-stats",Te);_e!=null&&_e.success&&_e.data?ce({ckbTotal:_e.data.ckbTotal??0,withContact:_e.data.withContact??0}):ce(null)}catch{ce(null)}z(!0);try{const[_e,U]=await Promise.allSettled([Re("/api/db/match-records?stats=true",Te),Re("/api/admin/distribution/overview",Te)]);_e.status==="fulfilled"&&((vt=_e.value)!=null&&vt.success)&&_e.value.data?ie({totalMatches:_e.value.data.totalMatches??0,todayMatches:_e.value.data.todayMatches??0,uniqueUsers:_e.value.data.uniqueUsers??0,paidMatchCount:_e.value.data.paidMatchCount??0}):ie(null),U.status==="fulfilled"&&((ft=U.value)!=null&&ft.success)&&U.value.overview?Be({todayClicks:U.value.overview.todayClicks??0,todayBindings:U.value.overview.todayBindings??0,todayConversions:U.value.overview.todayConversions??0,monthClicks:U.value.overview.monthClicks??0,monthBindings:U.value.overview.monthBindings??0,monthConversions:U.value.overview.monthConversions??0,totalClicks:U.value.overview.totalClicks??0,totalBindings:U.value.overview.totalBindings??0,totalConversions:U.value.overview.totalConversions??0,conversionRate:U.value.overview.conversionRate}):Be(null)}catch{ie(null),Be(null)}finally{z(!1)}try{const _e=await Re("/api/db/vip-members?limit=500",Te);_e!=null&&_e.success&&Array.isArray(_e.data)?bt(_e.data):bt([])}catch{bt([])}a(!0),o(!0);const We=async()=>{try{const _e=await Re("/api/admin/dashboard/recent-orders?limit=10",Te);if(_e!=null&&_e.success&&_e.recentOrders)f(_e.recentOrders);else throw new Error("no data")}catch(_e){if((_e==null?void 0:_e.name)!=="AbortError")try{const U=await Re("/api/admin/orders?page=1&pageSize=20&status=paid",Te),yt=((U==null?void 0:U.orders)??[]).filter($t=>["paid","completed","success"].includes($t.status||""));f(yt.slice(0,5))}catch{f([])}}finally{a(!1)}},tt=async()=>{try{const _e=await Re("/api/admin/dashboard/new-users",Te);if(_e!=null&&_e.success&&_e.newUsers)u(_e.newUsers);else throw new Error("no data")}catch(_e){if((_e==null?void 0:_e.name)!=="AbortError")try{const U=await Re("/api/db/users?page=1&pageSize=10",Te);u((U==null?void 0:U.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([We(),tt()])}async function Tt(Ne){const Te=Ne||H;$(!0);try{const We=await Re(`/api/admin/track/stats?period=${Te}`);We!=null&&We.success&&he({total:We.total??0,byModule:We.byModule??{}})}catch{he(null)}finally{$(!1)}}const ln={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},Dn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},Zt=Ne=>Ne?Ne.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",Dt=Ne=>{if(!Ne)return"";const Te=Ne.trim().toLowerCase();if(!Te)return"";const We=Ue.find(vt=>{const ft=String(vt.id||"").toLowerCase();return ft===Te||ft.includes(Te)||Te.includes(ft)});if(We)return We.name||We.nickname||"";const tt=Ue.find(vt=>{const ft=String(vt.token||"").toLowerCase();return ft&&(ft===Te||ft.includes(Te)||Te.includes(ft))});return tt&&(tt.name||tt.nickname)||""},mn=Ne=>{if(!Ne)return"未命名点击";const Te=Ne.trim(),We=Te.toLowerCase();if(/^超级个体[_::]/.test(Te)){const vt=Te.replace(/^超级个体[_::]/,"").trim(),ft=Dt(vt)||Dt(Zt(vt));return ft?`超级个体:${ft}`:`超级个体:${Zt(vt)||vt||"未知"}`}if(/^链接头像[_-]/.test(Te)){const vt=Te.replace(/^链接头像[_-]/,"").trim(),ft=Dt(vt)||Dt(Zt(vt));if(ft)return`头像:${ft}`;const _e=Zt(vt);return _e?`头像:${_e}`:"头像点击"}if(/^member[_-]?detail$/i.test(We)||We.includes("member detail"))return"成员详情";if(/^giftpay$/i.test(We)||We.includes("gift pay"))return"代付入口";if(/^part[-_]/i.test(We))return`章节:${Zt(Te)}`;if(We.includes("soulvip")||We.includes("super")){const vt=Te.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),ft=Dt(vt)||Dt(Zt(vt));return ft?`超级个体:${ft}`:`超级个体:${Zt(vt)}`}if(We.includes("qgdtw")||We.includes("token")||We.includes("0000"))return`对象:${Zt(Te)}`;const tt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return tt[Te]?tt[Te]:/^[a-z0-9_-]+$/i.test(Te)&&Zt(Te)||Te},Sn=Ne=>{const Te=ln[Ne.module]||ln[Ne.page]||Ne.module||Ne.page||"其他",We=Dn[Ne.action]||Ne.action||"点击",tt=mn(Ne.target);return`${Te} · ${We} · ${tt}`};async function _n(){ee(!0);try{const Ne=await Re("/api/admin/super-individual/stats");Ne!=null&&Ne.success&&Array.isArray(Ne.data)&&V(Ne.data)}catch{}finally{ee(!1)}}g.useEffect(()=>{const Ne=new AbortController;return dt(Ne.signal),Tt(),_n(),()=>{Ne.abort()}},[]);const Xn=m,Ot=Ne=>{const Te=Ne.productType||"",We=Ne.description||"";if(Te==="balance_recharge")return{title:`余额充值 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"余额充值"};if(Te==="gift_pay")return{title:`代付 ¥${typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2)}`,subtitle:"好友代付"};if(Te==="gift_pay_batch"){const tt=typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2);return{title:We||`代付分享 ¥${tt}`,subtitle:"代付分享"}}if(Te==="section"&&We.includes("代付领取"))return{title:We.replace("代付领取 - ",""),subtitle:"代付领取"};if(We){if(Te==="section"&&We.includes("章节")){if(We.includes("-")){const tt=We.split("-");if(tt.length>=3)return{title:`第${tt[1]}章 第${tt[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:We,subtitle:"章节购买"}}return Te==="fullbook"||We.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Te==="vip"||We.includes("VIP")?{title:"超级个体开通费用",subtitle:"超级个体"}:Te==="match"||We.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:We,subtitle:Te==="section"?"单章":Te==="fullbook"?"全书":"其他"}}return Te==="section"?{title:`章节 ${Ne.productId||""}`,subtitle:"单章购买"}:Te==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:Te==="vip"?{title:"超级个体开通费用",subtitle:"超级个体"}:Te==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:Te||"其他"}},xn=[{title:"总用户数",value:e?null:Xn,sub:null,icon:Vn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,sub:O>0?`含代付 ¥${O.toFixed(2)}`:null,icon:Cf,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:b,sub:null,icon:ou,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,sub:null,icon:or,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:se?se.ckbTotal??0:null,sub:(se==null?void 0:se.withContact)!=null?`含联系方式 ${se.withContact} 人`:null,icon:Uc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:Q?null:((te==null?void 0:te.totalMatches)??0)+((we==null?void 0:we.totalClicks)??0),sub:Q?null:`找伙伴 ${(te==null?void 0:te.totalMatches)??0} / 推广 ${(we==null?void 0:we.totalClicks)??0}`,icon:Gd,color:"text-emerald-400",bg:"bg-emerald-500/20",link:"/find-partner"}];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:()=>dt(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid gap-6 mb-8 grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6",children:xn.map((Ne,Te)=>s.jsxs($e,{className:"min-w-0 bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>Ne.link&&t(Ne.link),children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(ot,{className:"text-sm font-medium text-gray-400",children:Ne.title}),s.jsx("div",{className:`p-2 rounded-lg ${Ne.bg}`,children:s.jsx(Ne.icon,{className:`w-4 h-4 ${Ne.color}`})})]}),s.jsx(ze,{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:Ne.value!=null?Ne.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(He,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),Ne.sub&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:Ne.sub})]}),s.jsx(wi,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},Te))}),s.jsxs("div",{className:"flex gap-2 mb-6 mt-2",children:[s.jsx("button",{type:"button",onClick:()=>I("overview"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="overview"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"数据概览"}),s.jsx("button",{type:"button",onClick:()=>I("tags"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="tags"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"用户标签点击统计"}),s.jsx("button",{type:"button",onClick:()=>I("super"),className:`px-5 py-2 rounded-lg text-sm font-medium transition-colors ${me==="super"?"bg-[#38bdac] text-white":"bg-[#0f2137] text-gray-400 hover:text-white hover:bg-gray-700/50 border border-gray-700/50"}`,children:"超级个体统计"})]}),me==="overview"&&s.jsxs("div",{className:"space-y-8",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsx(ot,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>dt(),disabled:Q,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(He,{className:`w-3.5 h-3.5 ${Q?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(ze,{children:[Q&&!te&&!we?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(He,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-4",children:[s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴总匹配"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(te==null?void 0:te.totalMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴今日"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(te==null?void 0:te.todayMatches)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"找伙伴用户数"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(te==null?void 0:te.uniqueUsers)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalClicks)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalBindings)??0})]}),s.jsxs("div",{className:"rounded-lg bg-[#0a1628] border border-gray-700/30 p-4",children:[s.jsx("p",{className:"text-xs text-gray-400",children:"推广总转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(we==null?void 0:we.totalConversions)??0})]})]}),(we==null?void 0:we.conversionRate)&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["推广转化率:",we.conversionRate]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsx(ot,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>dt(),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(He,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(He,{className:"w-3.5 h-3.5"}),"刷新"]})]}),s.jsx(ze,{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(He,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,ae?10:4).map(Ne=>{var ft;const Te=Ne.referrerId?c.find(_e=>_e.id===Ne.referrerId):void 0,We=Ne.referralCode||(Te==null?void 0:Te.referralCode)||(Te==null?void 0:Te.nickname)||(Ne.referrerId?String(Ne.referrerId).slice(0,8):""),tt=Ot(Ne),vt=Ne.userNickname||((ft=c.find(_e=>_e.id===Ne.userId))==null?void 0:ft.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:[Ne.userAvatar?s.jsx("img",{src:Ne.userAvatar,alt:vt,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:_e=>{_e.currentTarget.style.display="none";const U=_e.currentTarget.nextElementSibling;U&&U.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] shrink-0 mt-0.5 ${Ne.userAvatar?"hidden":""}`,children:vt.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:()=>{Ne.userId&&(W(Ne.userId),B(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:vt}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:tt.title,children:tt.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[tt.subtitle&&tt.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:tt.subtitle}),s.jsx("span",{children:new Date(Ne.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),We&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",We]})]})]}),s.jsxs("div",{className:"text-right ml-4 shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(Ne.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Ne.paymentMethod||"微信"})]})]},Ne.id)}),h.length>4&&!ae&&s.jsx("button",{type:"button",onClick:()=>_(!0),className:"w-full py-2 text-sm text-[#38bdac] hover:text-[#2da396] border border-dashed border-gray-600 rounded-lg hover:border-[#38bdac]/50 transition-colors",children:"展开更多"}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(ou,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{children:s.jsx(ot,{className:"text-white",children:"新注册用户"})}),s.jsx(ze,{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(He,{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(Ne=>{var Te;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:((Te=Ne.nickname)==null?void 0:Te.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{W(Ne.id),B(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:Ne.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:Ne.phone||"未绑定手机"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:Ne.createdAt?new Date(Ne.createdAt).toLocaleDateString():"-"})]},Ne.id)}),c.length===0&&!i&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]})]}),me==="tags"&&s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Gd,{className:"w-5 h-5 text-[#38bdac]"}),"分类标签点击统计"]}),s.jsx("div",{className:"flex items-center gap-2",children:["today","week","month","all"].map(Ne=>s.jsx("button",{type:"button",onClick:()=>{K(Ne),Tt(Ne)},className:`px-3 py-1 text-xs rounded-full transition-colors ${H===Ne?"bg-[#38bdac] text-white":"bg-gray-700/50 text-gray-400 hover:bg-gray-700"}`,children:{today:"今日",week:"本周",month:"本月",all:"全部"}[Ne]},Ne))})]}),s.jsx(ze,{children:ue&&!fe?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(He,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):fe&&Object.keys(fe.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:fe.total})," 次"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Object.entries(fe.byModule).sort((Ne,Te)=>Te[1].reduce((We,tt)=>We+tt.count,0)-Ne[1].reduce((We,tt)=>We+tt.count,0)).slice(0,5).map(([Ne,Te])=>{const We=Te.reduce((tt,vt)=>tt+vt.count,0);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:ln[Ne]||Ne}),s.jsxs("span",{className:"text-xs text-gray-500",children:[We," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Te.sort((tt,vt)=>vt.count-tt.count).slice(0,8).map((tt,vt)=>{const ft=Sn(tt);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:ft,children:ft}),s.jsxs("div",{className:"flex items-center gap-2 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:`${We>0?tt.count/We*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:tt.count})]})]},vt)})})]},Ne)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Gd,{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:"小程序端接入埋点后,数据将在此实时展示"})]})})]}),me==="super"&&s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Gd,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:_n,disabled:xe,children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1 ${xe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(ze,{children:xe&&Z.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(He,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):Z.length>0?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:"text-xs text-gray-400 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"排名"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"超级个体"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"总点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"独立访客"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",children:"人均点击"}),s.jsx("th",{className:"text-center py-2 px-3 font-normal",title:"该用户绑定 @人物 后,指向其 person 的留资独立人数",children:"获客(去重)"}),s.jsx("th",{className:"text-left py-2 px-3 font-normal",children:"手机号"})]})}),s.jsx("tbody",{children:Z.map((Ne,Te)=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[s.jsx("td",{className:"py-2 px-3 text-gray-500 text-xs",children:Te+1}),s.jsx("td",{className:"py-2 px-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[Ne.avatar?s.jsx("img",{src:Ne.avatar,alt:"",className:"w-7 h-7 rounded-full object-cover"}):s.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-700 flex items-center justify-center text-xs text-gray-400",children:"?"}),s.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left text-sm truncate max-w-[160px]",onClick:()=>t(`/users?search=${encodeURIComponent(Ne.nickname||Ne.userId)}`),title:"点击跳转用户管理",children:Ne.nickname||Ne.userId})]})}),s.jsx("td",{className:"py-2 px-3 text-center text-white font-bold",children:Ne.clicks}),s.jsx("td",{className:"py-2 px-3 text-center text-[#38bdac]",children:Ne.uniqueClicks}),s.jsx("td",{className:"py-2 px-3 text-center text-gray-400",children:Ne.uniqueClicks>0?(Ne.clicks/Ne.uniqueClicks).toFixed(1):"-"}),s.jsx("td",{className:"py-2 px-3 text-center text-green-400 text-xs font-medium",children:typeof Ne.leadCount=="number"?Ne.leadCount:0}),s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:Ne.phone||"-"})]},Ne.userId))})]})}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Gd,{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(cy,{open:P,onClose:()=>{B(!1),W(null)},userId:R,onUserUpdated:()=>dt()})]})}const ls=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:_t("w-full caption-bottom text-sm",t),...e})}));ls.displayName="Table";const cs=g.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:_t("[&_tr]:border-b",t),...e}));cs.displayName="TableHeader";const ds=g.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:_t("[&_tr:last-child]:border-0",t),...e}));ds.displayName="TableBody";const ht=g.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:_t("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));ht.displayName="TableRow";const ke=g.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:_t("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));ke.displayName="TableHead";const je=g.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:_t("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableCell";function Ra(t,e){const[n,r]=g.useState(t);return g.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function us({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 x8(){const[t,e]=g.useState([]),[n,r]=g.useState([]),[a,i]=g.useState(0),[o,c]=g.useState(0),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=Ra(N,300),[k,M]=g.useState("all"),[E,L]=g.useState(!0),[R,W]=g.useState(null),[P,B]=g.useState(null),[O,X]=g.useState(""),[ae,_]=g.useState(!1);async function se(){L(!0),W(null);try{const ee=k==="all"?"":k==="completed"?"completed":k,H=new URLSearchParams({page:String(f),pageSize:String(x),...ee&&{status:ee},...v&&{search:v}}),[K,fe]=await Promise.all([Re(`/api/admin/orders?${H}`),Re("/api/db/users?page=1&pageSize=500")]);K!=null&&K.success&&(e(K.orders||[]),i(K.total??0),c(K.totalRevenue??0),h(K.todayRevenue??0)),fe!=null&&fe.success&&fe.users&&r(fe.users)}catch(ee){console.error("加载订单失败",ee),W("加载订单失败,请检查网络后重试")}finally{L(!1)}}g.useEffect(()=>{m(1)},[v,k]),g.useEffect(()=>{se()},[f,x,v,k]);const ce=ee=>{var H;return ee.userNickname||((H=n.find(K=>K.id===ee.userId))==null?void 0:H.nickname)||"匿名用户"},me=ee=>{var H;return((H=n.find(K=>K.id===ee))==null?void 0:H.phone)||"-"},I=ee=>{const H=ee.productType||ee.type||"",K=ee.description||"";if(H==="balance_recharge")return{name:`余额充值 ¥${Number(ee.amount||0).toFixed(2)}`,type:"余额充值"};if(K){if(H==="section"&&(K.includes("章节")||K.includes("代付领取"))){if(K.includes("代付领取"))return{name:K.replace("代付领取 - ",""),type:"代付领取"};if(K.includes("-")){const fe=K.split("-");if(fe.length>=3)return{name:`第${fe[1]}章 第${fe[2]}节`,type:"《一场Soul的创业实验》"}}return{name:K,type:"章节购买"}}return H==="fullbook"||K.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:H==="vip"||K.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:H==="match"||K.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:K,type:"其他"}}return H==="section"?{name:`章节 ${ee.productId||ee.sectionId||""}`,type:"单章"}:H==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:H==="vip"?{name:"超级个体开通费用",type:"超级个体"}:H==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:H||"其他"}},Z=Math.ceil(a/x)||1;async function V(){var ee;if(!(!(P!=null&&P.orderSn)&&!(P!=null&&P.id))){_(!0),W(null);try{const H=await Yt("/api/admin/orders/refund",{orderSn:P.orderSn||P.id,reason:O||void 0});H!=null&&H.success?(B(null),X(""),se()):W((H==null?void 0:H.error)||"退款失败")}catch(H){const K=H;W(((ee=K==null?void 0:K.data)==null?void 0:ee.error)||"退款失败,请检查网络后重试")}finally{_(!1)}}}function xe(){if(t.length===0){G.info("暂无数据可导出");return}const ee=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],H=t.map($=>{const Q=I($);return[$.orderSn||$.id||"",ce($),me($.userId),Q.name,Number($.amount||0).toFixed(2),$.paymentMethod==="wechat"?"微信支付":$.paymentMethod==="balance"?"余额支付":$.paymentMethod==="alipay"?"支付宝":$.paymentMethod||"微信支付",$.status==="refunded"?"已退款":$.status==="paid"||$.status==="completed"?"已完成":$.status==="pending"||$.status==="created"?"待支付":"已失败",$.status==="refunded"&&$.refundReason?$.refundReason:"-",$.referrerEarnings?Number($.referrerEarnings).toFixed(2):"-",$.createdAt?new Date($.createdAt).toLocaleString("zh-CN"):""].join(",")}),K="\uFEFF"+[ee.join(","),...H].join(` +`),fe=new Blob([K],{type:"text/csv;charset=utf-8"}),he=URL.createObjectURL(fe),ue=document.createElement("a");ue.href=he,ue.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,ue.click(),URL.revokeObjectURL(he)}return s.jsxs("div",{className:"p-8 w-full",children:[R&&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:R}),s.jsx("button",{type:"button",onClick:()=>W(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(J,{variant:"outline",onClick:se,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{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(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:ee=>w(ee.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nk,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:ee=>M(ee.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(J,{variant:"outline",onClick:xe,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(JT,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:E?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"订单号"}),s.jsx(ke,{className:"text-gray-400",children:"用户"}),s.jsx(ke,{className:"text-gray-400",children:"商品"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"支付方式"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"退款原因"}),s.jsx(ke,{className:"text-gray-400",children:"分销佣金"}),s.jsx(ke,{className:"text-gray-400",children:"下单时间"}),s.jsx(ke,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[t.map(ee=>{const H=I(ee);return s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(je,{className:"font-mono text-xs text-gray-400",children:[(ee.orderSn||ee.id||"").slice(0,12),"..."]}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[ce(ee),ee.paymentMethod==="gift_pay"&&s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),ee.payerUserId&&ee.paymentMethod!=="gift_pay"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"代付"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:me(ee.userId)}),ee.payerUserId&&ee.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[ee.paymentMethod==="gift_pay"?"赠送人:":"代付人:",ee.payerNickname]})]})}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[H.name,(ee.productType||ee.type)==="vip"&&s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"超级个体"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.type})]})}),s.jsxs(je,{className:"text-[#38bdac] font-bold",children:["¥",Number(ee.amount||0).toFixed(2)]}),s.jsx(je,{className:"text-gray-300",children:ee.paymentMethod==="wechat"?"微信支付":ee.paymentMethod==="balance"?"余额支付":ee.paymentMethod==="alipay"?"支付宝":ee.paymentMethod||"微信支付"}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ee.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):ee.status==="paid"||ee.status==="completed"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):ee.status==="pending"||ee.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(ee.status==="paid"||ee.status==="completed")&&(ee.webhookPushStatus==="sent"?s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 hover:bg-orange-500/20 border-0",children:"待补推"}))]})}),s.jsx(je,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:ee.refundReason,children:ee.status==="refunded"&&ee.refundReason?ee.refundReason:"-"}),s.jsx(je,{className:"text-[#FFD700]",children:ee.referrerEarnings?`¥${Number(ee.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(je,{className:"text-gray-400 text-sm",children:new Date(ee.createdAt).toLocaleString("zh-CN")}),s.jsx(je,{children:(ee.status==="paid"||ee.status==="completed")&&ee.paymentMethod!=="balance"&&s.jsxs(J,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{B(ee),X("")},children:[s.jsx(ok,{className:"w-3 h-3 mr-1"}),"退款"]})})]},ee.id)}),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(us,{page:f,totalPages:Z,total:a,pageSize:x,onPageChange:m,onPageSizeChange:ee=>{b(ee),m(1)}})]})})}),s.jsx(It,{open:!!P,onOpenChange:ee=>!ee&&B(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Rt,{children:s.jsx(Lt,{className:"text-white",children:"订单退款"})}),P&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",P.orderSn||P.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(P.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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:ee=>X(ee.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>B(null),disabled:ae,children:"取消"}),s.jsx(J,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:V,disabled:ae,children:ae?"退款中...":"确认退款"})]})]})})]})}const Uo=g.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:_t("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}));Uo.displayName="Textarea";const iN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],T2={INTJ:{title:"战略家",group:"NT",mood:"sharp"},INTP:{title:"逻辑学家",group:"NT",mood:"calm"},ENTJ:{title:"指挥官",group:"NT",mood:"sharp"},ENTP:{title:"辩论家",group:"NT",mood:"playful"},INFJ:{title:"提倡者",group:"NF",mood:"warm"},INFP:{title:"调停者",group:"NF",mood:"warm"},ENFJ:{title:"主人公",group:"NF",mood:"warm"},ENFP:{title:"竞选者",group:"NF",mood:"playful"},ISTJ:{title:"物流师",group:"SJ",mood:"calm"},ISFJ:{title:"守卫者",group:"SJ",mood:"warm"},ESTJ:{title:"总经理",group:"SJ",mood:"sharp"},ESFJ:{title:"执政官",group:"SJ",mood:"warm"},ISTP:{title:"鉴赏家",group:"SP",mood:"sharp"},ISFP:{title:"探险家",group:"SP",mood:"playful"},ESTP:{title:"企业家",group:"SP",mood:"playful"},ESFP:{title:"表演者",group:"SP",mood:"playful"}};function g8(t){switch(t){case"NT":return{bg:"#0d1424",body:"#c89a2c",accent:"#ffd66b",hair:"#6d540f",line:"#111827"};case"NF":return{bg:"#0a1721",body:"#2e9f7c",accent:"#84e9c9",hair:"#2d6a4f",line:"#11212a"};case"SJ":return{bg:"#101828",body:"#4f8cb8",accent:"#9bd4ff",hair:"#2e4a66",line:"#111f2d"};case"SP":return{bg:"#161225",body:"#8b6bc0",accent:"#ccb3ff",hair:"#574183",line:"#211832"};default:return{bg:"#0e1422",body:"#38bdac",accent:"#7ee7db",hair:"#1f6f66",line:"#10202d"}}}function y8(t){switch(t){case"sharp":return{eye:"M222 222 L242 220 M270 220 L290 222",brow:"M218 210 L244 202 M268 202 L294 210",mouth:"M234 256 Q256 246 278 256",tilt:-5};case"warm":return{eye:"M222 224 Q232 230 242 224 M270 224 Q280 230 290 224",brow:"M220 210 Q232 206 244 210 M268 210 Q280 206 292 210",mouth:"M232 254 Q256 272 280 254",tilt:2};case"playful":return{eye:"M222 224 Q232 236 242 224 M270 224 Q280 236 290 224",brow:"M220 210 Q234 200 246 208 M266 208 Q278 200 292 210",mouth:"M232 256 Q256 266 280 250",tilt:8};default:return{eye:"M222 224 Q232 220 242 224 M270 224 Q280 220 290 224",brow:"M220 210 Q232 208 244 210 M268 210 Q280 208 292 210",mouth:"M236 256 Q256 260 276 256",tilt:0}}}function b8(t){switch(t){case"sharp":return"M168 370 L206 300 L256 332 L306 300 L344 370 L306 392 L256 374 L206 392 Z";case"warm":return"M166 368 Q188 318 226 314 L256 340 L286 314 Q324 318 346 368 L314 392 Q286 404 256 396 Q226 404 198 392 Z";case"playful":return"M164 370 L198 304 L252 332 L318 300 L350 374 L316 394 L258 378 L196 396 Z";default:return"M166 370 L202 306 L256 336 L310 306 L346 370 L310 392 L256 380 L202 392 Z"}}function oN(t){const e=T2[t],n=g8(e.group),r=y8(e.mood),a=b8(e.mood),i=` @@ -685,19 +685,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do -`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function v8(){const[t,e]=g.useState({}),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useCallback(async()=>{r(!0);try{const x=await Re("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{G.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);g.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await xt("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){G.error((x==null?void 0:x.error)||"保存失败");return}G.success("已保存,后台与小程序默认头像同步生效"),u()}catch{G.error("保存失败")}finally{i(!1)}},f=x=>{const b=oN(x);e(N=>({...N,[x]:b})),G.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};iN.forEach(b=>{x[b]=oN(b)}),e(x),G.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(He,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(it,{className:"pb-2",children:[s.jsxs(ot,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(CA,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像库"]}),s.jsx(qt,{className:"text-gray-400 text-sm leading-relaxed",children:"采用人物化风格,按 MBTI 性格自动生成。头像内不显示中英文,仅显示人物形象,颜色与站点主题融合。"})]}),s.jsxs($e,{className:"flex flex-wrap gap-2",children:[s.jsxs(J,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(JA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(J,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(He,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(J,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(kn,{className:"w-3.5 h-3.5 mr-1"}),a?"保存中…":"保存映射"]})]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:iN.map(x=>{const b=t[x]??"",N=T2[x];return s.jsxs("div",{className:"rounded-xl border border-gray-700/60 bg-[#0a1628] p-3 flex flex-col gap-2 hover:border-[#38bdac]/35 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 font-mono text-xs",children:x}),s.jsx("span",{className:"text-xs text-gray-400 truncate",title:N.title,children:N.title})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full shrink-0 overflow-hidden flex items-center justify-center bg-[#081322] ring-2 ring-[#38bdac]/40 ring-offset-2 ring-offset-[#0a1628]",children:b?s.jsx("img",{src:b,alt:x,className:"w-full h-full object-cover scale-110"}):s.jsx("span",{className:"text-gray-600 text-[10px]",children:"未配"})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"https://... 或 data:image/...",value:b,onChange:w=>e(v=>({...v,[x]:w.target.value}))})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const lN=[{value:"after_login",label:"注册/登录成功",group:"用户状态"},{value:"bind_phone",label:"绑定手机号",group:"用户状态"},{value:"update_avatar",label:"完善头像(非默认图,与昵称分开配置)",group:"用户状态"},{value:"update_nickname",label:"修改昵称(非默认微信昵称,与头像分开)",group:"用户状态"},{value:"fill_profile",label:"完善资料(MBTI/行业/职位,不含头像昵称)",group:"用户状态"},{value:"view_chapter",label:"浏览章节",group:"阅读行为"},{value:"browse_5_chapters",label:"累计浏览5个章节",group:"阅读行为"},{value:"purchase_section",label:"购买单章",group:"付费行为"},{value:"purchase_fullbook",label:"购买全书/VIP",group:"付费行为"},{value:"after_pay",label:"任意付款成功",group:"付费行为"},{value:"after_match",label:"完成派对匹配",group:"社交行为"},{value:"click_super_individual",label:"点击超级个体头像",group:"社交行为"},{value:"lead_submit",label:"提交留资/链接",group:"社交行为"},{value:"referral_bind",label:"被推荐人绑定",group:"分销行为"},{value:"share_action",label:"分享给好友/朋友圈",group:"分销行为"},{value:"withdraw_request",label:"申请提现",group:"分销行为"},{value:"add_wechat",label:"添加微信联系方式",group:"用户状态"}],cN=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}];function M2(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string")try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>typeof n=="string")}catch{try{const e=typeof atob=="function"?atob(t):"",n=JSON.parse(e);if(Array.isArray(n))return n.filter(r=>typeof r=="string")}catch{}}return[]}function N8(t){return{...t,triggerConditions:M2(t.triggerConditions)}}const w8=[{level:"S",range:"≥85",label:"高价值"},{level:"A",range:"70–84",label:"优质"},{level:"B",range:"50–69",label:"中等"},{level:"C",range:"30–49",label:"潜力"},{level:"D",range:"<30",label:"待激活"}],Lc=[{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 dN(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function j8({userId:t,userAvatar:e,nickname:n,name:r,onOpenDetail:a}){const[i,o]=g.useState(!1),c=n||r||"-",u=(c==="-"?"?":c).charAt(0),h=!!(e!=null&&e.trim())&&!i;return s.jsxs("div",{className:"flex items-center gap-2 min-w-0 max-w-[220px]",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/15 flex items-center justify-center text-xs font-medium text-[#38bdac] flex-shrink-0 overflow-hidden border border-gray-600/50","aria-hidden":!0,children:h?s.jsx("img",{src:aa(e),alt:"",className:"w-full h-full object-cover",onError:()=>o(!0)}):s.jsx("span",{children:u})}),s.jsx("button",{type:"button",className:`text-left truncate min-w-0 ${t?"hover:text-[#38bdac] cursor-pointer":"cursor-default text-gray-300"}`,disabled:!t,title:t?"查看用户详情":void 0,onClick:()=>{t&&a(t)},children:c})]})}function k8(t){const e=(t||"").trim();if(!e)return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function S8(){var Ui,Wi,dl,ul,hl,T,F;const[t,e]=q0(),n=t.get("pool"),r=t.get("tab")||"users",a=["users","journey","rules","vip-roles","leads"].includes(r)?r:"users",i=(t.get("leadAction")||"").trim(),[o,c]=g.useState([]),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=Ra(N,300),k=n==="vip"?"vip":n==="complete"?"complete":"all",[M,E]=g.useState(k),[L,R]=g.useState(!0),[W,P]=g.useState(!1),[B,O]=g.useState(null),[Y,ae]=g.useState(!1),[_,se]=g.useState(!1),[ce,me]=g.useState("desc");g.useEffect(()=>{n==="vip"?E("vip"):n==="complete"?E("complete"):n==="all"&&E("all")},[n]);const[I,X]=g.useState(!1),[V,xe]=g.useState(null),[ee,H]=g.useState(!1),[K,fe]=g.useState(!1),[he,ue]=g.useState({referrals:[],stats:{}}),[$,Q]=g.useState(!1),[z,te]=g.useState(null),[ie,we]=g.useState(!1),[Be,Ue]=g.useState(null),[yt,vn]=g.useState(!1),[dt,Et]=g.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[on,Dn]=g.useState([]),[ln,Ut]=g.useState(!1),[mn,Sn]=g.useState(!1),[_n,Xn]=g.useState(null),[Lt,xn]=g.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[Ne,Me]=g.useState([]),[We,tt]=g.useState(!1),[Ot,wt]=g.useState(null),[ze,U]=g.useState(null),[qe,gt]=g.useState({}),[_t,pt]=g.useState(!1),[lt,Tt]=g.useState(null),[Wt,Nn]=g.useState([]),[ks,Ss]=g.useState(!1),[Li,da]=g.useState(null),[Fa,Ba]=g.useState(""),[Nr,wr]=g.useState([]),[jr,Fr]=g.useState(!1),[_s,qs]=g.useState({}),[dr,Gs]=g.useState([]),[ua,de]=g.useState(0),[ve,At]=g.useState(1),[Qt]=g.useState(10),[Zt,Zn]=g.useState(!1),[kr,Br]=g.useState(null),[bt,$n]=g.useState(""),Vr=Ra(bt,300),[ha,cn]=g.useState(""),[Hr,Va]=g.useState(""),[ur,Cs]=g.useState(""),[fa,Ha]=g.useState(!1),[$s,zn]=g.useState({}),[pa,es]=g.useState(null),[Ur,Qo]=g.useState(null),[ts,zs]=g.useState([]),[Js,ma]=g.useState(!1),xa=g.useRef(null),[Yo,nc]=g.useState(!1),[Ua,Oi]=g.useState(!1),[Di,Wa]=g.useState("存客宝返回 data"),[ga,Xo]=g.useState(""),ft=g.useCallback(async(S,D)=>{Zn(!0),Br(null);try{const Z=new URLSearchParams({mode:"contact",page:String(ve),pageSize:String(Qt)}),ye=S??Vr;ye&&Z.set("search",ye);const Ce=D??ha;Ce&&Z.set("source",Ce),Hr&&Z.set("action",Hr),ur&&Z.set("pushStatus",ur);const De=await Re(`/api/db/ckb-leads?${Z}`);if(De!=null&&De.success)Gs(De.records||[]),de(De.total??0),De.stats&&zn(De.stats);else{const mt=(De==null?void 0:De.error)||"加载获客列表失败";Br(mt),G.error(mt),Gs([]),de(0)}}catch(Z){const ye=Z instanceof Error?Z.message:"网络错误";Br(ye),G.error("加载获客列表失败: "+ye),Gs([]),de(0)}finally{Zn(!1)}},[ve,Qt,Vr,ha,Hr,ur]);g.useEffect(()=>{zs([])},[Vr,ha,Hr,ur]),g.useEffect(()=>{a==="leads"&&Va(i)},[a,i]);function Zo(S,D){return{...S,...D.pushStatus!==void 0?{pushStatus:D.pushStatus}:{},...typeof D.retryCount=="number"?{retryCount:D.retryCount}:{},...typeof D.ckbCode=="number"?{ckbCode:D.ckbCode}:{},...D.ckbMessage!==void 0?{ckbMessage:D.ckbMessage}:{},...D.ckbData!==void 0?{ckbData:D.ckbData}:{},...D.ckbError!==void 0?{ckbError:D.ckbError}:{},...D.lastPushAt!==void 0?{lastPushAt:D.lastPushAt??void 0}:{},...D.nextRetryAt!==void 0?{nextRetryAt:D.nextRetryAt??void 0}:{}}}async function sc(S){if(S){es(S);try{const D=await xt("/api/db/ckb-leads/retry",{id:S});D!=null&&D.success?(G.success(D.pushed?"重推成功":"已发起重推,请刷新查看状态"),D.record&&Gs(Z=>Z.map(ye=>ye.id===S?Zo(ye,D.record):ye))):G.error((D==null?void 0:D.error)||"重推失败")}catch(D){G.error(D instanceof Error?D.message:"重推请求失败")}finally{es(null)}}}async function _i(S){if(S&&confirm("确定删除该条获客记录?删除后不可恢复。")){Qo(S);try{const D=await xt("/api/db/ckb-leads/delete",{id:S});D!=null&&D.success?G.success("已删除"):G.error((D==null?void 0:D.error)||"删除失败")}catch(D){G.error(D instanceof Error?D.message:"删除请求失败")}finally{Qo(null),ft()}}}async function el(){const S=gs.filter(ye=>ye.pushStatus==="failed");if(S.length===0){G.info("当前页无失败记录");return}nc(!0);let D=0;for(const ye of S)try{const Ce=await xt("/api/db/ckb-leads/retry",{id:ye.id});if(Ce!=null&&Ce.success&&Ce.pushed&&D++,Ce!=null&&Ce.success&&Ce.record){const De=Ce.record;Gs(mt=>mt.map(Le=>Le.id===ye.id?Zo(Le,De):Le))}}catch{}nc(!1);const Z=S.length;G.success(`批量重推完成:成功 ${D} / ${Z}`)}function tl(){const S=gs.filter(Le=>Le.pushStatus==="failed");if(S.length===0){G.info("当前筛选下无失败记录可导出");return}const D=Le=>`"${String(Le??"").replace(/"/g,'""')}"`,ye=[["ID","昵称","手机号","微信号","对应@人","计划Key","来源","推送状态","重试次数","失败原因","下次重试时间","创建时间"].join(",")];for(const Le of S)ye.push([D(Le.id),D(Le.userNickname||Le.name||""),D(Le.phone||""),D(Le.wechatId||""),D(Le.personName||""),D(Le.planApiKey||""),D(Le.source||""),D(Le.pushStatus||""),D(typeof Le.retryCount=="number"?Le.retryCount:""),D(Le.ckbError||""),D(Le.nextRetryAt?new Date(Le.nextRetryAt).toLocaleString():""),D(Le.createdAt?new Date(Le.createdAt).toLocaleString():"")].join(","));const Ce=new Blob(["\uFEFF"+ye.join(` -`)],{type:"text/csv;charset=utf-8;"}),De=URL.createObjectURL(Ce),mt=document.createElement("a");mt.href=De,mt.download=`获客失败清单-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,document.body.appendChild(mt),mt.click(),document.body.removeChild(mt),URL.revokeObjectURL(De),G.success(`已导出失败清单(${S.length} 条)`)}const nl=g.useCallback(async()=>{try{const S=await Re("/api/admin/mbti-avatars"),D=S!=null&&S.avatars&&typeof S.avatars=="object"?S.avatars:{};qs(D)}catch{qs({})}},[]);g.useEffect(()=>{t.get("tab")==="leads"&&ft()},[t.get("tab"),ve,ft]),g.useEffect(()=>{if(a!=="leads")return;const S=window.setInterval(()=>{ft()},3e4);return()=>window.clearInterval(S)},[a,ft]),g.useEffect(()=>{nl()},[nl]);const Sr=g.useCallback((S,D)=>{const Z=(S||"").trim();if(Z)return Z;const ye=(D||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(ye)?(_s[ye]||"").trim():""},[_s]),Ka=g.useCallback(S=>{const D=!!S.hasFullBook,Z=Number(S.purchasedSectionCount||0);return D?{tone:"vip",main:"已购全书",sub:Z>0?`另购单章 ${Z} 章`:"购买项:VIP / 全书"}:Z>0?{tone:"paid",main:`已购 ${Z} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Qs,Fs]=g.useState(null),Es=g.useCallback(async()=>{try{const S=await Re("/api/admin/users/online-stats");S!=null&&S.success&&typeof S.onlineCount=="number"?Fs(S.onlineCount):Fs(0)}catch{Fs(null)}},[]);g.useEffect(()=>{Es();const S=setInterval(Es,1e4);return()=>clearInterval(S)},[Es]);async function ps(S=!1){var D;R(!0),S&&P(!0),O(null);try{if(Y){const Z=new URLSearchParams({search:v,limit:String(x*5)}),ye=await Re(`/api/db/users/rfm?${Z}`);if(ye!=null&&ye.success){let Ce=ye.users||[];ce==="asc"&&(Ce=[...Ce].reverse());const De=(f-1)*x;c(Ce.slice(De,De+x)),h(((D=ye.users)==null?void 0:D.length)??0),Ce.length===0&&(ae(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else ae(!1),O((ye==null?void 0:ye.error)||"RFM 加载失败,已切回普通模式")}else{const Z=new URLSearchParams({page:String(f),pageSize:String(x),search:v,...M==="vip"&&{vip:"true"},...M==="complete"&&{pool:"complete"}}),ye=await Re(`/api/db/users?${Z}`);ye!=null&&ye.success?(c(ye.users||[]),h(ye.total??0)):O((ye==null?void 0:ye.error)||"加载失败")}}catch(Z){console.error("Load users error:",Z),O("网络错误")}finally{R(!1),S&&P(!1)}}g.useEffect(()=>{m(1)},[v,M,Y]),g.useEffect(()=>{ps()},[f,x,v,M,Y,ce]);const qa=Math.ceil(u/x)||1,dn=()=>{Y?ce==="desc"?me("asc"):(ae(!1),me("desc")):(ae(!0),me("desc"))},sl=S=>({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"})[S||""]||"bg-gray-500/20 text-gray-400";async function Ga(S){var D;if(!dN("用户")){G.info("已取消删除");return}try{const Z=await bi(`/api/db/users?id=${encodeURIComponent(S)}`);Z!=null&&Z.success?(G.success("已删除"),ps()):G.error("删除失败: "+((Z==null?void 0:Z.error)||"未知错误"))}catch(Z){const ye=Z,Ce=((D=ye==null?void 0:ye.data)==null?void 0:D.error)||(ye==null?void 0:ye.message)||"网络错误";G.error("删除失败: "+Ce)}}const Wr=S=>{xe(S),Et({phone:S.phone||"",nickname:S.nickname||"",password:"",isAdmin:!!(S.isAdmin??!1),hasFullBook:!!(S.hasFullBook??!1)}),X(!0)},rc=()=>{xe(null),Et({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),X(!0)};async function ns(){if(!dt.phone||!dt.nickname){G.error("请填写手机号和昵称");return}H(!0);try{if(V){const S=await Yt("/api/db/users",{id:V.id,phone:dt.phone||void 0,nickname:dt.nickname,isAdmin:dt.isAdmin,hasFullBook:dt.hasFullBook,...dt.password&&{password:dt.password}});if(!(S!=null&&S.success)){G.error("更新失败: "+((S==null?void 0:S.error)||""));return}}else{const S=await xt("/api/db/users",{phone:dt.phone,nickname:dt.nickname,password:dt.password,isAdmin:dt.isAdmin});if(!(S!=null&&S.success)){G.error("创建失败: "+((S==null?void 0:S.error)||""));return}}X(!1),ps()}catch{G.error("保存失败")}finally{H(!1)}}async function Ja(S){te(S),fe(!0),Q(!0);try{const D=await Re(`/api/db/users/referrals?userId=${encodeURIComponent(S.id)}`);D!=null&&D.success?ue({referrals:D.referrals||[],stats:D.stats||{}}):ue({referrals:[],stats:{}})}catch{ue({referrals:[],stats:{}})}finally{Q(!1)}}const Bs=g.useCallback(async()=>{Ut(!0);try{const S=await Re("/api/db/user-rules");S!=null&&S.success&&Dn((S.rules||[]).map(D=>N8(D)))}catch{}finally{Ut(!1)}},[]);async function xd(){if(!Lt.title){G.error("请填写规则标题");return}H(!0);try{if(_n){const S=await Yt("/api/db/user-rules",{id:_n.id,...Lt});if(!(S!=null&&S.success)){G.error("更新失败: "+((S==null?void 0:S.error)||""));return}}else{const S=await xt("/api/db/user-rules",Lt);if(!(S!=null&&S.success)){G.error("创建失败: "+((S==null?void 0:S.error)||""));return}}Sn(!1),Bs()}catch{G.error("保存失败")}finally{H(!1)}}async function Qa(S){if(!dN("规则")){G.info("已取消删除");return}try{const D=await bi(`/api/db/user-rules?id=${S}`);D!=null&&D.success&&Bs()}catch{}}async function Ya(S){try{await Yt("/api/db/user-rules",{id:S.id,enabled:!S.enabled}),Bs()}catch{}}const ms=g.useCallback(async()=>{tt(!0);try{const S=await Re("/api/db/vip-members?limit=500");if(S!=null&&S.success&&S.data){const D=[...S.data].map((Z,ye)=>({...Z,vipSort:typeof Z.vipSort=="number"?Z.vipSort:ye+1}));D.sort((Z,ye)=>(Z.vipSort??999999)-(ye.vipSort??999999)),Me(D)}else S&&S.error&&G.error(S.error)}catch{G.error("加载超级个体列表失败")}finally{tt(!1)}},[]),[$i,Xa]=g.useState(!1),[xs,Za]=g.useState(null),[Kr,ei]=g.useState(""),[hr,Ys]=g.useState(!1),zi=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],Cr=S=>{Za(S),ei(S.vipRole||""),Xa(!0)},ya=async S=>{const D=S.trim();if(xs){if(!D){G.error("请选择或输入标签");return}Ys(!0);try{const Z=await Yt("/api/db/users",{id:xs.id,vipRole:D});if(!(Z!=null&&Z.success)){G.error((Z==null?void 0:Z.error)||"更新超级个体标签失败");return}G.success("已更新超级个体标签"),Xa(!1),Za(null),await ms()}catch{G.error("更新超级个体标签失败")}finally{Ys(!1)}}},[qr,Gr]=g.useState(!1),[Xs,gn]=g.useState(null),[Er,Zs]=g.useState(""),[ba,rl]=g.useState(!1),Fi=S=>{gn(S),Zs(S.vipSort!=null?String(S.vipSort):""),Gr(!0)},Bi=async()=>{if(!Xs)return;const S=Number(Er);if(!Number.isFinite(S)){G.error("请输入有效的数字序号");return}rl(!0);try{const D=await Yt("/api/db/users",{id:Xs.id,vipSort:S});if(!(D!=null&&D.success)){G.error((D==null?void 0:D.error)||"更新排序序号失败");return}G.success("已更新排序序号"),Gr(!1),gn(null),await ms()}catch{G.error("更新排序序号失败")}finally{rl(!1)}},va=(S,D)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",D),wt(D)},Vi=(S,D)=>{S.preventDefault(),ze!==D&&U(D)},Hi=()=>{wt(null),U(null)},gd=async(S,D)=>{S.preventDefault();const Z=S.dataTransfer.getData("text/plain")||Ot;if(wt(null),U(null),!Z||Z===D)return;const ye=Ne.find(Le=>Le.id===Z),Ce=Ne.find(Le=>Le.id===D);if(!ye||!Ce)return;const De=ye.vipSort??Ne.findIndex(Le=>Le.id===Z)+1,mt=Ce.vipSort??Ne.findIndex(Le=>Le.id===D)+1;Me(Le=>{const vt=[...Le],Ft=vt.findIndex(dc=>dc.id===Z),Fn=vt.findIndex(dc=>dc.id===D);if(Ft===-1||Fn===-1)return Le;const fl=[...vt],[am,im]=[fl[Ft],fl[Fn]];return fl[Ft]={...im,vipSort:De},fl[Fn]={...am,vipSort:mt},fl});try{const[Le,vt]=await Promise.all([Yt("/api/db/users",{id:Z,vipSort:mt}),Yt("/api/db/users",{id:D,vipSort:De})]);if(!(Le!=null&&Le.success)||!(vt!=null&&vt.success)){G.error((Le==null?void 0:Le.error)||(vt==null?void 0:vt.error)||"更新排序失败"),await ms();return}G.success("已更新排序"),await ms()}catch{G.error("更新排序失败"),await ms()}},al=g.useCallback(async()=>{pt(!0);try{const S=await Re("/api/db/users/journey-stats");S!=null&&S.success&&S.stats&>(S.stats)}catch{}finally{pt(!1)}},[]),il=g.useCallback(async S=>{Tt(S),Ss(!0);try{const D=await Re(`/api/db/users/journey-users?stage=${S}&limit=50`);D!=null&&D.success&&D.users&&Nn(D.users)}catch{}finally{Ss(!1)}},[]),ol=g.useCallback(async(S,D)=>{da(S),Ba(D),Fr(!0);try{const Z=await Re(`/api/db/users/tracks?userId=${S}&limit=50`);Z!=null&&Z.success&&Z.tracks&&wr(Z.tracks)}catch{}finally{Fr(!1)}},[]),[ac,ic]=g.useState(!1),yd=async()=>{ic(!0);try{const S=await xt("/api/admin/shensheshou/batch-enrich",{limit:20});S!=null&&S.success?(G.success(`批量补全完成:${S.enriched} 人已补全,${S.skipped} 人跳过`),ps()):G.error((S==null?void 0:S.error)||"批量补全失败")}catch{G.error("批量补全请求失败")}finally{ic(!1)}},bd=S=>{const D=[S.phone,S.nickname,S.avatar,S.wechatId,S.mbti,S.industry,S.region,S.position],Z=D.filter(ye=>ye!=null&&ye!=="").length;return Math.round(Z/D.length*100)},{leadsRows:gs,leadsRawCount:oc,leadsDeduped:lc}=g.useMemo(()=>{const S=Le=>(Le||"").replace(/\D/g,"")||"",D=Le=>{const vt=S(Le.phone);if(vt)return`phone:${vt}`;const Ft=(Le.userId||"").trim();if(Ft)return`user:${Ft}`;const Fn=(Le.wechatId||"").trim();return Fn?`wechat:${Fn}`:`row:${Le.id}`},Z=Vr.trim().toLowerCase();let ye=dr;Z&&(ye=dr.filter(Le=>[Le.userNickname,Le.name,Le.phone,Le.wechatId,Le.personName,Le.source,Le.planApiKey].filter(Boolean).join(" ").toLowerCase().includes(Z)));const Ce=[...ye].sort((Le,vt)=>{const Ft=Le.createdAt?new Date(Le.createdAt).getTime():0;return(vt.createdAt?new Date(vt.createdAt).getTime():0)-Ft});if(!fa)return{leadsRows:Ce,leadsRawCount:ye.length,leadsDeduped:0};const De=new Set,mt=[];for(const Le of Ce){const vt=D(Le);De.has(vt)||(De.add(vt),mt.push(Le))}return{leadsRows:mt,leadsRawCount:ye.length,leadsDeduped:ye.length-mt.length}},[dr,Vr,fa]);g.useEffect(()=>{const S=gs.map(ye=>ye.id),D=S.filter(ye=>ts.includes(ye)).length,Z=xa.current;Z&&(Z.indeterminate=D>0&&DZ.id),D=S.length>0&&S.every(Z=>ts.includes(Z));zs(D?Z=>Z.filter(ye=>!S.includes(ye)):Z=>[...new Set([...Z,...S])])}function Nd(S){zs(D=>D.includes(S)?D.filter(Z=>Z!==S):[...D,S])}async function wd(){if(ts.length===0){G.info("请先勾选要删除的记录");return}const S=ts.length;if(!confirm(`确定批量删除选中的 ${S} 条获客记录?删除后不可恢复。`))return;const D=500;ma(!0);try{let Z=0;for(let ye=0;ye{const D=S||"";return D==="success"?s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"已推送(存客宝已接收)"}):D==="pending_verify"?s.jsx(Ve,{className:"bg-sky-500/20 text-sky-300 border-0 text-xs",children:"待通过 / 处理中"}):D==="expired"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-300 border-0 text-xs",children:"已过期"}):D==="failed"?s.jsx(Ve,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):D==="pending"?s.jsx(Ve,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"}):D?s.jsx(Ve,{className:"bg-violet-500/20 text-violet-300 border-0 text-xs",title:D,children:D}):s.jsx(Ve,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"})},cl=g.useMemo(()=>{const S=new Map;for(const D of gs){if(D.pushStatus!=="failed")continue;const Z=(D.ckbError||"未知错误").trim()||"未知错误";S.set(Z,(S.get(Z)||0)+1)}return Array.from(S.entries()).map(([D,Z])=>({reason:D,count:Z})).sort((D,Z)=>Z.count-D.count)},[gs]);async function cc(){const S=gs.filter(De=>De.pushStatus==="failed");if(S.length===0){G.info("当前页无失败记录");return}const D=cl.slice(0,8).map(De=>`- ${De.reason}:${De.count} 条`).join(` -`),Z=S.slice(0,30).map(De=>De.id).join(", "),ye=S.slice(0,20).map(De=>`#${De.id} | ${De.userNickname||De.name||"-"} | 手机:${De.phone||"-"} | 来源:${De.source||"-"} | 重试:${De.retryCount??0} | 错误:${De.ckbError||"-"}`).join(` -`),Ce=["【获客失败排障信息】",`时间:${new Date().toLocaleString()}`,`当前页失败总数:${S.length}`,"主要失败原因:",D||"- 无",`最近失败记录ID(最多30条):${Z||"无"}`,"","失败记录明细(最多20条):",ye||"无"].join(` -`);try{await navigator.clipboard.writeText(Ce),G.success("已复制排障信息")}catch{G.error("复制失败,请检查浏览器剪贴板权限")}}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:()=>O(null),children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start gap-6 mb-6 flex-wrap",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",u," 位注册用户",Qs!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Qs," 人"]}),Y&&" · RFM 排序中"]})]}),s.jsx(_e,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:s.jsxs($e,{className:"p-3 sm:p-4 space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>se(S=>!S),className:"flex items-center gap-2 min-w-0 flex-1 text-left rounded-lg px-1 py-0.5 hover:bg-white/5 transition-colors","aria-expanded":_,children:[s.jsx(Cf,{className:"w-5 h-5 text-[#38bdac] shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-semibold text-white",children:"算法配置"}),s.jsx("div",{className:"text-xs text-gray-500 truncate",children:_?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),_?s.jsx(Dg,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(Mi,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:dn,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:Y?ce==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),_&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:["综合分 0–100(六维度):最近消费 R(25%)+ 订单频次 F(20%)+ 累计金额 M(20%)+ 推荐人数(15%)+ 行为轨迹(10%)+ 资料完善(10%)。各维度在全量用户中归一化,与后端"," ",s.jsx("code",{className:"text-gray-500",children:"/api/db/users/rfm"})," 一致。"]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:w8.map(({level:S,range:D,label:Z})=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] border-0 ${sl(S)}`,children:[S," ",D," · ",Z]},S))})]})]})})]}),s.jsxs(Vl,{value:a,onValueChange:S=>{const D=new URLSearchParams(t);S==="users"?D.delete("tab"):D.set("tab",S),e(D)},className:"w-full",children:[s.jsxs(Do,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Bt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Vn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Bt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>ft(),children:[s.jsx(Uc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Bt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:al,children:[s.jsx(na,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Bt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Bs,children:[s.jsx(No,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Bt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ms,children:[s.jsx(Kc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Vt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(J,{variant:"outline",onClick:yd,disabled:ac,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[ac?s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ro,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(J,{variant:"outline",onClick:()=>ps(!0),disabled:W,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${W?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:M,onChange:S=>{const D=S.target.value;E(D),m(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:Y,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(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:N,onChange:S=>w(S.target.value)})]}),s.jsxs(J,{onClick:rc,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Uc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:L?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"用户信息"}),s.jsx(ke,{className:"text-gray-400",children:"绑定信息"}),s.jsx(ke,{className:"text-gray-400",children:"购买状态"}),s.jsx(ke,{className:"text-gray-400",children:"分销收益"}),s.jsxs(ke,{className:"text-gray-400 cursor-pointer select-none",onClick:dn,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Cf,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),Y?ce==="desc"?s.jsx(Mi,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Dg,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Ix,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),Y&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(ke,{className:"text-gray-400",children:"资料完善"}),s.jsx(ke,{className:"text-gray-400",children:"注册时间"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[o.map(S=>{var D,Z,ye;return s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var mt;const Ce=Sr(S.avatar,S.mbti),De=((mt=S.nickname)==null?void 0:mt.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>vn(!0),className:"w-10 h-10 shrink-0 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] overflow-hidden ring-1 ring-transparent hover:ring-[#38bdac]/60 transition",children:Ce?s.jsx("img",{src:Ce,className:"w-full h-full rounded-full object-cover",alt:"",onError:Le=>{var Fn;const vt=Le.target;if(vt.style.display="none",vt.nextElementSibling)return;const Ft=document.createElement("span");Ft.textContent=De,(Fn=vt.parentElement)==null||Fn.appendChild(Ft)}}):De})})(),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{Ue(S.id),we(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:S.nickname}),S.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),S.openId&&!((D=S.id)!=null&&D.startsWith("user_"))&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate max-w-[140px]",title:S.id,children:[(Z=S.id)==null?void 0:Z.slice(0,16),(((ye=S.id)==null?void 0:ye.length)??0)>16?"…":""]})]})]})}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[S.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:S.phone})]}),S.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:S.wechatId})]}),!S.phone&&!S.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(je,{children:(()=>{const Ce=Ka(S);return Ce.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:Ce.main}),Ce.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:Ce.sub})]}):Ce.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:Ce.main}),Ce.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:Ce.sub})]}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:Ce.main})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(S.earnings||0)).toFixed(2)]}),parseFloat(String(S.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(S.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Ja(S),role:"button",tabIndex:0,onKeyDown:Ce=>Ce.key==="Enter"&&Ja(S),children:[s.jsx(Vn,{className:"w-3 h-3"})," 绑定",S.referralCount||0,"人"]})]})}),s.jsx(je,{children:S.rfmScore!=null&&S.rfmScore!==void 0?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:S.rfmScore}),s.jsx(Ve,{className:`border-0 text-xs ${sl(S.rfmLevel)}`,children:S.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(je,{children:(()=>{const Ce=bd(S),De=Ce>=75?"text-green-400":Ce>=50?"text-yellow-400":"text-gray-500";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-12 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${Ce>=75?"bg-green-500":Ce>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${Ce}%`}})}),s.jsxs("span",{className:`text-xs ${De}`,children:[Ce,"%"]})]})})()}),s.jsx(je,{className:"text-gray-400",children:S.createdAt?new Date(S.createdAt).toLocaleDateString():"-"}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{Ue(S.id),we(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(Sf,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Wr(S),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Ga(S.id),title:"删除",children:s.jsx(Jn,{className:"w-4 h-4"})})]})})]},S.id)}),o.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(us,{page:f,totalPages:qa,total:u,pageSize:x,onPageChange:m,onPageSizeChange:S=>{b(S),m(1)}})]})})})]}),s.jsxs(Vt,{value:"leads",children:[kr&&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:kr}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Br(null),"aria-label":"关闭",children:"×"})]}),!Zt&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"线索总条数(含留资/加入/匹配)"}),s.jsx("p",{className:"text-xl font-bold text-white",children:ua})]}),s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"去重用户数(按 userId)"}),s.jsx("p",{className:"text-xl font-bold text-[#38bdac]",title:"后端 COUNT(DISTINCT user_id)",children:$s.uniqueUsers??0})]}),($s.sourceStats&&$s.sourceStats.length>0?$s.sourceStats.slice(0,2):[]).map(S=>s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsxs("p",{className:"text-gray-500 text-xs",children:["来源:",S.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:S.cnt})]},S.source))]}),!Zt&&cl.length>0&&s.jsx(_e,{className:"bg-[#3a1010]/35 border-red-900/60 shadow-lg mb-4",children:s.jsxs($e,{className:"p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-red-200 font-medium",children:"失败原因聚合"}),s.jsx("p",{className:"text-red-300/70 text-xs",children:"基于当前页筛选结果,按失败原因聚合统计"})]}),s.jsx(J,{type:"button",variant:"outline",onClick:cc,className:"border-red-600/70 text-red-200 hover:bg-red-500/10 bg-transparent",children:"一键复制排障信息"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:cl.slice(0,8).map(S=>s.jsxs(Ve,{className:"bg-red-500/15 text-red-200 border border-red-600/40",children:[S.reason," · ",S.count]},S.reason))})]})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[200px]",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索昵称/手机/微信/@人/来源/类型…",value:bt,onChange:S=>$n(S.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),$s.sourceStats&&$s.sourceStats.length>0&&s.jsxs("select",{value:ha,onChange:S=>{cn(S.target.value),At(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),$s.sourceStats.map(S=>s.jsxs("option",{value:S.source,children:[S.source,"(",S.cnt,")"]},S.source))]}),s.jsxs("select",{value:Hr,onChange:S=>{const D=S.target.value;Va(D),At(1),e(Z=>{const ye=new URLSearchParams(Z);return ye.set("tab","leads"),D?ye.set("leadAction",D):ye.delete("leadAction"),ye})},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",title:"按业务类型筛选",children:[s.jsx("option",{value:"",children:"全部类型"}),s.jsx("option",{value:"lead",children:"留资线索(文章@ / 首页链接)"}),s.jsx("option",{value:"join",children:"加入报名(导师 / 资源对接 / 团队)"}),s.jsx("option",{value:"match",children:"匹配上报(找伙伴匹配)"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-gray-400 select-none bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2",children:[s.jsx("input",{type:"checkbox",checked:fa,onChange:S=>Ha(S.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"}),"去重展示"]}),s.jsxs("select",{value:ur,onChange:S=>{Cs(S.target.value),At(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待推送"}),s.jsx("option",{value:"success",children:"已推送(存客宝已接收)"}),s.jsx("option",{value:"pending_verify",children:"待通过 / 处理中"}),s.jsx("option",{value:"expired",children:"已过期"}),s.jsx("option",{value:"failed",children:"推送失败"})]}),s.jsx(J,{type:"button",variant:"outline",onClick:()=>{Cs("failed"),At(1)},className:"border-red-600/60 text-red-300 hover:bg-red-500/10 bg-transparent text-xs h-9",children:"只看失败"}),s.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID(含微信侧标识)只保留最近一条",children:["本页 ",oc," 条",lc>0?` · 已合并 ${lc} 条重复`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(J,{variant:"outline",onClick:tl,disabled:Zt,className:"border-cyan-600/60 text-cyan-300 hover:bg-cyan-500/10 bg-transparent",children:"导出失败清单"}),s.jsxs(J,{variant:"outline",onClick:el,disabled:Yo||Js||Zt,className:"border-amber-600/60 text-amber-300 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${Yo?"animate-spin":""}`}),"重推本页失败项"]}),s.jsxs(J,{variant:"outline",onClick:()=>void wd(),disabled:Js||ts.length===0||Zt,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Jn,{className:`w-4 h-4 mr-2 ${Js?"animate-pulse":""}`}),Js?"删除中…":`批量删除(${ts.length})`]}),s.jsxs(J,{variant:"outline",onClick:()=>ft(),disabled:Zt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${Zt?"animate-spin":""}`})," 刷新"]})]})]}),!Zt&&gs.length>0&&s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["已选 ",s.jsx("span",{className:"text-[#38bdac]",children:ts.length})," 条 · 可翻页继续勾选 · 改搜索/筛选会清空选择",ts.length>0&&s.jsx("button",{type:"button",className:"ml-2 text-gray-400 hover:text-gray-200 underline",onClick:()=>zs([]),children:"清空"})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:Zt?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-10 text-center",children:s.jsx("input",{ref:xa,type:"checkbox",checked:gs.length>0&&gs.every(S=>ts.includes(S.id)),onChange:vd,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页(展示行)"})}),s.jsx(ke,{className:"text-gray-400",children:"昵称"}),s.jsx(ke,{className:"text-gray-400",children:"手机号"}),s.jsx(ke,{className:"text-gray-400",children:"微信号"}),s.jsx(ke,{className:"text-gray-400",children:"对应 @人"}),s.jsx(ke,{className:"text-gray-400",children:"获客计划(Key)"}),s.jsx(ke,{className:"text-gray-400",children:"推送状态"}),s.jsx(ke,{className:"text-gray-400",children:"时间"}),s.jsx(ke,{className:"text-gray-400",children:"重试"})]})}),s.jsxs(ds,{children:[gs.map(S=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{className:"text-center align-middle w-10",children:s.jsx("input",{type:"checkbox",checked:ts.includes(S.id),onChange:()=>Nd(S.id),disabled:Js,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"})}),s.jsx(je,{className:"text-gray-300 align-middle",children:s.jsx(j8,{userId:S.userId,userAvatar:S.userAvatar,nickname:S.userNickname,name:S.name,onOpenDetail:D=>{Ue(D),we(!0)}})}),s.jsx(je,{className:"text-gray-300",children:S.phone||"-"}),s.jsx(je,{className:"text-gray-300",children:S.wechatId||"-"}),s.jsx(je,{className:"text-[#38bdac]",children:S.personName||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:(()=>{const D=(S.planApiKey||"").trim();if(!D)return"-";const Z=D.length<=10?D:`${D.slice(0,6)}…${D.slice(-4)}`;return s.jsx("button",{type:"button",className:"font-mono text-gray-400 hover:text-gray-200 underline decoration-dotted",title:D,onClick:async()=>{try{await navigator.clipboard.writeText(D),G.success("已复制计划Key")}catch{G.error("复制失败,请手动复制")}},children:Z})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[ll(S.pushStatus),(typeof S.ckbCode=="number"||(S.ckbMessage||"").trim())&&s.jsx("p",{className:"text-[11px] text-gray-500 max-w-[260px] truncate",title:[typeof S.ckbCode=="number"?`code=${S.ckbCode}`:"",(S.ckbMessage||"").trim()?`message=${String(S.ckbMessage).trim()}`:"",(S.ckbData||"").trim()?`data=${String(S.ckbData).trim()}`:""].filter(Boolean).join(" | "),children:[typeof S.ckbCode=="number"?`code=${S.ckbCode}`:"",(S.ckbMessage||"").trim()?String(S.ckbMessage).trim():""].filter(Boolean).join(" · ")}),!!(S.ckbData||"").trim()&&s.jsx("button",{type:"button",className:"text-[11px] text-sky-300/90 hover:text-sky-200 underline decoration-dotted",onClick:()=>{const D=String(S.ckbData||"").trim();Wa(`存客宝返回 data(#${S.id})`),Xo(k8(D)),Oi(!0)},children:"查看 data"}),!!S.ckbError&&s.jsx("p",{className:"text-[11px] text-red-300 max-w-[220px] truncate",title:S.ckbError,children:S.ckbError})]})}),s.jsx(je,{className:"text-gray-400 whitespace-nowrap",children:S.createdAt?new Date(S.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-gray-400 text-xs align-top py-3 min-w-[148px]",children:s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("p",{className:"text-gray-400 leading-snug",children:typeof S.retryCount=="number"?`第 ${S.retryCount} 次`:"-"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(J,{size:"sm",variant:"outline",disabled:Js||pa===S.id||Ur===S.id,onClick:()=>sc(S.id),className:"h-8 px-2.5 text-[11px] border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-3 h-3 mr-1 ${pa===S.id?"animate-spin":""}`}),"重推"]}),s.jsxs(J,{size:"sm",variant:"outline",disabled:Js||Ur===S.id||pa===S.id,onClick:()=>_i(S.id),className:"h-8 px-2.5 text-[11px] border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent shrink-0",children:[s.jsx(Jn,{className:`w-3 h-3 mr-1 ${Ur===S.id?"animate-pulse":""}`}),"删除"]})]})]})})]},S.id)),gs.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:9,className:"p-0 align-top",children:s.jsxs("div",{className:"py-16 px-6 text-center border-t border-gray-700/40 bg-[#0a1628]/30",children:[s.jsx(Uc,{className:"w-14 h-14 text-[#38bdac]/20 mx-auto mb-4","aria-hidden":!0}),s.jsx("p",{className:"text-gray-200 font-medium mb-1",children:"暂无获客线索"}),s.jsx("p",{className:"text-gray-500 text-sm mb-6 max-w-md mx-auto leading-relaxed",children:Vr.trim()||ha?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>ft(),disabled:Zt,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${Zt?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(us,{page:ve,totalPages:Math.ceil(ua/Qt)||1,total:ua,pageSize:Qt,onPageChange:At,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Vt,{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(J,{variant:"outline",onClick:al,disabled:_t,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${_t?"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:Lc.map((S,D)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${S.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${lt===S.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>il(S.id),title:`点击查看「${S.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:S.icon}),s.jsx("div",{className:`text-xs font-medium ${S.color.split(" ").find(Z=>Z.startsWith("text-"))}`,children:S.label}),qe[S.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:qe[S.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:D+1})]}),Ds.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:S.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:S.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",S.next]})]})]},S.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(or,{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:"实时更新"})]}),_t?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(qe).length>0?s.jsx("div",{className:"space-y-2",children:(()=>{const S=Lc.reduce((D,Z)=>D+(qe[Z.id]||0),0);return Lc.map(D=>{const Z=qe[D.id]||0,ye=S>0?Math.round(Z/S*100):0,Ce=Z>0?Math.max(ye,6):0;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-[5.5rem] shrink-0 leading-tight",children:[D.icon," ",D.label]}),s.jsx("div",{className:"flex-1 h-2.5 bg-[#0a1628] rounded-full overflow-hidden border border-gray-700/40",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-[#38bdac]/50 to-[#38bdac] transition-all",style:{width:`${Ce}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-14 text-right tabular-nums",children:Z}),s.jsx("span",{className:"text-gray-600 text-[10px] w-8 text-right tabular-nums",children:S>0?`${ye}%`:"—"})]},D.id)})})()}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),lt&&s.jsxs("div",{className:"mt-6 bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",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(Vn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(Ui=Lc.find(S=>S.id===lt))==null?void 0:Ui.icon," ",(Wi=Lc.find(S=>S.id===lt))==null?void 0:Wi.label," 阶段用户"]}),s.jsxs(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Wt.length," 人"]})]}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Tt(null),className:"text-gray-400 hover:text-white",children:s.jsx(Qn,{className:"w-4 h-4"})})]}),ks?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Wt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"昵称"}),s.jsx(ke,{className:"text-gray-400",children:"手机号"}),s.jsx(ke,{className:"text-gray-400",children:"注册时间"}),s.jsx(ke,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(ds,{children:Wt.map(S=>s.jsxs(ht,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(je,{className:"text-white",children:S.nickname||"微信用户"}),s.jsx(je,{className:"text-gray-300",children:S.phone||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:S.createdAt?new Date(S.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(je,{className:"text-right",children:s.jsxs(J,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>ol(S.id,S.nickname||"微信用户"),children:[s.jsx(Sf,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},S.id))})]})]}),s.jsx(Pt,{open:!!Li,onOpenChange:S=>{S||da(null)},children:s.jsxs(Mt,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(na,{className:"w-5 h-5 text-[#38bdac]"}),Fa," 的行为轨迹"]})}),jr?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Nr.length===0?s.jsx("p",{className:"text-gray-500 text-center py-8",children:"该用户暂无行为记录"}):s.jsxs("div",{className:"relative pl-6 space-y-0",children:[s.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-0.5 bg-gray-700"}),Nr.map((S,D)=>s.jsxs("div",{className:"relative flex items-start gap-3 py-2",children:[s.jsx("div",{className:"absolute left-[-13px] top-3 w-2.5 h-2.5 rounded-full bg-[#38bdac] border-2 border-[#0f2137] z-10"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-white text-sm font-medium",children:S.actionLabel}),S.module&&s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:S.module})]}),(S.chapterTitle||S.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:S.chapterTitle||S.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[S.timeAgo," · ",S.createdAt?new Date(S.createdAt).toLocaleString("zh-CN"):""]})]})]},S.id||D))]})]})})]}),s.jsxs(Vt,{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(J,{variant:"outline",onClick:Bs,disabled:ln,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${ln?"animate-spin":""}`})," 刷新"]}),s.jsxs(J,{onClick:()=>{Xn(null),xn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),Sn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),ln?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):on.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(or,{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(J,{onClick:Bs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(He,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:on.map(S=>{var Z;const D=M2(S.triggerConditions);return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${S.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsxs("span",{className:"text-gray-600 text-xs font-mono w-5 shrink-0 text-right",children:["#",S.sort]}),s.jsx(pn,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:S.title}),S.trigger&&s.jsx(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:S.trigger}),D.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[D.slice(0,3).map(ye=>{const Ce=lN.find(De=>De.value===ye);return s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(Ce==null?void 0:Ce.label)||ye},ye)}),D.length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",D.length-3]})]}),S.actionType&&S.actionType!=="popup"&&s.jsx(Ve,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((Z=cN.find(ye=>ye.value===S.actionType))==null?void 0:Z.label)||S.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx(Ht,{checked:S.enabled,onCheckedChange:()=>Ya(S)}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{Xn(S),xn({title:S.title,description:S.description,trigger:S.trigger,triggerConditions:D,actionType:S.actionType||"popup",sort:S.sort,enabled:S.enabled}),Sn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Qa(S.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),S.description&&s.jsxs("details",{className:"ml-[52px] mt-1",children:[s.jsxs("summary",{className:"text-gray-500 text-xs cursor-pointer hover:text-gray-400 select-none",children:["查看完整描述",s.jsxs("span",{className:"text-gray-600 ml-1",children:["(",S.description.length," 字,默认折叠)"]})]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1 pl-1 border-l-2 border-gray-700 whitespace-pre-wrap",children:S.description})]})]},S.id)})})]}),s.jsxs(Vt,{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.jsxs("p",{className:"text-xs text-gray-500",children:["飞书群 Webhook(按人推线索到飞书)已迁至"," ",s.jsx("span",{className:"text-[#38bdac]",children:"内容管理 → 链接人与事 → @列表"}),",在绑定会员的人物行操作栏配置。"]}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(J,{variant:"outline",onClick:ms,disabled:We,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${We?"animate-spin":""}`})," ","刷新"]})})]}),We?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Ne.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Kc,{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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(ke,{className:"text-gray-400",children:"成员"}),s.jsx(ke,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(ke,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(ke,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(ke,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(ke,{className:"text-gray-400 w-28 text-right",children:"操作"})]})}),s.jsx(ds,{children:Ne.map((S,D)=>{var Ce;const Z=Ot===S.id,ye=ze===S.id;return s.jsxs(ht,{draggable:!0,onDragStart:De=>va(De,S.id),onDragOver:De=>Vi(De,S.id),onDrop:De=>gd(De,S.id),onDragEnd:Hi,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${Z?"opacity-60":""} ${ye?"bg-[#38bdac]/10":""}`,children:[s.jsx(je,{className:"text-gray-300",children:D+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Sr(S.avatar,S.mbti)?s.jsx("img",{src:Sr(S.avatar,S.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:De=>{var Le,vt;De.target.style.display="none";const mt=document.createElement("div");mt.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",mt.textContent=((Le=S.name)==null?void 0:Le[0])||"创",(vt=De.target.parentElement)==null||vt.appendChild(mt)}}):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:((Ce=S.name)==null?void 0:Ce[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:S.name})})]})}),s.jsx(je,{className:"text-gray-300 whitespace-nowrap",children:S.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(je,{className:"text-center text-blue-400 text-xs font-mono",children:S.clickCount!=null?String(S.clickCount):"-"}),s.jsx(je,{className:"text-center text-green-400 text-xs font-mono",children:S.leadCount!=null?String(S.leadCount):"-"}),s.jsx(je,{className:"text-gray-300",children:S.vipSort??D+1}),s.jsx(je,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>Cr(S),title:"设置超级个体标签",children:s.jsx(ou,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Fi(S),title:"设置排序序号",children:s.jsx(Ix,{className:"w-3.5 h-3.5"})})]})})]},S.id)})})]})})})]})]}),s.jsx(Pt,{open:yt,onOpenChange:vn,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(It,{children:s.jsx(Rt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(v8,{})]})}),s.jsx(Pt,{open:qr,onOpenChange:S=>{Gr(S),S||gn(null)},children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ix,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",Xs==null?void 0:Xs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Er,onChange:S=>Zs(S.target.value)})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Gr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:Bi,disabled:ba,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ba?"保存中...":"保存"]})]})]})}),s.jsx(Pt,{open:$i,onOpenChange:S=>{Xa(S),S||Za(null)},children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Kc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",xs==null?void 0:xs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:zi.map(S=>s.jsx(J,{variant:Kr===S?"default":"outline",size:"sm",className:Kr===S?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>ei(S),children:S},S))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Kr,onChange:S=>ei(S.target.value)})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Xa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:()=>ya(Kr),disabled:hr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),hr?"保存中...":"保存"]})]})]})}),s.jsx(Pt,{open:I,onOpenChange:X,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[V?s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Uc,{className:"w-5 h-5 text-[#38bdac]"}),V?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"手机号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:dt.phone,onChange:S=>Et({...dt,phone:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"昵称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:dt.nickname,onChange:S=>Et({...dt,nickname:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:V?"新密码 (留空则不修改)":"密码"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:V?"留空则不修改":"请输入密码",value:dt.password,onChange:S=>Et({...dt,password:S.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ne,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Ht,{checked:dt.isAdmin,onCheckedChange:S=>Et({...dt,isAdmin:S})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ne,{className:"text-gray-300",children:"已购全书"}),s.jsx(Ht,{checked:dt.hasFullBook,onCheckedChange:S=>Et({...dt,hasFullBook:S})})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>X(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:ns,disabled:ee,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ee?"保存中...":"保存"]})]})]})}),s.jsx(Pt,{open:mn,onOpenChange:Sn,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),_n?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Lt.title,onChange:S=>xn({...Lt,title:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"规则描述"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:Lt.description,onChange:S=>xn({...Lt,description:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(S=>{const D=lN.filter(Z=>Z.group===S);return D.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:S}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:D.map(Z=>{const ye=(Lt.triggerConditions||[]).includes(Z.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${ye?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const Ce=Lt.triggerConditions||[],De=ye?Ce.filter(mt=>mt!==Z.value):[...Ce,Z.value];xn({...Lt,triggerConditions:De})},children:Z.label},Z.value)})})]},S)})}),(Lt.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(Lt.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"与小程序一致:注册、完成付款、update_avatar、update_nickname 等",value:Lt.trigger,onChange:S=>xn({...Lt,trigger:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:cN.map(S=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${Lt.actionType===S.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>xn({...Lt,actionType:S.value}),children:[s.jsx("span",{className:`text-xs font-medium ${Lt.actionType===S.value?"text-[#38bdac]":"text-gray-300"}`,children:S.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:S.desc})]},S.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(ne,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Ht,{checked:Lt.enabled,onCheckedChange:S=>xn({...Lt,enabled:S})})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Sn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:xd,disabled:ee,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ee?"保存中...":"保存"]})]})]})}),s.jsx(Pt,{open:K,onOpenChange:fe,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",z==null?void 0:z.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:((dl=he.stats)==null?void 0:dl.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:((ul=he.stats)==null?void 0:ul.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:["¥",(((hl=he.stats)==null?void 0:hl.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:["¥",(((T=he.stats)==null?void 0:T.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(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((F=he.referrals)==null?void 0:F.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(he.referrals??[]).map((S,D)=>{var ye;const Z=S;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:((ye=Z.nickname)==null?void 0:ye.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:Z.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:Z.phone||(Z.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Z.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Z.status==="paid"&&s.jsxs(Ve,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Z.purchasedSections,"章"]}),Z.status==="free"&&s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:Z.createdAt?new Date(Z.createdAt).toLocaleDateString():""})]})]},Z.id||D)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(Xt,{children:s.jsx(J,{variant:"outline",onClick:()=>fe(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(cy,{open:ie,onClose:()=>we(!1),userId:Be,onUserUpdated:ps}),s.jsx(Pt,{open:Ua,onOpenChange:Oi,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700/60 text-white max-w-2xl",children:[s.jsx(It,{children:s.jsx(Rt,{className:"text-white",children:Di})}),s.jsx("div",{className:"mt-2",children:s.jsx("pre",{className:"text-xs text-gray-200 bg-[#0a1628] border border-gray-700/60 rounded-lg p-3 max-h-[520px] overflow-auto whitespace-pre-wrap break-words",children:ga||"—"})}),s.jsxs(Xt,{children:[s.jsx(J,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent",onClick:async()=>{try{await navigator.clipboard.writeText(ga||""),G.success("已复制 data")}catch{G.error("复制失败,请手动复制")}},disabled:!ga,children:"复制 data"}),s.jsx(J,{type:"button",className:"bg-[#38bdac] hover:bg-[#2aa896] text-white",onClick:()=>Oi(!1),children:"关闭"})]})]})})]})}function Pf(t,[e,n]){return Math.min(n,Math.max(e,t))}var A2=["PageUp","PageDown"],P2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],I2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ud="Slider",[qg,C8,E8]=ay(ud),[R2]=Ho(ud,[E8]),[T8,Op]=R2(ud),L2=g.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:x=()=>{},inverted:b=!1,form:N,...w}=t,v=g.useRef(new Set),k=g.useRef(0),E=o==="horizontal"?M8:A8,[L=[],R]=Fl({prop:f,defaultProp:h,onChange:ae=>{var se;(se=[...v.current][k.current])==null||se.focus(),m(ae)}}),W=g.useRef(L);function P(ae){const _=O8(L,ae);Y(ae,_)}function B(ae){Y(ae,k.current)}function O(){const ae=W.current[k.current];L[k.current]!==ae&&x(L)}function Y(ae,_,{commit:se}={commit:!1}){const ce=z8(i),me=F8(Math.round((ae-r)/i)*i+r,ce),I=Pf(me,[r,a]);R((X=[])=>{const V=R8(X,I,_);if($8(V,u*i)){k.current=V.indexOf(I);const xe=String(V)!==String(X);return xe&&se&&x(V),xe?V:X}else return X})}return s.jsx(T8,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:L,orientation:o,form:N,children:s.jsx(qg.Provider,{scope:t.__scopeSlider,children:s.jsx(qg.Slot,{scope:t.__scopeSlider,children:s.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:Nt(w.onPointerDown,()=>{c||(W.current=L)}),min:r,max:a,inverted:b,onSlideStart:c?void 0:P,onSlideMove:c?void 0:B,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&Y(r,0,{commit:!0}),onEndKeyDown:()=>!c&&Y(a,L.length-1,{commit:!0}),onStepKeyDown:({event:ae,direction:_})=>{if(!c){const me=A2.includes(ae.key)||ae.shiftKey&&P2.includes(ae.key)?10:1,I=k.current,X=L[I],V=i*me*_;Y(X+V,I,{commit:!0})}}})})})})});L2.displayName=ud;var[O2,D2]=R2(ud,{startEdge:"left",endEdge:"right",size:"width",direction:1}),M8=g.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,x]=g.useState(null),b=Jt(e,E=>x(E)),N=g.useRef(void 0),w=Ip(a),v=w==="ltr",k=v&&!i||!v&&i;function M(E){const L=N.current||m.getBoundingClientRect(),R=[0,L.width],P=dy(R,k?[n,r]:[r,n]);return N.current=L,P(E-L.left)}return s.jsx(O2,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:s.jsx(_2,{dir:w,"data-orientation":"horizontal",...f,ref:b,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const L=M(E.clientX);o==null||o(L)},onSlideMove:E=>{const L=M(E.clientX);c==null||c(L)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:E=>{const R=I2[k?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:R?-1:1})}})})}),A8=g.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=g.useRef(null),m=Jt(e,f),x=g.useRef(void 0),b=!a;function N(w){const v=x.current||f.current.getBoundingClientRect(),k=[0,v.height],E=dy(k,b?[r,n]:[n,r]);return x.current=v,E(w-v.top)}return s.jsx(O2,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:s.jsx(_2,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const v=N(w.clientY);i==null||i(v)},onSlideMove:w=>{const v=N(w.clientY);o==null||o(v)},onSlideEnd:()=>{x.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=I2[b?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),_2=g.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Op(ud,n);return s.jsx(St.span,{...h,ref:e,onKeyDown:Nt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):A2.concat(P2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:Nt(t.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(x)?x.focus():r(m)}),onPointerMove:Nt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:Nt(t.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),i(m))})})}),$2="SliderTrack",z2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Op($2,n);return s.jsx(St.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});z2.displayName=$2;var Gg="SliderRange",F2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Op(Gg,n),i=D2(Gg,n),o=g.useRef(null),c=Jt(e,o),u=a.values.length,h=a.values.map(x=>H2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(St.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});F2.displayName=Gg;var Jg="SliderThumb",B2=g.forwardRef((t,e)=>{const n=C8(t.__scopeSlider),[r,a]=g.useState(null),i=Jt(e,c=>a(c)),o=g.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(P8,{...t,ref:i,index:o})}),P8=g.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=Op(Jg,n),c=D2(Jg,n),[u,h]=g.useState(null),f=Jt(e,M=>h(M)),m=u?o.form||!!u.closest("form"):!0,x=ly(u),b=o.values[r],N=b===void 0?0:H2(b,o.min,o.max),w=L8(r,o.values.length),v=x==null?void 0:x[c.size],k=v?D8(v,N,c.direction):0;return g.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(${N}% + ${k}px)`},children:[s.jsx(qg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(St.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":o.min,"aria-valuenow":b,"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:b===void 0?{display:"none"}:t.style,onFocus:Nt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(V2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});B2.displayName=Jg;var I8="RadioBubbleInput",V2=g.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=g.useRef(null),i=Jt(a,r),o=oy(e);return g.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(St.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});V2.displayName=I8;function R8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function H2(t,e,n){const i=100/(n-e)*(t-e);return Pf(i,[0,100])}function L8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function O8(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 D8(t,e,n){const r=t/2,i=dy([0,50],[0,r]);return(r-i(e)*n)*n}function _8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function $8(t,e){if(e>0){const n=_8(t);return Math.min(...n)>=e}return!0}function dy(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 z8(t){return(String(t).split(".")[1]||"").length}function F8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var B8=L2,V8=z2,H8=F2,U8=B2;function W8({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=g.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(B8,{defaultValue:e,value:n,min:r,max:a,className:Dt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(V8,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(H8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(U8,{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 K8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function U2(t){const e=!!(t!=null&&t.embedded),[n,r]=g.useState(K8),[a,i]=g.useState(!0),[o,c]=g.useState(!1);g.useEffect(()=>{Re("/api/admin/referral-settings").then(f=>{const m=f==null?void 0:f.data;m&&typeof m=="object"&&r({distributorShare:m.distributorShare??90,minWithdrawAmount:m.minWithdrawAmount??10,bindingDays:m.bindingDays??30,userDiscount:m.userDiscount??5,withdrawFee:m.withdrawFee??5,enableAutoWithdraw:m.enableAutoWithdraw??!1,vipOrderShareVip:m.vipOrderShareVip??20,vipOrderShareNonVip:m.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>i(!1))},[]);const u=async()=>{c(!0);try{const f={distributorShare:Number(n.distributorShare)||0,minWithdrawAmount:Number(n.minWithdrawAmount)||0,bindingDays:Number(n.bindingDays)||0,userDiscount:Number(n.userDiscount)||0,withdrawFee:Number(n.withdrawFee)??5,enableAutoWithdraw:!!n.enableAutoWithdraw,vipOrderShareVip:Number(n.vipOrderShareVip)||20,vipOrderShareNonVip:Number(n.vipOrderShareNonVip)||10},m=await xt("/api/admin/referral-settings",f);if(!m||m.success===!1){G.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}G.success(`✅ 分销配置已保存成功! +`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function v8(){const[t,e]=g.useState({}),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useCallback(async()=>{r(!0);try{const x=await Re("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{G.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);g.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await gt("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){G.error((x==null?void 0:x.error)||"保存失败");return}G.success("已保存,后台与小程序默认头像同步生效"),u()}catch{G.error("保存失败")}finally{i(!1)}},f=x=>{const b=oN(x);e(N=>({...N,[x]:b})),G.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};iN.forEach(b=>{x[b]=oN(b)}),e(x),G.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(He,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs($e,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(it,{className:"pb-2",children:[s.jsxs(ot,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(CA,{className:"w-5 h-5 text-[#38bdac]"}),"MBTI 头像库"]}),s.jsx(qt,{className:"text-gray-400 text-sm leading-relaxed",children:"采用人物化风格,按 MBTI 性格自动生成。头像内不显示中英文,仅显示人物形象,颜色与站点主题融合。"})]}),s.jsxs(ze,{className:"flex flex-wrap gap-2",children:[s.jsxs(J,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(JA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(J,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(He,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(J,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(kn,{className:"w-3.5 h-3.5 mr-1"}),a?"保存中…":"保存映射"]})]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:iN.map(x=>{const b=t[x]??"",N=T2[x];return s.jsxs("div",{className:"rounded-xl border border-gray-700/60 bg-[#0a1628] p-3 flex flex-col gap-2 hover:border-[#38bdac]/35 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 font-mono text-xs",children:x}),s.jsx("span",{className:"text-xs text-gray-400 truncate",title:N.title,children:N.title})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full shrink-0 overflow-hidden flex items-center justify-center bg-[#081322] ring-2 ring-[#38bdac]/40 ring-offset-2 ring-offset-[#0a1628]",children:b?s.jsx("img",{src:b,alt:x,className:"w-full h-full object-cover scale-110"}):s.jsx("span",{className:"text-gray-600 text-[10px]",children:"未配"})}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(le,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"https://... 或 data:image/...",value:b,onChange:w=>e(v=>({...v,[x]:w.target.value}))})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const lN=[{value:"after_login",label:"注册/登录成功",group:"用户状态"},{value:"bind_phone",label:"绑定手机号",group:"用户状态"},{value:"update_avatar",label:"完善头像(非默认图,与昵称分开配置)",group:"用户状态"},{value:"update_nickname",label:"修改昵称(非默认微信昵称,与头像分开)",group:"用户状态"},{value:"fill_profile",label:"完善资料(MBTI/行业/职位,不含头像昵称)",group:"用户状态"},{value:"view_chapter",label:"浏览章节",group:"阅读行为"},{value:"browse_5_chapters",label:"累计浏览5个章节",group:"阅读行为"},{value:"purchase_section",label:"购买单章",group:"付费行为"},{value:"purchase_fullbook",label:"购买全书/VIP",group:"付费行为"},{value:"after_pay",label:"任意付款成功",group:"付费行为"},{value:"after_match",label:"完成派对匹配",group:"社交行为"},{value:"click_super_individual",label:"点击超级个体头像",group:"社交行为"},{value:"lead_submit",label:"提交留资/链接",group:"社交行为"},{value:"referral_bind",label:"被推荐人绑定",group:"分销行为"},{value:"share_action",label:"分享给好友/朋友圈",group:"分销行为"},{value:"withdraw_request",label:"申请提现",group:"分销行为"},{value:"add_wechat",label:"添加微信联系方式",group:"用户状态"}],cN=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}];function M2(t){if(Array.isArray(t))return t.filter(e=>typeof e=="string");if(typeof t=="string")try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>typeof n=="string")}catch{try{const e=typeof atob=="function"?atob(t):"",n=JSON.parse(e);if(Array.isArray(n))return n.filter(r=>typeof r=="string")}catch{}}return[]}function N8(t){return{...t,triggerConditions:M2(t.triggerConditions)}}const w8=[{level:"S",range:"≥85",label:"高价值"},{level:"A",range:"70–84",label:"优质"},{level:"B",range:"50–69",label:"中等"},{level:"C",range:"30–49",label:"潜力"},{level:"D",range:"<30",label:"待激活"}],Lc=[{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 dN(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function j8({userId:t,userAvatar:e,nickname:n,name:r,onOpenDetail:a}){const[i,o]=g.useState(!1),c=n||r||"-",u=(c==="-"?"?":c).charAt(0),h=!!(e!=null&&e.trim())&&!i;return s.jsxs("div",{className:"flex items-center gap-2 min-w-0 max-w-[220px]",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/15 flex items-center justify-center text-xs font-medium text-[#38bdac] flex-shrink-0 overflow-hidden border border-gray-600/50","aria-hidden":!0,children:h?s.jsx("img",{src:aa(e),alt:"",className:"w-full h-full object-cover",onError:()=>o(!0)}):s.jsx("span",{children:u})}),s.jsx("button",{type:"button",className:`text-left truncate min-w-0 ${t?"hover:text-[#38bdac] cursor-pointer":"cursor-default text-gray-300"}`,disabled:!t,title:t?"查看用户详情":void 0,onClick:()=>{t&&a(t)},children:c})]})}function k8(t){const e=(t||"").trim();if(!e)return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function S8(){var Hi,Ui,dl,ul,hl,T,F;const[t,e]=q0(),n=t.get("pool"),r=t.get("tab")||"users",a=["users","journey","rules","vip-roles","leads"].includes(r)?r:"users",i=(t.get("leadAction")||"").trim(),[o,c]=g.useState([]),[u,h]=g.useState(0),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(""),v=Ra(N,300),k=n==="vip"?"vip":n==="complete"?"complete":"all",[M,E]=g.useState(k),[L,R]=g.useState(!0),[W,P]=g.useState(!1),[B,O]=g.useState(null),[X,ae]=g.useState(!1),[_,se]=g.useState(!1),[ce,me]=g.useState("desc");g.useEffect(()=>{n==="vip"?E("vip"):n==="complete"?E("complete"):n==="all"&&E("all")},[n]);const[I,Z]=g.useState(!1),[V,xe]=g.useState(null),[ee,H]=g.useState(!1),[K,fe]=g.useState(!1),[he,ue]=g.useState({referrals:[],stats:{}}),[$,Q]=g.useState(!1),[z,te]=g.useState(null),[ie,we]=g.useState(!1),[Be,Ue]=g.useState(null),[bt,vn]=g.useState(!1),[dt,Tt]=g.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[ln,Dn]=g.useState([]),[Zt,Dt]=g.useState(!1),[mn,Sn]=g.useState(!1),[_n,Xn]=g.useState(null),[Ot,xn]=g.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[Ne,Te]=g.useState([]),[We,tt]=g.useState(!1),[vt,ft]=g.useState(null),[_e,U]=g.useState(null),[qe,yt]=g.useState({}),[$t,mt]=g.useState(!1),[lt,Mt]=g.useState(null),[Wt,Nn]=g.useState([]),[ks,Ss]=g.useState(!1),[Ri,da]=g.useState(null),[Fa,Ba]=g.useState(""),[Nr,wr]=g.useState([]),[jr,Fr]=g.useState(!1),[_s,qs]=g.useState({}),[dr,Gs]=g.useState([]),[ua,de]=g.useState(0),[ve,Pt]=g.useState(1),[Qt]=g.useState(10),[en,Zn]=g.useState(!1),[kr,Br]=g.useState(null),[Nt,$n]=g.useState(""),Vr=Ra(Nt,300),[ha,cn]=g.useState(""),[Hr,Va]=g.useState(""),[ur,Cs]=g.useState(""),[fa,Ha]=g.useState(!1),[$s,zn]=g.useState({}),[pa,es]=g.useState(null),[Ur,Qo]=g.useState(null),[ts,zs]=g.useState([]),[Js,ma]=g.useState(!1),xa=g.useRef(null),[Yo,nc]=g.useState(!1),[Ua,Li]=g.useState(!1),[Oi,Wa]=g.useState("存客宝返回 data"),[ga,Xo]=g.useState(""),pt=g.useCallback(async(S,D)=>{Zn(!0),Br(null);try{const Y=new URLSearchParams({mode:"contact",page:String(ve),pageSize:String(Qt)}),ge=S??Vr;ge&&Y.set("search",ge);const Se=D??ha;Se&&Y.set("source",Se),Hr&&Y.set("action",Hr),ur&&Y.set("pushStatus",ur);const Oe=await Re(`/api/db/ckb-leads?${Y}`);if(Oe!=null&&Oe.success)Gs(Oe.records||[]),de(Oe.total??0),Oe.stats&&zn(Oe.stats);else{const xt=(Oe==null?void 0:Oe.error)||"加载获客列表失败";Br(xt),G.error(xt),Gs([]),de(0)}}catch(Y){const ge=Y instanceof Error?Y.message:"网络错误";Br(ge),G.error("加载获客列表失败: "+ge),Gs([]),de(0)}finally{Zn(!1)}},[ve,Qt,Vr,ha,Hr,ur]);g.useEffect(()=>{zs([])},[Vr,ha,Hr,ur]),g.useEffect(()=>{a==="leads"&&Va(i)},[a,i]);function Zo(S,D){return{...S,...D.pushStatus!==void 0?{pushStatus:D.pushStatus}:{},...typeof D.retryCount=="number"?{retryCount:D.retryCount}:{},...typeof D.ckbCode=="number"?{ckbCode:D.ckbCode}:{},...D.ckbMessage!==void 0?{ckbMessage:D.ckbMessage}:{},...D.ckbData!==void 0?{ckbData:D.ckbData}:{},...D.ckbError!==void 0?{ckbError:D.ckbError}:{},...D.lastPushAt!==void 0?{lastPushAt:D.lastPushAt??void 0}:{},...D.nextRetryAt!==void 0?{nextRetryAt:D.nextRetryAt??void 0}:{}}}async function sc(S){if(S){es(S);try{const D=await gt("/api/db/ckb-leads/retry",{id:S});D!=null&&D.success?(G.success(D.pushed?"重推成功":"已发起重推,请刷新查看状态"),D.record&&Gs(Y=>Y.map(ge=>ge.id===S?Zo(ge,D.record):ge))):G.error((D==null?void 0:D.error)||"重推失败")}catch(D){G.error(D instanceof Error?D.message:"重推请求失败")}finally{es(null)}}}async function Di(S){if(S&&confirm("确定删除该条获客记录?删除后不可恢复。")){Qo(S);try{const D=await gt("/api/db/ckb-leads/delete",{id:S});D!=null&&D.success?G.success("已删除"):G.error((D==null?void 0:D.error)||"删除失败")}catch(D){G.error(D instanceof Error?D.message:"删除请求失败")}finally{Qo(null),pt()}}}async function el(){const S=gs.filter(ge=>ge.pushStatus==="failed");if(S.length===0){G.info("当前页无失败记录");return}nc(!0);let D=0;for(const ge of S)try{const Se=await gt("/api/db/ckb-leads/retry",{id:ge.id});if(Se!=null&&Se.success&&Se.pushed&&D++,Se!=null&&Se.success&&Se.record){const Oe=Se.record;Gs(xt=>xt.map(Le=>Le.id===ge.id?Zo(Le,Oe):Le))}}catch{}nc(!1);const Y=S.length;G.success(`批量重推完成:成功 ${D} / ${Y}`)}function tl(){const S=gs.filter(Le=>Le.pushStatus==="failed");if(S.length===0){G.info("当前筛选下无失败记录可导出");return}const D=Le=>`"${String(Le??"").replace(/"/g,'""')}"`,ge=[["ID","昵称","手机号","微信号","对应@人","计划Key","来源","推送状态","重试次数","失败原因","下次重试时间","创建时间"].join(",")];for(const Le of S)ge.push([D(Le.id),D(Le.userNickname||Le.name||""),D(Le.phone||""),D(Le.wechatId||""),D(Le.personName||""),D(Le.planApiKey||""),D(Le.source||""),D(Le.pushStatus||""),D(typeof Le.retryCount=="number"?Le.retryCount:""),D(Le.ckbError||""),D(Le.nextRetryAt?new Date(Le.nextRetryAt).toLocaleString():""),D(Le.createdAt?new Date(Le.createdAt).toLocaleString():"")].join(","));const Se=new Blob(["\uFEFF"+ge.join(` +`)],{type:"text/csv;charset=utf-8;"}),Oe=URL.createObjectURL(Se),xt=document.createElement("a");xt.href=Oe,xt.download=`获客失败清单-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,document.body.appendChild(xt),xt.click(),document.body.removeChild(xt),URL.revokeObjectURL(Oe),G.success(`已导出失败清单(${S.length} 条)`)}const nl=g.useCallback(async()=>{try{const S=await Re("/api/admin/mbti-avatars"),D=S!=null&&S.avatars&&typeof S.avatars=="object"?S.avatars:{};qs(D)}catch{qs({})}},[]);g.useEffect(()=>{t.get("tab")==="leads"&&pt()},[t.get("tab"),ve,pt]),g.useEffect(()=>{if(a!=="leads")return;const S=window.setInterval(()=>{pt()},3e4);return()=>window.clearInterval(S)},[a,pt]),g.useEffect(()=>{nl()},[nl]);const Sr=g.useCallback((S,D)=>{const Y=(S||"").trim();if(Y)return Y;const ge=(D||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(ge)?(_s[ge]||"").trim():""},[_s]),Ka=g.useCallback(S=>{const D=!!S.hasFullBook,Y=Number(S.purchasedSectionCount||0);return D?{tone:"vip",main:"已购全书",sub:Y>0?`另购单章 ${Y} 章`:"购买项:VIP / 全书"}:Y>0?{tone:"paid",main:`已购 ${Y} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Qs,Fs]=g.useState(null),Es=g.useCallback(async()=>{try{const S=await Re("/api/admin/users/online-stats");S!=null&&S.success&&typeof S.onlineCount=="number"?Fs(S.onlineCount):Fs(0)}catch{Fs(null)}},[]);g.useEffect(()=>{Es();const S=setInterval(Es,1e4);return()=>clearInterval(S)},[Es]);async function ps(S=!1){var D;R(!0),S&&P(!0),O(null);try{if(X){const Y=new URLSearchParams({search:v,limit:String(x*5)}),ge=await Re(`/api/db/users/rfm?${Y}`);if(ge!=null&&ge.success){let Se=ge.users||[];ce==="asc"&&(Se=[...Se].reverse());const Oe=(f-1)*x;c(Se.slice(Oe,Oe+x)),h(((D=ge.users)==null?void 0:D.length)??0),Se.length===0&&(ae(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else ae(!1),O((ge==null?void 0:ge.error)||"RFM 加载失败,已切回普通模式")}else{const Y=new URLSearchParams({page:String(f),pageSize:String(x),search:v,...M==="vip"&&{vip:"true"},...M==="complete"&&{pool:"complete"}}),ge=await Re(`/api/db/users?${Y}`);ge!=null&&ge.success?(c(ge.users||[]),h(ge.total??0)):O((ge==null?void 0:ge.error)||"加载失败")}}catch(Y){console.error("Load users error:",Y),O("网络错误")}finally{R(!1),S&&P(!1)}}g.useEffect(()=>{m(1)},[v,M,X]),g.useEffect(()=>{ps()},[f,x,v,M,X,ce]);const qa=Math.ceil(u/x)||1,dn=()=>{X?ce==="desc"?me("asc"):(ae(!1),me("desc")):(ae(!0),me("desc"))},sl=S=>({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"})[S||""]||"bg-gray-500/20 text-gray-400";async function Ga(S){var D;if(!dN("用户")){G.info("已取消删除");return}try{const Y=await bi(`/api/db/users?id=${encodeURIComponent(S)}`);Y!=null&&Y.success?(G.success("已删除"),ps()):G.error("删除失败: "+((Y==null?void 0:Y.error)||"未知错误"))}catch(Y){const ge=Y,Se=((D=ge==null?void 0:ge.data)==null?void 0:D.error)||(ge==null?void 0:ge.message)||"网络错误";G.error("删除失败: "+Se)}}const Wr=S=>{xe(S),Tt({phone:S.phone||"",nickname:S.nickname||"",password:"",isAdmin:!!(S.isAdmin??!1),hasFullBook:!!(S.hasFullBook??!1)}),Z(!0)},rc=()=>{xe(null),Tt({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),Z(!0)};async function ns(){if(!dt.phone||!dt.nickname){G.error("请填写手机号和昵称");return}H(!0);try{if(V){const S=await Yt("/api/db/users",{id:V.id,phone:dt.phone||void 0,nickname:dt.nickname,isAdmin:dt.isAdmin,hasFullBook:dt.hasFullBook,...dt.password&&{password:dt.password}});if(!(S!=null&&S.success)){G.error("更新失败: "+((S==null?void 0:S.error)||""));return}}else{const S=await gt("/api/db/users",{phone:dt.phone,nickname:dt.nickname,password:dt.password,isAdmin:dt.isAdmin});if(!(S!=null&&S.success)){G.error("创建失败: "+((S==null?void 0:S.error)||""));return}}Z(!1),ps()}catch{G.error("保存失败")}finally{H(!1)}}async function Ja(S){te(S),fe(!0),Q(!0);try{const D=await Re(`/api/db/users/referrals?userId=${encodeURIComponent(S.id)}`);D!=null&&D.success?ue({referrals:D.referrals||[],stats:D.stats||{}}):ue({referrals:[],stats:{}})}catch{ue({referrals:[],stats:{}})}finally{Q(!1)}}const Bs=g.useCallback(async()=>{Dt(!0);try{const S=await Re("/api/db/user-rules");S!=null&&S.success&&Dn((S.rules||[]).map(D=>N8(D)))}catch{}finally{Dt(!1)}},[]);async function xd(){if(!Ot.title){G.error("请填写规则标题");return}H(!0);try{if(_n){const S=await Yt("/api/db/user-rules",{id:_n.id,...Ot});if(!(S!=null&&S.success)){G.error("更新失败: "+((S==null?void 0:S.error)||""));return}}else{const S=await gt("/api/db/user-rules",Ot);if(!(S!=null&&S.success)){G.error("创建失败: "+((S==null?void 0:S.error)||""));return}}Sn(!1),Bs()}catch{G.error("保存失败")}finally{H(!1)}}async function Qa(S){if(!dN("规则")){G.info("已取消删除");return}try{const D=await bi(`/api/db/user-rules?id=${S}`);D!=null&&D.success&&Bs()}catch{}}async function Ya(S){try{await Yt("/api/db/user-rules",{id:S.id,enabled:!S.enabled}),Bs()}catch{}}const ms=g.useCallback(async()=>{tt(!0);try{const S=await Re("/api/db/vip-members?limit=500");if(S!=null&&S.success&&S.data){const D=[...S.data].map((Y,ge)=>({...Y,vipSort:typeof Y.vipSort=="number"?Y.vipSort:ge+1}));D.sort((Y,ge)=>(Y.vipSort??999999)-(ge.vipSort??999999)),Te(D)}else S&&S.error&&G.error(S.error)}catch{G.error("加载超级个体列表失败")}finally{tt(!1)}},[]),[_i,Xa]=g.useState(!1),[xs,Za]=g.useState(null),[Kr,ei]=g.useState(""),[hr,Ys]=g.useState(!1),$i=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],Cr=S=>{Za(S),ei(S.vipRole||""),Xa(!0)},ya=async S=>{const D=S.trim();if(xs){if(!D){G.error("请选择或输入标签");return}Ys(!0);try{const Y=await Yt("/api/db/users",{id:xs.id,vipRole:D});if(!(Y!=null&&Y.success)){G.error((Y==null?void 0:Y.error)||"更新超级个体标签失败");return}G.success("已更新超级个体标签"),Xa(!1),Za(null),await ms()}catch{G.error("更新超级个体标签失败")}finally{Ys(!1)}}},[qr,Gr]=g.useState(!1),[Xs,gn]=g.useState(null),[Er,Zs]=g.useState(""),[ba,rl]=g.useState(!1),zi=S=>{gn(S),Zs(S.vipSort!=null?String(S.vipSort):""),Gr(!0)},Fi=async()=>{if(!Xs)return;const S=Number(Er);if(!Number.isFinite(S)){G.error("请输入有效的数字序号");return}rl(!0);try{const D=await Yt("/api/db/users",{id:Xs.id,vipSort:S});if(!(D!=null&&D.success)){G.error((D==null?void 0:D.error)||"更新排序序号失败");return}G.success("已更新排序序号"),Gr(!1),gn(null),await ms()}catch{G.error("更新排序序号失败")}finally{rl(!1)}},va=(S,D)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",D),ft(D)},Bi=(S,D)=>{S.preventDefault(),_e!==D&&U(D)},Vi=()=>{ft(null),U(null)},gd=async(S,D)=>{S.preventDefault();const Y=S.dataTransfer.getData("text/plain")||vt;if(ft(null),U(null),!Y||Y===D)return;const ge=Ne.find(Le=>Le.id===Y),Se=Ne.find(Le=>Le.id===D);if(!ge||!Se)return;const Oe=ge.vipSort??Ne.findIndex(Le=>Le.id===Y)+1,xt=Se.vipSort??Ne.findIndex(Le=>Le.id===D)+1;Te(Le=>{const wt=[...Le],Ht=wt.findIndex(dc=>dc.id===Y),Fn=wt.findIndex(dc=>dc.id===D);if(Ht===-1||Fn===-1)return Le;const fl=[...wt],[am,im]=[fl[Ht],fl[Fn]];return fl[Ht]={...im,vipSort:Oe},fl[Fn]={...am,vipSort:xt},fl});try{const[Le,wt]=await Promise.all([Yt("/api/db/users",{id:Y,vipSort:xt}),Yt("/api/db/users",{id:D,vipSort:Oe})]);if(!(Le!=null&&Le.success)||!(wt!=null&&wt.success)){G.error((Le==null?void 0:Le.error)||(wt==null?void 0:wt.error)||"更新排序失败"),await ms();return}G.success("已更新排序"),await ms()}catch{G.error("更新排序失败"),await ms()}},al=g.useCallback(async()=>{mt(!0);try{const S=await Re("/api/db/users/journey-stats");S!=null&&S.success&&S.stats&&yt(S.stats)}catch{}finally{mt(!1)}},[]),il=g.useCallback(async S=>{Mt(S),Ss(!0);try{const D=await Re(`/api/db/users/journey-users?stage=${S}&limit=50`);D!=null&&D.success&&D.users&&Nn(D.users)}catch{}finally{Ss(!1)}},[]),ol=g.useCallback(async(S,D)=>{da(S),Ba(D),Fr(!0);try{const Y=await Re(`/api/db/users/tracks?userId=${S}&limit=50`);Y!=null&&Y.success&&Y.tracks&&wr(Y.tracks)}catch{}finally{Fr(!1)}},[]),[ac,ic]=g.useState(!1),yd=async()=>{ic(!0);try{const S=await gt("/api/admin/shensheshou/batch-enrich",{limit:20});S!=null&&S.success?(G.success(`批量补全完成:${S.enriched} 人已补全,${S.skipped} 人跳过`),ps()):G.error((S==null?void 0:S.error)||"批量补全失败")}catch{G.error("批量补全请求失败")}finally{ic(!1)}},bd=S=>{const D=[S.phone,S.nickname,S.avatar,S.wechatId,S.mbti,S.industry,S.region,S.position],Y=D.filter(ge=>ge!=null&&ge!=="").length;return Math.round(Y/D.length*100)},{leadsRows:gs,leadsRawCount:oc,leadsDeduped:lc}=g.useMemo(()=>{const S=Le=>(Le||"").replace(/\D/g,"")||"",D=Le=>{const wt=S(Le.phone);if(wt)return`phone:${wt}`;const Ht=(Le.userId||"").trim();if(Ht)return`user:${Ht}`;const Fn=(Le.wechatId||"").trim();return Fn?`wechat:${Fn}`:`row:${Le.id}`},Y=Vr.trim().toLowerCase();let ge=dr;Y&&(ge=dr.filter(Le=>[Le.userNickname,Le.name,Le.phone,Le.wechatId,Le.personName,Le.source,Le.planApiKey].filter(Boolean).join(" ").toLowerCase().includes(Y)));const Se=[...ge].sort((Le,wt)=>{const Ht=Le.createdAt?new Date(Le.createdAt).getTime():0;return(wt.createdAt?new Date(wt.createdAt).getTime():0)-Ht});if(!fa)return{leadsRows:Se,leadsRawCount:ge.length,leadsDeduped:0};const Oe=new Set,xt=[];for(const Le of Se){const wt=D(Le);Oe.has(wt)||(Oe.add(wt),xt.push(Le))}return{leadsRows:xt,leadsRawCount:ge.length,leadsDeduped:ge.length-xt.length}},[dr,Vr,fa]);g.useEffect(()=>{const S=gs.map(ge=>ge.id),D=S.filter(ge=>ts.includes(ge)).length,Y=xa.current;Y&&(Y.indeterminate=D>0&&DY.id),D=S.length>0&&S.every(Y=>ts.includes(Y));zs(D?Y=>Y.filter(ge=>!S.includes(ge)):Y=>[...new Set([...Y,...S])])}function Nd(S){zs(D=>D.includes(S)?D.filter(Y=>Y!==S):[...D,S])}async function wd(){if(ts.length===0){G.info("请先勾选要删除的记录");return}const S=ts.length;if(!confirm(`确定批量删除选中的 ${S} 条获客记录?删除后不可恢复。`))return;const D=500;ma(!0);try{let Y=0;for(let ge=0;ge{const D=S||"";return D==="success"?s.jsx(Ve,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"已推送(存客宝已接收)"}):D==="pending_verify"?s.jsx(Ve,{className:"bg-sky-500/20 text-sky-300 border-0 text-xs",children:"待通过 / 处理中"}):D==="expired"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-300 border-0 text-xs",children:"已过期"}):D==="failed"?s.jsx(Ve,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):D==="pending"?s.jsx(Ve,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"}):D?s.jsx(Ve,{className:"bg-violet-500/20 text-violet-300 border-0 text-xs",title:D,children:D}):s.jsx(Ve,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"})},cl=g.useMemo(()=>{const S=new Map;for(const D of gs){if(D.pushStatus!=="failed")continue;const Y=(D.ckbError||"未知错误").trim()||"未知错误";S.set(Y,(S.get(Y)||0)+1)}return Array.from(S.entries()).map(([D,Y])=>({reason:D,count:Y})).sort((D,Y)=>Y.count-D.count)},[gs]);async function cc(){const S=gs.filter(Oe=>Oe.pushStatus==="failed");if(S.length===0){G.info("当前页无失败记录");return}const D=cl.slice(0,8).map(Oe=>`- ${Oe.reason}:${Oe.count} 条`).join(` +`),Y=S.slice(0,30).map(Oe=>Oe.id).join(", "),ge=S.slice(0,20).map(Oe=>`#${Oe.id} | ${Oe.userNickname||Oe.name||"-"} | 手机:${Oe.phone||"-"} | 来源:${Oe.source||"-"} | 重试:${Oe.retryCount??0} | 错误:${Oe.ckbError||"-"}`).join(` +`),Se=["【获客失败排障信息】",`时间:${new Date().toLocaleString()}`,`当前页失败总数:${S.length}`,"主要失败原因:",D||"- 无",`最近失败记录ID(最多30条):${Y||"无"}`,"","失败记录明细(最多20条):",ge||"无"].join(` +`);try{await navigator.clipboard.writeText(Se),G.success("已复制排障信息")}catch{G.error("复制失败,请检查浏览器剪贴板权限")}}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:()=>O(null),children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start gap-6 mb-6 flex-wrap",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",u," 位注册用户",Qs!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Qs," 人"]}),X&&" · RFM 排序中"]})]}),s.jsx($e,{className:"shrink-0 w-full max-w-md border-[#38bdac]/35 bg-[#0f2137]/90",children:s.jsxs(ze,{className:"p-3 sm:p-4 space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>se(S=>!S),className:"flex items-center gap-2 min-w-0 flex-1 text-left rounded-lg px-1 py-0.5 hover:bg-white/5 transition-colors","aria-expanded":_,children:[s.jsx(Cf,{className:"w-5 h-5 text-[#38bdac] shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-semibold text-white",children:"算法配置"}),s.jsx("div",{className:"text-xs text-gray-500 truncate",children:_?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),_?s.jsx(Dg,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(Ti,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:dn,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:X?ce==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),_&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-xs text-gray-400 leading-relaxed",children:["综合分 0–100(六维度):最近消费 R(25%)+ 订单频次 F(20%)+ 累计金额 M(20%)+ 推荐人数(15%)+ 行为轨迹(10%)+ 资料完善(10%)。各维度在全量用户中归一化,与后端"," ",s.jsx("code",{className:"text-gray-500",children:"/api/db/users/rfm"})," 一致。"]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:w8.map(({level:S,range:D,label:Y})=>s.jsxs(Ve,{variant:"outline",className:`text-[10px] border-0 ${sl(S)}`,children:[S," ",D," · ",Y]},S))})]})]})})]}),s.jsxs(Vl,{value:a,onValueChange:S=>{const D=new URLSearchParams(t);S==="users"?D.delete("tab"):D.set("tab",S),e(D)},className:"w-full",children:[s.jsxs(Do,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Bt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Vn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Bt,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>pt(),children:[s.jsx(Uc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Bt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:al,children:[s.jsx(na,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Bt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Bs,children:[s.jsx(vo,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Bt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ms,children:[s.jsx(Kc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Vt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(J,{variant:"outline",onClick:yd,disabled:ac,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[ac?s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ro,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(J,{variant:"outline",onClick:()=>ps(!0),disabled:W,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${W?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:M,onChange:S=>{const D=S.target.value;E(D),m(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:X,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(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:N,onChange:S=>w(S.target.value)})]}),s.jsxs(J,{onClick:rc,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Uc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:L?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"用户信息"}),s.jsx(ke,{className:"text-gray-400",children:"绑定信息"}),s.jsx(ke,{className:"text-gray-400",children:"购买状态"}),s.jsx(ke,{className:"text-gray-400",children:"分销收益"}),s.jsxs(ke,{className:"text-gray-400 cursor-pointer select-none",onClick:dn,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Cf,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),X?ce==="desc"?s.jsx(Ti,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Dg,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Ix,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),X&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(ke,{className:"text-gray-400",children:"资料完善"}),s.jsx(ke,{className:"text-gray-400",children:"注册时间"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[o.map(S=>{var D,Y,ge;return s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var xt;const Se=Sr(S.avatar,S.mbti),Oe=((xt=S.nickname)==null?void 0:xt.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>vn(!0),className:"w-10 h-10 shrink-0 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] overflow-hidden ring-1 ring-transparent hover:ring-[#38bdac]/60 transition",children:Se?s.jsx("img",{src:Se,className:"w-full h-full rounded-full object-cover",alt:"",onError:Le=>{var Fn;const wt=Le.target;if(wt.style.display="none",wt.nextElementSibling)return;const Ht=document.createElement("span");Ht.textContent=Oe,(Fn=wt.parentElement)==null||Fn.appendChild(Ht)}}):Oe})})(),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{Ue(S.id),we(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:S.nickname}),S.isAdmin&&s.jsx(Ve,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),S.openId&&!((D=S.id)!=null&&D.startsWith("user_"))&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate max-w-[140px]",title:S.id,children:[(Y=S.id)==null?void 0:Y.slice(0,16),(((ge=S.id)==null?void 0:ge.length)??0)>16?"…":""]})]})]})}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[S.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:S.phone})]}),S.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:S.wechatId})]}),!S.phone&&!S.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(je,{children:(()=>{const Se=Ka(S);return Se.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:Se.main}),Se.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:Se.sub})]}):Se.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:Se.main}),Se.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:Se.sub})]}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:Se.main})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(S.earnings||0)).toFixed(2)]}),parseFloat(String(S.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(S.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Ja(S),role:"button",tabIndex:0,onKeyDown:Se=>Se.key==="Enter"&&Ja(S),children:[s.jsx(Vn,{className:"w-3 h-3"})," 绑定",S.referralCount||0,"人"]})]})}),s.jsx(je,{children:S.rfmScore!=null&&S.rfmScore!==void 0?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:S.rfmScore}),s.jsx(Ve,{className:`border-0 text-xs ${sl(S.rfmLevel)}`,children:S.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(je,{children:(()=>{const Se=bd(S),Oe=Se>=75?"text-green-400":Se>=50?"text-yellow-400":"text-gray-500";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-12 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${Se>=75?"bg-green-500":Se>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${Se}%`}})}),s.jsxs("span",{className:`text-xs ${Oe}`,children:[Se,"%"]})]})})()}),s.jsx(je,{className:"text-gray-400",children:S.createdAt?new Date(S.createdAt).toLocaleDateString():"-"}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{Ue(S.id),we(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(Sf,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Wr(S),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Ga(S.id),title:"删除",children:s.jsx(Jn,{className:"w-4 h-4"})})]})})]},S.id)}),o.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(us,{page:f,totalPages:qa,total:u,pageSize:x,onPageChange:m,onPageSizeChange:S=>{b(S),m(1)}})]})})})]}),s.jsxs(Vt,{value:"leads",children:[kr&&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:kr}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Br(null),"aria-label":"关闭",children:"×"})]}),!en&&s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"线索总条数(含留资/加入/匹配)"}),s.jsx("p",{className:"text-xl font-bold text-white",children:ua})]}),s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"去重用户数(按 userId)"}),s.jsx("p",{className:"text-xl font-bold text-[#38bdac]",title:"后端 COUNT(DISTINCT user_id)",children:$s.uniqueUsers??0})]}),($s.sourceStats&&$s.sourceStats.length>0?$s.sourceStats.slice(0,2):[]).map(S=>s.jsxs("div",{className:"p-3 bg-[#0f2137] border border-gray-700/50 rounded-lg",children:[s.jsxs("p",{className:"text-gray-500 text-xs",children:["来源:",S.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:S.cnt})]},S.source))]}),!en&&cl.length>0&&s.jsx($e,{className:"bg-[#3a1010]/35 border-red-900/60 shadow-lg mb-4",children:s.jsxs(ze,{className:"p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-red-200 font-medium",children:"失败原因聚合"}),s.jsx("p",{className:"text-red-300/70 text-xs",children:"基于当前页筛选结果,按失败原因聚合统计"})]}),s.jsx(J,{type:"button",variant:"outline",onClick:cc,className:"border-red-600/70 text-red-200 hover:bg-red-500/10 bg-transparent",children:"一键复制排障信息"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:cl.slice(0,8).map(S=>s.jsxs(Ve,{className:"bg-red-500/15 text-red-200 border border-red-600/40",children:[S.reason," · ",S.count]},S.reason))})]})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[200px]",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索昵称/手机/微信/@人/来源/类型…",value:Nt,onChange:S=>$n(S.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),$s.sourceStats&&$s.sourceStats.length>0&&s.jsxs("select",{value:ha,onChange:S=>{cn(S.target.value),Pt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),$s.sourceStats.map(S=>s.jsxs("option",{value:S.source,children:[S.source,"(",S.cnt,")"]},S.source))]}),s.jsxs("select",{value:Hr,onChange:S=>{const D=S.target.value;Va(D),Pt(1),e(Y=>{const ge=new URLSearchParams(Y);return ge.set("tab","leads"),D?ge.set("leadAction",D):ge.delete("leadAction"),ge})},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",title:"按业务类型筛选",children:[s.jsx("option",{value:"",children:"全部类型"}),s.jsx("option",{value:"lead",children:"留资线索(文章@ / 首页链接)"}),s.jsx("option",{value:"join",children:"加入报名(导师 / 资源对接 / 团队)"}),s.jsx("option",{value:"match",children:"匹配上报(找伙伴匹配)"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-gray-400 select-none bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2",children:[s.jsx("input",{type:"checkbox",checked:fa,onChange:S=>Ha(S.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"}),"去重展示"]}),s.jsxs("select",{value:ur,onChange:S=>{Cs(S.target.value),Pt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待推送"}),s.jsx("option",{value:"success",children:"已推送(存客宝已接收)"}),s.jsx("option",{value:"pending_verify",children:"待通过 / 处理中"}),s.jsx("option",{value:"expired",children:"已过期"}),s.jsx("option",{value:"failed",children:"推送失败"})]}),s.jsx(J,{type:"button",variant:"outline",onClick:()=>{Cs("failed"),Pt(1)},className:"border-red-600/60 text-red-300 hover:bg-red-500/10 bg-transparent text-xs h-9",children:"只看失败"}),s.jsxs("span",{className:"text-xs text-gray-500 whitespace-nowrap max-w-[min(100%,20rem)]",title:"同一页内:相同手机号或相同用户 ID(含微信侧标识)只保留最近一条",children:["本页 ",oc," 条",lc>0?` · 已合并 ${lc} 条重复`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(J,{variant:"outline",onClick:tl,disabled:en,className:"border-cyan-600/60 text-cyan-300 hover:bg-cyan-500/10 bg-transparent",children:"导出失败清单"}),s.jsxs(J,{variant:"outline",onClick:el,disabled:Yo||Js||en,className:"border-amber-600/60 text-amber-300 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${Yo?"animate-spin":""}`}),"重推本页失败项"]}),s.jsxs(J,{variant:"outline",onClick:()=>void wd(),disabled:Js||ts.length===0||en,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Jn,{className:`w-4 h-4 mr-2 ${Js?"animate-pulse":""}`}),Js?"删除中…":`批量删除(${ts.length})`]}),s.jsxs(J,{variant:"outline",onClick:()=>pt(),disabled:en,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${en?"animate-spin":""}`})," 刷新"]})]})]}),!en&&gs.length>0&&s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["已选 ",s.jsx("span",{className:"text-[#38bdac]",children:ts.length})," 条 · 可翻页继续勾选 · 改搜索/筛选会清空选择",ts.length>0&&s.jsx("button",{type:"button",className:"ml-2 text-gray-400 hover:text-gray-200 underline",onClick:()=>zs([]),children:"清空"})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:en?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-10 text-center",children:s.jsx("input",{ref:xa,type:"checkbox",checked:gs.length>0&&gs.every(S=>ts.includes(S.id)),onChange:vd,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页(展示行)"})}),s.jsx(ke,{className:"text-gray-400",children:"昵称"}),s.jsx(ke,{className:"text-gray-400",children:"手机号"}),s.jsx(ke,{className:"text-gray-400",children:"微信号"}),s.jsx(ke,{className:"text-gray-400",children:"对应 @人"}),s.jsx(ke,{className:"text-gray-400",children:"获客计划(Key)"}),s.jsx(ke,{className:"text-gray-400",children:"推送状态"}),s.jsx(ke,{className:"text-gray-400",children:"时间"}),s.jsx(ke,{className:"text-gray-400",children:"重试"})]})}),s.jsxs(ds,{children:[gs.map(S=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{className:"text-center align-middle w-10",children:s.jsx("input",{type:"checkbox",checked:ts.includes(S.id),onChange:()=>Nd(S.id),disabled:Js,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"})}),s.jsx(je,{className:"text-gray-300 align-middle",children:s.jsx(j8,{userId:S.userId,userAvatar:S.userAvatar,nickname:S.userNickname,name:S.name,onOpenDetail:D=>{Ue(D),we(!0)}})}),s.jsx(je,{className:"text-gray-300",children:S.phone||"-"}),s.jsx(je,{className:"text-gray-300",children:S.wechatId||"-"}),s.jsx(je,{className:"text-[#38bdac]",children:S.personName||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:(()=>{const D=(S.planApiKey||"").trim();if(!D)return"-";const Y=D.length<=10?D:`${D.slice(0,6)}…${D.slice(-4)}`;return s.jsx("button",{type:"button",className:"font-mono text-gray-400 hover:text-gray-200 underline decoration-dotted",title:D,onClick:async()=>{try{await navigator.clipboard.writeText(D),G.success("已复制计划Key")}catch{G.error("复制失败,请手动复制")}},children:Y})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[ll(S.pushStatus),(typeof S.ckbCode=="number"||(S.ckbMessage||"").trim())&&s.jsx("p",{className:"text-[11px] text-gray-500 max-w-[260px] truncate",title:[typeof S.ckbCode=="number"?`code=${S.ckbCode}`:"",(S.ckbMessage||"").trim()?`message=${String(S.ckbMessage).trim()}`:"",(S.ckbData||"").trim()?`data=${String(S.ckbData).trim()}`:""].filter(Boolean).join(" | "),children:[typeof S.ckbCode=="number"?`code=${S.ckbCode}`:"",(S.ckbMessage||"").trim()?String(S.ckbMessage).trim():""].filter(Boolean).join(" · ")}),!!(S.ckbData||"").trim()&&s.jsx("button",{type:"button",className:"text-[11px] text-sky-300/90 hover:text-sky-200 underline decoration-dotted",onClick:()=>{const D=String(S.ckbData||"").trim();Wa(`存客宝返回 data(#${S.id})`),Xo(k8(D)),Li(!0)},children:"查看 data"}),!!S.ckbError&&s.jsx("p",{className:"text-[11px] text-red-300 max-w-[220px] truncate",title:S.ckbError,children:S.ckbError})]})}),s.jsx(je,{className:"text-gray-400 whitespace-nowrap",children:S.createdAt?new Date(S.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-gray-400 text-xs align-top py-3 min-w-[148px]",children:s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("p",{className:"text-gray-400 leading-snug",children:typeof S.retryCount=="number"?`第 ${S.retryCount} 次`:"-"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(J,{size:"sm",variant:"outline",disabled:Js||pa===S.id||Ur===S.id,onClick:()=>sc(S.id),className:"h-8 px-2.5 text-[11px] border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-3 h-3 mr-1 ${pa===S.id?"animate-spin":""}`}),"重推"]}),s.jsxs(J,{size:"sm",variant:"outline",disabled:Js||Ur===S.id||pa===S.id,onClick:()=>Di(S.id),className:"h-8 px-2.5 text-[11px] border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent shrink-0",children:[s.jsx(Jn,{className:`w-3 h-3 mr-1 ${Ur===S.id?"animate-pulse":""}`}),"删除"]})]})]})})]},S.id)),gs.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:9,className:"p-0 align-top",children:s.jsxs("div",{className:"py-16 px-6 text-center border-t border-gray-700/40 bg-[#0a1628]/30",children:[s.jsx(Uc,{className:"w-14 h-14 text-[#38bdac]/20 mx-auto mb-4","aria-hidden":!0}),s.jsx("p",{className:"text-gray-200 font-medium mb-1",children:"暂无获客线索"}),s.jsx("p",{className:"text-gray-500 text-sm mb-6 max-w-md mx-auto leading-relaxed",children:Vr.trim()||ha?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>pt(),disabled:en,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${en?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(us,{page:ve,totalPages:Math.ceil(ua/Qt)||1,total:ua,pageSize:Qt,onPageChange:Pt,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Vt,{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(J,{variant:"outline",onClick:al,disabled:$t,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${$t?"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:Lc.map((S,D)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${S.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${lt===S.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>il(S.id),title:`点击查看「${S.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:S.icon}),s.jsx("div",{className:`text-xs font-medium ${S.color.split(" ").find(Y=>Y.startsWith("text-"))}`,children:S.label}),qe[S.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:qe[S.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:D+1})]}),Ds.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:S.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:S.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",S.next]})]})]},S.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(or,{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:"实时更新"})]}),$t?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(qe).length>0?s.jsx("div",{className:"space-y-2",children:(()=>{const S=Lc.reduce((D,Y)=>D+(qe[Y.id]||0),0);return Lc.map(D=>{const Y=qe[D.id]||0,ge=S>0?Math.round(Y/S*100):0,Se=Y>0?Math.max(ge,6):0;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-[5.5rem] shrink-0 leading-tight",children:[D.icon," ",D.label]}),s.jsx("div",{className:"flex-1 h-2.5 bg-[#0a1628] rounded-full overflow-hidden border border-gray-700/40",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-[#38bdac]/50 to-[#38bdac] transition-all",style:{width:`${Se}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-14 text-right tabular-nums",children:Y}),s.jsx("span",{className:"text-gray-600 text-[10px] w-8 text-right tabular-nums",children:S>0?`${ge}%`:"—"})]},D.id)})})()}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),lt&&s.jsxs("div",{className:"mt-6 bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",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(Vn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(Hi=Lc.find(S=>S.id===lt))==null?void 0:Hi.icon," ",(Ui=Lc.find(S=>S.id===lt))==null?void 0:Ui.label," 阶段用户"]}),s.jsxs(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Wt.length," 人"]})]}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Mt(null),className:"text-gray-400 hover:text-white",children:s.jsx(Qn,{className:"w-4 h-4"})})]}),ks?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Wt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"昵称"}),s.jsx(ke,{className:"text-gray-400",children:"手机号"}),s.jsx(ke,{className:"text-gray-400",children:"注册时间"}),s.jsx(ke,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(ds,{children:Wt.map(S=>s.jsxs(ht,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(je,{className:"text-white",children:S.nickname||"微信用户"}),s.jsx(je,{className:"text-gray-300",children:S.phone||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:S.createdAt?new Date(S.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(je,{className:"text-right",children:s.jsxs(J,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>ol(S.id,S.nickname||"微信用户"),children:[s.jsx(Sf,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},S.id))})]})]}),s.jsx(It,{open:!!Ri,onOpenChange:S=>{S||da(null)},children:s.jsxs(At,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(na,{className:"w-5 h-5 text-[#38bdac]"}),Fa," 的行为轨迹"]})}),jr?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Nr.length===0?s.jsx("p",{className:"text-gray-500 text-center py-8",children:"该用户暂无行为记录"}):s.jsxs("div",{className:"relative pl-6 space-y-0",children:[s.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-0.5 bg-gray-700"}),Nr.map((S,D)=>s.jsxs("div",{className:"relative flex items-start gap-3 py-2",children:[s.jsx("div",{className:"absolute left-[-13px] top-3 w-2.5 h-2.5 rounded-full bg-[#38bdac] border-2 border-[#0f2137] z-10"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-white text-sm font-medium",children:S.actionLabel}),S.module&&s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:S.module})]}),(S.chapterTitle||S.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:S.chapterTitle||S.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[S.timeAgo," · ",S.createdAt?new Date(S.createdAt).toLocaleString("zh-CN"):""]})]})]},S.id||D))]})]})})]}),s.jsxs(Vt,{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(J,{variant:"outline",onClick:Bs,disabled:Zt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${Zt?"animate-spin":""}`})," 刷新"]}),s.jsxs(J,{onClick:()=>{Xn(null),xn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),Sn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),Zt?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):ln.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(or,{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(J,{onClick:Bs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(He,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:ln.map(S=>{var Y;const D=M2(S.triggerConditions);return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${S.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsxs("span",{className:"text-gray-600 text-xs font-mono w-5 shrink-0 text-right",children:["#",S.sort]}),s.jsx(pn,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:S.title}),S.trigger&&s.jsx(Ve,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:S.trigger}),D.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[D.slice(0,3).map(ge=>{const Se=lN.find(Oe=>Oe.value===ge);return s.jsx(Ve,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(Se==null?void 0:Se.label)||ge},ge)}),D.length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",D.length-3]})]}),S.actionType&&S.actionType!=="popup"&&s.jsx(Ve,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((Y=cN.find(ge=>ge.value===S.actionType))==null?void 0:Y.label)||S.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx(Ut,{checked:S.enabled,onCheckedChange:()=>Ya(S)}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>{Xn(S),xn({title:S.title,description:S.description,trigger:S.trigger,triggerConditions:D,actionType:S.actionType||"popup",sort:S.sort,enabled:S.enabled}),Sn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Qa(S.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),S.description&&s.jsxs("details",{className:"ml-[52px] mt-1",children:[s.jsxs("summary",{className:"text-gray-500 text-xs cursor-pointer hover:text-gray-400 select-none",children:["查看完整描述",s.jsxs("span",{className:"text-gray-600 ml-1",children:["(",S.description.length," 字,默认折叠)"]})]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1 pl-1 border-l-2 border-gray-700 whitespace-pre-wrap",children:S.description})]})]},S.id)})})]}),s.jsxs(Vt,{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.jsxs("p",{className:"text-xs text-gray-500",children:["飞书群 Webhook(按人推线索到飞书)已迁至"," ",s.jsx("span",{className:"text-[#38bdac]",children:"内容管理 → 链接人与事 → @列表"}),",在绑定会员的人物行操作栏配置。"]}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(J,{variant:"outline",onClick:ms,disabled:We,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${We?"animate-spin":""}`})," ","刷新"]})})]}),We?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Ne.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Kc,{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($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(ke,{className:"text-gray-400",children:"成员"}),s.jsx(ke,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(ke,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(ke,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(ke,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(ke,{className:"text-gray-400 w-28 text-right",children:"操作"})]})}),s.jsx(ds,{children:Ne.map((S,D)=>{var Se;const Y=vt===S.id,ge=_e===S.id;return s.jsxs(ht,{draggable:!0,onDragStart:Oe=>va(Oe,S.id),onDragOver:Oe=>Bi(Oe,S.id),onDrop:Oe=>gd(Oe,S.id),onDragEnd:Vi,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${Y?"opacity-60":""} ${ge?"bg-[#38bdac]/10":""}`,children:[s.jsx(je,{className:"text-gray-300",children:D+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Sr(S.avatar,S.mbti)?s.jsx("img",{src:Sr(S.avatar,S.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:Oe=>{var Le,wt;Oe.target.style.display="none";const xt=document.createElement("div");xt.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",xt.textContent=((Le=S.name)==null?void 0:Le[0])||"创",(wt=Oe.target.parentElement)==null||wt.appendChild(xt)}}):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:((Se=S.name)==null?void 0:Se[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:S.name})})]})}),s.jsx(je,{className:"text-gray-300 whitespace-nowrap",children:S.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(je,{className:"text-center text-blue-400 text-xs font-mono",children:S.clickCount!=null?String(S.clickCount):"-"}),s.jsx(je,{className:"text-center text-green-400 text-xs font-mono",children:S.leadCount!=null?String(S.leadCount):"-"}),s.jsx(je,{className:"text-gray-300",children:S.vipSort??D+1}),s.jsx(je,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>Cr(S),title:"设置超级个体标签",children:s.jsx(lu,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>zi(S),title:"设置排序序号",children:s.jsx(Ix,{className:"w-3.5 h-3.5"})})]})})]},S.id)})})]})})})]})]}),s.jsx(It,{open:bt,onOpenChange:vn,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(Rt,{children:s.jsx(Lt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(v8,{})]})}),s.jsx(It,{open:qr,onOpenChange:S=>{Gr(S),S||gn(null)},children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ix,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",Xs==null?void 0:Xs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Er,onChange:S=>Zs(S.target.value)})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Gr(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:Fi,disabled:ba,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ba?"保存中...":"保存"]})]})]})}),s.jsx(It,{open:_i,onOpenChange:S=>{Xa(S),S||Za(null)},children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(Kc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",xs==null?void 0:xs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:$i.map(S=>s.jsx(J,{variant:Kr===S?"default":"outline",size:"sm",className:Kr===S?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>ei(S),children:S},S))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Kr,onChange:S=>ei(S.target.value)})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Xa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:()=>ya(Kr),disabled:hr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),hr?"保存中...":"保存"]})]})]})}),s.jsx(It,{open:I,onOpenChange:Z,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[V?s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Uc,{className:"w-5 h-5 text-[#38bdac]"}),V?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"手机号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:dt.phone,onChange:S=>Tt({...dt,phone:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"昵称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:dt.nickname,onChange:S=>Tt({...dt,nickname:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:V?"新密码 (留空则不修改)":"密码"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:V?"留空则不修改":"请输入密码",value:dt.password,onChange:S=>Tt({...dt,password:S.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ne,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Ut,{checked:dt.isAdmin,onCheckedChange:S=>Tt({...dt,isAdmin:S})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(ne,{className:"text-gray-300",children:"已购全书"}),s.jsx(Ut,{checked:dt.hasFullBook,onCheckedChange:S=>Tt({...dt,hasFullBook:S})})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Z(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:ns,disabled:ee,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ee?"保存中...":"保存"]})]})]})}),s.jsx(It,{open:mn,onOpenChange:Sn,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),_n?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Ot.title,onChange:S=>xn({...Ot,title:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"规则描述"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:Ot.description,onChange:S=>xn({...Ot,description:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(S=>{const D=lN.filter(Y=>Y.group===S);return D.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:S}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:D.map(Y=>{const ge=(Ot.triggerConditions||[]).includes(Y.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${ge?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const Se=Ot.triggerConditions||[],Oe=ge?Se.filter(xt=>xt!==Y.value):[...Se,Y.value];xn({...Ot,triggerConditions:Oe})},children:Y.label},Y.value)})})]},S)})}),(Ot.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(Ot.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"与小程序一致:注册、完成付款、update_avatar、update_nickname 等",value:Ot.trigger,onChange:S=>xn({...Ot,trigger:S.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:cN.map(S=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${Ot.actionType===S.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>xn({...Ot,actionType:S.value}),children:[s.jsx("span",{className:`text-xs font-medium ${Ot.actionType===S.value?"text-[#38bdac]":"text-gray-300"}`,children:S.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:S.desc})]},S.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(ne,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Ut,{checked:Ot.enabled,onCheckedChange:S=>xn({...Ot,enabled:S})})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>Sn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:xd,disabled:ee,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ee?"保存中...":"保存"]})]})]})}),s.jsx(It,{open:K,onOpenChange:fe,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",z==null?void 0:z.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:((dl=he.stats)==null?void 0:dl.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:((ul=he.stats)==null?void 0:ul.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:["¥",(((hl=he.stats)==null?void 0:hl.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:["¥",(((T=he.stats)==null?void 0:T.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(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((F=he.referrals)==null?void 0:F.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(he.referrals??[]).map((S,D)=>{var ge;const Y=S;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:((ge=Y.nickname)==null?void 0:ge.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:Y.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:Y.phone||(Y.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Y.status==="vip"&&s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Y.status==="paid"&&s.jsxs(Ve,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Y.purchasedSections,"章"]}),Y.status==="free"&&s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:Y.createdAt?new Date(Y.createdAt).toLocaleDateString():""})]})]},Y.id||D)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(Xt,{children:s.jsx(J,{variant:"outline",onClick:()=>fe(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(cy,{open:ie,onClose:()=>we(!1),userId:Be,onUserUpdated:ps}),s.jsx(It,{open:Ua,onOpenChange:Li,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700/60 text-white max-w-2xl",children:[s.jsx(Rt,{children:s.jsx(Lt,{className:"text-white",children:Oi})}),s.jsx("div",{className:"mt-2",children:s.jsx("pre",{className:"text-xs text-gray-200 bg-[#0a1628] border border-gray-700/60 rounded-lg p-3 max-h-[520px] overflow-auto whitespace-pre-wrap break-words",children:ga||"—"})}),s.jsxs(Xt,{children:[s.jsx(J,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 hover:bg-gray-700/50 bg-transparent",onClick:async()=>{try{await navigator.clipboard.writeText(ga||""),G.success("已复制 data")}catch{G.error("复制失败,请手动复制")}},disabled:!ga,children:"复制 data"}),s.jsx(J,{type:"button",className:"bg-[#38bdac] hover:bg-[#2aa896] text-white",onClick:()=>Li(!1),children:"关闭"})]})]})})]})}function Pf(t,[e,n]){return Math.min(n,Math.max(e,t))}var A2=["PageUp","PageDown"],P2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],I2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ud="Slider",[qg,C8,E8]=ay(ud),[R2]=Ho(ud,[E8]),[T8,Op]=R2(ud),L2=g.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:x=()=>{},inverted:b=!1,form:N,...w}=t,v=g.useRef(new Set),k=g.useRef(0),E=o==="horizontal"?M8:A8,[L=[],R]=Fl({prop:f,defaultProp:h,onChange:ae=>{var se;(se=[...v.current][k.current])==null||se.focus(),m(ae)}}),W=g.useRef(L);function P(ae){const _=O8(L,ae);X(ae,_)}function B(ae){X(ae,k.current)}function O(){const ae=W.current[k.current];L[k.current]!==ae&&x(L)}function X(ae,_,{commit:se}={commit:!1}){const ce=z8(i),me=F8(Math.round((ae-r)/i)*i+r,ce),I=Pf(me,[r,a]);R((Z=[])=>{const V=R8(Z,I,_);if($8(V,u*i)){k.current=V.indexOf(I);const xe=String(V)!==String(Z);return xe&&se&&x(V),xe?V:Z}else return Z})}return s.jsx(T8,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:k,thumbs:v.current,values:L,orientation:o,form:N,children:s.jsx(qg.Provider,{scope:t.__scopeSlider,children:s.jsx(qg.Slot,{scope:t.__scopeSlider,children:s.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:jt(w.onPointerDown,()=>{c||(W.current=L)}),min:r,max:a,inverted:b,onSlideStart:c?void 0:P,onSlideMove:c?void 0:B,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&X(r,0,{commit:!0}),onEndKeyDown:()=>!c&&X(a,L.length-1,{commit:!0}),onStepKeyDown:({event:ae,direction:_})=>{if(!c){const me=A2.includes(ae.key)||ae.shiftKey&&P2.includes(ae.key)?10:1,I=k.current,Z=L[I],V=i*me*_;X(Z+V,I,{commit:!0})}}})})})})});L2.displayName=ud;var[O2,D2]=R2(ud,{startEdge:"left",endEdge:"right",size:"width",direction:1}),M8=g.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,x]=g.useState(null),b=Jt(e,E=>x(E)),N=g.useRef(void 0),w=Ip(a),v=w==="ltr",k=v&&!i||!v&&i;function M(E){const L=N.current||m.getBoundingClientRect(),R=[0,L.width],P=dy(R,k?[n,r]:[r,n]);return N.current=L,P(E-L.left)}return s.jsx(O2,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:s.jsx(_2,{dir:w,"data-orientation":"horizontal",...f,ref:b,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const L=M(E.clientX);o==null||o(L)},onSlideMove:E=>{const L=M(E.clientX);c==null||c(L)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:E=>{const R=I2[k?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:R?-1:1})}})})}),A8=g.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=g.useRef(null),m=Jt(e,f),x=g.useRef(void 0),b=!a;function N(w){const v=x.current||f.current.getBoundingClientRect(),k=[0,v.height],E=dy(k,b?[r,n]:[n,r]);return x.current=v,E(w-v.top)}return s.jsx(O2,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:s.jsx(_2,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const v=N(w.clientY);i==null||i(v)},onSlideMove:w=>{const v=N(w.clientY);o==null||o(v)},onSlideEnd:()=>{x.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=I2[b?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),_2=g.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Op(ud,n);return s.jsx(Ct.span,{...h,ref:e,onKeyDown:jt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):A2.concat(P2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:jt(t.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(x)?x.focus():r(m)}),onPointerMove:jt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:jt(t.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),i(m))})})}),$2="SliderTrack",z2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Op($2,n);return s.jsx(Ct.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});z2.displayName=$2;var Gg="SliderRange",F2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Op(Gg,n),i=D2(Gg,n),o=g.useRef(null),c=Jt(e,o),u=a.values.length,h=a.values.map(x=>H2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(Ct.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});F2.displayName=Gg;var Jg="SliderThumb",B2=g.forwardRef((t,e)=>{const n=C8(t.__scopeSlider),[r,a]=g.useState(null),i=Jt(e,c=>a(c)),o=g.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(P8,{...t,ref:i,index:o})}),P8=g.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=Op(Jg,n),c=D2(Jg,n),[u,h]=g.useState(null),f=Jt(e,M=>h(M)),m=u?o.form||!!u.closest("form"):!0,x=ly(u),b=o.values[r],N=b===void 0?0:H2(b,o.min,o.max),w=L8(r,o.values.length),v=x==null?void 0:x[c.size],k=v?D8(v,N,c.direction):0;return g.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(${N}% + ${k}px)`},children:[s.jsx(qg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(Ct.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":o.min,"aria-valuenow":b,"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:b===void 0?{display:"none"}:t.style,onFocus:jt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(V2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});B2.displayName=Jg;var I8="RadioBubbleInput",V2=g.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=g.useRef(null),i=Jt(a,r),o=oy(e);return g.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(Ct.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});V2.displayName=I8;function R8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function H2(t,e,n){const i=100/(n-e)*(t-e);return Pf(i,[0,100])}function L8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function O8(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 D8(t,e,n){const r=t/2,i=dy([0,50],[0,r]);return(r-i(e)*n)*n}function _8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function $8(t,e){if(e>0){const n=_8(t);return Math.min(...n)>=e}return!0}function dy(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 z8(t){return(String(t).split(".")[1]||"").length}function F8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var B8=L2,V8=z2,H8=F2,U8=B2;function W8({className:t,defaultValue:e,value:n,min:r=0,max:a=100,...i}){const o=g.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,a],[n,e,r,a]);return s.jsxs(B8,{defaultValue:e,value:n,min:r,max:a,className:_t("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(V8,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(H8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(U8,{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 K8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function U2(t){const e=!!(t!=null&&t.embedded),[n,r]=g.useState(K8),[a,i]=g.useState(!0),[o,c]=g.useState(!1);g.useEffect(()=>{Re("/api/admin/referral-settings").then(f=>{const m=f==null?void 0:f.data;m&&typeof m=="object"&&r({distributorShare:m.distributorShare??90,minWithdrawAmount:m.minWithdrawAmount??10,bindingDays:m.bindingDays??30,userDiscount:m.userDiscount??5,withdrawFee:m.withdrawFee??5,enableAutoWithdraw:m.enableAutoWithdraw??!1,vipOrderShareVip:m.vipOrderShareVip??20,vipOrderShareNonVip:m.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>i(!1))},[]);const u=async()=>{c(!0);try{const f={distributorShare:Number(n.distributorShare)||0,minWithdrawAmount:Number(n.minWithdrawAmount)||0,bindingDays:Number(n.bindingDays)||0,userDiscount:Number(n.userDiscount)||0,withdrawFee:Number(n.withdrawFee)??5,enableAutoWithdraw:!!n.enableAutoWithdraw,vipOrderShareVip:Number(n.vipOrderShareVip)||20,vipOrderShareNonVip:Number(n.vipOrderShareNonVip)||10},m=await gt("/api/admin/referral-settings",f);if(!m||m.success===!1){G.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}G.success(`✅ 分销配置已保存成功! • 小程序与网站的推广规则会一起生效 • 绑定关系会使用新的天数配置 • 佣金比例会立即应用到新订单 -如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),G.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const x=parseFloat(m.target.value||"0");r(b=>({...b,[f]:isNaN(x)?0:x}))};return a?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:e?"p-4 w-full":"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(Yc,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(Si,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(J,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[s.jsx(nA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(qt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx($e,{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(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fh,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.userDiscount,onChange:h("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Vn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(W8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(le,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:n.distributorShare,onChange:h("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[n.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareVip,onChange:h("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareNonVip,onChange:h("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Vn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(le,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[s.jsx(Yc,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(qt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx($e,{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(ne,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(le,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:n.minWithdrawAmount,onChange:h("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(le,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:n.withdrawFee,onChange:h("withdrawFee")}),s.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Ve,{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(Ht,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(it,{children:s.jsxs(ot,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(Fh,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs($e,{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 q8(){const[t]=q0(),e=_a(),[n,r]=g.useState("overview"),[a,i]=g.useState("orders"),[o,c]=g.useState([]),[u,h]=g.useState(null),[f,m]=g.useState([]),[x,b]=g.useState([]),[N,w]=g.useState([]),[v,k]=g.useState(!0),[M,E]=g.useState(null),[L,R]=g.useState(""),[W,P]=g.useState("all"),[B,O]=g.useState(1),[Y,ae]=g.useState(10),[_,se]=g.useState(0),[ce,me]=g.useState(new Set),[I,X]=g.useState(null),[V,xe]=g.useState(""),[ee,H]=g.useState(!1),[K,fe]=g.useState(null),[he,ue]=g.useState(""),[$,Q]=g.useState(!1),[z,te]=g.useState(!1),[ie,we]=g.useState(!1),[Be,Ue]=g.useState([]),[yt,vn]=g.useState(1),[dt,Et]=g.useState(0),[on,Dn]=g.useState("");g.useEffect(()=>{t.get("tab")==="leads"&&e("/users?tab=leads",{replace:!0})},[t,e]),g.useEffect(()=>{ln()},[]),g.useEffect(()=>{const U=t.get("tab");(U==="overview"||U==="orders"||U==="bindings"||U==="withdrawals"||U==="settings")&&r(U)},[t]),g.useEffect(()=>{O(1)},[n,W]),g.useEffect(()=>{Ut(n)},[n]),g.useEffect(()=>{if(n==="orders"&&a==="giftpay"){Ut("giftPay",!0);return}["orders","bindings","withdrawals"].includes(n)&&Ut(n,!0)},[B,Y,W,L,n,a,yt,on]),g.useEffect(()=>{n==="withdrawals"&&Lt()},[n]);async function ln(){E(null);try{const U=await Re("/api/admin/distribution/overview");U!=null&&U.success&&U.overview&&h(U.overview)}catch(U){console.error("[Admin] 概览接口异常:",U),E("加载概览失败")}try{const U=await Re("/api/db/users");w((U==null?void 0:U.users)||[])}catch(U){console.error("[Admin] 用户数据加载失败:",U)}}async function Ut(U,qe=!1){var gt;if(!(!qe&&ce.has(U))){k(!0);try{const _t=N;switch(U){case"overview":break;case"orders":{try{const pt=new URLSearchParams({page:String(B),pageSize:String(Y),...W!=="all"&&{status:W},...L&&{search:L}}),lt=await Re(`/api/admin/orders?${pt}`);if(lt!=null&<.success&<.orders){const Tt=lt.orders.map(Wt=>{const Nn=_t.find(Ss=>Ss.id===Wt.userId),ks=Wt.referrerId?_t.find(Ss=>Ss.id===Wt.referrerId):null;return{...Wt,amount:parseFloat(String(Wt.amount))||0,userNickname:(Nn==null?void 0:Nn.nickname)||Wt.userNickname||"未知用户",userPhone:(Nn==null?void 0:Nn.phone)||Wt.userPhone||"-",referrerNickname:(ks==null?void 0:ks.nickname)||null,referrerCode:(ks==null?void 0:ks.referralCode)??null,type:Wt.productType||Wt.type}});c(Tt),se(lt.total??Tt.length)}else c([]),se(0)}catch(pt){console.error(pt),E("加载订单失败"),c([])}break}case"bindings":{try{const pt=new URLSearchParams({page:String(B),pageSize:String(Y),...W!=="all"&&{status:W}}),lt=await Re(`/api/db/distribution?${pt}`);m((lt==null?void 0:lt.bindings)||[]),se((lt==null?void 0:lt.total)??((gt=lt==null?void 0:lt.bindings)==null?void 0:gt.length)??0)}catch(pt){console.error(pt),E("加载绑定数据失败"),m([])}break}case"withdrawals":{try{const pt=W==="completed"?"success":W==="rejected"?"failed":W,lt=new URLSearchParams({...pt&&pt!=="all"&&{status:pt},page:String(B),pageSize:String(Y)}),Tt=await Re(`/api/admin/withdrawals?${lt}`);if(Tt!=null&&Tt.success&&Tt.withdrawals){const Wt=Tt.withdrawals.map(Nn=>({...Nn,account:Nn.account??"未绑定微信号",status:Nn.status==="success"?"completed":Nn.status==="failed"?"rejected":Nn.status}));b(Wt),se((Tt==null?void 0:Tt.total)??Wt.length)}else Tt!=null&&Tt.success||E(`获取提现记录失败: ${(Tt==null?void 0:Tt.error)||"未知错误"}`),b([])}catch(pt){console.error(pt),E("加载提现数据失败"),b([])}break}case"giftPay":{try{const pt=new URLSearchParams({page:String(yt),pageSize:"20",...on&&{status:on}}),lt=await Re(`/api/admin/gift-pay-requests?${pt}`);lt!=null&<.success&<.data?(Ue(lt.data),Et(lt.total??lt.data.length)):(Ue([]),Et(0))}catch(pt){console.error(pt),E("加载代付请求失败"),Ue([])}break}}me(pt=>new Set(pt).add(U))}catch(_t){console.error(_t)}finally{k(!1)}}}async function mn(){E(null),me(U=>{const qe=new Set(U);return qe.delete(n),n==="orders"&&a==="giftpay"&&qe.delete("giftPay"),qe}),n==="overview"&&ln(),n==="orders"&&a==="giftpay"?await Ut("giftPay",!0):await Ut(n,!0)}async function Sn(U){if(confirm("确认审核通过并打款?"))try{const qe=await Yt("/api/admin/withdrawals",{id:U,action:"approve"});if(!(qe!=null&&qe.success)){const gt=(qe==null?void 0:qe.message)||(qe==null?void 0:qe.error)||"操作失败";G.error(gt);return}await mn()}catch(qe){console.error(qe),G.error("操作失败")}}function _n(U){fe(U),ue("")}async function Xn(){const U=K;if(!U)return;const qe=he.trim();if(!qe){G.error("请填写拒绝原因");return}Q(!0);try{const gt=await Yt("/api/admin/withdrawals",{id:U,action:"reject",errorMessage:qe});if(!(gt!=null&>.success)){G.error((gt==null?void 0:gt.error)||"操作失败");return}G.success("已拒绝该提现申请"),fe(null),ue(""),await mn()}catch(gt){console.error(gt),G.error("操作失败")}finally{Q(!1)}}async function Lt(){try{const U=await Re("/api/admin/withdrawals/auto-approve");U!=null&&U.success&&typeof U.enableAutoApprove=="boolean"&&te(U.enableAutoApprove)}catch{}}async function xn(U){we(!0);try{const qe=await Yt("/api/admin/withdrawals/auto-approve",{enableAutoApprove:U});qe!=null&&qe.success?(te(U),G.success(U?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):G.error("更新失败: "+((qe==null?void 0:qe.error)??""))}catch{G.error("更新失败")}finally{we(!1)}}function Ne(){K&&G.info("已取消操作"),fe(null),ue("")}async function Me(){var U;if(!(!(I!=null&&I.orderSn)&&!(I!=null&&I.id))){H(!0),E(null);try{const qe=await Yt("/api/admin/orders/refund",{orderSn:I.orderSn||I.id,reason:V||void 0});qe!=null&&qe.success?(X(null),xe(""),await Ut("orders",!0)):E((qe==null?void 0:qe.error)||"退款失败")}catch(qe){const gt=qe;E(((U=gt==null?void 0:gt.data)==null?void 0:U.error)||"退款失败,请检查网络后重试")}finally{H(!1)}}}function We(U){const qe={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"},gt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Ve,{className:`${qe[U]||"bg-gray-500/20 text-gray-400"} border-0`,children:gt[U]||U})}const tt=Math.ceil(_/Y)||1,Ot=o,wt=f.filter(U=>{var gt,_t,pt,lt;if(!L)return!0;const qe=L.toLowerCase();return((gt=U.refereeNickname)==null?void 0:gt.toLowerCase().includes(qe))||((_t=U.refereePhone)==null?void 0:_t.includes(qe))||((pt=U.referrerName)==null?void 0:pt.toLowerCase().includes(qe))||((lt=U.referrerCode)==null?void 0:lt.toLowerCase().includes(qe))}),ze=x.filter(U=>{var gt;if(!L)return!0;const qe=L.toLowerCase();return((gt=U.userName)==null?void 0:gt.toLowerCase().includes(qe))||U.account&&U.account.toLowerCase().includes(qe)});return s.jsxs("div",{className:"p-8 w-full",children:[M&&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:M}),s.jsx("button",{type:"button",onClick:()=>E(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),s.jsxs(J,{onClick:mn,disabled:v,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1.5 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:[{key:"overview",label:"数据概览",icon:Cf},{key:"orders",label:"订单与代付",icon:kf},{key:"bindings",label:"绑定管理",icon:Aa},{key:"withdrawals",label:"提现审核",icon:Yc},{key:"settings",label:"推广设置",icon:No}].map(U=>s.jsxs("button",{type:"button",onClick:()=>{r(U.key),P("all"),R(""),U.key!=="orders"&&i("orders")},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${n===U.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(U.icon,{className:"w-3.5 h-3.5"}),U.label]},U.key))}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(He,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[n==="overview"&&u&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("span",{className:"text-sm font-medium text-gray-300 flex items-center gap-2",children:[s.jsx(Ro,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",onClick:()=>void mn(),disabled:v,className:"text-gray-400 h-7",children:s.jsx(He,{className:`w-3.5 h-3.5 ${v?"animate-spin":""}`})})]}),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:"text-gray-500 text-xs border-b border-gray-700/50",children:[s.jsx("th",{className:"pb-2 text-left font-normal",children:"指标"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"今日"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"本月"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"累计"})]})}),s.jsxs("tbody",{className:"text-white",children:[s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Sf,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalClicks})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Aa,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalBindings})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Rx,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalConversions})]}),s.jsxs("tr",{children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(kf,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),s.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(u.todayEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.monthEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.totalEarnings??0).toFixed(0)]})]})]})]})}),u.conversionRate&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",u.conversionRate]})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(_e,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx($e,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(_g,{className:"w-5 h-5 text-orange-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-orange-300 font-medium text-sm",children:"即将过期绑定"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.expiringBindings," ",s.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),s.jsx(_e,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx($e,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Yc,{className:"w-5 h-5 text-blue-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-blue-300 font-medium text-sm",children:"待审核提现"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.pendingWithdrawals," ",s.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(u.pendingWithdrawAmount??0).toFixed(0)]})]})]}),s.jsx(J,{onClick:()=>r("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),s.jsx(_e,{className:"bg-emerald-500/10 border-emerald-500/30",children:s.jsxs($e,{className:"p-4 flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-emerald-300 font-medium text-sm",children:"获客线索(存客宝)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"留资列表、推送状态与重试已统一至「用户管理 → 获客列表」,避免与推广中心重复维护。"})]}),s.jsx(Si,{to:"/users?tab=leads",className:"shrink-0",children:s.jsx(J,{type:"button",variant:"outline",size:"sm",className:"border-emerald-500/50 text-emerald-400 hover:bg-emerald-500/15 bg-transparent",children:"打开获客列表"})})]})}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx($e,{className:"p-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(Vn,{className:"w-5 h-5 text-gray-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-white",children:u.totalDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"推广用户"})]})]}),s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(Rx,{className:"w-5 h-5 text-green-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-green-400",children:u.activeDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),n==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsx("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="orders"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>i("orders"),children:"普通订单"}),s.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="giftpay"?"bg-amber-500/20 text-amber-400 border border-amber-500/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>{i("giftpay"),Ut("giftPay",!0)},children:[s.jsx($g,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),a==="orders"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(le,{value:L,onChange:U=>R(U.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:W,onChange:U=>P(U.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",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.jsxs(J,{type:"button",variant:"outline",onClick:()=>void mn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{className:"p-0",children:[o.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:Ot.map(U=>{var qe,gt;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:[(qe=U.id)==null?void 0:qe.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:U.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:U.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const _t=U.productType||U.type,pt=U.description||"",lt=String(U.productId||U.sectionId||""),Tt=_t==="vip"||pt.includes("VIP")||pt.toLowerCase().includes("vip")||lt.toLowerCase().includes("vip");return _t==="balance_recharge"?`余额充值 ¥${typeof U.amount=="number"?U.amount.toFixed(2):parseFloat(String(U.amount||"0")).toFixed(2)}`:Tt?"超级个体开通费用":_t==="fullbook"?`${U.bookName||"《底层逻辑》"} - 全本`:_t==="match"?"匹配次数购买":`${U.bookName||"《底层逻辑》"} - ${U.sectionTitle||U.chapterTitle||`章节${U.productId||U.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const _t=U.productType||U.type,pt=U.description||"",lt=String(U.productId||U.sectionId||""),Tt=_t==="vip"||pt.includes("VIP")||pt.toLowerCase().includes("vip")||lt.toLowerCase().includes("vip");return _t==="balance_recharge"?"余额充值":Tt?"超级个体":_t==="fullbook"?"全书解锁":_t==="match"?"功能权益":U.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof U.amount=="number"?U.amount.toFixed(2):parseFloat(String(U.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:U.paymentMethod==="wechat"?"微信支付":U.paymentMethod==="balance"?"余额支付":U.paymentMethod==="alipay"?"支付宝":U.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:U.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):U.status==="completed"||U.status==="paid"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):U.status==="pending"||U.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Ve,{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:U.refundReason,children:U.status==="refunded"&&U.refundReason?U.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:U.referrerId||U.referralCode?s.jsxs("span",{title:U.referralCode||U.referrerCode||U.referrerId||"",children:[U.referrerNickname||U.referralCode||U.referrerCode||((gt=U.referrerId)==null?void 0:gt.slice(0,8)),(U.referralCode||U.referrerCode)&&` (${U.referralCode||U.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:U.referrerEarnings?`¥${(typeof U.referrerEarnings=="number"?U.referrerEarnings:parseFloat(String(U.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:U.createdAt?new Date(U.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(U.status==="paid"||U.status==="completed")&&s.jsxs(J,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{X(U),xe("")},children:[s.jsx(ok,{className:"w-3 h-3 mr-1"}),"退款"]})})]},U.id)})})]})}),n==="orders"&&s.jsx(us,{page:B,totalPages:tt,total:_,pageSize:Y,onPageChange:O,onPageSizeChange:U=>{ae(U),O(1)}})]})})]}),a==="giftpay"&&s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(it,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(ot,{className:"text-white text-base",children:"代付请求列表"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:on,onChange:U=>{Dn(U.target.value),vn(1)},children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待支付(旧)"}),s.jsx("option",{value:"pending_pay",children:"待发起人支付"}),s.jsx("option",{value:"paid",children:"已支付"}),s.jsx("option",{value:"refunded",children:"已退款"}),s.jsx("option",{value:"cancelled",children:"已取消"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>void Ut("giftPay",!0),disabled:v,className:"border-gray-600 text-gray-300",children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1 ${v?"animate-spin":""}`}),"刷新"]})]})]})}),s.jsxs($e,{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/50",children:[s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"请求号"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"发起人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"商品/金额"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"份数/已领"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"付款人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"状态"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"创建时间"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Be.map(U=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:U.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:U.initiatorNick||U.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[U.productType," · ¥",U.amount.toFixed(2)]}),U.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:U.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(U.quantity??1)>1?`${U.quantity}份 / 已领${U.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:U.payerNick||(U.payerUserId?U.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Ve,{className:U.status==="paid"?"bg-green-500/20 text-green-400 border-0":U.status==="pending"||U.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":U.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:U.status==="paid"?"已支付":U.status==="pending"||U.status==="pending_pay"?"待支付":U.status==="refunded"?"已退款":U.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:U.createdAt?new Date(U.createdAt).toLocaleString("zh-CN"):"-"})]},U.id))})]})}),Be.length===0&&!v&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),dt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(us,{page:yt,totalPages:Math.ceil(dt/20),total:dt,pageSize:20,onPageChange:vn,onPageSizeChange:()=>{}})})]})]})]}),n==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(le,{value:L,onChange:U=>R(U.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:W,onChange:U=>P(U.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",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.jsxs(J,{type:"button",variant:"outline",onClick:()=>void mn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{className:"p-0",children:[wt.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:wt.map(U=>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:U.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:U.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:U.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:U.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:U.boundAt?new Date(U.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:U.expiresAt?new Date(U.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(U.status)}),s.jsx("td",{className:"p-4",children:U.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",U.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},U.id))})]})}),n==="bindings"&&s.jsx(us,{page:B,totalPages:tt,total:_,pageSize:Y,onPageChange:O,onPageSizeChange:U=>{ae(U),O(1)}})]})})]}),n==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(le,{value:L,onChange:U=>R(U.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:W,onChange:U=>P(U.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",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.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[s.jsx(Ro,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx(Ht,{checked:z,onCheckedChange:xn,disabled:ie,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>void mn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{className:"p-0",children:[ze.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-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:ze.map(U=>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:[U.userAvatar?s.jsx("img",{src:U.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:(U.userName||U.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:U.userName||U.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",U.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Ve,{className:U.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:U.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:U.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:U.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:U.createdAt?new Date(U.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(U.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${U.status==="rejected"||U.status==="failed"?"text-red-400":"text-gray-400"}`,title:U.remark,children:U.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:U.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(J,{size:"sm",onClick:()=>Sn(U.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rx,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>_n(U.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(ek,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},U.id))})]})}),n==="withdrawals"&&s.jsx(us,{page:B,totalPages:tt,total:_,pageSize:Y,onPageChange:O,onPageSizeChange:U=>{ae(U),O(1)}})]})})]})]}),s.jsx(Pt,{open:!!I,onOpenChange:U=>!U&&X(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(It,{children:s.jsx(Rt,{className:"text-white",children:"订单退款"})}),I&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",I.orderSn||I.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof I.amount=="number"?I.amount.toFixed(2):parseFloat(String(I.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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:V,onChange:U=>xe(U.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>X(null),disabled:ee,children:"取消"}),s.jsx(J,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Me,disabled:ee,children:ee?"退款中...":"确认退款"})]})]})}),s.jsx(Pt,{open:!!K,onOpenChange:U=>!U&&Ne(),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(It,{children:s.jsx(Rt,{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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:he,onChange:U=>ue(U.target.value)})})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Ne,disabled:$,children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:Xn,disabled:$||!he.trim(),children:$?"提交中...":"确认拒绝"})]})]})}),n==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(U2,{embedded:!0})})]})}function G8(){const[t,e]=g.useState([]),[n,r]=g.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=g.useState(!0),[o,c]=g.useState(null),[u,h]=g.useState("all"),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(0),[v,k]=g.useState(null),[M,E]=g.useState(null),[L,R]=g.useState(""),[W,P]=g.useState(!1);async function B(){var I,X,V,xe,ee,H,K;i(!0),c(null);try{const fe=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),he=await Re(`/api/admin/withdrawals?${fe}`);if(he!=null&&he.success){const ue=he.withdrawals||[];e(ue),w(he.total??((I=he.stats)==null?void 0:I.total)??ue.length),r({total:((X=he.stats)==null?void 0:X.total)??he.total??ue.length,pendingCount:((V=he.stats)==null?void 0:V.pendingCount)??0,pendingAmount:((xe=he.stats)==null?void 0:xe.pendingAmount)??0,successCount:((ee=he.stats)==null?void 0:ee.successCount)??0,successAmount:((H=he.stats)==null?void 0:H.successAmount)??0,failedCount:((K=he.stats)==null?void 0:K.failedCount)??0})}else c("加载提现记录失败")}catch(fe){console.error("Load withdrawals error:",fe),c("加载失败,请检查网络后重试")}finally{i(!1)}}g.useEffect(()=>{m(1)},[u]),g.useEffect(()=>{B()},[u,f,x]);const O=Math.ceil(N/x)||1;async function Y(I){const X=t.find(V=>V.id===I);if(X!=null&&X.userCommissionInfo&&X.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${X.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 +如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),G.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{c(!1)}},h=f=>m=>{const x=parseFloat(m.target.value||"0");r(b=>({...b,[f]:isNaN(x)?0:x}))};return a?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:e?"p-4 w-full":"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(Yc,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(Po,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(J,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[s.jsx(nA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(qt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(ze,{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(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fh,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.userDiscount,onChange:h("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Vn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(W8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(le,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:n.distributorShare,onChange:h("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[n.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareVip,onChange:h("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:n.vipOrderShareNonVip,onChange:h("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Vn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(le,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[s.jsx(Yc,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(qt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(ze,{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(ne,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(le,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:n.minWithdrawAmount,onChange:h("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(le,{type:"number",min:0,max:100,step:.5,className:"bg-[#0a1628] border-gray-700 text-white",value:n.withdrawFee,onChange:h("withdrawFee")}),s.jsx("p",{className:"text-xs text-gray-500",children:"批准提现时按此比例扣除后打款,如 5 表示申请 100 元实际到账 95 元。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Ve,{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(Ut,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(it,{children:s.jsxs(ot,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(Fh,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(ze,{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 q8(){const[t]=q0(),e=_a(),[n,r]=g.useState("overview"),[a,i]=g.useState("orders"),[o,c]=g.useState([]),[u,h]=g.useState(null),[f,m]=g.useState([]),[x,b]=g.useState([]),[N,w]=g.useState([]),[v,k]=g.useState(!0),[M,E]=g.useState(null),[L,R]=g.useState(""),[W,P]=g.useState("all"),[B,O]=g.useState(1),[X,ae]=g.useState(10),[_,se]=g.useState(0),[ce,me]=g.useState(new Set),[I,Z]=g.useState(null),[V,xe]=g.useState(""),[ee,H]=g.useState(!1),[K,fe]=g.useState(null),[he,ue]=g.useState(""),[$,Q]=g.useState(!1),[z,te]=g.useState(!1),[ie,we]=g.useState(!1),[Be,Ue]=g.useState([]),[bt,vn]=g.useState(1),[dt,Tt]=g.useState(0),[ln,Dn]=g.useState("");g.useEffect(()=>{t.get("tab")==="leads"&&e("/users?tab=leads",{replace:!0})},[t,e]),g.useEffect(()=>{Zt()},[]),g.useEffect(()=>{const U=t.get("tab");(U==="overview"||U==="orders"||U==="bindings"||U==="withdrawals"||U==="settings")&&r(U)},[t]),g.useEffect(()=>{O(1)},[n,W]),g.useEffect(()=>{Dt(n)},[n]),g.useEffect(()=>{if(n==="orders"&&a==="giftpay"){Dt("giftPay",!0);return}["orders","bindings","withdrawals"].includes(n)&&Dt(n,!0)},[B,X,W,L,n,a,bt,ln]),g.useEffect(()=>{n==="withdrawals"&&Ot()},[n]);async function Zt(){E(null);try{const U=await Re("/api/admin/distribution/overview");U!=null&&U.success&&U.overview&&h(U.overview)}catch(U){console.error("[Admin] 概览接口异常:",U),E("加载概览失败")}try{const U=await Re("/api/db/users");w((U==null?void 0:U.users)||[])}catch(U){console.error("[Admin] 用户数据加载失败:",U)}}async function Dt(U,qe=!1){var yt;if(!(!qe&&ce.has(U))){k(!0);try{const $t=N;switch(U){case"overview":break;case"orders":{try{const mt=new URLSearchParams({page:String(B),pageSize:String(X),...W!=="all"&&{status:W},...L&&{search:L}}),lt=await Re(`/api/admin/orders?${mt}`);if(lt!=null&<.success&<.orders){const Mt=lt.orders.map(Wt=>{const Nn=$t.find(Ss=>Ss.id===Wt.userId),ks=Wt.referrerId?$t.find(Ss=>Ss.id===Wt.referrerId):null;return{...Wt,amount:parseFloat(String(Wt.amount))||0,userNickname:(Nn==null?void 0:Nn.nickname)||Wt.userNickname||"未知用户",userPhone:(Nn==null?void 0:Nn.phone)||Wt.userPhone||"-",referrerNickname:(ks==null?void 0:ks.nickname)||null,referrerCode:(ks==null?void 0:ks.referralCode)??null,type:Wt.productType||Wt.type}});c(Mt),se(lt.total??Mt.length)}else c([]),se(0)}catch(mt){console.error(mt),E("加载订单失败"),c([])}break}case"bindings":{try{const mt=new URLSearchParams({page:String(B),pageSize:String(X),...W!=="all"&&{status:W}}),lt=await Re(`/api/db/distribution?${mt}`);m((lt==null?void 0:lt.bindings)||[]),se((lt==null?void 0:lt.total)??((yt=lt==null?void 0:lt.bindings)==null?void 0:yt.length)??0)}catch(mt){console.error(mt),E("加载绑定数据失败"),m([])}break}case"withdrawals":{try{const mt=W==="completed"?"success":W==="rejected"?"failed":W,lt=new URLSearchParams({...mt&&mt!=="all"&&{status:mt},page:String(B),pageSize:String(X)}),Mt=await Re(`/api/admin/withdrawals?${lt}`);if(Mt!=null&&Mt.success&&Mt.withdrawals){const Wt=Mt.withdrawals.map(Nn=>({...Nn,account:Nn.account??"未绑定微信号",status:Nn.status==="success"?"completed":Nn.status==="failed"?"rejected":Nn.status}));b(Wt),se((Mt==null?void 0:Mt.total)??Wt.length)}else Mt!=null&&Mt.success||E(`获取提现记录失败: ${(Mt==null?void 0:Mt.error)||"未知错误"}`),b([])}catch(mt){console.error(mt),E("加载提现数据失败"),b([])}break}case"giftPay":{try{const mt=new URLSearchParams({page:String(bt),pageSize:"20",...ln&&{status:ln}}),lt=await Re(`/api/admin/gift-pay-requests?${mt}`);lt!=null&<.success&<.data?(Ue(lt.data),Tt(lt.total??lt.data.length)):(Ue([]),Tt(0))}catch(mt){console.error(mt),E("加载代付请求失败"),Ue([])}break}}me(mt=>new Set(mt).add(U))}catch($t){console.error($t)}finally{k(!1)}}}async function mn(){E(null),me(U=>{const qe=new Set(U);return qe.delete(n),n==="orders"&&a==="giftpay"&&qe.delete("giftPay"),qe}),n==="overview"&&Zt(),n==="orders"&&a==="giftpay"?await Dt("giftPay",!0):await Dt(n,!0)}async function Sn(U){if(confirm("确认审核通过并打款?"))try{const qe=await Yt("/api/admin/withdrawals",{id:U,action:"approve"});if(!(qe!=null&&qe.success)){const yt=(qe==null?void 0:qe.message)||(qe==null?void 0:qe.error)||"操作失败";G.error(yt);return}await mn()}catch(qe){console.error(qe),G.error("操作失败")}}function _n(U){fe(U),ue("")}async function Xn(){const U=K;if(!U)return;const qe=he.trim();if(!qe){G.error("请填写拒绝原因");return}Q(!0);try{const yt=await Yt("/api/admin/withdrawals",{id:U,action:"reject",errorMessage:qe});if(!(yt!=null&&yt.success)){G.error((yt==null?void 0:yt.error)||"操作失败");return}G.success("已拒绝该提现申请"),fe(null),ue(""),await mn()}catch(yt){console.error(yt),G.error("操作失败")}finally{Q(!1)}}async function Ot(){try{const U=await Re("/api/admin/withdrawals/auto-approve");U!=null&&U.success&&typeof U.enableAutoApprove=="boolean"&&te(U.enableAutoApprove)}catch{}}async function xn(U){we(!0);try{const qe=await Yt("/api/admin/withdrawals/auto-approve",{enableAutoApprove:U});qe!=null&&qe.success?(te(U),G.success(U?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):G.error("更新失败: "+((qe==null?void 0:qe.error)??""))}catch{G.error("更新失败")}finally{we(!1)}}function Ne(){K&&G.info("已取消操作"),fe(null),ue("")}async function Te(){var U;if(!(!(I!=null&&I.orderSn)&&!(I!=null&&I.id))){H(!0),E(null);try{const qe=await Yt("/api/admin/orders/refund",{orderSn:I.orderSn||I.id,reason:V||void 0});qe!=null&&qe.success?(Z(null),xe(""),await Dt("orders",!0)):E((qe==null?void 0:qe.error)||"退款失败")}catch(qe){const yt=qe;E(((U=yt==null?void 0:yt.data)==null?void 0:U.error)||"退款失败,请检查网络后重试")}finally{H(!1)}}}function We(U){const qe={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"},yt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Ve,{className:`${qe[U]||"bg-gray-500/20 text-gray-400"} border-0`,children:yt[U]||U})}const tt=Math.ceil(_/X)||1,vt=o,ft=f.filter(U=>{var yt,$t,mt,lt;if(!L)return!0;const qe=L.toLowerCase();return((yt=U.refereeNickname)==null?void 0:yt.toLowerCase().includes(qe))||(($t=U.refereePhone)==null?void 0:$t.includes(qe))||((mt=U.referrerName)==null?void 0:mt.toLowerCase().includes(qe))||((lt=U.referrerCode)==null?void 0:lt.toLowerCase().includes(qe))}),_e=x.filter(U=>{var yt;if(!L)return!0;const qe=L.toLowerCase();return((yt=U.userName)==null?void 0:yt.toLowerCase().includes(qe))||U.account&&U.account.toLowerCase().includes(qe)});return s.jsxs("div",{className:"p-8 w-full",children:[M&&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:M}),s.jsx("button",{type:"button",onClick:()=>E(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-semibold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"分销绑定、提现审核、推广设置"})]}),s.jsxs(J,{onClick:mn,disabled:v,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1.5 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:[{key:"overview",label:"数据概览",icon:Cf},{key:"orders",label:"订单与代付",icon:kf},{key:"bindings",label:"绑定管理",icon:Aa},{key:"withdrawals",label:"提现审核",icon:Yc},{key:"settings",label:"推广设置",icon:vo}].map(U=>s.jsxs("button",{type:"button",onClick:()=>{r(U.key),P("all"),R(""),U.key!=="orders"&&i("orders")},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${n===U.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(U.icon,{className:"w-3.5 h-3.5"}),U.label]},U.key))}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(He,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[n==="overview"&&u&&s.jsxs("div",{className:"space-y-6",children:[s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("span",{className:"text-sm font-medium text-gray-300 flex items-center gap-2",children:[s.jsx(Ro,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(J,{type:"button",size:"sm",variant:"ghost",onClick:()=>void mn(),disabled:v,className:"text-gray-400 h-7",children:s.jsx(He,{className:`w-3.5 h-3.5 ${v?"animate-spin":""}`})})]}),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:"text-gray-500 text-xs border-b border-gray-700/50",children:[s.jsx("th",{className:"pb-2 text-left font-normal",children:"指标"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"今日"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"本月"}),s.jsx("th",{className:"pb-2 text-right font-normal",children:"累计"})]})}),s.jsxs("tbody",{className:"text-white",children:[s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Sf,{className:"w-4 h-4 text-blue-400"}),"点击数"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthClicks}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalClicks})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Aa,{className:"w-4 h-4 text-green-400"}),"绑定关系"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthBindings}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalBindings})]}),s.jsxs("tr",{className:"border-b border-gray-700/30",children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(Rx,{className:"w-4 h-4 text-purple-400"}),"付款转化"]}),s.jsx("td",{className:"py-2.5 text-right font-bold",children:u.todayConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.monthConversions}),s.jsx("td",{className:"py-2.5 text-right",children:u.totalConversions})]}),s.jsxs("tr",{children:[s.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[s.jsx(kf,{className:"w-4 h-4 text-[#38bdac]"}),"佣金收入"]}),s.jsxs("td",{className:"py-2.5 text-right font-bold text-[#38bdac]",children:["¥",(u.todayEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.monthEarnings??0).toFixed(0)]}),s.jsxs("td",{className:"py-2.5 text-right text-[#38bdac]",children:["¥",(u.totalEarnings??0).toFixed(0)]})]})]})]})}),u.conversionRate&&s.jsxs("p",{className:"text-xs text-gray-500 mt-3 text-right",children:["综合转化率 ",u.conversionRate]})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx($e,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(_g,{className:"w-5 h-5 text-orange-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-orange-300 font-medium text-sm",children:"即将过期绑定"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.expiringBindings," ",s.jsx("span",{className:"text-sm font-normal text-orange-300/60",children:"个 · 7天内"})]})]})]})})}),s.jsx($e,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Yc,{className:"w-5 h-5 text-blue-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-blue-300 font-medium text-sm",children:"待审核提现"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[u.pendingWithdrawals," ",s.jsxs("span",{className:"text-sm font-normal text-blue-300/60",children:["笔 · ¥",(u.pendingWithdrawAmount??0).toFixed(0)]})]})]}),s.jsx(J,{onClick:()=>r("withdrawals"),variant:"outline",size:"sm",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20 shrink-0",children:"去审核"})]})})})]}),s.jsx($e,{className:"bg-emerald-500/10 border-emerald-500/30",children:s.jsxs(ze,{className:"p-4 flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-emerald-300 font-medium text-sm",children:"获客线索(存客宝)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"留资列表、推送状态与重试已统一至「用户管理 → 获客列表」,避免与推广中心重复维护。"})]}),s.jsx(Po,{to:"/users?tab=leads",className:"shrink-0",children:s.jsx(J,{type:"button",variant:"outline",size:"sm",className:"border-emerald-500/50 text-emerald-400 hover:bg-emerald-500/15 bg-transparent",children:"打开获客列表"})})]})}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(Vn,{className:"w-5 h-5 text-gray-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-white",children:u.totalDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"推广用户"})]})]}),s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-white/5",children:[s.jsx(Rx,{className:"w-5 h-5 text-green-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-bold text-green-400",children:u.activeDistributors}),s.jsx("p",{className:"text-[10px] text-gray-500",children:"有收益用户"})]})]})]})})})]}),n==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsx("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="orders"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>i("orders"),children:"普通订单"}),s.jsxs("button",{type:"button",className:`px-3 py-1.5 rounded-md text-xs font-medium transition-all ${a==="giftpay"?"bg-amber-500/20 text-amber-400 border border-amber-500/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,onClick:()=>{i("giftpay"),Dt("giftPay",!0)},children:[s.jsx($g,{className:"w-3 h-3 inline mr-1"}),"代付请求"]})]}),a==="orders"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(le,{value:L,onChange:U=>R(U.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:W,onChange:U=>P(U.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",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.jsxs(J,{type:"button",variant:"outline",onClick:()=>void mn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-0",children:[o.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:vt.map(U=>{var qe,yt;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:[(qe=U.id)==null?void 0:qe.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:U.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:U.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const $t=U.productType||U.type,mt=U.description||"",lt=String(U.productId||U.sectionId||""),Mt=$t==="vip"||mt.includes("VIP")||mt.toLowerCase().includes("vip")||lt.toLowerCase().includes("vip");return $t==="balance_recharge"?`余额充值 ¥${typeof U.amount=="number"?U.amount.toFixed(2):parseFloat(String(U.amount||"0")).toFixed(2)}`:Mt?"超级个体开通费用":$t==="fullbook"?`${U.bookName||"《底层逻辑》"} - 全本`:$t==="match"?"匹配次数购买":`${U.bookName||"《底层逻辑》"} - ${U.sectionTitle||U.chapterTitle||`章节${U.productId||U.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const $t=U.productType||U.type,mt=U.description||"",lt=String(U.productId||U.sectionId||""),Mt=$t==="vip"||mt.includes("VIP")||mt.toLowerCase().includes("vip")||lt.toLowerCase().includes("vip");return $t==="balance_recharge"?"余额充值":Mt?"超级个体":$t==="fullbook"?"全书解锁":$t==="match"?"功能权益":U.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof U.amount=="number"?U.amount.toFixed(2):parseFloat(String(U.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:U.paymentMethod==="wechat"?"微信支付":U.paymentMethod==="balance"?"余额支付":U.paymentMethod==="alipay"?"支付宝":U.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:U.status==="refunded"?s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):U.status==="completed"||U.status==="paid"?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):U.status==="pending"||U.status==="created"?s.jsx(Ve,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Ve,{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:U.refundReason,children:U.status==="refunded"&&U.refundReason?U.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:U.referrerId||U.referralCode?s.jsxs("span",{title:U.referralCode||U.referrerCode||U.referrerId||"",children:[U.referrerNickname||U.referralCode||U.referrerCode||((yt=U.referrerId)==null?void 0:yt.slice(0,8)),(U.referralCode||U.referrerCode)&&` (${U.referralCode||U.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:U.referrerEarnings?`¥${(typeof U.referrerEarnings=="number"?U.referrerEarnings:parseFloat(String(U.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:U.createdAt?new Date(U.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(U.status==="paid"||U.status==="completed")&&s.jsxs(J,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{Z(U),xe("")},children:[s.jsx(ok,{className:"w-3 h-3 mr-1"}),"退款"]})})]},U.id)})})]})}),n==="orders"&&s.jsx(us,{page:B,totalPages:tt,total:_,pageSize:X,onPageChange:O,onPageSizeChange:U=>{ae(U),O(1)}})]})})]}),a==="giftpay"&&s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(it,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(ot,{className:"text-white text-base",children:"代付请求列表"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsxs("select",{className:"bg-[#0a1628] border border-gray-700 text-white rounded px-3 py-1.5 text-sm",value:ln,onChange:U=>{Dn(U.target.value),vn(1)},children:[s.jsx("option",{value:"",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待支付(旧)"}),s.jsx("option",{value:"pending_pay",children:"待发起人支付"}),s.jsx("option",{value:"paid",children:"已支付"}),s.jsx("option",{value:"refunded",children:"已退款"}),s.jsx("option",{value:"cancelled",children:"已取消"}),s.jsx("option",{value:"expired",children:"已过期"})]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>void Dt("giftPay",!0),disabled:v,className:"border-gray-600 text-gray-300",children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1 ${v?"animate-spin":""}`}),"刷新"]})]})]})}),s.jsxs(ze,{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/50",children:[s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"请求号"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"发起人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"商品/金额"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"份数/已领"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"付款人"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"状态"}),s.jsx("th",{className:"p-3 text-left font-normal text-gray-400 text-xs",children:"创建时间"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Be.map(U=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:U.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:U.initiatorNick||U.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[U.productType," · ¥",U.amount.toFixed(2)]}),U.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:U.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(U.quantity??1)>1?`${U.quantity}份 / 已领${U.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:U.payerNick||(U.payerUserId?U.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Ve,{className:U.status==="paid"?"bg-green-500/20 text-green-400 border-0":U.status==="pending"||U.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":U.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:U.status==="paid"?"已支付":U.status==="pending"||U.status==="pending_pay"?"待支付":U.status==="refunded"?"已退款":U.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:U.createdAt?new Date(U.createdAt).toLocaleString("zh-CN"):"-"})]},U.id))})]})}),Be.length===0&&!v&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),dt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(us,{page:bt,totalPages:Math.ceil(dt/20),total:dt,pageSize:20,onPageChange:vn,onPageSizeChange:()=>{}})})]})]})]}),n==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(le,{value:L,onChange:U=>R(U.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:W,onChange:U=>P(U.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",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.jsxs(J,{type:"button",variant:"outline",onClick:()=>void mn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-0",children:[ft.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:ft.map(U=>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:U.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:U.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:U.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:U.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:U.boundAt?new Date(U.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:U.expiresAt?new Date(U.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(U.status)}),s.jsx("td",{className:"p-4",children:U.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",U.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},U.id))})]})}),n==="bindings"&&s.jsx(us,{page:B,totalPages:tt,total:_,pageSize:X,onPageChange:O,onPageSizeChange:U=>{ae(U),O(1)}})]})})]}),n==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[s.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(le,{value:L,onChange:U=>R(U.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:W,onChange:U=>P(U.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white shrink-0",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.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[#0f2137] border border-gray-700/50 shrink-0",children:[s.jsx(Ro,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx(Ut,{checked:z,onCheckedChange:xn,disabled:ie,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(J,{type:"button",variant:"outline",onClick:()=>void mn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{className:"p-0",children:[_e.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-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:_e.map(U=>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:[U.userAvatar?s.jsx("img",{src:U.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:(U.userName||U.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:U.userName||U.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",U.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Ve,{className:U.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:U.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:U.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:U.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:U.createdAt?new Date(U.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(U.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${U.status==="rejected"||U.status==="failed"?"text-red-400":"text-gray-400"}`,title:U.remark,children:U.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:U.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(J,{size:"sm",onClick:()=>Sn(U.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rx,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>_n(U.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(ek,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},U.id))})]})}),n==="withdrawals"&&s.jsx(us,{page:B,totalPages:tt,total:_,pageSize:X,onPageChange:O,onPageSizeChange:U=>{ae(U),O(1)}})]})})]})]}),s.jsx(It,{open:!!I,onOpenChange:U=>!U&&Z(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Rt,{children:s.jsx(Lt,{className:"text-white",children:"订单退款"})}),I&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",I.orderSn||I.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof I.amount=="number"?I.amount.toFixed(2):parseFloat(String(I.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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:V,onChange:U=>xe(U.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>Z(null),disabled:ee,children:"取消"}),s.jsx(J,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Te,disabled:ee,children:ee?"退款中...":"确认退款"})]})]})}),s.jsx(It,{open:!!K,onOpenChange:U=>!U&&Ne(),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Rt,{children:s.jsx(Lt,{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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:he,onChange:U=>ue(U.target.value)})})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Ne,disabled:$,children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:Xn,disabled:$||!he.trim(),children:$?"提交中...":"确认拒绝"})]})]})}),n==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(U2,{embedded:!0})})]})}function G8(){const[t,e]=g.useState([]),[n,r]=g.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[a,i]=g.useState(!0),[o,c]=g.useState(null),[u,h]=g.useState("all"),[f,m]=g.useState(1),[x,b]=g.useState(10),[N,w]=g.useState(0),[v,k]=g.useState(null),[M,E]=g.useState(null),[L,R]=g.useState(""),[W,P]=g.useState(!1);async function B(){var I,Z,V,xe,ee,H,K;i(!0),c(null);try{const fe=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),he=await Re(`/api/admin/withdrawals?${fe}`);if(he!=null&&he.success){const ue=he.withdrawals||[];e(ue),w(he.total??((I=he.stats)==null?void 0:I.total)??ue.length),r({total:((Z=he.stats)==null?void 0:Z.total)??he.total??ue.length,pendingCount:((V=he.stats)==null?void 0:V.pendingCount)??0,pendingAmount:((xe=he.stats)==null?void 0:xe.pendingAmount)??0,successCount:((ee=he.stats)==null?void 0:ee.successCount)??0,successAmount:((H=he.stats)==null?void 0:H.successAmount)??0,failedCount:((K=he.stats)==null?void 0:K.failedCount)??0})}else c("加载提现记录失败")}catch(fe){console.error("Load withdrawals error:",fe),c("加载失败,请检查网络后重试")}finally{i(!1)}}g.useEffect(()=>{m(1)},[u]),g.useEffect(()=>{B()},[u,f,x]);const O=Math.ceil(N/x)||1;async function X(I){const Z=t.find(V=>V.id===I);if(Z!=null&&Z.userCommissionInfo&&Z.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${Z.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 -确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const V=await Yt("/api/admin/withdrawals",{id:I,action:"approve"});V!=null&&V.success?B():G.error("操作失败: "+((V==null?void 0:V.error)??""))}catch{G.error("操作失败")}finally{k(null)}}async function ae(I){if(confirm("确认撤回该笔打款?仅在用户未确认收款前可撤回。")){k(I);try{const X=await xt("/api/admin/withdrawals/cancel",{id:I});X!=null&&X.success?(G.success("已撤回打款"),B()):G.error("撤回失败: "+((X==null?void 0:X.error)??"未知错误"))}catch{G.error("撤回失败")}finally{k(null)}}}function _(I){E(I),R("")}async function se(){const I=M;if(!I)return;const X=L.trim();if(!X){G.error("请填写拒绝原因");return}P(!0);try{const V=await Yt("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:X});V!=null&&V.success?(G.success("已拒绝该提现申请"),E(null),R(""),B()):G.error("操作失败: "+((V==null?void 0:V.error)??""))}catch{G.error("操作失败")}finally{P(!1)}}function ce(){M&&G.info("已取消操作"),E(null),R("")}function me(I){switch(I){case"pending":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:I})}}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(J,{variant:"outline",onClick:B,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx($e,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(kf,{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(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{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(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{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(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{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(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs($e,{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","processing","pending_confirm","success","failed"].map(I=>s.jsx(J,{variant:u===I?"default":"outline",size:"sm",onClick:()=>h(I),className:u===I?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:I==="all"?"全部":I==="pending"?"待处理":I==="processing"?"处理中":I==="pending_confirm"?"待确认收款":I==="success"?"已完成":"已拒绝"},I))}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(Yc,{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-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(I=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(I.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[I.userAvatar?s.jsx("img",{src:aa(I.userAvatar),alt:I.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:(I.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:I.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:I.userPhone??I.referralCode??(I.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(I.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:I.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:["¥",I.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:["¥",I.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:["¥",I.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:I.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",I.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsx("td",{className:"p-4",children:me(I.status)}),s.jsx("td",{className:"p-4 max-w-[180px]",children:s.jsx("span",{className:`text-xs ${I.status==="rejected"||I.status==="failed"?"text-red-400":"text-gray-400"}`,title:I.remark,children:I.remark||"-"})}),s.jsx("td",{className:"p-4 text-gray-400",children:I.processedAt?new Date(I.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:I.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:I.userConfirmedAt,children:["已确认 ",new Date(I.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(I.status==="pending"||I.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(J,{size:"sm",onClick:()=>Y(I.id),disabled:v===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(Tp,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>_(I.id),disabled:v===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(I.status==="processing"||I.status==="pending_confirm")&&s.jsx("div",{className:"mt-2 flex items-center justify-end gap-2",children:s.jsx(J,{size:"sm",variant:"outline",onClick:()=>ae(I.id),disabled:v===I.id,className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:"撤回打款"})}),(I.status==="success"||I.status==="completed")&&I.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:I.transactionId})]})]},I.id))})]})}),s.jsx(us,{page:f,totalPages:O,total:N,pageSize:x,onPageChange:m,onPageSizeChange:I=>{b(I),m(1)}})]})})}),s.jsx(Pt,{open:!!M,onOpenChange:I=>!I&&ce(),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(It,{children:s.jsx(Rt,{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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:L,onChange:I=>R(I.target.value)})})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ce,disabled:W,children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:se,disabled:W||!L.trim(),children:W?"提交中...":"确认拒绝"})]})]})})]})}var Kx={exports:{}},qx={};/** +确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const V=await Yt("/api/admin/withdrawals",{id:I,action:"approve"});V!=null&&V.success?B():G.error("操作失败: "+((V==null?void 0:V.error)??""))}catch{G.error("操作失败")}finally{k(null)}}async function ae(I){if(confirm("确认撤回该笔打款?仅在用户未确认收款前可撤回。")){k(I);try{const Z=await gt("/api/admin/withdrawals/cancel",{id:I});Z!=null&&Z.success?(G.success("已撤回打款"),B()):G.error("撤回失败: "+((Z==null?void 0:Z.error)??"未知错误"))}catch{G.error("撤回失败")}finally{k(null)}}}function _(I){E(I),R("")}async function se(){const I=M;if(!I)return;const Z=L.trim();if(!Z){G.error("请填写拒绝原因");return}P(!0);try{const V=await Yt("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:Z});V!=null&&V.success?(G.success("已拒绝该提现申请"),E(null),R(""),B()):G.error("操作失败: "+((V==null?void 0:V.error)??""))}catch{G.error("操作失败")}finally{P(!1)}}function ce(){M&&G.info("已取消操作"),E(null),R("")}function me(I){switch(I){case"pending":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Ve,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Ve,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Ve,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Ve,{className:"bg-gray-500/20 text-gray-400 border-0",children:I})}}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(J,{variant:"outline",onClick:B,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx($e,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(ze,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(kf,{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($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{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($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{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($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{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($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(ze,{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","processing","pending_confirm","success","failed"].map(I=>s.jsx(J,{variant:u===I?"default":"outline",size:"sm",onClick:()=>h(I),className:u===I?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:I==="all"?"全部":I==="pending"?"待处理":I==="processing"?"处理中":I==="pending_confirm"?"待确认收款":I==="success"?"已完成":"已拒绝"},I))}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:a?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{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(Yc,{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-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(I=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(I.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[I.userAvatar?s.jsx("img",{src:aa(I.userAvatar),alt:I.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:(I.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:I.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:I.userPhone??I.referralCode??(I.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(I.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:I.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:["¥",I.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:["¥",I.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:["¥",I.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:I.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",I.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsx("td",{className:"p-4",children:me(I.status)}),s.jsx("td",{className:"p-4 max-w-[180px]",children:s.jsx("span",{className:`text-xs ${I.status==="rejected"||I.status==="failed"?"text-red-400":"text-gray-400"}`,title:I.remark,children:I.remark||"-"})}),s.jsx("td",{className:"p-4 text-gray-400",children:I.processedAt?new Date(I.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:I.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:I.userConfirmedAt,children:["已确认 ",new Date(I.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(I.status==="pending"||I.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(J,{size:"sm",onClick:()=>X(I.id),disabled:v===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(Tp,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(J,{size:"sm",variant:"outline",onClick:()=>_(I.id),disabled:v===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(I.status==="processing"||I.status==="pending_confirm")&&s.jsx("div",{className:"mt-2 flex items-center justify-end gap-2",children:s.jsx(J,{size:"sm",variant:"outline",onClick:()=>ae(I.id),disabled:v===I.id,className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:"撤回打款"})}),(I.status==="success"||I.status==="completed")&&I.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:I.transactionId})]})]},I.id))})]})}),s.jsx(us,{page:f,totalPages:O,total:N,pageSize:x,onPageChange:m,onPageSizeChange:I=>{b(I),m(1)}})]})})}),s.jsx(It,{open:!!M,onOpenChange:I=>!I&&ce(),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Rt,{children:s.jsx(Lt,{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(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:L,onChange:I=>R(I.target.value)})})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:ce,disabled:W,children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:se,disabled:W||!L.trim(),children:W?"提交中...":"确认拒绝"})]})]})})]})}var Kx={exports:{}},qx={};/** * @license React * use-sync-external-store-shim.production.js * @@ -705,19 +705,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var uN;function J8(){if(uN)return qx;uN=1;var t=Du();function e(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,x){var b=x(),N=r({inst:{value:b,getSnapshot:x}}),w=N[0].inst,v=N[1];return i(function(){w.value=b,w.getSnapshot=x,u(w)&&v({inst:w})},[m,b,x]),a(function(){return u(w)&&v({inst:w}),m(function(){u(w)&&v({inst:w})})},[m]),o(b),b}function u(m){var x=m.getSnapshot;m=m.value;try{var b=x();return!n(m,b)}catch{return!0}}function h(m,x){return x()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return qx.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,qx}var hN;function W2(){return hN||(hN=1,Kx.exports=J8()),Kx.exports}var K2=W2();function vs(t){this.content=t}vs.prototype={constructor:vs,find:function(t){for(var e=0;e>1}};vs.from=function(t){if(t instanceof vs)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new vs(e)};function q2(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=q2(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function G2(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 Se(r,a)}cutByIndex(e,n){return e==n?Se.empty:e==0&&n==this.content.length?this:new Se(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 Se(a,i)}addToStart(e){return new Se([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Se(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?Jh(n+1,i):Jh(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 Se.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Se(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Se.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}};nn.none=[];class Rf extends Error{}class Fe{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=Q2(this.content,e+this.openStart,n);return r&&new Fe(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Fe(J2(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 Fe.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 Fe(Se.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 Fe(e,r,a)}}Fe.empty=new Fe(Se.empty,0,0);function J2(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(J2(i.content,e-a-1,n-a-1)))}function Q2(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=Q2(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function Q8(t,e,n){if(n.openStart>t.depth)throw new Rf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Rf("Inconsistent open depths");return Y2(t,e,n,0)}function Y2(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 lu(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&&(Rl(t.nodeAfter,r),i++));for(let c=i;ca&&Yg(t,e,a+1),o=r.depth>a&&Yg(n,r,a+1),c=[];return lu(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(X2(i,o),Rl(Ll(i,Z2(t,e,n,r,a+1)),c)):(i&&Rl(Ll(i,Lf(t,e,a+1)),c),lu(e,n,a,c),o&&Rl(Ll(o,Lf(n,r,a+1)),c)),lu(r,null,a,c),new Se(c)}function Lf(t,e,n){let r=[];if(lu(null,t,n,r),t.depth>n){let a=Yg(t,e,n+1);Rl(Ll(a,Lf(t,e,n+1)),r)}return lu(e,null,n,r),new Se(r)}function Y8(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(Se.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class ju{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 Of(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 ju(n,r,i)}static resolveCached(e,n){let r=fN.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()+")"),eS(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=Se.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=Se.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,r);return i.type.checkAttrs(i.attrs),i}};Ci.prototype.text=void 0;class Df extends Ci{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):eS(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 Df(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Df(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 eS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Hl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new t6(e,n);if(r.next==null)return Hl.empty;let a=tS(r);r.next&&r.err("Unexpected trailing text");let i=l6(o6(a));return c6(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(` -`)}}Hl.empty=new Hl(!0);class t6{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 tS(t){let e=[];do e.push(n6(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function n6(t){let e=[];do e.push(s6(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function s6(t){let e=i6(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=r6(t,e);else break;return e}function pN(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function r6(t,e){let n=pN(t),r=n;return t.eat(",")&&(t.next!="}"?r=pN(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function a6(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 i6(t){if(t.eat("(")){let e=tS(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=a6(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 o6(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 Hl(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:rS(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ci(this,this.computeAttrs(e),Se.from(n),nn.setFrom(r))}createChecked(e=null,n,r){return n=Se.from(n),this.checkContent(n),new Ci(this,this.computeAttrs(e),n,nn.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Se.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(Se.empty,!0);return i?new Ci(this,e,n.append(i),nn.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 oS(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 d6(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 u6{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?d6(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Dp{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=iS(e,a.attrs),this.excluded=null;let i=sS(this.attrs);this.instance=i?new nn(this,i):null}create(e=null){return!e&&this.instance?this.instance:new nn(this,rS(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new Dp(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class lS{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=vs.from(e.nodes),n.marks=vs.from(e.marks||{}),this.nodes=xN.compile(this.spec.nodes,this),this.marks=Dp.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]=Hl.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?gN(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==""?[]:gN(this,o.split(" "))}this.nodeFromJSON=a=>Ci.fromJSON(this,a),this.markFromJSON=a=>nn.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 xN){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 Df(r,r.defaultAttrs,e,nn.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 gN(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 h6(t){return t.tag!=null}function f6(t){return t.style!=null}class To{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(h6(a))this.tags.push(a);else if(f6(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 bN(this,n,!1);return r.addAll(e,nn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new bN(this,n,!0);return r.addAll(e,nn.none,n.from,n.to),Fe.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=vN(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=vN(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new To(e,To.schemaRules(e)))}}const cS={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},p6={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dS={ol:!0,ul:!0},ku=1,Zg=2,cu=4;function yN(t,e,n){return e!=null?(e?ku:0)|(e==="full"?Zg:0):t&&t.whitespace=="pre"?ku|Zg:n&~cu}class Qh{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=nn.none,this.match=i||(o&cu?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Se.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&ku)){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=Se.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Se.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&&!cS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class bN{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=yN(null,n.preserveWhitespace,0)|(r?cu:0);a?i=new Qh(a.type,a.attrs,nn.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new Qh(null,null,nn.none,!0,null,o):i=new Qh(e.schema.topNodeType,null,nn.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&Zg?"full":this.localPreserveWS||(a.options&ku)>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,` + */var uN;function J8(){if(uN)return qx;uN=1;var t=_u();function e(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,x){var b=x(),N=r({inst:{value:b,getSnapshot:x}}),w=N[0].inst,v=N[1];return i(function(){w.value=b,w.getSnapshot=x,u(w)&&v({inst:w})},[m,b,x]),a(function(){return u(w)&&v({inst:w}),m(function(){u(w)&&v({inst:w})})},[m]),o(b),b}function u(m){var x=m.getSnapshot;m=m.value;try{var b=x();return!n(m,b)}catch{return!0}}function h(m,x){return x()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return qx.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,qx}var hN;function W2(){return hN||(hN=1,Kx.exports=J8()),Kx.exports}var K2=W2();function vs(t){this.content=t}vs.prototype={constructor:vs,find:function(t){for(var e=0;e>1}};vs.from=function(t){if(t instanceof vs)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new vs(e)};function q2(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=q2(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function G2(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 Ce(r,a)}cutByIndex(e,n){return e==n?Ce.empty:e==0&&n==this.content.length?this:new Ce(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 Ce(a,i)}addToStart(e){return new Ce([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ce(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?Jh(n+1,i):Jh(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 Ce.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ce(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ce.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}};sn.none=[];class Rf extends Error{}class Fe{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=Q2(this.content,e+this.openStart,n);return r&&new Fe(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Fe(J2(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 Fe.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 Fe(Ce.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 Fe(e,r,a)}}Fe.empty=new Fe(Ce.empty,0,0);function J2(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(J2(i.content,e-a-1,n-a-1)))}function Q2(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=Q2(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function Q8(t,e,n){if(n.openStart>t.depth)throw new Rf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Rf("Inconsistent open depths");return Y2(t,e,n,0)}function Y2(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 cu(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&&(Rl(t.nodeAfter,r),i++));for(let c=i;ca&&Yg(t,e,a+1),o=r.depth>a&&Yg(n,r,a+1),c=[];return cu(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(X2(i,o),Rl(Ll(i,Z2(t,e,n,r,a+1)),c)):(i&&Rl(Ll(i,Lf(t,e,a+1)),c),cu(e,n,a,c),o&&Rl(Ll(o,Lf(n,r,a+1)),c)),cu(r,null,a,c),new Ce(c)}function Lf(t,e,n){let r=[];if(cu(null,t,n,r),t.depth>n){let a=Yg(t,e,n+1);Rl(Ll(a,Lf(t,e,n+1)),r)}return cu(e,null,n,r),new Ce(r)}function Y8(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(Ce.from(a));return{start:a.resolveNoCache(t.openStart+n),end:a.resolveNoCache(a.content.size-t.openEnd-n)}}class ku{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 Of(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 ku(n,r,i)}static resolveCached(e,n){let r=fN.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()+")"),eS(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=Ce.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=Ce.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,a,r);return i.type.checkAttrs(i.attrs),i}};Si.prototype.text=void 0;class Df extends Si{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):eS(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 Df(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Df(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 eS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Hl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new t6(e,n);if(r.next==null)return Hl.empty;let a=tS(r);r.next&&r.err("Unexpected trailing text");let i=l6(o6(a));return c6(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(` +`)}}Hl.empty=new Hl(!0);class t6{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 tS(t){let e=[];do e.push(n6(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function n6(t){let e=[];do e.push(s6(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function s6(t){let e=i6(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=r6(t,e);else break;return e}function pN(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function r6(t,e){let n=pN(t),r=n;return t.eat(",")&&(t.next!="}"?r=pN(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function a6(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 i6(t){if(t.eat("(")){let e=tS(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=a6(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 o6(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 Hl(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:rS(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Si(this,this.computeAttrs(e),Ce.from(n),sn.setFrom(r))}createChecked(e=null,n,r){return n=Ce.from(n),this.checkContent(n),new Si(this,this.computeAttrs(e),n,sn.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Ce.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(Ce.empty,!0);return i?new Si(this,e,n.append(i),sn.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 oS(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 d6(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 u6{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?d6(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Dp{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=iS(e,a.attrs),this.excluded=null;let i=sS(this.attrs);this.instance=i?new sn(this,i):null}create(e=null){return!e&&this.instance?this.instance:new sn(this,rS(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new Dp(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class lS{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=vs.from(e.nodes),n.marks=vs.from(e.marks||{}),this.nodes=xN.compile(this.spec.nodes,this),this.marks=Dp.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]=Hl.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?gN(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==""?[]:gN(this,o.split(" "))}this.nodeFromJSON=a=>Si.fromJSON(this,a),this.markFromJSON=a=>sn.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 xN){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 Df(r,r.defaultAttrs,e,sn.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 gN(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 h6(t){return t.tag!=null}function f6(t){return t.style!=null}class Eo{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(h6(a))this.tags.push(a);else if(f6(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 bN(this,n,!1);return r.addAll(e,sn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new bN(this,n,!0);return r.addAll(e,sn.none,n.from,n.to),Fe.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=vN(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=vN(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Eo(e,Eo.schemaRules(e)))}}const cS={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},p6={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dS={ol:!0,ul:!0},Su=1,Zg=2,du=4;function yN(t,e,n){return e!=null?(e?Su:0)|(e==="full"?Zg:0):t&&t.whitespace=="pre"?Su|Zg:n&~du}class Qh{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=sn.none,this.match=i||(o&du?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ce.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&Su)){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=Ce.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ce.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&&!cS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class bN{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=yN(null,n.preserveWhitespace,0)|(r?du:0);a?i=new Qh(a.type,a.attrs,sn.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new Qh(null,null,sn.none,!0,null,o):i=new Qh(e.schema.topNodeType,null,sn.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&Zg?"full":this.localPreserveWS||(a.options&Su)>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):NN(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new Qh(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|=ku)}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 m6(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&dS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function x6(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function vN(t){let e={};for(let n in t)e[n]=t[n];return e}function NN(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&&mf(Jx(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return mf(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Zl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=wN(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return wN(e.marks)}}function wN(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Jx(t){return t.document||window.document}const jN=new WeakMap;function g6(t){let e=jN.get(t);return e===void 0&&jN.set(t,e=y6(t)),e}function y6(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 x=m.indexOf(" ");x>0?u.setAttributeNS(m.slice(0,x),m.slice(x+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:b,contentDOM:N}=mf(t,x,n,r);if(u.appendChild(b),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const uS=65535,hS=Math.pow(2,16);function b6(t,e){return t+e*hS}function kN(t){return t&uS}function v6(t){return(t-(t&uS))/hS}const fS=1,pS=2,xf=4,mS=8;class e0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&mS)>0}get deletedBefore(){return(this.delInfo&(fS|xf))>0}get deletedAfter(){return(this.delInfo&(pS|xf))>0}get deletedAcross(){return(this.delInfo&xf)>0}}class gr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&gr.empty)return gr.empty}recover(e){let n=0,r=kN(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 x=h?e==u?-1:e==m?1:n:n,b=u+a+(x<0?0:f);if(r)return b;let N=e==(n<0?u:m)?null:b6(c/3,e-u),w=e==u?pS:e==m?fS:xf;return(n<0?e!=u:e!=m)&&(w|=mS),new e0(b,w,N)}a+=f-h}return r?e+a:new e0(e+a,0,null)}touches(e,n){let r=0,a=kN(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 Su;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 Hn.fromReplace(e,this.from,this.to,i)}invert(){return new ra(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 wo(n.pos,r.pos,this.mark)}merge(e){return e instanceof wo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wo(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 wo(n.from,n.to,e.markFromJSON(n.mark))}}Ds.jsonID("addMark",wo);class ra extends Ds{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 Fe(uy(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Hn.fromReplace(e,this.from,this.to,r)}invert(){return new wo(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 ra(n.pos,r.pos,this.mark)}merge(e){return e instanceof ra&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ra(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 ra(n.from,n.to,e.markFromJSON(n.mark))}}Ds.jsonID("removeMark",ra);class jo extends Ds{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Hn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Hn.fromReplace(e,this.pos,this.pos+1,new Fe(Se.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 hs(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 hs(n.from,n.to,n.gapFrom,n.gapTo,Fe.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ds.jsonID("replaceAround",hs);function t0(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 N6(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 x=Math.max(h,e),b=Math.min(h+u.nodeSize,n),N=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function w6(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 Dp){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 ra(o.from,o.to,o.style)))}function hy(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 j6(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hd(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;N--)w||r.index(N)>0?(w=!0,f=Se.from(r.node(N).copy(f)),m++):u--;let x=Se.empty,b=0;for(let N=i,w=!1;N>n;N--)w||a.after(N+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=Se.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new hs(a,i,a,i,new Fe(r,0,0),n.length,!0))}function T6(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)&&M6(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",N=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!N?h=!1:!b&&N&&(h=!0)}h===!1&&gS(t,o,c,i),hy(t,t.mapping.slice(i).map(c,1),r,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),x=f.map(c+o.nodeSize,1);return t.step(new hs(m,x,m+1,x-1,new Fe(Se.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&xS(t,o,c,i),!1}})}function xS(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 gS(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 M6(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function A6(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 hs(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Fe(Se.from(o),0,0),1,!0))}function Ei(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),x=a.index(h);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(x,m.childCount),N=r&&r[f+1];N&&(b=b.replaceChild(0,N.type.create(N.attrs)));let w=r&&r[f]||m;if(!m.canReplace(x+1,m.childCount)||!w.type.validContent(b))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 P6(t,e,n=1,r){let a=t.doc.resolve(e),i=Se.empty,o=Se.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Se.from(a.node(c).copy(i));let f=r&&r[h];o=Se.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new is(e,e,new Fe(i.append(o),n,n),!0))}function Wo(t,e){let n=t.resolve(e),r=n.index();return yS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function I6(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&&yS(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 R6(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);gS(t,f.node(),f.before(),c)}o.inlineContent&&hy(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 is(h,u.map(e+n,-1),Fe.empty,!0)),r===!0){let f=t.doc.resolve(h);xS(t,f.node(),f.before(),t.steps.length)}return t}function L6(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 $p(t,e,n=e,r=Fe.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return vS(a,i,r)?new is(e,n,r):new O6(a,i,r).fit()}function vS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class O6{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Se.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=Se.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 Fe(i,o,c);return e>-1?new hs(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new is(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=Yx(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(Se.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=Yx(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Fe(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=Yx(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new Fe(Zd(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Fe(Zd(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=v,f.push(NS(w.mark(x.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?b:-1)))}let N=h==c.childCount;N||(b=-1),this.placed=eu(this.placed,n,Se.from(f)),this.frontier[n].match=m,N&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,v=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=Xx(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=eu(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=eu(this.placed,this.depth,Se.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Se.empty,!0);n.childCount&&(this.placed=eu(this.placed,this.frontier.length,n))}}function Zd(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Zd(t.firstChild.content,e-1,n)))}function eu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(eu(t.lastChild.content,e-1,n)))}function Yx(t,e){for(let n=0;n1&&(r=r.replaceChild(0,NS(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(Se.empty,!0)))),t.copy(r)}function Xx(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&&!D6(n,i.content,o)?c:null}function D6(t,e,n){for(let r=n;r0;x--,b--){let N=a.node(x).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(x)>-1?c=x:a.before(x)==b&&o.splice(1,0,-x)}let u=o.indexOf(c),h=[],f=r.openStart;for(let x=r.content,b=0;;b++){let N=x.firstChild;if(h.push(N),b==r.openStart)break;x=N.content}for(let x=f-1;x>=0;x--){let b=h[x],N=_6(b.type);if(N&&!b.sameMarkup(a.node(Math.abs(c)-1)))f=x;else if(N||!b.type.isTextblock)break}for(let x=r.openStart;x>=0;x--){let b=(x+f+1)%(r.openStart+1),N=h[b];if(N)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));x--){let b=o[x];b<0||(e=a.before(b),n=i.after(b))}}function wS(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(Se.empty,!0))}return t}function z6(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=L6(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new Fe(Se.from(r),0,0))}function F6(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=jS(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 jS(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 Gc extends Ds{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 Hn.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 Hn.fromReplace(e,this.pos,this.pos+1,new Fe(Se.from(a),0,n.isLeaf?0:1))}getMap(){return gr.empty}invert(e){return new Gc(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 Gc(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 Gc(n.pos,n.attr,n.value)}}Ds.jsonID("attr",Gc);class Cu extends Ds{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 Hn.ok(r)}getMap(){return gr.empty}invert(e){return new Cu(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 Cu(n.attr,n.value)}}Ds.jsonID("docAttr",Cu);let Xc=class extends Error{};Xc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Xc.prototype=Object.create(Error.prototype);Xc.prototype.constructor=Xc;Xc.prototype.name="TransformError";class py{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Su}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Xc(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=Fe.empty){let a=$p(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new Fe(Se.from(r),0,0))}delete(e,n){return this.replace(e,n,Fe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return $6(this,e,n,r),this}replaceRangeWith(e,n,r){return z6(this,e,n,r),this}deleteRange(e,n){return F6(this,e,n),this}lift(e,n){return k6(this,e,n),this}join(e,n=1){return R6(this,e,n),this}wrap(e,n){return E6(this,e,n),this}setBlockType(e,n=e,r,a=null){return T6(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return A6(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new Gc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Cu(e,n)),this}addNodeMark(e,n){return this.step(new jo(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 nn)n.isInSet(r.marks)&&this.step(new Ul(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new Ul(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 P6(this,e,n,r),this}addMark(e,n,r){return N6(this,e,n,r),this}removeMark(e,n,r){return w6(this,e,n,r),this}clearIncompatible(e,n,r){return hy(this,e,n,r),this}}const Zx=Object.create(null);class ct{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new kS(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?$c(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):$c(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 br(e.node(0))}static atStart(e){return $c(e,e,0,0,1)||new br(e)}static atEnd(e){return $c(e,e,e.content.size,e.childCount,-1)||new br(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Zx[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 Zx)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zx[e]=n,n.prototype.jsonID=e,n}getBookmark(){return st.between(this.$anchor,this.$head).getBookmark()}}ct.prototype.visible=!0;class kS{constructor(e,n){this.$from=e,this.$to=n}}let CN=!1;function EN(t){!CN&&!t.parent.inlineContent&&(CN=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class st extends ct{constructor(e,n=e){EN(e),EN(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 ct.near(r);let a=e.resolve(n.map(this.anchor));return new st(a.parent.inlineContent?a:r,r)}replace(e,n=Fe.empty){if(super.replace(e,n),n==Fe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof st&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zp(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 st(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=ct.findFrom(n,r,!0)||ct.findFrom(n,-r,!0);if(i)n=i.$head;else return ct.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ct.findFrom(e,-r,!0)||ct.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&&nt.isSelectable(c))return nt.create(t,n-(a<0?c.nodeSize:0))}else{let u=$c(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function TN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ct.near(t.doc.resolve(o),n))}const MN=1,Yh=2,AN=4;class V6 extends py{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|=Yh,this}ensureMarks(e){return nn.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&Yh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Yh,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)||nn.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(ct.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|=AN,this}get scrolledIntoView(){return(this.updated&AN)>0}}function PN(t,e){return!e||!t?t:t.bind(e)}class tu{constructor(e,n,r){this.name=e,this.init=PN(n.init,r),this.apply=PN(n.apply,r)}}const H6=[new tu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new tu("selection",{init(t,e){return t.selection||ct.atStart(e.doc)},apply(t){return t.selection}}),new tu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new tu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class eg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=H6.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 tu(r.key,r.spec.state,r))})}}class Wc{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 eg(e.schema,e.plugins),i=new Wc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=Ci.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ct.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 SS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=SS(a,e,{})),n[r]=a}return n}class an{constructor(e){this.spec=e,this.props={},e.props&&SS(e.props,this,this.props),this.key=e.key?e.key.key:CS("plugin")}getState(e){return e[this.key]}}const tg=Object.create(null);function CS(t){return t in tg?t+"$"+ ++tg[t]:(tg[t]=0,t+"$")}class bn{constructor(e="key"){this.key=CS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const xy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ES(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const TS=(t,e,n)=>{let r=ES(t,n);if(!r)return!1;let a=gy(r);if(!a){let o=r.blockRange(),c=o&&hd(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(_S(t,a,e,-1))return!0;if(r.parent.content.size==0&&(Zc(i,"end")||nt.isSelectable(i)))for(let o=r.depth;;o--){let c=$p(t.doc,r.before(o),r.after(o),Fe.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},U6=(t,e,n)=>{let r=ES(t,n);if(!r)return!1;let a=gy(r);return a?MS(t,a,e):!1},W6=(t,e,n)=>{let r=PS(t,n);if(!r)return!1;let a=yy(r);return a?MS(t,a,e):!1};function MS(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=$p(t.doc,i,u,Fe.empty);if(!h||h.from!=i||h instanceof is&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(st.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Zc(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 AS=(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=gy(r)}let o=i&&i.nodeBefore;return!o||!nt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(nt.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function gy(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 PS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=PS(t,n);if(!r)return!1;let a=yy(r);if(!a)return!1;let i=a.nodeAfter;if(_S(t,a,e,1))return!0;if(r.parent.content.size==0&&(Zc(i,"start")||nt.isSelectable(i))){let o=$p(t.doc,r.before(),r.after(),Fe.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 nt,a;if(r){if(n.node.isTextblock||!Wo(t.doc,n.from))return!1;a=n.from}else if(a=_p(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(nt.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},q6=(t,e)=>{let n=t.selection,r;if(n instanceof nt){if(n.node.isTextblock||!Wo(t.doc,n.to))return!1;r=n.to}else if(r=_p(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},G6=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&hd(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},LS=(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 by(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=by(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(ct.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},OS=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof br||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=by(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(Ei(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&hd(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function Q6(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof nt&&e.selection.node.isBlock)return!r.parentOffset||!Ei(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 b=r.depth;;b--)if(r.node(b).isBlock){u=r.end(b)==r.pos+(r.depth-b),h=r.start(b)==r.pos-(r.depth-b),c=by(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),i.unshift(u&&c?{type:c}:null),o=b;break}else{if(b==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof st||e.selection instanceof br)&&f.deleteSelection();let m=f.mapping.map(r.pos),x=Ei(f.doc,m,i.length,i);if(x||(i[0]=c?{type:c}:null,x=Ei(f.doc,m,i.length,i)),!x)return!1;if(f.split(m,i.length,i),!u&&h&&r.node(o).type!=c){let b=f.mapping.map(r.before(o)),N=f.doc.resolve(b);c&&r.node(o-1).canReplaceWith(N.index(),N.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const Y6=Q6(),X6=(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(nt.create(t.doc,a))),!0)};function Z6(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||Wo(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function _S(t,e,n,r){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&Z6(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 b=e.pos+i.nodeSize,N=Se.empty;for(let k=o.length-1;k>=0;k--)N=Se.from(o[k].create(null,N));N=Se.from(a.copy(N));let w=t.tr.step(new hs(e.pos-1,b,e.pos,b,new Fe(N,1,0),o.length,!0)),v=w.doc.resolve(b+2*o.length);v.nodeAfter&&v.nodeAfter.type==a.type&&Wo(w.doc,v.pos)&&w.join(v.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:ct.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),x=m&&hd(m);if(x!=null&&x>=e.depth)return n&&n(t.tr.lift(m,x).scrollIntoView()),!0;if(h&&Zc(i,"start",!0)&&Zc(a,"end")){let b=a,N=[];for(;N.push(b),!b.isTextblock;)b=b.lastChild;let w=i,v=1;for(;!w.isTextblock;w=w.firstChild)v++;if(b.canReplace(b.childCount,b.childCount,w.content)){if(n){let k=Se.empty;for(let E=N.length-1;E>=0;E--)k=Se.from(N[E].copy(k));let M=t.tr.step(new hs(e.pos-N.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new Fe(k,N.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function $S(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(st.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const eL=$S(-1),tL=$S(1);function nL(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&fy(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function IN(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 Of(u,u,e.depth),e.endIndex=0;f--)i=Se.from(n[f].type.create(n[f].attrs,i));t.step(new hs(e.start-(r?2:0),e.end,e.start,e.end,new Fe(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?oL(e,n,t,i):lL(e,n,i):!0:!1}}function oL(t,e,n,r){let a=t.tr,i=r.end,o=r.$to.end(r.depth);iw;N--)b-=a.child(N).nodeSize,r.delete(b-1,b+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?Se.empty:Se.from(a))))return!1;let m=i.pos,x=m+o.nodeSize;return r.step(new hs(m-(c?1:0),x+(u?1:0),m+1,x-1,new Fe((c?Se.empty:Se.from(a.copy(Se.empty))).append(u?Se.empty:Se.from(a.copy(Se.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function cL(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=Se.from(h?t.create():null),m=new Fe(Se.from(t.create(null,Se.from(c.type.create(null,f)))),h?3:1,0),x=i.start,b=i.end;n(e.tr.step(new hs(x-(h?3:1),b,x,b,m,1,!0)).scrollIntoView())}return!0}}const Ns=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ed=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let n0=null;const xi=function(t,e,n){let r=n0||(n0=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},dL=function(){n0=null},Wl=function(t,e,n,r){return n&&(RN(t,e,n,r,-1)||RN(t,e,n,r,1))},uL=/^(img|br|input|textarea|hr)$/i;function RN(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:_r(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Fu(t)||uL.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ns(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?_r(t):0}else return!1}}function _r(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function hL(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=_r(t)}else if(t.parentNode&&!Fu(t))e=Ns(t),t=t.parentNode;else return null}}function fL(t,e){for(;;){if(t.nodeType==3&&e2),Dr=td||(La?/Mac/.test(La.platform):!1),BS=La?/Win/.test(La.platform):!1,ji=/Android \d/.test(Ko),Bu=!!LN&&"webkitFontSmoothing"in LN.documentElement.style,gL=Bu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yL(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 ui(t,e){return typeof t=="number"?t:t[e]}function bL(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 ON(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=ed(o);continue}let c=o,u=c==i.body,h=u?yL(i):bL(c),f=0,m=0;if(e.toph.bottom-ui(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ui(a,"top")-h.top:e.bottom-h.bottom+ui(a,"bottom")),e.lefth.right-ui(r,"right")&&(f=e.right-h.right+ui(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let b=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-b,v=c.scrollTop-N;e={left:e.left-w,top:e.top-v,right:e.right-w,bottom:e.bottom-v}}let x=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(x))break;o=x=="absolute"?o.offsetParent:ed(o)}}function vL(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:VS(t.dom)}}function VS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ed(r));return e}function NL({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;HS(n,r==0?0:r-e)}function HS(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let w=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,r=0),n&&n.nodeType==3?jL(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:US(n,a)}function jL(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 Ny(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function kL(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 CL(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 WS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;Bu&&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=CL(t,r,a,e))}c==null&&(c=SL(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function DN(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,Jd(uo(xi(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==_r(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return ng(u.getBoundingClientRect(),!1)}if(i==null&&a<_r(r)){let u=r.childNodes[a];if(u.nodeType==1)return ng(u.getBoundingClientRect(),!0)}return ng(r.getBoundingClientRect(),n>=0)}if(i==null&&a&&(n<0||a==_r(r))){let u=r.childNodes[a-1],h=u.nodeType==3?xi(u,_r(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return Jd(uo(h,1),!1)}if(i==null&&a<_r(r)){let u=r.childNodes[a];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let h=u?u.nodeType==3?xi(u,0,o?0:1):u.nodeType==1?u:null:null;if(h)return Jd(uo(h,-1),!0)}return Jd(uo(r.nodeType==3?xi(r):r,-n),n>=0)}function Jd(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 ng(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qS(t,e,n){let 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 ML(t,e,n){let r=e.selection,a=n=="up"?r.$from:r.$to;return qS(t,e,()=>{let{node:i}=t.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let o=KS(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=xi(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 AL=/[\u0590-\u08ac]/;function PL(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?!AL.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:qS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),x=c.caretBidiLevel;c.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:N,focusOffset:w}=t.domSelectionRange(),v=N&&!b.contains(N.nodeType==1?N:N.parentNode)||u==N&&h==w;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return x!=null&&(c.caretBidiLevel=x),v}):r.pos==r.start()||r.pos==r.end()}let _N=null,$N=null,zN=!1;function IL(t,e,n){return _N==e&&$N==n?zN:(_N=e,$N=n,zN=n=="up"||n=="down"?ML(t,e,n):PL(t,e,n))}const zr=0,FN=1,Ml=2,Oa=3;class Vu{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=zr,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;nNs(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 JS){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 GS&&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?Ns(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 x=this.children[m-1];if(x.size&&x.dom.parentNode==this.contentDOM&&!x.emptyChildAt(1)){a=Ns(x.dom)+1;break}e-=x.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fN&&on){let N=c;c=u,u=N}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(b)}}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?Ml:FN,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Oa:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ml:Oa}r=o}this.dirty=Ml}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ml:FN;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==zr&&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 RL extends Vu{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 Kl extends Vu{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=Zl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Kl(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Oa||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oa&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=zr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=o0(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}=Zl.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 x=f;return f=XS(f,r,n),h?u=new LL(e,n,r,a,f,m||null,x,h,i,o+1):n.isText?new Bp(e,n,r,a,f,x,i):new Ao(e,n,r,a,f,m||null,x,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=()=>Se.empty)}return e}matchesNode(e,n,r){return this.dirty==zr&&e.eq(this.node)&&_f(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 DL(this,o&&o.node,e);zL(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?nn.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,a)},(h,f,m,x)=>{u.syncToMarks(h.marks,r,e,x);let b;u.findNodeMatch(h,f,m,x)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,b,e)||u.updateNextNode(h,f,m,e,x,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==Ml)&&(o&&this.protectLocalComposition(e,o),QS(this.contentDOM,this.children,e),td&&FL(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof st)||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=BL(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 RL(this,i,n,a);e.input.compositionNodes.push(o),this.children=o0(this.children,r,r+a.length,e,o)}update(e,n,r,a){return this.dirty==Oa||!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=zr}updateOuterDeco(e){if(_f(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=YS(this.dom,this.nodeDOM,i0(this.outerDeco,this.node,n),i0(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 BN(t,e,n,r,a){XS(r,e,t);let i=new Ao(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Bp extends Ao{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==Oa||this.dirty!=zr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=zr||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=zr,!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 Bp(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=Oa)}get domAtom(){return!1}isText(e){return this.node.text==e}}class JS extends Vu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==zr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class LL extends Ao{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==Oa)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 QS(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=Kl.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 Kl)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 $L(t,e){return t.type.side-e.type.side}function zL(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 N=i+x.nodeSize;if(x.isText){let v=N;o!v.inline):c.slice();r(x,w,e.forChild(i,x),b),i=N}}function FL(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 BL(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 o0(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 wy(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(Fp(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&nt.isSelectable(m)&&a.parent&&!(m.isInline&&pL(n.focusNode,n.focusOffset,a.dom))){let x=a.posBefore;h=new nt(o==x?c:r.resolve(x))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,x=o;for(let b=0;b{(n.anchorNode!=r||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!ZS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function HL(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ns(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&cr&&Mo<=11&&(n.disabled=!0,n.disabled=!1)}function eC(t,e){if(e instanceof nt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(KN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else KN(t)}function KN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function jy(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||st.between(e,n,r)}function qN(t){return t.editable&&!t.hasFocus()?!1:tC(t)}function tC(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 UL(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Wl(e.node,e.offset,n.anchorNode,n.anchorOffset)}function l0(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&&ct.findFrom(i,e)}function ho(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function GN(t,e,n){let r=t.state.selection;if(r instanceof st)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 ho(t,new st(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=l0(t.state,e);return a&&a instanceof nt?ho(t,a):!1}else if(!(Dr&&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?nt.isSelectable(i)?ho(t,new nt(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Bu?ho(t,new st(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof nt&&r.node.isInline)return ho(t,new st(e>0?r.$to:r.$from));{let a=l0(t.state,e);return a?ho(t,a):!1}}}function $f(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function uu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Dc(t,e){return e<0?WL(t):KL(t)}function WL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for($r&&n.nodeType==1&&r<$f(n)&&uu(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(uu(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(nC(n))break;{let c=n.previousSibling;for(;c&&uu(c,-1);)a=n.parentNode,i=Ns(c),c=c.previousSibling;if(c)n=c,r=$f(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?c0(t,n,r):a&&c0(t,a,i)}function KL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=$f(n),i,o;for(;;)if(r{t.state==a&&Ti(t)},50)}function JN(t,e){let n=t.state.doc.resolve(e);if(!(js||BS)&&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 QN(t,e,n){let r=t.state.selection;if(r instanceof st&&!r.empty||n.indexOf("s")>-1||Dr&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=r;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=l0(t.state,e);if(o&&o instanceof nt)return ho(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof br?ct.near(o,e):ct.findFrom(o,e);return c?ho(t,c):!1}return!1}function YN(t,e){if(!(t.state.selection instanceof st))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 XN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function JL(t){if(!Ls||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;XN(t,r,"true"),setTimeout(()=>XN(t,r,"false"),20)}return!1}function QL(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function YL(t,e){let n=e.keyCode,r=QL(e);if(n==8||Dr&&n==72&&r=="c")return YN(t,-1)||Dc(t,-1);if(n==46&&!e.shiftKey||Dr&&n==68&&r=="c")return YN(t,1)||Dc(t,1);if(n==13||n==27)return!0;if(n==37||Dr&&n==66&&r=="c"){let a=n==37?JN(t,t.state.selection.from)=="ltr"?-1:1:-1;return GN(t,a,r)||Dc(t,a)}else if(n==39||Dr&&n==70&&r=="c"){let a=n==39?JN(t,t.state.selection.from)=="ltr"?1:-1:1;return GN(t,a,r)||Dc(t,a)}else{if(n==38||Dr&&n==80&&r=="c")return QN(t,-1,r)||Dc(t,-1);if(n==40||Dr&&n==78&&r=="c")return JL(t)||QN(t,1,r)||Dc(t,1);if(r==(Dr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ky(t,e){t.someProp("transformCopied",b=>{e=b(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 b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let o=t.someProp("clipboardSerializer")||Zl.fromSchema(t.state.schema),c=lC(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=oC[h.nodeName.toLowerCase()]);){for(let b=f.length-1;b>=0;b--){let N=c.createElement(f[b]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let x=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,` +`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let a=0;a!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,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):NN(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new Qh(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|=Su)}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 m6(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&dS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function x6(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function vN(t){let e={};for(let n in t)e[n]=t[n];return e}function NN(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&&mf(Jx(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return mf(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Zl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=wN(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return wN(e.marks)}}function wN(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Jx(t){return t.document||window.document}const jN=new WeakMap;function g6(t){let e=jN.get(t);return e===void 0&&jN.set(t,e=y6(t)),e}function y6(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 x=m.indexOf(" ");x>0?u.setAttributeNS(m.slice(0,x),m.slice(x+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:b,contentDOM:N}=mf(t,x,n,r);if(u.appendChild(b),N){if(c)throw new RangeError("Multiple content holes");c=N}}}return{dom:u,contentDOM:c}}const uS=65535,hS=Math.pow(2,16);function b6(t,e){return t+e*hS}function kN(t){return t&uS}function v6(t){return(t-(t&uS))/hS}const fS=1,pS=2,xf=4,mS=8;class e0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&mS)>0}get deletedBefore(){return(this.delInfo&(fS|xf))>0}get deletedAfter(){return(this.delInfo&(pS|xf))>0}get deletedAcross(){return(this.delInfo&xf)>0}}class gr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&gr.empty)return gr.empty}recover(e){let n=0,r=kN(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 x=h?e==u?-1:e==m?1:n:n,b=u+a+(x<0?0:f);if(r)return b;let N=e==(n<0?u:m)?null:b6(c/3,e-u),w=e==u?pS:e==m?fS:xf;return(n<0?e!=u:e!=m)&&(w|=mS),new e0(b,w,N)}a+=f-h}return r?e+a:new e0(e+a,0,null)}touches(e,n){let r=0,a=kN(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 Cu;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 Hn.fromReplace(e,this.from,this.to,i)}invert(){return new ra(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 No(n.pos,r.pos,this.mark)}merge(e){return e instanceof No&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new No(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 No(n.from,n.to,e.markFromJSON(n.mark))}}Ds.jsonID("addMark",No);class ra extends Ds{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 Fe(uy(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Hn.fromReplace(e,this.from,this.to,r)}invert(){return new No(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 ra(n.pos,r.pos,this.mark)}merge(e){return e instanceof ra&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ra(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 ra(n.from,n.to,e.markFromJSON(n.mark))}}Ds.jsonID("removeMark",ra);class wo extends Ds{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Hn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Hn.fromReplace(e,this.pos,this.pos+1,new Fe(Ce.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 hs(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 hs(n.from,n.to,n.gapFrom,n.gapTo,Fe.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ds.jsonID("replaceAround",hs);function t0(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 N6(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 x=Math.max(h,e),b=Math.min(h+u.nodeSize,n),N=r.addToSet(m);for(let w=0;wt.step(u)),i.forEach(u=>t.step(u))}function w6(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 Dp){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 ra(o.from,o.to,o.style)))}function hy(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 j6(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hd(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;N--)w||r.index(N)>0?(w=!0,f=Ce.from(r.node(N).copy(f)),m++):u--;let x=Ce.empty,b=0;for(let N=i,w=!1;N>n;N--)w||a.after(N+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=Ce.from(n[o].type.create(n[o].attrs,r))}let a=e.start,i=e.end;t.step(new hs(a,i,a,i,new Fe(r,0,0),n.length,!0))}function T6(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)&&M6(t.doc,t.mapping.slice(i).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",N=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!N?h=!1:!b&&N&&(h=!0)}h===!1&&gS(t,o,c,i),hy(t,t.mapping.slice(i).map(c,1),r,void 0,h===null);let f=t.mapping.slice(i),m=f.map(c,1),x=f.map(c+o.nodeSize,1);return t.step(new hs(m,x,m+1,x-1,new Fe(Ce.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&xS(t,o,c,i),!1}})}function xS(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 gS(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 M6(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function A6(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 hs(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Fe(Ce.from(o),0,0),1,!0))}function Ci(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),x=a.index(h);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(x,m.childCount),N=r&&r[f+1];N&&(b=b.replaceChild(0,N.type.create(N.attrs)));let w=r&&r[f]||m;if(!m.canReplace(x+1,m.childCount)||!w.type.validContent(b))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 P6(t,e,n=1,r){let a=t.doc.resolve(e),i=Ce.empty,o=Ce.empty;for(let c=a.depth,u=a.depth-n,h=n-1;c>u;c--,h--){i=Ce.from(a.node(c).copy(i));let f=r&&r[h];o=Ce.from(f?f.type.create(f.attrs,o):a.node(c).copy(o))}t.step(new is(e,e,new Fe(i.append(o),n,n),!0))}function Wo(t,e){let n=t.resolve(e),r=n.index();return yS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function I6(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&&yS(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 R6(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);gS(t,f.node(),f.before(),c)}o.inlineContent&&hy(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 is(h,u.map(e+n,-1),Fe.empty,!0)),r===!0){let f=t.doc.resolve(h);xS(t,f.node(),f.before(),t.steps.length)}return t}function L6(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 $p(t,e,n=e,r=Fe.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return vS(a,i,r)?new is(e,n,r):new O6(a,i,r).fit()}function vS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class O6{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ce.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=Ce.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 Fe(i,o,c);return e>-1?new hs(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new is(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=Yx(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(Ce.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=Yx(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Fe(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=Yx(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new Fe(eu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Fe(eu(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=v,f.push(NS(w.mark(x.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?b:-1)))}let N=h==c.childCount;N||(b=-1),this.placed=tu(this.placed,n,Ce.from(f)),this.frontier[n].match=m,N&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,v=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=Xx(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=tu(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=tu(this.placed,this.depth,Ce.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ce.empty,!0);n.childCount&&(this.placed=tu(this.placed,this.frontier.length,n))}}function eu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(eu(t.firstChild.content,e-1,n)))}function tu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(tu(t.lastChild.content,e-1,n)))}function Yx(t,e){for(let n=0;n1&&(r=r.replaceChild(0,NS(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(Ce.empty,!0)))),t.copy(r)}function Xx(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&&!D6(n,i.content,o)?c:null}function D6(t,e,n){for(let r=n;r0;x--,b--){let N=a.node(x).type.spec;if(N.defining||N.definingAsContext||N.isolating)break;o.indexOf(x)>-1?c=x:a.before(x)==b&&o.splice(1,0,-x)}let u=o.indexOf(c),h=[],f=r.openStart;for(let x=r.content,b=0;;b++){let N=x.firstChild;if(h.push(N),b==r.openStart)break;x=N.content}for(let x=f-1;x>=0;x--){let b=h[x],N=_6(b.type);if(N&&!b.sameMarkup(a.node(Math.abs(c)-1)))f=x;else if(N||!b.type.isTextblock)break}for(let x=r.openStart;x>=0;x--){let b=(x+f+1)%(r.openStart+1),N=h[b];if(N)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));x--){let b=o[x];b<0||(e=a.before(b),n=i.after(b))}}function wS(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(Ce.empty,!0))}return t}function z6(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=L6(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new Fe(Ce.from(r),0,0))}function F6(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=jS(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 jS(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 Gc extends Ds{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 Hn.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 Hn.fromReplace(e,this.pos,this.pos+1,new Fe(Ce.from(a),0,n.isLeaf?0:1))}getMap(){return gr.empty}invert(e){return new Gc(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 Gc(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 Gc(n.pos,n.attr,n.value)}}Ds.jsonID("attr",Gc);class Eu extends Ds{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 Hn.ok(r)}getMap(){return gr.empty}invert(e){return new Eu(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 Eu(n.attr,n.value)}}Ds.jsonID("docAttr",Eu);let Xc=class extends Error{};Xc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Xc.prototype=Object.create(Error.prototype);Xc.prototype.constructor=Xc;Xc.prototype.name="TransformError";class py{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Cu}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Xc(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=Fe.empty){let a=$p(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new Fe(Ce.from(r),0,0))}delete(e,n){return this.replace(e,n,Fe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return $6(this,e,n,r),this}replaceRangeWith(e,n,r){return z6(this,e,n,r),this}deleteRange(e,n){return F6(this,e,n),this}lift(e,n){return k6(this,e,n),this}join(e,n=1){return R6(this,e,n),this}wrap(e,n){return E6(this,e,n),this}setBlockType(e,n=e,r,a=null){return T6(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return A6(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new Gc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Eu(e,n)),this}addNodeMark(e,n){return this.step(new wo(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 sn)n.isInSet(r.marks)&&this.step(new Ul(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new Ul(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 P6(this,e,n,r),this}addMark(e,n,r){return N6(this,e,n,r),this}removeMark(e,n,r){return w6(this,e,n,r),this}clearIncompatible(e,n,r){return hy(this,e,n,r),this}}const Zx=Object.create(null);class ct{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new kS(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?$c(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):$c(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 br(e.node(0))}static atStart(e){return $c(e,e,0,0,1)||new br(e)}static atEnd(e){return $c(e,e,e.content.size,e.childCount,-1)||new br(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Zx[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 Zx)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zx[e]=n,n.prototype.jsonID=e,n}getBookmark(){return st.between(this.$anchor,this.$head).getBookmark()}}ct.prototype.visible=!0;class kS{constructor(e,n){this.$from=e,this.$to=n}}let CN=!1;function EN(t){!CN&&!t.parent.inlineContent&&(CN=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class st extends ct{constructor(e,n=e){EN(e),EN(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 ct.near(r);let a=e.resolve(n.map(this.anchor));return new st(a.parent.inlineContent?a:r,r)}replace(e,n=Fe.empty){if(super.replace(e,n),n==Fe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof st&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zp(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 st(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=ct.findFrom(n,r,!0)||ct.findFrom(n,-r,!0);if(i)n=i.$head;else return ct.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ct.findFrom(e,-r,!0)||ct.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&&nt.isSelectable(c))return nt.create(t,n-(a<0?c.nodeSize:0))}else{let u=$c(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function TN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ct.near(t.doc.resolve(o),n))}const MN=1,Yh=2,AN=4;class V6 extends py{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|=Yh,this}ensureMarks(e){return sn.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&Yh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Yh,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)||sn.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(ct.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|=AN,this}get scrolledIntoView(){return(this.updated&AN)>0}}function PN(t,e){return!e||!t?t:t.bind(e)}class nu{constructor(e,n,r){this.name=e,this.init=PN(n.init,r),this.apply=PN(n.apply,r)}}const H6=[new nu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new nu("selection",{init(t,e){return t.selection||ct.atStart(e.doc)},apply(t){return t.selection}}),new nu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new nu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class eg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=H6.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 nu(r.key,r.spec.state,r))})}}class Wc{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 eg(e.schema,e.plugins),i=new Wc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=Si.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ct.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 SS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=SS(a,e,{})),n[r]=a}return n}class on{constructor(e){this.spec=e,this.props={},e.props&&SS(e.props,this,this.props),this.key=e.key?e.key.key:CS("plugin")}getState(e){return e[this.key]}}const tg=Object.create(null);function CS(t){return t in tg?t+"$"+ ++tg[t]:(tg[t]=0,t+"$")}class bn{constructor(e="key"){this.key=CS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const xy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ES(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const TS=(t,e,n)=>{let r=ES(t,n);if(!r)return!1;let a=gy(r);if(!a){let o=r.blockRange(),c=o&&hd(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=a.nodeBefore;if(_S(t,a,e,-1))return!0;if(r.parent.content.size==0&&(Zc(i,"end")||nt.isSelectable(i)))for(let o=r.depth;;o--){let c=$p(t.doc,r.before(o),r.after(o),Fe.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},U6=(t,e,n)=>{let r=ES(t,n);if(!r)return!1;let a=gy(r);return a?MS(t,a,e):!1},W6=(t,e,n)=>{let r=PS(t,n);if(!r)return!1;let a=yy(r);return a?MS(t,a,e):!1};function MS(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=$p(t.doc,i,u,Fe.empty);if(!h||h.from!=i||h instanceof is&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(st.create(f.doc,i)),n(f.scrollIntoView())}return!0}function Zc(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 AS=(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=gy(r)}let o=i&&i.nodeBefore;return!o||!nt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(nt.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function gy(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 PS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=PS(t,n);if(!r)return!1;let a=yy(r);if(!a)return!1;let i=a.nodeAfter;if(_S(t,a,e,1))return!0;if(r.parent.content.size==0&&(Zc(i,"start")||nt.isSelectable(i))){let o=$p(t.doc,r.before(),r.after(),Fe.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 nt,a;if(r){if(n.node.isTextblock||!Wo(t.doc,n.from))return!1;a=n.from}else if(a=_p(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(nt.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},q6=(t,e)=>{let n=t.selection,r;if(n instanceof nt){if(n.node.isTextblock||!Wo(t.doc,n.to))return!1;r=n.to}else if(r=_p(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},G6=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&hd(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},LS=(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 by(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=by(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(ct.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},OS=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof br||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=by(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(Ci(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&hd(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function Q6(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof nt&&e.selection.node.isBlock)return!r.parentOffset||!Ci(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 b=r.depth;;b--)if(r.node(b).isBlock){u=r.end(b)==r.pos+(r.depth-b),h=r.start(b)==r.pos-(r.depth-b),c=by(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),i.unshift(u&&c?{type:c}:null),o=b;break}else{if(b==1)return!1;i.unshift(null)}let f=e.tr;(e.selection instanceof st||e.selection instanceof br)&&f.deleteSelection();let m=f.mapping.map(r.pos),x=Ci(f.doc,m,i.length,i);if(x||(i[0]=c?{type:c}:null,x=Ci(f.doc,m,i.length,i)),!x)return!1;if(f.split(m,i.length,i),!u&&h&&r.node(o).type!=c){let b=f.mapping.map(r.before(o)),N=f.doc.resolve(b);c&&r.node(o-1).canReplaceWith(N.index(),N.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const Y6=Q6(),X6=(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(nt.create(t.doc,a))),!0)};function Z6(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||Wo(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function _S(t,e,n,r){let a=e.nodeBefore,i=e.nodeAfter,o,c,u=a.type.spec.isolating||i.type.spec.isolating;if(!u&&Z6(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 b=e.pos+i.nodeSize,N=Ce.empty;for(let k=o.length-1;k>=0;k--)N=Ce.from(o[k].create(null,N));N=Ce.from(a.copy(N));let w=t.tr.step(new hs(e.pos-1,b,e.pos,b,new Fe(N,1,0),o.length,!0)),v=w.doc.resolve(b+2*o.length);v.nodeAfter&&v.nodeAfter.type==a.type&&Wo(w.doc,v.pos)&&w.join(v.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:ct.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),x=m&&hd(m);if(x!=null&&x>=e.depth)return n&&n(t.tr.lift(m,x).scrollIntoView()),!0;if(h&&Zc(i,"start",!0)&&Zc(a,"end")){let b=a,N=[];for(;N.push(b),!b.isTextblock;)b=b.lastChild;let w=i,v=1;for(;!w.isTextblock;w=w.firstChild)v++;if(b.canReplace(b.childCount,b.childCount,w.content)){if(n){let k=Ce.empty;for(let E=N.length-1;E>=0;E--)k=Ce.from(N[E].copy(k));let M=t.tr.step(new hs(e.pos-N.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new Fe(k,N.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function $S(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(st.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const eL=$S(-1),tL=$S(1);function nL(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&fy(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function IN(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 Of(u,u,e.depth),e.endIndex=0;f--)i=Ce.from(n[f].type.create(n[f].attrs,i));t.step(new hs(e.start-(r?2:0),e.end,e.start,e.end,new Fe(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?oL(e,n,t,i):lL(e,n,i):!0:!1}}function oL(t,e,n,r){let a=t.tr,i=r.end,o=r.$to.end(r.depth);iw;N--)b-=a.child(N).nodeSize,r.delete(b-1,b+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?Ce.empty:Ce.from(a))))return!1;let m=i.pos,x=m+o.nodeSize;return r.step(new hs(m-(c?1:0),x+(u?1:0),m+1,x-1,new Fe((c?Ce.empty:Ce.from(a.copy(Ce.empty))).append(u?Ce.empty:Ce.from(a.copy(Ce.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function cL(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=Ce.from(h?t.create():null),m=new Fe(Ce.from(t.create(null,Ce.from(c.type.create(null,f)))),h?3:1,0),x=i.start,b=i.end;n(e.tr.step(new hs(x-(h?3:1),b,x,b,m,1,!0)).scrollIntoView())}return!0}}const Ns=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ed=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let n0=null;const xi=function(t,e,n){let r=n0||(n0=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},dL=function(){n0=null},Wl=function(t,e,n,r){return n&&(RN(t,e,n,r,-1)||RN(t,e,n,r,1))},uL=/^(img|br|input|textarea|hr)$/i;function RN(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:_r(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Bu(t)||uL.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ns(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?_r(t):0}else return!1}}function _r(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function hL(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=_r(t)}else if(t.parentNode&&!Bu(t))e=Ns(t),t=t.parentNode;else return null}}function fL(t,e){for(;;){if(t.nodeType==3&&e2),Dr=td||(La?/Mac/.test(La.platform):!1),BS=La?/Win/.test(La.platform):!1,ji=/Android \d/.test(Ko),Vu=!!LN&&"webkitFontSmoothing"in LN.documentElement.style,gL=Vu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yL(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 ui(t,e){return typeof t=="number"?t:t[e]}function bL(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 ON(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=ed(o);continue}let c=o,u=c==i.body,h=u?yL(i):bL(c),f=0,m=0;if(e.toph.bottom-ui(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ui(a,"top")-h.top:e.bottom-h.bottom+ui(a,"bottom")),e.lefth.right-ui(r,"right")&&(f=e.right-h.right+ui(a,"right")),f||m)if(u)i.defaultView.scrollBy(f,m);else{let b=c.scrollLeft,N=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let w=c.scrollLeft-b,v=c.scrollTop-N;e={left:e.left-w,top:e.top-v,right:e.right-w,bottom:e.bottom-v}}let x=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(x))break;o=x=="absolute"?o.offsetParent:ed(o)}}function vL(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:VS(t.dom)}}function VS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ed(r));return e}function NL({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;HS(n,r==0?0:r-e)}function HS(t,e){for(let n=0;n=c){o=Math.max(N.bottom,o),c=Math.min(N.top,c);let w=N.left>e.left?N.left-e.left:N.right=(N.left+N.right)/2?1:0));continue}}else N.top>e.top&&!u&&N.left<=e.left&&N.right>=e.left&&(u=f,h={left:Math.max(N.left,Math.min(N.right,e.left)),top:N.top});!n&&(e.left>=N.right&&e.top>=N.top||e.left>=N.left&&e.top>=N.bottom)&&(i=m+1)}}return!n&&u&&(n=u,a=h,r=0),n&&n.nodeType==3?jL(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:US(n,a)}function jL(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 Ny(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function kL(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 CL(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 WS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;Vu&&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=CL(t,r,a,e))}c==null&&(c=SL(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function DN(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,Qd(co(xi(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==_r(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return ng(u.getBoundingClientRect(),!1)}if(i==null&&a<_r(r)){let u=r.childNodes[a];if(u.nodeType==1)return ng(u.getBoundingClientRect(),!0)}return ng(r.getBoundingClientRect(),n>=0)}if(i==null&&a&&(n<0||a==_r(r))){let u=r.childNodes[a-1],h=u.nodeType==3?xi(u,_r(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return Qd(co(h,1),!1)}if(i==null&&a<_r(r)){let u=r.childNodes[a];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let h=u?u.nodeType==3?xi(u,0,o?0:1):u.nodeType==1?u:null:null;if(h)return Qd(co(h,-1),!0)}return Qd(co(r.nodeType==3?xi(r):r,-n),n>=0)}function Qd(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 ng(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qS(t,e,n){let 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 ML(t,e,n){let r=e.selection,a=n=="up"?r.$from:r.$to;return qS(t,e,()=>{let{node:i}=t.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let o=KS(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=xi(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 AL=/[\u0590-\u08ac]/;function PL(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?!AL.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:qS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),x=c.caretBidiLevel;c.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:N,focusOffset:w}=t.domSelectionRange(),v=N&&!b.contains(N.nodeType==1?N:N.parentNode)||u==N&&h==w;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return x!=null&&(c.caretBidiLevel=x),v}):r.pos==r.start()||r.pos==r.end()}let _N=null,$N=null,zN=!1;function IL(t,e,n){return _N==e&&$N==n?zN:(_N=e,$N=n,zN=n=="up"||n=="down"?ML(t,e,n):PL(t,e,n))}const zr=0,FN=1,Ml=2,Oa=3;class Hu{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=zr,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;nNs(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 JS){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 GS&&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?Ns(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 x=this.children[m-1];if(x.size&&x.dom.parentNode==this.contentDOM&&!x.emptyChildAt(1)){a=Ns(x.dom)+1;break}e-=x.size}a==-1&&(a=0)}if(a>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fN&&on){let N=c;c=u,u=N}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(b)}}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?Ml:FN,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Oa:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ml:Oa}r=o}this.dirty=Ml}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ml:FN;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==zr&&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 RL extends Hu{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 Kl extends Hu{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=Zl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Kl(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Oa||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oa&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=zr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=o0(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}=Zl.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 x=f;return f=XS(f,r,n),h?u=new LL(e,n,r,a,f,m||null,x,h,i,o+1):n.isText?new Bp(e,n,r,a,f,x,i):new Mo(e,n,r,a,f,m||null,x,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=()=>Ce.empty)}return e}matchesNode(e,n,r){return this.dirty==zr&&e.eq(this.node)&&_f(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 DL(this,o&&o.node,e);zL(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?sn.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,a)},(h,f,m,x)=>{u.syncToMarks(h.marks,r,e,x);let b;u.findNodeMatch(h,f,m,x)||c&&e.state.selection.from>a&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,b,e)||u.updateNextNode(h,f,m,e,x,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==Ml)&&(o&&this.protectLocalComposition(e,o),QS(this.contentDOM,this.children,e),td&&FL(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof st)||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=BL(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 RL(this,i,n,a);e.input.compositionNodes.push(o),this.children=o0(this.children,r,r+a.length,e,o)}update(e,n,r,a){return this.dirty==Oa||!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=zr}updateOuterDeco(e){if(_f(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=YS(this.dom,this.nodeDOM,i0(this.outerDeco,this.node,n),i0(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 BN(t,e,n,r,a){XS(r,e,t);let i=new Mo(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Bp extends Mo{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==Oa||this.dirty!=zr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=zr||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=zr,!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 Bp(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=Oa)}get domAtom(){return!1}isText(e){return this.node.text==e}}class JS extends Hu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==zr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class LL extends Mo{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==Oa)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 QS(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=Kl.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 Kl)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 $L(t,e){return t.type.side-e.type.side}function zL(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 N=i+x.nodeSize;if(x.isText){let v=N;o!v.inline):c.slice();r(x,w,e.forChild(i,x),b),i=N}}function FL(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 BL(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 o0(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 wy(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(Fp(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&nt.isSelectable(m)&&a.parent&&!(m.isInline&&pL(n.focusNode,n.focusOffset,a.dom))){let x=a.posBefore;h=new nt(o==x?c:r.resolve(x))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,x=o;for(let b=0;b{(n.anchorNode!=r||n.anchorOffset!=a)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!ZS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function HL(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ns(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&cr&&To<=11&&(n.disabled=!0,n.disabled=!1)}function eC(t,e){if(e instanceof nt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(KN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else KN(t)}function KN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function jy(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||st.between(e,n,r)}function qN(t){return t.editable&&!t.hasFocus()?!1:tC(t)}function tC(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 UL(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Wl(e.node,e.offset,n.anchorNode,n.anchorOffset)}function l0(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&&ct.findFrom(i,e)}function uo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function GN(t,e,n){let r=t.state.selection;if(r instanceof st)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 uo(t,new st(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=l0(t.state,e);return a&&a instanceof nt?uo(t,a):!1}else if(!(Dr&&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?nt.isSelectable(i)?uo(t,new nt(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Vu?uo(t,new st(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof nt&&r.node.isInline)return uo(t,new st(e>0?r.$to:r.$from));{let a=l0(t.state,e);return a?uo(t,a):!1}}}function $f(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function hu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Dc(t,e){return e<0?WL(t):KL(t)}function WL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for($r&&n.nodeType==1&&r<$f(n)&&hu(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(hu(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(nC(n))break;{let c=n.previousSibling;for(;c&&hu(c,-1);)a=n.parentNode,i=Ns(c),c=c.previousSibling;if(c)n=c,r=$f(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?c0(t,n,r):a&&c0(t,a,i)}function KL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=$f(n),i,o;for(;;)if(r{t.state==a&&Ei(t)},50)}function JN(t,e){let n=t.state.doc.resolve(e);if(!(js||BS)&&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 QN(t,e,n){let r=t.state.selection;if(r instanceof st&&!r.empty||n.indexOf("s")>-1||Dr&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=r;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=l0(t.state,e);if(o&&o instanceof nt)return uo(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof br?ct.near(o,e):ct.findFrom(o,e);return c?uo(t,c):!1}return!1}function YN(t,e){if(!(t.state.selection instanceof st))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 XN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function JL(t){if(!Ls||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;XN(t,r,"true"),setTimeout(()=>XN(t,r,"false"),20)}return!1}function QL(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function YL(t,e){let n=e.keyCode,r=QL(e);if(n==8||Dr&&n==72&&r=="c")return YN(t,-1)||Dc(t,-1);if(n==46&&!e.shiftKey||Dr&&n==68&&r=="c")return YN(t,1)||Dc(t,1);if(n==13||n==27)return!0;if(n==37||Dr&&n==66&&r=="c"){let a=n==37?JN(t,t.state.selection.from)=="ltr"?-1:1:-1;return GN(t,a,r)||Dc(t,a)}else if(n==39||Dr&&n==70&&r=="c"){let a=n==39?JN(t,t.state.selection.from)=="ltr"?1:-1:1;return GN(t,a,r)||Dc(t,a)}else{if(n==38||Dr&&n==80&&r=="c")return QN(t,-1,r)||Dc(t,-1);if(n==40||Dr&&n==78&&r=="c")return JL(t)||QN(t,1,r)||Dc(t,1);if(r==(Dr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ky(t,e){t.someProp("transformCopied",b=>{e=b(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 b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let o=t.someProp("clipboardSerializer")||Zl.fromSchema(t.state.schema),c=lC(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=oC[h.nodeName.toLowerCase()]);){for(let b=f.length-1;b>=0;b--){let N=c.createElement(f[b]);for(;u.firstChild;)N.appendChild(u.firstChild);u.appendChild(N),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${a} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let x=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,` -`);return{dom:u,text:x,slice:e}}function sC(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",x=>{e=x(e,i||r,t)}),i)return c=new Fe(Se.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0),t.someProp("transformPasted",x=>{c=x(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",x=>x(e,a,r,t));if(m)c=m;else{let x=a.marks(),{schema:b}=t.state,N=Zl.fromSchema(b);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let v=o.appendChild(document.createElement("p"));w&&v.appendChild(N.serializeNode(b.text(w,x)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=tO(n),Bu&&nO(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 x=o.firstChild;for(;x&&x.nodeType!=1;)x=x.nextSibling;if(!x)break;o=x}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||To.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(x){return x.nodeName=="BR"&&!x.nextSibling&&x.parentNode&&!XL.test(x.parentNode.nodeName)?{ignore:!0}:null}})),f)c=sO(ZN(c,+f[1],+f[2]),f[4]);else if(c=Fe.maxOpen(ZL(c.content,a),!0),c.openStart||c.openEnd){let m=0,x=0;for(let b=c.content.firstChild;m{c=m(c,t,u)}),c}const XL=/^(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 ZL(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&&aC(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=iC(o[o.length-1],i.length));let f=rC(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Se.from(o)}return t}function rC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Se.from(t));return t}function aC(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(Se.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function ZN(t,e,n){return en})),rg.createHTML(t)):t}function tO(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=lC().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&oC[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=eO(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;a=Se.from(u.create(r[c+1],a)),i++,o++}return new Fe(a,i,o)}const Ws={},Ks={},rO={touchstart:!0,touchmove:!0};class aO{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 iO(t){for(let e in Ws){let n=Ws[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{lO(t,r)&&!Sy(t,r)&&(t.editable||!(r.type in Ks))&&n(t,r)},rO[e]?{passive:!0}:void 0)}Ls&&t.dom.addEventListener("input",()=>null),u0(t)}function ko(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function oO(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 u0(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Sy(t,r))})}function Sy(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function lO(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 cO(t,e){!Sy(t,e)&&Ws[e.type]&&(t.editable||!(e.type in Ks))&&Ws[e.type](t,e)}Ks.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!dC(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ji&&js&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),td&&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,Tl(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||YL(t,n)?n.preventDefault():ko(t,"key")};Ks.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ks.keypress=(t,e)=>{let n=e;if(dC(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Dr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof st)||!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 Vp(t){return{left:t.clientX,top:t.clientY}}function dO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Cy(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 Jc(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 uO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&nt.isSelectable(r)?(Jc(t,new nt(n)),!0):!1}function hO(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof nt&&(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(nt.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?(Jc(t,nt.create(t.state.doc,a)),!0):!1}function fO(t,e,n,r,a){return Cy(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?hO(t,n):uO(t,n))}function pO(t,e,n,r){return Cy(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function mO(t,e,n,r){return Cy(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||xO(t,n,r)}function xO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Jc(t,st.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)Jc(t,st.create(r,c+1,c+1+o.content.size));else if(nt.isSelectable(o))Jc(t,nt.create(r,c));else continue;return!0}}function Ey(t){return zf(t)}const cC=Dr?"metaKey":"ctrlKey";Ws.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Ey(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&dO(n,t.input.lastClick)&&!n[cC]&&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(Vp(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new gO(t,o,n,!!r)):(i=="doubleClick"?pO:mO)(t,o.pos,o.inside,n)?n.preventDefault():ko(t,"pointer"))};class gO{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[cC],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 nt&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$r&&!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)),ko(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(()=>Ti(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(Vp(e))),this.updateAllowDefault(e),this.allowDefault||!n?ko(this.view,"pointer"):fO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ls&&this.mightDrag&&!this.mightDrag.node.isAtom||js&&!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)?(Jc(this.view,ct.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ko(this.view,"pointer")}move(e){this.updateAllowDefault(e),ko(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)}}Ws.touchstart=t=>{t.input.lastTouch=Date.now(),Ey(t),ko(t,"pointer")};Ws.touchmove=t=>{t.input.lastTouch=Date.now(),ko(t,"pointer")};Ws.contextmenu=t=>Ey(t);function dC(t,e){return t.composing?!0:Ls&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const yO=ji?5e3:-1;Ks.compositionstart=Ks.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof st&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||js&&BS&&bO(t)))t.markCursor=t.state.storedMarks||n.marks(),zf(t,!0),t.markCursor=null;else if(zf(t,!e.selection.empty),$r&&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}uC(t,yO)};function bO(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"}Ks.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++,uC(t,20))};function uC(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>zf(t),e))}function hC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=NO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function vO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=hL(e.focusNode,e.focusOffset),r=fL(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 NO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function zf(t,e=!1){if(!(ji&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),hC(t),e||t.docView&&t.docView.dirty){let n=wy(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 wO(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 Eu=cr&&Mo<15||td&&gL<604;Ws.copy=Ks.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=Eu?null:n.clipboardData,o=r.content(),{dom:c,text:u}=ky(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):wO(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function kO(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?Tu(t,r.value,null,a,e):Tu(t,r.textContent,r.innerHTML,a,e)},50)}function Tu(t,e,n,r,a){let i=sC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||Fe.empty)))return!0;if(!i)return!1;let o=jO(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 fC(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," "):""}Ks.paste=(t,e)=>{let n=e;if(t.composing&&!ji)return;let r=Eu?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Tu(t,fC(r),r.getData("text/html"),a,n)?n.preventDefault():kO(t,n)};class pC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const SO=Dr?"altKey":"ctrlKey";function mC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[SO]}Ws.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(Vp(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof nt?a.to-1:a.to))){if(r&&r.mightDrag)o=nt.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=nt.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=ky(t,c);(!n.dataTransfer.files.length||!js||FS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Eu?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Eu||n.dataTransfer.setData("text/plain",h),t.dragging=new pC(f,mC(t,n),o)};Ws.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ks.dragover=Ks.dragenter=(t,e)=>e.preventDefault();Ks.drop=(t,e)=>{try{CO(t,e,t.dragging)}finally{t.dragging=null}};function CO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Vp(e));if(!r)return;let a=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",b=>{i=b(i,t,!1)}):i=sC(t,fC(e.dataTransfer),Eu?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&mC(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||Fe.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?bS(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:b}=n;b?b.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 x=u.doc.resolve(h);if(f&&nt.isSelectable(i.content.firstChild)&&x.nodeAfter&&x.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new nt(x));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((N,w,v,k)=>b=k),u.setSelection(jy(t,x,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Ws.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())&&Ti(t)},20))};Ws.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)};Ws.beforeinput=(t,e)=>{if(js&&ji&&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,Tl(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 Ks)Ws[t]=Ks[t];function Mu(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 Ff{constructor(e,n){this.toDOM=e,this.spec=n||Ol,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 Yn(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ff&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Mu(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Po{constructor(e,n){this.attrs=e,this.spec=n||Ol}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 Yn(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==Is||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ol)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=gC(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 Po){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,Ol));return mo.from(r)}forChild(e,n){if(n.isLeaf)return tn.empty;let r=[];for(let a=0;an instanceof tn)?e:e.reduce((n,r)=>n.concat(r instanceof tn?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let v=w-N-(b-x);for(let k=0;kM+f-m)continue;let E=c[k]+f-m;b>=E?c[k+1]=x<=E?-2:-1:x>=f&&v&&(c[k]+=v,c[k+1]+=v)}m+=v}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let x=n.map(t[h+1]+i,-1),b=x-a,{index:N,offset:w}=r.content.findIndex(m),v=r.maybeChild(N);if(v&&w==m&&w+v.nodeSize==b){let k=c[h+2].mapInner(n,v,f+1,t[h]+i+1,o);k!=Is?(c[h]=m,c[h+1]=b,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=TO(c,t,e,n,a,i,o),f=Bf(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=gC(t,c,u+n);if(h){i=!0;let f=Bf(h,c,n+u+1,r);f!=Is&&a.push(u,u+c.nodeSize,f)}});let o=xC(i?yC(t):t,-n).sort(Dl);for(let c=0;c0;)e++;t.splice(e,0,n)}function ag(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Is&&e.push(r)}),t.cursorWrapper&&e.push(tn.create(t.state.doc,[t.cursorWrapper.deco])),mo.from(e)}const MO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},AO=cr&&Mo<=11;class PO{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 IO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new PO,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():Ls&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),AO&&(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,MO)),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(qN(this.view)){if(this.suppressingSelectionUpdates)return Ti(this.view);if(cr&&Mo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wl(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=ed(i))n.add(i);for(let i=e.anchorNode;i;i=ed(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)&&qN(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($r&&u.length){let f=u.filter(m=>m.nodeName=="BR");if(f.length==2){let[m,x]=f;m.parentNode&&m.parentNode.parentNode==x.parentNode?x.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let x of f){let b=x.parentNode;b&&b.nodeName=="LI"&&(!m||OO(e,m)!=b)&&x.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),RO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,DO(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ti(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;v--){let k=r.childNodes[v-1],M=k.pmViewDesc;if(k.nodeName=="BR"&&!M){i=v;break}if(!M||M.size)break}let m=t.state.doc,x=t.someProp("domParser")||To.fromSchema(t.state.schema),b=m.resolve(o),N=null,w=x.parse(r,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:a,to:i,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:$O,context:b});if(h&&h[0].pos!=null){let v=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=v),N={anchor:v+o,head:k+o}}return{doc:w,sel:N,from:o,to:c}}function $O(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ls&&/^(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||Ls&&/^(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 zO=/^(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 FO(t,e,n,r,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let P=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,B=wy(t,P);if(B&&!t.state.selection.eq(B)){if(js&&ji&&t.input.lastKeyCode===13&&Date.now()-100Y(t,Tl(13,"Enter"))))return;let O=t.state.tr.setSelection(B);P=="pointer"?O.setMeta("pointer",!0):P=="key"&&O.scrollIntoView(),i&&O.setMeta("composition",i),t.dispatch(O)}return}let o=t.state.doc.resolve(e),c=o.sharedDepth(n);e=o.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,h=_O(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),x,b;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ji)&&a.some(P=>P.nodeType==1&&!zO.test(P.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",P=>P(t,Tl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(r&&u instanceof st&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))N={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let P=aw(t,t.state.doc,h.sel);if(P&&!P.eq(t.state.selection)){let B=t.state.tr.setSelection(P);i&&B.setMeta("composition",i),t.dispatch(B)}}return}t.state.selection.fromt.state.selection.from&&N.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?N.start=t.state.selection.from:N.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(N.endB+=t.state.selection.to-N.endA,N.endA=t.state.selection.to)),cr&&Mo<=11&&N.endB==N.start+1&&N.endA==N.start&&N.start>h.from&&h.doc.textBetween(N.start-h.from-1,N.start-h.from+1)=="  "&&(N.start--,N.endA--,N.endB--);let w=h.doc.resolveNoCache(N.start-h.from),v=h.doc.resolveNoCache(N.endB-h.from),k=f.resolve(N.start),M=w.sameParent(v)&&w.parent.inlineContent&&k.end()>=N.endA;if((td&&t.input.lastIOSEnter>Date.now()-225&&(!M||a.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!M&&w.posP(t,Tl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&VO(f,N.start,N.endA,w,v)&&t.someProp("handleKeyDown",P=>P(t,Tl(8,"Backspace")))){ji&&js&&t.domObserver.suppressSelectionUpdates();return}js&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),ji&&!M&&w.start()!=v.start()&&v.parentOffset==0&&w.depth==v.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==N.endA&&(N.endB-=2,v=h.doc.resolveNoCache(N.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(P){return P(t,Tl(13,"Enter"))})},20));let E=N.start,L=N.endA,R=P=>{let B=P||t.state.tr.replace(E,L,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let O=aw(t,B.doc,h.sel);O&&!(js&&t.composing&&O.empty&&(N.start!=N.endB||t.input.lastChromeDeleteTi(t),20));let P=R(t.state.tr.delete(E,L)),B=f.resolve(N.start).marksAcross(f.resolve(N.endA));B&&P.ensureMarks(B),t.dispatch(P)}else if(N.endA==N.endB&&(W=BO(w.parent.content.cut(w.parentOffset,v.parentOffset),k.parent.content.cut(k.parentOffset,N.endA-k.start())))){let P=R(t.state.tr);W.type=="add"?P.addMark(E,L,W.mark):P.removeMark(E,L,W.mark),t.dispatch(P)}else if(w.parent.child(w.index()).isText&&w.index()==v.index()-(v.textOffset?0:1)){let P=w.parent.textBetween(w.parentOffset,v.parentOffset),B=()=>R(t.state.tr.insertText(P,E,L));t.someProp("handleTextInput",O=>O(t,E,L,P,B))||t.dispatch(B())}else t.dispatch(R());else t.dispatch(R())}function aw(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:jy(t,e.resolve(n.anchor),e.resolve(n.head))}function BO(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||ig(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 HO(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 bC{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 aO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(uw),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=cw(this),lw(this),this.nodeViews=dw(this),this.docView=BN(this.state.doc,ow(this),ag(this),this.dom,this),this.domObserver=new IO(this,(r,a,i,o)=>FO(this,r,a,i,o)),this.domObserver.start(),iO(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&&u0(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(uw),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&&(hC(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 b=dw(this);WO(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&u0(this),this.editable=cw(this),lw(this);let u=ag(this),h=ow(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 x=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&vL(this);if(o){this.domObserver.stop();let b=m&&(cr||js)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&UO(a.selection,e.selection);if(m){let N=js?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vO(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=BN(e.doc,h,u,this.dom,this)),N&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&UL(this))?Ti(this,b):(eC(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():x&&NL(x)}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 nt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&ON(this,n.getBoundingClientRect(),e)}else ON(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 pC(e.slice,e.move,a<0?void 0:nt.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 EL(this,e)}coordsAtPos(e,n=1){return KS(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 IL(this,n||this.state,e)}pasteHTML(e,n){return Tu(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Tu(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return ky(this,e)}destroy(){this.docView&&(oO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ag(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,dL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return cO(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ls&&this.root.nodeType===11&&mL(this.dom.ownerDocument)==this.dom&&LO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}bC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function ow(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"),[Yn.node(0,t.state.doc.content.size,e)]}function lw(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:Yn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function cw(t){return!t.someProp("editable",e=>e(t.state)===!1)}function UO(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 dw(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 WO(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 uw(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 _o={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:"'"},Vf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},KO=typeof navigator<"u"&&/Mac/.test(navigator.platform),qO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ws=0;ws<10;ws++)_o[48+ws]=_o[96+ws]=String(ws);for(var ws=1;ws<=24;ws++)_o[ws+111]="F"+ws;for(var ws=65;ws<=90;ws++)_o[ws]=String.fromCharCode(ws+32),Vf[ws]=String.fromCharCode(ws);for(var og in _o)Vf.hasOwnProperty(og)||(Vf[og]=_o[og]);function GO(t){var e=KO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||qO&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Vf:_o)[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 JO=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),QO=typeof navigator<"u"&&/Win/.test(navigator.platform);function YO(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)eD(t,n,{get:e[n],enumerable:!0})};function Hp(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 Up=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,x])=>[m,(...N)=>{const w=this.buildProps(u,e),v=x(...N)(w);return o.push(v),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:Hp({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}},vC={};Py(vC,{blur:()=>tD,clearContent:()=>nD,clearNodes:()=>sD,command:()=>rD,createParagraphNear:()=>aD,cut:()=>iD,deleteCurrentNode:()=>oD,deleteNode:()=>lD,deleteRange:()=>cD,deleteSelection:()=>dD,enter:()=>uD,exitCode:()=>hD,extendMarkRange:()=>fD,first:()=>pD,focus:()=>xD,forEach:()=>gD,insertContent:()=>yD,insertContentAt:()=>ND,joinBackward:()=>kD,joinDown:()=>jD,joinForward:()=>SD,joinItemBackward:()=>CD,joinItemForward:()=>ED,joinTextblockBackward:()=>TD,joinTextblockForward:()=>MD,joinUp:()=>wD,keyboardShortcut:()=>PD,lift:()=>ID,liftEmptyBlock:()=>RD,liftListItem:()=>LD,newlineInCode:()=>OD,resetAttributes:()=>DD,scrollIntoView:()=>_D,selectAll:()=>$D,selectNodeBackward:()=>zD,selectNodeForward:()=>FD,selectParentNode:()=>BD,selectTextblockEnd:()=>VD,selectTextblockStart:()=>HD,setContent:()=>UD,setMark:()=>d_,setMeta:()=>u_,setNode:()=>h_,setNodeSelection:()=>f_,setTextDirection:()=>p_,setTextSelection:()=>m_,sinkListItem:()=>x_,splitBlock:()=>g_,splitListItem:()=>y_,toggleList:()=>b_,toggleMark:()=>v_,toggleNode:()=>N_,toggleWrap:()=>w_,undoInputRule:()=>j_,unsetAllMarks:()=>k_,unsetMark:()=>S_,unsetTextDirection:()=>C_,updateAttributes:()=>E_,wrapIn:()=>T_,wrapInList:()=>M_});var tD=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),nD=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),sD=()=>({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)),x=h.resolve(f.map(u+c.nodeSize)),b=m.blockRange(x);if(!b)return;const N=hd(b);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(b.start,w)}(N||N===0)&&e.lift(b,N)})}),!0},rD=t=>e=>t(e),aD=()=>({state:t,dispatch:e})=>OS(t,e),iD=(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 st(r.doc.resolve(Math.max(o-1,0)))),!0},oD=()=>({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 Un(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 lD=t=>({tr:e,state:n,dispatch:r})=>{const a=Un(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},cD=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},dD=()=>({state:t,dispatch:e})=>xy(t,e),uD=()=>({commands:t})=>t.keyboardShortcut("Enter"),hD=()=>({state:t,dispatch:e})=>J6(t,e);function Iy(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Hf(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:Iy(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function NC(t,e,n={}){return t.find(r=>r.type===e&&Hf(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function hw(t,e,n={}){return!!NC(t,e,n)}function Ry(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),!NC([...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&&hw([...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=Ri(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=Ry(u,i,e);if(m&&m.from<=h&&m.to>=f){const x=st.create(o,m.from,m.to);n.setSelection(x)}}return!0},pD=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=()=>{(Uf()||fw())&&r.dom.focus(),mD()&&!Uf()&&!fw()&&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&&!wC(n.state.selection))return o(),!0;const c=jC(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},gD=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),yD=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),kC=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&&kC(r)}return t};function Xh(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 kC(n)}function Au(t,e,n){if(t instanceof Ci||t instanceof Se)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 Se.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),Au("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new lS({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?To.fromSchema(u).parseSlice(Xh(t),n.parseOptions):To.fromSchema(u).parse(Xh(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=To.fromSchema(e);return n.slice?i.parseSlice(Xh(t),n.parseOptions).content:i.parse(Xh(t),n.parseOptions)}return Au("",e,n)}function bD(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(ct.near(t.doc.resolve(o),n))}var vD=t=>!("type"in t),ND=(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=v=>{i.emit("contentError",{editor:i,error:v,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Au(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(v){u(v)}try{c=Au(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(v){return u(v),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},x=!0,b=!0;if((vD(c)?c:[c]).forEach(v=>{v.check(),x=x?v.isText&&v.marks.length===0:!1,b=b?v.isBlock:!1}),f===m&&b){const{parent:v}=r.doc.resolve(f);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(f-=1,m+=1)}let w;if(x){if(Array.isArray(e))w=e.map(v=>v.text||"").join("");else if(e instanceof Se){let v="";e.forEach(k=>{k.text&&(v+=k.text)}),w=v}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,f,m)}else{w=c;const v=r.doc.resolve(f),k=v.node(),M=v.parentOffset===0,E=k.isText||k.isTextblock,L=k.content.size>0;M&&E&&L&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&bD(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},wD=()=>({state:t,dispatch:e})=>K6(t,e),jD=()=>({state:t,dispatch:e})=>q6(t,e),kD=()=>({state:t,dispatch:e})=>TS(t,e),SD=()=>({state:t,dispatch:e})=>IS(t,e),CD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=_p(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},ED=()=>({state:t,dispatch:e,tr:n})=>{try{const r=_p(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},TD=()=>({state:t,dispatch:e})=>U6(t,e),MD=()=>({state:t,dispatch:e})=>W6(t,e);function SC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function AD(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=AD(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 $o(t,e,n={}){const{from:r,to:a,empty:i}=t.selection,o=e?Un(e,t.schema):null,c=[];t.doc.nodesBetween(r,a,(m,x)=>{if(m.isText)return;const b=Math.max(r,x),N=Math.min(a,x+m.nodeSize);c.push({node:m,from:b,to:N})});const u=a-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Hf(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,x)=>m+x.to-x.from,0)>=u}var ID=(t,e={})=>({state:n,dispatch:r})=>{const a=Un(t,n.schema);return $o(n,a,e)?G6(n,r):!1},RD=()=>({state:t,dispatch:e})=>DS(t,e),LD=t=>({state:e,dispatch:n})=>{const r=Un(t,e.schema);return iL(r)(e,n)},OD=()=>({state:t,dispatch:e})=>LS(t,e);function Wp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function pw(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 DD=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=Wp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Un(t,r.schema)),c==="mark"&&(o=Ri(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,pw(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(x=>{o===x.type&&(u=!0,a&&n.addMark(m,m+f.nodeSize,o.create(pw(x.attrs,e))))})})}),u},_D=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),$D=()=>({tr:t,dispatch:e})=>{if(e){const n=new br(t.doc);t.setSelection(n)}return!0},zD=()=>({state:t,dispatch:e})=>AS(t,e),FD=()=>({state:t,dispatch:e})=>RS(t,e),BD=()=>({state:t,dispatch:e})=>X6(t,e),VD=()=>({state:t,dispatch:e})=>tL(t,e),HD=()=>({state:t,dispatch:e})=>eL(t,e);function h0(t,e,n={},r={}){return Au(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var UD=(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=h0(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 CC(t,e){const n=Ri(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 EC(t,e){const n=new py(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function WD(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function TC(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 Kp(t){return e=>TC(e.$from,t)}function et(t,e,n){return t.config[e]===void 0&&t.parent?et(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?et(t.parent,e,n):null}):t.config[e]}function Ly(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=et(e,"addExtensions",n);return r?[e,...Ly(r())]:e}).flat(10)}function Oy(t,e){const n=Zl.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function MC(t){return typeof t=="function"}function Kt(t,e=void 0,...n){return MC(t)?e?t.bind(e)(...n):t(...n):t}function qD(t={}){return Object.keys(t).length===0&&t.constructor===Object}function nd(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 AC(t){const e=[],{nodeExtensions:n,markExtensions:r}=nd(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=et(h,"addGlobalAttributes",f);if(!m)return;m().forEach(b=>{let N;Array.isArray(b.types)?N=b.types:b.types==="*"?N=u:b.types==="nodes"?N=o:b.types==="marks"?N=c:N=[],N.forEach(w=>{Object.entries(b.attributes).forEach(([v,k])=>{e.push({type:w,name:v,attribute:{...i,...k}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=et(h,"addAttributes",f);if(!m)return;const x=m();Object.entries(x).forEach(([b,N])=>{const w={...i,...N};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:b,attribute:w})})}),e}function GD(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 mw(t){const e=[],n=GD(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([...mw(r[a]),...mw(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function Pu(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)=>Gt(n,r),{})}function JD(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function xw(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):JD(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function gw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&qD(n)?!1:n!=null))}function yw(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 QD(t,e){var n;const r=AC(t),{nodeExtensions:a,markExtensions:i}=nd(t),o=(n=a.find(h=>et(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},x=t.reduce((k,M)=>{const E=et(M,"extendNodeSchema",m);return{...k,...E?E(h):{}}},{}),b=gw({...x,content:Kt(et(h,"content",m)),marks:Kt(et(h,"marks",m)),group:Kt(et(h,"group",m)),inline:Kt(et(h,"inline",m)),atom:Kt(et(h,"atom",m)),selectable:Kt(et(h,"selectable",m)),draggable:Kt(et(h,"draggable",m)),code:Kt(et(h,"code",m)),whitespace:Kt(et(h,"whitespace",m)),linebreakReplacement:Kt(et(h,"linebreakReplacement",m)),defining:Kt(et(h,"defining",m)),isolating:Kt(et(h,"isolating",m)),attrs:Object.fromEntries(f.map(yw))}),N=Kt(et(h,"parseHTML",m));N&&(b.parseDOM=N.map(k=>xw(k,f)));const w=et(h,"renderHTML",m);w&&(b.toDOM=k=>w({node:k,HTMLAttributes:Pu(k,f)}));const v=et(h,"renderText",m);return v&&(b.toText=v),[h.name,b]})),u=Object.fromEntries(i.map(h=>{const f=r.filter(v=>v.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},x=t.reduce((v,k)=>{const M=et(k,"extendMarkSchema",m);return{...v,...M?M(h):{}}},{}),b=gw({...x,inclusive:Kt(et(h,"inclusive",m)),excludes:Kt(et(h,"excludes",m)),group:Kt(et(h,"group",m)),spanning:Kt(et(h,"spanning",m)),code:Kt(et(h,"code",m)),attrs:Object.fromEntries(f.map(yw))}),N=Kt(et(h,"parseHTML",m));N&&(b.parseDOM=N.map(v=>xw(v,f)));const w=et(h,"renderHTML",m);return w&&(b.toDOM=v=>w({mark:v,HTMLAttributes:Pu(v,f)})),[h.name,b]}));return new lS({topNode:o,nodes:c,marks:u})}function YD(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function hu(t){return t.sort((n,r)=>{const a=et(n,"priority")||100,i=et(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 IC(t,e,n){const{from:r,to:a}=e,{blockSeparator:i=` +`);return{dom:u,text:x,slice:e}}function sC(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",x=>{e=x(e,i||r,t)}),i)return c=new Fe(Ce.from(t.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0),t.someProp("transformPasted",x=>{c=x(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",x=>x(e,a,r,t));if(m)c=m;else{let x=a.marks(),{schema:b}=t.state,N=Zl.fromSchema(b);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let v=o.appendChild(document.createElement("p"));w&&v.appendChild(N.serializeNode(b.text(w,x)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=tO(n),Vu&&nO(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 x=o.firstChild;for(;x&&x.nodeType!=1;)x=x.nextSibling;if(!x)break;o=x}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||Eo.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(x){return x.nodeName=="BR"&&!x.nextSibling&&x.parentNode&&!XL.test(x.parentNode.nodeName)?{ignore:!0}:null}})),f)c=sO(ZN(c,+f[1],+f[2]),f[4]);else if(c=Fe.maxOpen(ZL(c.content,a),!0),c.openStart||c.openEnd){let m=0,x=0;for(let b=c.content.firstChild;m{c=m(c,t,u)}),c}const XL=/^(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 ZL(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&&aC(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=iC(o[o.length-1],i.length));let f=rC(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ce.from(o)}return t}function rC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ce.from(t));return t}function aC(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(Ce.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function ZN(t,e,n){return en})),rg.createHTML(t)):t}function tO(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=lC().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&oC[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=eO(t),a)for(let i=0;i=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;a=Ce.from(u.create(r[c+1],a)),i++,o++}return new Fe(a,i,o)}const Ws={},Ks={},rO={touchstart:!0,touchmove:!0};class aO{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 iO(t){for(let e in Ws){let n=Ws[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{lO(t,r)&&!Sy(t,r)&&(t.editable||!(r.type in Ks))&&n(t,r)},rO[e]?{passive:!0}:void 0)}Ls&&t.dom.addEventListener("input",()=>null),u0(t)}function jo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function oO(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 u0(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Sy(t,r))})}function Sy(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function lO(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 cO(t,e){!Sy(t,e)&&Ws[e.type]&&(t.editable||!(e.type in Ks))&&Ws[e.type](t,e)}Ks.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!dC(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ji&&js&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),td&&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,Tl(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||YL(t,n)?n.preventDefault():jo(t,"key")};Ks.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ks.keypress=(t,e)=>{let n=e;if(dC(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Dr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof st)||!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 Vp(t){return{left:t.clientX,top:t.clientY}}function dO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Cy(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 Jc(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 uO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&nt.isSelectable(r)?(Jc(t,new nt(n)),!0):!1}function hO(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof nt&&(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(nt.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?(Jc(t,nt.create(t.state.doc,a)),!0):!1}function fO(t,e,n,r,a){return Cy(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?hO(t,n):uO(t,n))}function pO(t,e,n,r){return Cy(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function mO(t,e,n,r){return Cy(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||xO(t,n,r)}function xO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Jc(t,st.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)Jc(t,st.create(r,c+1,c+1+o.content.size));else if(nt.isSelectable(o))Jc(t,nt.create(r,c));else continue;return!0}}function Ey(t){return zf(t)}const cC=Dr?"metaKey":"ctrlKey";Ws.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Ey(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&dO(n,t.input.lastClick)&&!n[cC]&&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(Vp(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new gO(t,o,n,!!r)):(i=="doubleClick"?pO:mO)(t,o.pos,o.inside,n)?n.preventDefault():jo(t,"pointer"))};class gO{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[cC],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 nt&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$r&&!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)),jo(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(()=>Ei(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(Vp(e))),this.updateAllowDefault(e),this.allowDefault||!n?jo(this.view,"pointer"):fO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ls&&this.mightDrag&&!this.mightDrag.node.isAtom||js&&!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)?(Jc(this.view,ct.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):jo(this.view,"pointer")}move(e){this.updateAllowDefault(e),jo(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)}}Ws.touchstart=t=>{t.input.lastTouch=Date.now(),Ey(t),jo(t,"pointer")};Ws.touchmove=t=>{t.input.lastTouch=Date.now(),jo(t,"pointer")};Ws.contextmenu=t=>Ey(t);function dC(t,e){return t.composing?!0:Ls&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const yO=ji?5e3:-1;Ks.compositionstart=Ks.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof st&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||js&&BS&&bO(t)))t.markCursor=t.state.storedMarks||n.marks(),zf(t,!0),t.markCursor=null;else if(zf(t,!e.selection.empty),$r&&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}uC(t,yO)};function bO(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"}Ks.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++,uC(t,20))};function uC(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>zf(t),e))}function hC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=NO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function vO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=hL(e.focusNode,e.focusOffset),r=fL(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 NO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function zf(t,e=!1){if(!(ji&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),hC(t),e||t.docView&&t.docView.dirty){let n=wy(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 wO(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 Tu=cr&&To<15||td&&gL<604;Ws.copy=Ks.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=Tu?null:n.clipboardData,o=r.content(),{dom:c,text:u}=ky(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):wO(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function kO(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?Mu(t,r.value,null,a,e):Mu(t,r.textContent,r.innerHTML,a,e)},50)}function Mu(t,e,n,r,a){let i=sC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||Fe.empty)))return!0;if(!i)return!1;let o=jO(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 fC(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," "):""}Ks.paste=(t,e)=>{let n=e;if(t.composing&&!ji)return;let r=Tu?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Mu(t,fC(r),r.getData("text/html"),a,n)?n.preventDefault():kO(t,n)};class pC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const SO=Dr?"altKey":"ctrlKey";function mC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[SO]}Ws.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(Vp(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof nt?a.to-1:a.to))){if(r&&r.mightDrag)o=nt.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=nt.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=ky(t,c);(!n.dataTransfer.files.length||!js||FS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Tu?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Tu||n.dataTransfer.setData("text/plain",h),t.dragging=new pC(f,mC(t,n),o)};Ws.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ks.dragover=Ks.dragenter=(t,e)=>e.preventDefault();Ks.drop=(t,e)=>{try{CO(t,e,t.dragging)}finally{t.dragging=null}};function CO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Vp(e));if(!r)return;let a=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",b=>{i=b(i,t,!1)}):i=sC(t,fC(e.dataTransfer),Tu?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&mC(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||Fe.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?bS(t.state.doc,a.pos,i):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:b}=n;b?b.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 x=u.doc.resolve(h);if(f&&nt.isSelectable(i.content.firstChild)&&x.nodeAfter&&x.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new nt(x));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((N,w,v,k)=>b=k),u.setSelection(jy(t,x,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Ws.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())&&Ei(t)},20))};Ws.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)};Ws.beforeinput=(t,e)=>{if(js&&ji&&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,Tl(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 Ks)Ws[t]=Ks[t];function Au(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 Ff{constructor(e,n){this.toDOM=e,this.spec=n||Ol,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 Yn(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ff&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Au(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ao{constructor(e,n){this.attrs=e,this.spec=n||Ol}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 Yn(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==Is||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ol)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=gC(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 Ao){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,Ol));return po.from(r)}forChild(e,n){if(n.isLeaf)return nn.empty;let r=[];for(let a=0;an instanceof nn)?e:e.reduce((n,r)=>n.concat(r instanceof nn?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let v=w-N-(b-x);for(let k=0;kM+f-m)continue;let E=c[k]+f-m;b>=E?c[k+1]=x<=E?-2:-1:x>=f&&v&&(c[k]+=v,c[k+1]+=v)}m+=v}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let x=n.map(t[h+1]+i,-1),b=x-a,{index:N,offset:w}=r.content.findIndex(m),v=r.maybeChild(N);if(v&&w==m&&w+v.nodeSize==b){let k=c[h+2].mapInner(n,v,f+1,t[h]+i+1,o);k!=Is?(c[h]=m,c[h+1]=b,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=TO(c,t,e,n,a,i,o),f=Bf(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=gC(t,c,u+n);if(h){i=!0;let f=Bf(h,c,n+u+1,r);f!=Is&&a.push(u,u+c.nodeSize,f)}});let o=xC(i?yC(t):t,-n).sort(Dl);for(let c=0;c0;)e++;t.splice(e,0,n)}function ag(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Is&&e.push(r)}),t.cursorWrapper&&e.push(nn.create(t.state.doc,[t.cursorWrapper.deco])),po.from(e)}const MO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},AO=cr&&To<=11;class PO{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 IO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new PO,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():Ls&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),AO&&(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,MO)),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(qN(this.view)){if(this.suppressingSelectionUpdates)return Ei(this.view);if(cr&&To<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wl(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=ed(i))n.add(i);for(let i=e.anchorNode;i;i=ed(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)&&qN(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($r&&u.length){let f=u.filter(m=>m.nodeName=="BR");if(f.length==2){let[m,x]=f;m.parentNode&&m.parentNode.parentNode==x.parentNode?x.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let x of f){let b=x.parentNode;b&&b.nodeName=="LI"&&(!m||OO(e,m)!=b)&&x.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),RO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,DO(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ei(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;v--){let k=r.childNodes[v-1],M=k.pmViewDesc;if(k.nodeName=="BR"&&!M){i=v;break}if(!M||M.size)break}let m=t.state.doc,x=t.someProp("domParser")||Eo.fromSchema(t.state.schema),b=m.resolve(o),N=null,w=x.parse(r,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:a,to:i,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:$O,context:b});if(h&&h[0].pos!=null){let v=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=v),N={anchor:v+o,head:k+o}}return{doc:w,sel:N,from:o,to:c}}function $O(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ls&&/^(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||Ls&&/^(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 zO=/^(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 FO(t,e,n,r,a){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let P=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,B=wy(t,P);if(B&&!t.state.selection.eq(B)){if(js&&ji&&t.input.lastKeyCode===13&&Date.now()-100X(t,Tl(13,"Enter"))))return;let O=t.state.tr.setSelection(B);P=="pointer"?O.setMeta("pointer",!0):P=="key"&&O.scrollIntoView(),i&&O.setMeta("composition",i),t.dispatch(O)}return}let o=t.state.doc.resolve(e),c=o.sharedDepth(n);e=o.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,h=_O(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),x,b;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ji)&&a.some(P=>P.nodeType==1&&!zO.test(P.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",P=>P(t,Tl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(r&&u instanceof st&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))N={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let P=aw(t,t.state.doc,h.sel);if(P&&!P.eq(t.state.selection)){let B=t.state.tr.setSelection(P);i&&B.setMeta("composition",i),t.dispatch(B)}}return}t.state.selection.fromt.state.selection.from&&N.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?N.start=t.state.selection.from:N.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(N.endB+=t.state.selection.to-N.endA,N.endA=t.state.selection.to)),cr&&To<=11&&N.endB==N.start+1&&N.endA==N.start&&N.start>h.from&&h.doc.textBetween(N.start-h.from-1,N.start-h.from+1)=="  "&&(N.start--,N.endA--,N.endB--);let w=h.doc.resolveNoCache(N.start-h.from),v=h.doc.resolveNoCache(N.endB-h.from),k=f.resolve(N.start),M=w.sameParent(v)&&w.parent.inlineContent&&k.end()>=N.endA;if((td&&t.input.lastIOSEnter>Date.now()-225&&(!M||a.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!M&&w.posP(t,Tl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&VO(f,N.start,N.endA,w,v)&&t.someProp("handleKeyDown",P=>P(t,Tl(8,"Backspace")))){ji&&js&&t.domObserver.suppressSelectionUpdates();return}js&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),ji&&!M&&w.start()!=v.start()&&v.parentOffset==0&&w.depth==v.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==N.endA&&(N.endB-=2,v=h.doc.resolveNoCache(N.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(P){return P(t,Tl(13,"Enter"))})},20));let E=N.start,L=N.endA,R=P=>{let B=P||t.state.tr.replace(E,L,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let O=aw(t,B.doc,h.sel);O&&!(js&&t.composing&&O.empty&&(N.start!=N.endB||t.input.lastChromeDeleteEi(t),20));let P=R(t.state.tr.delete(E,L)),B=f.resolve(N.start).marksAcross(f.resolve(N.endA));B&&P.ensureMarks(B),t.dispatch(P)}else if(N.endA==N.endB&&(W=BO(w.parent.content.cut(w.parentOffset,v.parentOffset),k.parent.content.cut(k.parentOffset,N.endA-k.start())))){let P=R(t.state.tr);W.type=="add"?P.addMark(E,L,W.mark):P.removeMark(E,L,W.mark),t.dispatch(P)}else if(w.parent.child(w.index()).isText&&w.index()==v.index()-(v.textOffset?0:1)){let P=w.parent.textBetween(w.parentOffset,v.parentOffset),B=()=>R(t.state.tr.insertText(P,E,L));t.someProp("handleTextInput",O=>O(t,E,L,P,B))||t.dispatch(B())}else t.dispatch(R());else t.dispatch(R())}function aw(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:jy(t,e.resolve(n.anchor),e.resolve(n.head))}function BO(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||ig(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 HO(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 bC{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 aO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(uw),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=cw(this),lw(this),this.nodeViews=dw(this),this.docView=BN(this.state.doc,ow(this),ag(this),this.dom,this),this.domObserver=new IO(this,(r,a,i,o)=>FO(this,r,a,i,o)),this.domObserver.start(),iO(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&&u0(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(uw),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&&(hC(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 b=dw(this);WO(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&u0(this),this.editable=cw(this),lw(this);let u=ag(this),h=ow(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 x=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&vL(this);if(o){this.domObserver.stop();let b=m&&(cr||js)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&UO(a.selection,e.selection);if(m){let N=js?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vO(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=BN(e.doc,h,u,this.dom,this)),N&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&UL(this))?Ei(this,b):(eC(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():x&&NL(x)}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 nt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&ON(this,n.getBoundingClientRect(),e)}else ON(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 pC(e.slice,e.move,a<0?void 0:nt.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 EL(this,e)}coordsAtPos(e,n=1){return KS(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 IL(this,n||this.state,e)}pasteHTML(e,n){return Mu(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Mu(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return ky(this,e)}destroy(){this.docView&&(oO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ag(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,dL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return cO(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ls&&this.root.nodeType===11&&mL(this.dom.ownerDocument)==this.dom&&LO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}bC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function ow(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"),[Yn.node(0,t.state.doc.content.size,e)]}function lw(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:Yn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function cw(t){return!t.someProp("editable",e=>e(t.state)===!1)}function UO(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 dw(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 WO(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 uw(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 _o={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:"'"},Vf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},KO=typeof navigator<"u"&&/Mac/.test(navigator.platform),qO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ws=0;ws<10;ws++)_o[48+ws]=_o[96+ws]=String(ws);for(var ws=1;ws<=24;ws++)_o[ws+111]="F"+ws;for(var ws=65;ws<=90;ws++)_o[ws]=String.fromCharCode(ws+32),Vf[ws]=String.fromCharCode(ws);for(var og in _o)Vf.hasOwnProperty(og)||(Vf[og]=_o[og]);function GO(t){var e=KO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||qO&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Vf:_o)[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 JO=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),QO=typeof navigator<"u"&&/Win/.test(navigator.platform);function YO(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)eD(t,n,{get:e[n],enumerable:!0})};function Hp(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 Up=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,x])=>[m,(...N)=>{const w=this.buildProps(u,e),v=x(...N)(w);return o.push(v),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:Hp({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}},vC={};Py(vC,{blur:()=>tD,clearContent:()=>nD,clearNodes:()=>sD,command:()=>rD,createParagraphNear:()=>aD,cut:()=>iD,deleteCurrentNode:()=>oD,deleteNode:()=>lD,deleteRange:()=>cD,deleteSelection:()=>dD,enter:()=>uD,exitCode:()=>hD,extendMarkRange:()=>fD,first:()=>pD,focus:()=>xD,forEach:()=>gD,insertContent:()=>yD,insertContentAt:()=>ND,joinBackward:()=>kD,joinDown:()=>jD,joinForward:()=>SD,joinItemBackward:()=>CD,joinItemForward:()=>ED,joinTextblockBackward:()=>TD,joinTextblockForward:()=>MD,joinUp:()=>wD,keyboardShortcut:()=>PD,lift:()=>ID,liftEmptyBlock:()=>RD,liftListItem:()=>LD,newlineInCode:()=>OD,resetAttributes:()=>DD,scrollIntoView:()=>_D,selectAll:()=>$D,selectNodeBackward:()=>zD,selectNodeForward:()=>FD,selectParentNode:()=>BD,selectTextblockEnd:()=>VD,selectTextblockStart:()=>HD,setContent:()=>UD,setMark:()=>d_,setMeta:()=>u_,setNode:()=>h_,setNodeSelection:()=>f_,setTextDirection:()=>p_,setTextSelection:()=>m_,sinkListItem:()=>x_,splitBlock:()=>g_,splitListItem:()=>y_,toggleList:()=>b_,toggleMark:()=>v_,toggleNode:()=>N_,toggleWrap:()=>w_,undoInputRule:()=>j_,unsetAllMarks:()=>k_,unsetMark:()=>S_,unsetTextDirection:()=>C_,updateAttributes:()=>E_,wrapIn:()=>T_,wrapInList:()=>M_});var tD=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),nD=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),sD=()=>({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)),x=h.resolve(f.map(u+c.nodeSize)),b=m.blockRange(x);if(!b)return;const N=hd(b);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(b.start,w)}(N||N===0)&&e.lift(b,N)})}),!0},rD=t=>e=>t(e),aD=()=>({state:t,dispatch:e})=>OS(t,e),iD=(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 st(r.doc.resolve(Math.max(o-1,0)))),!0},oD=()=>({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 Un(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 lD=t=>({tr:e,state:n,dispatch:r})=>{const a=Un(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},cD=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},dD=()=>({state:t,dispatch:e})=>xy(t,e),uD=()=>({commands:t})=>t.keyboardShortcut("Enter"),hD=()=>({state:t,dispatch:e})=>J6(t,e);function Iy(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Hf(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:Iy(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function NC(t,e,n={}){return t.find(r=>r.type===e&&Hf(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function hw(t,e,n={}){return!!NC(t,e,n)}function Ry(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),!NC([...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&&hw([...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=Ii(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=Ry(u,i,e);if(m&&m.from<=h&&m.to>=f){const x=st.create(o,m.from,m.to);n.setSelection(x)}}return!0},pD=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=()=>{(Uf()||fw())&&r.dom.focus(),mD()&&!Uf()&&!fw()&&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&&!wC(n.state.selection))return o(),!0;const c=jC(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},gD=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),yD=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),kC=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&&kC(r)}return t};function Xh(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 kC(n)}function Pu(t,e,n){if(t instanceof Si||t instanceof Ce)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 Ce.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),Pu("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new lS({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?Eo.fromSchema(u).parseSlice(Xh(t),n.parseOptions):Eo.fromSchema(u).parse(Xh(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=Eo.fromSchema(e);return n.slice?i.parseSlice(Xh(t),n.parseOptions).content:i.parse(Xh(t),n.parseOptions)}return Pu("",e,n)}function bD(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(ct.near(t.doc.resolve(o),n))}var vD=t=>!("type"in t),ND=(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=v=>{i.emit("contentError",{editor:i,error:v,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Pu(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(v){u(v)}try{c=Pu(e,i.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(v){return u(v),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},x=!0,b=!0;if((vD(c)?c:[c]).forEach(v=>{v.check(),x=x?v.isText&&v.marks.length===0:!1,b=b?v.isBlock:!1}),f===m&&b){const{parent:v}=r.doc.resolve(f);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(f-=1,m+=1)}let w;if(x){if(Array.isArray(e))w=e.map(v=>v.text||"").join("");else if(e instanceof Ce){let v="";e.forEach(k=>{k.text&&(v+=k.text)}),w=v}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,f,m)}else{w=c;const v=r.doc.resolve(f),k=v.node(),M=v.parentOffset===0,E=k.isText||k.isTextblock,L=k.content.size>0;M&&E&&L&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&bD(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},wD=()=>({state:t,dispatch:e})=>K6(t,e),jD=()=>({state:t,dispatch:e})=>q6(t,e),kD=()=>({state:t,dispatch:e})=>TS(t,e),SD=()=>({state:t,dispatch:e})=>IS(t,e),CD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=_p(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},ED=()=>({state:t,dispatch:e,tr:n})=>{try{const r=_p(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},TD=()=>({state:t,dispatch:e})=>U6(t,e),MD=()=>({state:t,dispatch:e})=>W6(t,e);function SC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function AD(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=AD(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 $o(t,e,n={}){const{from:r,to:a,empty:i}=t.selection,o=e?Un(e,t.schema):null,c=[];t.doc.nodesBetween(r,a,(m,x)=>{if(m.isText)return;const b=Math.max(r,x),N=Math.min(a,x+m.nodeSize);c.push({node:m,from:b,to:N})});const u=a-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Hf(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,x)=>m+x.to-x.from,0)>=u}var ID=(t,e={})=>({state:n,dispatch:r})=>{const a=Un(t,n.schema);return $o(n,a,e)?G6(n,r):!1},RD=()=>({state:t,dispatch:e})=>DS(t,e),LD=t=>({state:e,dispatch:n})=>{const r=Un(t,e.schema);return iL(r)(e,n)},OD=()=>({state:t,dispatch:e})=>LS(t,e);function Wp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function pw(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 DD=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=Wp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Un(t,r.schema)),c==="mark"&&(o=Ii(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,pw(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(x=>{o===x.type&&(u=!0,a&&n.addMark(m,m+f.nodeSize,o.create(pw(x.attrs,e))))})})}),u},_D=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),$D=()=>({tr:t,dispatch:e})=>{if(e){const n=new br(t.doc);t.setSelection(n)}return!0},zD=()=>({state:t,dispatch:e})=>AS(t,e),FD=()=>({state:t,dispatch:e})=>RS(t,e),BD=()=>({state:t,dispatch:e})=>X6(t,e),VD=()=>({state:t,dispatch:e})=>tL(t,e),HD=()=>({state:t,dispatch:e})=>eL(t,e);function h0(t,e,n={},r={}){return Pu(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var UD=(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=h0(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 CC(t,e){const n=Ii(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 EC(t,e){const n=new py(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function WD(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function TC(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 Kp(t){return e=>TC(e.$from,t)}function et(t,e,n){return t.config[e]===void 0&&t.parent?et(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?et(t.parent,e,n):null}):t.config[e]}function Ly(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=et(e,"addExtensions",n);return r?[e,...Ly(r())]:e}).flat(10)}function Oy(t,e){const n=Zl.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function MC(t){return typeof t=="function"}function Kt(t,e=void 0,...n){return MC(t)?e?t.bind(e)(...n):t(...n):t}function qD(t={}){return Object.keys(t).length===0&&t.constructor===Object}function nd(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 AC(t){const e=[],{nodeExtensions:n,markExtensions:r}=nd(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=et(h,"addGlobalAttributes",f);if(!m)return;m().forEach(b=>{let N;Array.isArray(b.types)?N=b.types:b.types==="*"?N=u:b.types==="nodes"?N=o:b.types==="marks"?N=c:N=[],N.forEach(w=>{Object.entries(b.attributes).forEach(([v,k])=>{e.push({type:w,name:v,attribute:{...i,...k}})})})})}),a.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=et(h,"addAttributes",f);if(!m)return;const x=m();Object.entries(x).forEach(([b,N])=>{const w={...i,...N};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:b,attribute:w})})}),e}function GD(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 mw(t){const e=[],n=GD(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([...mw(r[a]),...mw(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function Iu(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)=>Gt(n,r),{})}function JD(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function xw(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):JD(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function gw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&qD(n)?!1:n!=null))}function yw(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 QD(t,e){var n;const r=AC(t),{nodeExtensions:a,markExtensions:i}=nd(t),o=(n=a.find(h=>et(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},x=t.reduce((k,M)=>{const E=et(M,"extendNodeSchema",m);return{...k,...E?E(h):{}}},{}),b=gw({...x,content:Kt(et(h,"content",m)),marks:Kt(et(h,"marks",m)),group:Kt(et(h,"group",m)),inline:Kt(et(h,"inline",m)),atom:Kt(et(h,"atom",m)),selectable:Kt(et(h,"selectable",m)),draggable:Kt(et(h,"draggable",m)),code:Kt(et(h,"code",m)),whitespace:Kt(et(h,"whitespace",m)),linebreakReplacement:Kt(et(h,"linebreakReplacement",m)),defining:Kt(et(h,"defining",m)),isolating:Kt(et(h,"isolating",m)),attrs:Object.fromEntries(f.map(yw))}),N=Kt(et(h,"parseHTML",m));N&&(b.parseDOM=N.map(k=>xw(k,f)));const w=et(h,"renderHTML",m);w&&(b.toDOM=k=>w({node:k,HTMLAttributes:Iu(k,f)}));const v=et(h,"renderText",m);return v&&(b.toText=v),[h.name,b]})),u=Object.fromEntries(i.map(h=>{const f=r.filter(v=>v.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},x=t.reduce((v,k)=>{const M=et(k,"extendMarkSchema",m);return{...v,...M?M(h):{}}},{}),b=gw({...x,inclusive:Kt(et(h,"inclusive",m)),excludes:Kt(et(h,"excludes",m)),group:Kt(et(h,"group",m)),spanning:Kt(et(h,"spanning",m)),code:Kt(et(h,"code",m)),attrs:Object.fromEntries(f.map(yw))}),N=Kt(et(h,"parseHTML",m));N&&(b.parseDOM=N.map(v=>xw(v,f)));const w=et(h,"renderHTML",m);return w&&(b.toDOM=v=>w({mark:v,HTMLAttributes:Iu(v,f)})),[h.name,b]}));return new lS({topNode:o,nodes:c,marks:u})}function YD(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function fu(t){return t.sort((n,r)=>{const a=et(n,"priority")||100,i=et(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 IC(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 x;u.isBlock&&h>r&&(c+=i);const b=o==null?void 0:o[u.type.name];if(b)return f&&(c+=b({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(x=u==null?void 0:u.text)==null?void 0:x.slice(Math.max(r,h)-h,a-h))}),c}function XD(t,e){const n={from:0,to:t.content.size};return IC(t,n,e)}function RC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function ZD(t,e){const n=Un(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 LC(t,e){const n=Wp(typeof e=="string"?e:e.name,t.schema);return n==="node"?ZD(t,e):n==="mark"?CC(t,e):{}}function e_(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 t_(t){const e=e_(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 OC(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),x=e.invert().map(f);r.push({oldRange:{from:m,to:x},newRange:{from:h,to:f}})})}),t_(r)}function Dy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=Ry(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 n_=(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 Qd(t,e){return e.nodes[t]||e.marks[t]||null}function gf(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 s_=(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 f0(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?Ri(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Hf(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:x})=>{const b=m.pos,N=x.pos;t.doc.nodesBetween(b,N,(w,v)=>{if(i&&w.inlineContent&&!w.type.allowsMarkType(i))return!1;if(!w.isText&&!w.marks.length)return;const k=Math.max(b,v),M=Math.min(N,v+w.nodeSize),E=M-k;o+=E,c.push(...w.marks.map(L=>({mark:L,from:k,to:M})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Hf(m.mark.attrs,n,{strict:!1})).reduce((m,x)=>m+x.to-x.from,0),h=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,x)=>m+x.to-x.from,0);return(u>0?u+h:u)>=o}function r_(t,e,n={}){if(!e)return $o(t,null,n)||f0(t,null,n);const r=Wp(e,t.schema);return r==="node"?$o(t,e,n):r==="mark"?f0(t,e,n):!1}var a_=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=Kp(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 bw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function vw(t,e){const{nodeExtensions:n}=nd(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=Kt(et(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function qp(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&&(qp(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function DC(t){return t instanceof nt}var _C=class $C{constructor(e){this.position=e}static fromJSON(e){return new $C(e.position)}toJSON(){return{position:this.position}}};function o_(t,e){const n=e.mapping.mapResult(t.position);return{position:new _C(n.pos),mapResult:n}}function l_(t){return new _C(t)}function c_(t,e,n){var r;const{selection:a}=e;let i=null;if(wC(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,x)=>{if(h)return!1;if(f.isInline){const b=!x||x.type.allowsMarkType(n),N=!!n.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(n));h=b&&N}return!h}),h})}var d_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=Ri(t,r.schema);if(a)if(o){const h=CC(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,(x,b)=>{const N=Math.max(b,f),w=Math.min(b+x.nodeSize,m);x.marks.find(k=>k.type===u)?x.marks.forEach(k=>{u===k.type&&n.addMark(N,w,u.create({...k.attrs,...e}))}):n.addMark(N,w,u.create(e))})});return c_(r,n,u)},u_=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),h_=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=Un(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})=>IN(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>IN(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},f_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=Pl(t,0,r.content.size),i=nt.create(r,a);e.setSelection(i)}return!0},p_=(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},m_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=st.atStart(r).from,c=st.atEnd(r).to,u=Pl(a,o,c),h=Pl(i,o,c),f=st.create(r,u,h);e.setSelection(f)}return!0},x_=t=>({state:e,dispatch:n})=>{const r=Un(t,e.schema);return cL(r)(e,n)};function Nw(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 g_=({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=gf(h,c.node().type.name,c.node().attrs);if(i instanceof nt&&i.node.isBlock)return!c.parentOffset||!Ei(o,c.pos)?!1:(r&&(t&&Nw(n,a.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,x=c.depth===0?void 0:WD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&x?[{type:x,attrs:f}]:void 0,N=Ei(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!N&&Ei(e.doc,e.mapping.map(c.pos),1,x?[{type:x}]:void 0)&&(N=!0,b=x?[{type:x,attrs:f}]:void 0),r){if(N&&(i instanceof st&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,b),x&&!m&&!c.parentOffset&&c.parent.type!==x)){const w=e.mapping.map(c.before()),v=e.doc.resolve(w);c.node(-1).canReplaceWith(v.index(),v.index()+1,x)&&e.setNodeMarkup(e.mapping.map(c.before()),x)}t&&Nw(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},y_=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=Un(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 x=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=Se.empty;const M=u.index(-1)?1:u.index(-2)?2:3;for(let B=u.depth-M;B>=u.depth-3;B-=1)k=Se.from(u.node(B).copy(k));const E=u.indexAfter(-1){if(P>-1)return!1;B.isTextblock&&B.content.size===0&&(P=O+1)}),P>-1&&n.setSelection(st.near(n.doc.resolve(P))),n.scrollIntoView()}return!0}const b=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...gf(x,m.type.name,m.attrs),...e},w={...gf(x,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const v=b?[{type:c,attrs:N},{type:b,attrs:w}]:[{type:c,attrs:N}];if(!Ei(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:M}=r,{splittableMarks:E}=i.extensionManager,L=M||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,v).scrollIntoView(),!L||!a)return!0;const R=L.filter(W=>E.includes(W.type.name));n.ensureMarks(R)}return!0},cg=(t,e)=>{const n=Kp(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)&&Wo(t.doc,n.pos)&&t.join(n.pos),!0},dg=(t,e)=>{const n=Kp(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)&&Wo(t.doc,r)&&t.join(r),!0},b_=(t,e,n,r={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:x}=a.extensionManager,b=Un(t,o.schema),N=Un(e,o.schema),{selection:w,storedMarks:v}=o,{$from:k,$to:M}=w,E=k.blockRange(M),L=v||w.$to.parentOffset&&w.$from.marks();if(!E)return!1;const R=Kp(W=>vw(W.type.name,m))(w);if(E.depth>=1&&R&&E.depth-R.depth<=1){if(R.node.type===b)return h.liftListItem(N);if(vw(R.node.type.name,m)&&b.validContent(R.node.content)&&c)return u().command(()=>(i.setNodeMarkup(R.pos,b),!0)).command(()=>cg(i,b)).command(()=>dg(i,b)).run()}return!n||!L||!c?u().command(()=>f().wrapInList(b,r)?!0:h.clearNodes()).wrapInList(b,r).command(()=>cg(i,b)).command(()=>dg(i,b)).run():u().command(()=>{const W=f().wrapInList(b,r),P=L.filter(B=>x.includes(B.type.name));return i.ensureMarks(P),W?!0:h.clearNodes()}).wrapInList(b,r).command(()=>cg(i,b)).command(()=>dg(i,b)).run()},v_=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=Ri(t,r.schema);return f0(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},N_=(t,e,n={})=>({state:r,commands:a})=>{const i=Un(t,r.schema),o=Un(e,r.schema),c=$o(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})},w_=(t,e={})=>({state:n,commands:r})=>{const a=Un(t,n.schema);return $o(n,a,e)?r.lift(a):r.wrapIn(a,e)},j_=()=>({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},k_=()=>({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},S_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=Ri(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:x,to:b}=c;const N=(i=h.marks().find(v=>v.type===u))==null?void 0:i.attrs,w=Ry(h,u,N);w&&(x=w.from,b=w.to),n.removeMark(x,b,u)}else m.forEach(x=>{n.removeMark(x.$from.pos,x.$to.pos,u)});return n.removeStoredMark(u),!0},C_=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},E_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=Wp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Un(t,r.schema)),c==="mark"&&(o=Ri(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let x,b,N,w;n.selection.empty?r.doc.nodesBetween(f,m,(v,k)=>{i&&i===v.type&&(u=!0,N=Math.max(k,f),w=Math.min(k+v.nodeSize,m),x=k,b=v)}):r.doc.nodesBetween(f,m,(v,k)=>{k=f&&k<=m&&(i&&i===v.type&&(u=!0,a&&n.setNodeMarkup(k,void 0,{...v.attrs,...e})),o&&v.marks.length&&v.marks.forEach(M=>{if(o===M.type&&(u=!0,a)){const E=Math.max(k,f),L=Math.min(k+v.nodeSize,m);n.addMark(E,L,o.create({...M.attrs,...e}))}}))}),b&&(x!==void 0&&a&&n.setNodeMarkup(x,void 0,{...b.attrs,...e}),o&&b.marks.length&&b.marks.forEach(v=>{o===v.type&&a&&n.addMark(N,w,o.create({...v.attrs,...e}))}))}),u},T_=(t,e={})=>({state:n,dispatch:r})=>{const a=Un(t,n.schema);return nL(a,e)(n,r)},M_=(t,e={})=>({state:n,dispatch:r})=>{const a=Un(t,n.schema);return sL(a,e)(n,r)},A_=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={}}},Gp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},P_=(t,e)=>{if(Iy(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 Zh(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(x=>x.type.spec.code))return!1;let f=!1;const m=s_(h)+i;return o.forEach(x=>{if(f)return;const b=P_(m,x.find);if(!b)return;const N=u.state.tr,w=Hp({state:u.state,transaction:N}),v={from:r-(b[0].length-i.length),to:a},{commands:k,chain:M,can:E}=new Up({editor:n,state:w});x.handler({state:w,range:v,match:b,commands:k,chain:M,can:E})===null||!N.steps.length||(x.undoable&&N.setMeta(c,{transform:N,from:r,to:a,text:i}),u.dispatch(N),f=!0)}),f}function I_(t){const{editor:e,rules:n}=t,r=new an({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=Oy(Se.from(f),o.schema);const{from:m}=u,x=m+f.length;Zh({editor:e,from:m,to:x,text:f,rules:n,plugin:r})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return Zh({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&Zh({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?Zh({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function R_(t){return Object.prototype.toString.call(t).slice(8,-1)}function ef(t){return R_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function zC(t,e){const n={...t};return ef(t)&&ef(e)&&Object.keys(e).forEach(r=>{ef(e[r])&&ef(t[r])?n[r]=zC(t[r],e[r]):n[r]=e[r]}),n}var _y=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Kt(et(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Kt(et(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>zC(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}},ec=class FC extends _y{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new FC(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 L_(t){return typeof t=="number"}var O_=class{constructor(t){this.find=t.find,this.handler=t.handler}},D_=(t,e,n)=>{if(Iy(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 __(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Up({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(b,N)=>{var w,v,k,M,E;if((v=(w=b.type)==null?void 0:w.spec)!=null&&v.code||!(b.isText||b.isTextblock||b.isInline))return;const L=(E=(M=(k=b.content)==null?void 0:k.size)!=null?M:b.nodeSize)!=null?E:0,R=Math.max(r,N),W=Math.min(a,N+L);if(R>=W)return;const P=b.isText?b.text||"":b.textBetween(R-N,W-N,void 0,"");D_(P,i.find,o).forEach(O=>{if(O.index===void 0)return;const Y=R+O.index+1,ae=Y+O[0].length,_={from:n.tr.mapping.map(Y),to:n.tr.mapping.map(ae)},se=i.handler({state:n,range:_,match:O,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(se)})}),m.every(b=>b!==null)}var tf=null,$_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function z_(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:x,rule:b,pasteEvt:N})=>{const w=f.tr,v=Hp({state:f,transaction:w});if(!(!__({editor:e,state:v,from:Math.max(m-1,0),to:x.b-1,rule:b,pasteEvent:N,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 an({view(m){const x=N=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(N.target)?m.dom.parentElement:null,r&&(tf=e)},b=()=>{tf&&(tf=null)};return window.addEventListener("dragstart",x),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",x),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(m,x)=>{if(i=r===m.dom.parentElement,c=x,!i){const b=tf;b!=null&&b.isEditable&&setTimeout(()=>{const N=b.state.selection;N&&b.commands.deleteRange({from:N.from,to:N.to})},10)}return!1},paste:(m,x)=>{var b;const N=(b=x.clipboardData)==null?void 0:b.getData("text/html");return o=x,a=!!(N!=null&&N.includes("data-pm-slice")),!1}}},appendTransaction:(m,x,b)=>{const N=m[0],w=N.getMeta("uiEvent")==="paste"&&!a,v=N.getMeta("uiEvent")==="drop"&&!i,k=N.getMeta("applyPasteRules"),M=!!k;if(!w&&!v&&!M)return;if(M){let{text:R}=k;typeof R=="string"?R=R:R=Oy(Se.from(R),b.schema);const{from:W}=k,P=W+R.length,B=$_(R);return u({rule:f,state:b,from:W,to:{b:P},pasteEvt:B})}const E=x.doc.content.findDiffStart(b.doc.content),L=x.doc.content.findDiffEnd(b.doc.content);if(!(!L_(E)||!L||E===L.b))return u({rule:f,state:b,from:E,to:L,pasteEvt:o})}}))}var Jp=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=PC(t),this.schema=QD(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:Qd(e.name,this.schema)},r=et(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return hu([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Qd(r.name,this.schema)},i=[],o=et(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&et(r,"exitable",a)&&(c.ArrowRight=()=>ec.handleExit({editor:t,mark:r})),o){const x=Object.fromEntries(Object.entries(o()).map(([b,N])=>[b,()=>N({editor:t})]));c={...c,...x}}const u=ZO(c);i.push(u);const h=et(r,"addInputRules",a);if(bw(r,t.options.enableInputRules)&&h){const x=h();if(x&&x.length){const b=I_({editor:t,rules:x}),N=Array.isArray(b)?b:[b];i.push(...N)}}const f=et(r,"addPasteRules",a);if(bw(r,t.options.enablePasteRules)&&f){const x=f();if(x&&x.length){const b=z_({editor:t,rules:x});i.push(...b)}}const m=et(r,"addProseMirrorPlugins",a);if(m){const x=m();i.push(...x)}return i})}get attributes(){return AC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=nd(this.extensions);return Object.fromEntries(e.filter(n=>!!et(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:Un(n.name,this.schema)},i=et(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,x)=>{const b=Pu(u,r);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:x,editor:t,extension:n,HTMLAttributes:b})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return hu([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Qd(a.name,this.schema)},o=et(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return hu([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Qd(a.name,this.schema)},o=et(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}=nd(this.extensions);return Object.fromEntries(e.filter(n=>!!et(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:Ri(n.name,this.schema)},i=et(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Pu(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{e7(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:Qd(e.name,this.schema)};e.type==="mark"&&((n=Kt(et(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=et(e,"onBeforeCreate",r),i=et(e,"onCreate",r),o=et(e,"onUpdate",r),c=et(e,"onSelectionUpdate",r),u=et(e,"onTransaction",r),h=et(e,"onFocus",r),f=et(e,"onBlur",r),m=et(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)})}};Jp.resolve=PC;Jp.sort=hu;Jp.flatten=Ly;var F_={};Py(F_,{ClipboardTextSerializer:()=>VC,Commands:()=>HC,Delete:()=>UC,Drop:()=>WC,Editable:()=>KC,FocusEvents:()=>GC,Keymap:()=>JC,Paste:()=>QC,Tabindex:()=>YC,TextDirection:()=>XC,focusEventsPluginKey:()=>qC});var In=class BC extends _y{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new BC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},VC=In.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new an({key:new bn("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=RC(n);return IC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),HC=In.create({name:"commands",addCommands(){return{...vC}}}),UC=In.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=EC(t.before,[t,...e]);OC(f).forEach(b=>{f.mapping.mapResult(b.oldRange.from).deletedAfter&&f.mapping.mapResult(b.oldRange.to).deletedBefore&&f.before.nodesBetween(b.oldRange.from,b.oldRange.to,(N,w)=>{const v=w+N.nodeSize-2,k=b.oldRange.from<=w&&v<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:N,from:w,to:v,newFrom:f.mapping.map(w),newTo:f.mapping.map(v),deletedRange:b.oldRange,newRange:b.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const x=f.mapping;f.steps.forEach((b,N)=>{var w,v;if(b instanceof ra){const k=x.slice(N).map(b.from,-1),M=x.slice(N).map(b.to),E=x.invert().map(k,-1),L=x.invert().map(M),R=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(P=>P.eq(b.mark)),W=(v=f.doc.nodeAt(M))==null?void 0:v.marks.some(P=>P.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:E,to:L},newRange:{from:k,to:M},partial:!!(W||R),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()}}),WC=In.create({name:"drop",addProseMirrorPlugins(){return[new an({key:new bn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),KC=In.create({name:"editable",addProseMirrorPlugins(){return[new an({key:new bn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qC=new bn("focusEvents"),GC=In.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new an({key:qC,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}}}})]}}),JC=In.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:x,parent:b}=m,N=m.parent.isTextblock&&x>0?c.doc.resolve(x-1):m,w=N.parent.type.spec.isolating,v=m.pos-m.parentOffset,k=w&&N.parent.childCount===1?v===m.pos:ct.atStart(h).from===x;return!f||!b.type.isTextblock||b.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 Uf()||SC()?i:a},addProseMirrorPlugins(){return[new an({key:new bn("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=ct.atStart(e.doc).from,h=ct.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!qp(n.doc))return;const x=n.tr,b=Hp({state:n,transaction:x}),{commands:N}=new Up({editor:this.editor,state:b});if(N.clearNodes(),!!x.steps.length)return x}})]}}),QC=In.create({name:"paste",addProseMirrorPlugins(){return[new an({key:new bn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),YC=In.create({name:"tabindex",addProseMirrorPlugins(){return[new an({key:new bn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),XC=In.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=nd(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 an({key:new bn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),B_=class nu{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 nu(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 nu(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 nu(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 nu(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)}},V_=`.ProseMirror { +`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,a,(u,h,f,m)=>{var x;u.isBlock&&h>r&&(c+=i);const b=o==null?void 0:o[u.type.name];if(b)return f&&(c+=b({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(x=u==null?void 0:u.text)==null?void 0:x.slice(Math.max(r,h)-h,a-h))}),c}function XD(t,e){const n={from:0,to:t.content.size};return IC(t,n,e)}function RC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function ZD(t,e){const n=Un(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 LC(t,e){const n=Wp(typeof e=="string"?e:e.name,t.schema);return n==="node"?ZD(t,e):n==="mark"?CC(t,e):{}}function e_(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 t_(t){const e=e_(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 OC(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),x=e.invert().map(f);r.push({oldRange:{from:m,to:x},newRange:{from:h,to:f}})})}),t_(r)}function Dy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=Ry(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 n_=(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 Yd(t,e){return e.nodes[t]||e.marks[t]||null}function gf(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 s_=(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 f0(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?Ii(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Hf(m.attrs,n,{strict:!1}));let o=0;const c=[];if(a.forEach(({$from:m,$to:x})=>{const b=m.pos,N=x.pos;t.doc.nodesBetween(b,N,(w,v)=>{if(i&&w.inlineContent&&!w.type.allowsMarkType(i))return!1;if(!w.isText&&!w.marks.length)return;const k=Math.max(b,v),M=Math.min(N,v+w.nodeSize),E=M-k;o+=E,c.push(...w.marks.map(L=>({mark:L,from:k,to:M})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Hf(m.mark.attrs,n,{strict:!1})).reduce((m,x)=>m+x.to-x.from,0),h=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,x)=>m+x.to-x.from,0);return(u>0?u+h:u)>=o}function r_(t,e,n={}){if(!e)return $o(t,null,n)||f0(t,null,n);const r=Wp(e,t.schema);return r==="node"?$o(t,e,n):r==="mark"?f0(t,e,n):!1}var a_=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=Kp(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 bw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function vw(t,e){const{nodeExtensions:n}=nd(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=Kt(et(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function qp(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&&(qp(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function DC(t){return t instanceof nt}var _C=class $C{constructor(e){this.position=e}static fromJSON(e){return new $C(e.position)}toJSON(){return{position:this.position}}};function o_(t,e){const n=e.mapping.mapResult(t.position);return{position:new _C(n.pos),mapResult:n}}function l_(t){return new _C(t)}function c_(t,e,n){var r;const{selection:a}=e;let i=null;if(wC(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,x)=>{if(h)return!1;if(f.isInline){const b=!x||x.type.allowsMarkType(n),N=!!n.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(n));h=b&&N}return!h}),h})}var d_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=Ii(t,r.schema);if(a)if(o){const h=CC(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,(x,b)=>{const N=Math.max(b,f),w=Math.min(b+x.nodeSize,m);x.marks.find(k=>k.type===u)?x.marks.forEach(k=>{u===k.type&&n.addMark(N,w,u.create({...k.attrs,...e}))}):n.addMark(N,w,u.create(e))})});return c_(r,n,u)},u_=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),h_=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=Un(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})=>IN(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>IN(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},f_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=Pl(t,0,r.content.size),i=nt.create(r,a);e.setSelection(i)}return!0},p_=(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},m_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=st.atStart(r).from,c=st.atEnd(r).to,u=Pl(a,o,c),h=Pl(i,o,c),f=st.create(r,u,h);e.setSelection(f)}return!0},x_=t=>({state:e,dispatch:n})=>{const r=Un(t,e.schema);return cL(r)(e,n)};function Nw(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 g_=({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=gf(h,c.node().type.name,c.node().attrs);if(i instanceof nt&&i.node.isBlock)return!c.parentOffset||!Ci(o,c.pos)?!1:(r&&(t&&Nw(n,a.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,x=c.depth===0?void 0:WD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&x?[{type:x,attrs:f}]:void 0,N=Ci(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!N&&Ci(e.doc,e.mapping.map(c.pos),1,x?[{type:x}]:void 0)&&(N=!0,b=x?[{type:x,attrs:f}]:void 0),r){if(N&&(i instanceof st&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,b),x&&!m&&!c.parentOffset&&c.parent.type!==x)){const w=e.mapping.map(c.before()),v=e.doc.resolve(w);c.node(-1).canReplaceWith(v.index(),v.index()+1,x)&&e.setNodeMarkup(e.mapping.map(c.before()),x)}t&&Nw(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},y_=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=Un(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 x=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=Ce.empty;const M=u.index(-1)?1:u.index(-2)?2:3;for(let B=u.depth-M;B>=u.depth-3;B-=1)k=Ce.from(u.node(B).copy(k));const E=u.indexAfter(-1){if(P>-1)return!1;B.isTextblock&&B.content.size===0&&(P=O+1)}),P>-1&&n.setSelection(st.near(n.doc.resolve(P))),n.scrollIntoView()}return!0}const b=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...gf(x,m.type.name,m.attrs),...e},w={...gf(x,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const v=b?[{type:c,attrs:N},{type:b,attrs:w}]:[{type:c,attrs:N}];if(!Ci(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:M}=r,{splittableMarks:E}=i.extensionManager,L=M||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,v).scrollIntoView(),!L||!a)return!0;const R=L.filter(W=>E.includes(W.type.name));n.ensureMarks(R)}return!0},cg=(t,e)=>{const n=Kp(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)&&Wo(t.doc,n.pos)&&t.join(n.pos),!0},dg=(t,e)=>{const n=Kp(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)&&Wo(t.doc,r)&&t.join(r),!0},b_=(t,e,n,r={})=>({editor:a,tr:i,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:x}=a.extensionManager,b=Un(t,o.schema),N=Un(e,o.schema),{selection:w,storedMarks:v}=o,{$from:k,$to:M}=w,E=k.blockRange(M),L=v||w.$to.parentOffset&&w.$from.marks();if(!E)return!1;const R=Kp(W=>vw(W.type.name,m))(w);if(E.depth>=1&&R&&E.depth-R.depth<=1){if(R.node.type===b)return h.liftListItem(N);if(vw(R.node.type.name,m)&&b.validContent(R.node.content)&&c)return u().command(()=>(i.setNodeMarkup(R.pos,b),!0)).command(()=>cg(i,b)).command(()=>dg(i,b)).run()}return!n||!L||!c?u().command(()=>f().wrapInList(b,r)?!0:h.clearNodes()).wrapInList(b,r).command(()=>cg(i,b)).command(()=>dg(i,b)).run():u().command(()=>{const W=f().wrapInList(b,r),P=L.filter(B=>x.includes(B.type.name));return i.ensureMarks(P),W?!0:h.clearNodes()}).wrapInList(b,r).command(()=>cg(i,b)).command(()=>dg(i,b)).run()},v_=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=Ii(t,r.schema);return f0(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},N_=(t,e,n={})=>({state:r,commands:a})=>{const i=Un(t,r.schema),o=Un(e,r.schema),c=$o(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})},w_=(t,e={})=>({state:n,commands:r})=>{const a=Un(t,n.schema);return $o(n,a,e)?r.lift(a):r.wrapIn(a,e)},j_=()=>({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},k_=()=>({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},S_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=Ii(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!a)return!0;if(f&&o){let{from:x,to:b}=c;const N=(i=h.marks().find(v=>v.type===u))==null?void 0:i.attrs,w=Ry(h,u,N);w&&(x=w.from,b=w.to),n.removeMark(x,b,u)}else m.forEach(x=>{n.removeMark(x.$from.pos,x.$to.pos,u)});return n.removeStoredMark(u),!0},C_=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},E_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=Wp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Un(t,r.schema)),c==="mark"&&(o=Ii(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let x,b,N,w;n.selection.empty?r.doc.nodesBetween(f,m,(v,k)=>{i&&i===v.type&&(u=!0,N=Math.max(k,f),w=Math.min(k+v.nodeSize,m),x=k,b=v)}):r.doc.nodesBetween(f,m,(v,k)=>{k=f&&k<=m&&(i&&i===v.type&&(u=!0,a&&n.setNodeMarkup(k,void 0,{...v.attrs,...e})),o&&v.marks.length&&v.marks.forEach(M=>{if(o===M.type&&(u=!0,a)){const E=Math.max(k,f),L=Math.min(k+v.nodeSize,m);n.addMark(E,L,o.create({...M.attrs,...e}))}}))}),b&&(x!==void 0&&a&&n.setNodeMarkup(x,void 0,{...b.attrs,...e}),o&&b.marks.length&&b.marks.forEach(v=>{o===v.type&&a&&n.addMark(N,w,o.create({...v.attrs,...e}))}))}),u},T_=(t,e={})=>({state:n,dispatch:r})=>{const a=Un(t,n.schema);return nL(a,e)(n,r)},M_=(t,e={})=>({state:n,dispatch:r})=>{const a=Un(t,n.schema);return sL(a,e)(n,r)},A_=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={}}},Gp=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},P_=(t,e)=>{if(Iy(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 Zh(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(x=>x.type.spec.code))return!1;let f=!1;const m=s_(h)+i;return o.forEach(x=>{if(f)return;const b=P_(m,x.find);if(!b)return;const N=u.state.tr,w=Hp({state:u.state,transaction:N}),v={from:r-(b[0].length-i.length),to:a},{commands:k,chain:M,can:E}=new Up({editor:n,state:w});x.handler({state:w,range:v,match:b,commands:k,chain:M,can:E})===null||!N.steps.length||(x.undoable&&N.setMeta(c,{transform:N,from:r,to:a,text:i}),u.dispatch(N),f=!0)}),f}function I_(t){const{editor:e,rules:n}=t,r=new on({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=Oy(Ce.from(f),o.schema);const{from:m}=u,x=m+f.length;Zh({editor:e,from:m,to:x,text:f,rules:n,plugin:r})}),a.selectionSet||a.docChanged?null:i}},props:{handleTextInput(a,i,o,c){return Zh({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&Zh({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?Zh({editor:e,from:o.pos,to:o.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function R_(t){return Object.prototype.toString.call(t).slice(8,-1)}function ef(t){return R_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function zC(t,e){const n={...t};return ef(t)&&ef(e)&&Object.keys(e).forEach(r=>{ef(e[r])&&ef(t[r])?n[r]=zC(t[r],e[r]):n[r]=e[r]}),n}var _y=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Kt(et(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Kt(et(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>zC(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}},ec=class FC extends _y{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new FC(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 L_(t){return typeof t=="number"}var O_=class{constructor(t){this.find=t.find,this.handler=t.handler}},D_=(t,e,n)=>{if(Iy(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 __(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Up({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(b,N)=>{var w,v,k,M,E;if((v=(w=b.type)==null?void 0:w.spec)!=null&&v.code||!(b.isText||b.isTextblock||b.isInline))return;const L=(E=(M=(k=b.content)==null?void 0:k.size)!=null?M:b.nodeSize)!=null?E:0,R=Math.max(r,N),W=Math.min(a,N+L);if(R>=W)return;const P=b.isText?b.text||"":b.textBetween(R-N,W-N,void 0,"");D_(P,i.find,o).forEach(O=>{if(O.index===void 0)return;const X=R+O.index+1,ae=X+O[0].length,_={from:n.tr.mapping.map(X),to:n.tr.mapping.map(ae)},se=i.handler({state:n,range:_,match:O,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(se)})}),m.every(b=>b!==null)}var tf=null,$_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function z_(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:x,rule:b,pasteEvt:N})=>{const w=f.tr,v=Hp({state:f,transaction:w});if(!(!__({editor:e,state:v,from:Math.max(m-1,0),to:x.b-1,rule:b,pasteEvent:N,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 on({view(m){const x=N=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(N.target)?m.dom.parentElement:null,r&&(tf=e)},b=()=>{tf&&(tf=null)};return window.addEventListener("dragstart",x),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",x),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(m,x)=>{if(i=r===m.dom.parentElement,c=x,!i){const b=tf;b!=null&&b.isEditable&&setTimeout(()=>{const N=b.state.selection;N&&b.commands.deleteRange({from:N.from,to:N.to})},10)}return!1},paste:(m,x)=>{var b;const N=(b=x.clipboardData)==null?void 0:b.getData("text/html");return o=x,a=!!(N!=null&&N.includes("data-pm-slice")),!1}}},appendTransaction:(m,x,b)=>{const N=m[0],w=N.getMeta("uiEvent")==="paste"&&!a,v=N.getMeta("uiEvent")==="drop"&&!i,k=N.getMeta("applyPasteRules"),M=!!k;if(!w&&!v&&!M)return;if(M){let{text:R}=k;typeof R=="string"?R=R:R=Oy(Ce.from(R),b.schema);const{from:W}=k,P=W+R.length,B=$_(R);return u({rule:f,state:b,from:W,to:{b:P},pasteEvt:B})}const E=x.doc.content.findDiffStart(b.doc.content),L=x.doc.content.findDiffEnd(b.doc.content);if(!(!L_(E)||!L||E===L.b))return u({rule:f,state:b,from:E,to:L,pasteEvt:o})}}))}var Jp=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=PC(t),this.schema=QD(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:Yd(e.name,this.schema)},r=et(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return fu([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Yd(r.name,this.schema)},i=[],o=et(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&et(r,"exitable",a)&&(c.ArrowRight=()=>ec.handleExit({editor:t,mark:r})),o){const x=Object.fromEntries(Object.entries(o()).map(([b,N])=>[b,()=>N({editor:t})]));c={...c,...x}}const u=ZO(c);i.push(u);const h=et(r,"addInputRules",a);if(bw(r,t.options.enableInputRules)&&h){const x=h();if(x&&x.length){const b=I_({editor:t,rules:x}),N=Array.isArray(b)?b:[b];i.push(...N)}}const f=et(r,"addPasteRules",a);if(bw(r,t.options.enablePasteRules)&&f){const x=f();if(x&&x.length){const b=z_({editor:t,rules:x});i.push(...b)}}const m=et(r,"addProseMirrorPlugins",a);if(m){const x=m();i.push(...x)}return i})}get attributes(){return AC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=nd(this.extensions);return Object.fromEntries(e.filter(n=>!!et(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:Un(n.name,this.schema)},i=et(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,x)=>{const b=Iu(u,r);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:x,editor:t,extension:n,HTMLAttributes:b})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return fu([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Yd(a.name,this.schema)},o=et(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return fu([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:Yd(a.name,this.schema)},o=et(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}=nd(this.extensions);return Object.fromEntries(e.filter(n=>!!et(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:Ii(n.name,this.schema)},i=et(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Iu(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{e7(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:Yd(e.name,this.schema)};e.type==="mark"&&((n=Kt(et(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=et(e,"onBeforeCreate",r),i=et(e,"onCreate",r),o=et(e,"onUpdate",r),c=et(e,"onSelectionUpdate",r),u=et(e,"onTransaction",r),h=et(e,"onFocus",r),f=et(e,"onBlur",r),m=et(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)})}};Jp.resolve=PC;Jp.sort=fu;Jp.flatten=Ly;var F_={};Py(F_,{ClipboardTextSerializer:()=>VC,Commands:()=>HC,Delete:()=>UC,Drop:()=>WC,Editable:()=>KC,FocusEvents:()=>GC,Keymap:()=>JC,Paste:()=>QC,Tabindex:()=>YC,TextDirection:()=>XC,focusEventsPluginKey:()=>qC});var In=class BC extends _y{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new BC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},VC=In.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new on({key:new bn("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=RC(n);return IC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),HC=In.create({name:"commands",addCommands(){return{...vC}}}),UC=In.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=EC(t.before,[t,...e]);OC(f).forEach(b=>{f.mapping.mapResult(b.oldRange.from).deletedAfter&&f.mapping.mapResult(b.oldRange.to).deletedBefore&&f.before.nodesBetween(b.oldRange.from,b.oldRange.to,(N,w)=>{const v=w+N.nodeSize-2,k=b.oldRange.from<=w&&v<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:N,from:w,to:v,newFrom:f.mapping.map(w),newTo:f.mapping.map(v),deletedRange:b.oldRange,newRange:b.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const x=f.mapping;f.steps.forEach((b,N)=>{var w,v;if(b instanceof ra){const k=x.slice(N).map(b.from,-1),M=x.slice(N).map(b.to),E=x.invert().map(k,-1),L=x.invert().map(M),R=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(P=>P.eq(b.mark)),W=(v=f.doc.nodeAt(M))==null?void 0:v.marks.some(P=>P.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:E,to:L},newRange:{from:k,to:M},partial:!!(W||R),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()}}),WC=In.create({name:"drop",addProseMirrorPlugins(){return[new on({key:new bn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),KC=In.create({name:"editable",addProseMirrorPlugins(){return[new on({key:new bn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qC=new bn("focusEvents"),GC=In.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new on({key:qC,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}}}})]}}),JC=In.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:x,parent:b}=m,N=m.parent.isTextblock&&x>0?c.doc.resolve(x-1):m,w=N.parent.type.spec.isolating,v=m.pos-m.parentOffset,k=w&&N.parent.childCount===1?v===m.pos:ct.atStart(h).from===x;return!f||!b.type.isTextblock||b.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 Uf()||SC()?i:a},addProseMirrorPlugins(){return[new on({key:new bn("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=ct.atStart(e.doc).from,h=ct.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!qp(n.doc))return;const x=n.tr,b=Hp({state:n,transaction:x}),{commands:N}=new Up({editor:this.editor,state:b});if(N.clearNodes(),!!x.steps.length)return x}})]}}),QC=In.create({name:"paste",addProseMirrorPlugins(){return[new on({key:new bn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),YC=In.create({name:"tabindex",addProseMirrorPlugins(){return[new on({key:new bn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),XC=In.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=nd(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 on({key:new bn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),B_=class su{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 su(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 su(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 su(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 su(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)}},V_=`.ProseMirror { position: relative; } @@ -789,7 +789,7 @@ img.ProseMirror-separator { display: block; }`;function H_(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 U_=class extends A_{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:o_,createMappablePosition:l_},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=jC(e,this.options.autofocus);this.editorState=Wc.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=H_(V_,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=MC(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?[KC,VC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),HC,GC,JC,YC,WC,QC,UC,XC.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 Jp(r,this)}createCommandManager(){this.commandManager=new Up({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=h0(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=h0(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 bC(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 LC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return r_(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Oy(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` -`,textSerializers:n={}}=t||{};return XD(this.state.doc,{blockSeparator:e,textSerializers:{...RC(this.schema),...n}})}get isEmpty(){return qp(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 B_(e,this)}get $doc(){return this.$pos(0)}};function sd(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Kt(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(Dy(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>h).length)return null;fn.from&&i.delete(n.from+u,h);const x=n.from+u+o.length;i.addMark(n.from+u,x,t.type.create(a||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function ZC(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Kt(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 p0(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=Kt(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 rd(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=Kt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&fy(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:x}=e,{splittableMarks:b}=t.editor.extensionManager,N=x||m.$to.parentOffset&&m.$from.marks();if(N){const w=N.filter(v=>b.includes(v.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&&Wo(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var W_=t=>"touches"in t,K_=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,W_(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 q_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof nt){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 G_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var J_={};Py(J_,{createAtomBlockMarkdownSpec:()=>Q_,createBlockMarkdownSpec:()=>Y_,createInlineMarkdownSpec:()=>e3,parseAttributes:()=>$y,parseIndentedBlocks:()=>m0,renderNestedMarkdownContent:()=>Fy,serializeAttributes:()=>zy});function $y(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 x=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),b=n[x];b&&(e[h]=b.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 zy(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 Q_(t){const{nodeName:e,name:n,parseAttributes:r=$y,serializeAttributes:a=zy,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(x=>{x in f&&(m[x]=f[x])}),m};return{parseMarkdown:(f,m)=>{const x={...i,...f.attributes};return m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const x=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(m=f.match(x))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(f,m,x){const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),N=f.match(b);if(!N)return;const w=N[1]||"",v=r(w);if(!o.find(M=>!(M in v)))return{type:e,raw:N[0],attributes:v}}},renderMarkdown:f=>{const m=h(f.attrs||{}),x=a(m),b=x?` {${x}}`:"";return`:::${u}${b} :::`}}}function Y_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=$y,serializeAttributes:i=zy,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const x={};return u.forEach(b=>{b in m&&(x[b]=m[b])}),x};return{parseMarkdown:(m,x)=>{let b;if(r){const w=r(m);b=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?b=x.parseChildren(m.tokens||[]):b=x.parseInline(m.tokens||[]);const N={...o,...m.attributes};return x.createNode(e,N,b)},markdownTokenizer:{name:e,level:"block",start(m){var x;const b=new RegExp(`^:::${h}`,"m"),N=(x=m.match(b))==null?void 0:x.index;return N!==void 0?N:-1},tokenize(m,x,b){var N;const w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=m.match(w);if(!v)return;const[k,M=""]=v,E=a(M);let L=1;const R=k.length;let W="";const P=/^:::([\w-]*)(\s.*)?/gm,B=m.slice(R);for(P.lastIndex=0;;){const O=P.exec(B);if(O===null)break;const Y=O.index,ae=O[1];if(!((N=O[2])!=null&&N.endsWith(":::"))){if(ae)L+=1;else if(L-=1,L===0){const _=B.slice(0,Y);W=_.trim();const se=m.slice(0,R+Y+O[0].length);let ce=[];if(W)if(c==="block")for(ce=b.blockTokens(_),ce.forEach(me=>{me.text&&(!me.tokens||me.tokens.length===0)&&(me.tokens=b.inlineTokens(me.text))});ce.length>0;){const me=ce[ce.length-1];if(me.type==="paragraph"&&(!me.text||me.text.trim()===""))ce.pop();else break}else ce=b.inlineTokens(W);return{type:e,raw:se,attributes:E,content:W,tokens:ce}}}}}},renderMarkdown:(m,x)=>{const b=f(m.attrs||{}),N=i(b),w=N?` {${N}}`:"",v=x.renderChildren(m.content||[],` +`,textSerializers:n={}}=t||{};return XD(this.state.doc,{blockSeparator:e,textSerializers:{...RC(this.schema),...n}})}get isEmpty(){return qp(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 B_(e,this)}get $doc(){return this.$pos(0)}};function sd(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Kt(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(Dy(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>h).length)return null;fn.from&&i.delete(n.from+u,h);const x=n.from+u+o.length;i.addMark(n.from+u,x,t.type.create(a||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function ZC(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Kt(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 p0(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=Kt(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 rd(t){return new Gp({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=Kt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&fy(u,t.type,i);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:x}=e,{splittableMarks:b}=t.editor.extensionManager,N=x||m.$to.parentOffset&&m.$from.marks();if(N){const w=N.filter(v=>b.includes(v.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&&Wo(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var W_=t=>"touches"in t,K_=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,W_(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 q_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof nt){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 G_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var J_={};Py(J_,{createAtomBlockMarkdownSpec:()=>Q_,createBlockMarkdownSpec:()=>Y_,createInlineMarkdownSpec:()=>e3,parseAttributes:()=>$y,parseIndentedBlocks:()=>m0,renderNestedMarkdownContent:()=>Fy,serializeAttributes:()=>zy});function $y(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 x=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),b=n[x];b&&(e[h]=b.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 zy(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 Q_(t){const{nodeName:e,name:n,parseAttributes:r=$y,serializeAttributes:a=zy,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(x=>{x in f&&(m[x]=f[x])}),m};return{parseMarkdown:(f,m)=>{const x={...i,...f.attributes};return m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const x=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(m=f.match(x))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(f,m,x){const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),N=f.match(b);if(!N)return;const w=N[1]||"",v=r(w);if(!o.find(M=>!(M in v)))return{type:e,raw:N[0],attributes:v}}},renderMarkdown:f=>{const m=h(f.attrs||{}),x=a(m),b=x?` {${x}}`:"";return`:::${u}${b} :::`}}}function Y_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=$y,serializeAttributes:i=zy,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const x={};return u.forEach(b=>{b in m&&(x[b]=m[b])}),x};return{parseMarkdown:(m,x)=>{let b;if(r){const w=r(m);b=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?b=x.parseChildren(m.tokens||[]):b=x.parseInline(m.tokens||[]);const N={...o,...m.attributes};return x.createNode(e,N,b)},markdownTokenizer:{name:e,level:"block",start(m){var x;const b=new RegExp(`^:::${h}`,"m"),N=(x=m.match(b))==null?void 0:x.index;return N!==void 0?N:-1},tokenize(m,x,b){var N;const w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=m.match(w);if(!v)return;const[k,M=""]=v,E=a(M);let L=1;const R=k.length;let W="";const P=/^:::([\w-]*)(\s.*)?/gm,B=m.slice(R);for(P.lastIndex=0;;){const O=P.exec(B);if(O===null)break;const X=O.index,ae=O[1];if(!((N=O[2])!=null&&N.endsWith(":::"))){if(ae)L+=1;else if(L-=1,L===0){const _=B.slice(0,X);W=_.trim();const se=m.slice(0,R+X+O[0].length);let ce=[];if(W)if(c==="block")for(ce=b.blockTokens(_),ce.forEach(me=>{me.text&&(!me.tokens||me.tokens.length===0)&&(me.tokens=b.inlineTokens(me.text))});ce.length>0;){const me=ce[ce.length-1];if(me.type==="paragraph"&&(!me.text||me.text.trim()===""))ce.pop();else break}else ce=b.inlineTokens(W);return{type:e,raw:se,attributes:E,content:W,tokens:ce}}}}}},renderMarkdown:(m,x)=>{const b=f(m.attrs||{}),N=i(b),w=N?` {${N}}`:"",v=x.renderChildren(m.content||[],` `);return`:::${h}${w} @@ -798,13 +798,13 @@ ${v} :::`}}}function X_(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 Z_(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function e3(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=X_,serializeAttributes:i=Z_,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=x=>{if(!u)return x;const b={};return u.forEach(N=>{const w=typeof N=="string"?N:N.name,v=typeof N=="string"?void 0:N.skipIfDefault;if(w in x){const k=x[w];if(v!==void 0&&k===v)return;b[w]=k}}),b},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(x,b)=>{const N={...o,...x.attributes};if(c)return b.createNode(e,N);const w=r?r(x):x.content||"";return w?b.createNode(e,N,[b.createTextNode(w)]):b.createNode(e,N,[])},markdownTokenizer:{name:e,level:"inline",start(x){const b=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),N=x.match(b),w=N==null?void 0:N.index;return w!==void 0?w:-1},tokenize(x,b,N){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),v=x.match(w);if(!v)return;let k="",M="";if(c){const[,L]=v;M=L}else{const[,L,R]=v;M=L,k=R||""}const E=a(M.trim());return{type:e,raw:v[0],content:k.trim(),attributes:E}}},renderMarkdown:x=>{let b="";r?b=r(x):x.content&&x.content.length>0&&(b=x.content.filter(k=>k.type==="text").map(k=>k.text).join(""));const N=f(x.attrs||{}),w=i(N),v=w?` ${w}`:"";return c?`[${h}${v}]`:`[${h}${v}]${b}[/${h}]`}}}function m0(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(x.trim()===""){f+=1,h=`${h}${x} `;continue}else return}const N=e.extractItemData(b),{indentLevel:w,mainContent:v}=N;h=`${h}${x} -`;const k=[v];for(f+=1;fY.trim()!=="");if(P===-1)break;if((((a=(r=c[f+1+P].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:a.length)||0)>w){k.push(R),h=`${h}${R} +`;const k=[v];for(f+=1;fX.trim()!=="");if(P===-1)break;if((((a=(r=c[f+1+P].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:a.length)||0)>w){k.push(R),h=`${h}${R} `,f+=1;continue}else break}if((((o=(i=R.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>w)k.push(R),h=`${h}${R} `,f+=1;else break}let M;const E=k.slice(1);if(E.length>0){const R=E.map(W=>W.slice(w+m)).join(` `);R.trim()&&(e.customNestedParser?M=e.customNestedParser(R):M=n.blockTokens(R))}const L=e.createToken(N,M);u.push(L)}if(u.length!==0)return{items:u,raw:h}}function Fy(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(x=>x?e.indent(x):"").join(` `);u.push(m)}}),u.join(` -`)}function e7(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(b=>{if(b!==o)return!1;m=b}),!m)return;let x=!1;if(Object.keys(n).forEach(b=>{n[b]!==m.attrs[b]&&(x=!0)}),x){const b=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,b)}}),i.docChanged&&e.view.dispatch(i)}var On=class t3 extends _y{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new t3(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function ql(t){return new O_({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:a})=>{const i=Kt(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),x=m+c.length;if(Dy(n.from,n.to,e.doc).filter(N=>N.mark.type.excluded.find(v=>v===t.type&&v!==N.mark.type)).filter(N=>N.to>m).length)return null;xn.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:t7,getOwnPropertySymbols:n7}=Object,{hasOwnProperty:s7}=Object.prototype;function ug(t,e){return function(r,a,i){return t(r,a,i)&&e(r,a,i)}}function nf(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 r7(t){return t!=null?t[Symbol.toStringTag]:void 0}function ww(t){return t7(t).concat(n7(t))}const a7=Object.hasOwn||((t,e)=>s7.call(t,e));function tc(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const i7="__v",o7="__o",l7="_owner",{getOwnPropertyDescriptor:jw,keys:kw}=Object;function c7(t,e){return t.byteLength===e.byteLength&&Wf(new Uint8Array(t),new Uint8Array(e))}function d7(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 u7(t,e){return t.byteLength===e.byteLength&&Wf(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function h7(t,e){return tc(t.getTime(),e.getTime())}function f7(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function p7(t,e){return t===e}function Sw(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 x=o.value,b=c.value;if(n.equals(x[0],b[0],u,m,t,e,n)&&n.equals(x[1],b[1],x[0],b[0],t,e,n)){f=a[m]=!0;break}m++}if(!f)return!1;u++}return!0}const m7=tc;function x7(t,e,n){const r=kw(t);let a=r.length;if(kw(e).length!==a)return!1;for(;a-- >0;)if(!n3(t,e,n,r[a]))return!1;return!0}function Yd(t,e,n){const r=ww(t);let a=r.length;if(ww(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=r[a],!n3(t,e,n,i)||(o=jw(t,i),c=jw(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function g7(t,e){return tc(t.valueOf(),e.valueOf())}function y7(t,e){return t.source===e.source&&t.flags===e.flags}function Cw(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 Wf(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 b7(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 n3(t,e,n,r){return(r===l7||r===o7||r===i7)&&(t.$$typeof||e.$$typeof)?!0:a7(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const v7="[object ArrayBuffer]",N7="[object Arguments]",w7="[object Boolean]",j7="[object DataView]",k7="[object Date]",S7="[object Error]",C7="[object Map]",E7="[object Number]",T7="[object Object]",M7="[object RegExp]",A7="[object Set]",P7="[object String]",I7={"[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},R7="[object URL]",L7=Object.prototype.toString;function O7({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:x,areUrlsEqual:b,unknownTagComparators:N}){return function(v,k,M){if(v===k)return!0;if(v==null||k==null)return!1;const E=typeof v;if(E!==typeof k)return!1;if(E!=="object")return E==="number"?c(v,k,M):E==="function"?i(v,k,M):!1;const L=v.constructor;if(L!==k.constructor)return!1;if(L===Object)return u(v,k,M);if(Array.isArray(v))return e(v,k,M);if(L===Date)return r(v,k,M);if(L===RegExp)return f(v,k,M);if(L===Map)return o(v,k,M);if(L===Set)return m(v,k,M);const R=L7.call(v);if(R===k7)return r(v,k,M);if(R===M7)return f(v,k,M);if(R===C7)return o(v,k,M);if(R===A7)return m(v,k,M);if(R===T7)return typeof v.then!="function"&&typeof k.then!="function"&&u(v,k,M);if(R===R7)return b(v,k,M);if(R===S7)return a(v,k,M);if(R===N7)return u(v,k,M);if(I7[R])return x(v,k,M);if(R===v7)return t(v,k,M);if(R===j7)return n(v,k,M);if(R===w7||R===E7||R===P7)return h(v,k,M);if(N){let W=N[R];if(!W){const P=r7(v);P&&(W=N[P])}if(W)return W(v,k,M)}return!1}}function D7({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:c7,areArraysEqual:n?Yd:d7,areDataViewsEqual:u7,areDatesEqual:h7,areErrorsEqual:f7,areFunctionsEqual:p7,areMapsEqual:n?ug(Sw,Yd):Sw,areNumbersEqual:m7,areObjectsEqual:n?Yd:x7,arePrimitiveWrappersEqual:g7,areRegExpsEqual:y7,areSetsEqual:n?ug(Cw,Yd):Cw,areTypedArraysEqual:n?ug(Wf,Yd):Wf,areUrlsEqual:b7,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const a=nf(r.areArraysEqual),i=nf(r.areMapsEqual),o=nf(r.areObjectsEqual),c=nf(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return r}function _7(t){return function(e,n,r,a,i,o,c){return t(e,n,c)}}function $7({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 z7=qo();qo({strict:!0});qo({circular:!0});qo({circular:!0,strict:!0});qo({createInternalComparator:()=>tc});qo({strict:!0,createInternalComparator:()=>tc});qo({circular:!0,createInternalComparator:()=>tc});qo({circular:!0,createInternalComparator:()=>tc,strict:!0});function qo(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:a=!1}=t,i=D7(t),o=O7(i),c=n?n(o):_7(o);return $7({circular:e,comparator:o,createState:r,equals:c,strict:a})}var hg={exports:{}},fg={};/** +`)}function e7(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(b=>{if(b!==o)return!1;m=b}),!m)return;let x=!1;if(Object.keys(n).forEach(b=>{n[b]!==m.attrs[b]&&(x=!0)}),x){const b=t.type.create({...t.attrs,...n});i.removeMark(h,f,t.type),i.addMark(h,f,b)}}),i.docChanged&&e.view.dispatch(i)}var On=class t3 extends _y{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new t3(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function ql(t){return new O_({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:a})=>{const i=Kt(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),x=m+c.length;if(Dy(n.from,n.to,e.doc).filter(N=>N.mark.type.excluded.find(v=>v===t.type&&v!==N.mark.type)).filter(N=>N.to>m).length)return null;xn.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:t7,getOwnPropertySymbols:n7}=Object,{hasOwnProperty:s7}=Object.prototype;function ug(t,e){return function(r,a,i){return t(r,a,i)&&e(r,a,i)}}function nf(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 r7(t){return t!=null?t[Symbol.toStringTag]:void 0}function ww(t){return t7(t).concat(n7(t))}const a7=Object.hasOwn||((t,e)=>s7.call(t,e));function tc(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const i7="__v",o7="__o",l7="_owner",{getOwnPropertyDescriptor:jw,keys:kw}=Object;function c7(t,e){return t.byteLength===e.byteLength&&Wf(new Uint8Array(t),new Uint8Array(e))}function d7(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 u7(t,e){return t.byteLength===e.byteLength&&Wf(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function h7(t,e){return tc(t.getTime(),e.getTime())}function f7(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function p7(t,e){return t===e}function Sw(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 x=o.value,b=c.value;if(n.equals(x[0],b[0],u,m,t,e,n)&&n.equals(x[1],b[1],x[0],b[0],t,e,n)){f=a[m]=!0;break}m++}if(!f)return!1;u++}return!0}const m7=tc;function x7(t,e,n){const r=kw(t);let a=r.length;if(kw(e).length!==a)return!1;for(;a-- >0;)if(!n3(t,e,n,r[a]))return!1;return!0}function Xd(t,e,n){const r=ww(t);let a=r.length;if(ww(e).length!==a)return!1;let i,o,c;for(;a-- >0;)if(i=r[a],!n3(t,e,n,i)||(o=jw(t,i),c=jw(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function g7(t,e){return tc(t.valueOf(),e.valueOf())}function y7(t,e){return t.source===e.source&&t.flags===e.flags}function Cw(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 Wf(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 b7(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 n3(t,e,n,r){return(r===l7||r===o7||r===i7)&&(t.$$typeof||e.$$typeof)?!0:a7(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const v7="[object ArrayBuffer]",N7="[object Arguments]",w7="[object Boolean]",j7="[object DataView]",k7="[object Date]",S7="[object Error]",C7="[object Map]",E7="[object Number]",T7="[object Object]",M7="[object RegExp]",A7="[object Set]",P7="[object String]",I7={"[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},R7="[object URL]",L7=Object.prototype.toString;function O7({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:x,areUrlsEqual:b,unknownTagComparators:N}){return function(v,k,M){if(v===k)return!0;if(v==null||k==null)return!1;const E=typeof v;if(E!==typeof k)return!1;if(E!=="object")return E==="number"?c(v,k,M):E==="function"?i(v,k,M):!1;const L=v.constructor;if(L!==k.constructor)return!1;if(L===Object)return u(v,k,M);if(Array.isArray(v))return e(v,k,M);if(L===Date)return r(v,k,M);if(L===RegExp)return f(v,k,M);if(L===Map)return o(v,k,M);if(L===Set)return m(v,k,M);const R=L7.call(v);if(R===k7)return r(v,k,M);if(R===M7)return f(v,k,M);if(R===C7)return o(v,k,M);if(R===A7)return m(v,k,M);if(R===T7)return typeof v.then!="function"&&typeof k.then!="function"&&u(v,k,M);if(R===R7)return b(v,k,M);if(R===S7)return a(v,k,M);if(R===N7)return u(v,k,M);if(I7[R])return x(v,k,M);if(R===v7)return t(v,k,M);if(R===j7)return n(v,k,M);if(R===w7||R===E7||R===P7)return h(v,k,M);if(N){let W=N[R];if(!W){const P=r7(v);P&&(W=N[P])}if(W)return W(v,k,M)}return!1}}function D7({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:c7,areArraysEqual:n?Xd:d7,areDataViewsEqual:u7,areDatesEqual:h7,areErrorsEqual:f7,areFunctionsEqual:p7,areMapsEqual:n?ug(Sw,Xd):Sw,areNumbersEqual:m7,areObjectsEqual:n?Xd:x7,arePrimitiveWrappersEqual:g7,areRegExpsEqual:y7,areSetsEqual:n?ug(Cw,Xd):Cw,areTypedArraysEqual:n?ug(Wf,Xd):Wf,areUrlsEqual:b7,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const a=nf(r.areArraysEqual),i=nf(r.areMapsEqual),o=nf(r.areObjectsEqual),c=nf(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return r}function _7(t){return function(e,n,r,a,i,o,c){return t(e,n,c)}}function $7({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 z7=qo();qo({strict:!0});qo({circular:!0});qo({circular:!0,strict:!0});qo({createInternalComparator:()=>tc});qo({strict:!0,createInternalComparator:()=>tc});qo({circular:!0,createInternalComparator:()=>tc});qo({circular:!0,createInternalComparator:()=>tc,strict:!0});function qo(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:a=!1}=t,i=D7(t),o=O7(i),c=n?n(o):_7(o);return $7({circular:e,comparator:o,createState:r,equals:c,strict:a})}var hg={exports:{}},fg={};/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -812,7 +812,7 @@ ${v} * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ew;function F7(){if(Ew)return fg;Ew=1;var t=Du(),e=W2();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 fg.useSyncExternalStoreWithSelector=function(h,f,m,x,b){var N=i(null);if(N.current===null){var w={hasValue:!1,value:null};N.current=w}else w=N.current;N=c(function(){function k(W){if(!M){if(M=!0,E=W,W=x(W),b!==void 0&&w.hasValue){var P=w.value;if(b(P,W))return L=P}return L=W}if(P=L,r(E,W))return P;var B=x(W);return b!==void 0&&b(P,B)?(E=W,P):(E=W,L=B)}var M=!1,E,L,R=m===void 0?null:m;return[function(){return k(f())},R===null?void 0:function(){return k(R())}]},[f,m,x,b]);var v=a(h,N[0],N[1]);return o(function(){w.hasValue=!0,w.value=v},[v]),u(v),v},fg}var Tw;function B7(){return Tw||(Tw=1,hg.exports=F7()),hg.exports}var V7=B7(),H7=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},U7=({contentComponent:t})=>{const e=K2.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function W7(){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]:Fj.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 K7=class extends Us.Component{constructor(t){var e;super(t),this.editorContentRef=Us.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=W7(),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:H7(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(U7,{contentComponent:t.contentComponent})]})}},q7=g.forwardRef((t,e)=>{const n=Us.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Us.createElement(K7,{key:n,innerRef:e,...t})}),s3=Us.memo(q7),G7=typeof window<"u"?g.useLayoutEffect:g.useEffect,J7=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 Q7(t){var e;const[n]=g.useState(()=>new J7(t.editor)),r=V7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:z7);return G7(()=>n.watch(t.editor),[t.editor,n]),g.useDebugValue(r),r}var Y7=!1,x0=typeof window>"u",X7=x0||!!(typeof window<"u"&&window.next),Z7=class r3{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?x0||X7?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 U_(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?r3.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 e$(t={},e=[]){const n=g.useRef(t);n.current=t;const[r]=g.useState(()=>new Z7(n)),a=K2.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return g.useDebugValue(a),g.useEffect(r.onRender(e)),Q7({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var a3=g.createContext({editor:null});a3.Consumer;var t$=g.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),n$=()=>g.useContext(t$);Us.forwardRef((t,e)=>{const{onDragStart:n}=n$(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Us.createContext({markViewContentRef:()=>{}});var By=g.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});By.displayName="TiptapContext";var s$=()=>g.useContext(By);function i3({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=g.useMemo(()=>({editor:r}),[r]),i=g.useMemo(()=>({editor:r}),[r]);return s.jsx(a3.Provider,{value:i,children:s.jsx(By.Provider,{value:a,children:n})})}i3.displayName="Tiptap";function o3({...t}){const{editor:e}=s$();return s.jsx(s3,{editor:e,...t})}o3.displayName="Tiptap.Content";Object.assign(i3,{Content:o3});var Kf=(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]},r$=/^\s*>\s$/,a$=On.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Kf("blockquote",{...Gt(this.options.HTMLAttributes,t),children:Kf("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(` + */var Ew;function F7(){if(Ew)return fg;Ew=1;var t=_u(),e=W2();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 fg.useSyncExternalStoreWithSelector=function(h,f,m,x,b){var N=i(null);if(N.current===null){var w={hasValue:!1,value:null};N.current=w}else w=N.current;N=c(function(){function k(W){if(!M){if(M=!0,E=W,W=x(W),b!==void 0&&w.hasValue){var P=w.value;if(b(P,W))return L=P}return L=W}if(P=L,r(E,W))return P;var B=x(W);return b!==void 0&&b(P,B)?(E=W,P):(E=W,L=B)}var M=!1,E,L,R=m===void 0?null:m;return[function(){return k(f())},R===null?void 0:function(){return k(R())}]},[f,m,x,b]);var v=a(h,N[0],N[1]);return o(function(){w.hasValue=!0,w.value=v},[v]),u(v),v},fg}var Tw;function B7(){return Tw||(Tw=1,hg.exports=F7()),hg.exports}var V7=B7(),H7=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},U7=({contentComponent:t})=>{const e=K2.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function W7(){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]:Fj.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 K7=class extends Us.Component{constructor(t){var e;super(t),this.editorContentRef=Us.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=W7(),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:H7(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(U7,{contentComponent:t.contentComponent})]})}},q7=g.forwardRef((t,e)=>{const n=Us.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Us.createElement(K7,{key:n,innerRef:e,...t})}),s3=Us.memo(q7),G7=typeof window<"u"?g.useLayoutEffect:g.useEffect,J7=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 Q7(t){var e;const[n]=g.useState(()=>new J7(t.editor)),r=V7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:z7);return G7(()=>n.watch(t.editor),[t.editor,n]),g.useDebugValue(r),r}var Y7=!1,x0=typeof window>"u",X7=x0||!!(typeof window<"u"&&window.next),Z7=class r3{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?x0||X7?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 U_(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?r3.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 e$(t={},e=[]){const n=g.useRef(t);n.current=t;const[r]=g.useState(()=>new Z7(n)),a=K2.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return g.useDebugValue(a),g.useEffect(r.onRender(e)),Q7({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var a3=g.createContext({editor:null});a3.Consumer;var t$=g.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),n$=()=>g.useContext(t$);Us.forwardRef((t,e)=>{const{onDragStart:n}=n$(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Us.createContext({markViewContentRef:()=>{}});var By=g.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});By.displayName="TiptapContext";var s$=()=>g.useContext(By);function i3({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=g.useMemo(()=>({editor:r}),[r]),i=g.useMemo(()=>({editor:r}),[r]);return s.jsx(a3.Provider,{value:i,children:s.jsx(By.Provider,{value:a,children:n})})}i3.displayName="Tiptap";function o3({...t}){const{editor:e}=s$();return s.jsx(s3,{editor:e,...t})}o3.displayName="Tiptap.Content";Object.assign(i3,{Content:o3});var Kf=(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]},r$=/^\s*>\s$/,a$=On.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Kf("blockquote",{...Gt(this.options.HTMLAttributes,t),children:Kf("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} @@ -832,17 +832,17 @@ ${n} `).map(b=>{var N;const w=((N=b.match(/^ */))==null?void 0:N[0])||"",v=Math.min(w.length,n);return b.slice(v)}).join(` `);return c.replaceWith(u,h,r.schema.text(x)),!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(ct.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[p0({find:p$,type:this.type,getAttributes:t=>({language:t[1]})}),p0({find:m$,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new an({key:new bn("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!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(ct.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[p0({find:p$,type:this.type,getAttributes:t=>({language:t[1]})}),p0({find:m$,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new on({key:new bn("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(st.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),g$=On.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):""}),y$=On.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",Gt(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(x=>c.includes(x.type.name));h.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),b$=On.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]}`,Gt(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=>p0({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),v$=On.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Gt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!q_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,a=t();return DC(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(st.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(nt.create(o.doc,u.pos)):o.setSelection(st.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(st.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ZC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),N$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,w$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,j$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,k$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,S$=ec.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",Gt(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[sd({find:N$,type:this.type}),sd({find:j$,type:this.type})]},addPasteRules(){return[ql({find:w$,type:this.type}),ql({find:k$,type:this.type})]}});const C$="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",E$="ελ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",g0="numeric",y0="ascii",b0="alpha",fu="asciinumeric",su="alphanumeric",v0="domain",l3="emoji",T$="scheme",M$="slashscheme",mg="whitespace";function A$(t,e){return t in e||(e[t]=[]),e[t]}function Il(t,e,n){e[g0]&&(e[fu]=!0,e[su]=!0),e[y0]&&(e[fu]=!0,e[b0]=!0),e[fu]&&(e[su]=!0),e[b0]&&(e[su]=!0),e[su]&&(e[v0]=!0),e[l3]&&(e[v0]=!0);for(const r in e){const a=A$(r,n);a.indexOf(t)<0&&a.push(t)}}function P$(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ir(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ir.groups={};ir.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),En=(t,e,n,r,a)=>t.tr(e,n,r,a),Mw=(t,e,n,r,a)=>t.ts(e,n,r,a),Ie=(t,e,n,r,a)=>t.tt(e,n,r,a),pi="WORD",N0="UWORD",c3="ASCIINUMERICAL",d3="ALPHANUMERICAL",Iu="LOCALHOST",w0="TLD",j0="UTLD",yf="SCHEME",Fc="SLASH_SCHEME",Vy="NUM",k0="WS",Hy="NL",pu="OPENBRACE",mu="CLOSEBRACE",qf="OPENBRACKET",Gf="CLOSEBRACKET",Jf="OPENPAREN",Qf="CLOSEPAREN",Yf="OPENANGLEBRACKET",Xf="CLOSEANGLEBRACKET",Zf="FULLWIDTHLEFTPAREN",ep="FULLWIDTHRIGHTPAREN",tp="LEFTCORNERBRACKET",np="RIGHTCORNERBRACKET",sp="LEFTWHITECORNERBRACKET",rp="RIGHTWHITECORNERBRACKET",ap="FULLWIDTHLESSTHAN",ip="FULLWIDTHGREATERTHAN",op="AMPERSAND",lp="APOSTROPHE",cp="ASTERISK",fo="AT",dp="BACKSLASH",up="BACKTICK",hp="CARET",xo="COLON",Uy="COMMA",fp="DOLLAR",Sa="DOT",pp="EQUALS",Wy="EXCLAMATION",Or="HYPHEN",xu="PERCENT",mp="PIPE",xp="PLUS",gp="POUND",gu="QUERY",Ky="QUOTE",u3="FULLWIDTHMIDDLEDOT",qy="SEMI",Ca="SLASH",yu="TILDE",yp="UNDERSCORE",h3="EMOJI",bp="SYM";var f3=Object.freeze({__proto__:null,ALPHANUMERICAL:d3,AMPERSAND:op,APOSTROPHE:lp,ASCIINUMERICAL:c3,ASTERISK:cp,AT:fo,BACKSLASH:dp,BACKTICK:up,CARET:hp,CLOSEANGLEBRACKET:Xf,CLOSEBRACE:mu,CLOSEBRACKET:Gf,CLOSEPAREN:Qf,COLON:xo,COMMA:Uy,DOLLAR:fp,DOT:Sa,EMOJI:h3,EQUALS:pp,EXCLAMATION:Wy,FULLWIDTHGREATERTHAN:ip,FULLWIDTHLEFTPAREN:Zf,FULLWIDTHLESSTHAN:ap,FULLWIDTHMIDDLEDOT:u3,FULLWIDTHRIGHTPAREN:ep,HYPHEN:Or,LEFTCORNERBRACKET:tp,LEFTWHITECORNERBRACKET:sp,LOCALHOST:Iu,NL:Hy,NUM:Vy,OPENANGLEBRACKET:Yf,OPENBRACE:pu,OPENBRACKET:qf,OPENPAREN:Jf,PERCENT:xu,PIPE:mp,PLUS:xp,POUND:gp,QUERY:gu,QUOTE:Ky,RIGHTCORNERBRACKET:np,RIGHTWHITECORNERBRACKET:rp,SCHEME:yf,SEMI:qy,SLASH:Ca,SLASH_SCHEME:Fc,SYM:bp,TILDE:yu,TLD:w0,UNDERSCORE:yp,UTLD:j0,UWORD:N0,WORD:pi,WS:k0});const hi=/[a-z]/,Xd=new RegExp("\\p{L}","u"),xg=new RegExp("\\p{Emoji}","u"),fi=/\d/,gg=/\s/,Aw="\r",yg=` -`,I$="️",R$="‍",bg="";let sf=null,rf=null;function L$(t=[]){const e={};ir.groups=e;const n=new ir;sf==null&&(sf=Pw(C$)),rf==null&&(rf=Pw(E$)),Ie(n,"'",lp),Ie(n,"{",pu),Ie(n,"}",mu),Ie(n,"[",qf),Ie(n,"]",Gf),Ie(n,"(",Jf),Ie(n,")",Qf),Ie(n,"<",Yf),Ie(n,">",Xf),Ie(n,"(",Zf),Ie(n,")",ep),Ie(n,"「",tp),Ie(n,"」",np),Ie(n,"『",sp),Ie(n,"』",rp),Ie(n,"<",ap),Ie(n,">",ip),Ie(n,"&",op),Ie(n,"*",cp),Ie(n,"@",fo),Ie(n,"`",up),Ie(n,"^",hp),Ie(n,":",xo),Ie(n,",",Uy),Ie(n,"$",fp),Ie(n,".",Sa),Ie(n,"=",pp),Ie(n,"!",Wy),Ie(n,"-",Or),Ie(n,"%",xu),Ie(n,"|",mp),Ie(n,"+",xp),Ie(n,"#",gp),Ie(n,"?",gu),Ie(n,'"',Ky),Ie(n,"/",Ca),Ie(n,";",qy),Ie(n,"~",yu),Ie(n,"_",yp),Ie(n,"\\",dp),Ie(n,"・",u3);const r=En(n,fi,Vy,{[g0]:!0});En(r,fi,r);const a=En(r,hi,c3,{[fu]:!0}),i=En(r,Xd,d3,{[su]:!0}),o=En(n,hi,pi,{[y0]:!0});En(o,fi,a),En(o,hi,o),En(a,fi,a),En(a,hi,a);const c=En(n,Xd,N0,{[b0]:!0});En(c,hi),En(c,fi,i),En(c,Xd,c),En(i,fi,i),En(i,hi),En(i,Xd,i);const u=Ie(n,yg,Hy,{[mg]:!0}),h=Ie(n,Aw,k0,{[mg]:!0}),f=En(n,gg,k0,{[mg]:!0});Ie(n,bg,f),Ie(h,yg,u),Ie(h,bg,f),En(h,gg,f),Ie(f,Aw),Ie(f,yg),En(f,gg,f),Ie(f,bg,f);const m=En(n,xg,h3,{[l3]:!0});Ie(m,"#"),En(m,xg,m),Ie(m,I$,m);const x=Ie(m,R$);Ie(x,"#"),En(x,xg,m);const b=[[hi,o],[fi,a]],N=[[hi,null],[Xd,c],[fi,i]];for(let w=0;ww[0]>v[0]?1:-1);for(let w=0;w=0?M[v0]=!0:hi.test(v)?fi.test(v)?M[fu]=!0:M[y0]=!0:M[g0]=!0,Mw(n,v,v,M)}return Mw(n,"localhost",Iu,{ascii:!0}),n.jd=new ir(bp),{start:n,tokens:Object.assign({groups:e},f3)}}function p3(t,e){const n=O$(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,a=[];let i=0,o=0;for(;o=0&&(m+=n[o].length,x++),h+=n[o].length,i+=n[o].length,o++;i-=m,o-=x,h-=m,a.push({t:f.t,v:e.slice(i-h,i),s:i-h,e:i})}return a}function O$(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 oo(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 Ru={defaultProtocol:"http",events:null,format:Iw,formatHref:Iw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Gy(t,e=null){let n=Object.assign({},Ru);t&&(n=Object.assign(n,t instanceof Gy?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=Ru.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 Qp(t,e){class n extends m3{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 Rw=Qp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Lw=Qp("text"),D$=Qp("nl"),af=Qp("url",{isLink:!0,toHref(t=Ru.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Iu&&t[1].t===xo}}),Lr=t=>new ir(t);function _$({groups:t}){const e=t.domain.concat([op,cp,fo,dp,up,hp,fp,pp,Or,Vy,xu,mp,xp,gp,Ca,bp,yu,yp]),n=[lp,xo,Uy,Sa,Wy,xu,gu,Ky,qy,Yf,Xf,pu,mu,Gf,qf,Jf,Qf,Zf,ep,tp,np,sp,rp,ap,ip],r=[op,lp,cp,dp,up,hp,fp,pp,Or,pu,mu,xu,mp,xp,gp,gu,Ca,bp,yu,yp],a=Lr(),i=Ie(a,yu);jt(i,r,i),jt(i,t.domain,i);const o=Lr(),c=Lr(),u=Lr();jt(a,t.domain,o),jt(a,t.scheme,c),jt(a,t.slashscheme,u),jt(o,r,i),jt(o,t.domain,o);const h=Ie(o,fo);Ie(i,fo,h),Ie(c,fo,h),Ie(u,fo,h);const f=Ie(i,Sa);jt(f,r,i),jt(f,t.domain,i);const m=Lr();jt(h,t.domain,m),jt(m,t.domain,m);const x=Ie(m,Sa);jt(x,t.domain,m);const b=Lr(Rw);jt(x,t.tld,b),jt(x,t.utld,b),Ie(h,Iu,b);const N=Ie(m,Or);Ie(N,Or,N),jt(N,t.domain,m),jt(b,t.domain,m),Ie(b,Sa,x),Ie(b,Or,N);const w=Ie(b,xo);jt(w,t.numeric,Rw);const v=Ie(o,Or),k=Ie(o,Sa);Ie(v,Or,v),jt(v,t.domain,o),jt(k,r,i),jt(k,t.domain,o);const M=Lr(af);jt(k,t.tld,M),jt(k,t.utld,M),jt(M,t.domain,o),jt(M,r,i),Ie(M,Sa,k),Ie(M,Or,v),Ie(M,fo,h);const E=Ie(M,xo),L=Lr(af);jt(E,t.numeric,L);const R=Lr(af),W=Lr();jt(R,e,R),jt(R,n,W),jt(W,e,R),jt(W,n,W),Ie(M,Ca,R),Ie(L,Ca,R);const P=Ie(c,xo),B=Ie(u,xo),O=Ie(B,Ca),Y=Ie(O,Ca);jt(c,t.domain,o),Ie(c,Sa,k),Ie(c,Or,v),jt(u,t.domain,o),Ie(u,Sa,k),Ie(u,Or,v),jt(P,t.domain,R),Ie(P,Ca,R),Ie(P,gu,R),jt(Y,t.domain,R),jt(Y,e,R),Ie(Y,Ca,R);const ae=[[pu,mu],[qf,Gf],[Jf,Qf],[Yf,Xf],[Zf,ep],[tp,np],[sp,rp],[ap,ip]];for(let _=0;_=0&&x++,a++,f++;if(x<0)a-=f,a0&&(i.push(vg(Lw,e,o)),o=[]),a-=x,f-=x;const b=m.t,N=n.slice(a-f,a);i.push(vg(b,e,N))}}return o.length>0&&i.push(vg(Lw,e,o)),i}function vg(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 z$=typeof console<"u"&&console&&console.warn||(()=>{}),F$="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",fn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function B$(){return ir.groups={},fn.scanner=null,fn.parser=null,fn.tokenQueue=[],fn.pluginQueue=[],fn.customSchemes=[],fn.initialized=!1,fn}function Ow(t,e=!1){if(fn.initialized&&z$(`linkifyjs: already initialized - will not register custom scheme "${t}" ${F$}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor: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(x=>c.includes(x.type.name));h.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),b$=On.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]}`,Gt(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=>p0({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),v$=On.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Gt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!q_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,a=t();return DC(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(st.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(nt.create(o.doc,u.pos)):o.setSelection(st.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(st.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ZC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),N$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,w$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,j$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,k$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,S$=ec.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",Gt(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[sd({find:N$,type:this.type}),sd({find:j$,type:this.type})]},addPasteRules(){return[ql({find:w$,type:this.type}),ql({find:k$,type:this.type})]}});const C$="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",E$="ελ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",g0="numeric",y0="ascii",b0="alpha",pu="asciinumeric",ru="alphanumeric",v0="domain",l3="emoji",T$="scheme",M$="slashscheme",mg="whitespace";function A$(t,e){return t in e||(e[t]=[]),e[t]}function Il(t,e,n){e[g0]&&(e[pu]=!0,e[ru]=!0),e[y0]&&(e[pu]=!0,e[b0]=!0),e[pu]&&(e[ru]=!0),e[b0]&&(e[ru]=!0),e[ru]&&(e[v0]=!0),e[l3]&&(e[v0]=!0);for(const r in e){const a=A$(r,n);a.indexOf(t)<0&&a.push(t)}}function P$(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ir(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ir.groups={};ir.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),En=(t,e,n,r,a)=>t.tr(e,n,r,a),Mw=(t,e,n,r,a)=>t.ts(e,n,r,a),Ie=(t,e,n,r,a)=>t.tt(e,n,r,a),pi="WORD",N0="UWORD",c3="ASCIINUMERICAL",d3="ALPHANUMERICAL",Ru="LOCALHOST",w0="TLD",j0="UTLD",yf="SCHEME",Fc="SLASH_SCHEME",Vy="NUM",k0="WS",Hy="NL",mu="OPENBRACE",xu="CLOSEBRACE",qf="OPENBRACKET",Gf="CLOSEBRACKET",Jf="OPENPAREN",Qf="CLOSEPAREN",Yf="OPENANGLEBRACKET",Xf="CLOSEANGLEBRACKET",Zf="FULLWIDTHLEFTPAREN",ep="FULLWIDTHRIGHTPAREN",tp="LEFTCORNERBRACKET",np="RIGHTCORNERBRACKET",sp="LEFTWHITECORNERBRACKET",rp="RIGHTWHITECORNERBRACKET",ap="FULLWIDTHLESSTHAN",ip="FULLWIDTHGREATERTHAN",op="AMPERSAND",lp="APOSTROPHE",cp="ASTERISK",ho="AT",dp="BACKSLASH",up="BACKTICK",hp="CARET",mo="COLON",Uy="COMMA",fp="DOLLAR",Sa="DOT",pp="EQUALS",Wy="EXCLAMATION",Or="HYPHEN",gu="PERCENT",mp="PIPE",xp="PLUS",gp="POUND",yu="QUERY",Ky="QUOTE",u3="FULLWIDTHMIDDLEDOT",qy="SEMI",Ca="SLASH",bu="TILDE",yp="UNDERSCORE",h3="EMOJI",bp="SYM";var f3=Object.freeze({__proto__:null,ALPHANUMERICAL:d3,AMPERSAND:op,APOSTROPHE:lp,ASCIINUMERICAL:c3,ASTERISK:cp,AT:ho,BACKSLASH:dp,BACKTICK:up,CARET:hp,CLOSEANGLEBRACKET:Xf,CLOSEBRACE:xu,CLOSEBRACKET:Gf,CLOSEPAREN:Qf,COLON:mo,COMMA:Uy,DOLLAR:fp,DOT:Sa,EMOJI:h3,EQUALS:pp,EXCLAMATION:Wy,FULLWIDTHGREATERTHAN:ip,FULLWIDTHLEFTPAREN:Zf,FULLWIDTHLESSTHAN:ap,FULLWIDTHMIDDLEDOT:u3,FULLWIDTHRIGHTPAREN:ep,HYPHEN:Or,LEFTCORNERBRACKET:tp,LEFTWHITECORNERBRACKET:sp,LOCALHOST:Ru,NL:Hy,NUM:Vy,OPENANGLEBRACKET:Yf,OPENBRACE:mu,OPENBRACKET:qf,OPENPAREN:Jf,PERCENT:gu,PIPE:mp,PLUS:xp,POUND:gp,QUERY:yu,QUOTE:Ky,RIGHTCORNERBRACKET:np,RIGHTWHITECORNERBRACKET:rp,SCHEME:yf,SEMI:qy,SLASH:Ca,SLASH_SCHEME:Fc,SYM:bp,TILDE:bu,TLD:w0,UNDERSCORE:yp,UTLD:j0,UWORD:N0,WORD:pi,WS:k0});const hi=/[a-z]/,Zd=new RegExp("\\p{L}","u"),xg=new RegExp("\\p{Emoji}","u"),fi=/\d/,gg=/\s/,Aw="\r",yg=` +`,I$="️",R$="‍",bg="";let sf=null,rf=null;function L$(t=[]){const e={};ir.groups=e;const n=new ir;sf==null&&(sf=Pw(C$)),rf==null&&(rf=Pw(E$)),Ie(n,"'",lp),Ie(n,"{",mu),Ie(n,"}",xu),Ie(n,"[",qf),Ie(n,"]",Gf),Ie(n,"(",Jf),Ie(n,")",Qf),Ie(n,"<",Yf),Ie(n,">",Xf),Ie(n,"(",Zf),Ie(n,")",ep),Ie(n,"「",tp),Ie(n,"」",np),Ie(n,"『",sp),Ie(n,"』",rp),Ie(n,"<",ap),Ie(n,">",ip),Ie(n,"&",op),Ie(n,"*",cp),Ie(n,"@",ho),Ie(n,"`",up),Ie(n,"^",hp),Ie(n,":",mo),Ie(n,",",Uy),Ie(n,"$",fp),Ie(n,".",Sa),Ie(n,"=",pp),Ie(n,"!",Wy),Ie(n,"-",Or),Ie(n,"%",gu),Ie(n,"|",mp),Ie(n,"+",xp),Ie(n,"#",gp),Ie(n,"?",yu),Ie(n,'"',Ky),Ie(n,"/",Ca),Ie(n,";",qy),Ie(n,"~",bu),Ie(n,"_",yp),Ie(n,"\\",dp),Ie(n,"・",u3);const r=En(n,fi,Vy,{[g0]:!0});En(r,fi,r);const a=En(r,hi,c3,{[pu]:!0}),i=En(r,Zd,d3,{[ru]:!0}),o=En(n,hi,pi,{[y0]:!0});En(o,fi,a),En(o,hi,o),En(a,fi,a),En(a,hi,a);const c=En(n,Zd,N0,{[b0]:!0});En(c,hi),En(c,fi,i),En(c,Zd,c),En(i,fi,i),En(i,hi),En(i,Zd,i);const u=Ie(n,yg,Hy,{[mg]:!0}),h=Ie(n,Aw,k0,{[mg]:!0}),f=En(n,gg,k0,{[mg]:!0});Ie(n,bg,f),Ie(h,yg,u),Ie(h,bg,f),En(h,gg,f),Ie(f,Aw),Ie(f,yg),En(f,gg,f),Ie(f,bg,f);const m=En(n,xg,h3,{[l3]:!0});Ie(m,"#"),En(m,xg,m),Ie(m,I$,m);const x=Ie(m,R$);Ie(x,"#"),En(x,xg,m);const b=[[hi,o],[fi,a]],N=[[hi,null],[Zd,c],[fi,i]];for(let w=0;ww[0]>v[0]?1:-1);for(let w=0;w=0?M[v0]=!0:hi.test(v)?fi.test(v)?M[pu]=!0:M[y0]=!0:M[g0]=!0,Mw(n,v,v,M)}return Mw(n,"localhost",Ru,{ascii:!0}),n.jd=new ir(bp),{start:n,tokens:Object.assign({groups:e},f3)}}function p3(t,e){const n=O$(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,a=[];let i=0,o=0;for(;o=0&&(m+=n[o].length,x++),h+=n[o].length,i+=n[o].length,o++;i-=m,o-=x,h-=m,a.push({t:f.t,v:e.slice(i-h,i),s:i-h,e:i})}return a}function O$(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 io(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 Lu={defaultProtocol:"http",events:null,format:Iw,formatHref:Iw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Gy(t,e=null){let n=Object.assign({},Lu);t&&(n=Object.assign(n,t instanceof Gy?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=Lu.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 Qp(t,e){class n extends m3{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 Rw=Qp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Lw=Qp("text"),D$=Qp("nl"),af=Qp("url",{isLink:!0,toHref(t=Lu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ru&&t[1].t===mo}}),Lr=t=>new ir(t);function _$({groups:t}){const e=t.domain.concat([op,cp,ho,dp,up,hp,fp,pp,Or,Vy,gu,mp,xp,gp,Ca,bp,bu,yp]),n=[lp,mo,Uy,Sa,Wy,gu,yu,Ky,qy,Yf,Xf,mu,xu,Gf,qf,Jf,Qf,Zf,ep,tp,np,sp,rp,ap,ip],r=[op,lp,cp,dp,up,hp,fp,pp,Or,mu,xu,gu,mp,xp,gp,yu,Ca,bp,bu,yp],a=Lr(),i=Ie(a,bu);kt(i,r,i),kt(i,t.domain,i);const o=Lr(),c=Lr(),u=Lr();kt(a,t.domain,o),kt(a,t.scheme,c),kt(a,t.slashscheme,u),kt(o,r,i),kt(o,t.domain,o);const h=Ie(o,ho);Ie(i,ho,h),Ie(c,ho,h),Ie(u,ho,h);const f=Ie(i,Sa);kt(f,r,i),kt(f,t.domain,i);const m=Lr();kt(h,t.domain,m),kt(m,t.domain,m);const x=Ie(m,Sa);kt(x,t.domain,m);const b=Lr(Rw);kt(x,t.tld,b),kt(x,t.utld,b),Ie(h,Ru,b);const N=Ie(m,Or);Ie(N,Or,N),kt(N,t.domain,m),kt(b,t.domain,m),Ie(b,Sa,x),Ie(b,Or,N);const w=Ie(b,mo);kt(w,t.numeric,Rw);const v=Ie(o,Or),k=Ie(o,Sa);Ie(v,Or,v),kt(v,t.domain,o),kt(k,r,i),kt(k,t.domain,o);const M=Lr(af);kt(k,t.tld,M),kt(k,t.utld,M),kt(M,t.domain,o),kt(M,r,i),Ie(M,Sa,k),Ie(M,Or,v),Ie(M,ho,h);const E=Ie(M,mo),L=Lr(af);kt(E,t.numeric,L);const R=Lr(af),W=Lr();kt(R,e,R),kt(R,n,W),kt(W,e,R),kt(W,n,W),Ie(M,Ca,R),Ie(L,Ca,R);const P=Ie(c,mo),B=Ie(u,mo),O=Ie(B,Ca),X=Ie(O,Ca);kt(c,t.domain,o),Ie(c,Sa,k),Ie(c,Or,v),kt(u,t.domain,o),Ie(u,Sa,k),Ie(u,Or,v),kt(P,t.domain,R),Ie(P,Ca,R),Ie(P,yu,R),kt(X,t.domain,R),kt(X,e,R),Ie(X,Ca,R);const ae=[[mu,xu],[qf,Gf],[Jf,Qf],[Yf,Xf],[Zf,ep],[tp,np],[sp,rp],[ap,ip]];for(let _=0;_=0&&x++,a++,f++;if(x<0)a-=f,a0&&(i.push(vg(Lw,e,o)),o=[]),a-=x,f-=x;const b=m.t,N=n.slice(a-f,a);i.push(vg(b,e,N))}}return o.length>0&&i.push(vg(Lw,e,o)),i}function vg(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 z$=typeof console<"u"&&console&&console.warn||(()=>{}),F$="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",fn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function B$(){return ir.groups={},fn.scanner=null,fn.parser=null,fn.tokenQueue=[],fn.pluginQueue=[],fn.customSchemes=[],fn.initialized=!1,fn}function Ow(t,e=!1){if(fn.initialized&&z$(`linkifyjs: already initialized - will not register custom scheme "${t}" ${F$}`),!/^[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`);fn.customSchemes.push([t,e])}function V$(){fn.scanner=L$(fn.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=EC(n.doc,[...e]);if(OC(c).forEach(({newRange:h})=>{const f=KD(r.doc,h,b=>b.isTextblock);let m,x;if(f.length>1)m=f[0],x=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const b=r.doc.textBetween(h.from,h.to," "," ");if(!U$.test(b))return;m=f[0],x=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&x){const b=x.split(H$).filter(Boolean);if(b.length<=0)return!1;const N=b[b.length-1],w=m.pos+x.lastIndexOf(N);if(!N)return!1;const v=Jy(N).map(k=>k.toObject(t.defaultProtocol));if(!K$(v))return!1;v.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=>{Dy(k.from,k.to,r.doc).some(M=>M.mark.type===t.type)||o.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!o.steps.length)return o}})}function G$(t){return new an({key:new bn("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=LC(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 J$(t){return new an({key:new bn("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=x3(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 El(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(W$,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Q$=ec.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"){Ow(t);return}Ow(t.scheme,t.optionalSlashes)})},onDestroy(){B$()},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)=>!!El(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=>!!El(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=>!!El(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Gt(this.options.HTMLAttributes,t),0]:["a",Gt(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=>!!El(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=>!!El(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[ql({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,a=x3(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!El(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(q$({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:a=>!!El(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(G$({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(J$({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Y$=Object.defineProperty,X$=(t,e)=>{for(var n in e)Y$(t,n,{get:e[n],enumerable:!0})},Z$="listItem",Dw="textStyle",_w=/^\s*([-+*])\s$/,g3=On.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",Gt(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(Z$,this.editor.getAttributes(Dw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=rd({find:_w,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=rd({find:_w,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Dw),editor:this.editor})),[t]}}),y3=On.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Gt(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)=>Fy(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)}}}),ez={};X$(ez,{findListItemPos:()=>Hu,getNextListDepth:()=>Yy,handleBackspace:()=>S0,handleDelete:()=>C0,hasListBefore:()=>b3,hasListItemAfter:()=>tz,hasListItemBefore:()=>v3,listItemHasSubList:()=>N3,nextListIsDeeper:()=>w3,nextListIsHigher:()=>j3});var Hu=(t,e)=>{const{$from:n}=e.selection,r=Un(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}},Yy=(t,e)=>{const n=Hu(t,e);if(!n)return!1;const[,r]=n_(e,t,n.$pos.pos+4);return r},b3=(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))},v3=(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)},N3=(t,e,n)=>{if(!n)return!1;const r=Un(t,e.schema);let a=!1;return n.descendants(i=>{i.type===r&&(a=!0)}),a},S0=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!$o(t.state,e)&&b3(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),h=[];u.node().descendants((x,b)=>{x.type.name===e&&h.push({node:x,pos:b})});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(!$o(t.state,e)||!i_(t.state))return!1;const r=Hu(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=N3(e,t.state,i);return v3(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},w3=(t,e)=>{const n=Yy(t,e),r=Hu(t,e);return!r||!n?!1:n>r.depth},j3=(t,e)=>{const n=Yy(t,e),r=Hu(t,e);return!r||!n?!1:n{if(!$o(t.state,e)||!a_(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:a}=n;return!n.empty&&r.sameParent(a)?!1:w3(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():j3(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},tz=(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)},k3=In.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&&C0(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&&C0(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&&S0(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&&S0(t,n,r)&&(e=!0)}),e}}}}),$w=/^(\s*)(\d+)\.\s+(.*)$/,nz=/^\s/;function sz(t){const e=[];let n=0,r=0;for(;n{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=EC(n.doc,[...e]);if(OC(c).forEach(({newRange:h})=>{const f=KD(r.doc,h,b=>b.isTextblock);let m,x;if(f.length>1)m=f[0],x=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const b=r.doc.textBetween(h.from,h.to," "," ");if(!U$.test(b))return;m=f[0],x=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&x){const b=x.split(H$).filter(Boolean);if(b.length<=0)return!1;const N=b[b.length-1],w=m.pos+x.lastIndexOf(N);if(!N)return!1;const v=Jy(N).map(k=>k.toObject(t.defaultProtocol));if(!K$(v))return!1;v.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=>{Dy(k.from,k.to,r.doc).some(M=>M.mark.type===t.type)||o.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!o.steps.length)return o}})}function G$(t){return new on({key:new bn("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=LC(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 J$(t){return new on({key:new bn("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=x3(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 El(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(W$,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Q$=ec.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"){Ow(t);return}Ow(t.scheme,t.optionalSlashes)})},onDestroy(){B$()},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)=>!!El(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=>!!El(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=>!!El(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Gt(this.options.HTMLAttributes,t),0]:["a",Gt(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=>!!El(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=>!!El(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[ql({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,a=x3(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!El(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(q$({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:a=>!!El(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(G$({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(J$({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Y$=Object.defineProperty,X$=(t,e)=>{for(var n in e)Y$(t,n,{get:e[n],enumerable:!0})},Z$="listItem",Dw="textStyle",_w=/^\s*([-+*])\s$/,g3=On.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",Gt(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(Z$,this.editor.getAttributes(Dw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=rd({find:_w,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=rd({find:_w,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Dw),editor:this.editor})),[t]}}),y3=On.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Gt(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)=>Fy(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)}}}),ez={};X$(ez,{findListItemPos:()=>Uu,getNextListDepth:()=>Yy,handleBackspace:()=>S0,handleDelete:()=>C0,hasListBefore:()=>b3,hasListItemAfter:()=>tz,hasListItemBefore:()=>v3,listItemHasSubList:()=>N3,nextListIsDeeper:()=>w3,nextListIsHigher:()=>j3});var Uu=(t,e)=>{const{$from:n}=e.selection,r=Un(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}},Yy=(t,e)=>{const n=Uu(t,e);if(!n)return!1;const[,r]=n_(e,t,n.$pos.pos+4);return r},b3=(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))},v3=(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)},N3=(t,e,n)=>{if(!n)return!1;const r=Un(t,e.schema);let a=!1;return n.descendants(i=>{i.type===r&&(a=!0)}),a},S0=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!$o(t.state,e)&&b3(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),h=[];u.node().descendants((x,b)=>{x.type.name===e&&h.push({node:x,pos:b})});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(!$o(t.state,e)||!i_(t.state))return!1;const r=Uu(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=N3(e,t.state,i);return v3(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},w3=(t,e)=>{const n=Yy(t,e),r=Uu(t,e);return!r||!n?!1:n>r.depth},j3=(t,e)=>{const n=Yy(t,e),r=Uu(t,e);return!r||!n?!1:n{if(!$o(t.state,e)||!a_(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:a}=n;return!n.empty&&r.sameParent(a)?!1:w3(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():j3(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},tz=(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)},k3=In.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&&C0(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&&C0(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&&S0(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&&S0(t,n,r)&&(e=!0)}),e}}}}),$w=/^(\s*)(\d+)\.\s+(.*)$/,nz=/^\s/;function sz(t){const e=[];let n=0,r=0;for(;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 az="listItem",zw="textStyle",Fw=/^(\d+)\.\s$/,C3=On.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",Gt(this.options.HTMLAttributes,n),0]:["ol",Gt(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?rz(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]=sz(a);if(i.length===0)return;const c=S3(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(az,this.editor.getAttributes(zw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=rd({find:Fw,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=rd({find:Fw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(zw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),iz=/^\s*(\[([( |x])?\])\s$/,oz=On.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",Gt(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 Fy(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 x,b;c.ariaLabel=((b=(x=this.options.a11y)==null?void 0:x.checkboxLabel)==null?void 0:b.call(x,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:x}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:b})=>{const N=n();if(typeof N!="number")return!1;const w=b.doc.nodeAt(N);return b.setNodeMarkup(N,void 0,{...w==null?void 0:w.attrs,checked:x}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,x)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,x])=>{a.setAttribute(m,x)}),a.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,o),a.append(i,u),Object.entries(e).forEach(([m,x])=>{a.setAttribute(m,x)});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 x=r.extensionManager.attributes,b=Pu(m,x),N=new Set(Object.keys(b)),w=this.options.HTMLAttributes;return f.forEach(v=>{N.has(v)||(v in w?a.setAttribute(v,w[v]):a.removeAttribute(v))}),Object.entries(b).forEach(([v,k])=>{k==null?v in w?a.setAttribute(v,w[v]):a.removeAttribute(v):a.setAttribute(v,k)}),f=N,!0}}}},addInputRules(){return[rd({find:iz,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),lz=On.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",Gt(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=m0(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=m0(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()}}});In.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(g3.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(y3.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(k3.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(C3.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(oz.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(lz.configure(this.options.taskList)),t}});var Bw=" ",cz=" ",dz=On.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Gt(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===Bw||r[0].text===cz)?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?Bw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),uz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,hz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,fz=ec.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",Gt(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[sd({find:uz,type:this.type})]},addPasteRules(){return[ql({find:hz,type:this.type})]}}),pz=On.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),mz=ec.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",Gt(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 xz(t={}){return new an({view(e){return new gz(e,t)}})}class gz{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,x=e.nodeAfter;if(m||x){let b=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(b){let N=b.getBoundingClientRect(),w=m?N.bottom:N.top;m&&x&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*c;r={left:N.left,right:N.right,top:w-v,bottom:w+v}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),x=this.width/2*o;r={left:m.left-x,right:m.left+x,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(),x=m.width/u.offsetWidth,b=m.height/u.offsetHeight;h=m.left-u.scrollLeft*x,f=m.top-u.scrollTop*b}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=bS(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 An extends ct{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return An.valid(r)?new An(r):ct.near(r)}content(){return Fe.empty}eq(e){return e instanceof An&&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 An(e.resolve(n.pos))}getBookmark(){return new Xy(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!yz(e)||!bz(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&&An.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(An.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!nt.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(An.valid(c))return c}return null}}}An.prototype.visible=!1;An.findFrom=An.findGapCursorFrom;ct.jsonID("gapcursor",An);class Xy{constructor(e){this.pos=e}map(e){return new Xy(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return An.valid(n)?new An(n):ct.near(n)}}function E3(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function yz(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||E3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function bz(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||E3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function vz(){return new an({props:{decorations:kz,createSelectionBetween(t,e,n){return e.pos==n.pos&&An.valid(n)?new An(n):null},handleClick:wz,handleKeyDown:Nz,handleDOMEvents:{beforeinput:jz}}})}const Nz=Ay({ArrowLeft:of("horiz",-1),ArrowRight:of("horiz",1),ArrowUp:of("vert",-1),ArrowDown:of("vert",1)});function of(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 st){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=An.findGapCursorFrom(c,e,u);return h?(a&&a(r.tr.setSelection(new An(h))),!0):!1}}function wz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!An.valid(r))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&nt.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new An(r))),!0)}function jz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof An))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=Se.empty;for(let o=r.length-1;o>=0;o--)a=Se.from(r[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new Fe(a,0,0));return i.setSelection(st.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function kz(t){if(!(t.selection instanceof An))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",tn.create(t.doc,[Yn.widget(t.selection.head,e,{key:"gapcursor"})])}var vp=200,fs=function(){};fs.prototype.append=function(e){return e.length?(e=fs.from(e),!this.length&&e||e.length=n?fs.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};fs.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};fs.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)};fs.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};fs.from=function(e){return e instanceof fs?e:e&&e.length?new T3(e):fs.empty};var T3=(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<=vp)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=vp)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})(fs);fs.empty=new T3([]);var Sz=(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})(fs);const Cz=500;class sa{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,x)=>{if(!m.step){a||(a=this.remapping(r,x+1),i=a.maps.length),i--,f.push(m);return}if(a){f.push(new lo(m.map));let b=m.step.map(a.slice(i)),N;b&&o.maybeStep(b).doc&&(N=o.mapping.maps[o.mapping.maps.length-1],h.push(new lo(N,void 0,void 0,h.length+f.length))),i--,N&&a.appendMap(N,i)}else o.maybeStep(m.step);if(m.selection)return c=a?m.selection.map(a.slice(i)):m.selection,u=new sa(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;fTz&&(c=Ez(c,h),o-=h),new sa(c.append(i),o)}remapping(e,n){let r=new Su;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 sa(this.items.append(e.map(n=>new lo(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(x=>{x.selection&&c--},a);let u=n;this.items.forEach(x=>{let b=i.getMirror(--u);if(b==null)return;o=Math.min(o,b);let N=i.maps[b];if(x.step){let w=e.steps[b].invert(e.docs[b]),v=x.selection&&x.selection.map(i.slice(u+1,b));v&&c++,r.push(new lo(N,w,v))}else r.push(new lo(N))},a);let h=[];for(let x=n;xCz&&(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 lo(h.invert(),u,f),x,b=a.length-1;(x=a.length&&a[b].merge(m))?a[b]=x:a.push(m)}}else o.map&&r--},this.items.length,0),new sa(fs.from(a.reverse()),i)}}sa.empty=new sa(fs.empty,0);function Ez(t,e){let n;return t.forEach((r,a)=>{if(r.selection&&e--==0)return n=a,!1}),t.slice(n)}let lo=class M3{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 M3(n.getMap().invert(),n,this.selection)}}};class po{constructor(e,n,r,a,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=a,this.prevComposition=i}}const Tz=20;function Mz(t,e,n,r){let a=n.getMeta(_l),i;if(a)return a.historyState;n.getMeta(Iz)&&(t=new po(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(_l))return o.getMeta(_l).redo?new po(t.done.addTransform(n,void 0,r,bf(e)),t.undone,Vw(n.mapping.maps),t.prevTime,t.prevComposition):new po(t.done,t.undone.addTransform(n,void 0,r,bf(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||!Az(n,t.prevRanges)),h=o?Ng(t.prevRanges,n.mapping):Vw(n.mapping.maps);return new po(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,bf(e)),sa.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new po(t.done.rebased(n,i),t.undone.rebased(n,i),Ng(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new po(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ng(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Az(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 Vw(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 Ng(t,e){if(!t)return null;let n=[];for(let r=0;r{let a=_l.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(r){let i=Pz(a,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const P3=A3(!1,!0),I3=A3(!0,!0);In.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 an({key:new bn("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 Lz=In.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[xz(this.options)]}});In.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new an({key:new bn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:a}=e,i=[];if(!n||!r)return tn.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(Yn.node(h,h+u.nodeSize,{class:this.options.className}))}),tn.create(t,i)}}})]}});var Oz=In.create({name:"gapCursor",addProseMirrorPlugins(){return[vz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Kt(et(t,"allowGapCursor",n)))!=null?e:null}}}),Uw="placeholder";function Dz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var _z=In.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Uw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Dz(this.options.dataAttribute)}`:`data-${Uw}`;return[new an({key:new bn("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&&qp(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const x=Yn.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(x)}return this.options.includeChildren}),tn.create(e,i)}}})]}});In.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new an({key:new bn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||DC(n.selection)||t.view.dragging?null:tn.create(n.doc,[Yn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Ww({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var $z=In.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new bn(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 an({key:e,appendTransaction:(a,i,o)=>{const{doc:c,tr:u,schema:h}=o,f=e.getState(o),m=c.content.size,x=h.nodes[n];if(f)return u.insert(m,x.create())},state:{init:(a,i)=>{const o=i.tr.doc.lastChild;return!Ww({node:o,types:r})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!Ww({node:o,types:r})}}})]}}),zz=In.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>P3(t,e),redo:()=>({state:t,dispatch:e})=>I3(t,e)}},addProseMirrorPlugins(){return[Rz(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()}}}),Fz=In.create({name:"starterKit",addExtensions(){var t,e,n,r;const a=[];return this.options.bold!==!1&&a.push(d$.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(a$.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(g3.configure(this.options.bulletList)),this.options.code!==!1&&a.push(f$.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(x$.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(g$.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(Lz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Oz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(y$.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(b$.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(zz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(v$.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(S$.configure(this.options.italic)),this.options.listItem!==!1&&a.push(y3.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(k3.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(Q$.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(C3.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(dz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(fz.configure(this.options.strike)),this.options.text!==!1&&a.push(pz.configure(this.options.text)),this.options.underline!==!1&&a.push(mz.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push($z.configure((r=this.options)==null?void 0:r.trailingNode)),a}}),Bz=Fz,Vz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Hz=On.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",Gt(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,x])=>{if(x!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,x);break}}),u.src=o.src;const h=new K_({element:u,editor:c,node:a,getPos:i,onResize:(m,x)=>{u.style.width=`${m}px`,u.style.height=`${x}px`},onCommit:(m,x)=>{const b=i();b!==void 0&&this.editor.chain().setNodeSelection(b).updateAttributes(this.name,{width:m,height:x}).run()},onUpdate:(m,x,b)=>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[ZC({find:Vz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Uz=Hz;function Wz(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=r&&!a,h=G_(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",x=a?"":h,b=u?new RegExp(`${m}${h}.*?(?=\\s${x}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${x}]*`,"gm"),N=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!N)return null;const w=c.pos-N.length,v=Array.from(N.matchAll(b)).pop();if(!v||v.input===void 0||v.index===void 0)return null;const k=v.input.slice(Math.max(0,v.index-1),v.index),M=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!M)return null;const E=w+v.index;let L=E+v[0].length;return u&&f.test(N.slice(L-1,L+1))&&(v[0]+=" ",L+=1),E=c.pos?{range:{from:E,to:L},query:v[0].slice(n.length),text:v[0]}:null}var Kz=new bn("suggestion");function qz({pluginKey:t=Kz,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:x=()=>[],render:b=()=>({}),allow:N=()=>!0,findSuggestionMatch:w=Wz,shouldShow:v}){let k;const M=b==null?void 0:b(),E=()=>{const P=e.state.selection.$anchor.pos,B=e.view.coordsAtPos(P),{top:O,right:Y,bottom:ae,left:_}=B;try{return new DOMRect(_,O,Y-_,ae-O)}catch{return null}},L=(P,B)=>B?()=>{const O=t.getState(e.state),Y=O==null?void 0:O.decorationId,ae=P.dom.querySelector(`[data-decoration-id="${Y}"]`);return(ae==null?void 0:ae.getBoundingClientRect())||null}:E;function R(P,B){var O;try{const ae=t.getState(P.state),_=ae!=null&&ae.decorationId?P.dom.querySelector(`[data-decoration-id="${ae.decorationId}"]`):null,se={editor:e,range:(ae==null?void 0:ae.range)||{from:0,to:0},query:(ae==null?void 0:ae.query)||null,text:(ae==null?void 0:ae.text)||null,items:[],command:ce=>m({editor:e,range:(ae==null?void 0:ae.range)||{from:0,to:0},props:ce}),decorationNode:_,clientRect:L(P,_)};(O=M==null?void 0:M.onExit)==null||O.call(M,se)}catch{}const Y=P.state.tr.setMeta(B,{exit:!0});P.dispatch(Y)}const W=new an({key:t,view(){return{update:async(P,B)=>{var O,Y,ae,_,se,ce,me;const I=(O=this.key)==null?void 0:O.getState(B),X=(Y=this.key)==null?void 0:Y.getState(P.state),V=I.active&&X.active&&I.range.from!==X.range.from,xe=!I.active&&X.active,ee=I.active&&!X.active,H=!xe&&!ee&&I.query!==X.query,K=xe||V&&H,fe=H||V,he=ee||V&&H;if(!K&&!fe&&!he)return;const ue=he&&!K?I:X,$=P.dom.querySelector(`[data-decoration-id="${ue.decorationId}"]`);k={editor:e,range:ue.range,query:ue.query,text:ue.text,items:[],command:Q=>m({editor:e,range:ue.range,props:Q}),decorationNode:$,clientRect:L(P,$)},K&&((ae=M==null?void 0:M.onBeforeStart)==null||ae.call(M,k)),fe&&((_=M==null?void 0:M.onBeforeUpdate)==null||_.call(M,k)),(fe||K)&&(k.items=await x({editor:e,query:ue.query})),he&&((se=M==null?void 0:M.onExit)==null||se.call(M,k)),fe&&((ce=M==null?void 0:M.onUpdate)==null||ce.call(M,k)),K&&((me=M==null?void 0:M.onStart)==null||me.call(M,k))},destroy:()=>{var P;k&&((P=M==null?void 0:M.onExit)==null||P.call(M,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(P,B,O,Y){const{isEditable:ae}=e,{composing:_}=e.view,{selection:se}=P,{empty:ce,from:me}=se,I={...B},X=P.getMeta(t);if(X&&X.exit)return I.active=!1,I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null,I;if(I.composing=_,ae&&(ce||e.view.composing)){(meB.range.to)&&!_&&!B.composing&&(I.active=!1);const V=w({char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:se.$from}),xe=`id_${Math.floor(Math.random()*4294967295)}`;V&&N({editor:e,state:Y,range:V.range,isActive:B.active})&&(!v||v({editor:e,range:V.range,query:V.query,text:V.text,transaction:P}))?(I.active=!0,I.decorationId=B.decorationId?B.decorationId:xe,I.range=V.range,I.query=V.query,I.text=V.text):I.active=!1}else I.active=!1;return I.active||(I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null),I}},props:{handleKeyDown(P,B){var O,Y,ae,_;const{active:se,range:ce}=W.getState(P.state);if(!se)return!1;if(B.key==="Escape"||B.key==="Esc"){const I=W.getState(P.state),X=(O=k==null?void 0:k.decorationNode)!=null?O:null,V=X??(I!=null&&I.decorationId?P.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null);if(((Y=M==null?void 0:M.onKeyDown)==null?void 0:Y.call(M,{view:P,event:B,range:I.range}))||!1)return!0;const ee={editor:e,range:I.range,query:I.query,text:I.text,items:[],command:H=>m({editor:e,range:I.range,props:H}),decorationNode:V,clientRect:V?()=>V.getBoundingClientRect()||null:null};return(ae=M==null?void 0:M.onExit)==null||ae.call(M,ee),R(P,t),!0}return((_=M==null?void 0:M.onKeyDown)==null?void 0:_.call(M,{view:P,event:B,range:ce}))||!1},decorations(P){const{active:B,range:O,decorationId:Y,query:ae}=W.getState(P);if(!B)return null;const _=!(ae!=null&&ae.length),se=[u];return _&&se.push(f),tn.create(P.doc,[Yn.inline(O.from,O.to,{nodeName:c,class:se.join(" "),"data-decoration-id":Y,"data-decoration-content":h})])}}});return W}function Gz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const a=new bn;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 R3(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Gz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function Kw(t,e){const n=R3(t),r=n.find(a=>a.char===e);return r||(n.length?n[0]:null)}var Jz=On.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",Gt(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=Kw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Gt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Gt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof a=="string"?["span",Gt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...e3({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:Kw(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 Ci,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 R3(this).map(qz)}}),Qz=Jz,Yz=_z;let E0,T0;if(typeof WeakMap<"u"){let t=new WeakMap;E0=e=>t.get(e),T0=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;E0=r=>{for(let a=0;a(n==10&&(n=0),t[n++]=r,t[n++]=a)}var Pn=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 L=a+E*e;for(let R=0;Rr&&(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 eF(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 nF(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 ca(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 Yp(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=Gl(e.$head)||sF(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function sF(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 M0(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function rF(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Zy(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function L3(t,e,n){const r=t.node(-1),a=Pn.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 Jl(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 O3(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 x=i+f+1;return new kS(c.resolve(x),c.resolve(x+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(M0(r)&&M0(a)&&Zy(r,a)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?mi.rowSelection(r,a):i&&this.isColSelection()?mi.colSelection(r,a):new mi(r,a)}return st.between(r,a)}content(){const e=this.$anchorCell.node(-1),n=Pn.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||v>0){let k=N.attrs;if(w>0&&(k=Jl(k,0,w)),v>0&&(k=Jl(k,k.colspan-v,v)),b.lefta.bottom){const k={...N.attrs,rowspan:Math.min(b.bottom,a.bottom)-Math.max(b.top,a.top)};b.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=Pn.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 mi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),a=Pn.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(Yn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),tn.create(t.doc,e)}function lF({$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 cF({$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 dF(t,e,n){const r=(e||t).selection,a=(e||t).doc;let i,o;if(r instanceof nt&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=rn.create(a,r.from);else if(o=="row"){const c=a.resolve(r.from+1);i=rn.rowSelection(c,c)}else if(!n){const c=Pn.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];i=rn.create(a,u+1,h)}}else r instanceof st&&lF(r)?i=st.create(a,r.from):r instanceof st&&cF(r)&&(i=st.create(a,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const uF=new bn("fix-tables");function _3(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=hF(t,a,i,n))};return e?e.doc!=t.doc&&_3(e.doc,t.doc,0,r):t.doc.descendants(r),n}function hF(t,e,n,r){const a=Pn.get(e);if(!a.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const N=[];for(let v=0;v0?-1:0;aF(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;gF(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 x=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...x,rowspan:x.rowspan-1}),h+=x.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=qw(h)?u+1:f;i.replaceWith(m+r.tableStart,f+r.tableStart,c)}i.setSelection(new rn(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function Jw(t,e){const n=Os(t.schema);return jF(({node:r})=>n[r.type.spec.tableRole])(t,e)}function jF(t){return(e,n)=>{const r=e.selection;let a,i;if(r instanceof rn){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;a=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(a=nF(r.$from),!a)return!1;i=(o=Gl(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=$a(e),m=e.tr;for(let b=0;b{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 SF(t){return function(e,n){if(!ca(e))return!1;if(n){const r=Os(e.schema),a=$a(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 b=x+i.tableStart,N=o.doc.nodeAt(b);N&&o.setNodeMarkup(b,m,N.attrs)}),r(o)}return!0}}Lu("row",{useDeprecatedLogic:!0});Lu("column",{useDeprecatedLogic:!0});const CF=Lu("cell",{useDeprecatedLogic:!0});function EF(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 lf(t,e){const n=t.selection;if(!(n instanceof rn))return!1;if(e){const r=t.tr,a=Os(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 Fe(a,0,0))}),r.docChanged&&e(r)}return!0}function MF(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(Se.empty),n[a]r&&(x=x.type.createChecked(Jl(x.attrs,x.attrs.colspan,f+x.attrs.colspan-r),x.content)),h.push(x),f+=x.attrs.colspan;for(let b=1;ba&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,a-m.attrs.rowspan)},m.content)),u.push(m)}i.push(Se.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function IF(t,e,n,r,a,i,o){const c=t.doc.type.schema,u=Os(c);let h,f;if(a>e.width)for(let m=0,x=0;me.height){const m=[];for(let N=0,w=(e.height-1)*e.width;N=e.width?!1:n.nodeAt(e.map[w+N]).type==u.header_cell;m.push(v?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const x=u.row.create(null,Se.from(m)),b=[];for(let N=e.height;N{if(!a)return!1;const i=n.selection;if(i instanceof rn)return vf(n,r,ct.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=B3(a,t,e);if(o==null)return!1;if(t=="horiz")return vf(n,r,ct.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=L3(c,t,e);let h;return u?h=ct.near(u,1):e<0?h=ct.near(n.doc.resolve(c.before(-1)),-1):h=ct.near(n.doc.resolve(c.after(-1)),1),vf(n,r,h)}}}function df(t,e){return(n,r,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof rn)o=i;else{const u=B3(a,t,e);if(u==null)return!1;o=new rn(n.doc.resolve(u))}const c=L3(o.$headCell,t,e);return c?vf(n,r,new rn(o.$anchorCell,c)):!1}}function LF(t,e){const n=t.state.doc,r=Gl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new rn(r))),!0):!1}function OF(t,e,n){if(!ca(t.state))return!1;let r=MF(n);const a=t.state.selection;if(a instanceof rn){r||(r={width:1,height:1,rows:[Se.from(A0(Os(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=Pn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return r=PF(r,c.right-c.left,c.bottom-c.top),ej(t.state,t.dispatch,o,c,r),!0}else if(r){const i=Yp(t.state),o=i.start(-1);return ej(t.state,t.dispatch,o,Pn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function DF(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=tj(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof rn)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(a=Gl(t.state.selection.$anchor))!=null&&((n=jg(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=jg(t,h);const m=go.getState(t.state)==null;if(!f||!Zy(u,f))if(m)f=u;else return;const x=new rn(u,f);if(m||!t.state.selection.eq(x)){const b=t.state.tr.setSelection(x);m&&b.setMeta(go,u.pos),t.dispatch(b)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),go.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(go,-1))}function c(u){const h=u,f=go.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(tj(t,h.target)!=r&&(m=jg(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 B3(t,e,n){if(!(t.state.selection instanceof st))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 tj(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function jg(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&&Gl(t.state.doc.resolve(r))||Gl(t.state.doc.resolve(a))}var _F=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")),P0(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,P0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function P0(t,e,n,r,a,i){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,x=0;mnew r(m,n,x)),new zF(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=yr.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{FF(o,c,t,a)},mouseleave:o=>{BF(o)},mousedown:(o,c)=>{VF(o,c,e,n)}},decorations:o=>{const c=yr.getState(o);if(c&&c.activeHandle>-1)return qF(o,c.activeHandle)},nodeViews:{}}});return i}var zF=class Nf{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(yr);if(r&&r.setHandle!=null)return new Nf(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Nf(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return M0(e.doc.resolve(a))||(a=-1),new Nf(a,n.dragging)}return n}};function FF(t,e,n,r){if(!t.editable)return;const a=yr.getState(t.state);if(a&&!a.dragging){const i=UF(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=nj(t,e,"left",n):u-e.clientX<=n&&(o=nj(t,e,"right",n))}if(o!=a.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=Pn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}V3(t,o)}}}function BF(t){if(!t.editable)return;const e=yr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&V3(t,-1)}function VF(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=yr.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=HF(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(yr,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const x=yr.getState(t.state);x!=null&&x.dragging&&(WF(t,x.activeHandle,sj(x.dragging,m,n)),t.dispatch(t.state.tr.setMeta(yr,{setDragging:null})))}function f(m){if(!m.which)return h(m);const x=yr.getState(t.state);if(x&&x.dragging){const b=sj(x.dragging,m,n);rj(t,x.activeHandle,b,r)}}return rj(t,o.activeHandle,u,r),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function HF(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",Gt(this.options.HTMLAttributes,t),0]}}),U3=On.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",Gt(this.options.HTMLAttributes,t),0]}}),W3=On.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Gt(this.options.HTMLAttributes,t),0]}});function I0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function aj(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 x=0,b=0;x{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function XF(t,e,n,r,a){const i=YF(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!ZF(e))return!1;let n=0;const r=TC(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},eB="";function tB(t){return(t||"").replace(/\s+/g," ").trim()}function nB(t,e,n={}){var r;const a=(r=n.cellLineSeparator)!=null?r:eB;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(N=>{const w=[];N.content&&N.content.forEach(v=>{let k="";v.content&&Array.isArray(v.content)&&v.content.length>1?k=v.content.map(R=>e.renderChildren(R)).join(a):k=v.content?e.renderChildren(v.content):"";const M=tB(k),E=v.type==="tableHeader";w.push({text:M,isHeader:E})}),i.push(w)});const o=i.reduce((N,w)=>Math.max(N,w.length),0);if(o===0)return"";const c=new Array(o).fill(0);i.forEach(N=>{var w;for(let v=0;vc[v]&&(c[v]=M),c[v]<3&&(c[v]=3)}});const u=(N,w)=>N+" ".repeat(Math.max(0,w-N.length)),h=i[0],f=h.some(N=>N.isHeader);let m=` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(az,this.editor.getAttributes(zw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=rd({find:Fw,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=rd({find:Fw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(zw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),iz=/^\s*(\[([( |x])?\])\s$/,oz=On.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",Gt(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 Fy(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 x,b;c.ariaLabel=((b=(x=this.options.a11y)==null?void 0:x.checkboxLabel)==null?void 0:b.call(x,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:x}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:b})=>{const N=n();if(typeof N!="number")return!1;const w=b.doc.nodeAt(N);return b.setNodeMarkup(N,void 0,{...w==null?void 0:w.attrs,checked:x}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,x)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,x])=>{a.setAttribute(m,x)}),a.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,o),a.append(i,u),Object.entries(e).forEach(([m,x])=>{a.setAttribute(m,x)});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 x=r.extensionManager.attributes,b=Iu(m,x),N=new Set(Object.keys(b)),w=this.options.HTMLAttributes;return f.forEach(v=>{N.has(v)||(v in w?a.setAttribute(v,w[v]):a.removeAttribute(v))}),Object.entries(b).forEach(([v,k])=>{k==null?v in w?a.setAttribute(v,w[v]):a.removeAttribute(v):a.setAttribute(v,k)}),f=N,!0}}}},addInputRules(){return[rd({find:iz,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),lz=On.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",Gt(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=m0(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=m0(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()}}});In.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(g3.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(y3.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(k3.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(C3.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(oz.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(lz.configure(this.options.taskList)),t}});var Bw=" ",cz=" ",dz=On.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Gt(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===Bw||r[0].text===cz)?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?Bw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),uz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,hz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,fz=ec.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",Gt(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[sd({find:uz,type:this.type})]},addPasteRules(){return[ql({find:hz,type:this.type})]}}),pz=On.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),mz=ec.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",Gt(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 xz(t={}){return new on({view(e){return new gz(e,t)}})}class gz{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,x=e.nodeAfter;if(m||x){let b=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(b){let N=b.getBoundingClientRect(),w=m?N.bottom:N.top;m&&x&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*c;r={left:N.left,right:N.right,top:w-v,bottom:w+v}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),x=this.width/2*o;r={left:m.left-x,right:m.left+x,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(),x=m.width/u.offsetWidth,b=m.height/u.offsetHeight;h=m.left-u.scrollLeft*x,f=m.top-u.scrollTop*b}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=bS(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 An extends ct{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return An.valid(r)?new An(r):ct.near(r)}content(){return Fe.empty}eq(e){return e instanceof An&&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 An(e.resolve(n.pos))}getBookmark(){return new Xy(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!yz(e)||!bz(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&&An.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(An.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!nt.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(An.valid(c))return c}return null}}}An.prototype.visible=!1;An.findFrom=An.findGapCursorFrom;ct.jsonID("gapcursor",An);class Xy{constructor(e){this.pos=e}map(e){return new Xy(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return An.valid(n)?new An(n):ct.near(n)}}function E3(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function yz(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||E3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function bz(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||E3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function vz(){return new on({props:{decorations:kz,createSelectionBetween(t,e,n){return e.pos==n.pos&&An.valid(n)?new An(n):null},handleClick:wz,handleKeyDown:Nz,handleDOMEvents:{beforeinput:jz}}})}const Nz=Ay({ArrowLeft:of("horiz",-1),ArrowRight:of("horiz",1),ArrowUp:of("vert",-1),ArrowDown:of("vert",1)});function of(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 st){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=An.findGapCursorFrom(c,e,u);return h?(a&&a(r.tr.setSelection(new An(h))),!0):!1}}function wz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!An.valid(r))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&nt.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new An(r))),!0)}function jz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof An))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=Ce.empty;for(let o=r.length-1;o>=0;o--)a=Ce.from(r[o].createAndFill(null,a));let i=t.state.tr.replace(n.pos,n.pos,new Fe(a,0,0));return i.setSelection(st.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function kz(t){if(!(t.selection instanceof An))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",nn.create(t.doc,[Yn.widget(t.selection.head,e,{key:"gapcursor"})])}var vp=200,fs=function(){};fs.prototype.append=function(e){return e.length?(e=fs.from(e),!this.length&&e||e.length=n?fs.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};fs.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};fs.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)};fs.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};fs.from=function(e){return e instanceof fs?e:e&&e.length?new T3(e):fs.empty};var T3=(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<=vp)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=vp)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})(fs);fs.empty=new T3([]);var Sz=(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})(fs);const Cz=500;class sa{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,x)=>{if(!m.step){a||(a=this.remapping(r,x+1),i=a.maps.length),i--,f.push(m);return}if(a){f.push(new oo(m.map));let b=m.step.map(a.slice(i)),N;b&&o.maybeStep(b).doc&&(N=o.mapping.maps[o.mapping.maps.length-1],h.push(new oo(N,void 0,void 0,h.length+f.length))),i--,N&&a.appendMap(N,i)}else o.maybeStep(m.step);if(m.selection)return c=a?m.selection.map(a.slice(i)):m.selection,u=new sa(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;fTz&&(c=Ez(c,h),o-=h),new sa(c.append(i),o)}remapping(e,n){let r=new Cu;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 sa(this.items.append(e.map(n=>new oo(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(x=>{x.selection&&c--},a);let u=n;this.items.forEach(x=>{let b=i.getMirror(--u);if(b==null)return;o=Math.min(o,b);let N=i.maps[b];if(x.step){let w=e.steps[b].invert(e.docs[b]),v=x.selection&&x.selection.map(i.slice(u+1,b));v&&c++,r.push(new oo(N,w,v))}else r.push(new oo(N))},a);let h=[];for(let x=n;xCz&&(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 oo(h.invert(),u,f),x,b=a.length-1;(x=a.length&&a[b].merge(m))?a[b]=x:a.push(m)}}else o.map&&r--},this.items.length,0),new sa(fs.from(a.reverse()),i)}}sa.empty=new sa(fs.empty,0);function Ez(t,e){let n;return t.forEach((r,a)=>{if(r.selection&&e--==0)return n=a,!1}),t.slice(n)}let oo=class M3{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 M3(n.getMap().invert(),n,this.selection)}}};class fo{constructor(e,n,r,a,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=a,this.prevComposition=i}}const Tz=20;function Mz(t,e,n,r){let a=n.getMeta(_l),i;if(a)return a.historyState;n.getMeta(Iz)&&(t=new fo(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(_l))return o.getMeta(_l).redo?new fo(t.done.addTransform(n,void 0,r,bf(e)),t.undone,Vw(n.mapping.maps),t.prevTime,t.prevComposition):new fo(t.done,t.undone.addTransform(n,void 0,r,bf(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||!Az(n,t.prevRanges)),h=o?Ng(t.prevRanges,n.mapping):Vw(n.mapping.maps);return new fo(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,bf(e)),sa.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new fo(t.done.rebased(n,i),t.undone.rebased(n,i),Ng(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new fo(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ng(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Az(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 Vw(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 Ng(t,e){if(!t)return null;let n=[];for(let r=0;r{let a=_l.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(r){let i=Pz(a,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const P3=A3(!1,!0),I3=A3(!0,!0);In.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 on({key:new bn("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 Lz=In.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[xz(this.options)]}});In.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new on({key:new bn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:a}=e,i=[];if(!n||!r)return nn.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(Yn.node(h,h+u.nodeSize,{class:this.options.className}))}),nn.create(t,i)}}})]}});var Oz=In.create({name:"gapCursor",addProseMirrorPlugins(){return[vz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Kt(et(t,"allowGapCursor",n)))!=null?e:null}}}),Uw="placeholder";function Dz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var _z=In.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Uw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Dz(this.options.dataAttribute)}`:`data-${Uw}`;return[new on({key:new bn("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&&qp(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const x=Yn.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(x)}return this.options.includeChildren}),nn.create(e,i)}}})]}});In.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new on({key:new bn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||DC(n.selection)||t.view.dragging?null:nn.create(n.doc,[Yn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Ww({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var $z=In.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new bn(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 on({key:e,appendTransaction:(a,i,o)=>{const{doc:c,tr:u,schema:h}=o,f=e.getState(o),m=c.content.size,x=h.nodes[n];if(f)return u.insert(m,x.create())},state:{init:(a,i)=>{const o=i.tr.doc.lastChild;return!Ww({node:o,types:r})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!Ww({node:o,types:r})}}})]}}),zz=In.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>P3(t,e),redo:()=>({state:t,dispatch:e})=>I3(t,e)}},addProseMirrorPlugins(){return[Rz(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()}}}),Fz=In.create({name:"starterKit",addExtensions(){var t,e,n,r;const a=[];return this.options.bold!==!1&&a.push(d$.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(a$.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(g3.configure(this.options.bulletList)),this.options.code!==!1&&a.push(f$.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(x$.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(g$.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(Lz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Oz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(y$.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(b$.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(zz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(v$.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(S$.configure(this.options.italic)),this.options.listItem!==!1&&a.push(y3.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(k3.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(Q$.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(C3.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(dz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(fz.configure(this.options.strike)),this.options.text!==!1&&a.push(pz.configure(this.options.text)),this.options.underline!==!1&&a.push(mz.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push($z.configure((r=this.options)==null?void 0:r.trailingNode)),a}}),Bz=Fz,Vz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Hz=On.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",Gt(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,x])=>{if(x!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,x);break}}),u.src=o.src;const h=new K_({element:u,editor:c,node:a,getPos:i,onResize:(m,x)=>{u.style.width=`${m}px`,u.style.height=`${x}px`},onCommit:(m,x)=>{const b=i();b!==void 0&&this.editor.chain().setNodeSelection(b).updateAttributes(this.name,{width:m,height:x}).run()},onUpdate:(m,x,b)=>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[ZC({find:Vz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Uz=Hz;function Wz(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=r&&!a,h=G_(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",x=a?"":h,b=u?new RegExp(`${m}${h}.*?(?=\\s${x}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${x}]*`,"gm"),N=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!N)return null;const w=c.pos-N.length,v=Array.from(N.matchAll(b)).pop();if(!v||v.input===void 0||v.index===void 0)return null;const k=v.input.slice(Math.max(0,v.index-1),v.index),M=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!M)return null;const E=w+v.index;let L=E+v[0].length;return u&&f.test(N.slice(L-1,L+1))&&(v[0]+=" ",L+=1),E=c.pos?{range:{from:E,to:L},query:v[0].slice(n.length),text:v[0]}:null}var Kz=new bn("suggestion");function qz({pluginKey:t=Kz,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:x=()=>[],render:b=()=>({}),allow:N=()=>!0,findSuggestionMatch:w=Wz,shouldShow:v}){let k;const M=b==null?void 0:b(),E=()=>{const P=e.state.selection.$anchor.pos,B=e.view.coordsAtPos(P),{top:O,right:X,bottom:ae,left:_}=B;try{return new DOMRect(_,O,X-_,ae-O)}catch{return null}},L=(P,B)=>B?()=>{const O=t.getState(e.state),X=O==null?void 0:O.decorationId,ae=P.dom.querySelector(`[data-decoration-id="${X}"]`);return(ae==null?void 0:ae.getBoundingClientRect())||null}:E;function R(P,B){var O;try{const ae=t.getState(P.state),_=ae!=null&&ae.decorationId?P.dom.querySelector(`[data-decoration-id="${ae.decorationId}"]`):null,se={editor:e,range:(ae==null?void 0:ae.range)||{from:0,to:0},query:(ae==null?void 0:ae.query)||null,text:(ae==null?void 0:ae.text)||null,items:[],command:ce=>m({editor:e,range:(ae==null?void 0:ae.range)||{from:0,to:0},props:ce}),decorationNode:_,clientRect:L(P,_)};(O=M==null?void 0:M.onExit)==null||O.call(M,se)}catch{}const X=P.state.tr.setMeta(B,{exit:!0});P.dispatch(X)}const W=new on({key:t,view(){return{update:async(P,B)=>{var O,X,ae,_,se,ce,me;const I=(O=this.key)==null?void 0:O.getState(B),Z=(X=this.key)==null?void 0:X.getState(P.state),V=I.active&&Z.active&&I.range.from!==Z.range.from,xe=!I.active&&Z.active,ee=I.active&&!Z.active,H=!xe&&!ee&&I.query!==Z.query,K=xe||V&&H,fe=H||V,he=ee||V&&H;if(!K&&!fe&&!he)return;const ue=he&&!K?I:Z,$=P.dom.querySelector(`[data-decoration-id="${ue.decorationId}"]`);k={editor:e,range:ue.range,query:ue.query,text:ue.text,items:[],command:Q=>m({editor:e,range:ue.range,props:Q}),decorationNode:$,clientRect:L(P,$)},K&&((ae=M==null?void 0:M.onBeforeStart)==null||ae.call(M,k)),fe&&((_=M==null?void 0:M.onBeforeUpdate)==null||_.call(M,k)),(fe||K)&&(k.items=await x({editor:e,query:ue.query})),he&&((se=M==null?void 0:M.onExit)==null||se.call(M,k)),fe&&((ce=M==null?void 0:M.onUpdate)==null||ce.call(M,k)),K&&((me=M==null?void 0:M.onStart)==null||me.call(M,k))},destroy:()=>{var P;k&&((P=M==null?void 0:M.onExit)==null||P.call(M,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(P,B,O,X){const{isEditable:ae}=e,{composing:_}=e.view,{selection:se}=P,{empty:ce,from:me}=se,I={...B},Z=P.getMeta(t);if(Z&&Z.exit)return I.active=!1,I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null,I;if(I.composing=_,ae&&(ce||e.view.composing)){(meB.range.to)&&!_&&!B.composing&&(I.active=!1);const V=w({char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:se.$from}),xe=`id_${Math.floor(Math.random()*4294967295)}`;V&&N({editor:e,state:X,range:V.range,isActive:B.active})&&(!v||v({editor:e,range:V.range,query:V.query,text:V.text,transaction:P}))?(I.active=!0,I.decorationId=B.decorationId?B.decorationId:xe,I.range=V.range,I.query=V.query,I.text=V.text):I.active=!1}else I.active=!1;return I.active||(I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null),I}},props:{handleKeyDown(P,B){var O,X,ae,_;const{active:se,range:ce}=W.getState(P.state);if(!se)return!1;if(B.key==="Escape"||B.key==="Esc"){const I=W.getState(P.state),Z=(O=k==null?void 0:k.decorationNode)!=null?O:null,V=Z??(I!=null&&I.decorationId?P.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null);if(((X=M==null?void 0:M.onKeyDown)==null?void 0:X.call(M,{view:P,event:B,range:I.range}))||!1)return!0;const ee={editor:e,range:I.range,query:I.query,text:I.text,items:[],command:H=>m({editor:e,range:I.range,props:H}),decorationNode:V,clientRect:V?()=>V.getBoundingClientRect()||null:null};return(ae=M==null?void 0:M.onExit)==null||ae.call(M,ee),R(P,t),!0}return((_=M==null?void 0:M.onKeyDown)==null?void 0:_.call(M,{view:P,event:B,range:ce}))||!1},decorations(P){const{active:B,range:O,decorationId:X,query:ae}=W.getState(P);if(!B)return null;const _=!(ae!=null&&ae.length),se=[u];return _&&se.push(f),nn.create(P.doc,[Yn.inline(O.from,O.to,{nodeName:c,class:se.join(" "),"data-decoration-id":X,"data-decoration-content":h})])}}});return W}function Gz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const a=new bn;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 R3(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Gz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function Kw(t,e){const n=R3(t),r=n.find(a=>a.char===e);return r||(n.length?n[0]:null)}var Jz=On.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",Gt(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=Kw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Gt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Gt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof a=="string"?["span",Gt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...e3({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:Kw(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 Si,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 R3(this).map(qz)}}),Qz=Jz,Yz=_z;let E0,T0;if(typeof WeakMap<"u"){let t=new WeakMap;E0=e=>t.get(e),T0=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;E0=r=>{for(let a=0;a(n==10&&(n=0),t[n++]=r,t[n++]=a)}var Pn=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 L=a+E*e;for(let R=0;Rr&&(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 eF(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 nF(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 ca(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 Yp(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=Gl(e.$head)||sF(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function sF(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 M0(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function rF(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Zy(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function L3(t,e,n){const r=t.node(-1),a=Pn.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 Jl(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 O3(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 x=i+f+1;return new kS(c.resolve(x),c.resolve(x+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(M0(r)&&M0(a)&&Zy(r,a)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?mi.rowSelection(r,a):i&&this.isColSelection()?mi.colSelection(r,a):new mi(r,a)}return st.between(r,a)}content(){const e=this.$anchorCell.node(-1),n=Pn.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||v>0){let k=N.attrs;if(w>0&&(k=Jl(k,0,w)),v>0&&(k=Jl(k,k.colspan-v,v)),b.lefta.bottom){const k={...N.attrs,rowspan:Math.min(b.bottom,a.bottom)-Math.max(b.top,a.top)};b.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=Pn.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 mi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),a=Pn.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(Yn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),nn.create(t.doc,e)}function lF({$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 cF({$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 dF(t,e,n){const r=(e||t).selection,a=(e||t).doc;let i,o;if(r instanceof nt&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=an.create(a,r.from);else if(o=="row"){const c=a.resolve(r.from+1);i=an.rowSelection(c,c)}else if(!n){const c=Pn.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];i=an.create(a,u+1,h)}}else r instanceof st&&lF(r)?i=st.create(a,r.from):r instanceof st&&cF(r)&&(i=st.create(a,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const uF=new bn("fix-tables");function _3(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=hF(t,a,i,n))};return e?e.doc!=t.doc&&_3(e.doc,t.doc,0,r):t.doc.descendants(r),n}function hF(t,e,n,r){const a=Pn.get(e);if(!a.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const N=[];for(let v=0;v0?-1:0;aF(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;gF(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 x=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...x,rowspan:x.rowspan-1}),h+=x.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=qw(h)?u+1:f;i.replaceWith(m+r.tableStart,f+r.tableStart,c)}i.setSelection(new an(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function Jw(t,e){const n=Os(t.schema);return jF(({node:r})=>n[r.type.spec.tableRole])(t,e)}function jF(t){return(e,n)=>{const r=e.selection;let a,i;if(r instanceof an){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;a=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(a=nF(r.$from),!a)return!1;i=(o=Gl(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=$a(e),m=e.tr;for(let b=0;b{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 SF(t){return function(e,n){if(!ca(e))return!1;if(n){const r=Os(e.schema),a=$a(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 b=x+i.tableStart,N=o.doc.nodeAt(b);N&&o.setNodeMarkup(b,m,N.attrs)}),r(o)}return!0}}Ou("row",{useDeprecatedLogic:!0});Ou("column",{useDeprecatedLogic:!0});const CF=Ou("cell",{useDeprecatedLogic:!0});function EF(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 lf(t,e){const n=t.selection;if(!(n instanceof an))return!1;if(e){const r=t.tr,a=Os(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 Fe(a,0,0))}),r.docChanged&&e(r)}return!0}function MF(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(Ce.empty),n[a]r&&(x=x.type.createChecked(Jl(x.attrs,x.attrs.colspan,f+x.attrs.colspan-r),x.content)),h.push(x),f+=x.attrs.colspan;for(let b=1;ba&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,a-m.attrs.rowspan)},m.content)),u.push(m)}i.push(Ce.from(u))}n=i,e=a}return{width:t,height:e,rows:n}}function IF(t,e,n,r,a,i,o){const c=t.doc.type.schema,u=Os(c);let h,f;if(a>e.width)for(let m=0,x=0;me.height){const m=[];for(let N=0,w=(e.height-1)*e.width;N=e.width?!1:n.nodeAt(e.map[w+N]).type==u.header_cell;m.push(v?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const x=u.row.create(null,Ce.from(m)),b=[];for(let N=e.height;N{if(!a)return!1;const i=n.selection;if(i instanceof an)return vf(n,r,ct.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=B3(a,t,e);if(o==null)return!1;if(t=="horiz")return vf(n,r,ct.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=L3(c,t,e);let h;return u?h=ct.near(u,1):e<0?h=ct.near(n.doc.resolve(c.before(-1)),-1):h=ct.near(n.doc.resolve(c.after(-1)),1),vf(n,r,h)}}}function df(t,e){return(n,r,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof an)o=i;else{const u=B3(a,t,e);if(u==null)return!1;o=new an(n.doc.resolve(u))}const c=L3(o.$headCell,t,e);return c?vf(n,r,new an(o.$anchorCell,c)):!1}}function LF(t,e){const n=t.state.doc,r=Gl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new an(r))),!0):!1}function OF(t,e,n){if(!ca(t.state))return!1;let r=MF(n);const a=t.state.selection;if(a instanceof an){r||(r={width:1,height:1,rows:[Ce.from(A0(Os(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=Pn.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return r=PF(r,c.right-c.left,c.bottom-c.top),ej(t.state,t.dispatch,o,c,r),!0}else if(r){const i=Yp(t.state),o=i.start(-1);return ej(t.state,t.dispatch,o,Pn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function DF(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=tj(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof an)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(a=Gl(t.state.selection.$anchor))!=null&&((n=jg(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=jg(t,h);const m=xo.getState(t.state)==null;if(!f||!Zy(u,f))if(m)f=u;else return;const x=new an(u,f);if(m||!t.state.selection.eq(x)){const b=t.state.tr.setSelection(x);m&&b.setMeta(xo,u.pos),t.dispatch(b)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),xo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(xo,-1))}function c(u){const h=u,f=xo.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(tj(t,h.target)!=r&&(m=jg(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 B3(t,e,n){if(!(t.state.selection instanceof st))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 tj(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function jg(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&&Gl(t.state.doc.resolve(r))||Gl(t.state.doc.resolve(a))}var _F=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")),P0(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,P0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function P0(t,e,n,r,a,i){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,x=0;mnew r(m,n,x)),new zF(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=yr.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{FF(o,c,t,a)},mouseleave:o=>{BF(o)},mousedown:(o,c)=>{VF(o,c,e,n)}},decorations:o=>{const c=yr.getState(o);if(c&&c.activeHandle>-1)return qF(o,c.activeHandle)},nodeViews:{}}});return i}var zF=class Nf{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(yr);if(r&&r.setHandle!=null)return new Nf(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Nf(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return M0(e.doc.resolve(a))||(a=-1),new Nf(a,n.dragging)}return n}};function FF(t,e,n,r){if(!t.editable)return;const a=yr.getState(t.state);if(a&&!a.dragging){const i=UF(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=nj(t,e,"left",n):u-e.clientX<=n&&(o=nj(t,e,"right",n))}if(o!=a.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=Pn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}V3(t,o)}}}function BF(t){if(!t.editable)return;const e=yr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&V3(t,-1)}function VF(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=yr.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=HF(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(yr,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const x=yr.getState(t.state);x!=null&&x.dragging&&(WF(t,x.activeHandle,sj(x.dragging,m,n)),t.dispatch(t.state.tr.setMeta(yr,{setDragging:null})))}function f(m){if(!m.which)return h(m);const x=yr.getState(t.state);if(x&&x.dragging){const b=sj(x.dragging,m,n);rj(t,x.activeHandle,b,r)}}return rj(t,o.activeHandle,u,r),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function HF(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",Gt(this.options.HTMLAttributes,t),0]}}),U3=On.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",Gt(this.options.HTMLAttributes,t),0]}}),W3=On.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Gt(this.options.HTMLAttributes,t),0]}});function I0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function aj(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 x=0,b=0;x{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function XF(t,e,n,r,a){const i=YF(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!ZF(e))return!1;let n=0;const r=TC(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},eB="";function tB(t){return(t||"").replace(/\s+/g," ").trim()}function nB(t,e,n={}){var r;const a=(r=n.cellLineSeparator)!=null?r:eB;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(N=>{const w=[];N.content&&N.content.forEach(v=>{let k="";v.content&&Array.isArray(v.content)&&v.content.length>1?k=v.content.map(R=>e.renderChildren(R)).join(a):k=v.content?e.renderChildren(v.content):"";const M=tB(k),E=v.type==="tableHeader";w.push({text:M,isHeader:E})}),i.push(w)});const o=i.reduce((N,w)=>Math.max(N,w.length),0);if(o===0)return"";const c=new Array(o).fill(0);i.forEach(N=>{var w;for(let v=0;vc[v]&&(c[v]=M),c[v]<3&&(c[v]=3)}});const u=(N,w)=>N+" ".repeat(Math.max(0,w-N.length)),h=i[0],f=h.some(N=>N.isHeader);let m=` `;const x=new Array(o).fill(0).map((N,w)=>f&&h[w]&&h[w].text||"");return m+=`| ${x.map((N,w)=>u(N,c[w])).join(" | ")} | `,m+=`| ${c.map(N=>"-".repeat(Math.max(3,N))).join(" | ")} | `,(f?i.slice(1):i).forEach(N=>{m+=`| ${new Array(o).fill(0).map((w,v)=>u(N[v]&&N[v].text||"",c[v])).join(" | ")} | -`}),m}var sB=nB,K3=On.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:JF,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}=QF(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${a}`)}const c=["table",Gt(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)=>sB(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:a,editor:i})=>{const o=XF(i.schema,t,e,n);if(a){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(st.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>fF(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>pF(t,e),deleteColumn:()=>({state:t,dispatch:e})=>xF(t,e),addRowBefore:()=>({state:t,dispatch:e})=>yF(t,e),addRowAfter:()=>({state:t,dispatch:e})=>bF(t,e),deleteRow:()=>({state:t,dispatch:e})=>NF(t,e),deleteTable:()=>({state:t,dispatch:e})=>TF(t,e),mergeCells:()=>({state:t,dispatch:e})=>Gw(t,e),splitCell:()=>({state:t,dispatch:e})=>Jw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Lu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Lu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>CF(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Gw(t,e)?!0:Jw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>kF(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Yw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Yw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&$3(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=rn.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:uf,"Mod-Backspace":uf,Delete:uf,"Mod-Delete":uf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[$F({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],GF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Kt(et(t,"tableRole",e))}}});In.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(K3.configure(this.options.table)),this.options.tableCell!==!1&&t.push(H3.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(U3.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(W3.configure(this.options.tableRow)),t}});function rB(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function aB(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}function iB(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 +`}),m}var sB=nB,K3=On.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:JF,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}=QF(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${a}`)}const c=["table",Gt(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)=>sB(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:a,editor:i})=>{const o=XF(i.schema,t,e,n);if(a){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(st.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>fF(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>pF(t,e),deleteColumn:()=>({state:t,dispatch:e})=>xF(t,e),addRowBefore:()=>({state:t,dispatch:e})=>yF(t,e),addRowAfter:()=>({state:t,dispatch:e})=>bF(t,e),deleteRow:()=>({state:t,dispatch:e})=>NF(t,e),deleteTable:()=>({state:t,dispatch:e})=>TF(t,e),mergeCells:()=>({state:t,dispatch:e})=>Gw(t,e),splitCell:()=>({state:t,dispatch:e})=>Jw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Ou("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Ou("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>CF(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Gw(t,e)?!0:Jw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>kF(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Yw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Yw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&$3(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=an.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:uf,"Mod-Backspace":uf,Delete:uf,"Mod-Delete":uf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[$F({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],GF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Kt(et(t,"tableRole",e))}}});In.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(K3.configure(this.options.table)),this.options.tableCell!==!1&&t.push(H3.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(U3.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(W3.configure(this.options.tableRow)),t}});function rB(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function aB(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}function iB(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 `),e=e.replace(/]*>(.*?)<\/h2>/gi,`## $1 @@ -877,19 +877,19 @@ ${b.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: `),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 oB=On.create({name:"videoEmbed",group:"block",atom:!0,draggable:!0,addAttributes(){return{src:{default:null}}},parseHTML(){return[{tag:"div.rich-video-wrap",getAttrs:t=>{const e=t.querySelector("video"),n=e==null?void 0:e.getAttribute("src");return n?{src:n}:!1}},{tag:"video[src]",getAttrs:t=>({src:t.getAttribute("src")})}]},renderHTML({node:t}){const e=t.attrs.src||"";return["div",{class:"rich-video-wrap"},["video",{src:e,controls:!0,preload:"metadata"}],["div",{class:"rich-video-caption"},"视频(预览已缩小,保存后 C 端全宽播放)"]]}}),lB=On.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",Gt(e,{"data-type":"linkTag","data-url":t.attrs.url,"data-tag-type":t.attrs.tagType,"data-tag-id":t.attrs.tagId,"data-page-path":t.attrs.pagePath,"data-app-id":t.attrs.appId||"","data-mp-key":t.attrs.mpKey||t.attrs.appId||"",class:"link-tag-node"}),`#${t.attrs.label}`]}});function lj(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}const cB=t=>({items:({query:e})=>{const n=e.trim().toLowerCase();return(n?t.filter(a=>a.name.toLowerCase().includes(n)||a.id.toLowerCase().includes(n)||a.label&&a.label.toLowerCase().includes(n)||a.userId&&a.userId.toLowerCase().includes(n)):t).slice(0,16)},render:()=>{let e=null,n=0,r=[],a=null;const i=()=>{e&&(e.innerHTML=r.map((o,c)=>`
@${lj(o.name)} ${lj(o.label||o.id)} -
`).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");a&&r[c]&&a({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,a=o.command,n=0,i(),o.clientRect){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onUpdate:o=>{if(r=o.items,a=o.command,n=0,i(),o.clientRect&&e){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onKeyDown:o=>o.event.key==="ArrowUp"?(n=Math.max(0,n-1),i(),!0):o.event.key==="ArrowDown"?(n=Math.min(r.length-1,n+1),i(),!0):o.event.key==="Enter"?(a&&r[n]&&a({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}}}});function dB(t){var r;const e=[],n=(r=t.clipboardData)==null?void 0:r.items;if(!n)return e;for(let a=0;a{const h=g.useRef(null),f=g.useRef(null),m=g.useRef(null),x=g.useRef(null),[b,N]=g.useState(""),[w,v]=g.useState(!1),k=g.useRef(oj(t)),M=g.useCallback((ae,_)=>{var I;const se=x.current;if(!se||!n)return!1;const ce=dB(_);if(ce.length>0)return _.preventDefault(),(async()=>{for(const X of ce)try{const V=await n(X);V&&se.chain().focus().setImage({src:V}).run()}catch(V){console.error("粘贴图片上传失败",V)}})(),!0;const me=(I=_.clipboardData)==null?void 0:I.getData("text/html");if(me&&/data:image\/[^;"']+;base64,/i.test(me)){_.preventDefault();const{from:X,to:V}=se.state.selection;return(async()=>{try{const xe=await fB(me,n);se.chain().focus().insertContentAt({from:X,to:V},xe).run()}catch(xe){console.error("粘贴 HTML 内 base64 转换失败",xe)}})(),!0}return!1},[n]),E=e$({extensions:[Bz.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),Uz.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"rich-editor-img-thumb"}}),oB,Qz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:cB(a)}),lB,Yz.configure({placeholder:o}),K3.configure({resizable:!0}),W3,H3,U3],content:k.current,onUpdate:({editor:ae})=>{e(ae.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:M}});g.useEffect(()=>{x.current=E??null},[E]),g.useImperativeHandle(u,()=>({getHTML:()=>(E==null?void 0:E.getHTML())||"",getMarkdown:()=>iB((E==null?void 0:E.getHTML())||"")})),g.useEffect(()=>{if(E&&t!==E.getHTML()){const ae=oj(t);ae!==E.getHTML()&&E.commands.setContent(ae)}},[t]);const L=g.useCallback(async ae=>{if(r)return r(ae);if(n)return n(ae);throw new Error("未配置上传")},[n,r]),R=g.useCallback(async ae=>{var se;const _=(se=ae.target.files)==null?void 0:se[0];if(!(!_||!E)){if(n){const ce=await n(_);ce&&E.chain().focus().setImage({src:ce}).run()}else{const ce=new FileReader;ce.onload=()=>{typeof ce.result=="string"&&E.chain().focus().setImage({src:ce.result}).run()},ce.readAsDataURL(_)}ae.target.value=""}},[E,n]),W=g.useCallback(async ae=>{var se;const _=(se=ae.target.files)==null?void 0:se[0];if(!(!_||!E)){try{const ce=await L(_);ce&&E.chain().focus().insertContent({type:"videoEmbed",attrs:{src:ce}}).run()}catch(ce){console.error(ce)}ae.target.value=""}},[E,L]),P=g.useCallback(async ae=>{var se;const _=(se=ae.target.files)==null?void 0:se[0];if(!(!_||!E)){try{const ce=await L(_);if(!ce)return;const me=_.name||"附件";E.chain().focus().insertContent(`

附件 ${rB(me)}

`).run()}catch(ce){console.error(ce)}ae.target.value=""}},[E,L]),B=g.useCallback(()=>{E&&E.chain().focus().insertContent("@").run()},[E]),O=g.useCallback(ae=>{E&&E.chain().focus().insertContent([{type:"linkTag",attrs:{label:ae.label,url:ae.url||"",tagType:ae.type||"url",tagId:ae.id||"",pagePath:ae.pagePath||"",appId:ae.appId||"",mpKey:ae.type==="miniprogram"&&ae.appId||""}},{type:"text",text:" "}]).run()},[E]),Y=g.useCallback(()=>{!E||!b||(E.chain().focus().setLink({href:b}).run(),N(""),v(!1))},[E,b]);return E?s.jsxs("div",{className:`rich-editor-wrapper ${c||""}`,children:[s.jsxs("div",{className:"rich-editor-toolbar",children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().toggleBold().run(),className:E.isActive("bold")?"is-active":"",type:"button",children:s.jsx(wT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleItalic().run(),className:E.isActive("italic")?"is-active":"",type:"button",children:s.jsx(SM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleStrike().run(),className:E.isActive("strike")?"is-active":"",type:"button",children:s.jsx(PA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleCode().run(),className:E.isActive("code")?"is-active":"",type:"button",children:s.jsx(HT,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().toggleHeading({level:1}).run(),className:E.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(mM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleHeading({level:2}).run(),className:E.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(gM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleHeading({level:3}).run(),className:E.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(bM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().toggleBulletList().run(),className:E.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(OM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleOrderedList().run(),className:E.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(rk,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleBlockquote().run(),className:E.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(lA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(qM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:R,className:"hidden"}),s.jsx("input",{ref:f,type:"file",accept:"video/*",onChange:W,className:"hidden"}),s.jsx("input",{ref:m,type:"file",onChange:P,className:"hidden"}),s.jsx("button",{onClick:()=>{var ae;return(ae=h.current)==null?void 0:ae.click()},type:"button",title:"上传图片",children:s.jsx(sk,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var ae;return(ae=f.current)==null?void 0:ae.click()},type:"button",title:"上传视频",disabled:!r&&!n,children:s.jsx(KA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var ae;return(ae=m.current)==null?void 0:ae.click()},type:"button",title:"上传附件(生成下载链接)",disabled:!r&&!n,children:s.jsx(XM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:B,type:"button",title:"插入 @ 并选择人物",className:a.length?"mention-trigger-btn":"",disabled:a.length===0,children:s.jsx(gT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v(!w),className:E.isActive("link")?"is-active":"",type:"button",title:"链接",children:s.jsx(Fg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",title:"表格",children:s.jsx(RA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().undo().run(),disabled:!E.can().undo(),type:"button",children:s.jsx(FA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().redo().run(),disabled:!E.can().redo(),type:"button",children:s.jsx(dA,{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:ae=>{const _=i.find(se=>se.id===ae.target.value);_&&O(_),ae.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(ae=>s.jsx("option",{value:ae.id,children:ae.label},ae.id))]})})]})]}),w&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:b,onChange:ae=>N(ae.target.value),onKeyDown:ae=>ae.key==="Enter"&&Y(),className:"link-input"}),s.jsx("button",{onClick:Y,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{E.chain().focus().unsetLink().run(),v(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(s3,{editor:E})]}):null});R0.displayName="RichEditor";const pB=["top","right","bottom","left"],zo=Math.min,xr=Math.max,Np=Math.round,hf=Math.floor,Ia=t=>({x:t,y:t}),mB={left:"right",right:"left",bottom:"top",top:"bottom"},xB={start:"end",end:"start"};function L0(t,e,n){return xr(t,zo(e,n))}function Ai(t,e){return typeof t=="function"?t(e):t}function Pi(t){return t.split("-")[0]}function fd(t){return t.split("-")[1]}function eb(t){return t==="x"?"y":"x"}function tb(t){return t==="y"?"height":"width"}const gB=new Set(["top","bottom"]);function Pa(t){return gB.has(Pi(t))?"y":"x"}function nb(t){return eb(Pa(t))}function yB(t,e,n){n===void 0&&(n=!1);const r=fd(t),a=nb(t),i=tb(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=wp(o)),[o,wp(o)]}function bB(t){const e=wp(t);return[O0(t),e,O0(e)]}function O0(t){return t.replace(/start|end/g,e=>xB[e])}const cj=["left","right"],dj=["right","left"],vB=["top","bottom"],NB=["bottom","top"];function wB(t,e,n){switch(t){case"top":case"bottom":return n?e?dj:cj:e?cj:dj;case"left":case"right":return e?vB:NB;default:return[]}}function jB(t,e,n,r){const a=fd(t);let i=wB(Pi(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(O0)))),i}function wp(t){return t.replace(/left|right|bottom|top/g,e=>mB[e])}function kB(t){return{top:0,right:0,bottom:0,left:0,...t}}function q3(t){return typeof t!="number"?kB(t):{top:t,right:t,bottom:t,left:t}}function jp(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 uj(t,e,n){let{reference:r,floating:a}=t;const i=Pa(e),o=nb(e),c=tb(o),u=Pi(e),h=i==="y",f=r.x+r.width/2-a.width/2,m=r.y+r.height/2-a.height/2,x=r[c]/2-a[c]/2;let b;switch(u){case"top":b={x:f,y:r.y-a.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:m};break;case"left":b={x:r.x-a.width,y:m};break;default:b={x:r.x,y:r.y}}switch(fd(e)){case"start":b[o]-=x*(n&&h?-1:1);break;case"end":b[o]+=x*(n&&h?-1:1);break}return b}async function SB(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:x=!1,padding:b=0}=Ai(e,t),N=q3(b),v=c[x?m==="floating"?"reference":"floating":m],k=jp(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),M=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)),L=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},R=jp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:M,offsetParent:E,strategy:u}):M);return{top:(k.top-R.top+N.top)/L.y,bottom:(R.bottom-k.bottom+N.bottom)/L.y,left:(k.left-R.left+N.left)/L.x,right:(R.right-k.right+N.right)/L.x}}const CB=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}=uj(h,r,u),x=r,b={},N=0;for(let v=0;v({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}=Ai(t,e)||{};if(h==null)return{};const m=q3(f),x={x:n,y:r},b=nb(a),N=tb(b),w=await o.getDimensions(h),v=b==="y",k=v?"top":"left",M=v?"bottom":"right",E=v?"clientHeight":"clientWidth",L=i.reference[N]+i.reference[b]-x[b]-i.floating[N],R=x[b]-i.reference[b],W=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let P=W?W[E]:0;(!P||!await(o.isElement==null?void 0:o.isElement(W)))&&(P=c.floating[E]||i.floating[N]);const B=L/2-R/2,O=P/2-w[N]/2-1,Y=zo(m[k],O),ae=zo(m[M],O),_=Y,se=P-w[N]-ae,ce=P/2-w[N]/2+B,me=L0(_,ce,se),I=!u.arrow&&fd(a)!=null&&ce!==me&&i.reference[N]/2-(ce<_?Y:ae)-w[N]/2<0,X=I?ce<_?ce-_:ce-se:0;return{[b]:x[b]+X,data:{[b]:me,centerOffset:ce-me-X,...I&&{alignmentOffset:X}},reset:I}}}),TB=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:a,middlewareData:i,rects:o,initialPlacement:c,platform:u,elements:h}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:x,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:N="none",flipAlignment:w=!0,...v}=Ai(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const k=Pi(a),M=Pa(c),E=Pi(c)===c,L=await(u.isRTL==null?void 0:u.isRTL(h.floating)),R=x||(E||!w?[wp(c)]:bB(c)),W=N!=="none";!x&&W&&R.push(...jB(c,w,N,L));const P=[c,...R],B=await u.detectOverflow(e,v),O=[];let Y=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&O.push(B[k]),m){const ce=yB(a,o,L);O.push(B[ce[0]],B[ce[1]])}if(Y=[...Y,{placement:a,overflows:O}],!O.every(ce=>ce<=0)){var ae,_;const ce=(((ae=i.flip)==null?void 0:ae.index)||0)+1,me=P[ce];if(me&&(!(m==="alignment"?M!==Pa(me):!1)||Y.every(V=>Pa(V.placement)===M?V.overflows[0]>0:!0)))return{data:{index:ce,overflows:Y},reset:{placement:me}};let I=(_=Y.filter(X=>X.overflows[0]<=0).sort((X,V)=>X.overflows[1]-V.overflows[1])[0])==null?void 0:_.placement;if(!I)switch(b){case"bestFit":{var se;const X=(se=Y.filter(V=>{if(W){const xe=Pa(V.placement);return xe===M||xe==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(xe=>xe>0).reduce((xe,ee)=>xe+ee,0)]).sort((V,xe)=>V[1]-xe[1])[0])==null?void 0:se[0];X&&(I=X);break}case"initialPlacement":I=c;break}if(a!==I)return{reset:{placement:I}}}return{}}}};function hj(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function fj(t){return pB.some(e=>t[e]>=0)}const MB=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:a="referenceHidden",...i}=Ai(t,e);switch(a){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),c=hj(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:fj(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),c=hj(o,n.floating);return{data:{escapedOffsets:c,escaped:fj(c)}}}default:return{}}}}},G3=new Set(["left","top"]);async function AB(t,e){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=Pi(n),c=fd(n),u=Pa(n)==="y",h=G3.has(o)?-1:1,f=i&&u?-1:1,m=Ai(e,t);let{mainAxis:x,crossAxis:b,alignmentAxis:N}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof N=="number"&&(b=c==="end"?N*-1:N),u?{x:b*f,y:x*h}:{x:x*h,y:b*f}}const PB=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 AB(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}}}}},IB=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:M,y:E}=k;return{x:M,y:E}}},...h}=Ai(t,e),f={x:n,y:r},m=await i.detectOverflow(e,h),x=Pa(Pi(a)),b=eb(x);let N=f[b],w=f[x];if(o){const k=b==="y"?"top":"left",M=b==="y"?"bottom":"right",E=N+m[k],L=N-m[M];N=L0(E,N,L)}if(c){const k=x==="y"?"top":"left",M=x==="y"?"bottom":"right",E=w+m[k],L=w-m[M];w=L0(E,w,L)}const v=u.fn({...e,[b]:N,[x]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[b]:o,[x]:c}}}}}},RB=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}=Ai(t,e),f={x:n,y:r},m=Pa(a),x=eb(m);let b=f[x],N=f[m];const w=Ai(c,e),v=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const E=x==="y"?"height":"width",L=i.reference[x]-i.floating[E]+v.mainAxis,R=i.reference[x]+i.reference[E]-v.mainAxis;bR&&(b=R)}if(h){var k,M;const E=x==="y"?"width":"height",L=G3.has(Pi(a)),R=i.reference[m]-i.floating[E]+(L&&((k=o.offset)==null?void 0:k[m])||0)+(L?0:v.crossAxis),W=i.reference[m]+i.reference[E]+(L?0:((M=o.offset)==null?void 0:M[m])||0)-(L?v.crossAxis:0);NW&&(N=W)}return{[x]:b,[m]:N}}}},LB=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}=Ai(t,e),f=await o.detectOverflow(e,h),m=Pi(a),x=fd(a),b=Pa(a)==="y",{width:N,height:w}=i.floating;let v,k;m==="top"||m==="bottom"?(v=m,k=x===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,v=x==="end"?"top":"bottom");const M=w-f.top-f.bottom,E=N-f.left-f.right,L=zo(w-f[v],M),R=zo(N-f[k],E),W=!e.middlewareData.shift;let P=L,B=R;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(B=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(P=M),W&&!x){const Y=xr(f.left,0),ae=xr(f.right,0),_=xr(f.top,0),se=xr(f.bottom,0);b?B=N-2*(Y!==0||ae!==0?Y+ae:xr(f.left,f.right)):P=w-2*(_!==0||se!==0?_+se:xr(f.top,f.bottom))}await u({...e,availableWidth:B,availableHeight:P});const O=await o.getDimensions(c.floating);return N!==O.width||w!==O.height?{reset:{rects:!0}}:{}}}};function Xp(){return typeof window<"u"}function pd(t){return J3(t)?(t.nodeName||"").toLowerCase():"#document"}function vr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function za(t){var e;return(e=(J3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function J3(t){return Xp()?t instanceof Node||t instanceof vr(t).Node:!1}function ia(t){return Xp()?t instanceof Element||t instanceof vr(t).Element:!1}function Da(t){return Xp()?t instanceof HTMLElement||t instanceof vr(t).HTMLElement:!1}function pj(t){return!Xp()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof vr(t).ShadowRoot}const OB=new Set(["inline","contents"]);function Uu(t){const{overflow:e,overflowX:n,overflowY:r,display:a}=oa(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!OB.has(a)}const DB=new Set(["table","td","th"]);function _B(t){return DB.has(pd(t))}const $B=[":popover-open",":modal"];function Zp(t){return $B.some(e=>{try{return t.matches(e)}catch{return!1}})}const zB=["transform","translate","scale","rotate","perspective"],FB=["transform","translate","scale","rotate","perspective","filter"],BB=["paint","layout","strict","content"];function sb(t){const e=rb(),n=ia(t)?oa(t):t;return zB.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)||FB.some(r=>(n.willChange||"").includes(r))||BB.some(r=>(n.contain||"").includes(r))}function VB(t){let e=Fo(t);for(;Da(e)&&!ad(e);){if(sb(e))return e;if(Zp(e))return null;e=Fo(e)}return null}function rb(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const HB=new Set(["html","body","#document"]);function ad(t){return HB.has(pd(t))}function oa(t){return vr(t).getComputedStyle(t)}function em(t){return ia(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Fo(t){if(pd(t)==="html")return t;const e=t.assignedSlot||t.parentNode||pj(t)&&t.host||za(t);return pj(e)?e.host:e}function Q3(t){const e=Fo(t);return ad(e)?t.ownerDocument?t.ownerDocument.body:t.body:Da(e)&&Uu(e)?e:Q3(e)}function Ou(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=Q3(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=vr(a);if(i){const c=D0(o);return e.concat(o,o.visualViewport||[],Uu(a)?a:[],c&&n?Ou(c):[])}return e.concat(a,Ou(a,[],n))}function D0(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Y3(t){const e=oa(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const a=Da(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,c=Np(n)!==i||Np(r)!==o;return c&&(n=i,r=o),{width:n,height:r,$:c}}function ab(t){return ia(t)?t:t.contextElement}function Qc(t){const e=ab(t);if(!Da(e))return Ia(1);const n=e.getBoundingClientRect(),{width:r,height:a,$:i}=Y3(e);let o=(i?Np(n.width):n.width)/r,c=(i?Np(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const UB=Ia(0);function X3(t){const e=vr(t);return!rb()||!e.visualViewport?UB:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function WB(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==vr(t)?!1:e}function Ql(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=ab(t);let o=Ia(1);e&&(r?ia(r)&&(o=Qc(r)):o=Qc(t));const c=WB(i,n,r)?X3(i):Ia(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 x=vr(i),b=r&&ia(r)?vr(r):r;let N=x,w=D0(N);for(;w&&r&&b!==N;){const v=Qc(w),k=w.getBoundingClientRect(),M=oa(w),E=k.left+(w.clientLeft+parseFloat(M.paddingLeft))*v.x,L=k.top+(w.clientTop+parseFloat(M.paddingTop))*v.y;u*=v.x,h*=v.y,f*=v.x,m*=v.y,u+=E,h+=L,N=vr(w),w=D0(N)}}return jp({width:f,height:m,x:u,y:h})}function tm(t,e){const n=em(t).scrollLeft;return e?e.left+n:Ql(za(t)).left+n}function Z3(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-tm(t,n),a=n.top+e.scrollTop;return{x:r,y:a}}function KB(t){let{elements:e,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=za(r),c=e?Zp(e.floating):!1;if(r===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Ia(1);const f=Ia(0),m=Da(r);if((m||!m&&!i)&&((pd(r)!=="body"||Uu(o))&&(u=em(r)),Da(r))){const b=Ql(r);h=Qc(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const x=o&&!m&&!i?Z3(o,u):Ia(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+f.x+x.x,y:n.y*h.y-u.scrollTop*h.y+f.y+x.y}}function qB(t){return Array.from(t.getClientRects())}function GB(t){const e=za(t),n=em(t),r=t.ownerDocument.body,a=xr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=xr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+tm(t);const c=-n.scrollTop;return oa(r).direction==="rtl"&&(o+=xr(e.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:c}}const mj=25;function JB(t,e){const n=vr(t),r=za(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=rb();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=tm(r);if(h<=0){const f=r.ownerDocument,m=f.body,x=getComputedStyle(m),b=f.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,N=Math.abs(r.clientWidth-m.clientWidth-b);N<=mj&&(i-=N)}else h<=mj&&(i+=h);return{width:i,height:o,x:c,y:u}}const QB=new Set(["absolute","fixed"]);function YB(t,e){const n=Ql(t,!0,e==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=Da(t)?Qc(t):Ia(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 xj(t,e,n){let r;if(e==="viewport")r=JB(t,n);else if(e==="document")r=GB(za(t));else if(ia(e))r=YB(e,n);else{const a=X3(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return jp(r)}function e4(t,e){const n=Fo(t);return n===e||!ia(n)||ad(n)?!1:oa(n).position==="fixed"||e4(n,e)}function XB(t,e){const n=e.get(t);if(n)return n;let r=Ou(t,[],!1).filter(c=>ia(c)&&pd(c)!=="body"),a=null;const i=oa(t).position==="fixed";let o=i?Fo(t):t;for(;ia(o)&&!ad(o);){const c=oa(o),u=sb(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&QB.has(a.position)||Uu(o)&&!u&&e4(t,o))?r=r.filter(f=>f!==o):a=c,o=Fo(o)}return e.set(t,r),r}function ZB(t){let{element:e,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?Zp(e)?[]:XB(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=xj(e,f,a);return h.top=xr(m.top,h.top),h.right=zo(m.right,h.right),h.bottom=zo(m.bottom,h.bottom),h.left=xr(m.left,h.left),h},xj(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function e9(t){const{width:e,height:n}=Y3(t);return{width:e,height:n}}function t9(t,e,n){const r=Da(e),a=za(e),i=n==="fixed",o=Ql(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Ia(0);function h(){u.x=tm(a)}if(r||!r&&!i)if((pd(e)!=="body"||Uu(a))&&(c=em(e)),r){const b=Ql(e,!0,i,e);u.x=b.x+e.clientLeft,u.y=b.y+e.clientTop}else a&&h();i&&!r&&a&&h();const f=a&&!r&&!i?Z3(a,c):Ia(0),m=o.left+c.scrollLeft-u.x-f.x,x=o.top+c.scrollTop-u.y-f.y;return{x:m,y:x,width:o.width,height:o.height}}function kg(t){return oa(t).position==="static"}function gj(t,e){if(!Da(t)||oa(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return za(t)===n&&(n=n.ownerDocument.body),n}function t4(t,e){const n=vr(t);if(Zp(t))return n;if(!Da(t)){let a=Fo(t);for(;a&&!ad(a);){if(ia(a)&&!kg(a))return a;a=Fo(a)}return n}let r=gj(t,e);for(;r&&_B(r)&&kg(r);)r=gj(r,e);return r&&ad(r)&&kg(r)&&!sb(r)?n:r||VB(t)||n}const n9=async function(t){const e=this.getOffsetParent||t4,n=this.getDimensions,r=await n(t.floating);return{reference:t9(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function s9(t){return oa(t).direction==="rtl"}const r9={convertOffsetParentRelativeRectToViewportRelativeRect:KB,getDocumentElement:za,getClippingRect:ZB,getOffsetParent:t4,getElementRects:n9,getClientRects:qB,getDimensions:e9,getScale:Qc,isElement:ia,isRTL:s9};function n4(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function a9(t,e){let n=null,r;const a=za(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:x,height:b}=h;if(c||e(),!x||!b)return;const N=hf(m),w=hf(a.clientWidth-(f+x)),v=hf(a.clientHeight-(m+b)),k=hf(f),E={rootMargin:-N+"px "+-w+"px "+-v+"px "+-k+"px",threshold:xr(0,zo(1,u))||1};let L=!0;function R(W){const P=W[0].intersectionRatio;if(P!==u){if(!L)return o();P?o(!1,P):r=setTimeout(()=>{o(!1,1e-7)},1e3)}P===1&&!n4(h,t.getBoundingClientRect())&&o(),L=!1}try{n=new IntersectionObserver(R,{...E,root:a.ownerDocument})}catch{n=new IntersectionObserver(R,E)}n.observe(t)}return o(!0),i}function i9(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=ab(t),f=a||i?[...h?Ou(h):[],...Ou(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?a9(h,n):null;let x=-1,b=null;o&&(b=new ResizeObserver(k=>{let[M]=k;M&&M.target===h&&b&&(b.unobserve(e),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var E;(E=b)==null||E.observe(e)})),n()}),h&&!u&&b.observe(h),b.observe(e));let N,w=u?Ql(t):null;u&&v();function v(){const k=Ql(t);w&&!n4(w,k)&&n(),w=k,N=requestAnimationFrame(v)}return n(),()=>{var k;f.forEach(M=>{a&&M.removeEventListener("scroll",n),i&&M.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,u&&cancelAnimationFrame(N)}}const o9=PB,l9=IB,c9=TB,d9=LB,u9=MB,yj=EB,h9=RB,f9=(t,e,n)=>{const r=new Map,a={platform:r9,...n},i={...a.platform,_c:r};return CB(t,e,{...a,platform:i})};var p9=typeof document<"u",m9=function(){},wf=p9?g.useLayoutEffect:m9;function kp(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(!kp(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)&&!kp(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function s4(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function bj(t,e){const n=s4(t);return Math.round(e*n)/n}function Sg(t){const e=g.useRef(t);return wf(()=>{e.current=t}),e}function x9(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]=g.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[x,b]=g.useState(r);kp(x,r)||b(r);const[N,w]=g.useState(null),[v,k]=g.useState(null),M=g.useCallback(V=>{V!==W.current&&(W.current=V,w(V))},[]),E=g.useCallback(V=>{V!==P.current&&(P.current=V,k(V))},[]),L=i||N,R=o||v,W=g.useRef(null),P=g.useRef(null),B=g.useRef(f),O=u!=null,Y=Sg(u),ae=Sg(a),_=Sg(h),se=g.useCallback(()=>{if(!W.current||!P.current)return;const V={placement:e,strategy:n,middleware:x};ae.current&&(V.platform=ae.current),f9(W.current,P.current,V).then(xe=>{const ee={...xe,isPositioned:_.current!==!1};ce.current&&!kp(B.current,ee)&&(B.current=ee,id.flushSync(()=>{m(ee)}))})},[x,e,n,ae,_]);wf(()=>{h===!1&&B.current.isPositioned&&(B.current.isPositioned=!1,m(V=>({...V,isPositioned:!1})))},[h]);const ce=g.useRef(!1);wf(()=>(ce.current=!0,()=>{ce.current=!1}),[]),wf(()=>{if(L&&(W.current=L),R&&(P.current=R),L&&R){if(Y.current)return Y.current(L,R,se);se()}},[L,R,se,Y,O]);const me=g.useMemo(()=>({reference:W,floating:P,setReference:M,setFloating:E}),[M,E]),I=g.useMemo(()=>({reference:L,floating:R}),[L,R]),X=g.useMemo(()=>{const V={position:n,left:0,top:0};if(!I.floating)return V;const xe=bj(I.floating,f.x),ee=bj(I.floating,f.y);return c?{...V,transform:"translate("+xe+"px, "+ee+"px)",...s4(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:xe,top:ee}},[n,c,I.floating,f.x,f.y]);return g.useMemo(()=>({...f,update:se,refs:me,elements:I,floatingStyles:X}),[f,se,me,I,X])}const g9=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?yj({element:r.current,padding:a}).fn(n):{}:r?yj({element:r,padding:a}).fn(n):{}}}},y9=(t,e)=>({...o9(t),options:[t,e]}),b9=(t,e)=>({...l9(t),options:[t,e]}),v9=(t,e)=>({...h9(t),options:[t,e]}),N9=(t,e)=>({...c9(t),options:[t,e]}),w9=(t,e)=>({...d9(t),options:[t,e]}),j9=(t,e)=>({...u9(t),options:[t,e]}),k9=(t,e)=>({...g9(t),options:[t,e]});var S9="Arrow",r4=g.forwardRef((t,e)=>{const{children:n,width:r=10,height:a=5,...i}=t;return s.jsx(St.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"})})});r4.displayName=S9;var C9=r4,ib="Popper",[a4,i4]=Ho(ib),[E9,o4]=a4(ib),l4=t=>{const{__scopePopper:e,children:n}=t,[r,a]=g.useState(null);return s.jsx(E9,{scope:e,anchor:r,onAnchorChange:a,children:n})};l4.displayName=ib;var c4="PopperAnchor",d4=g.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=o4(c4,n),o=g.useRef(null),c=Jt(e,o),u=g.useRef(null);return g.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(St.div,{...a,ref:c})});d4.displayName=c4;var ob="PopperContent",[T9,M9]=a4(ob),u4=g.forwardRef((t,e)=>{var Q,z,te,ie,we,Be;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:x=!1,updatePositionStrategy:b="optimized",onPlaced:N,...w}=t,v=o4(ob,n),[k,M]=g.useState(null),E=Jt(e,Ue=>M(Ue)),[L,R]=g.useState(null),W=ly(L),P=(W==null?void 0:W.width)??0,B=(W==null?void 0:W.height)??0,O=r+(i!=="center"?"-"+i:""),Y=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},ae=Array.isArray(h)?h:[h],_=ae.length>0,se={padding:Y,boundary:ae.filter(P9),altBoundary:_},{refs:ce,floatingStyles:me,placement:I,isPositioned:X,middlewareData:V}=x9({strategy:"fixed",placement:O,whileElementsMounted:(...Ue)=>i9(...Ue,{animationFrame:b==="always"}),elements:{reference:v.anchor},middleware:[y9({mainAxis:a+B,alignmentAxis:o}),u&&b9({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?v9():void 0,...se}),u&&N9({...se}),w9({...se,apply:({elements:Ue,rects:yt,availableWidth:vn,availableHeight:dt})=>{const{width:Et,height:on}=yt.reference,Dn=Ue.floating.style;Dn.setProperty("--radix-popper-available-width",`${vn}px`),Dn.setProperty("--radix-popper-available-height",`${dt}px`),Dn.setProperty("--radix-popper-anchor-width",`${Et}px`),Dn.setProperty("--radix-popper-anchor-height",`${on}px`)}}),L&&k9({element:L,padding:c}),I9({arrowWidth:P,arrowHeight:B}),x&&j9({strategy:"referenceHidden",...se})]}),[xe,ee]=p4(I),H=Lo(N);Rs(()=>{X&&(H==null||H())},[X,H]);const K=(Q=V.arrow)==null?void 0:Q.x,fe=(z=V.arrow)==null?void 0:z.y,he=((te=V.arrow)==null?void 0:te.centerOffset)!==0,[ue,$]=g.useState();return Rs(()=>{k&&$(window.getComputedStyle(k).zIndex)},[k]),s.jsx("div",{ref:ce.setFloating,"data-radix-popper-content-wrapper":"",style:{...me,transform:X?me.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(ie=V.transformOrigin)==null?void 0:ie.x,(we=V.transformOrigin)==null?void 0:we.y].join(" "),...((Be=V.hide)==null?void 0:Be.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(T9,{scope:n,placedSide:xe,onArrowChange:R,arrowX:K,arrowY:fe,shouldHideArrow:he,children:s.jsx(St.div,{"data-side":xe,"data-align":ee,...w,ref:E,style:{...w.style,animation:X?void 0:"none"}})})})});u4.displayName=ob;var h4="PopperArrow",A9={top:"bottom",right:"left",bottom:"top",left:"right"},f4=g.forwardRef(function(e,n){const{__scopePopper:r,...a}=e,i=M9(h4,r),o=A9[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(C9,{...a,ref:n,style:{...a.style,display:"block"}})})});f4.displayName=h4;function P9(t){return t!==null}var I9=t=>({name:"transformOrigin",options:t,fn(e){var v,k,M;const{placement:n,rects:r,middlewareData:a}=e,o=((v=a.arrow)==null?void 0:v.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=p4(n),m={start:"0%",center:"50%",end:"100%"}[f],x=(((k=a.arrow)==null?void 0:k.x)??0)+c/2,b=(((M=a.arrow)==null?void 0:M.y)??0)+u/2;let N="",w="";return h==="bottom"?(N=o?m:`${x}px`,w=`${-u}px`):h==="top"?(N=o?m:`${x}px`,w=`${r.floating.height+u}px`):h==="right"?(N=`${-u}px`,w=o?m:`${b}px`):h==="left"&&(N=`${r.floating.width+u}px`,w=o?m:`${b}px`),{data:{x:N,y:w}}}});function p4(t){const[e,n="center"]=t.split("-");return[e,n]}var R9=l4,L9=d4,O9=u4,D9=f4,m4=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"}),_9="VisuallyHidden",$9=g.forwardRef((t,e)=>s.jsx(St.span,{...t,ref:e,style:{...m4,...t.style}}));$9.displayName=_9;var z9=[" ","Enter","ArrowUp","ArrowDown"],F9=[" ","Enter"],Yl="Select",[nm,sm,B9]=ay(Yl),[md]=Ho(Yl,[B9,i4]),rm=i4(),[V9,Go]=md(Yl),[H9,U9]=md(Yl),x4=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:x,required:b,form:N}=t,w=rm(e),[v,k]=g.useState(null),[M,E]=g.useState(null),[L,R]=g.useState(!1),W=Ip(h),[P,B]=Fl({prop:r,defaultProp:a??!1,onChange:i,caller:Yl}),[O,Y]=Fl({prop:o,defaultProp:c,onChange:u,caller:Yl}),ae=g.useRef(null),_=v?N||!!v.closest("form"):!0,[se,ce]=g.useState(new Set),me=Array.from(se).map(I=>I.props.value).join(";");return s.jsx(R9,{...w,children:s.jsxs(V9,{required:b,scope:e,trigger:v,onTriggerChange:k,valueNode:M,onValueNodeChange:E,valueNodeHasChildren:L,onValueNodeHasChildrenChange:R,contentId:Eo(),value:O,onValueChange:Y,open:P,onOpenChange:B,dir:W,triggerPointerDownPosRef:ae,disabled:x,children:[s.jsx(nm.Provider,{scope:e,children:s.jsx(H9,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(I=>{ce(X=>new Set(X).add(I))},[]),onNativeOptionRemove:g.useCallback(I=>{ce(X=>{const V=new Set(X);return V.delete(I),V})},[]),children:n})}),_?s.jsxs($4,{"aria-hidden":!0,required:b,tabIndex:-1,name:f,autoComplete:m,value:O,onChange:I=>Y(I.target.value),disabled:x,form:N,children:[O===void 0?s.jsx("option",{value:""}):null,Array.from(se)]},me):null]})})};x4.displayName=Yl;var g4="SelectTrigger",y4=g.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=rm(n),o=Go(g4,n),c=o.disabled||r,u=Jt(e,o.onTriggerChange),h=sm(n),f=g.useRef("touch"),[m,x,b]=F4(w=>{const v=h().filter(E=>!E.disabled),k=v.find(E=>E.value===o.value),M=B4(v,w,k);M!==void 0&&o.onValueChange(M.value)}),N=w=>{c||(o.onOpenChange(!0),b()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return s.jsx(L9,{asChild:!0,...i,children:s.jsx(St.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":z4(o.value)?"":void 0,...a,ref:u,onClick:Nt(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&N(w)}),onPointerDown:Nt(a.onPointerDown,w=>{f.current=w.pointerType;const v=w.target;v.hasPointerCapture(w.pointerId)&&v.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(N(w),w.preventDefault())}),onKeyDown:Nt(a.onKeyDown,w=>{const v=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&x(w.key),!(v&&w.key===" ")&&z9.includes(w.key)&&(N(),w.preventDefault())})})})});y4.displayName=g4;var b4="SelectValue",v4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=t,u=Go(b4,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Jt(e,u.onValueNodeChange);return Rs(()=>{h(f)},[h,f]),s.jsx(St.span,{...c,ref:m,style:{pointerEvents:"none"},children:z4(u.value)?s.jsx(s.Fragment,{children:o}):i})});v4.displayName=b4;var W9="SelectIcon",N4=g.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...a}=t;return s.jsx(St.span,{"aria-hidden":!0,...a,ref:e,children:r||"▼"})});N4.displayName=W9;var K9="SelectPortal",w4=t=>s.jsx(ey,{asChild:!0,...t});w4.displayName=K9;var Xl="SelectContent",j4=g.forwardRef((t,e)=>{const n=Go(Xl,t.__scopeSelect),[r,a]=g.useState();if(Rs(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?id.createPortal(s.jsx(k4,{scope:t.__scopeSelect,children:s.jsx(nm.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),i):null}return s.jsx(S4,{...t,ref:e})});j4.displayName=Xl;var ta=10,[k4,Jo]=md(Xl),q9="SelectContentImpl",G9=wu("SelectContent.RemoveScroll"),S4=g.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:x,collisionPadding:b,sticky:N,hideWhenDetached:w,avoidCollisions:v,...k}=t,M=Go(Xl,n),[E,L]=g.useState(null),[R,W]=g.useState(null),P=Jt(e,Q=>L(Q)),[B,O]=g.useState(null),[Y,ae]=g.useState(null),_=sm(n),[se,ce]=g.useState(!1),me=g.useRef(!1);g.useEffect(()=>{if(E)return $k(E)},[E]),Mk();const I=g.useCallback(Q=>{const[z,...te]=_().map(Be=>Be.ref.current),[ie]=te.slice(-1),we=document.activeElement;for(const Be of Q)if(Be===we||(Be==null||Be.scrollIntoView({block:"nearest"}),Be===z&&R&&(R.scrollTop=0),Be===ie&&R&&(R.scrollTop=R.scrollHeight),Be==null||Be.focus(),document.activeElement!==we))return},[_,R]),X=g.useCallback(()=>I([B,E]),[I,B,E]);g.useEffect(()=>{se&&X()},[se,X]);const{onOpenChange:V,triggerPointerDownPosRef:xe}=M;g.useEffect(()=>{if(E){let Q={x:0,y:0};const z=ie=>{var we,Be;Q={x:Math.abs(Math.round(ie.pageX)-(((we=xe.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((Be=xe.current)==null?void 0:Be.y)??0))}},te=ie=>{Q.x<=10&&Q.y<=10?ie.preventDefault():E.contains(ie.target)||V(!1),document.removeEventListener("pointermove",z),xe.current=null};return xe.current!==null&&(document.addEventListener("pointermove",z),document.addEventListener("pointerup",te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",te,{capture:!0})}}},[E,V,xe]),g.useEffect(()=>{const Q=()=>V(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[V]);const[ee,H]=F4(Q=>{const z=_().filter(we=>!we.disabled),te=z.find(we=>we.ref.current===document.activeElement),ie=B4(z,Q,te);ie&&setTimeout(()=>ie.ref.current.focus())}),K=g.useCallback((Q,z,te)=>{const ie=!me.current&&!te;(M.value!==void 0&&M.value===z||ie)&&(O(Q),ie&&(me.current=!0))},[M.value]),fe=g.useCallback(()=>E==null?void 0:E.focus(),[E]),he=g.useCallback((Q,z,te)=>{const ie=!me.current&&!te;(M.value!==void 0&&M.value===z||ie)&&ae(Q)},[M.value]),ue=r==="popper"?_0:C4,$=ue===_0?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:x,collisionPadding:b,sticky:N,hideWhenDetached:w,avoidCollisions:v}:{};return s.jsx(k4,{scope:n,content:E,viewport:R,onViewportChange:W,itemRefCallback:K,selectedItem:B,onItemLeave:fe,itemTextRefCallback:he,focusSelectedItem:X,selectedItemText:Y,position:r,isPositioned:se,searchRef:ee,children:s.jsx(ty,{as:G9,allowPinchZoom:!0,children:s.jsx(Z0,{asChild:!0,trapped:M.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:Nt(a,Q=>{var z;(z=M.trigger)==null||z.focus({preventScroll:!0}),Q.preventDefault()}),children:s.jsx(X0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>M.onOpenChange(!1),children:s.jsx(ue,{role:"listbox",id:M.contentId,"data-state":M.open?"open":"closed",dir:M.dir,onContextMenu:Q=>Q.preventDefault(),...k,...$,onPlaced:()=>ce(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Nt(k.onKeyDown,Q=>{const z=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!z&&Q.key.length===1&&H(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let ie=_().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const we=Q.target,Be=ie.indexOf(we);ie=ie.slice(Be+1)}setTimeout(()=>I(ie)),Q.preventDefault()}})})})})})})});S4.displayName=q9;var J9="SelectItemAlignedPosition",C4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=Go(Xl,n),o=Jo(Xl,n),[c,u]=g.useState(null),[h,f]=g.useState(null),m=Jt(e,P=>f(P)),x=sm(n),b=g.useRef(!1),N=g.useRef(!0),{viewport:w,selectedItem:v,selectedItemText:k,focusSelectedItem:M}=o,E=g.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&v&&k){const P=i.trigger.getBoundingClientRect(),B=h.getBoundingClientRect(),O=i.valueNode.getBoundingClientRect(),Y=k.getBoundingClientRect();if(i.dir!=="rtl"){const we=Y.left-B.left,Be=O.left-we,Ue=P.left-Be,yt=P.width+Ue,vn=Math.max(yt,B.width),dt=window.innerWidth-ta,Et=Pf(Be,[ta,Math.max(ta,dt-vn)]);c.style.minWidth=yt+"px",c.style.left=Et+"px"}else{const we=B.right-Y.right,Be=window.innerWidth-O.right-we,Ue=window.innerWidth-P.right-Be,yt=P.width+Ue,vn=Math.max(yt,B.width),dt=window.innerWidth-ta,Et=Pf(Be,[ta,Math.max(ta,dt-vn)]);c.style.minWidth=yt+"px",c.style.right=Et+"px"}const ae=x(),_=window.innerHeight-ta*2,se=w.scrollHeight,ce=window.getComputedStyle(h),me=parseInt(ce.borderTopWidth,10),I=parseInt(ce.paddingTop,10),X=parseInt(ce.borderBottomWidth,10),V=parseInt(ce.paddingBottom,10),xe=me+I+se+V+X,ee=Math.min(v.offsetHeight*5,xe),H=window.getComputedStyle(w),K=parseInt(H.paddingTop,10),fe=parseInt(H.paddingBottom,10),he=P.top+P.height/2-ta,ue=_-he,$=v.offsetHeight/2,Q=v.offsetTop+$,z=me+I+Q,te=xe-z;if(z<=he){const we=ae.length>0&&v===ae[ae.length-1].ref.current;c.style.bottom="0px";const Be=h.clientHeight-w.offsetTop-w.offsetHeight,Ue=Math.max(ue,$+(we?fe:0)+Be+X),yt=z+Ue;c.style.height=yt+"px"}else{const we=ae.length>0&&v===ae[0].ref.current;c.style.top="0px";const Ue=Math.max(he,me+w.offsetTop+(we?K:0)+$)+te;c.style.height=Ue+"px",w.scrollTop=z-he+w.offsetTop}c.style.margin=`${ta}px 0`,c.style.minHeight=ee+"px",c.style.maxHeight=_+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[x,i.trigger,i.valueNode,c,h,w,v,k,i.dir,r]);Rs(()=>E(),[E]);const[L,R]=g.useState();Rs(()=>{h&&R(window.getComputedStyle(h).zIndex)},[h]);const W=g.useCallback(P=>{P&&N.current===!0&&(E(),M==null||M(),N.current=!1)},[E,M]);return s.jsx(Y9,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:b,onScrollButtonChange:W,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:s.jsx(St.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});C4.displayName=J9;var Q9="SelectPopperPosition",_0=g.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=ta,...i}=t,o=rm(n);return s.jsx(O9,{...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)"}})});_0.displayName=Q9;var[Y9,lb]=md(Xl,{}),$0="SelectViewport",E4=g.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=Jo($0,n),o=lb($0,n),c=Jt(e,i.onViewportChange),u=g.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(nm.Slot,{scope:n,children:s.jsx(St.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Nt(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:x}=o;if(x!=null&&x.current&&m){const b=Math.abs(u.current-f.scrollTop);if(b>0){const N=window.innerHeight-ta*2,w=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),k=Math.max(w,v);if(k0?L:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});E4.displayName=$0;var T4="SelectGroup",[X9,Z9]=md(T4),eV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Eo();return s.jsx(X9,{scope:n,id:a,children:s.jsx(St.div,{role:"group","aria-labelledby":a,...r,ref:e})})});eV.displayName=T4;var M4="SelectLabel",tV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Z9(M4,n);return s.jsx(St.div,{id:a.id,...r,ref:e})});tV.displayName=M4;var Sp="SelectItem",[nV,A4]=md(Sp),P4=g.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,c=Go(Sp,n),u=Jo(Sp,n),h=c.value===r,[f,m]=g.useState(i??""),[x,b]=g.useState(!1),N=Jt(e,M=>{var E;return(E=u.itemRefCallback)==null?void 0:E.call(u,M,r,a)}),w=Eo(),v=g.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(nV,{scope:n,value:r,disabled:a,textId:w,isSelected:h,onItemTextChange:g.useCallback(M=>{m(E=>E||((M==null?void 0:M.textContent)??"").trim())},[]),children:s.jsx(nm.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:s.jsx(St.div,{role:"option","aria-labelledby":w,"data-highlighted":x?"":void 0,"aria-selected":h&&x,"data-state":h?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:Nt(o.onFocus,()=>b(!0)),onBlur:Nt(o.onBlur,()=>b(!1)),onClick:Nt(o.onClick,()=>{v.current!=="mouse"&&k()}),onPointerUp:Nt(o.onPointerUp,()=>{v.current==="mouse"&&k()}),onPointerDown:Nt(o.onPointerDown,M=>{v.current=M.pointerType}),onPointerMove:Nt(o.onPointerMove,M=>{var E;v.current=M.pointerType,a?(E=u.onItemLeave)==null||E.call(u):v.current==="mouse"&&M.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Nt(o.onPointerLeave,M=>{var E;M.currentTarget===document.activeElement&&((E=u.onItemLeave)==null||E.call(u))}),onKeyDown:Nt(o.onKeyDown,M=>{var L;((L=u.searchRef)==null?void 0:L.current)!==""&&M.key===" "||(F9.includes(M.key)&&k(),M.key===" "&&M.preventDefault())})})})})});P4.displayName=Sp;var ru="SelectItemText",I4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=Go(ru,n),c=Jo(ru,n),u=A4(ru,n),h=U9(ru,n),[f,m]=g.useState(null),x=Jt(e,k=>m(k),u.onItemTextChange,k=>{var M;return(M=c.itemTextRefCallback)==null?void 0:M.call(c,k,u.value,u.disabled)}),b=f==null?void 0:f.textContent,N=g.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:b},u.value),[u.disabled,u.value,b]),{onNativeOptionAdd:w,onNativeOptionRemove:v}=h;return Rs(()=>(w(N),()=>v(N)),[w,v,N]),s.jsxs(s.Fragment,{children:[s.jsx(St.span,{id:u.textId,...i,ref:x}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?id.createPortal(i.children,o.valueNode):null]})});I4.displayName=ru;var R4="SelectItemIndicator",L4=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return A4(R4,n).isSelected?s.jsx(St.span,{"aria-hidden":!0,...r,ref:e}):null});L4.displayName=R4;var z0="SelectScrollUpButton",O4=g.forwardRef((t,e)=>{const n=Jo(z0,t.__scopeSelect),r=lb(z0,t.__scopeSelect),[a,i]=g.useState(!1),o=Jt(e,r.onScrollButtonChange);return Rs(()=>{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(_4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});O4.displayName=z0;var F0="SelectScrollDownButton",D4=g.forwardRef((t,e)=>{const n=Jo(F0,t.__scopeSelect),r=lb(F0,t.__scopeSelect),[a,i]=g.useState(!1),o=Jt(e,r.onScrollButtonChange);return Rs(()=>{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(_4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});D4.displayName=F0;var _4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=Jo("SelectScrollButton",n),o=g.useRef(null),c=sm(n),u=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>u(),[u]),Rs(()=>{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(St.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:Nt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Nt(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Nt(a.onPointerLeave,()=>{u()})})}),sV="SelectSeparator",rV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(St.div,{"aria-hidden":!0,...r,ref:e})});rV.displayName=sV;var B0="SelectArrow",aV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=rm(n),i=Go(B0,n),o=Jo(B0,n);return i.open&&o.position==="popper"?s.jsx(D9,{...a,...r,ref:e}):null});aV.displayName=B0;var iV="SelectBubbleInput",$4=g.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const a=g.useRef(null),i=Jt(r,a),o=oy(e);return g.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(St.select,{...n,style:{...m4,...n.style},ref:i,defaultValue:e})});$4.displayName=iV;function z4(t){return t===""||t===void 0}function F4(t){const e=Lo(t),n=g.useRef(""),r=g.useRef(0),a=g.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=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function B4(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=oV(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 oV(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var lV=x4,V4=y4,cV=v4,dV=N4,uV=w4,H4=j4,hV=E4,U4=P4,fV=I4,pV=L4,mV=O4,xV=D4;const yo=lV,bo=cV,vi=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(V4,{ref:r,className:Dt("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(dV,{asChild:!0,children:s.jsx(Mi,{className:"h-4 w-4 opacity-50"})})]}));vi.displayName=V4.displayName;const Ni=g.forwardRef(({className:t,children:e,position:n="popper",...r},a)=>s.jsx(uV,{children:s.jsxs(H4,{ref:a,className:Dt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-[#0b1828] border-gray-700 text-white shadow-lg",n==="popper"&&"data-[side=bottom]:translate-y-1",t),position:n,...r,children:[s.jsx(mV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Dg,{className:"h-4 w-4"})}),s.jsx(hV,{className:"p-1",children:e}),s.jsx(xV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Mi,{className:"h-4 w-4"})})]})}));Ni.displayName=H4.displayName;const Gn=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(U4,{ref:r,className:Dt("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(pV,{children:s.jsx(Tp,{className:"h-4 w-4"})})}),s.jsx(fV,{children:e})]}));Gn.displayName=U4.displayName;const vj=["📖","📕","📗","📘","📙","📓","📔","📒","📚","📖"];function gV(t){return t.title==="序言"||t.title.includes("序言")}function Nj(t){const e=[];for(const n of t.chapters)for(const r of n.sections)e.push(r.id);return e.length===0?"暂无章节":e.length===1?e[0]:`${e[0]}~${e[e.length-1]}`}function Cg(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 yV({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:x=[],onToggleSectionSelect:b,onShowSectionOrders:N,pinnedSectionIds:w=[]}){const[v,k]=g.useState(null),[M,E]=g.useState(null),L=(_,se)=>(v==null?void 0:v.type)===_&&(v==null?void 0:v.id)===se,R=(_,se)=>(M==null?void 0:M.type)===_&&(M==null?void 0:M.id)===se,W=g.useCallback(()=>{const _=[];for(const se of t)for(const ce of se.chapters)for(const me of ce.sections)_.push({id:me.id,partId:se.id,partTitle:se.title,chapterId:ce.id,chapterTitle:ce.title});return _},[t]),P=g.useCallback(async(_,se,ce,me)=>{var ee;_.preventDefault(),_.stopPropagation();const I=_.dataTransfer.getData("text/plain"),X=Cg(I);if(!X||X.type===se&&X.id===ce)return;const V=W(),xe=new Map(V.map(H=>[H.id,H]));if(X.type==="part"&&se==="part"){const H=t.map($=>$.id),K=H.indexOf(X.id),fe=H.indexOf(ce);if(K===-1||fe===-1)return;const he=[...H];he.splice(K,1),he.splice(Kz.id===$);if(Q)for(const z of Q.chapters)for(const te of z.sections){const ie=xe.get(te.id);ie&&ue.push(ie)}}await r(ue);return}if(X.type==="chapter"&&(se==="chapter"||se==="section"||se==="part")){const H=t.find(ie=>ie.chapters.some(we=>we.id===X.id)),K=H==null?void 0:H.chapters.find(ie=>ie.id===X.id);if(!H||!K)return;let fe,he,ue=null;if(se==="section"){const ie=xe.get(ce);if(!ie)return;fe=ie.partId,he=ie.partTitle,ue=ce}else if(se==="chapter"){const ie=t.find(Ue=>Ue.chapters.some(yt=>yt.id===ce)),we=ie==null?void 0:ie.chapters.find(Ue=>Ue.id===ce);if(!ie||!we)return;fe=ie.id,he=ie.title;const Be=V.filter(Ue=>Ue.chapterId===ce).pop();ue=(Be==null?void 0:Be.id)??null}else{const ie=t.find(we=>we.id===ce);if(!ie)return;if(fe=ie.id,he=ie.title,ie.chapters[0]){const we=V.filter(Be=>Be.partId===ie.id&&Be.chapterId===ie.chapters[0].id);ue=((ee=we[we.length-1])==null?void 0:ee.id)??null}}const $=K.sections.map(ie=>ie.id),Q=V.filter(ie=>!$.includes(ie.id));let z=Q.length;if(ue){const ie=Q.findIndex(we=>we.id===ue);ie>=0&&(z=ie+1)}const te=$.map(ie=>({...xe.get(ie),partId:fe,partTitle:he,chapterId:K.id,chapterTitle:K.title}));await r([...Q.slice(0,z),...te,...Q.slice(z)]);return}if(X.type==="section"&&(se==="section"||se==="chapter"||se==="part")){if(!me)return;const{partId:H,partTitle:K,chapterId:fe,chapterTitle:he}=me,ue=V.findIndex(ie=>ie.id===X.id);if(ue===-1)return;const $=V.filter(ie=>ie.id!==X.id);let Q;if(se==="section"){const ie=$.findIndex(we=>we.id===ce);Q=ie>=0?ie+1:$.length}else if(se==="chapter"){const ie=$.filter(we=>we.chapterId===ce).pop();Q=ie?$.findIndex(we=>we.id===ie.id)+1:$.length}else{const ie=t.find(we=>we.id===ce);if(ie!=null&&ie.chapters[0]){const we=$.filter(Ue=>Ue.partId===ie.id&&Ue.chapterId===ie.chapters[0].id),Be=we[we.length-1];Q=Be?$.findIndex(Ue=>Ue.id===Be.id)+1:$.length}else Q=$.length}const te={...V[ue],partId:H,partTitle:K,chapterId:fe,chapterTitle:he};$.splice(Q,0,te),await r($)}},[t,W,r]),B=(_,se,ce)=>({onDragEnter:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",E({type:_,id:se})},onDragOver:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",E({type:_,id:se})},onDragLeave:()=>E(null),onDrop:me=>{E(null);const I=Cg(me.dataTransfer.getData("text/plain"));I&&(_==="section"&&I.type==="section"&&I.id===se||(_==="part"?I.type==="part"?P(me,"part",se):ce&&P(me,"part",se,ce):_==="chapter"&&ce?(I.type==="section"||I.type==="chapter")&&P(me,"chapter",se,ce):_==="section"&&ce&&P(me,"section",se,ce)))}}),O=_=>vj[_%vj.length],Y=_=>t.slice(0,_).filter(se=>!gV(se)).length,ae=_=>s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-500 font-mono text-xs tabular-nums shrink-0 mr-1.5 max-w-[72px] truncate",title:`章节ID: ${_.id}`,children:_.id}),s.jsx("span",{className:"truncate",children:_.title})]});return s.jsx("div",{className:"space-y-3",children:t.map((_,se)=>{var K,fe,he,ue;const ce=_.title==="序言"||_.title.includes("序言"),me=_.title==="尾声"||_.title.includes("尾声"),I=_.title==="附录"||_.title.includes("附录"),X=R("part",_.id),V=e.includes(_.id),xe=_.chapters.length,ee=_.chapters.reduce(($,Q)=>$+Q.sections.length,0);if(ce&&_.chapters.length===1&&_.chapters[0].sections.length===1){const $=_.chapters[0].sections[0],Q=R("section",$.id),z={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:te=>{te.stopPropagation(),te.dataTransfer.setData("text/plain","section:"+$.id),te.dataTransfer.effectAllowed="move",k({type:"section",id:$.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] ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",$.id,z),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(ci,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:te=>te.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes($.id),onChange:()=>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(or,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",$.title]}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),children:[$.price===0||$.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:["¥",$.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",$.clickCount??0," · 付款 ",$.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",($.hotScore??0).toFixed(1)," · 第",$.hotRank&&$.hotRank>0?$.hotRank:"-","名"]}),N&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N($),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}if(_.title==="2026每日派对干货"||_.title.includes("2026每日派对干货")){const $=R("part",_.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${$?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...B("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((K=_.chapters[0])==null?void 0:K.id)??"",chapterTitle:((fe=_.chapters[0])==null?void 0:fe.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","part:"+_.id),Q.dataTransfer.effectAllowed="move",k({type:"part",id:_.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ci,{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:_.badgeText||"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Nj(_)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>Q.stopPropagation(),children:[o&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),f&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",ee," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:V?"收起":"展开",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),n(_.id)},children:V?s.jsx(Mi,{className:"w-5 h-5"}):s.jsx(wi,{className:"w-5 h-5"})})]})]}),V&&_.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(Q=>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:Q.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:z=>z.stopPropagation(),children:[m&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>m(_,Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),c&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>u(_,Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:Q.sections.map(z=>{const te=R("section",z.id);return s.jsxs("div",{draggable:!0,onDragStart:ie=>{ie.stopPropagation(),ie.dataTransfer.setData("text/plain","section:"+z.id),ie.dataTransfer.effectAllowed="move",k({type:"section",id:z.id})},onDragEnd:()=>{k(null),E(null)},onClick:()=>a(z),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${te?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",z.id,{partId:_.id,partTitle:_.title,chapterId:Q.id,chapterTitle:Q.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ie=>ie.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(z.id),onChange:()=>b(z.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ae(z)}),w.includes(z.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:ie=>ie.stopPropagation(),children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",z.clickCount??0," · 付款 ",z.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(z.hotScore??0).toFixed(1)," · 第",z.hotRank&&z.hotRank>0?z.hotRank:"-","名"]}),N&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(z),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(z),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]},z.id)})})]},Q.id))})]},_.id)}if(I)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(($,Q)=>$.sections.length>0?$.sections.map(z=>{const te=R("section",z.id);return s.jsxs("div",{draggable:!0,onDragStart:ie=>{ie.stopPropagation(),ie.dataTransfer.setData("text/plain","section:"+z.id),ie.dataTransfer.effectAllowed="move",k({type:"section",id:z.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 ${te?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",z.id,{partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ie=>ie.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(z.id),onChange:()=>b(z.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:["附录",Q+1," | ",$.title," | ",z.title]}),w.includes(z.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:["点击 ",z.clickCount??0," · 付款 ",z.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(z.hotScore??0).toFixed(1)," · 第",z.hotRank&&z.hotRank>0?z.hotRank:"-","名"]}),N&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(z),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(J,{variant:"ghost",size:"sm",onClick:()=>a(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>i(z),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(wi,{className:"w-4 h-4 text-gray-500 shrink-0"})]},z.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:["附录",Q+1," | ",$.title,"(空)"]}),s.jsx(wi,{className:"w-4 h-4 text-gray-500 shrink-0"})]},$.id))})]},_.id);if(me&&_.chapters.length===1&&_.chapters[0].sections.length===1){const $=_.chapters[0].sections[0],Q=R("section",$.id),z={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:te=>{te.stopPropagation(),te.dataTransfer.setData("text/plain","section:"+$.id),te.dataTransfer.effectAllowed="move",k({type:"section",id:$.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] ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",$.id,z),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(ci,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:te=>te.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes($.id),onChange:()=>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(or,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",$.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),children:[$.price===0||$.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:["¥",$.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",$.clickCount??0," · 付款 ",$.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",($.hotScore??0).toFixed(1)," · 第",$.hotRank&&$.hotRank>0?$.hotRank:"-","名"]}),N&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N($),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}return me?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($=>$.sections.map(Q=>{const z=R("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:te=>{te.stopPropagation(),te.dataTransfer.setData("text/plain","section:"+Q.id),te.dataTransfer.effectAllowed="move",k({type:"section",id:Q.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 ${z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:te=>te.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(Q.id),onChange:()=>b(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",children:[$.title," | ",Q.title]})]}),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:"-","名"]}),N&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(Q),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},Q.id)}))})]},_.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${X?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...B("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((he=_.chapters[0])==null?void 0:he.id)??"",chapterTitle:((ue=_.chapters[0])==null?void 0:ue.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:$=>{$.stopPropagation(),$.dataTransfer.setData("text/plain","part:"+_.id),$.dataTransfer.effectAllowed="move",k({type:"part",id:_.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ci,{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-lg shadow-lg shadow-[#38bdac]/30 shrink-0",children:_.badgeText||O(Y(se))}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Nj(_)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:$=>$.stopPropagation(),onClick:$=>$.stopPropagation(),children:[o&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),f&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",ee," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:V?"收起":"展开",onMouseDown:$=>$.stopPropagation(),onClick:$=>{$.stopPropagation(),n(_.id)},children:V?s.jsx(Mi,{className:"w-5 h-5"}):s.jsx(wi,{className:"w-5 h-5"})})]})]}),V&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map($=>{const Q=R("chapter",$.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:z=>{z.stopPropagation(),z.dataTransfer.setData("text/plain","chapter:"+$.id),z.dataTransfer.effectAllowed="move",k({type:"chapter",id:$.id})},onDragEnd:()=>{k(null),E(null)},onDragEnter:z=>{z.preventDefault(),z.stopPropagation(),z.dataTransfer.dropEffect="move",E({type:"chapter",id:$.id})},onDragOver:z=>{z.preventDefault(),z.stopPropagation(),z.dataTransfer.dropEffect="move",E({type:"chapter",id:$.id})},onDragLeave:()=>E(null),onDrop:z=>{E(null);const te=Cg(z.dataTransfer.getData("text/plain"));if(!te)return;const ie={partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title};(te.type==="section"||te.type==="chapter")&&P(z,"chapter",$.id,ie)},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 ${Q?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${L("chapter",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(ci,{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:$.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:z=>z.stopPropagation(),children:[m&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>m(_,$),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),c&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>u(_,$),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:$.sections.map(z=>{const te=R("section",z.id);return s.jsxs("div",{draggable:!0,onDragStart:ie=>{ie.stopPropagation(),ie.dataTransfer.setData("text/plain","section:"+z.id),ie.dataTransfer.effectAllowed="move",k({type:"section",id:z.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 ${te?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...B("section",z.id,{partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ie=>ie.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(z.id),onChange:()=>b(z.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${z.price===0||z.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),s.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ae(z)}),w.includes(z.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:ie=>ie.stopPropagation(),onClick:ie=>ie.stopPropagation(),children:[z.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),z.price===0||z.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:["¥",z.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",z.clickCount??0," · 付款 ",z.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(z.hotScore??0).toFixed(1)," · 第",z.hotRank&&z.hotRank>0?z.hotRank:"-","名"]}),N&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(z),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(z),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},z.id)})})]},$.id)})})]},_.id)})})}function bV(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 Re(r)}function vV(t){return Re(`/api/db/person?personId=${encodeURIComponent(t)}`)}function NV(t){var r;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(r=t==null?void 0:t.keyword)!=null&&r.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString();return Re(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const wV=10;function W4(t){const e=(t??"").trim();if(!e)return"";if(/^https?:\/\//i.test(e))return aa(e);const n=e.startsWith("/")?e:`/${e}`;return aa(zl(n))}function jV(t){const{nickname:e,avatar:n}=t,r=W4(n);return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"h-8 w-8 shrink-0 overflow-hidden rounded-full bg-gray-800",children:r?s.jsx("img",{src:r,alt:"",className:"h-full w-full object-cover",onError:a=>{a.currentTarget.style.display="none"}}):s.jsx("span",{className:"flex h-full w-full items-center justify-center text-[10px] text-gray-500",children:e.slice(0,1)})}),s.jsx("span",{className:"min-w-0 truncate text-left font-medium text-white",children:e})]})}function kV(t,e){const n=new Set(t.map(a=>a.id).filter(Boolean)),r=[...t];for(const a of e){const i=a.id;i&&!n.has(i)&&(n.add(i),r.push(a))}return r}function SV({id:t,label:e,value:n,preview:r,previewLoading:a=!1,onSelect:i,onClear:o,containerOpen:c,disabled:u=!1,hint:h,className:f,portalMountRef:m,positionContainerRef:x}){const[b,N]=g.useState(!1),[w,v]=g.useState(""),k=Ra(w,300),[M,E]=g.useState([]),[L,R]=g.useState(!1),[W,P]=g.useState(!1),[B,O]=g.useState(0),Y=g.useRef(1),ae=g.useRef(!1),_=g.useRef(!1),se=g.useRef(null),ce=g.useRef(null),[me,I]=g.useState({top:0,left:0,width:320,maxH:360}),X=g.useCallback(()=>{const $=ce.current;if(!$||typeof window>"u")return;const Q=$.getBoundingClientRect(),z=Math.min(400,Math.max(200,window.innerHeight-Q.bottom-16)),te=x==null?void 0:x.current;if(te){const ie=te.getBoundingClientRect();I({top:Q.bottom-ie.top+6,left:Q.left-ie.left,width:Math.max(Q.width,300),maxH:z})}else I({top:Q.bottom+6,left:Q.left,width:Math.max(Q.width,300),maxH:z})},[x]);g.useEffect(()=>{c||(N(!1),v(""))},[c]),g.useLayoutEffect(()=>{if(b)return X(),window.addEventListener("scroll",X,!0),window.addEventListener("resize",X),()=>{window.removeEventListener("scroll",X,!0),window.removeEventListener("resize",X)}},[b,X]);const V=g.useCallback(async($,Q,z)=>{if(!ae.current){ae.current=!0,z?P(!0):R(!0);try{const te=new URLSearchParams({page:String($),pageSize:String(wV),search:Q.trim()}),ie=await Re(`/api/db/users?${te}`);if(ie!=null&&ie.success&&Array.isArray(ie.users)){const we=ie.users,Be=typeof ie.total=="number"?ie.total:0;O(Be),z?we.length===0?_.current=!0:E(Ue=>{const yt=kV(Ue,we);return yt.length===Ue.length?_.current=!0:Y.current=$,yt}):(E(we),Y.current=$)}else ie!=null&&ie.error&&G.error(ie.error)}catch(te){G.error(te instanceof Error?te.message:"加载用户列表失败")}finally{ae.current=!1,R(!1),P(!1)}}},[]);g.useEffect(()=>{b&&(Y.current=1,_.current=!1,V(1,k,!1))},[b,k,V]);const xe=g.useCallback(()=>{L||W||ae.current||_.current||B>0&&M.length>=B||V(Y.current+1,k,!0)},[k,V,L,W,B,M.length]);g.useLayoutEffect(()=>{if(!b||L||W||_.current||B>0&&M.length>=B||M.length===0)return;const $=se.current;$&&($.scrollHeight>$.clientHeight+12||xe())},[b,M.length,L,W,B,xe]);const ee=$=>{($.id||"").trim()&&(i($),N(!1),v(""))},H=$=>{$.preventDefault(),$.stopPropagation(),!(u||a)&&o()},K=!!n.trim(),fe=B>0,he=typeof document>"u"?null:(m==null?void 0:m.current)??document.body,ue=b&&he&&id.createPortal(s.jsxs("div",{"data-member-user-select-portal":"",children:[s.jsx("div",{className:"fixed inset-0 z-40 bg-transparent","aria-hidden":!0,onMouseDown:$=>{$.preventDefault(),N(!1)}}),s.jsxs("div",{role:"listbox",className:"fixed z-50 overflow-hidden rounded-lg border border-gray-700 bg-[#0b1828] shadow-xl",style:{top:me.top,left:me.left,width:me.width,height:me.maxH,maxHeight:me.maxH,display:"grid",gridTemplateRows:fe?"auto auto minmax(0, 1fr) auto":"auto minmax(0, 1fr) auto"},children:[s.jsx("div",{className:"border-b border-gray-700/60 p-2 min-h-0",children:s.jsx(le,{className:"bg-[#050c18] border-gray-700 text-white h-9 text-sm",placeholder:"搜索昵称、手机号、用户 id…",value:w,onChange:$=>v($.target.value),onMouseDown:$=>$.stopPropagation(),autoFocus:!0})}),fe?s.jsxs("p",{className:"text-[11px] text-gray-500 px-3 pt-1.5 min-h-0 leading-snug",children:["已加载 ",M.length," / ",B," 条",M.length{const Q=$.currentTarget;L||W||_.current||B>0&&M.length>=B||Q.scrollHeight-Q.scrollTop-Q.clientHeight<100&&xe()},children:L&&M.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-gray-400 text-sm",children:"正在加载…"}):M.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-gray-500 text-sm px-3 text-center",children:"暂无用户,请调整搜索条件"}):s.jsxs("div",{className:"p-1.5 space-y-0.5",children:[M.map($=>{const Q=$.id||"",z=n===Q,te=W4($.avatar),ie=$.nickname&&String($.nickname).trim()||"(无昵称)";return s.jsxs("button",{type:"button",role:"option","aria-selected":z,className:Dt("flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left text-sm transition-colors",z?"border-[#38bdac] bg-[#38bdac]/15 text-white":"border-transparent bg-[#050c18] hover:border-[#38bdac]/40 hover:bg-[#0a1628]"),onMouseDown:we=>we.preventDefault(),onClick:()=>ee($),children:[s.jsx("span",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-gray-800",children:te?s.jsx("img",{src:te,alt:"",className:"h-full w-full object-cover",onError:we=>{we.currentTarget.style.display="none"}}):s.jsx("span",{className:"flex h-full w-full items-center justify-center text-[11px] text-gray-500",children:ie.slice(0,1)})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium truncate",children:ie}),s.jsxs("div",{className:"text-[11px] text-gray-500 font-mono truncate mt-0.5",children:[$.phone?`${$.phone} · `:"",Q]})]})]},Q)}),W&&s.jsx("div",{className:"py-2 text-center text-gray-500 text-xs",children:"加载更多…"})]})}),s.jsx("div",{className:"flex justify-end gap-2 border-t border-gray-700/60 px-2 py-1.5 min-h-0",children:s.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-gray-400 h-8 text-xs",onMouseDown:$=>$.preventDefault(),onClick:()=>{o(),N(!1)},children:"清除绑定"})})]})]}),he);return s.jsxs("div",{className:Dt("space-y-1.5",f),children:[typeof e=="string"?s.jsx(ne,{htmlFor:t,className:"text-gray-400 text-xs",children:e}):e,s.jsxs("div",{className:"flex gap-2 items-stretch",children:[s.jsxs("button",{ref:ce,id:t,type:"button",disabled:u,"aria-haspopup":"listbox","aria-expanded":b,className:Dt("flex h-10 min-w-0 flex-1 items-center gap-2 rounded-md border bg-[#0a1628] px-3 text-left text-sm transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac]/50 focus-visible:ring-offset-0",u&&"cursor-not-allowed opacity-50",b?"border-[#38bdac] ring-1 ring-[#38bdac]/35":"border-gray-700 hover:border-gray-600"),onClick:()=>{u||(b||(v(""),X()),N($=>!$))},children:[s.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-2 truncate",children:a?s.jsx("span",{className:"text-gray-500",children:"正在加载已绑定用户…"}):K?s.jsx(jV,{nickname:(r==null?void 0:r.nickname)||n,avatar:r==null?void 0:r.avatar}):s.jsx("span",{className:"text-gray-500",children:"选择会员用户(可搜索,可不绑定)"})}),s.jsx(Mi,{className:Dt("h-4 w-4 shrink-0 text-gray-400 transition-transform",b&&"rotate-180")})]}),K&&s.jsx(J,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0 border-gray-600 text-gray-400 hover:text-white",disabled:u||a,"aria-label":"清除已选用户",onClick:H,children:s.jsx(Qn,{className:"h-4 w-4"})})]}),h&&s.jsx("div",{className:"text-[11px] text-gray-500",children:h}),ue]})}const K4=11,wj={personId:"",name:"",boundUserId:"",aliases:"",label:"",sceneId:K4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"06:00",endTime:"22:00",deviceGroups:""};function CV({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){var Q;const a=!!n,i=g.useRef(null),o=g.useRef(null),[c,u]=g.useState(wj),[h,f]=g.useState(!1),[m,x]=g.useState(!1),[b,N]=g.useState([]),[w,v]=g.useState(!1),[k,M]=g.useState(""),[E,L]=g.useState([]),[R,W]=g.useState(!1),[P,B]=g.useState(""),[O,Y]=g.useState(!1),[ae,_]=g.useState(null),[se,ce]=g.useState(!1),[me,I]=g.useState({}),[X,V]=g.useState({loading:!1,messages:[]}),xe=Ra(c.name,400),ee=Ra(c.aliases,400);g.useEffect(()=>{if(!t){V({loading:!1,messages:[]});return}const z=xe.trim(),te=ee.trim();if(!z&&!te){V({loading:!1,messages:[]});return}let ie=!1;V(Ue=>({...Ue,loading:!0}));const we=a?((n==null?void 0:n.personId)??"").trim():"",Be=new URLSearchParams;return z&&Be.set("name",xe.trim()),Be.set("aliases",ee),we&&Be.set("excludePersonId",we),Re(`/api/db/persons/check-unique?${Be.toString()}`).then(Ue=>{if(!ie){if((Ue==null?void 0:Ue.success)===!1&&(Ue!=null&&Ue.error)){V({loading:!1,messages:[Ue.error]});return}if((Ue==null?void 0:Ue.ok)===!1&&Array.isArray(Ue.messages)&&Ue.messages.length>0){V({loading:!1,messages:Ue.messages});return}V({loading:!1,messages:[]})}}).catch(()=>{ie||V({loading:!1,messages:[]})}),()=>{ie=!0}},[t,xe,ee,a,n==null?void 0:n.personId]),g.useEffect(()=>{if(t){if(M(""),_(null),ce(!1),n){u({personId:n.personId??n.name??"",name:n.name??"",boundUserId:n.userId??"",aliases:n.aliases??"",label:n.label??"",sceneId:K4,ckbApiKey:n.ckbApiKey??"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:n.remarkType??"phone",remarkFormat:n.remarkFormat??"",addFriendInterval:n.addFriendInterval??1,startTime:n.startTime??"06:00",endTime:n.endTime??"22:00",deviceGroups:n.deviceGroups??""});const z=(n.userId??"").trim();z&&(ce(!0),Re(`/api/db/users?id=${encodeURIComponent(z)}`).then(te=>{const ie=te==null?void 0:te.user;ie!=null&&ie.id?_({id:ie.id,nickname:ie.nickname&&String(ie.nickname).trim()||ie.id,phone:ie.phone,avatar:ie.avatar??void 0}):_({id:z,nickname:z,phone:void 0,avatar:void 0})}).catch(()=>{_({id:z,nickname:z,phone:void 0,avatar:void 0})}).finally(()=>ce(!1)))}else u({...wj});I({}),b.length===0&&H(""),E.length===0&&K("")}},[t,n]);const H=async z=>{v(!0);try{const te=await bV({page:1,limit:50,keyword:z});te!=null&&te.success&&Array.isArray(te.devices)?N(te.devices):te!=null&&te.error&&G.error(te.error)}catch(te){G.error(te instanceof Error?te.message:"加载设备列表失败")}finally{v(!1)}},K=async z=>{W(!0);try{const te=await NV({page:1,limit:100,keyword:z});te!=null&&te.success&&Array.isArray(te.plans)?L(te.plans):te!=null&&te.error&&G.error(te.error)}catch{G.error("加载计划列表失败")}finally{W(!1)}},fe=()=>{u(z=>{const te=(z.boundUserId||"").trim(),ie={...z,boundUserId:""};return!a&&te&&(z.personId||"").trim()===te&&(ie.personId=""),ie}),_(null)},he=z=>{const te=Array.isArray(z.deviceGroups)?z.deviceGroups.map(String).join(","):"";u(ie=>({...ie,ckbApiKey:z.apiKey||"",greeting:z.greeting||ie.greeting,tips:z.tips||ie.tips,remarkType:z.remarkType||ie.remarkType,remarkFormat:z.remarkFormat||ie.remarkFormat,addFriendInterval:z.addInterval||ie.addFriendInterval,startTime:z.startTime||ie.startTime,endTime:z.endTime||ie.endTime,deviceGroups:te||ie.deviceGroups})),Y(!1),G.success(`已选择计划「${z.name}」,参数已覆盖`)},ue=P.trim()?E.filter(z=>(z.name||"").includes(P.trim())||String(z.id).includes(P.trim())):E,$=async()=>{var we;const z={};(!c.name||!String(c.name).trim())&&(z.name="请填写名称");const te=c.addFriendInterval;if((typeof te!="number"||te<1)&&(z.addFriendInterval="添加间隔至少为 1 分钟"),(((we=c.deviceGroups)==null?void 0:we.split(",").map(Be=>Be.trim()).filter(Boolean))??[]).length===0&&(z.deviceGroups="请至少选择 1 台设备"),I(z),Object.keys(z).length>0){G.error(z.name||z.addFriendInterval||z.deviceGroups||"请完善必填项");return}if(X.messages.length>0){G.error(X.messages[0]??"名称或别名与他人重复");return}f(!0);try{await r(c),e(!1)}catch(Be){G.error(Be instanceof Error?Be.message:"保存失败")}finally{f(!1)}};return s.jsx(Pt,{open:t,onOpenChange:e,children:s.jsxs(Mt,{ref:i,className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex min-h-0 flex-col gap-0 p-0",children:[s.jsxs("div",{ref:o,className:"relative flex min-h-0 flex-1 flex-col overflow-visible",children:[s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pt-6",children:[s.jsxs(It,{children:[s.jsx(Rt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Oo,{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(ne,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(le,{className:`bg-[#0a1628] text-white ${me.name?"border-red-500 focus-visible:ring-red-500":X.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡若",value:c.name,onChange:z=>{u(te=>({...te,name:z.target.value})),me.name&&I(te=>({...te,name:void 0}))}}),me.name&&s.jsx("p",{className:"text-xs text-red-400",children:me.name})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:(c.boundUserId||"").trim()?c.boundUserId:c.personId,onChange:z=>u(te=>({...te,personId:z.target.value})),disabled:a||!!(c.boundUserId||"").trim()})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:c.label,onChange:z=>u(te=>({...te,label:z.target.value}))})]}),s.jsx(SV,{className:"col-span-3",id:"person-bound-member-user",label:"绑定会员用户(可选,与「用户管理」中用户一致)",containerOpen:t,portalMountRef:o,positionContainerRef:i,value:c.boundUserId,preview:ae,previewLoading:se,onSelect:z=>{const te=(z.id||"").trim();te&&(u(ie=>({...ie,boundUserId:te,...a?{}:{personId:te}})),_({id:te,nickname:z.nickname&&String(z.nickname).trim()||te,phone:z.phone,avatar:z.avatar??void 0}))},onClear:fe,hint:s.jsx("span",{children:"单选;保存时后端校验用户是否存在。同一会员只能绑定一个 @人物;绑定后获客统计可与超级个体对齐。"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),s.jsx(le,{className:`bg-[#0a1628] text-white ${X.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡卡, 若若",value:c.aliases,onChange:z=>u(te=>({...te,aliases:z.target.value}))})]}),s.jsx("div",{className:"col-span-3 space-y-1",children:X.loading?s.jsx("p",{className:"text-xs text-gray-500",children:"正在检测名称与别名是否与他人重复…"}):X.messages.length>0?s.jsx("div",{className:"rounded-md border border-amber-600/60 bg-amber-950/25 px-3 py-2 text-xs text-amber-200 space-y-1",children:X.messages.map((z,te)=>s.jsx("p",{children:z},`${te}-${z.slice(0,24)}`))}):null})]})]}),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 relative",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"选择存客宝获客计划"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("div",{className:"flex-1 flex items-center bg-[#0a1628] border border-gray-700 rounded-md px-3 py-2 cursor-pointer hover:border-[#38bdac]/60 text-sm",onClick:()=>Y(!O),children:c.ckbApiKey?s.jsx("span",{className:"text-white truncate",children:((Q=E.find(z=>z.apiKey===c.ckbApiKey))==null?void 0:Q.name)||`获客计划 (${c.ckbApiKey.slice(0,8)}…)`}):s.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),s.jsx(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{K(P),Y(!0)},disabled:R,children:R?"加载...":"刷新"})]}),O&&s.jsxs("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-[#0b1828] border border-gray-700 rounded-lg shadow-xl max-h-64 flex flex-col",children:[s.jsx("div",{className:"p-2 border-b border-gray-700/60",children:s.jsx(le,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:P,onChange:z=>B(z.target.value),onKeyDown:z=>{z.key==="Enter"&&K(P)},autoFocus:!0})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:ue.length===0?s.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:R?"加载中...":"暂无计划"}):ue.map(z=>s.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${c.ckbApiKey===z.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>he(z),children:[s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-medium",children:z.name}),s.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String(z.id)]})]}),z.enabled?s.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 rounded shrink-0 ml-2",children:"启用"}):s.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 rounded shrink-0 ml-2",children:"停用"})]},String(z.id)))}),s.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>Y(!1),children:"关闭"})})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(ne,{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 ${me.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(le,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:c.deviceGroups?`已选择 ${c.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>x(!0)}),s.jsx(J,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>x(!0),children:"选择"})]}),me.deviceGroups?s.jsx("p",{className:"text-xs text-red-400",children:me.deviceGroups}):s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(yo,{value:c.remarkType,onValueChange:z=>u(te=>({...te,remarkType:z})),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(bo,{placeholder:"选择备注类型"})}),s.jsxs(Ni,{children:[s.jsx(Gn,{value:"phone",children:"手机号"}),s.jsx(Gn,{value:"nickname",children:"昵称"}),s.jsx(Gn,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"备注格式(手机号+标签,标签不超过6字)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 {手机号}-{来源标签},总长不超过10字",value:c.remarkFormat,onChange:z=>u(te=>({...te,remarkFormat:z.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"格式:手机号+来源标签(标签≤6字,总长≤10字)"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:c.greeting,onChange:z=>u(te=>({...te,greeting:z.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(le,{type:"number",min:1,className:`bg-[#0a1628] text-white ${me.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:c.addFriendInterval,onChange:z=>{u(te=>({...te,addFriendInterval:Number(z.target.value)||1})),me.addFriendInterval&&I(te=>({...te,addFriendInterval:void 0}))}}),me.addFriendInterval&&s.jsx("p",{className:"text-xs text-red-400",children:me.addFriendInterval})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(le,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.startTime,onChange:z=>u(te=>({...te,startTime:z.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(le,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.endTime,onChange:z=>u(te=>({...te,endTime:z.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:c.tips,onChange:z=>u(te=>({...te,tips:z.target.value}))})]})]})]})]})]})]}),s.jsxs(Xt,{className:"gap-3 border-t border-gray-700/40 px-6 py-4 shrink-0",children:[s.jsx(J,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(J,{onClick:$,disabled:h||X.messages.length>0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:h?"保存中...":a?"保存":"添加"})]})]}),m&&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(J,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>{const z=b.map(we=>String(we.id??"")),te=c.deviceGroups?c.deviceGroups.split(",").map(we=>we.trim()).filter(Boolean):[],ie=z.length>0&&z.every(we=>te.includes(we));u(we=>({...we,deviceGroups:ie?"":z.join(",")})),!ie&&z.length>0&&I(we=>({...we,deviceGroups:void 0}))},children:(()=>{const z=b.map(ie=>String(ie.id??"")),te=c.deviceGroups?c.deviceGroups.split(",").map(ie=>ie.trim()).filter(Boolean):[];return z.length>0&&z.every(ie=>te.includes(ie))?"取消全选":"全选"})()}),s.jsx(le,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:k,onChange:z=>M(z.target.value),onKeyDown:z=>{z.key==="Enter"&&H(k)}}),s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>H(k),disabled:w,children:"刷新"}),s.jsx(J,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>x(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:w?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):b.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:b.map(z=>{const te=String(z.id??""),ie=c.deviceGroups?c.deviceGroups.split(",").map(Ue=>Ue.trim()).filter(Boolean):[],we=ie.includes(te),Be=()=>{let Ue;we?Ue=ie.filter(yt=>yt!==te):Ue=[...ie,te],u(yt=>({...yt,deviceGroups:Ue.join(",")})),Ue.length>0&&I(yt=>({...yt,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:we,onChange:Be}),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:z.memo||z.wechatId||`设备 ${te}`}),z.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),z.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: ",te]}),z.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",z.wechatId]}),typeof z.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",z.totalFriend]})]})]})]},te)})})}),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:["已选择"," ",c.deviceGroups?c.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(J,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>x(!1),children:"取消"}),s.jsx(J,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>x(!1),children:"确定"})]})]})]})})]})})}const Eg=JSON.stringify({singlePageUnlockTitle:"解锁完整内容",singlePagePayButtonText:"支付 ¥{price} 解锁全文",singlePageExpandedHint:"预览页不能直接付款,务必先点底栏「前往小程序」。",payTapModalTitle:"解锁说明",payTapModalContent:"全文 ¥{price}。预览里无法完成支付:请先点屏幕底部「前往小程序」进入完整版,登录后再付款解锁。",fullUnlockTitle:"解锁完整内容",fullUnlockDesc:"可先上滑阅读预览;需要全文时,点下方「支付¥{price}」查看说明",fullLockedProgressText:"已阅读约 {percent}% ,购买后继续阅读",fullPaywallTip:"转发给需要的人,一起学习还能赚佣金",notLoginUnlockDesc:"已预览约 {percent}% 内容,登录并支付 ¥{price} 后阅读全文",notLoginPaywallTip:"分享给好友一起学习,还能赚取佣金",shareTipLine:"好友经你分享购买,你可获得约 90% 收益",momentsModalTitle:"分享到朋友圈",momentsModalContent:`已复制发圈文案(非分享给好友)。 + `).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");a&&r[c]&&a({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,a=o.command,n=0,i(),o.clientRect){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onUpdate:o=>{if(r=o.items,a=o.command,n=0,i(),o.clientRect&&e){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onKeyDown:o=>o.event.key==="ArrowUp"?(n=Math.max(0,n-1),i(),!0):o.event.key==="ArrowDown"?(n=Math.min(r.length-1,n+1),i(),!0):o.event.key==="Enter"?(a&&r[n]&&a({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}}}});function dB(t){var r;const e=[],n=(r=t.clipboardData)==null?void 0:r.items;if(!n)return e;for(let a=0;a{const h=g.useRef(null),f=g.useRef(null),m=g.useRef(null),x=g.useRef(null),[b,N]=g.useState(""),[w,v]=g.useState(!1),k=g.useRef(oj(t)),M=g.useCallback((ae,_)=>{var I;const se=x.current;if(!se||!n)return!1;const ce=dB(_);if(ce.length>0)return _.preventDefault(),(async()=>{for(const Z of ce)try{const V=await n(Z);V&&se.chain().focus().setImage({src:V}).run()}catch(V){console.error("粘贴图片上传失败",V)}})(),!0;const me=(I=_.clipboardData)==null?void 0:I.getData("text/html");if(me&&/data:image\/[^;"']+;base64,/i.test(me)){_.preventDefault();const{from:Z,to:V}=se.state.selection;return(async()=>{try{const xe=await fB(me,n);se.chain().focus().insertContentAt({from:Z,to:V},xe).run()}catch(xe){console.error("粘贴 HTML 内 base64 转换失败",xe)}})(),!0}return!1},[n]),E=e$({extensions:[Bz.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),Uz.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"rich-editor-img-thumb"}}),oB,Qz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:cB(a)}),lB,Yz.configure({placeholder:o}),K3.configure({resizable:!0}),W3,H3,U3],content:k.current,onUpdate:({editor:ae})=>{e(ae.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:M}});g.useEffect(()=>{x.current=E??null},[E]),g.useImperativeHandle(u,()=>({getHTML:()=>(E==null?void 0:E.getHTML())||"",getMarkdown:()=>iB((E==null?void 0:E.getHTML())||"")})),g.useEffect(()=>{if(E&&t!==E.getHTML()){const ae=oj(t);ae!==E.getHTML()&&E.commands.setContent(ae)}},[t]);const L=g.useCallback(async ae=>{if(r)return r(ae);if(n)return n(ae);throw new Error("未配置上传")},[n,r]),R=g.useCallback(async ae=>{var se;const _=(se=ae.target.files)==null?void 0:se[0];if(!(!_||!E)){if(n){const ce=await n(_);ce&&E.chain().focus().setImage({src:ce}).run()}else{const ce=new FileReader;ce.onload=()=>{typeof ce.result=="string"&&E.chain().focus().setImage({src:ce.result}).run()},ce.readAsDataURL(_)}ae.target.value=""}},[E,n]),W=g.useCallback(async ae=>{var se;const _=(se=ae.target.files)==null?void 0:se[0];if(!(!_||!E)){try{const ce=await L(_);ce&&E.chain().focus().insertContent({type:"videoEmbed",attrs:{src:ce}}).run()}catch(ce){console.error(ce)}ae.target.value=""}},[E,L]),P=g.useCallback(async ae=>{var se;const _=(se=ae.target.files)==null?void 0:se[0];if(!(!_||!E)){try{const ce=await L(_);if(!ce)return;const me=_.name||"附件";E.chain().focus().insertContent(`

附件 ${rB(me)}

`).run()}catch(ce){console.error(ce)}ae.target.value=""}},[E,L]),B=g.useCallback(()=>{E&&E.chain().focus().insertContent("@").run()},[E]),O=g.useCallback(ae=>{E&&E.chain().focus().insertContent([{type:"linkTag",attrs:{label:ae.label,url:ae.url||"",tagType:ae.type||"url",tagId:ae.id||"",pagePath:ae.pagePath||"",appId:ae.appId||"",mpKey:ae.type==="miniprogram"&&ae.appId||""}},{type:"text",text:" "}]).run()},[E]),X=g.useCallback(()=>{!E||!b||(E.chain().focus().setLink({href:b}).run(),N(""),v(!1))},[E,b]);return E?s.jsxs("div",{className:`rich-editor-wrapper ${c||""}`,children:[s.jsxs("div",{className:"rich-editor-toolbar",children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().toggleBold().run(),className:E.isActive("bold")?"is-active":"",type:"button",children:s.jsx(wT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleItalic().run(),className:E.isActive("italic")?"is-active":"",type:"button",children:s.jsx(SM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleStrike().run(),className:E.isActive("strike")?"is-active":"",type:"button",children:s.jsx(PA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleCode().run(),className:E.isActive("code")?"is-active":"",type:"button",children:s.jsx(HT,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().toggleHeading({level:1}).run(),className:E.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(mM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleHeading({level:2}).run(),className:E.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(gM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleHeading({level:3}).run(),className:E.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(bM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().toggleBulletList().run(),className:E.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(OM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleOrderedList().run(),className:E.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(rk,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().toggleBlockquote().run(),className:E.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(lA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(qM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:R,className:"hidden"}),s.jsx("input",{ref:f,type:"file",accept:"video/*",onChange:W,className:"hidden"}),s.jsx("input",{ref:m,type:"file",onChange:P,className:"hidden"}),s.jsx("button",{onClick:()=>{var ae;return(ae=h.current)==null?void 0:ae.click()},type:"button",title:"上传图片",children:s.jsx(sk,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var ae;return(ae=f.current)==null?void 0:ae.click()},type:"button",title:"上传视频",disabled:!r&&!n,children:s.jsx(KA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var ae;return(ae=m.current)==null?void 0:ae.click()},type:"button",title:"上传附件(生成下载链接)",disabled:!r&&!n,children:s.jsx(XM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:B,type:"button",title:"插入 @ 并选择人物",className:a.length?"mention-trigger-btn":"",disabled:a.length===0,children:s.jsx(gT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v(!w),className:E.isActive("link")?"is-active":"",type:"button",title:"链接",children:s.jsx(Fg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",title:"表格",children:s.jsx(RA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>E.chain().focus().undo().run(),disabled:!E.can().undo(),type:"button",children:s.jsx(FA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E.chain().focus().redo().run(),disabled:!E.can().redo(),type:"button",children:s.jsx(dA,{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:ae=>{const _=i.find(se=>se.id===ae.target.value);_&&O(_),ae.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(ae=>s.jsx("option",{value:ae.id,children:ae.label},ae.id))]})})]})]}),w&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:b,onChange:ae=>N(ae.target.value),onKeyDown:ae=>ae.key==="Enter"&&X(),className:"link-input"}),s.jsx("button",{onClick:X,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{E.chain().focus().unsetLink().run(),v(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(s3,{editor:E})]}):null});R0.displayName="RichEditor";const pB=["top","right","bottom","left"],zo=Math.min,xr=Math.max,Np=Math.round,hf=Math.floor,Ia=t=>({x:t,y:t}),mB={left:"right",right:"left",bottom:"top",top:"bottom"},xB={start:"end",end:"start"};function L0(t,e,n){return xr(t,zo(e,n))}function Mi(t,e){return typeof t=="function"?t(e):t}function Ai(t){return t.split("-")[0]}function fd(t){return t.split("-")[1]}function eb(t){return t==="x"?"y":"x"}function tb(t){return t==="y"?"height":"width"}const gB=new Set(["top","bottom"]);function Pa(t){return gB.has(Ai(t))?"y":"x"}function nb(t){return eb(Pa(t))}function yB(t,e,n){n===void 0&&(n=!1);const r=fd(t),a=nb(t),i=tb(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=wp(o)),[o,wp(o)]}function bB(t){const e=wp(t);return[O0(t),e,O0(e)]}function O0(t){return t.replace(/start|end/g,e=>xB[e])}const cj=["left","right"],dj=["right","left"],vB=["top","bottom"],NB=["bottom","top"];function wB(t,e,n){switch(t){case"top":case"bottom":return n?e?dj:cj:e?cj:dj;case"left":case"right":return e?vB:NB;default:return[]}}function jB(t,e,n,r){const a=fd(t);let i=wB(Ai(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(O0)))),i}function wp(t){return t.replace(/left|right|bottom|top/g,e=>mB[e])}function kB(t){return{top:0,right:0,bottom:0,left:0,...t}}function q3(t){return typeof t!="number"?kB(t):{top:t,right:t,bottom:t,left:t}}function jp(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 uj(t,e,n){let{reference:r,floating:a}=t;const i=Pa(e),o=nb(e),c=tb(o),u=Ai(e),h=i==="y",f=r.x+r.width/2-a.width/2,m=r.y+r.height/2-a.height/2,x=r[c]/2-a[c]/2;let b;switch(u){case"top":b={x:f,y:r.y-a.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:m};break;case"left":b={x:r.x-a.width,y:m};break;default:b={x:r.x,y:r.y}}switch(fd(e)){case"start":b[o]-=x*(n&&h?-1:1);break;case"end":b[o]+=x*(n&&h?-1:1);break}return b}async function SB(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:x=!1,padding:b=0}=Mi(e,t),N=q3(b),v=c[x?m==="floating"?"reference":"floating":m],k=jp(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),M=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)),L=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},R=jp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:M,offsetParent:E,strategy:u}):M);return{top:(k.top-R.top+N.top)/L.y,bottom:(R.bottom-k.bottom+N.bottom)/L.y,left:(k.left-R.left+N.left)/L.x,right:(R.right-k.right+N.right)/L.x}}const CB=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}=uj(h,r,u),x=r,b={},N=0;for(let v=0;v({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}=Mi(t,e)||{};if(h==null)return{};const m=q3(f),x={x:n,y:r},b=nb(a),N=tb(b),w=await o.getDimensions(h),v=b==="y",k=v?"top":"left",M=v?"bottom":"right",E=v?"clientHeight":"clientWidth",L=i.reference[N]+i.reference[b]-x[b]-i.floating[N],R=x[b]-i.reference[b],W=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let P=W?W[E]:0;(!P||!await(o.isElement==null?void 0:o.isElement(W)))&&(P=c.floating[E]||i.floating[N]);const B=L/2-R/2,O=P/2-w[N]/2-1,X=zo(m[k],O),ae=zo(m[M],O),_=X,se=P-w[N]-ae,ce=P/2-w[N]/2+B,me=L0(_,ce,se),I=!u.arrow&&fd(a)!=null&&ce!==me&&i.reference[N]/2-(ce<_?X:ae)-w[N]/2<0,Z=I?ce<_?ce-_:ce-se:0;return{[b]:x[b]+Z,data:{[b]:me,centerOffset:ce-me-Z,...I&&{alignmentOffset:Z}},reset:I}}}),TB=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:a,middlewareData:i,rects:o,initialPlacement:c,platform:u,elements:h}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:x,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:N="none",flipAlignment:w=!0,...v}=Mi(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const k=Ai(a),M=Pa(c),E=Ai(c)===c,L=await(u.isRTL==null?void 0:u.isRTL(h.floating)),R=x||(E||!w?[wp(c)]:bB(c)),W=N!=="none";!x&&W&&R.push(...jB(c,w,N,L));const P=[c,...R],B=await u.detectOverflow(e,v),O=[];let X=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&O.push(B[k]),m){const ce=yB(a,o,L);O.push(B[ce[0]],B[ce[1]])}if(X=[...X,{placement:a,overflows:O}],!O.every(ce=>ce<=0)){var ae,_;const ce=(((ae=i.flip)==null?void 0:ae.index)||0)+1,me=P[ce];if(me&&(!(m==="alignment"?M!==Pa(me):!1)||X.every(V=>Pa(V.placement)===M?V.overflows[0]>0:!0)))return{data:{index:ce,overflows:X},reset:{placement:me}};let I=(_=X.filter(Z=>Z.overflows[0]<=0).sort((Z,V)=>Z.overflows[1]-V.overflows[1])[0])==null?void 0:_.placement;if(!I)switch(b){case"bestFit":{var se;const Z=(se=X.filter(V=>{if(W){const xe=Pa(V.placement);return xe===M||xe==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(xe=>xe>0).reduce((xe,ee)=>xe+ee,0)]).sort((V,xe)=>V[1]-xe[1])[0])==null?void 0:se[0];Z&&(I=Z);break}case"initialPlacement":I=c;break}if(a!==I)return{reset:{placement:I}}}return{}}}};function hj(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function fj(t){return pB.some(e=>t[e]>=0)}const MB=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:a="referenceHidden",...i}=Mi(t,e);switch(a){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),c=hj(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:fj(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),c=hj(o,n.floating);return{data:{escapedOffsets:c,escaped:fj(c)}}}default:return{}}}}},G3=new Set(["left","top"]);async function AB(t,e){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=Ai(n),c=fd(n),u=Pa(n)==="y",h=G3.has(o)?-1:1,f=i&&u?-1:1,m=Mi(e,t);let{mainAxis:x,crossAxis:b,alignmentAxis:N}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof N=="number"&&(b=c==="end"?N*-1:N),u?{x:b*f,y:x*h}:{x:x*h,y:b*f}}const PB=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 AB(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}}}}},IB=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:M,y:E}=k;return{x:M,y:E}}},...h}=Mi(t,e),f={x:n,y:r},m=await i.detectOverflow(e,h),x=Pa(Ai(a)),b=eb(x);let N=f[b],w=f[x];if(o){const k=b==="y"?"top":"left",M=b==="y"?"bottom":"right",E=N+m[k],L=N-m[M];N=L0(E,N,L)}if(c){const k=x==="y"?"top":"left",M=x==="y"?"bottom":"right",E=w+m[k],L=w-m[M];w=L0(E,w,L)}const v=u.fn({...e,[b]:N,[x]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[b]:o,[x]:c}}}}}},RB=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}=Mi(t,e),f={x:n,y:r},m=Pa(a),x=eb(m);let b=f[x],N=f[m];const w=Mi(c,e),v=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const E=x==="y"?"height":"width",L=i.reference[x]-i.floating[E]+v.mainAxis,R=i.reference[x]+i.reference[E]-v.mainAxis;bR&&(b=R)}if(h){var k,M;const E=x==="y"?"width":"height",L=G3.has(Ai(a)),R=i.reference[m]-i.floating[E]+(L&&((k=o.offset)==null?void 0:k[m])||0)+(L?0:v.crossAxis),W=i.reference[m]+i.reference[E]+(L?0:((M=o.offset)==null?void 0:M[m])||0)-(L?v.crossAxis:0);NW&&(N=W)}return{[x]:b,[m]:N}}}},LB=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}=Mi(t,e),f=await o.detectOverflow(e,h),m=Ai(a),x=fd(a),b=Pa(a)==="y",{width:N,height:w}=i.floating;let v,k;m==="top"||m==="bottom"?(v=m,k=x===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,v=x==="end"?"top":"bottom");const M=w-f.top-f.bottom,E=N-f.left-f.right,L=zo(w-f[v],M),R=zo(N-f[k],E),W=!e.middlewareData.shift;let P=L,B=R;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(B=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(P=M),W&&!x){const X=xr(f.left,0),ae=xr(f.right,0),_=xr(f.top,0),se=xr(f.bottom,0);b?B=N-2*(X!==0||ae!==0?X+ae:xr(f.left,f.right)):P=w-2*(_!==0||se!==0?_+se:xr(f.top,f.bottom))}await u({...e,availableWidth:B,availableHeight:P});const O=await o.getDimensions(c.floating);return N!==O.width||w!==O.height?{reset:{rects:!0}}:{}}}};function Xp(){return typeof window<"u"}function pd(t){return J3(t)?(t.nodeName||"").toLowerCase():"#document"}function vr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function za(t){var e;return(e=(J3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function J3(t){return Xp()?t instanceof Node||t instanceof vr(t).Node:!1}function ia(t){return Xp()?t instanceof Element||t instanceof vr(t).Element:!1}function Da(t){return Xp()?t instanceof HTMLElement||t instanceof vr(t).HTMLElement:!1}function pj(t){return!Xp()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof vr(t).ShadowRoot}const OB=new Set(["inline","contents"]);function Wu(t){const{overflow:e,overflowX:n,overflowY:r,display:a}=oa(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!OB.has(a)}const DB=new Set(["table","td","th"]);function _B(t){return DB.has(pd(t))}const $B=[":popover-open",":modal"];function Zp(t){return $B.some(e=>{try{return t.matches(e)}catch{return!1}})}const zB=["transform","translate","scale","rotate","perspective"],FB=["transform","translate","scale","rotate","perspective","filter"],BB=["paint","layout","strict","content"];function sb(t){const e=rb(),n=ia(t)?oa(t):t;return zB.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)||FB.some(r=>(n.willChange||"").includes(r))||BB.some(r=>(n.contain||"").includes(r))}function VB(t){let e=Fo(t);for(;Da(e)&&!ad(e);){if(sb(e))return e;if(Zp(e))return null;e=Fo(e)}return null}function rb(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const HB=new Set(["html","body","#document"]);function ad(t){return HB.has(pd(t))}function oa(t){return vr(t).getComputedStyle(t)}function em(t){return ia(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Fo(t){if(pd(t)==="html")return t;const e=t.assignedSlot||t.parentNode||pj(t)&&t.host||za(t);return pj(e)?e.host:e}function Q3(t){const e=Fo(t);return ad(e)?t.ownerDocument?t.ownerDocument.body:t.body:Da(e)&&Wu(e)?e:Q3(e)}function Du(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=Q3(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=vr(a);if(i){const c=D0(o);return e.concat(o,o.visualViewport||[],Wu(a)?a:[],c&&n?Du(c):[])}return e.concat(a,Du(a,[],n))}function D0(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Y3(t){const e=oa(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const a=Da(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,c=Np(n)!==i||Np(r)!==o;return c&&(n=i,r=o),{width:n,height:r,$:c}}function ab(t){return ia(t)?t:t.contextElement}function Qc(t){const e=ab(t);if(!Da(e))return Ia(1);const n=e.getBoundingClientRect(),{width:r,height:a,$:i}=Y3(e);let o=(i?Np(n.width):n.width)/r,c=(i?Np(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const UB=Ia(0);function X3(t){const e=vr(t);return!rb()||!e.visualViewport?UB:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function WB(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==vr(t)?!1:e}function Ql(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=ab(t);let o=Ia(1);e&&(r?ia(r)&&(o=Qc(r)):o=Qc(t));const c=WB(i,n,r)?X3(i):Ia(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 x=vr(i),b=r&&ia(r)?vr(r):r;let N=x,w=D0(N);for(;w&&r&&b!==N;){const v=Qc(w),k=w.getBoundingClientRect(),M=oa(w),E=k.left+(w.clientLeft+parseFloat(M.paddingLeft))*v.x,L=k.top+(w.clientTop+parseFloat(M.paddingTop))*v.y;u*=v.x,h*=v.y,f*=v.x,m*=v.y,u+=E,h+=L,N=vr(w),w=D0(N)}}return jp({width:f,height:m,x:u,y:h})}function tm(t,e){const n=em(t).scrollLeft;return e?e.left+n:Ql(za(t)).left+n}function Z3(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-tm(t,n),a=n.top+e.scrollTop;return{x:r,y:a}}function KB(t){let{elements:e,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=za(r),c=e?Zp(e.floating):!1;if(r===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Ia(1);const f=Ia(0),m=Da(r);if((m||!m&&!i)&&((pd(r)!=="body"||Wu(o))&&(u=em(r)),Da(r))){const b=Ql(r);h=Qc(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const x=o&&!m&&!i?Z3(o,u):Ia(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+f.x+x.x,y:n.y*h.y-u.scrollTop*h.y+f.y+x.y}}function qB(t){return Array.from(t.getClientRects())}function GB(t){const e=za(t),n=em(t),r=t.ownerDocument.body,a=xr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=xr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+tm(t);const c=-n.scrollTop;return oa(r).direction==="rtl"&&(o+=xr(e.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:c}}const mj=25;function JB(t,e){const n=vr(t),r=za(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=rb();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=tm(r);if(h<=0){const f=r.ownerDocument,m=f.body,x=getComputedStyle(m),b=f.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,N=Math.abs(r.clientWidth-m.clientWidth-b);N<=mj&&(i-=N)}else h<=mj&&(i+=h);return{width:i,height:o,x:c,y:u}}const QB=new Set(["absolute","fixed"]);function YB(t,e){const n=Ql(t,!0,e==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=Da(t)?Qc(t):Ia(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 xj(t,e,n){let r;if(e==="viewport")r=JB(t,n);else if(e==="document")r=GB(za(t));else if(ia(e))r=YB(e,n);else{const a=X3(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return jp(r)}function e4(t,e){const n=Fo(t);return n===e||!ia(n)||ad(n)?!1:oa(n).position==="fixed"||e4(n,e)}function XB(t,e){const n=e.get(t);if(n)return n;let r=Du(t,[],!1).filter(c=>ia(c)&&pd(c)!=="body"),a=null;const i=oa(t).position==="fixed";let o=i?Fo(t):t;for(;ia(o)&&!ad(o);){const c=oa(o),u=sb(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&QB.has(a.position)||Wu(o)&&!u&&e4(t,o))?r=r.filter(f=>f!==o):a=c,o=Fo(o)}return e.set(t,r),r}function ZB(t){let{element:e,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?Zp(e)?[]:XB(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=xj(e,f,a);return h.top=xr(m.top,h.top),h.right=zo(m.right,h.right),h.bottom=zo(m.bottom,h.bottom),h.left=xr(m.left,h.left),h},xj(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function e9(t){const{width:e,height:n}=Y3(t);return{width:e,height:n}}function t9(t,e,n){const r=Da(e),a=za(e),i=n==="fixed",o=Ql(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Ia(0);function h(){u.x=tm(a)}if(r||!r&&!i)if((pd(e)!=="body"||Wu(a))&&(c=em(e)),r){const b=Ql(e,!0,i,e);u.x=b.x+e.clientLeft,u.y=b.y+e.clientTop}else a&&h();i&&!r&&a&&h();const f=a&&!r&&!i?Z3(a,c):Ia(0),m=o.left+c.scrollLeft-u.x-f.x,x=o.top+c.scrollTop-u.y-f.y;return{x:m,y:x,width:o.width,height:o.height}}function kg(t){return oa(t).position==="static"}function gj(t,e){if(!Da(t)||oa(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return za(t)===n&&(n=n.ownerDocument.body),n}function t4(t,e){const n=vr(t);if(Zp(t))return n;if(!Da(t)){let a=Fo(t);for(;a&&!ad(a);){if(ia(a)&&!kg(a))return a;a=Fo(a)}return n}let r=gj(t,e);for(;r&&_B(r)&&kg(r);)r=gj(r,e);return r&&ad(r)&&kg(r)&&!sb(r)?n:r||VB(t)||n}const n9=async function(t){const e=this.getOffsetParent||t4,n=this.getDimensions,r=await n(t.floating);return{reference:t9(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function s9(t){return oa(t).direction==="rtl"}const r9={convertOffsetParentRelativeRectToViewportRelativeRect:KB,getDocumentElement:za,getClippingRect:ZB,getOffsetParent:t4,getElementRects:n9,getClientRects:qB,getDimensions:e9,getScale:Qc,isElement:ia,isRTL:s9};function n4(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function a9(t,e){let n=null,r;const a=za(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:x,height:b}=h;if(c||e(),!x||!b)return;const N=hf(m),w=hf(a.clientWidth-(f+x)),v=hf(a.clientHeight-(m+b)),k=hf(f),E={rootMargin:-N+"px "+-w+"px "+-v+"px "+-k+"px",threshold:xr(0,zo(1,u))||1};let L=!0;function R(W){const P=W[0].intersectionRatio;if(P!==u){if(!L)return o();P?o(!1,P):r=setTimeout(()=>{o(!1,1e-7)},1e3)}P===1&&!n4(h,t.getBoundingClientRect())&&o(),L=!1}try{n=new IntersectionObserver(R,{...E,root:a.ownerDocument})}catch{n=new IntersectionObserver(R,E)}n.observe(t)}return o(!0),i}function i9(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=ab(t),f=a||i?[...h?Du(h):[],...Du(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?a9(h,n):null;let x=-1,b=null;o&&(b=new ResizeObserver(k=>{let[M]=k;M&&M.target===h&&b&&(b.unobserve(e),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var E;(E=b)==null||E.observe(e)})),n()}),h&&!u&&b.observe(h),b.observe(e));let N,w=u?Ql(t):null;u&&v();function v(){const k=Ql(t);w&&!n4(w,k)&&n(),w=k,N=requestAnimationFrame(v)}return n(),()=>{var k;f.forEach(M=>{a&&M.removeEventListener("scroll",n),i&&M.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,u&&cancelAnimationFrame(N)}}const o9=PB,l9=IB,c9=TB,d9=LB,u9=MB,yj=EB,h9=RB,f9=(t,e,n)=>{const r=new Map,a={platform:r9,...n},i={...a.platform,_c:r};return CB(t,e,{...a,platform:i})};var p9=typeof document<"u",m9=function(){},wf=p9?g.useLayoutEffect:m9;function kp(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(!kp(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)&&!kp(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function s4(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function bj(t,e){const n=s4(t);return Math.round(e*n)/n}function Sg(t){const e=g.useRef(t);return wf(()=>{e.current=t}),e}function x9(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]=g.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[x,b]=g.useState(r);kp(x,r)||b(r);const[N,w]=g.useState(null),[v,k]=g.useState(null),M=g.useCallback(V=>{V!==W.current&&(W.current=V,w(V))},[]),E=g.useCallback(V=>{V!==P.current&&(P.current=V,k(V))},[]),L=i||N,R=o||v,W=g.useRef(null),P=g.useRef(null),B=g.useRef(f),O=u!=null,X=Sg(u),ae=Sg(a),_=Sg(h),se=g.useCallback(()=>{if(!W.current||!P.current)return;const V={placement:e,strategy:n,middleware:x};ae.current&&(V.platform=ae.current),f9(W.current,P.current,V).then(xe=>{const ee={...xe,isPositioned:_.current!==!1};ce.current&&!kp(B.current,ee)&&(B.current=ee,id.flushSync(()=>{m(ee)}))})},[x,e,n,ae,_]);wf(()=>{h===!1&&B.current.isPositioned&&(B.current.isPositioned=!1,m(V=>({...V,isPositioned:!1})))},[h]);const ce=g.useRef(!1);wf(()=>(ce.current=!0,()=>{ce.current=!1}),[]),wf(()=>{if(L&&(W.current=L),R&&(P.current=R),L&&R){if(X.current)return X.current(L,R,se);se()}},[L,R,se,X,O]);const me=g.useMemo(()=>({reference:W,floating:P,setReference:M,setFloating:E}),[M,E]),I=g.useMemo(()=>({reference:L,floating:R}),[L,R]),Z=g.useMemo(()=>{const V={position:n,left:0,top:0};if(!I.floating)return V;const xe=bj(I.floating,f.x),ee=bj(I.floating,f.y);return c?{...V,transform:"translate("+xe+"px, "+ee+"px)",...s4(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:xe,top:ee}},[n,c,I.floating,f.x,f.y]);return g.useMemo(()=>({...f,update:se,refs:me,elements:I,floatingStyles:Z}),[f,se,me,I,Z])}const g9=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?yj({element:r.current,padding:a}).fn(n):{}:r?yj({element:r,padding:a}).fn(n):{}}}},y9=(t,e)=>({...o9(t),options:[t,e]}),b9=(t,e)=>({...l9(t),options:[t,e]}),v9=(t,e)=>({...h9(t),options:[t,e]}),N9=(t,e)=>({...c9(t),options:[t,e]}),w9=(t,e)=>({...d9(t),options:[t,e]}),j9=(t,e)=>({...u9(t),options:[t,e]}),k9=(t,e)=>({...g9(t),options:[t,e]});var S9="Arrow",r4=g.forwardRef((t,e)=>{const{children:n,width:r=10,height:a=5,...i}=t;return s.jsx(Ct.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"})})});r4.displayName=S9;var C9=r4,ib="Popper",[a4,i4]=Ho(ib),[E9,o4]=a4(ib),l4=t=>{const{__scopePopper:e,children:n}=t,[r,a]=g.useState(null);return s.jsx(E9,{scope:e,anchor:r,onAnchorChange:a,children:n})};l4.displayName=ib;var c4="PopperAnchor",d4=g.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=o4(c4,n),o=g.useRef(null),c=Jt(e,o),u=g.useRef(null);return g.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(Ct.div,{...a,ref:c})});d4.displayName=c4;var ob="PopperContent",[T9,M9]=a4(ob),u4=g.forwardRef((t,e)=>{var Q,z,te,ie,we,Be;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:x=!1,updatePositionStrategy:b="optimized",onPlaced:N,...w}=t,v=o4(ob,n),[k,M]=g.useState(null),E=Jt(e,Ue=>M(Ue)),[L,R]=g.useState(null),W=ly(L),P=(W==null?void 0:W.width)??0,B=(W==null?void 0:W.height)??0,O=r+(i!=="center"?"-"+i:""),X=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},ae=Array.isArray(h)?h:[h],_=ae.length>0,se={padding:X,boundary:ae.filter(P9),altBoundary:_},{refs:ce,floatingStyles:me,placement:I,isPositioned:Z,middlewareData:V}=x9({strategy:"fixed",placement:O,whileElementsMounted:(...Ue)=>i9(...Ue,{animationFrame:b==="always"}),elements:{reference:v.anchor},middleware:[y9({mainAxis:a+B,alignmentAxis:o}),u&&b9({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?v9():void 0,...se}),u&&N9({...se}),w9({...se,apply:({elements:Ue,rects:bt,availableWidth:vn,availableHeight:dt})=>{const{width:Tt,height:ln}=bt.reference,Dn=Ue.floating.style;Dn.setProperty("--radix-popper-available-width",`${vn}px`),Dn.setProperty("--radix-popper-available-height",`${dt}px`),Dn.setProperty("--radix-popper-anchor-width",`${Tt}px`),Dn.setProperty("--radix-popper-anchor-height",`${ln}px`)}}),L&&k9({element:L,padding:c}),I9({arrowWidth:P,arrowHeight:B}),x&&j9({strategy:"referenceHidden",...se})]}),[xe,ee]=p4(I),H=Lo(N);Rs(()=>{Z&&(H==null||H())},[Z,H]);const K=(Q=V.arrow)==null?void 0:Q.x,fe=(z=V.arrow)==null?void 0:z.y,he=((te=V.arrow)==null?void 0:te.centerOffset)!==0,[ue,$]=g.useState();return Rs(()=>{k&&$(window.getComputedStyle(k).zIndex)},[k]),s.jsx("div",{ref:ce.setFloating,"data-radix-popper-content-wrapper":"",style:{...me,transform:Z?me.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(ie=V.transformOrigin)==null?void 0:ie.x,(we=V.transformOrigin)==null?void 0:we.y].join(" "),...((Be=V.hide)==null?void 0:Be.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(T9,{scope:n,placedSide:xe,onArrowChange:R,arrowX:K,arrowY:fe,shouldHideArrow:he,children:s.jsx(Ct.div,{"data-side":xe,"data-align":ee,...w,ref:E,style:{...w.style,animation:Z?void 0:"none"}})})})});u4.displayName=ob;var h4="PopperArrow",A9={top:"bottom",right:"left",bottom:"top",left:"right"},f4=g.forwardRef(function(e,n){const{__scopePopper:r,...a}=e,i=M9(h4,r),o=A9[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(C9,{...a,ref:n,style:{...a.style,display:"block"}})})});f4.displayName=h4;function P9(t){return t!==null}var I9=t=>({name:"transformOrigin",options:t,fn(e){var v,k,M;const{placement:n,rects:r,middlewareData:a}=e,o=((v=a.arrow)==null?void 0:v.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=p4(n),m={start:"0%",center:"50%",end:"100%"}[f],x=(((k=a.arrow)==null?void 0:k.x)??0)+c/2,b=(((M=a.arrow)==null?void 0:M.y)??0)+u/2;let N="",w="";return h==="bottom"?(N=o?m:`${x}px`,w=`${-u}px`):h==="top"?(N=o?m:`${x}px`,w=`${r.floating.height+u}px`):h==="right"?(N=`${-u}px`,w=o?m:`${b}px`):h==="left"&&(N=`${r.floating.width+u}px`,w=o?m:`${b}px`),{data:{x:N,y:w}}}});function p4(t){const[e,n="center"]=t.split("-");return[e,n]}var R9=l4,L9=d4,O9=u4,D9=f4,m4=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"}),_9="VisuallyHidden",$9=g.forwardRef((t,e)=>s.jsx(Ct.span,{...t,ref:e,style:{...m4,...t.style}}));$9.displayName=_9;var z9=[" ","Enter","ArrowUp","ArrowDown"],F9=[" ","Enter"],Yl="Select",[nm,sm,B9]=ay(Yl),[md]=Ho(Yl,[B9,i4]),rm=i4(),[V9,Go]=md(Yl),[H9,U9]=md(Yl),x4=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:x,required:b,form:N}=t,w=rm(e),[v,k]=g.useState(null),[M,E]=g.useState(null),[L,R]=g.useState(!1),W=Ip(h),[P,B]=Fl({prop:r,defaultProp:a??!1,onChange:i,caller:Yl}),[O,X]=Fl({prop:o,defaultProp:c,onChange:u,caller:Yl}),ae=g.useRef(null),_=v?N||!!v.closest("form"):!0,[se,ce]=g.useState(new Set),me=Array.from(se).map(I=>I.props.value).join(";");return s.jsx(R9,{...w,children:s.jsxs(V9,{required:b,scope:e,trigger:v,onTriggerChange:k,valueNode:M,onValueNodeChange:E,valueNodeHasChildren:L,onValueNodeHasChildrenChange:R,contentId:Co(),value:O,onValueChange:X,open:P,onOpenChange:B,dir:W,triggerPointerDownPosRef:ae,disabled:x,children:[s.jsx(nm.Provider,{scope:e,children:s.jsx(H9,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(I=>{ce(Z=>new Set(Z).add(I))},[]),onNativeOptionRemove:g.useCallback(I=>{ce(Z=>{const V=new Set(Z);return V.delete(I),V})},[]),children:n})}),_?s.jsxs($4,{"aria-hidden":!0,required:b,tabIndex:-1,name:f,autoComplete:m,value:O,onChange:I=>X(I.target.value),disabled:x,form:N,children:[O===void 0?s.jsx("option",{value:""}):null,Array.from(se)]},me):null]})})};x4.displayName=Yl;var g4="SelectTrigger",y4=g.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=rm(n),o=Go(g4,n),c=o.disabled||r,u=Jt(e,o.onTriggerChange),h=sm(n),f=g.useRef("touch"),[m,x,b]=F4(w=>{const v=h().filter(E=>!E.disabled),k=v.find(E=>E.value===o.value),M=B4(v,w,k);M!==void 0&&o.onValueChange(M.value)}),N=w=>{c||(o.onOpenChange(!0),b()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return s.jsx(L9,{asChild:!0,...i,children:s.jsx(Ct.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":z4(o.value)?"":void 0,...a,ref:u,onClick:jt(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&N(w)}),onPointerDown:jt(a.onPointerDown,w=>{f.current=w.pointerType;const v=w.target;v.hasPointerCapture(w.pointerId)&&v.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(N(w),w.preventDefault())}),onKeyDown:jt(a.onKeyDown,w=>{const v=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&x(w.key),!(v&&w.key===" ")&&z9.includes(w.key)&&(N(),w.preventDefault())})})})});y4.displayName=g4;var b4="SelectValue",v4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=t,u=Go(b4,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Jt(e,u.onValueNodeChange);return Rs(()=>{h(f)},[h,f]),s.jsx(Ct.span,{...c,ref:m,style:{pointerEvents:"none"},children:z4(u.value)?s.jsx(s.Fragment,{children:o}):i})});v4.displayName=b4;var W9="SelectIcon",N4=g.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...a}=t;return s.jsx(Ct.span,{"aria-hidden":!0,...a,ref:e,children:r||"▼"})});N4.displayName=W9;var K9="SelectPortal",w4=t=>s.jsx(ey,{asChild:!0,...t});w4.displayName=K9;var Xl="SelectContent",j4=g.forwardRef((t,e)=>{const n=Go(Xl,t.__scopeSelect),[r,a]=g.useState();if(Rs(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?id.createPortal(s.jsx(k4,{scope:t.__scopeSelect,children:s.jsx(nm.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),i):null}return s.jsx(S4,{...t,ref:e})});j4.displayName=Xl;var ta=10,[k4,Jo]=md(Xl),q9="SelectContentImpl",G9=ju("SelectContent.RemoveScroll"),S4=g.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:x,collisionPadding:b,sticky:N,hideWhenDetached:w,avoidCollisions:v,...k}=t,M=Go(Xl,n),[E,L]=g.useState(null),[R,W]=g.useState(null),P=Jt(e,Q=>L(Q)),[B,O]=g.useState(null),[X,ae]=g.useState(null),_=sm(n),[se,ce]=g.useState(!1),me=g.useRef(!1);g.useEffect(()=>{if(E)return $k(E)},[E]),Mk();const I=g.useCallback(Q=>{const[z,...te]=_().map(Be=>Be.ref.current),[ie]=te.slice(-1),we=document.activeElement;for(const Be of Q)if(Be===we||(Be==null||Be.scrollIntoView({block:"nearest"}),Be===z&&R&&(R.scrollTop=0),Be===ie&&R&&(R.scrollTop=R.scrollHeight),Be==null||Be.focus(),document.activeElement!==we))return},[_,R]),Z=g.useCallback(()=>I([B,E]),[I,B,E]);g.useEffect(()=>{se&&Z()},[se,Z]);const{onOpenChange:V,triggerPointerDownPosRef:xe}=M;g.useEffect(()=>{if(E){let Q={x:0,y:0};const z=ie=>{var we,Be;Q={x:Math.abs(Math.round(ie.pageX)-(((we=xe.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((Be=xe.current)==null?void 0:Be.y)??0))}},te=ie=>{Q.x<=10&&Q.y<=10?ie.preventDefault():E.contains(ie.target)||V(!1),document.removeEventListener("pointermove",z),xe.current=null};return xe.current!==null&&(document.addEventListener("pointermove",z),document.addEventListener("pointerup",te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",te,{capture:!0})}}},[E,V,xe]),g.useEffect(()=>{const Q=()=>V(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[V]);const[ee,H]=F4(Q=>{const z=_().filter(we=>!we.disabled),te=z.find(we=>we.ref.current===document.activeElement),ie=B4(z,Q,te);ie&&setTimeout(()=>ie.ref.current.focus())}),K=g.useCallback((Q,z,te)=>{const ie=!me.current&&!te;(M.value!==void 0&&M.value===z||ie)&&(O(Q),ie&&(me.current=!0))},[M.value]),fe=g.useCallback(()=>E==null?void 0:E.focus(),[E]),he=g.useCallback((Q,z,te)=>{const ie=!me.current&&!te;(M.value!==void 0&&M.value===z||ie)&&ae(Q)},[M.value]),ue=r==="popper"?_0:C4,$=ue===_0?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:x,collisionPadding:b,sticky:N,hideWhenDetached:w,avoidCollisions:v}:{};return s.jsx(k4,{scope:n,content:E,viewport:R,onViewportChange:W,itemRefCallback:K,selectedItem:B,onItemLeave:fe,itemTextRefCallback:he,focusSelectedItem:Z,selectedItemText:X,position:r,isPositioned:se,searchRef:ee,children:s.jsx(ty,{as:G9,allowPinchZoom:!0,children:s.jsx(Z0,{asChild:!0,trapped:M.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:jt(a,Q=>{var z;(z=M.trigger)==null||z.focus({preventScroll:!0}),Q.preventDefault()}),children:s.jsx(X0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>M.onOpenChange(!1),children:s.jsx(ue,{role:"listbox",id:M.contentId,"data-state":M.open?"open":"closed",dir:M.dir,onContextMenu:Q=>Q.preventDefault(),...k,...$,onPlaced:()=>ce(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:jt(k.onKeyDown,Q=>{const z=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!z&&Q.key.length===1&&H(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let ie=_().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const we=Q.target,Be=ie.indexOf(we);ie=ie.slice(Be+1)}setTimeout(()=>I(ie)),Q.preventDefault()}})})})})})})});S4.displayName=q9;var J9="SelectItemAlignedPosition",C4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=Go(Xl,n),o=Jo(Xl,n),[c,u]=g.useState(null),[h,f]=g.useState(null),m=Jt(e,P=>f(P)),x=sm(n),b=g.useRef(!1),N=g.useRef(!0),{viewport:w,selectedItem:v,selectedItemText:k,focusSelectedItem:M}=o,E=g.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&v&&k){const P=i.trigger.getBoundingClientRect(),B=h.getBoundingClientRect(),O=i.valueNode.getBoundingClientRect(),X=k.getBoundingClientRect();if(i.dir!=="rtl"){const we=X.left-B.left,Be=O.left-we,Ue=P.left-Be,bt=P.width+Ue,vn=Math.max(bt,B.width),dt=window.innerWidth-ta,Tt=Pf(Be,[ta,Math.max(ta,dt-vn)]);c.style.minWidth=bt+"px",c.style.left=Tt+"px"}else{const we=B.right-X.right,Be=window.innerWidth-O.right-we,Ue=window.innerWidth-P.right-Be,bt=P.width+Ue,vn=Math.max(bt,B.width),dt=window.innerWidth-ta,Tt=Pf(Be,[ta,Math.max(ta,dt-vn)]);c.style.minWidth=bt+"px",c.style.right=Tt+"px"}const ae=x(),_=window.innerHeight-ta*2,se=w.scrollHeight,ce=window.getComputedStyle(h),me=parseInt(ce.borderTopWidth,10),I=parseInt(ce.paddingTop,10),Z=parseInt(ce.borderBottomWidth,10),V=parseInt(ce.paddingBottom,10),xe=me+I+se+V+Z,ee=Math.min(v.offsetHeight*5,xe),H=window.getComputedStyle(w),K=parseInt(H.paddingTop,10),fe=parseInt(H.paddingBottom,10),he=P.top+P.height/2-ta,ue=_-he,$=v.offsetHeight/2,Q=v.offsetTop+$,z=me+I+Q,te=xe-z;if(z<=he){const we=ae.length>0&&v===ae[ae.length-1].ref.current;c.style.bottom="0px";const Be=h.clientHeight-w.offsetTop-w.offsetHeight,Ue=Math.max(ue,$+(we?fe:0)+Be+Z),bt=z+Ue;c.style.height=bt+"px"}else{const we=ae.length>0&&v===ae[0].ref.current;c.style.top="0px";const Ue=Math.max(he,me+w.offsetTop+(we?K:0)+$)+te;c.style.height=Ue+"px",w.scrollTop=z-he+w.offsetTop}c.style.margin=`${ta}px 0`,c.style.minHeight=ee+"px",c.style.maxHeight=_+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[x,i.trigger,i.valueNode,c,h,w,v,k,i.dir,r]);Rs(()=>E(),[E]);const[L,R]=g.useState();Rs(()=>{h&&R(window.getComputedStyle(h).zIndex)},[h]);const W=g.useCallback(P=>{P&&N.current===!0&&(E(),M==null||M(),N.current=!1)},[E,M]);return s.jsx(Y9,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:b,onScrollButtonChange:W,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:s.jsx(Ct.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});C4.displayName=J9;var Q9="SelectPopperPosition",_0=g.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=ta,...i}=t,o=rm(n);return s.jsx(O9,{...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)"}})});_0.displayName=Q9;var[Y9,lb]=md(Xl,{}),$0="SelectViewport",E4=g.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=Jo($0,n),o=lb($0,n),c=Jt(e,i.onViewportChange),u=g.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(nm.Slot,{scope:n,children:s.jsx(Ct.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:jt(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:x}=o;if(x!=null&&x.current&&m){const b=Math.abs(u.current-f.scrollTop);if(b>0){const N=window.innerHeight-ta*2,w=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),k=Math.max(w,v);if(k0?L:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});E4.displayName=$0;var T4="SelectGroup",[X9,Z9]=md(T4),eV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Co();return s.jsx(X9,{scope:n,id:a,children:s.jsx(Ct.div,{role:"group","aria-labelledby":a,...r,ref:e})})});eV.displayName=T4;var M4="SelectLabel",tV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Z9(M4,n);return s.jsx(Ct.div,{id:a.id,...r,ref:e})});tV.displayName=M4;var Sp="SelectItem",[nV,A4]=md(Sp),P4=g.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,c=Go(Sp,n),u=Jo(Sp,n),h=c.value===r,[f,m]=g.useState(i??""),[x,b]=g.useState(!1),N=Jt(e,M=>{var E;return(E=u.itemRefCallback)==null?void 0:E.call(u,M,r,a)}),w=Co(),v=g.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(nV,{scope:n,value:r,disabled:a,textId:w,isSelected:h,onItemTextChange:g.useCallback(M=>{m(E=>E||((M==null?void 0:M.textContent)??"").trim())},[]),children:s.jsx(nm.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:s.jsx(Ct.div,{role:"option","aria-labelledby":w,"data-highlighted":x?"":void 0,"aria-selected":h&&x,"data-state":h?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:jt(o.onFocus,()=>b(!0)),onBlur:jt(o.onBlur,()=>b(!1)),onClick:jt(o.onClick,()=>{v.current!=="mouse"&&k()}),onPointerUp:jt(o.onPointerUp,()=>{v.current==="mouse"&&k()}),onPointerDown:jt(o.onPointerDown,M=>{v.current=M.pointerType}),onPointerMove:jt(o.onPointerMove,M=>{var E;v.current=M.pointerType,a?(E=u.onItemLeave)==null||E.call(u):v.current==="mouse"&&M.currentTarget.focus({preventScroll:!0})}),onPointerLeave:jt(o.onPointerLeave,M=>{var E;M.currentTarget===document.activeElement&&((E=u.onItemLeave)==null||E.call(u))}),onKeyDown:jt(o.onKeyDown,M=>{var L;((L=u.searchRef)==null?void 0:L.current)!==""&&M.key===" "||(F9.includes(M.key)&&k(),M.key===" "&&M.preventDefault())})})})})});P4.displayName=Sp;var au="SelectItemText",I4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=Go(au,n),c=Jo(au,n),u=A4(au,n),h=U9(au,n),[f,m]=g.useState(null),x=Jt(e,k=>m(k),u.onItemTextChange,k=>{var M;return(M=c.itemTextRefCallback)==null?void 0:M.call(c,k,u.value,u.disabled)}),b=f==null?void 0:f.textContent,N=g.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:b},u.value),[u.disabled,u.value,b]),{onNativeOptionAdd:w,onNativeOptionRemove:v}=h;return Rs(()=>(w(N),()=>v(N)),[w,v,N]),s.jsxs(s.Fragment,{children:[s.jsx(Ct.span,{id:u.textId,...i,ref:x}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?id.createPortal(i.children,o.valueNode):null]})});I4.displayName=au;var R4="SelectItemIndicator",L4=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return A4(R4,n).isSelected?s.jsx(Ct.span,{"aria-hidden":!0,...r,ref:e}):null});L4.displayName=R4;var z0="SelectScrollUpButton",O4=g.forwardRef((t,e)=>{const n=Jo(z0,t.__scopeSelect),r=lb(z0,t.__scopeSelect),[a,i]=g.useState(!1),o=Jt(e,r.onScrollButtonChange);return Rs(()=>{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(_4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});O4.displayName=z0;var F0="SelectScrollDownButton",D4=g.forwardRef((t,e)=>{const n=Jo(F0,t.__scopeSelect),r=lb(F0,t.__scopeSelect),[a,i]=g.useState(!1),o=Jt(e,r.onScrollButtonChange);return Rs(()=>{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(_4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});D4.displayName=F0;var _4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=Jo("SelectScrollButton",n),o=g.useRef(null),c=sm(n),u=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>u(),[u]),Rs(()=>{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(Ct.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:jt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:jt(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:jt(a.onPointerLeave,()=>{u()})})}),sV="SelectSeparator",rV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(Ct.div,{"aria-hidden":!0,...r,ref:e})});rV.displayName=sV;var B0="SelectArrow",aV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=rm(n),i=Go(B0,n),o=Jo(B0,n);return i.open&&o.position==="popper"?s.jsx(D9,{...a,...r,ref:e}):null});aV.displayName=B0;var iV="SelectBubbleInput",$4=g.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const a=g.useRef(null),i=Jt(r,a),o=oy(e);return g.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(Ct.select,{...n,style:{...m4,...n.style},ref:i,defaultValue:e})});$4.displayName=iV;function z4(t){return t===""||t===void 0}function F4(t){const e=Lo(t),n=g.useRef(""),r=g.useRef(0),a=g.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=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function B4(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=oV(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 oV(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var lV=x4,V4=y4,cV=v4,dV=N4,uV=w4,H4=j4,hV=E4,U4=P4,fV=I4,pV=L4,mV=O4,xV=D4;const go=lV,yo=cV,vi=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(V4,{ref:r,className:_t("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(dV,{asChild:!0,children:s.jsx(Ti,{className:"h-4 w-4 opacity-50"})})]}));vi.displayName=V4.displayName;const Ni=g.forwardRef(({className:t,children:e,position:n="popper",...r},a)=>s.jsx(uV,{children:s.jsxs(H4,{ref:a,className:_t("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-[#0b1828] border-gray-700 text-white shadow-lg",n==="popper"&&"data-[side=bottom]:translate-y-1",t),position:n,...r,children:[s.jsx(mV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Dg,{className:"h-4 w-4"})}),s.jsx(hV,{className:"p-1",children:e}),s.jsx(xV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Ti,{className:"h-4 w-4"})})]})}));Ni.displayName=H4.displayName;const Gn=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(U4,{ref:r,className:_t("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(pV,{children:s.jsx(Tp,{className:"h-4 w-4"})})}),s.jsx(fV,{children:e})]}));Gn.displayName=U4.displayName;const vj=["📖","📕","📗","📘","📙","📓","📔","📒","📚","📖"];function gV(t){return t.title==="序言"||t.title.includes("序言")}function Nj(t){const e=[];for(const n of t.chapters)for(const r of n.sections)e.push(r.id);return e.length===0?"暂无章节":e.length===1?e[0]:`${e[0]}~${e[e.length-1]}`}function Cg(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 yV({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:x=[],onToggleSectionSelect:b,onShowSectionOrders:N,pinnedSectionIds:w=[]}){const[v,k]=g.useState(null),[M,E]=g.useState(null),L=(_,se)=>(v==null?void 0:v.type)===_&&(v==null?void 0:v.id)===se,R=(_,se)=>(M==null?void 0:M.type)===_&&(M==null?void 0:M.id)===se,W=g.useCallback(()=>{const _=[];for(const se of t)for(const ce of se.chapters)for(const me of ce.sections)_.push({id:me.id,partId:se.id,partTitle:se.title,chapterId:ce.id,chapterTitle:ce.title});return _},[t]),P=g.useCallback(async(_,se,ce,me)=>{var ee;_.preventDefault(),_.stopPropagation();const I=_.dataTransfer.getData("text/plain"),Z=Cg(I);if(!Z||Z.type===se&&Z.id===ce)return;const V=W(),xe=new Map(V.map(H=>[H.id,H]));if(Z.type==="part"&&se==="part"){const H=t.map($=>$.id),K=H.indexOf(Z.id),fe=H.indexOf(ce);if(K===-1||fe===-1)return;const he=[...H];he.splice(K,1),he.splice(Kz.id===$);if(Q)for(const z of Q.chapters)for(const te of z.sections){const ie=xe.get(te.id);ie&&ue.push(ie)}}await r(ue);return}if(Z.type==="chapter"&&(se==="chapter"||se==="section"||se==="part")){const H=t.find(ie=>ie.chapters.some(we=>we.id===Z.id)),K=H==null?void 0:H.chapters.find(ie=>ie.id===Z.id);if(!H||!K)return;let fe,he,ue=null;if(se==="section"){const ie=xe.get(ce);if(!ie)return;fe=ie.partId,he=ie.partTitle,ue=ce}else if(se==="chapter"){const ie=t.find(Ue=>Ue.chapters.some(bt=>bt.id===ce)),we=ie==null?void 0:ie.chapters.find(Ue=>Ue.id===ce);if(!ie||!we)return;fe=ie.id,he=ie.title;const Be=V.filter(Ue=>Ue.chapterId===ce).pop();ue=(Be==null?void 0:Be.id)??null}else{const ie=t.find(we=>we.id===ce);if(!ie)return;if(fe=ie.id,he=ie.title,ie.chapters[0]){const we=V.filter(Be=>Be.partId===ie.id&&Be.chapterId===ie.chapters[0].id);ue=((ee=we[we.length-1])==null?void 0:ee.id)??null}}const $=K.sections.map(ie=>ie.id),Q=V.filter(ie=>!$.includes(ie.id));let z=Q.length;if(ue){const ie=Q.findIndex(we=>we.id===ue);ie>=0&&(z=ie+1)}const te=$.map(ie=>({...xe.get(ie),partId:fe,partTitle:he,chapterId:K.id,chapterTitle:K.title}));await r([...Q.slice(0,z),...te,...Q.slice(z)]);return}if(Z.type==="section"&&(se==="section"||se==="chapter"||se==="part")){if(!me)return;const{partId:H,partTitle:K,chapterId:fe,chapterTitle:he}=me,ue=V.findIndex(ie=>ie.id===Z.id);if(ue===-1)return;const $=V.filter(ie=>ie.id!==Z.id);let Q;if(se==="section"){const ie=$.findIndex(we=>we.id===ce);Q=ie>=0?ie+1:$.length}else if(se==="chapter"){const ie=$.filter(we=>we.chapterId===ce).pop();Q=ie?$.findIndex(we=>we.id===ie.id)+1:$.length}else{const ie=t.find(we=>we.id===ce);if(ie!=null&&ie.chapters[0]){const we=$.filter(Ue=>Ue.partId===ie.id&&Ue.chapterId===ie.chapters[0].id),Be=we[we.length-1];Q=Be?$.findIndex(Ue=>Ue.id===Be.id)+1:$.length}else Q=$.length}const te={...V[ue],partId:H,partTitle:K,chapterId:fe,chapterTitle:he};$.splice(Q,0,te),await r($)}},[t,W,r]),B=(_,se,ce)=>({onDragEnter:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",E({type:_,id:se})},onDragOver:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",E({type:_,id:se})},onDragLeave:()=>E(null),onDrop:me=>{E(null);const I=Cg(me.dataTransfer.getData("text/plain"));I&&(_==="section"&&I.type==="section"&&I.id===se||(_==="part"?I.type==="part"?P(me,"part",se):ce&&P(me,"part",se,ce):_==="chapter"&&ce?(I.type==="section"||I.type==="chapter")&&P(me,"chapter",se,ce):_==="section"&&ce&&P(me,"section",se,ce)))}}),O=_=>vj[_%vj.length],X=_=>t.slice(0,_).filter(se=>!gV(se)).length,ae=_=>s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-500 font-mono text-xs tabular-nums shrink-0 mr-1.5 max-w-[72px] truncate",title:`章节ID: ${_.id}`,children:_.id}),s.jsx("span",{className:"truncate",children:_.title})]});return s.jsx("div",{className:"space-y-3",children:t.map((_,se)=>{var K,fe,he,ue;const ce=_.title==="序言"||_.title.includes("序言"),me=_.title==="尾声"||_.title.includes("尾声"),I=_.title==="附录"||_.title.includes("附录"),Z=R("part",_.id),V=e.includes(_.id),xe=_.chapters.length,ee=_.chapters.reduce(($,Q)=>$+Q.sections.length,0);if(ce&&_.chapters.length===1&&_.chapters[0].sections.length===1){const $=_.chapters[0].sections[0],Q=R("section",$.id),z={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:te=>{te.stopPropagation(),te.dataTransfer.setData("text/plain","section:"+$.id),te.dataTransfer.effectAllowed="move",k({type:"section",id:$.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] ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",$.id,z),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(ci,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:te=>te.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes($.id),onChange:()=>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(or,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",$.title]}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),children:[$.price===0||$.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:["¥",$.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",$.clickCount??0," · 付款 ",$.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",($.hotScore??0).toFixed(1)," · 第",$.hotRank&&$.hotRank>0?$.hotRank:"-","名"]}),N&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N($),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}if(_.title==="2026每日派对干货"||_.title.includes("2026每日派对干货")){const $=R("part",_.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${$?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...B("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((K=_.chapters[0])==null?void 0:K.id)??"",chapterTitle:((fe=_.chapters[0])==null?void 0:fe.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","part:"+_.id),Q.dataTransfer.effectAllowed="move",k({type:"part",id:_.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ci,{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:_.badgeText||"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Nj(_)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>Q.stopPropagation(),children:[o&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),f&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",ee," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:V?"收起":"展开",onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),n(_.id)},children:V?s.jsx(Ti,{className:"w-5 h-5"}):s.jsx(wi,{className:"w-5 h-5"})})]})]}),V&&_.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(Q=>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:Q.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:z=>z.stopPropagation(),children:[m&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>m(_,Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),c&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>u(_,Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:Q.sections.map(z=>{const te=R("section",z.id);return s.jsxs("div",{draggable:!0,onDragStart:ie=>{ie.stopPropagation(),ie.dataTransfer.setData("text/plain","section:"+z.id),ie.dataTransfer.effectAllowed="move",k({type:"section",id:z.id})},onDragEnd:()=>{k(null),E(null)},onClick:()=>a(z),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${te?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",z.id,{partId:_.id,partTitle:_.title,chapterId:Q.id,chapterTitle:Q.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ie=>ie.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(z.id),onChange:()=>b(z.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ae(z)}),w.includes(z.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:ie=>ie.stopPropagation(),children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",z.clickCount??0," · 付款 ",z.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(z.hotScore??0).toFixed(1)," · 第",z.hotRank&&z.hotRank>0?z.hotRank:"-","名"]}),N&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(z),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(z),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]},z.id)})})]},Q.id))})]},_.id)}if(I)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(($,Q)=>$.sections.length>0?$.sections.map(z=>{const te=R("section",z.id);return s.jsxs("div",{draggable:!0,onDragStart:ie=>{ie.stopPropagation(),ie.dataTransfer.setData("text/plain","section:"+z.id),ie.dataTransfer.effectAllowed="move",k({type:"section",id:z.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 ${te?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",z.id,{partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ie=>ie.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(z.id),onChange:()=>b(z.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:["附录",Q+1," | ",$.title," | ",z.title]}),w.includes(z.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:["点击 ",z.clickCount??0," · 付款 ",z.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(z.hotScore??0).toFixed(1)," · 第",z.hotRank&&z.hotRank>0?z.hotRank:"-","名"]}),N&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(z),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(J,{variant:"ghost",size:"sm",onClick:()=>a(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>i(z),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(wi,{className:"w-4 h-4 text-gray-500 shrink-0"})]},z.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:["附录",Q+1," | ",$.title,"(空)"]}),s.jsx(wi,{className:"w-4 h-4 text-gray-500 shrink-0"})]},$.id))})]},_.id);if(me&&_.chapters.length===1&&_.chapters[0].sections.length===1){const $=_.chapters[0].sections[0],Q=R("section",$.id),z={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:te=>{te.stopPropagation(),te.dataTransfer.setData("text/plain","section:"+$.id),te.dataTransfer.effectAllowed="move",k({type:"section",id:$.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] ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",$.id,z),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(ci,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:te=>te.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes($.id),onChange:()=>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(or,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",$.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),children:[$.price===0||$.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:["¥",$.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",$.clickCount??0," · 付款 ",$.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",($.hotScore??0).toFixed(1)," · 第",$.hotRank&&$.hotRank>0?$.hotRank:"-","名"]}),N&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N($),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}return me?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($=>$.sections.map(Q=>{const z=R("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:te=>{te.stopPropagation(),te.dataTransfer.setData("text/plain","section:"+Q.id),te.dataTransfer.effectAllowed="move",k({type:"section",id:Q.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 ${z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...B("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:te=>te.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(Q.id),onChange:()=>b(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",children:[$.title," | ",Q.title]})]}),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:"-","名"]}),N&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(Q),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},Q.id)}))})]},_.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${Z?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...B("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((he=_.chapters[0])==null?void 0:he.id)??"",chapterTitle:((ue=_.chapters[0])==null?void 0:ue.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:$=>{$.stopPropagation(),$.dataTransfer.setData("text/plain","part:"+_.id),$.dataTransfer.effectAllowed="move",k({type:"part",id:_.id})},onDragEnd:()=>{k(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ci,{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-lg shadow-lg shadow-[#38bdac]/30 shrink-0",children:_.badgeText||O(X(se))}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:Nj(_)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:$=>$.stopPropagation(),onClick:$=>$.stopPropagation(),children:[o&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),f&&s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",ee," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:V?"收起":"展开",onMouseDown:$=>$.stopPropagation(),onClick:$=>{$.stopPropagation(),n(_.id)},children:V?s.jsx(Ti,{className:"w-5 h-5"}):s.jsx(wi,{className:"w-5 h-5"})})]})]}),V&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map($=>{const Q=R("chapter",$.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:z=>{z.stopPropagation(),z.dataTransfer.setData("text/plain","chapter:"+$.id),z.dataTransfer.effectAllowed="move",k({type:"chapter",id:$.id})},onDragEnd:()=>{k(null),E(null)},onDragEnter:z=>{z.preventDefault(),z.stopPropagation(),z.dataTransfer.dropEffect="move",E({type:"chapter",id:$.id})},onDragOver:z=>{z.preventDefault(),z.stopPropagation(),z.dataTransfer.dropEffect="move",E({type:"chapter",id:$.id})},onDragLeave:()=>E(null),onDrop:z=>{E(null);const te=Cg(z.dataTransfer.getData("text/plain"));if(!te)return;const ie={partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title};(te.type==="section"||te.type==="chapter")&&P(z,"chapter",$.id,ie)},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 ${Q?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${L("chapter",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(ci,{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:$.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:z=>z.stopPropagation(),children:[m&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>m(_,$),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),c&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Mn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>u(_,$),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:$.sections.map(z=>{const te=R("section",z.id);return s.jsxs("div",{draggable:!0,onDragStart:ie=>{ie.stopPropagation(),ie.dataTransfer.setData("text/plain","section:"+z.id),ie.dataTransfer.effectAllowed="move",k({type:"section",id:z.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 ${te?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",z.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...B("section",z.id,{partId:_.id,partTitle:_.title,chapterId:$.id,chapterTitle:$.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ie=>ie.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(z.id),onChange:()=>b(z.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx(ci,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${z.price===0||z.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),s.jsx("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:ae(z)}),w.includes(z.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Hc,{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:ie=>ie.stopPropagation(),onClick:ie=>ie.stopPropagation(),children:[z.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),z.price===0||z.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:["¥",z.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",z.clickCount??0," · 付款 ",z.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(z.hotScore??0).toFixed(1)," · 第",z.hotRank&&z.hotRank>0?z.hotRank:"-","名"]}),N&&s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(z),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(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(z),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(pn,{className:"w-3.5 h-3.5"})}),s.jsx(J,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(z),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Jn,{className:"w-3.5 h-3.5"})})]})]})]},z.id)})})]},$.id)})})]},_.id)})})}function bV(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 Re(r)}function vV(t){return Re(`/api/db/person?personId=${encodeURIComponent(t)}`)}function NV(t){var r;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(r=t==null?void 0:t.keyword)!=null&&r.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString();return Re(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const wV=10;function W4(t){const e=(t??"").trim();if(!e)return"";if(/^https?:\/\//i.test(e))return aa(e);const n=e.startsWith("/")?e:`/${e}`;return aa(zl(n))}function jV(t){const{nickname:e,avatar:n}=t,r=W4(n);return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"h-8 w-8 shrink-0 overflow-hidden rounded-full bg-gray-800",children:r?s.jsx("img",{src:r,alt:"",className:"h-full w-full object-cover",onError:a=>{a.currentTarget.style.display="none"}}):s.jsx("span",{className:"flex h-full w-full items-center justify-center text-[10px] text-gray-500",children:e.slice(0,1)})}),s.jsx("span",{className:"min-w-0 truncate text-left font-medium text-white",children:e})]})}function kV(t,e){const n=new Set(t.map(a=>a.id).filter(Boolean)),r=[...t];for(const a of e){const i=a.id;i&&!n.has(i)&&(n.add(i),r.push(a))}return r}function SV({id:t,label:e,value:n,preview:r,previewLoading:a=!1,onSelect:i,onClear:o,containerOpen:c,disabled:u=!1,hint:h,className:f,portalMountRef:m,positionContainerRef:x}){const[b,N]=g.useState(!1),[w,v]=g.useState(""),k=Ra(w,300),[M,E]=g.useState([]),[L,R]=g.useState(!1),[W,P]=g.useState(!1),[B,O]=g.useState(0),X=g.useRef(1),ae=g.useRef(!1),_=g.useRef(!1),se=g.useRef(null),ce=g.useRef(null),[me,I]=g.useState({top:0,left:0,width:320,maxH:360}),Z=g.useCallback(()=>{const $=ce.current;if(!$||typeof window>"u")return;const Q=$.getBoundingClientRect(),z=Math.min(400,Math.max(200,window.innerHeight-Q.bottom-16)),te=x==null?void 0:x.current;if(te){const ie=te.getBoundingClientRect();I({top:Q.bottom-ie.top+6,left:Q.left-ie.left,width:Math.max(Q.width,300),maxH:z})}else I({top:Q.bottom+6,left:Q.left,width:Math.max(Q.width,300),maxH:z})},[x]);g.useEffect(()=>{c||(N(!1),v(""))},[c]),g.useLayoutEffect(()=>{if(b)return Z(),window.addEventListener("scroll",Z,!0),window.addEventListener("resize",Z),()=>{window.removeEventListener("scroll",Z,!0),window.removeEventListener("resize",Z)}},[b,Z]);const V=g.useCallback(async($,Q,z)=>{if(!ae.current){ae.current=!0,z?P(!0):R(!0);try{const te=new URLSearchParams({page:String($),pageSize:String(wV),search:Q.trim()}),ie=await Re(`/api/db/users?${te}`);if(ie!=null&&ie.success&&Array.isArray(ie.users)){const we=ie.users,Be=typeof ie.total=="number"?ie.total:0;O(Be),z?we.length===0?_.current=!0:E(Ue=>{const bt=kV(Ue,we);return bt.length===Ue.length?_.current=!0:X.current=$,bt}):(E(we),X.current=$)}else ie!=null&&ie.error&&G.error(ie.error)}catch(te){G.error(te instanceof Error?te.message:"加载用户列表失败")}finally{ae.current=!1,R(!1),P(!1)}}},[]);g.useEffect(()=>{b&&(X.current=1,_.current=!1,V(1,k,!1))},[b,k,V]);const xe=g.useCallback(()=>{L||W||ae.current||_.current||B>0&&M.length>=B||V(X.current+1,k,!0)},[k,V,L,W,B,M.length]);g.useLayoutEffect(()=>{if(!b||L||W||_.current||B>0&&M.length>=B||M.length===0)return;const $=se.current;$&&($.scrollHeight>$.clientHeight+12||xe())},[b,M.length,L,W,B,xe]);const ee=$=>{($.id||"").trim()&&(i($),N(!1),v(""))},H=$=>{$.preventDefault(),$.stopPropagation(),!(u||a)&&o()},K=!!n.trim(),fe=B>0,he=typeof document>"u"?null:(m==null?void 0:m.current)??document.body,ue=b&&he&&id.createPortal(s.jsxs("div",{"data-member-user-select-portal":"",children:[s.jsx("div",{className:"fixed inset-0 z-40 bg-transparent","aria-hidden":!0,onMouseDown:$=>{$.preventDefault(),N(!1)}}),s.jsxs("div",{role:"listbox",className:"fixed z-50 overflow-hidden rounded-lg border border-gray-700 bg-[#0b1828] shadow-xl",style:{top:me.top,left:me.left,width:me.width,height:me.maxH,maxHeight:me.maxH,display:"grid",gridTemplateRows:fe?"auto auto minmax(0, 1fr) auto":"auto minmax(0, 1fr) auto"},children:[s.jsx("div",{className:"border-b border-gray-700/60 p-2 min-h-0",children:s.jsx(le,{className:"bg-[#050c18] border-gray-700 text-white h-9 text-sm",placeholder:"搜索昵称、手机号、用户 id…",value:w,onChange:$=>v($.target.value),onMouseDown:$=>$.stopPropagation(),autoFocus:!0})}),fe?s.jsxs("p",{className:"text-[11px] text-gray-500 px-3 pt-1.5 min-h-0 leading-snug",children:["已加载 ",M.length," / ",B," 条",M.length{const Q=$.currentTarget;L||W||_.current||B>0&&M.length>=B||Q.scrollHeight-Q.scrollTop-Q.clientHeight<100&&xe()},children:L&&M.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-gray-400 text-sm",children:"正在加载…"}):M.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-gray-500 text-sm px-3 text-center",children:"暂无用户,请调整搜索条件"}):s.jsxs("div",{className:"p-1.5 space-y-0.5",children:[M.map($=>{const Q=$.id||"",z=n===Q,te=W4($.avatar),ie=$.nickname&&String($.nickname).trim()||"(无昵称)";return s.jsxs("button",{type:"button",role:"option","aria-selected":z,className:_t("flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left text-sm transition-colors",z?"border-[#38bdac] bg-[#38bdac]/15 text-white":"border-transparent bg-[#050c18] hover:border-[#38bdac]/40 hover:bg-[#0a1628]"),onMouseDown:we=>we.preventDefault(),onClick:()=>ee($),children:[s.jsx("span",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-gray-800",children:te?s.jsx("img",{src:te,alt:"",className:"h-full w-full object-cover",onError:we=>{we.currentTarget.style.display="none"}}):s.jsx("span",{className:"flex h-full w-full items-center justify-center text-[11px] text-gray-500",children:ie.slice(0,1)})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium truncate",children:ie}),s.jsxs("div",{className:"text-[11px] text-gray-500 font-mono truncate mt-0.5",children:[$.phone?`${$.phone} · `:"",Q]})]})]},Q)}),W&&s.jsx("div",{className:"py-2 text-center text-gray-500 text-xs",children:"加载更多…"})]})}),s.jsx("div",{className:"flex justify-end gap-2 border-t border-gray-700/60 px-2 py-1.5 min-h-0",children:s.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"text-gray-400 h-8 text-xs",onMouseDown:$=>$.preventDefault(),onClick:()=>{o(),N(!1)},children:"清除绑定"})})]})]}),he);return s.jsxs("div",{className:_t("space-y-1.5",f),children:[typeof e=="string"?s.jsx(ne,{htmlFor:t,className:"text-gray-400 text-xs",children:e}):e,s.jsxs("div",{className:"flex gap-2 items-stretch",children:[s.jsxs("button",{ref:ce,id:t,type:"button",disabled:u,"aria-haspopup":"listbox","aria-expanded":b,className:_t("flex h-10 min-w-0 flex-1 items-center gap-2 rounded-md border bg-[#0a1628] px-3 text-left text-sm transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac]/50 focus-visible:ring-offset-0",u&&"cursor-not-allowed opacity-50",b?"border-[#38bdac] ring-1 ring-[#38bdac]/35":"border-gray-700 hover:border-gray-600"),onClick:()=>{u||(b||(v(""),Z()),N($=>!$))},children:[s.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-2 truncate",children:a?s.jsx("span",{className:"text-gray-500",children:"正在加载已绑定用户…"}):K?s.jsx(jV,{nickname:(r==null?void 0:r.nickname)||n,avatar:r==null?void 0:r.avatar}):s.jsx("span",{className:"text-gray-500",children:"选择会员用户(可搜索,可不绑定)"})}),s.jsx(Ti,{className:_t("h-4 w-4 shrink-0 text-gray-400 transition-transform",b&&"rotate-180")})]}),K&&s.jsx(J,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0 border-gray-600 text-gray-400 hover:text-white",disabled:u||a,"aria-label":"清除已选用户",onClick:H,children:s.jsx(Qn,{className:"h-4 w-4"})})]}),h&&s.jsx("div",{className:"text-[11px] text-gray-500",children:h}),ue]})}const K4=11,wj={personId:"",name:"",boundUserId:"",aliases:"",label:"",sceneId:K4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"06:00",endTime:"22:00",deviceGroups:""};function CV({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){var Q;const a=!!n,i=g.useRef(null),o=g.useRef(null),[c,u]=g.useState(wj),[h,f]=g.useState(!1),[m,x]=g.useState(!1),[b,N]=g.useState([]),[w,v]=g.useState(!1),[k,M]=g.useState(""),[E,L]=g.useState([]),[R,W]=g.useState(!1),[P,B]=g.useState(""),[O,X]=g.useState(!1),[ae,_]=g.useState(null),[se,ce]=g.useState(!1),[me,I]=g.useState({}),[Z,V]=g.useState({loading:!1,messages:[]}),xe=Ra(c.name,400),ee=Ra(c.aliases,400);g.useEffect(()=>{if(!t){V({loading:!1,messages:[]});return}const z=xe.trim(),te=ee.trim();if(!z&&!te){V({loading:!1,messages:[]});return}let ie=!1;V(Ue=>({...Ue,loading:!0}));const we=a?((n==null?void 0:n.personId)??"").trim():"",Be=new URLSearchParams;return z&&Be.set("name",xe.trim()),Be.set("aliases",ee),we&&Be.set("excludePersonId",we),Re(`/api/db/persons/check-unique?${Be.toString()}`).then(Ue=>{if(!ie){if((Ue==null?void 0:Ue.success)===!1&&(Ue!=null&&Ue.error)){V({loading:!1,messages:[Ue.error]});return}if((Ue==null?void 0:Ue.ok)===!1&&Array.isArray(Ue.messages)&&Ue.messages.length>0){V({loading:!1,messages:Ue.messages});return}V({loading:!1,messages:[]})}}).catch(()=>{ie||V({loading:!1,messages:[]})}),()=>{ie=!0}},[t,xe,ee,a,n==null?void 0:n.personId]),g.useEffect(()=>{if(t){if(M(""),_(null),ce(!1),n){u({personId:n.personId??n.name??"",name:n.name??"",boundUserId:n.userId??"",aliases:n.aliases??"",label:n.label??"",sceneId:K4,ckbApiKey:n.ckbApiKey??"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:n.remarkType??"phone",remarkFormat:n.remarkFormat??"",addFriendInterval:n.addFriendInterval??1,startTime:n.startTime??"06:00",endTime:n.endTime??"22:00",deviceGroups:n.deviceGroups??""});const z=(n.userId??"").trim();z&&(ce(!0),Re(`/api/db/users?id=${encodeURIComponent(z)}`).then(te=>{const ie=te==null?void 0:te.user;ie!=null&&ie.id?_({id:ie.id,nickname:ie.nickname&&String(ie.nickname).trim()||ie.id,phone:ie.phone,avatar:ie.avatar??void 0}):_({id:z,nickname:z,phone:void 0,avatar:void 0})}).catch(()=>{_({id:z,nickname:z,phone:void 0,avatar:void 0})}).finally(()=>ce(!1)))}else u({...wj});I({}),b.length===0&&H(""),E.length===0&&K("")}},[t,n]);const H=async z=>{v(!0);try{const te=await bV({page:1,limit:50,keyword:z});te!=null&&te.success&&Array.isArray(te.devices)?N(te.devices):te!=null&&te.error&&G.error(te.error)}catch(te){G.error(te instanceof Error?te.message:"加载设备列表失败")}finally{v(!1)}},K=async z=>{W(!0);try{const te=await NV({page:1,limit:100,keyword:z});te!=null&&te.success&&Array.isArray(te.plans)?L(te.plans):te!=null&&te.error&&G.error(te.error)}catch{G.error("加载计划列表失败")}finally{W(!1)}},fe=()=>{u(z=>{const te=(z.boundUserId||"").trim(),ie={...z,boundUserId:""};return!a&&te&&(z.personId||"").trim()===te&&(ie.personId=""),ie}),_(null)},he=z=>{const te=Array.isArray(z.deviceGroups)?z.deviceGroups.map(String).join(","):"";u(ie=>({...ie,ckbApiKey:z.apiKey||"",greeting:z.greeting||ie.greeting,tips:z.tips||ie.tips,remarkType:z.remarkType||ie.remarkType,remarkFormat:z.remarkFormat||ie.remarkFormat,addFriendInterval:z.addInterval||ie.addFriendInterval,startTime:z.startTime||ie.startTime,endTime:z.endTime||ie.endTime,deviceGroups:te||ie.deviceGroups})),X(!1),G.success(`已选择计划「${z.name}」,参数已覆盖`)},ue=P.trim()?E.filter(z=>(z.name||"").includes(P.trim())||String(z.id).includes(P.trim())):E,$=async()=>{var we;const z={};(!c.name||!String(c.name).trim())&&(z.name="请填写名称");const te=c.addFriendInterval;if((typeof te!="number"||te<1)&&(z.addFriendInterval="添加间隔至少为 1 分钟"),(((we=c.deviceGroups)==null?void 0:we.split(",").map(Be=>Be.trim()).filter(Boolean))??[]).length===0&&(z.deviceGroups="请至少选择 1 台设备"),I(z),Object.keys(z).length>0){G.error(z.name||z.addFriendInterval||z.deviceGroups||"请完善必填项");return}if(Z.messages.length>0){G.error(Z.messages[0]??"名称或别名与他人重复");return}f(!0);try{await r(c),e(!1)}catch(Be){G.error(Be instanceof Error?Be.message:"保存失败")}finally{f(!1)}};return s.jsx(It,{open:t,onOpenChange:e,children:s.jsxs(At,{ref:i,className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex min-h-0 flex-col gap-0 p-0",children:[s.jsxs("div",{ref:o,className:"relative flex min-h-0 flex-1 flex-col overflow-visible",children:[s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pt-6",children:[s.jsxs(Rt,{children:[s.jsx(Lt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Oo,{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(ne,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(le,{className:`bg-[#0a1628] text-white ${me.name?"border-red-500 focus-visible:ring-red-500":Z.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡若",value:c.name,onChange:z=>{u(te=>({...te,name:z.target.value})),me.name&&I(te=>({...te,name:void 0}))}}),me.name&&s.jsx("p",{className:"text-xs text-red-400",children:me.name})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:(c.boundUserId||"").trim()?c.boundUserId:c.personId,onChange:z=>u(te=>({...te,personId:z.target.value})),disabled:a||!!(c.boundUserId||"").trim()})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:c.label,onChange:z=>u(te=>({...te,label:z.target.value}))})]}),s.jsx(SV,{className:"col-span-3",id:"person-bound-member-user",label:"绑定会员用户(可选,与「用户管理」中用户一致)",containerOpen:t,portalMountRef:o,positionContainerRef:i,value:c.boundUserId,preview:ae,previewLoading:se,onSelect:z=>{const te=(z.id||"").trim();te&&(u(ie=>({...ie,boundUserId:te,...a?{}:{personId:te}})),_({id:te,nickname:z.nickname&&String(z.nickname).trim()||te,phone:z.phone,avatar:z.avatar??void 0}))},onClear:fe,hint:s.jsx("span",{children:"单选;保存时后端校验用户是否存在。同一会员只能绑定一个 @人物;绑定后获客统计可与超级个体对齐。"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),s.jsx(le,{className:`bg-[#0a1628] text-white ${Z.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡卡, 若若",value:c.aliases,onChange:z=>u(te=>({...te,aliases:z.target.value}))})]}),s.jsx("div",{className:"col-span-3 space-y-1",children:Z.loading?s.jsx("p",{className:"text-xs text-gray-500",children:"正在检测名称与别名是否与他人重复…"}):Z.messages.length>0?s.jsx("div",{className:"rounded-md border border-amber-600/60 bg-amber-950/25 px-3 py-2 text-xs text-amber-200 space-y-1",children:Z.messages.map((z,te)=>s.jsx("p",{children:z},`${te}-${z.slice(0,24)}`))}):null})]})]}),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 relative",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"选择存客宝获客计划"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("div",{className:"flex-1 flex items-center bg-[#0a1628] border border-gray-700 rounded-md px-3 py-2 cursor-pointer hover:border-[#38bdac]/60 text-sm",onClick:()=>X(!O),children:c.ckbApiKey?s.jsx("span",{className:"text-white truncate",children:((Q=E.find(z=>z.apiKey===c.ckbApiKey))==null?void 0:Q.name)||`获客计划 (${c.ckbApiKey.slice(0,8)}…)`}):s.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),s.jsx(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{K(P),X(!0)},disabled:R,children:R?"加载...":"刷新"})]}),O&&s.jsxs("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-[#0b1828] border border-gray-700 rounded-lg shadow-xl max-h-64 flex flex-col",children:[s.jsx("div",{className:"p-2 border-b border-gray-700/60",children:s.jsx(le,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:P,onChange:z=>B(z.target.value),onKeyDown:z=>{z.key==="Enter"&&K(P)},autoFocus:!0})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:ue.length===0?s.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:R?"加载中...":"暂无计划"}):ue.map(z=>s.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${c.ckbApiKey===z.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>he(z),children:[s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-medium",children:z.name}),s.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String(z.id)]})]}),z.enabled?s.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 rounded shrink-0 ml-2",children:"启用"}):s.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 rounded shrink-0 ml-2",children:"停用"})]},String(z.id)))}),s.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:s.jsx(J,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>X(!1),children:"关闭"})})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(ne,{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 ${me.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(le,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:c.deviceGroups?`已选择 ${c.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>x(!0)}),s.jsx(J,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>x(!0),children:"选择"})]}),me.deviceGroups?s.jsx("p",{className:"text-xs text-red-400",children:me.deviceGroups}):s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(go,{value:c.remarkType,onValueChange:z=>u(te=>({...te,remarkType:z})),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(yo,{placeholder:"选择备注类型"})}),s.jsxs(Ni,{children:[s.jsx(Gn,{value:"phone",children:"手机号"}),s.jsx(Gn,{value:"nickname",children:"昵称"}),s.jsx(Gn,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"备注格式(手机号+标签,标签不超过6字)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 {手机号}-{来源标签},总长不超过10字",value:c.remarkFormat,onChange:z=>u(te=>({...te,remarkFormat:z.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"格式:手机号+来源标签(标签≤6字,总长≤10字)"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:c.greeting,onChange:z=>u(te=>({...te,greeting:z.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(le,{type:"number",min:1,className:`bg-[#0a1628] text-white ${me.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:c.addFriendInterval,onChange:z=>{u(te=>({...te,addFriendInterval:Number(z.target.value)||1})),me.addFriendInterval&&I(te=>({...te,addFriendInterval:void 0}))}}),me.addFriendInterval&&s.jsx("p",{className:"text-xs text-red-400",children:me.addFriendInterval})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(le,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.startTime,onChange:z=>u(te=>({...te,startTime:z.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(le,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.endTime,onChange:z=>u(te=>({...te,endTime:z.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:c.tips,onChange:z=>u(te=>({...te,tips:z.target.value}))})]})]})]})]})]})]}),s.jsxs(Xt,{className:"gap-3 border-t border-gray-700/40 px-6 py-4 shrink-0",children:[s.jsx(J,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(J,{onClick:$,disabled:h||Z.messages.length>0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:h?"保存中...":a?"保存":"添加"})]})]}),m&&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(J,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>{const z=b.map(we=>String(we.id??"")),te=c.deviceGroups?c.deviceGroups.split(",").map(we=>we.trim()).filter(Boolean):[],ie=z.length>0&&z.every(we=>te.includes(we));u(we=>({...we,deviceGroups:ie?"":z.join(",")})),!ie&&z.length>0&&I(we=>({...we,deviceGroups:void 0}))},children:(()=>{const z=b.map(ie=>String(ie.id??"")),te=c.deviceGroups?c.deviceGroups.split(",").map(ie=>ie.trim()).filter(Boolean):[];return z.length>0&&z.every(ie=>te.includes(ie))?"取消全选":"全选"})()}),s.jsx(le,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:k,onChange:z=>M(z.target.value),onKeyDown:z=>{z.key==="Enter"&&H(k)}}),s.jsx(J,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>H(k),disabled:w,children:"刷新"}),s.jsx(J,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>x(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:w?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):b.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:b.map(z=>{const te=String(z.id??""),ie=c.deviceGroups?c.deviceGroups.split(",").map(Ue=>Ue.trim()).filter(Boolean):[],we=ie.includes(te),Be=()=>{let Ue;we?Ue=ie.filter(bt=>bt!==te):Ue=[...ie,te],u(bt=>({...bt,deviceGroups:Ue.join(",")})),Ue.length>0&&I(bt=>({...bt,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:we,onChange:Be}),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:z.memo||z.wechatId||`设备 ${te}`}),z.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),z.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: ",te]}),z.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",z.wechatId]}),typeof z.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",z.totalFriend]})]})]})]},te)})})}),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:["已选择"," ",c.deviceGroups?c.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(J,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>x(!1),children:"取消"}),s.jsx(J,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>x(!1),children:"确定"})]})]})]})})]})})}const Eg=JSON.stringify({singlePageUnlockTitle:"解锁完整内容",singlePagePayButtonText:"支付 ¥{price} 解锁全文",singlePageExpandedHint:"预览页不能直接付款,务必先点底栏「前往小程序」。",payTapModalTitle:"解锁说明",payTapModalContent:"全文 ¥{price}。预览里无法完成支付:请先点屏幕底部「前往小程序」进入完整版,登录后再付款解锁。",fullUnlockTitle:"解锁完整内容",fullUnlockDesc:"可先上滑阅读预览;需要全文时,点下方「支付¥{price}」查看说明",fullLockedProgressText:"已阅读约 {percent}% ,购买后继续阅读",fullPaywallTip:"转发给需要的人,一起学习还能赚佣金",notLoginUnlockDesc:"已预览约 {percent}% 内容,登录并支付 ¥{price} 后阅读全文",notLoginPaywallTip:"分享给好友一起学习,还能赚取佣金",shareTipLine:"好友经你分享购买,你可获得约 90% 收益",momentsModalTitle:"分享到朋友圈",momentsModalContent:`已复制发圈文案(非分享给好友)。 请点击右上角「···」→「分享到朋友圈」粘贴发布。`,momentsClipboardFooter:` -—— 以上为正文预览约 {percent}% ,搜「卡若创业派对」小程序阅读全文 ——`,timelineTitleSuffix:"(预览{percent}%)"},null,2);function Bc(t){if(t!=null){if(typeof t=="number"&&Number.isFinite(t))return Math.round(t);if(typeof t=="string"&&t.trim()!==""){const e=Number(t.trim().replace(/%/g,""));if(Number.isFinite(e))return Math.round(e)}}}function EV(t,e,n){const r=new Map;for(const o of t){const c=o.partId||"part-1",u=o.partTitle||"未分类",h=o.chapterId||"chapter-1",f=o.chapterTitle||"未分类";r.has(c)||r.set(c,{id:c,title:u,badgeText:n[c]||"",chapters:new Map});const m=r.get(c);m.chapters.has(h)||m.chapters.set(h,{id:h,title:f,sections:[]}),m.chapters.get(h).sections.push({id:o.id,mid:o.mid,title:o.title,price:o.price??1,filePath:o.filePath,isFree:o.isFree,isNew:o.isNew,clickCount:o.clickCount??0,payCount:o.payCount??0,hotScore:o.hotScore??0,hotRank:e.get(o.id)??0,previewPercent:Bc(o.previewPercent)})}const a=Array.from(r.values()).map(o=>({...o,chapters:Array.from(o.chapters.values())})),i=new Map;for(let o=0;o{const u=i.get(o.id),h=i.get(c.id);return u!==void 0&&h!==void 0&&u!==h?u-h:u!==void 0&&h===void 0?-1:u===void 0&&h!==void 0?1:o.id.localeCompare(c.id)})}function TV(){var dl,ul,hl;const t=_a(),[e,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState([]),[c,u]=g.useState(null),[h,f]=g.useState(!1),[m,x]=g.useState(!1),[b,N]=g.useState(!1),[w,v]=g.useState(""),[k,M]=g.useState([]),[E,L]=g.useState(!1),[R,W]=g.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[P,B]=g.useState(null),[O,Y]=g.useState(!1),[ae,_]=g.useState(!1),[se,ce]=g.useState(null),[me,I]=g.useState(!1),[X,V]=g.useState([]),[xe,ee]=g.useState(!1),[H,K]=g.useState(""),[fe,he]=g.useState(""),[ue,$]=g.useState(!1),[Q,z]=g.useState(""),[te,ie]=g.useState(!1),[we,Be]=g.useState(null),[Ue,yt]=g.useState(!1),[vn,dt]=g.useState(!1),[Et,on]=g.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[Dn,ln]=g.useState(!1),[Ut,mn]=g.useState(!1),[Sn,_n]=g.useState(1),[Xn,Lt]=g.useState([]),[xn,Ne]=g.useState(!1),[Me,We]=g.useState([]),[tt,Ot]=g.useState(!1),[wt,ze]=g.useState(20),[U,qe]=g.useState(!1),[gt,_t]=g.useState(!1),[pt,lt]=g.useState(Eg),[Tt,Wt]=g.useState(!1),[Nn,ks]=g.useState(!1),[Ss,Li]=g.useState([]),[da,Fa]=g.useState([]),[Ba,Nr]=g.useState([]),[wr,jr]=g.useState(!1),[Fr,_s]=g.useState(1),[qs,dr]=g.useState(20),[Gs,ua]=g.useState(0),[de,ve]=g.useState(1),[At,Qt]=g.useState(""),[Zt,Zn]=g.useState(!1),[kr,Br]=g.useState(null),[bt,$n]=g.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),[Vr,ha]=g.useState(!1),[cn,Hr]=g.useState(!1),[Va,ur]=g.useState(null),[Cs,fa]=g.useState(null),[Ha,$s]=g.useState({}),[zn,pa]=g.useState(null),[es,Ur]=g.useState(""),[Qo,ts]=g.useState(!1),[zs,Js]=g.useState({}),[ma,xa]=g.useState(!1),[Yo,nc]=g.useState(""),[Ua,Oi]=g.useState(""),[Di,Wa]=g.useState([]),[ga,Xo]=g.useState(0),[ft,Zo]=g.useState(1),[sc,_i]=g.useState(!1),[el,tl]=g.useState(""),nl=g.useRef(null),Sr=g.useCallback(async(T,F)=>{var ye;const S=new FormData;S.append("file",T),S.append("folder",F);const Z=await(await fetch(zl("/api/upload"),{method:"POST",body:S,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((ye=Z==null?void 0:Z.data)==null?void 0:ye.url)||(Z==null?void 0:Z.url)||""},[]),Ka=g.useCallback(T=>Sr(T,"book-images"),[Sr]),Qs=g.useCallback(T=>{const F=T.type.startsWith("video/")?"book-videos":"book-attachments";return Sr(T,F)},[Sr]),[Fs,Es]=g.useState({}),ps=T=>String(T||"").trim().slice(0,8),qa=g.useMemo(()=>{const T=new Map;return Xn.forEach((F,S)=>{T.set(F.id,S+1)}),T},[Xn]),dn=EV(e,qa,Fs),sl=e.length,Ga=10,Wr=Math.max(1,Math.ceil(Xn.length/Ga)),rc=Xn.slice((Sn-1)*Ga,Sn*Ga),ns=async()=>{a(!0);try{const T=await Re("/api/db/book?action=list",{cache:"no-store"});n(Array.isArray(T==null?void 0:T.sections)?T.sections:[])}catch(T){console.error(T),n([])}finally{a(!1)}},Ja=async()=>{try{const T=await Re("/api/db/config?key=book_part_badges",{cache:"no-store"});let F={};if(T&&Array.isArray(T.data)){const D=T.data.find(Z=>Z&&Z.configKey==="book_part_badges");D&&D.configValue&&typeof D.configValue=="object"&&!Array.isArray(D.configValue)&&(F=D.configValue)}else T&&T.data&&typeof T.data=="object"&&!Array.isArray(T.data)&&(F=T.data);const S={};Object.keys(F).forEach(D=>{const Z=ps(F[D]);Z&&(S[D]=Z)}),Es(S)}catch(T){console.error(T),Es({})}},Bs=async()=>{Ne(!0);try{const T=await Re("/api/db/book?action=ranking",{cache:"no-store"}),F=Array.isArray(T==null?void 0:T.sections)?T.sections:[];Lt(F);const S=F.filter(D=>D.isPinned).map(D=>D.id);We(S)}catch(T){console.error(T),Lt([])}finally{Ne(!1)}};g.useEffect(()=>{ns(),Bs(),Ja()},[]);const xd=T=>{o(F=>F.includes(T)?F.filter(S=>S!==T):[...F,T])},Qa=g.useCallback(T=>{const F=e,S=T.flatMap(D=>{const Z=F.find(ye=>ye.id===D.id);return Z?[{...Z,partId:D.partId,partTitle:D.partTitle,chapterId:D.chapterId,chapterTitle:D.chapterTitle}]:[]});return n(S),Yt("/api/db/book",{action:"reorder",items:T}).then(D=>{D&&D.success===!1&&(n(F),G.error("排序失败: "+(D&&typeof D=="object"&&"error"in D?D.error:"未知错误")))}).catch(D=>{n(F),console.error("排序失败:",D),G.error("排序失败: "+(D instanceof Error?D.message:"网络或服务异常"))}),Promise.resolve()},[e]),Ya=async T=>{if(confirm(`确定要删除章节「${T.title}」吗?此操作不可恢复。`))try{const F=await bi(`/api/db/book?id=${encodeURIComponent(T.id)}`);F&&F.success!==!1?(G.success("已删除"),ns(),Bs()):G.error("删除失败: "+(F&&typeof F=="object"&&"error"in F?F.error:"未知错误"))}catch(F){console.error(F),G.error("删除失败")}},ms=g.useCallback(async()=>{ln(!0);try{const T=await Re("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),F=T&&T.data;F&&typeof F.readWeight=="number"&&typeof F.recencyWeight=="number"&&typeof F.payWeight=="number"&&on({readWeight:Math.max(0,Math.min(1,F.readWeight)),recencyWeight:Math.max(0,Math.min(1,F.recencyWeight)),payWeight:Math.max(0,Math.min(1,F.payWeight))})}catch{}finally{ln(!1)}},[]);g.useEffect(()=>{vn&&ms()},[vn,ms]);const $i=async()=>{const{readWeight:T,recencyWeight:F,payWeight:S}=Et,D=T+F+S;if(Math.abs(D-1)>.001){G.error("三个权重之和必须等于 1");return}mn(!0);try{const Z=await xt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:T,recencyWeight:F,payWeight:S},description:"文章排名算法权重"});Z&&Z.success!==!1?(G.success("排名权重已保存"),dt(!1),ns(),Bs()):G.error("保存失败: "+(Z&&typeof Z=="object"&&"error"in Z?Z.error:""))}catch(Z){console.error(Z),G.error("保存失败")}finally{mn(!1)}},Xa=g.useCallback(async()=>{Ot(!0);try{const T=await Re("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),F=T&&T.data;Array.isArray(F)&&We(F)}catch{}finally{Ot(!1)}},[]),xs=g.useCallback(async()=>{try{const[T,F]=await Promise.all([Re("/api/db/persons"),Re("/api/db/vip-members?limit=500").catch(()=>null)]),S={};if(F!=null&&F.success&&Array.isArray(F.data))for(const D of F.data){const Z=(D.id||"").trim();if(!Z)continue;const ye=D.webhookUrl!=null?String(D.webhookUrl).trim():"";ye&&(S[Z]=ye)}$s(S),T!=null&&T.success&&T.persons&&Li(T.persons.map(D=>{const Z=D.deviceGroups,ye=Array.isArray(Z)?Z.join(","):Z??"";return{id:D.token??D.personId??"",personId:D.personId,name:D.name,personSource:D.personSource??"",userId:D.userId,aliases:D.aliases??"",label:D.label??"",ckbApiKey:D.ckbApiKey??"",ckbPlanId:D.ckbPlanId,remarkType:D.remarkType,remarkFormat:D.remarkFormat,addFriendInterval:D.addFriendInterval,startTime:D.startTime,endTime:D.endTime,deviceGroups:ye,isPinned:!!D.isPinned}}))}catch{}},[]),Za=g.useCallback(async(T,F)=>{const S=(T.personId||T.id||"").trim();if(!S){G.error("缺少 personId");return}F&&!(T.userId||"").trim()&&G.info("未绑定会员时,小程序仍显示 @ 名称,头像可能为默认图");try{const D=await Yt("/api/db/persons/pin",{personId:S,isPinned:F});if(!(D!=null&&D.success)){G.error((D==null?void 0:D.error)||"置顶失败");return}G.success(F?"已设为小程序首页置顶(全局仅一条)":"已取消置顶"),await xs()}catch(D){G.error(D instanceof Error?D.message:"操作失败")}},[xs]),Kr=g.useCallback(T=>{const F=(T.userId||"").trim();if(!F){G.info("未绑定会员的人物无法配置:飞书群 Webhook 按「超级个体用户」维度保存,请先为该人物绑定会员用户。");return}pa({userId:F,name:T.name}),Ur((Ha[F]||"").trim())},[Ha]),ei=g.useCallback(async()=>{if(!zn)return;const T=zn.userId,F=es.trim();if(F&&!/^https?:\/\//i.test(F)){G.error("Webhook 地址需以 http/https 开头");return}ts(!0);try{const S=await Yt("/api/db/vip-members/webhook",{userId:T,webhookUrl:F});if(!(S!=null&&S.success)){G.error((S==null?void 0:S.error)||"保存飞书群 Webhook 失败");return}G.success(F?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),pa(null),Ur(""),$s(D=>{const Z={...D};return F?Z[T]=F:delete Z[T],Z})}catch{G.error("保存飞书群 Webhook 失败")}finally{ts(!1)}},[zn,es]),hr=g.useCallback(async()=>{try{const T=await Re("/api/db/link-tags");T!=null&&T.success&&T.linkTags&&Fa(T.linkTags.map(F=>({id:F.tagId,label:F.label,url:F.url,type:F.type||"url",appId:F.appId||"",pagePath:F.pagePath||"",hasAppSecret:!!F.hasAppSecret})))}catch{}},[]),Ys=g.useCallback(async()=>{try{const T=await Re("/api/db/config/full?key=ckb_lead_webhook_url",{cache:"no-store"});T!=null&&T.success&&typeof T.data=="string"&&tl(T.data)}catch{}},[]),zi=g.useCallback(async()=>{try{const T=await Re("/api/db/ckb-person-leads");if(T!=null&&T.success&&T.byPerson){const F={};for(const S of T.byPerson)F[S.token]=S.total;Js(F)}}catch{}},[]),Cr=g.useCallback(async(T,F,S=1)=>{nc(T),Oi(F),xa(!0),Zo(S),_i(!0);try{const D=await Re(`/api/db/ckb-person-leads?token=${encodeURIComponent(T)}&page=${S}&pageSize=20`);D!=null&&D.success?(Wa(D.records||[]),Xo(D.total||0)):G.error((D==null?void 0:D.error)||"加载获客详情失败")}catch(D){G.error(D instanceof Error?D.message:"加载获客详情失败")}finally{_i(!1)}},[]),ya=g.useCallback(async()=>{jr(!0);try{const T=new URLSearchParams({page:String(Fr),pageSize:String(qs)}),F=At.trim();F&&T.set("search",F);const S=await Re(`/api/db/link-tags?${T.toString()}`);if(S!=null&&S.success){const D=Array.isArray(S.linkTags)?S.linkTags:[];Nr(D.map(Z=>({id:Z.tagId,label:Z.label,aliases:Z.aliases||"",url:Z.url,type:Z.type||"url",appId:Z.appId||"",pagePath:Z.pagePath||"",hasAppSecret:!!Z.hasAppSecret}))),ua(typeof S.total=="number"?S.total:0),ve(typeof S.totalPages=="number"&&S.totalPages>0?S.totalPages:1)}}catch(T){console.error(T),G.error("加载链接标签失败")}finally{jr(!1)}},[Fr,qs,At]),[qr,Gr]=g.useState([]),[Xs,gn]=g.useState(""),[Er,Zs]=g.useState(!1),ba=g.useRef(null),rl=g.useCallback(async()=>{try{const T=await Re("/api/admin/linked-miniprograms");T!=null&&T.success&&Array.isArray(T.data)&&Gr(T.data.map(F=>({...F,key:F.key})))}catch{}},[]),Fi=qr.filter(T=>!Xs.trim()||T.name.toLowerCase().includes(Xs.toLowerCase())||T.key&&T.key.toLowerCase().includes(Xs.toLowerCase())||T.appId.toLowerCase().includes(Xs.toLowerCase())),Bi=async T=>{const F=Me.includes(T)?Me.filter(S=>S!==T):[...Me,T];We(F);try{await xt("/api/db/config",{key:"pinned_section_ids",value:F,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),Bs()}catch{We(Me)}},va=g.useCallback(async()=>{qe(!0);try{const T=await Re("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),F=T&&T.data;typeof F=="number"&&F>0&&F<=100&&ze(F)}catch{}finally{qe(!1)}},[]),Vi=async()=>{if(wt<1||wt>100){G.error("预览比例需在 1~100 之间");return}_t(!0);try{const T=await xt("/api/db/config",{key:"unpaid_preview_percent",value:wt,description:"小程序未付费内容默认预览比例(%)"});T&&T.success!==!1?G.success("预览比例已保存"):G.error("保存失败: "+(T.error||""))}catch{G.error("保存失败")}finally{_t(!1)}},Hi=g.useCallback(async()=>{Wt(!0);try{const T=await Re("/api/db/config/full?key=read_preview_ui",{cache:"no-store"}),F=T&&T.data;F!=null&&typeof F=="object"&&!Array.isArray(F)&&Object.keys(F).length>0?lt(JSON.stringify(F,null,2)):lt(Eg)}catch{lt(Eg)}finally{Wt(!1)}},[]),gd=async()=>{let T;try{T=JSON.parse(pt)}catch{G.error("JSON 格式错误,请检查括号与引号");return}ks(!0);try{const F=await xt("/api/db/config",{key:"read_preview_ui",value:T,description:"阅读页/朋友圈付费墙与分享文案(占位符 {percent} {price})"});F&&F.success!==!1?G.success("阅读页文案已保存"):G.error("保存失败: "+(F.error||""))}catch{G.error("保存失败")}finally{ks(!1)}};g.useEffect(()=>{Xa(),va(),Hi(),xs(),hr(),zi(),rl(),Ys()},[Xa,va,Hi,xs,hr,zi,rl,Ys]),g.useEffect(()=>{ya()},[ya]);const al=async T=>{Be({section:T,orders:[]}),yt(!0);try{const F=await Re(`/api/db/book?action=section-orders&id=${encodeURIComponent(T.id)}`),S=F!=null&&F.success&&Array.isArray(F.orders)?F.orders:[];Be(D=>D?{...D,orders:S}:null)}catch(F){console.error(F),Be(S=>S?{...S,orders:[]}:null)}finally{yt(!1)}},il=async T=>{x(!0);try{const F=T.mid!=null&&T.mid>0?`/api/db/book?action=read&mid=${T.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(T.id)}`,S=await Re(F);if(S!=null&&S.success&&S.section){const D=S.section,Z=D.editionPremium===!0,ye=Bc(D.previewPercent)??Bc(D.preview_percent),Ce=Bc(T.previewPercent);u({id:T.id,originalId:T.id,title:S.section.title??T.title,price:S.section.price??T.price,content:S.section.content??"",filePath:T.filePath,isFree:T.isFree||T.price===0,isNew:D.isNew??T.isNew,isPinned:Me.includes(T.id),hotScore:T.hotScore??0,previewPercent:ye??Ce??void 0,editionStandard:Z?!1:D.editionStandard??!0,editionPremium:Z})}else u({id:T.id,originalId:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree,isNew:T.isNew,isPinned:Me.includes(T.id),hotScore:T.hotScore??0,previewPercent:Bc(T.previewPercent),editionStandard:!0,editionPremium:!1}),S&&!S.success&&G.error("无法读取文件内容: "+(S.error||"未知错误"))}catch(F){console.error(F),u({id:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree,previewPercent:Bc(T.previewPercent)})}finally{x(!1)}},ol=async()=>{var T;if(c){N(!0);try{let F=c.content||"";const S=[new RegExp(`^#+\\s*${c.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${c.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(T=c.title)==null?void 0:T.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const mt of S)F=F.replace(mt,"");F=F.replace(/^\s*\n+/,"").trim();const D=c.originalId||c.id,Z=c.id!==D,ye={id:D,...Z?{newId:c.id}:{},title:c.title,price:c.isFree?0:c.price,content:F,isFree:c.isFree||c.price===0,isNew:c.isNew,hotScore:c.hotScore,editionStandard:c.editionPremium?!1:c.editionStandard??!0,editionPremium:c.editionPremium??!1,saveToFile:!0};c.previewPercent===null?ye.previewPercent=null:typeof c.previewPercent=="number"&&Number.isFinite(c.previewPercent)&&(ye.previewPercent=c.previewPercent);const Ce=await Yt("/api/db/book",ye,{timeout:z1}),De=Z?c.id:D;c.isPinned!==Me.includes(De)&&await Bi(De),Ce&&Ce.success!==!1?(G.success(`已保存:${c.title}`),u(null),ns(),xs(),hr()):G.error("保存失败: "+(Ce&&typeof Ce=="object"&&"error"in Ce?Ce.error:"未知错误"))}catch(F){console.error(F);const S=F instanceof Error&&F.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";G.error(S)}finally{N(!1)}}},ac=async()=>{if(!R.id||!R.title){G.error("请填写章节ID和标题");return}N(!0);try{const T=dn.find(D=>D.id===R.partId),F=T==null?void 0:T.chapters.find(D=>D.id===R.chapterId),S=await Yt("/api/db/book",{id:R.id,title:R.title,price:R.isFree?0:R.price,content:R.content||"",partId:R.partId,partTitle:(T==null?void 0:T.title)??"",chapterId:R.chapterId,chapterTitle:(F==null?void 0:F.title)??"",isFree:R.isFree,isNew:R.isNew,editionStandard:R.editionPremium?!1:R.editionStandard??!0,editionPremium:R.editionPremium??!1,hotScore:R.hotScore??0,saveToFile:!1},{timeout:z1});if(S&&S.success!==!1){if(R.isPinned){const D=[...Me,R.id];We(D);try{await xt("/api/db/config",{key:"pinned_section_ids",value:D,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}G.success(`章节创建成功:${R.title}`),f(!1),W({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),ns(),xs(),hr()}else G.error("创建失败: "+(S&&typeof S=="object"&&"error"in S?S.error:"未知错误"))}catch(T){console.error(T),G.error("创建失败")}finally{N(!1)}},ic=T=>{W(F=>{var S;return{...F,partId:T.id,chapterId:((S=T.chapters[0])==null?void 0:S.id)??"chapter-1"}}),f(!0)},yd=T=>{B({id:T.id,title:T.title,badgeText:ps(T.badgeText)})},bd=async()=>{var T;if((T=P==null?void 0:P.title)!=null&&T.trim()){Y(!0);try{const F=e.map(D=>({id:D.id,partId:D.partId||"part-1",partTitle:D.partId===P.id?P.title.trim():D.partTitle||"",chapterId:D.chapterId||"chapter-1",chapterTitle:D.chapterTitle||""})),S=await Yt("/api/db/book",{action:"reorder",items:F});if(S&&S.success!==!1){const D=P.title.trim(),Z={...Fs},ye=ps(P.badgeText);ye?Z[P.id]=ye:delete Z[P.id];const Ce=await xt("/api/db/config",{key:"book_part_badges",value:Z,description:"目录篇名角标(key=part_id, value=角标文案)"});if(Ce&&Ce.success===!1){G.error("更新篇名角标失败: "+(Ce.error||"未知错误"));return}Es(Z),n(De=>De.map(mt=>mt.partId===P.id?{...mt,partTitle:D}:mt)),B(null),ns()}else G.error("更新篇名失败: "+(S&&typeof S=="object"&&"error"in S?S.error:"未知错误"))}catch(F){console.error(F),G.error("更新篇名失败")}finally{Y(!1)}}},gs=T=>{const F=T.chapters.length+1,S=`chapter-${T.id}-${F}-${Date.now()}`;W({id:`${F}.1`,title:"新章节",price:1,partId:T.id,chapterId:S,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),f(!0)},oc=(T,F)=>{const S=F.sections;let D=1,Z=!1,ye=!1;if(S.length>0){const Ce=typeof S[0].price=="number"?S[0].price:Number(S[0].price)||1,De=!!(S[0].isFree||Ce===0);ye=S.some(mt=>{const Le=typeof mt.price=="number"?mt.price:Number(mt.price)||1,vt=!!(mt.isFree||Le===0);return Le!==Ce||vt!==De}),D=De?0:Ce,Z=De}ce({part:T,chapter:F,title:F.title,price:D,isFree:Z,priceMixed:ye,initialTitle:F.title,initialPrice:D,initialIsFree:Z})},lc=async()=>{var Z;if(!((Z=se==null?void 0:se.title)!=null&&Z.trim()))return;const T=se,F=T.title.trim(),S=F!==T.initialTitle,D=T.isFree!==T.initialIsFree||!T.isFree&&Number(T.price)!==Number(T.initialPrice);if(!S&&!D){G.info("未修改任何内容"),ce(null);return}if(T.priceMixed&&D){const ye=T.chapter.sections.length,Ce=T.isFree?"全部设为免费":`全部设为 ¥${T.price}`;if(!confirm(`本章 ${ye} 节当前定价不一致,保存后将${Ce},确定?`))return}I(!0);try{if(S){const ye=e.map(Le=>({id:Le.id,partId:Le.partId||T.part.id,partTitle:Le.partId===T.part.id?T.part.title:Le.partTitle||"",chapterId:Le.chapterId||T.chapter.id,chapterTitle:Le.partId===T.part.id&&Le.chapterId===T.chapter.id?F:Le.chapterTitle||""})),Ce=await Yt("/api/db/book",{action:"reorder",items:ye});if(Ce&&Ce.success===!1){G.error("保存章节名失败: "+(Ce&&typeof Ce=="object"&&"error"in Ce?Ce.error:"未知错误"));return}const De=T.part.id,mt=T.chapter.id;n(Le=>Le.map(vt=>vt.partId===De&&vt.chapterId===mt?{...vt,chapterTitle:F}:vt))}if(D){const ye=await Yt("/api/db/book",{action:"update-chapter-pricing",partId:T.part.id,chapterId:T.chapter.id,price:T.isFree?0:Number(T.price)||0,isFree:T.isFree});if(ye&&ye.success===!1){G.error("保存定价失败: "+(ye&&typeof ye=="object"&&"error"in ye?ye.error:"未知错误")),S&&ns();return}}ce(null),ns(),G.success("已保存")}catch(ye){console.error(ye),G.error("保存失败")}finally{I(!1)}},vd=async(T,F)=>{const S=F.sections.map(D=>D.id);if(S.length===0){G.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${T.chapters.indexOf(F)+1}章 | ${F.title}」吗?将删除共 ${S.length} 节,此操作不可恢复。`))try{for(const D of S)await bi(`/api/db/book?id=${encodeURIComponent(D)}`);ns()}catch(D){console.error(D),G.error("删除失败")}},Nd=async()=>{if(!Q.trim()){G.error("请输入篇名");return}ie(!0);try{const T=`part-new-${Date.now()}`,F="chapter-1",S=`part-placeholder-${Date.now()}`,D=await Yt("/api/db/book",{id:S,title:"占位节(可编辑)",price:0,content:"",partId:T,partTitle:Q.trim(),chapterId:F,chapterTitle:"第1章 | 待编辑",saveToFile:!1});D&&D.success!==!1?(G.success(`篇「${Q}」创建成功`),_(!1),z(""),ns()):G.error("创建失败: "+(D&&typeof D=="object"&&"error"in D?D.error:"未知错误"))}catch(T){console.error(T),G.error("创建失败")}finally{ie(!1)}},wd=async()=>{if(X.length===0){G.error("请先勾选要移动的章节");return}const T=dn.find(S=>S.id===H),F=T==null?void 0:T.chapters.find(S=>S.id===fe);if(!T||!F||!H||!fe){G.error("请选择目标篇和章");return}$(!0);try{const S=()=>{const Ce=new Set(X),De=e.map(Ft=>({id:Ft.id,partId:Ft.partId||"",partTitle:Ft.partTitle||"",chapterId:Ft.chapterId||"",chapterTitle:Ft.chapterTitle||""})),mt=De.filter(Ft=>Ce.has(Ft.id)).map(Ft=>({...Ft,partId:H,partTitle:T.title||H,chapterId:fe,chapterTitle:F.title||fe})),Le=De.filter(Ft=>!Ce.has(Ft.id));let vt=Le.length;for(let Ft=Le.length-1;Ft>=0;Ft-=1){const Fn=Le[Ft];if(Fn.partId===H&&Fn.chapterId===fe){vt=Ft+1;break}}return[...Le.slice(0,vt),...mt,...Le.slice(vt)]},D=async()=>{const Ce=S(),De=await Yt("/api/db/book",{action:"reorder",items:Ce});return De&&De.success!==!1?(G.success(`已移动 ${X.length} 节到「${T.title}」-「${F.title}」`),ee(!1),V([]),await ns(),!0):!1},Z={action:"move-sections",sectionIds:X,targetPartId:H,targetChapterId:fe,targetPartTitle:T.title||H,targetChapterTitle:F.title||fe},ye=await Yt("/api/db/book",Z);if(ye&&ye.success!==!1)G.success(`已移动 ${ye.count??X.length} 节到「${T.title}」-「${F.title}」`),ee(!1),V([]),await ns();else{const Ce=ye&&typeof ye=="object"&&"error"in ye?ye.error||"":"未知错误";if((Ce.includes("缺少 id")||Ce.includes("无效的 action"))&&await D())return;G.error("移动失败: "+Ce)}}catch(S){console.error(S),G.error("移动失败: "+(S instanceof Error?S.message:"网络或服务异常"))}finally{$(!1)}},ll=T=>{V(F=>F.includes(T)?F.filter(S=>S!==T):[...F,T])},cl=async T=>{const F=e.filter(S=>S.partId===T.id).map(S=>S.id);if(F.length===0){G.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${T.title}」整篇吗?将删除共 ${F.length} 节内容,此操作不可恢复。`))try{for(const S of F)await bi(`/api/db/book?id=${encodeURIComponent(S)}`);ns()}catch(S){console.error(S),G.error("删除失败")}},cc=async()=>{var T;if(w.trim()){L(!0);try{const F=await Re(`/api/search?q=${encodeURIComponent(w)}`);F!=null&&F.success&&((T=F.data)!=null&&T.results)?M(F.data.results):(M([]),F&&!F.success&&G.error("搜索失败: "+F.error))}catch(F){console.error(F),M([]),G.error("搜索失败")}finally{L(!1)}}},Ui=dn.find(T=>T.id===R.partId),Wi=(Ui==null?void 0:Ui.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:["共 ",dn.length," 篇 · ",sl," 节内容"]})]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(J,{onClick:()=>dt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Bh,{className:"w-4 h-4 mr-2"}),"排名算法"]})})]}),s.jsx(Pt,{open:h,onOpenChange:f,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(It,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"章节ID *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:R.id,onChange:T=>W({...R,id:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:R.isFree?0:R.price,onChange:T=>W({...R,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:R.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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:R.isFree,onChange:T=>W({...R,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(ne,{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:R.isNew,onChange:T=>W({...R,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(ne,{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:R.isPinned,onChange:T=>W({...R,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(ne,{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:R.editionPremium!==!0,onChange:()=>W({...R,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:R.editionPremium===!0,onChange:()=>W({...R,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(ne,{className:"text-gray-300",children:"热度分"}),s.jsx(le,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:R.hotScore??0,onChange:T=>W({...R,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:R.title,onChange:T=>W({...R,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(ne,{className:"text-gray-300",children:"所属篇"}),s.jsxs(yo,{value:R.partId,onValueChange:T=>{var S;const F=dn.find(D=>D.id===T);W({...R,partId:T,chapterId:((S=F==null?void 0:F.chapters[0])==null?void 0:S.id)??"chapter-1"})},children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(bo,{})}),s.jsxs(Ni,{className:"bg-[#0f2137] border-gray-700",children:[dn.map(T=>s.jsx(Gn,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),dn.length===0&&s.jsx(Gn,{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(ne,{className:"text-gray-300",children:"所属章"}),s.jsxs(yo,{value:R.chapterId,onValueChange:T=>W({...R,chapterId:T}),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(bo,{})}),s.jsxs(Ni,{className:"bg-[#0f2137] border-gray-700",children:[Wi.map(T=>s.jsx(Gn,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),Wi.length===0&&s.jsx(Gn,{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(ne,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(R0,{content:R.content||"",onChange:T=>W({...R,content:T}),onImageUpload:Ka,onMediaUpload:Qs,persons:Ss,linkTags:da,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(Xt,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(J,{variant:"outline",onClick:()=>f(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:ac,disabled:b||!R.id||!R.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(He,{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(Pt,{open:!!P,onOpenChange:T=>!T&&B(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),P&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"篇名"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.title,onChange:T=>B({...P,title:T.target.value}),placeholder:"输入篇名"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"左侧图标文字(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.badgeText||"",onChange:T=>B({...P,badgeText:ps(T.target.value)}),placeholder:"例如:派 / 新 / 热",maxLength:8}),s.jsx("p",{className:"text-xs text-gray-500",children:"保存后会同步到目录左侧图标文字(小程序与管理端目录树)。"})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>B(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:bd,disabled:O||!((dl=P==null?void 0:P.title)!=null&&dl.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:O?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Pt,{open:!!se,onOpenChange:T=>!T&&ce(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsxs(It,{children:[s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),s.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),se&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:se.title,onChange:T=>ce({...se,title:T.target.value}),placeholder:"输入章节名称"})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[s.jsxs(ne,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",se.chapter.sections.length," 节)"]}),se.priceMixed&&s.jsx("p",{className:"text-amber-400/90 text-xs",children:"当前各节定价不一致,保存后将按下方设置全部统一。"}),s.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[s.jsxs("div",{className:"space-y-1 flex-1 min-w-[120px]",children:[s.jsx("span",{className:"text-gray-500 text-xs",children:"价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:se.isFree?0:se.price,onChange:T=>ce({...se,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:se.isFree,min:0,step:.01})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pb-2",children:[s.jsx("input",{type:"checkbox",checked:se.isFree||se.price===0,onChange:T=>ce({...se,isFree:T.target.checked,price:T.target.checked?0:se.initialPrice>0?se.initialPrice:1}),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac]"}),s.jsx("span",{className:"text-gray-400 text-sm",children:"本章全部免费"})]})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>ce(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:lc,disabled:me||!((ul=se==null?void 0:se.title)!=null&&ul.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Pt,{open:xe,onOpenChange:T=>{var F;if(ee(T),T&&dn.length>0){const S=dn[0];K(S.id),he(((F=S.chapters[0])==null?void 0:F.id)??"")}},children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(It,{children:s.jsx(Rt,{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:X.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"目标篇"}),s.jsxs(yo,{value:H,onValueChange:T=>{var S;K(T);const F=dn.find(D=>D.id===T);he(((S=F==null?void 0:F.chapters[0])==null?void 0:S.id)??"")},children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(bo,{placeholder:"选择篇"})}),s.jsx(Ni,{className:"bg-[#0f2137] border-gray-700",children:dn.map(T=>s.jsx(Gn,{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(ne,{className:"text-gray-300",children:"目标章"}),s.jsxs(yo,{value:fe,onValueChange:he,children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(bo,{placeholder:"选择章"})}),s.jsx(Ni,{className:"bg-[#0f2137] border-gray-700",children:(((hl=dn.find(T=>T.id===H))==null?void 0:hl.chapters)??[]).map(T=>s.jsx(Gn,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>ee(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:wd,disabled:ue||X.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:ue?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Pt,{open:!!we,onOpenChange:T=>!T&&Be(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white",children:["付款记录 — ",(we==null?void 0:we.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:Ue?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):we&&we.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):we?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:we.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 F=T.userId??T.openId??"-";return F.length>12?F.slice(0,6)+"..."+F.slice(-4):F})()})}),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(Pt,{open:vn,onOpenChange:dt,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Bh,{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)"}),Dn?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(ne,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(le,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Et.readWeight,onChange:T=>on(F=>({...F,readWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(le,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Et.recencyWeight,onChange:T=>on(F=>({...F,recencyWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(le,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Et.payWeight,onChange:T=>on(F=>({...F,payWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(Et.readWeight+Et.recencyWeight+Et.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(J,{onClick:$i,disabled:Ut||Math.abs(Et.readWeight+Et.recencyWeight+Et.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Ut?"保存中...":"保存权重"})]})]})]})}),s.jsx(Pt,{open:ae,onOpenChange:_,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:Q,onChange:T=>z(T.target.value),placeholder:"输入篇名"})]})}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>{_(!1),z("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:Nd,disabled:te||!Q.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:te?s.jsxs(s.Fragment,{children:[s.jsx(He,{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(Pt,{open:!!c,onOpenChange:()=>u(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(It,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),c&&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(ne,{className:"text-gray-300",children:"章节ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.id,onChange:T=>u({...c,id:T.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:c.isFree?0:c.price,onChange:T=>u({...c,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:c.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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:c.isFree||c.price===0,onChange:T=>u({...c,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(ne,{className:"text-gray-300",children:"预览%"}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",placeholder:`全局 ${wt}%`,value:c.previewPercent!=null?String(c.previewPercent):"",onChange:T=>{const F=T.target.value.trim();if(F===""){u({...c,previewPercent:null});return}const S=Number(F);Number.isFinite(S)&&u({...c,previewPercent:Math.min(100,Math.max(1,Math.round(S)))})}})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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:c.isNew??!1,onChange:T=>u({...c,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(ne,{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:c.isPinned??!1,onChange:T=>u({...c,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(ne,{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:c.editionPremium!==!0,onChange:()=>u({...c,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:c.editionPremium===!0,onChange:()=>u({...c,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(ne,{className:"text-gray-300",children:"热度分"}),s.jsx(le,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:c.hotScore??0,onChange:T=>u({...c,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"章节标题"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.title,onChange:T=>u({...c,title:T.target.value})})]}),c.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"文件路径"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:c.filePath,disabled:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),m?s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(R0,{ref:nl,content:c.content||"",onChange:T=>u({...c,content:T}),onImageUpload:Ka,onMediaUpload:Qs,persons:Ss,linkTags:da,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(Xt,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[c&&s.jsxs(J,{variant:"outline",onClick:()=>al({id:c.id,title:c.title,price:c.price}),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent mr-auto",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(J,{variant:"outline",onClick:()=>u(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(J,{onClick:ol,disabled:b,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(Vl,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Do,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Bt,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(Bt,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(Vg,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(Bt,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(lr,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(Bt,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(Aa,{className:"w-4 h-4 mr-2"}),"@列表"]}),s.jsxs(Bt,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(L1,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),s.jsxs(Vt,{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(or,{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:sl}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(J,{onClick:()=>f(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(J,{onClick:()=>_(!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(Mn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(J,{variant:"outline",onClick:()=>ee(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",X.length," 节)"]})]}),r?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(yV,{parts:dn,expandedParts:i,onTogglePart:xd,onReorder:Qa,onReadSection:il,onDeleteSection:Ya,onAddSectionInPart:ic,onAddChapterInPart:gs,onDeleteChapter:vd,onEditPart:yd,onDeletePart:cl,onEditChapter:oc,selectedSectionIds:X,onToggleSectionSelect:ll,onShowSectionOrders:al,pinnedSectionIds:Me})]}),s.jsx(Vt,{value:"search",className:"space-y-4",children:s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{children:s.jsx(ot,{className:"text-white",children:"内容搜索"})}),s.jsxs($e,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:w,onChange:T=>v(T.target.value),onKeyDown:T=>T.key==="Enter"&&cc()}),s.jsx(J,{onClick:cc,disabled:E||!w.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:E?s.jsx(He,{className:"w-4 h-4 animate-spin"}):s.jsx(lr,{className:"w-4 h-4"})})]}),k.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",k.length," 个结果"]}),k.map(T=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>{const F=e.find(S=>S.id===T.id);il({id:T.id,mid:T.mid,title:T.title,price:T.price??1,filePath:"",previewPercent:F==null?void 0:F.previewPercent})},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:T.id}),s.jsx("span",{className:"text-white",children:T.title}),Me.includes(T.id)&&s.jsx(Hc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Ve,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:T.matchType==="title"?"标题匹配":"内容匹配"})]}),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(Vt,{value:"ranking",className:"space-y-4",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Bh,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsxs($e,{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(ne,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(le,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:wt,onChange:T=>ze(Math.max(1,Math.min(100,Number(T.target.value)||20))),disabled:U}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(J,{size:"sm",onClick:Vi,disabled:gt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:gt?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",wt,"% 内容;章节「预览%」可单独覆盖"]})]}),s.jsxs("div",{className:"mt-6 space-y-2",children:[s.jsx(ne,{className:"text-gray-400 text-sm",children:"阅读页 / 朋友圈文案(JSON)"}),s.jsxs("p",{className:"text-xs text-gray-500",children:["占位符:",s.jsx("code",{className:"text-gray-400",children:"{percent}"})," 为预览比例、",s.jsx("code",{className:"text-gray-400",children:"{price}"})," 为章节价;与小程序付费墙、复制发圈、单页模式弹窗一致。"]}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-gray-200 font-mono text-xs min-h-[280px]",value:pt,onChange:T=>lt(T.target.value),disabled:Tt,spellCheck:!1}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>Hi(),disabled:Tt,children:"重新加载"}),s.jsx(J,{type:"button",size:"sm",onClick:gd,disabled:Nn||Tt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Nn?"保存中...":"保存文案配置"})]})]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Vg,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",Xn.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Bs(),disabled:xn,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(He,{className:`w-4 h-4 ${xn?"animate-spin":""}`})}),s.jsx(J,{variant:"ghost",size:"sm",disabled:Sn<=1||xn,onClick:()=>_n(T=>Math.max(1,T-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(MT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[Sn," / ",Wr]}),s.jsx(J,{variant:"ghost",size:"sm",disabled:Sn>=Wr||xn,onClick:()=>_n(T=>Math.min(Wr,T+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(wi,{className:"w-4 h-4"})})]})]})}),s.jsx($e,{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:"编辑"})]}),rc.map((T,F)=>{const S=(Sn-1)*Ga+F+1,D=T.isPinned??Me.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 ${D?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${S<=3?"text-amber-400":"text-gray-500"}`,children:S<=3?["🥇","🥈","🥉"][S-1]:`#${S}`}),s.jsx(J,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${D?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>Bi(T.id),disabled:tt,title:D?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:D?s.jsx(Hc,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(D1,{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(J,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>il({id:T.id,mid:T.mid,title:T.title,price:T.price,filePath:"",previewPercent:T.previewPercent}),title:"编辑文章",children:s.jsx(pn,{className:"w-3 h-3"})})})]},T.id)}),rc.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(Vt,{value:"link-person",className:"space-y-4",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — @列表(编辑器内输入 @ 可链接)"]}),s.jsxs("div",{className:"text-xs text-gray-500 mt-1 space-y-1",children:[s.jsxs("p",{children:["文章 @ 存 ",s.jsx("span",{className:"text-gray-400",children:"token"}),";小程序点 @ 用 token 换存客宝密钥后加好友/拉群。"]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-purple-300",children:"超级个体"}),":开通且昵称合法会自动进本列表可 @;共用「超级个体拉群」统一获客计划(话术由技术侧在系统里配置,本页不填 plan/apiKey,避免误操作)。"]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-[#38bdac]",children:"飞书群 Webhook"}),"(按人推线索到群):在下方表格「飞书群」列查看状态,操作栏点 Webhook 图标配置;与绑定会员用户维度一致。"]}),s.jsx("p",{children:"点「添加」新建的人物:每人单独一条存客宝计划(SOUL链接人与事-名称)。"})]})]}),s.jsxs($e,{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:"本页只管理可 @ 的人物列表"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>{xs()},title:"刷新",children:s.jsx(He,{className:"w-4 h-4"})}),s.jsxs(J,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{ur(null),Hr(!0)},children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),s.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:Ss.length>0?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-1.5 px-3 w-[280px] font-normal",children:"token"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-24 font-normal",children:"@的人"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[72px] font-normal text-xs",children:"来源"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[100px] font-normal text-xs",children:"会员"}),s.jsx("th",{className:"py-1.5 px-3 w-16 font-normal text-center",children:"获客数"}),s.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"获客计划"}),s.jsx("th",{className:"text-left py-1.5 px-2 w-[72px] font-normal text-xs",children:"飞书群"}),s.jsx("th",{className:"text-center py-1.5 px-2 w-14 font-normal text-xs",children:"置顶"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-16 font-normal",children:"状态"}),s.jsx("th",{className:"text-left py-1.5 px-2 w-24 font-normal",children:"操作"})]})}),s.jsx("tbody",{children:Ss.map(T=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono",title:"32位token",children:T.id}),s.jsx("td",{className:"py-2 px-3 truncate max-w-[96px]",children:s.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left",onClick:()=>{zs[T.id]&&Cr(T.id,T.name)},title:zs[T.id]?"点击查看获客详情":T.name,children:T.name})}),s.jsx("td",{className:"py-2 px-3",children:T.personSource==="vip_sync"?s.jsx("span",{className:"text-[10px] text-purple-300 bg-purple-500/15 px-1.5 py-0.5 rounded whitespace-nowrap",children:"超级个体"}):s.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 py-0.5 rounded whitespace-nowrap",children:"手工"})}),s.jsx("td",{className:"py-2 px-3 text-xs",children:T.userId?s.jsxs("div",{className:"flex flex-col gap-0.5 items-start max-w-[100px]",children:[T.personSource==="vip_sync"&&s.jsx("span",{className:"text-[10px] text-purple-300/90 leading-tight",children:"已绑定超级个体"}),s.jsx("button",{type:"button",className:"text-[#38bdac] hover:underline truncate max-w-[96px] block text-left",title:`用户ID: ${T.userId}`,onClick:()=>t(`/users?search=${encodeURIComponent(T.userId||"")}`),children:T.name})]}):s.jsx("span",{className:"text-gray-600",children:"—"})}),(()=>{const F=zs[T.id]||0;return s.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold cursor-pointer ${F>0?"text-green-400 hover:text-green-300 hover:underline":"text-gray-600"}`,title:F>0?"点击查看获客详情":"暂无获客",onClick:()=>{F>0&&Cr(T.id,T.name)},children:F})})(),s.jsx("td",{className:"py-2 px-3 text-white truncate max-w-[220px]",title:`planId: ${T.ckbPlanId??"-"}`,children:s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"truncate",children:T.ckbPlanId?T.personSource==="vip_sync"?"超级个体拉群(统一计划)":`SOUL链接人与事-${T.name}`:"—"})})}),s.jsx("td",{className:"py-2 px-2 text-xs",children:T.userId?Ha[(T.userId||"").trim()]?s.jsx("span",{className:"text-[#38bdac]",title:Ha[(T.userId||"").trim()],children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"}):s.jsx("span",{className:"text-gray-600",children:"—"})}),s.jsx("td",{className:"py-2 px-2 text-center",children:s.jsx(J,{type:"button",variant:"ghost",size:"sm",className:T.isPinned?"text-amber-400 hover:text-amber-300 h-7 px-2":"text-gray-500 hover:text-amber-400/90 h-7 px-2",title:T.isPinned?"取消小程序首页置顶":"设为小程序首页置顶(全局唯一)",onClick:()=>void Za(T,!T.isPinned),children:s.jsx(D1,{className:`w-3.5 h-3.5 ${T.isPinned?"fill-amber-400":""}`})})}),s.jsx("td",{className:"py-2 px-3 text-center",children:T.ckbPlanId?s.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 py-0.5 rounded",children:"启用"}):s.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 py-0.5 rounded",children:"未配置"})}),s.jsx("td",{className:"py-2 px-2",children:s.jsxs("div",{className:"flex items-center gap-0",children:[s.jsx(J,{variant:"ghost",size:"sm",className:`h-6 px-2 ${T.userId?"text-[#38bdac] hover:text-[#5fe0cd]":"text-gray-600 cursor-not-allowed opacity-50"}`,title:T.userId?"设置飞书群 Webhook(点击头像留资推送)":"未绑定会员,无法配置",disabled:!T.userId,onClick:()=>Kr(T),children:s.jsx($1,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const F=await vV(T.personId||"");if(F!=null&&F.success&&F.person){const S=F.person;ur({id:S.token??S.personId,personId:S.personId,name:S.name,personSource:S.personSource??"",userId:S.userId??"",label:S.label??"",ckbApiKey:S.ckbApiKey??"",remarkType:S.remarkType,remarkFormat:S.remarkFormat,addFriendInterval:S.addFriendInterval,startTime:S.startTime,endTime:S.endTime,deviceGroups:S.deviceGroups})}else ur(T),F!=null&&F.error&&G.error(F.error)}catch(F){console.error(F),ur(T),G.error(F instanceof Error?F.message:"加载人物详情失败")}Hr(!0)},children:s.jsx(Bg,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>Cr(T.id,T.name),children:s.jsx(Vn,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:T.personSource==="vip_sync"?"删除本地 @人物(不删统一获客计划)":"删除(同时删除存客宝对应获客计划)",onClick:()=>fa(T),children:s.jsx(Qn,{className:"w-3 h-3"})})]})})]},T.id))})]}):s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(NA,{className:"w-4 h-4 text-[#38bdac]"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs($e,{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(ne,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(le,{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(ne,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(le,{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.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Bh,{className:"w-4 h-4 text-blue-400"}),"获客 Webhook 通知"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置后新获客线索将自动推送到群聊(支持企业微信/飞书 Webhook)"})]}),s.jsxs($e,{className:"space-y-3",children:[s.jsxs("div",{className:"flex gap-3 items-end",children:[s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"Webhook URL"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",value:el,onChange:T=>tl(T.target.value)})]}),s.jsxs(J,{size:"sm",className:"bg-blue-500 hover:bg-blue-600 text-white h-8",onClick:async()=>{const T=el.trim();try{const F=await xt("/api/db/config",{key:"ckb_lead_webhook_url",value:T,description:"获客线索 Webhook 通知 URL(企微/飞书)"});F!=null&&F.success?G.success(T?"Webhook 已保存":"Webhook 已清除"):G.error((F==null?void 0:F.error)??"保存失败")}catch{G.error("保存失败")}},children:[s.jsx(kn,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"配置企业微信或飞书群机器人 Webhook URL,获客成功后自动推送通知"})]})]})]}),s.jsxs(Vt,{value:"link-tag",className:"space-y-4",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(L1,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转网页/本小程序页/其他小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可跳转外链、当前小程序指定页面、或进入流量池"})]}),s.jsxs($e,{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-end justify-between gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"搜索"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:At,onChange:T=>{Qt(T.target.value),_s(1)}})]}),s.jsx(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{hr(),ya()},title:"刷新",children:s.jsx(He,{className:"w-4 h-4"})})]}),s.jsxs(J,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{Br(null),$n({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),gn(""),Zs(!1),Zn(!0)},children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加标签"]})]}),s.jsxs("div",{className:"rounded-md border border-gray-700/50 overflow-hidden",children:[s.jsx("div",{className:"max-h-[420px] overflow-y-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-[#0a1628] border-b border-gray-700/50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-32",children:"标签"}),s.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-28",children:"别名"}),s.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-20",children:"类型"}),s.jsx("th",{className:"text-left px-3 py-2 text-gray-400",children:"目标 / AppID"}),s.jsx("th",{className:"text-right px-3 py-2 text-gray-400 w-28",children:"操作"})]})}),s.jsx("tbody",{children:wr?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"加载中..."})}):Ba.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):Ba.map(T=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-white/5",children:[s.jsx("td",{className:"px-3 py-2",children:s.jsxs("button",{type:"button",className:"text-amber-400 font-semibold hover:text-amber-300 hover:underline text-left",onClick:()=>{Br(T),$n({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",appSecret:"",pagePath:T.pagePath??""}),gn(T.appId??""),Zs(!1),Zn(!0)},title:"点击编辑标签",children:["#",T.label]})}),s.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs truncate max-w-[120px]",title:T.aliases||"",children:T.aliases||"—"}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Ve,{variant:"secondary",className:`text-[10px] ${T.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":T.type==="internal"?"bg-sky-500/20 text-sky-200 border-sky-500/30":T.type==="miniprogram"||T.type==="wxlink"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:T.type==="url"?"网页":T.type==="internal"?"本小程序":T.type==="ckb"?"存客宝":T.type==="wxlink"?"小程序链接":"小程序"})}),s.jsx("td",{className:"px-3 py-2 text-gray-300",children:T.type==="internal"?s.jsx("div",{className:"text-xs font-mono text-sky-300 truncate max-w-[420px]",title:T.pagePath||"",children:T.pagePath||"—"}):T.type==="miniprogram"?s.jsxs("div",{className:"space-y-0.5",children:[(()=>{const F=qr.find(S=>S.key===T.appId);return s.jsxs(s.Fragment,{children:[F&&s.jsx("div",{className:"text-xs text-white",children:F.name}),s.jsxs("div",{className:"text-xs font-mono text-[#38bdac]",children:["AppID: ",(F==null?void 0:F.appId)||T.appId||"—"]})]})})(),T.pagePath&&s.jsx("div",{className:"text-xs text-gray-500 font-mono",children:T.pagePath}),s.jsxs("div",{className:`text-xs ${T.hasAppSecret?"text-emerald-400/90":"text-amber-500/80"}`,children:["AppSecret:",T.hasAppSecret?"已保存(仅服务端)":"未配置"]})]}):T.type==="wxlink"?s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"text-xs text-[#38bdac] truncate max-w-[420px] font-mono",title:T.url,children:T.url||"—"}),s.jsx("div",{className:"text-[11px] text-gray-500",children:"小程序内点击 → web-view 打开 → 自动唤起目标小程序"})]}):T.url?s.jsxs("a",{href:T.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[T.url," ",s.jsx(Io,{className:"w-3 h-3 shrink-0"})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"—"})}),s.jsx("td",{className:"px-3 py-2",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{Br(T),$n({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",appSecret:"",pagePath:T.pagePath??""}),gn(T.appId??""),Zs(!1),Zn(!0)},title:"编辑",children:s.jsx(Bg,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${T.label}」吗?`))try{const F=await bi(`/api/db/link-tags?tagId=${encodeURIComponent(T.id)}`);F!=null&&F.success?(G.success("已删除"),hr(),ya()):G.error((F==null?void 0:F.error)??"删除失败")}catch(F){console.error(F),G.error("删除失败")}},title:"删除",children:s.jsx(Qn,{className:"w-3 h-3"})})]})})]},T.id))})]})}),s.jsx(us,{page:Fr,pageSize:qs,total:Gs,totalPages:de,onPageChange:T=>_s(T),onPageSizeChange:T=>{dr(T),_s(1)}})]})]})]}),s.jsx(Pt,{open:Zt,onOpenChange:Zn,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[s.jsxs(It,{className:"gap-1",children:[s.jsx(Rt,{className:"text-base",children:kr?"编辑链接标签":"添加链接标签"}),s.jsx(Oo,{className:"text-gray-400 text-xs",children:"配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转。「本小程序页面」仅跳转当前小程序内路径;API 跳转小程序类型需填 mpKey 或微信 AppID;AppSecret 仅存服务端(不下发小程序),供后续开放接口与台账使用。"})]}),s.jsxs("div",{className:"space-y-3 py-2",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"标签ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或自定义短 ID(如 kr),最长 50 字符",value:bt.tagId,disabled:!!kr,onChange:T=>$n(F=>({...F,tagId:T.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"显示文字"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:bt.label,onChange:T=>$n(F=>({...F,label:T.target.value}))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"别名(多个用逗号分隔,同指向一个目标)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 团队招募, 团队合伙人",value:bt.aliases,onChange:T=>$n(F=>({...F,aliases:T.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"类型"}),s.jsxs(yo,{value:bt.type,onValueChange:T=>$n(F=>({...F,type:T})),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:s.jsx(bo,{})}),s.jsxs(Ni,{className:"bg-[#0f2137] border-gray-700 text-white",children:[s.jsx(Gn,{value:"url",children:"网页链接"}),s.jsx(Gn,{value:"internal",children:"本小程序页面"}),s.jsx(Gn,{value:"miniprogram",children:"小程序(API跳转)"}),s.jsx(Gn,{value:"wxlink",children:"小程序链接(右上角复制)"}),s.jsx(Gn,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:bt.type==="url"?"URL地址":bt.type==="ckb"?"存客宝计划URL":bt.type==="wxlink"?"小程序链接":bt.type==="internal"?"页面路径":"小程序 mpKey / 微信 AppID"}),bt.type==="internal"?s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"/pages/index/index 或带参数 ?id=1",value:bt.pagePath,onChange:T=>$n(F=>({...F,pagePath:T.target.value}))}):bt.type==="wxlink"?s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"粘贴小程序右上角 ... → 复制链接 得到的 URL",value:bt.url,onChange:T=>$n(F=>({...F,url:T.target.value}))}):bt.type==="miniprogram"&&qr.length>0?s.jsxs("div",{ref:ba,className:"relative",children:[s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Er?Xs:bt.appId,onChange:T=>{const F=T.target.value;gn(F),Zs(!0),qr.some(S=>S.key===F)||$n(S=>({...S,appId:F}))},onFocus:()=>{gn(bt.appId),Zs(!0)},onBlur:()=>setTimeout(()=>Zs(!1),150)}),Er&&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:Fi.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Fi.map(T=>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:F=>{F.preventDefault(),$n(S=>({...S,appId:T.key,pagePath:T.path||""})),gn(""),Zs(!1)},children:[s.jsx("span",{children:T.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:T.key})]},T.key))})]}):s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:bt.type==="url"?"https://...":bt.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联配置的 key,或直接填 wx 开头的 AppID",value:bt.type==="url"||bt.type==="ckb"?bt.url:bt.appId,onChange:T=>{bt.type==="url"||bt.type==="ckb"?$n(F=>({...F,url:T.target.value})):$n(F=>({...F,appId:T.target.value}))}})]})]}),bt.type==="wxlink"&&s.jsx("p",{className:"text-[11px] text-amber-400/80 leading-snug px-0.5",children:"操作:打开目标小程序 → 右上角「...」→「复制链接」→ 粘贴到上面。小程序内点击此标签会在 web-view 中打开,微信自动唤起目标小程序,无需修改小程序版本。"}),bt.type==="miniprogram"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:bt.pagePath,onChange:T=>$n(F=>({...F,pagePath:T.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"AppSecret(微信公众平台 · 仅服务端存储)"}),s.jsx(le,{type:"password",autoComplete:"new-password",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:kr!=null&&kr.hasAppSecret?"已保存密钥,留空不改;填写则覆盖":"粘贴目标小程序 AppSecret",value:bt.appSecret,onChange:T=>$n(F=>({...F,appSecret:T.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-snug",children:"与 AppID 成对落库;接口响应与小程序配置中均不会返回此字段。"})]})]})]}),s.jsxs(Xt,{className:"gap-2 pt-1",children:[s.jsx(J,{variant:"outline",onClick:()=>Zn(!1),className:"border-gray-600",children:"取消"}),s.jsx(J,{onClick:async()=>{const T={tagId:bt.tagId.trim(),label:bt.label.trim(),aliases:bt.aliases.trim(),url:bt.url.trim(),type:bt.type,appId:bt.appId.trim(),appSecret:bt.appSecret.trim(),pagePath:bt.pagePath.trim()};if(T.tagId){const F=T.tagId;if([...F].length>50){G.error("标签ID 最长 50 个字符");return}if(/[#,\n\r\t]/.test(F)){G.error("标签ID 不能含 #、逗号或换行");return}}if(!T.label){G.error("显示文字必填");return}if(T.type==="miniprogram"&&(T.url=""),T.type==="internal"){T.url="",T.appId="",T.appSecret="";let F=T.pagePath.trim();if(!F){G.error("请填写本小程序页面路径");return}if(F.startsWith("/")||(F="/"+F.replace(/^\/+/,"")),!/^\/pages\//.test(F)){G.error("路径需以 /pages/ 开头");return}T.pagePath=F}T.type==="wxlink"&&(T.appId="",T.pagePath=""),ha(!0);try{const F=await xt("/api/db/link-tags",T);F!=null&&F.success?(G.success(kr?"已更新":"已添加"),Zn(!1),hr(),ya()):G.error((F==null?void 0:F.error)??"保存失败")}catch(F){console.error(F),G.error("保存失败")}finally{ha(!1)}},disabled:Vr,className:"bg-amber-500 hover:bg-amber-600 text-white",children:Vr?"保存中...":"保存"})]})]})})]})]}),s.jsx(CV,{open:cn,onOpenChange:Hr,editingPerson:Va,onSubmit:async T=>{var D;const F={personId:T.personId||T.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:T.name,userId:T.boundUserId,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:(D=T.deviceGroups)!=null&&D.trim()?T.deviceGroups.split(",").map(Z=>parseInt(Z.trim(),10)).filter(Z=>!Number.isNaN(Z)):void 0},S=await xt("/api/db/persons",F);if(S&&S.success===!1){const Z=S;Z.ckbResponse&&console.log("存客宝返回",Z.ckbResponse);const ye=Z.error||"操作失败";throw new Error(ye)}if(xs(),G.success(Va?"已保存":"已添加"),S!=null&&S.ckbCreateResult&&Object.keys(S.ckbCreateResult).length>0){const Z=S.ckbCreateResult;console.log("存客宝创建结果",Z);const ye=Z.planId??Z.id,Ce=ye!=null?[`planId: ${ye}`]:[];Z.apiKey!=null&&Ce.push("apiKey: ***"),G.info(Ce.length?`存客宝创建结果:${Ce.join(",")}`:"存客宝创建结果见控制台")}}}),s.jsx(Pt,{open:!!zn,onOpenChange:T=>{T||(pa(null),Ur(""))},children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx($1,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",zn==null?void 0:zn.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:es,onChange:T=>Ur(T.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交线索时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>{pa(null),Ur("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:()=>void ei(),disabled:Qo,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),Qo?"保存中...":"保存"]})]})]})}),s.jsx(Pt,{open:!!Cs,onOpenChange:T=>{T||fa(null)},children:s.jsxs(Mt,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(It,{className:"gap-1",children:[s.jsx(Rt,{className:"text-white text-base",children:"确认删除"}),s.jsx(Oo,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:Cs&&s.jsxs(s.Fragment,{children:[Cs.personSource==="vip_sync"?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["确定删除超级个体「",Cs.name,"」对应的 @人物?"]}),s.jsxs("p",{className:"mt-1.5 text-amber-200/90",children:["仅删除本系统的 Person 与独立 token,",s.jsx("strong",{children:"不会"}),"删除存客宝里的「超级个体统一获客计划」(其他超级个体仍在使用该计划)。"]})]}):s.jsx(s.Fragment,{children:s.jsxs("p",{children:["确定删除「SOUL链接人与事-",Cs.name,"」?将同时删除存客宝对应获客计划。"]})}),s.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",Cs.name," 将无法正常跳转。"]})]})})]}),s.jsxs(Xt,{className:"gap-2 sm:gap-2 pt-1",children:[s.jsx(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>fa(null),children:"取消"}),s.jsx(J,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{Cs&&(await bi(`/api/db/persons?personId=${Cs.personId}`),fa(null),xs(),G.success("已删除"))},children:"确定删除"})]})]})}),s.jsx(Pt,{open:ma,onOpenChange:xa,children:s.jsxs(Mt,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-green-400"}),Ua," — 获客详情(共 ",ga," 条)"]})}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:sc?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Di.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-[40px_1fr_90px_90px_70px_60px_110px] 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:"状态"}),s.jsx("span",{children:"时间"})]}),Di.map((T,F)=>s.jsxs("div",{className:"grid grid-cols-[40px_1fr_90px_90px_70px_60px_110px] gap-2 px-3 py-2 bg-[#0a1628] rounded text-sm",children:[s.jsx("span",{className:"text-gray-500 text-xs",children:(ft-1)*20+F+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-xs",children:T.source==="article_mention"?s.jsx("span",{className:"text-purple-400",children:"文章@"}):T.source==="index_lead"?s.jsx("span",{className:"text-blue-400",children:"首页"}):s.jsx("span",{className:"text-gray-500",children:T.source||"-"})}),s.jsx("span",{className:"text-[10px]",children:s.jsx("span",{className:"text-green-400 bg-green-400/10 px-1 py-0.5 rounded",children:"已添加"})}),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))]})}),ga>20&&s.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[s.jsx(J,{size:"sm",variant:"outline",disabled:ft<=1,onClick:()=>Cr(Yo,Ua,ft-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:[ft," / ",Math.ceil(ga/20)]}),s.jsx(J,{size:"sm",variant:"outline",disabled:ft>=Math.ceil(ga/20),onClick:()=>Cr(Yo,Ua,ft+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const gi={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 jj(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):gi.stats}function kj(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):gi.highlights}function MV(){const[t,e]=g.useState(gi),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useRef(null);g.useEffect(()=>{Re("/api/admin/author-settings").then(k=>{const M=k==null?void 0:k.data;M&&typeof M=="object"&&e({name:String(M.name??gi.name),avatar:String(M.avatar??gi.avatar),avatarImg:String(M.avatarImg??""),title:String(M.title??gi.title),bio:String(M.bio??gi.bio),stats:jj(M.stats).length?jj(M.stats):gi.stats,highlights:kj(M.highlights).length?kj(M.highlights):gi.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(L=>L.label||L.value),highlights:t.highlights.filter(Boolean)},M=await xt("/api/admin/author-settings",k);if(!M||M.success===!1){G.error("保存失败: "+(M&&typeof M=="object"&&"error"in M?M.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),G.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{i(!1)}},f=async k=>{var E;const M=(E=k.target.files)==null?void 0:E[0];if(M){c(!0);try{const L=new FormData;L.append("file",M),L.append("folder","avatars");const R=_u(),W={};R&&(W.Authorization=`Bearer ${R}`);const B=await(await fetch(zl("/api/upload"),{method:"POST",body:L,credentials:"include",headers:W})).json();B!=null&&B.success&&(B!=null&&B.url)?e(O=>({...O,avatarImg:B.url})):G.error("上传失败: "+((B==null?void 0:B.error)||"未知错误"))}catch(L){console.error(L),G.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),x=k=>e(M=>({...M,stats:M.stats.filter((E,L)=>L!==k)})),b=(k,M,E)=>e(L=>({...L,stats:L.stats.map((R,W)=>W===k?{...R,[M]:E}:R)})),N=()=>e(k=>({...k,highlights:[...k.highlights,""]})),w=k=>e(M=>({...M,highlights:M.highlights.filter((E,L)=>L!==k)})),v=(k,M)=>e(E=>({...E,highlights:E.highlights.map((L,R)=>R===k?M:L)}));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(yi,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(J,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[s.jsx(yi,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx(qt,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs($e,{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(ne,{className:"text-gray-300",children:"姓名"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(M=>({...M,name:k.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(M=>({...M,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(sk,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(M=>({...M,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(J,{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(Ef,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:aa(t.avatarImg.startsWith("http")?t.avatarImg:zl(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(ne,{className:"text-gray-300",children:"头衔"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(M=>({...M,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"个人简介"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(M=>({...M,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsx(ot,{className:"text-white",children:"统计数据"}),s.jsx(qt,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs($e,{className:"space-y-3",children:[t.stats.map((k,M)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:E=>b(M,"label",E.target.value),placeholder:"标签"}),s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:E=>b(M,"value",E.target.value),placeholder:"数值"}),s.jsx(J,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>x(M),children:s.jsx(Qn,{className:"w-4 h-4"})})]},M)),s.jsxs(J,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsx(ot,{className:"text-white",children:"亮点标签"}),s.jsx(qt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs($e,{className:"space-y-3",children:[t.highlights.map((k,M)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:E=>v(M,E.target.value),placeholder:"5年私域运营经验"}),s.jsx(J,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(M),children:s.jsx(Qn,{className:"w-4 h-4"})})]},M)),s.jsxs(J,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function AV(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function PV(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o]=g.useState(10),[c,u]=g.useState(0),[h,f]=g.useState(""),m=Ra(h,300),[x,b]=g.useState(!0),[N,w]=g.useState(null),[v,k]=g.useState(!1),[M,E]=g.useState(null),[L,R]=g.useState(""),[W,P]=g.useState(""),[B,O]=g.useState(""),[Y,ae]=g.useState("admin"),[_,se]=g.useState("active"),[ce,me]=g.useState(!1);async function I(){var K;b(!0),w(null);try{const fe=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&fe.set("search",m.trim());const he=await Re(`/api/admin/users?${fe}`);he!=null&&he.success?(e(he.records||[]),r(he.total??0),u(he.totalPages??0)):w(he.error||"加载失败")}catch(fe){const he=fe;w(he.status===403?"无权限访问":((K=he==null?void 0:he.data)==null?void 0:K.error)||"加载失败"),e([])}finally{b(!1)}}g.useEffect(()=>{I()},[a,o,m]);const X=()=>{E(null),R(""),P(""),O(""),ae("admin"),se("active"),k(!0)},V=K=>{E(K),R(K.username),P(""),O(K.name||""),ae(K.role==="super_admin"?"super_admin":"admin"),se(K.status==="disabled"?"disabled":"active"),k(!0)},xe=async()=>{var K;if(!L.trim()){w("用户名不能为空");return}if(!M&&!W){w("新建时密码必填,至少 6 位");return}if(W&&W.length<6){w("密码至少 6 位");return}w(null),me(!0);try{if(M){const fe=await Yt("/api/admin/users",{id:M.id,password:W||void 0,name:B.trim(),role:Y,status:_});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}else{const fe=await xt("/api/admin/users",{username:L.trim(),password:W,name:B.trim(),role:Y});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}}catch(fe){const he=fe;w(((K=he==null?void 0:he.data)==null?void 0:K.error)||"保存失败")}finally{me(!1)}},ee=async K=>{var fe;if(!AV("管理员")){w("已取消删除");return}try{const he=await bi(`/api/admin/users?id=${K}`);he!=null&&he.success?I():w((he==null?void 0:he.error)||"删除失败")}catch(he){const ue=he;w(((fe=ue==null?void 0:ue.data)==null?void 0:fe.error)||"删除失败")}},H=K=>{if(!K)return"-";try{const fe=new Date(K);return isNaN(fe.getTime())?K:fe.toLocaleString("zh-CN")}catch{return K}};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(Vc,{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(le,{placeholder:"搜索用户名/昵称",value:h,onChange:K=>f(K.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(J,{variant:"outline",size:"sm",onClick:I,disabled:x,className:"border-gray-600 text-gray-300",children:s.jsx(He,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsxs(J,{onClick:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),N&&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:N}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx($e,{className:"p-0",children:x?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户名"}),s.jsx(ke,{className:"text-gray-400",children:"昵称"}),s.jsx(ke,{className:"text-gray-400",children:"角色"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[t.map(K=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:K.id}),s.jsx(je,{className:"text-white font-medium",children:K.username}),s.jsx(je,{className:"text-gray-400",children:K.name||"-"}),s.jsx(je,{children:s.jsx(Ve,{variant:"outline",className:K.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:K.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(je,{children:s.jsx(Ve,{variant:"outline",className:K.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:K.status==="active"?"正常":"已禁用"})}),s.jsx(je,{className:"text-gray-500 text-sm",children:H(K.createdAt)}),s.jsxs(je,{className:"text-right",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>V(K),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>ee(K.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Jn,{className:"w-4 h-4"})})]})]},K.id)),t.length===0&&!x&&s.jsx(ht,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:N==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&s.jsx("div",{className:"p-4 border-t border-gray-700/50",children:s.jsx(us,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),s.jsx(Pt,{open:v,onOpenChange:k,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(It,{children:s.jsx(Rt,{className:"text-white",children:M?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"用户名"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:L,onChange:K=>R(K.target.value),disabled:!!M}),M&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:M?"新密码(留空不改)":"密码"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:M?"留空表示不修改":"至少 6 位",value:W,onChange:K=>P(K.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"昵称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:B,onChange:K=>O(K.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:Y,onChange:K=>ae(K.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:"超级管理员"})]})]}),M&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:_,onChange:K=>se(K.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(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:xe,disabled:ce,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ce?"保存中...":"保存"]})]})]})})]})}function Tn({method:t,url:e,desc:n,headers:r,bodyTitle:a,body:i,response:o}){const c=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 ${c}`,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(` -`)})]}),i&&s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:a??"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:i})]}),o&&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:o})]})]})}function q4(){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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),s.jsx($e,{className:"space-y-4",children:s.jsx(Tn,{method:"POST",url:"/api/admin",desc:"登录,返回 JWT token",headers:["Content-Type: application/json"],body:`{ +—— 以上为正文预览约 {percent}% ,搜「卡若创业派对」小程序阅读全文 ——`,timelineTitleSuffix:"(预览{percent}%)"},null,2);function Bc(t){if(t!=null){if(typeof t=="number"&&Number.isFinite(t))return Math.round(t);if(typeof t=="string"&&t.trim()!==""){const e=Number(t.trim().replace(/%/g,""));if(Number.isFinite(e))return Math.round(e)}}}function EV(t,e,n){const r=new Map;for(const o of t){const c=o.partId||"part-1",u=o.partTitle||"未分类",h=o.chapterId||"chapter-1",f=o.chapterTitle||"未分类";r.has(c)||r.set(c,{id:c,title:u,badgeText:n[c]||"",chapters:new Map});const m=r.get(c);m.chapters.has(h)||m.chapters.set(h,{id:h,title:f,sections:[]}),m.chapters.get(h).sections.push({id:o.id,mid:o.mid,title:o.title,price:o.price??1,filePath:o.filePath,isFree:o.isFree,isNew:o.isNew,clickCount:o.clickCount??0,payCount:o.payCount??0,hotScore:o.hotScore??0,hotRank:e.get(o.id)??0,previewPercent:Bc(o.previewPercent)})}const a=Array.from(r.values()).map(o=>({...o,chapters:Array.from(o.chapters.values())})),i=new Map;for(let o=0;o{const u=i.get(o.id),h=i.get(c.id);return u!==void 0&&h!==void 0&&u!==h?u-h:u!==void 0&&h===void 0?-1:u===void 0&&h!==void 0?1:o.id.localeCompare(c.id)})}function TV(){var dl,ul,hl;const t=_a(),[e,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState([]),[c,u]=g.useState(null),[h,f]=g.useState(!1),[m,x]=g.useState(!1),[b,N]=g.useState(!1),[w,v]=g.useState(""),[k,M]=g.useState([]),[E,L]=g.useState(!1),[R,W]=g.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[P,B]=g.useState(null),[O,X]=g.useState(!1),[ae,_]=g.useState(!1),[se,ce]=g.useState(null),[me,I]=g.useState(!1),[Z,V]=g.useState([]),[xe,ee]=g.useState(!1),[H,K]=g.useState(""),[fe,he]=g.useState(""),[ue,$]=g.useState(!1),[Q,z]=g.useState(""),[te,ie]=g.useState(!1),[we,Be]=g.useState(null),[Ue,bt]=g.useState(!1),[vn,dt]=g.useState(!1),[Tt,ln]=g.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[Dn,Zt]=g.useState(!1),[Dt,mn]=g.useState(!1),[Sn,_n]=g.useState(1),[Xn,Ot]=g.useState([]),[xn,Ne]=g.useState(!1),[Te,We]=g.useState([]),[tt,vt]=g.useState(!1),[ft,_e]=g.useState(20),[U,qe]=g.useState(!1),[yt,$t]=g.useState(!1),[mt,lt]=g.useState(Eg),[Mt,Wt]=g.useState(!1),[Nn,ks]=g.useState(!1),[Ss,Ri]=g.useState([]),[da,Fa]=g.useState([]),[Ba,Nr]=g.useState([]),[wr,jr]=g.useState(!1),[Fr,_s]=g.useState(1),[qs,dr]=g.useState(20),[Gs,ua]=g.useState(0),[de,ve]=g.useState(1),[Pt,Qt]=g.useState(""),[en,Zn]=g.useState(!1),[kr,Br]=g.useState(null),[Nt,$n]=g.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),[Vr,ha]=g.useState(!1),[cn,Hr]=g.useState(!1),[Va,ur]=g.useState(null),[Cs,fa]=g.useState(null),[Ha,$s]=g.useState({}),[zn,pa]=g.useState(null),[es,Ur]=g.useState(""),[Qo,ts]=g.useState(!1),[zs,Js]=g.useState({}),[ma,xa]=g.useState(!1),[Yo,nc]=g.useState(""),[Ua,Li]=g.useState(""),[Oi,Wa]=g.useState([]),[ga,Xo]=g.useState(0),[pt,Zo]=g.useState(1),[sc,Di]=g.useState(!1),[el,tl]=g.useState(""),nl=g.useRef(null),Sr=g.useCallback(async(T,F)=>{var ge;const S=new FormData;S.append("file",T),S.append("folder",F);const Y=await(await fetch(zl("/api/upload"),{method:"POST",body:S,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((ge=Y==null?void 0:Y.data)==null?void 0:ge.url)||(Y==null?void 0:Y.url)||""},[]),Ka=g.useCallback(T=>Sr(T,"book-images"),[Sr]),Qs=g.useCallback(T=>{const F=T.type.startsWith("video/")?"book-videos":"book-attachments";return Sr(T,F)},[Sr]),[Fs,Es]=g.useState({}),ps=T=>String(T||"").trim().slice(0,8),qa=g.useMemo(()=>{const T=new Map;return Xn.forEach((F,S)=>{T.set(F.id,S+1)}),T},[Xn]),dn=EV(e,qa,Fs),sl=e.length,Ga=10,Wr=Math.max(1,Math.ceil(Xn.length/Ga)),rc=Xn.slice((Sn-1)*Ga,Sn*Ga),ns=async()=>{a(!0);try{const T=await Re("/api/db/book?action=list",{cache:"no-store"});n(Array.isArray(T==null?void 0:T.sections)?T.sections:[])}catch(T){console.error(T),n([])}finally{a(!1)}},Ja=async()=>{try{const T=await Re("/api/db/config?key=book_part_badges",{cache:"no-store"});let F={};if(T&&Array.isArray(T.data)){const D=T.data.find(Y=>Y&&Y.configKey==="book_part_badges");D&&D.configValue&&typeof D.configValue=="object"&&!Array.isArray(D.configValue)&&(F=D.configValue)}else T&&T.data&&typeof T.data=="object"&&!Array.isArray(T.data)&&(F=T.data);const S={};Object.keys(F).forEach(D=>{const Y=ps(F[D]);Y&&(S[D]=Y)}),Es(S)}catch(T){console.error(T),Es({})}},Bs=async()=>{Ne(!0);try{const T=await Re("/api/db/book?action=ranking",{cache:"no-store"}),F=Array.isArray(T==null?void 0:T.sections)?T.sections:[];Ot(F);const S=F.filter(D=>D.isPinned).map(D=>D.id);We(S)}catch(T){console.error(T),Ot([])}finally{Ne(!1)}};g.useEffect(()=>{ns(),Bs(),Ja()},[]);const xd=T=>{o(F=>F.includes(T)?F.filter(S=>S!==T):[...F,T])},Qa=g.useCallback(T=>{const F=e,S=T.flatMap(D=>{const Y=F.find(ge=>ge.id===D.id);return Y?[{...Y,partId:D.partId,partTitle:D.partTitle,chapterId:D.chapterId,chapterTitle:D.chapterTitle}]:[]});return n(S),Yt("/api/db/book",{action:"reorder",items:T}).then(D=>{D&&D.success===!1&&(n(F),G.error("排序失败: "+(D&&typeof D=="object"&&"error"in D?D.error:"未知错误")))}).catch(D=>{n(F),console.error("排序失败:",D),G.error("排序失败: "+(D instanceof Error?D.message:"网络或服务异常"))}),Promise.resolve()},[e]),Ya=async T=>{if(confirm(`确定要删除章节「${T.title}」吗?此操作不可恢复。`))try{const F=await bi(`/api/db/book?id=${encodeURIComponent(T.id)}`);F&&F.success!==!1?(G.success("已删除"),ns(),Bs()):G.error("删除失败: "+(F&&typeof F=="object"&&"error"in F?F.error:"未知错误"))}catch(F){console.error(F),G.error("删除失败")}},ms=g.useCallback(async()=>{Zt(!0);try{const T=await Re("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),F=T&&T.data;F&&typeof F.readWeight=="number"&&typeof F.recencyWeight=="number"&&typeof F.payWeight=="number"&&ln({readWeight:Math.max(0,Math.min(1,F.readWeight)),recencyWeight:Math.max(0,Math.min(1,F.recencyWeight)),payWeight:Math.max(0,Math.min(1,F.payWeight))})}catch{}finally{Zt(!1)}},[]);g.useEffect(()=>{vn&&ms()},[vn,ms]);const _i=async()=>{const{readWeight:T,recencyWeight:F,payWeight:S}=Tt,D=T+F+S;if(Math.abs(D-1)>.001){G.error("三个权重之和必须等于 1");return}mn(!0);try{const Y=await gt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:T,recencyWeight:F,payWeight:S},description:"文章排名算法权重"});Y&&Y.success!==!1?(G.success("排名权重已保存"),dt(!1),ns(),Bs()):G.error("保存失败: "+(Y&&typeof Y=="object"&&"error"in Y?Y.error:""))}catch(Y){console.error(Y),G.error("保存失败")}finally{mn(!1)}},Xa=g.useCallback(async()=>{vt(!0);try{const T=await Re("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),F=T&&T.data;Array.isArray(F)&&We(F)}catch{}finally{vt(!1)}},[]),xs=g.useCallback(async()=>{try{const[T,F,S]=await Promise.all([Re("/api/db/persons"),Re("/api/db/vip-members?limit=500").catch(()=>null),Re("/api/db/config/full?key=super_individual_webhook_map",{cache:"no-store"}).catch(()=>null)]),D={};if(S!=null&&S.success&&S.data&&typeof S.data=="object"&&!Array.isArray(S.data))for(const[Y,ge]of Object.entries(S.data)){const Se=String(Y||"").trim(),Oe=ge!=null?String(ge).trim():"";Se&&Oe&&(D[Se]=Oe)}else if(F!=null&&F.success&&Array.isArray(F.data))for(const Y of F.data){const ge=(Y.id||"").trim();if(!ge)continue;const Se=Y.webhookUrl!=null?String(Y.webhookUrl).trim():"";Se&&(D[ge]=Se)}$s(D),T!=null&&T.success&&T.persons&&Ri(T.persons.map(Y=>{const ge=Y.deviceGroups,Se=Array.isArray(ge)?ge.join(","):ge??"";return{id:Y.token??Y.personId??"",personId:Y.personId,name:Y.name,personSource:Y.personSource??"",userId:Y.userId,aliases:Y.aliases??"",label:Y.label??"",ckbApiKey:Y.ckbApiKey??"",ckbPlanId:Y.ckbPlanId,remarkType:Y.remarkType,remarkFormat:Y.remarkFormat,addFriendInterval:Y.addFriendInterval,startTime:Y.startTime,endTime:Y.endTime,deviceGroups:Se,isPinned:!!Y.isPinned}}))}catch{}},[]),Za=g.useCallback(async(T,F)=>{const S=(T.personId||T.id||"").trim();if(!S){G.error("缺少 personId");return}F&&!(T.userId||"").trim()&&G.info("未绑定会员时,小程序仍显示 @ 名称,头像可能为默认图");try{const D=await Yt("/api/db/persons/pin",{personId:S,isPinned:F});if(!(D!=null&&D.success)){G.error((D==null?void 0:D.error)||"置顶失败");return}G.success(F?"已设为小程序首页置顶(全局仅一条)":"已取消置顶"),await xs()}catch(D){G.error(D instanceof Error?D.message:"操作失败")}},[xs]),Kr=g.useCallback(T=>{const F=(T.userId||"").trim();if(!F){G.info("未绑定会员的人物无法配置:飞书群 Webhook 按「超级个体用户」维度保存,请先为该人物绑定会员用户。");return}pa({userId:F,name:T.name}),Ur((Ha[F]||"").trim())},[Ha]),ei=g.useCallback(async()=>{if(!zn)return;const T=zn.userId,F=es.trim();if(F&&!/^https?:\/\//i.test(F)){G.error("Webhook 地址需以 http/https 开头");return}ts(!0);try{const S=await Yt("/api/db/vip-members/webhook",{userId:T,webhookUrl:F});if(!(S!=null&&S.success)){G.error((S==null?void 0:S.error)||"保存飞书群 Webhook 失败");return}G.success(F?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),pa(null),Ur(""),$s(D=>{const Y={...D};return F?Y[T]=F:delete Y[T],Y})}catch{G.error("保存飞书群 Webhook 失败")}finally{ts(!1)}},[zn,es]),hr=g.useCallback(async()=>{try{const T=await Re("/api/db/link-tags");T!=null&&T.success&&T.linkTags&&Fa(T.linkTags.map(F=>({id:F.tagId,label:F.label,url:F.url,type:F.type||"url",appId:F.appId||"",pagePath:F.pagePath||"",hasAppSecret:!!F.hasAppSecret})))}catch{}},[]),Ys=g.useCallback(async()=>{try{const T=await Re("/api/db/config/full?key=ckb_lead_webhook_url",{cache:"no-store"});T!=null&&T.success&&typeof T.data=="string"&&tl(T.data)}catch{}},[]),$i=g.useCallback(async()=>{try{const T=await Re("/api/db/ckb-person-leads");if(T!=null&&T.success&&T.byPerson){const F={};for(const S of T.byPerson)F[S.token]=S.total;Js(F)}}catch{}},[]),Cr=g.useCallback(async(T,F,S=1)=>{nc(T),Li(F),xa(!0),Zo(S),Di(!0);try{const D=await Re(`/api/db/ckb-person-leads?token=${encodeURIComponent(T)}&page=${S}&pageSize=20`);D!=null&&D.success?(Wa(D.records||[]),Xo(D.total||0)):G.error((D==null?void 0:D.error)||"加载获客详情失败")}catch(D){G.error(D instanceof Error?D.message:"加载获客详情失败")}finally{Di(!1)}},[]),ya=g.useCallback(async()=>{jr(!0);try{const T=new URLSearchParams({page:String(Fr),pageSize:String(qs)}),F=Pt.trim();F&&T.set("search",F);const S=await Re(`/api/db/link-tags?${T.toString()}`);if(S!=null&&S.success){const D=Array.isArray(S.linkTags)?S.linkTags:[];Nr(D.map(Y=>({id:Y.tagId,label:Y.label,aliases:Y.aliases||"",url:Y.url,type:Y.type||"url",appId:Y.appId||"",pagePath:Y.pagePath||"",hasAppSecret:!!Y.hasAppSecret}))),ua(typeof S.total=="number"?S.total:0),ve(typeof S.totalPages=="number"&&S.totalPages>0?S.totalPages:1)}}catch(T){console.error(T),G.error("加载链接标签失败")}finally{jr(!1)}},[Fr,qs,Pt]),[qr,Gr]=g.useState([]),[Xs,gn]=g.useState(""),[Er,Zs]=g.useState(!1),ba=g.useRef(null),rl=g.useCallback(async()=>{try{const T=await Re("/api/admin/linked-miniprograms");T!=null&&T.success&&Array.isArray(T.data)&&Gr(T.data.map(F=>({...F,key:F.key})))}catch{}},[]),zi=qr.filter(T=>!Xs.trim()||T.name.toLowerCase().includes(Xs.toLowerCase())||T.key&&T.key.toLowerCase().includes(Xs.toLowerCase())||T.appId.toLowerCase().includes(Xs.toLowerCase())),Fi=async T=>{const F=Te.includes(T)?Te.filter(S=>S!==T):[...Te,T];We(F);try{await gt("/api/db/config",{key:"pinned_section_ids",value:F,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),Bs()}catch{We(Te)}},va=g.useCallback(async()=>{qe(!0);try{const T=await Re("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),F=T&&T.data;typeof F=="number"&&F>0&&F<=100&&_e(F)}catch{}finally{qe(!1)}},[]),Bi=async()=>{if(ft<1||ft>100){G.error("预览比例需在 1~100 之间");return}$t(!0);try{const T=await gt("/api/db/config",{key:"unpaid_preview_percent",value:ft,description:"小程序未付费内容默认预览比例(%)"});T&&T.success!==!1?G.success("预览比例已保存"):G.error("保存失败: "+(T.error||""))}catch{G.error("保存失败")}finally{$t(!1)}},Vi=g.useCallback(async()=>{Wt(!0);try{const T=await Re("/api/db/config/full?key=read_preview_ui",{cache:"no-store"}),F=T&&T.data;F!=null&&typeof F=="object"&&!Array.isArray(F)&&Object.keys(F).length>0?lt(JSON.stringify(F,null,2)):lt(Eg)}catch{lt(Eg)}finally{Wt(!1)}},[]),gd=async()=>{let T;try{T=JSON.parse(mt)}catch{G.error("JSON 格式错误,请检查括号与引号");return}ks(!0);try{const F=await gt("/api/db/config",{key:"read_preview_ui",value:T,description:"阅读页/朋友圈付费墙与分享文案(占位符 {percent} {price})"});F&&F.success!==!1?G.success("阅读页文案已保存"):G.error("保存失败: "+(F.error||""))}catch{G.error("保存失败")}finally{ks(!1)}};g.useEffect(()=>{Xa(),va(),Vi(),xs(),hr(),$i(),rl(),Ys()},[Xa,va,Vi,xs,hr,$i,rl,Ys]),g.useEffect(()=>{ya()},[ya]);const al=async T=>{Be({section:T,orders:[]}),bt(!0);try{const F=await Re(`/api/db/book?action=section-orders&id=${encodeURIComponent(T.id)}`),S=F!=null&&F.success&&Array.isArray(F.orders)?F.orders:[];Be(D=>D?{...D,orders:S}:null)}catch(F){console.error(F),Be(S=>S?{...S,orders:[]}:null)}finally{bt(!1)}},il=async T=>{x(!0);try{const F=T.mid!=null&&T.mid>0?`/api/db/book?action=read&mid=${T.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(T.id)}`,S=await Re(F);if(S!=null&&S.success&&S.section){const D=S.section,Y=D.editionPremium===!0,ge=Bc(D.previewPercent)??Bc(D.preview_percent),Se=Bc(T.previewPercent);u({id:T.id,originalId:T.id,title:S.section.title??T.title,price:S.section.price??T.price,content:S.section.content??"",filePath:T.filePath,isFree:T.isFree||T.price===0,isNew:D.isNew??T.isNew,isPinned:Te.includes(T.id),hotScore:T.hotScore??0,previewPercent:ge??Se??void 0,editionStandard:Y?!1:D.editionStandard??!0,editionPremium:Y})}else u({id:T.id,originalId:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree,isNew:T.isNew,isPinned:Te.includes(T.id),hotScore:T.hotScore??0,previewPercent:Bc(T.previewPercent),editionStandard:!0,editionPremium:!1}),S&&!S.success&&G.error("无法读取文件内容: "+(S.error||"未知错误"))}catch(F){console.error(F),u({id:T.id,title:T.title,price:T.price,content:"",filePath:T.filePath,isFree:T.isFree,previewPercent:Bc(T.previewPercent)})}finally{x(!1)}},ol=async()=>{var T;if(c){N(!0);try{let F=c.content||"";const S=[new RegExp(`^#+\\s*${c.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${c.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(T=c.title)==null?void 0:T.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const xt of S)F=F.replace(xt,"");F=F.replace(/^\s*\n+/,"").trim();const D=c.originalId||c.id,Y=c.id!==D,ge={id:D,...Y?{newId:c.id}:{},title:c.title,price:c.isFree?0:c.price,content:F,isFree:c.isFree||c.price===0,isNew:c.isNew,hotScore:c.hotScore,editionStandard:c.editionPremium?!1:c.editionStandard??!0,editionPremium:c.editionPremium??!1,saveToFile:!0};c.previewPercent===null?ge.previewPercent=null:typeof c.previewPercent=="number"&&Number.isFinite(c.previewPercent)&&(ge.previewPercent=c.previewPercent);const Se=await Yt("/api/db/book",ge,{timeout:z1}),Oe=Y?c.id:D;c.isPinned!==Te.includes(Oe)&&await Fi(Oe),Se&&Se.success!==!1?(G.success(`已保存:${c.title}`),u(null),ns(),xs(),hr()):G.error("保存失败: "+(Se&&typeof Se=="object"&&"error"in Se?Se.error:"未知错误"))}catch(F){console.error(F);const S=F instanceof Error&&F.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";G.error(S)}finally{N(!1)}}},ac=async()=>{if(!R.id||!R.title){G.error("请填写章节ID和标题");return}N(!0);try{const T=dn.find(D=>D.id===R.partId),F=T==null?void 0:T.chapters.find(D=>D.id===R.chapterId),S=await Yt("/api/db/book",{id:R.id,title:R.title,price:R.isFree?0:R.price,content:R.content||"",partId:R.partId,partTitle:(T==null?void 0:T.title)??"",chapterId:R.chapterId,chapterTitle:(F==null?void 0:F.title)??"",isFree:R.isFree,isNew:R.isNew,editionStandard:R.editionPremium?!1:R.editionStandard??!0,editionPremium:R.editionPremium??!1,hotScore:R.hotScore??0,saveToFile:!1},{timeout:z1});if(S&&S.success!==!1){if(R.isPinned){const D=[...Te,R.id];We(D);try{await gt("/api/db/config",{key:"pinned_section_ids",value:D,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}G.success(`章节创建成功:${R.title}`),f(!1),W({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),ns(),xs(),hr()}else G.error("创建失败: "+(S&&typeof S=="object"&&"error"in S?S.error:"未知错误"))}catch(T){console.error(T),G.error("创建失败")}finally{N(!1)}},ic=T=>{W(F=>{var S;return{...F,partId:T.id,chapterId:((S=T.chapters[0])==null?void 0:S.id)??"chapter-1"}}),f(!0)},yd=T=>{B({id:T.id,title:T.title,badgeText:ps(T.badgeText)})},bd=async()=>{var T;if((T=P==null?void 0:P.title)!=null&&T.trim()){X(!0);try{const F=e.map(D=>({id:D.id,partId:D.partId||"part-1",partTitle:D.partId===P.id?P.title.trim():D.partTitle||"",chapterId:D.chapterId||"chapter-1",chapterTitle:D.chapterTitle||""})),S=await Yt("/api/db/book",{action:"reorder",items:F});if(S&&S.success!==!1){const D=P.title.trim(),Y={...Fs},ge=ps(P.badgeText);ge?Y[P.id]=ge:delete Y[P.id];const Se=await gt("/api/db/config",{key:"book_part_badges",value:Y,description:"目录篇名角标(key=part_id, value=角标文案)"});if(Se&&Se.success===!1){G.error("更新篇名角标失败: "+(Se.error||"未知错误"));return}Es(Y),n(Oe=>Oe.map(xt=>xt.partId===P.id?{...xt,partTitle:D}:xt)),B(null),ns()}else G.error("更新篇名失败: "+(S&&typeof S=="object"&&"error"in S?S.error:"未知错误"))}catch(F){console.error(F),G.error("更新篇名失败")}finally{X(!1)}}},gs=T=>{const F=T.chapters.length+1,S=`chapter-${T.id}-${F}-${Date.now()}`;W({id:`${F}.1`,title:"新章节",price:1,partId:T.id,chapterId:S,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),f(!0)},oc=(T,F)=>{const S=F.sections;let D=1,Y=!1,ge=!1;if(S.length>0){const Se=typeof S[0].price=="number"?S[0].price:Number(S[0].price)||1,Oe=!!(S[0].isFree||Se===0);ge=S.some(xt=>{const Le=typeof xt.price=="number"?xt.price:Number(xt.price)||1,wt=!!(xt.isFree||Le===0);return Le!==Se||wt!==Oe}),D=Oe?0:Se,Y=Oe}ce({part:T,chapter:F,title:F.title,price:D,isFree:Y,priceMixed:ge,initialTitle:F.title,initialPrice:D,initialIsFree:Y})},lc=async()=>{var Y;if(!((Y=se==null?void 0:se.title)!=null&&Y.trim()))return;const T=se,F=T.title.trim(),S=F!==T.initialTitle,D=T.isFree!==T.initialIsFree||!T.isFree&&Number(T.price)!==Number(T.initialPrice);if(!S&&!D){G.info("未修改任何内容"),ce(null);return}if(T.priceMixed&&D){const ge=T.chapter.sections.length,Se=T.isFree?"全部设为免费":`全部设为 ¥${T.price}`;if(!confirm(`本章 ${ge} 节当前定价不一致,保存后将${Se},确定?`))return}I(!0);try{if(S){const ge=e.map(Le=>({id:Le.id,partId:Le.partId||T.part.id,partTitle:Le.partId===T.part.id?T.part.title:Le.partTitle||"",chapterId:Le.chapterId||T.chapter.id,chapterTitle:Le.partId===T.part.id&&Le.chapterId===T.chapter.id?F:Le.chapterTitle||""})),Se=await Yt("/api/db/book",{action:"reorder",items:ge});if(Se&&Se.success===!1){G.error("保存章节名失败: "+(Se&&typeof Se=="object"&&"error"in Se?Se.error:"未知错误"));return}const Oe=T.part.id,xt=T.chapter.id;n(Le=>Le.map(wt=>wt.partId===Oe&&wt.chapterId===xt?{...wt,chapterTitle:F}:wt))}if(D){const ge=await Yt("/api/db/book",{action:"update-chapter-pricing",partId:T.part.id,chapterId:T.chapter.id,price:T.isFree?0:Number(T.price)||0,isFree:T.isFree});if(ge&&ge.success===!1){G.error("保存定价失败: "+(ge&&typeof ge=="object"&&"error"in ge?ge.error:"未知错误")),S&&ns();return}}ce(null),ns(),G.success("已保存")}catch(ge){console.error(ge),G.error("保存失败")}finally{I(!1)}},vd=async(T,F)=>{const S=F.sections.map(D=>D.id);if(S.length===0){G.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${T.chapters.indexOf(F)+1}章 | ${F.title}」吗?将删除共 ${S.length} 节,此操作不可恢复。`))try{for(const D of S)await bi(`/api/db/book?id=${encodeURIComponent(D)}`);ns()}catch(D){console.error(D),G.error("删除失败")}},Nd=async()=>{if(!Q.trim()){G.error("请输入篇名");return}ie(!0);try{const T=`part-new-${Date.now()}`,F="chapter-1",S=`part-placeholder-${Date.now()}`,D=await Yt("/api/db/book",{id:S,title:"占位节(可编辑)",price:0,content:"",partId:T,partTitle:Q.trim(),chapterId:F,chapterTitle:"第1章 | 待编辑",saveToFile:!1});D&&D.success!==!1?(G.success(`篇「${Q}」创建成功`),_(!1),z(""),ns()):G.error("创建失败: "+(D&&typeof D=="object"&&"error"in D?D.error:"未知错误"))}catch(T){console.error(T),G.error("创建失败")}finally{ie(!1)}},wd=async()=>{if(Z.length===0){G.error("请先勾选要移动的章节");return}const T=dn.find(S=>S.id===H),F=T==null?void 0:T.chapters.find(S=>S.id===fe);if(!T||!F||!H||!fe){G.error("请选择目标篇和章");return}$(!0);try{const S=()=>{const Se=new Set(Z),Oe=e.map(Ht=>({id:Ht.id,partId:Ht.partId||"",partTitle:Ht.partTitle||"",chapterId:Ht.chapterId||"",chapterTitle:Ht.chapterTitle||""})),xt=Oe.filter(Ht=>Se.has(Ht.id)).map(Ht=>({...Ht,partId:H,partTitle:T.title||H,chapterId:fe,chapterTitle:F.title||fe})),Le=Oe.filter(Ht=>!Se.has(Ht.id));let wt=Le.length;for(let Ht=Le.length-1;Ht>=0;Ht-=1){const Fn=Le[Ht];if(Fn.partId===H&&Fn.chapterId===fe){wt=Ht+1;break}}return[...Le.slice(0,wt),...xt,...Le.slice(wt)]},D=async()=>{const Se=S(),Oe=await Yt("/api/db/book",{action:"reorder",items:Se});return Oe&&Oe.success!==!1?(G.success(`已移动 ${Z.length} 节到「${T.title}」-「${F.title}」`),ee(!1),V([]),await ns(),!0):!1},Y={action:"move-sections",sectionIds:Z,targetPartId:H,targetChapterId:fe,targetPartTitle:T.title||H,targetChapterTitle:F.title||fe},ge=await Yt("/api/db/book",Y);if(ge&&ge.success!==!1)G.success(`已移动 ${ge.count??Z.length} 节到「${T.title}」-「${F.title}」`),ee(!1),V([]),await ns();else{const Se=ge&&typeof ge=="object"&&"error"in ge?ge.error||"":"未知错误";if((Se.includes("缺少 id")||Se.includes("无效的 action"))&&await D())return;G.error("移动失败: "+Se)}}catch(S){console.error(S),G.error("移动失败: "+(S instanceof Error?S.message:"网络或服务异常"))}finally{$(!1)}},ll=T=>{V(F=>F.includes(T)?F.filter(S=>S!==T):[...F,T])},cl=async T=>{const F=e.filter(S=>S.partId===T.id).map(S=>S.id);if(F.length===0){G.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${T.title}」整篇吗?将删除共 ${F.length} 节内容,此操作不可恢复。`))try{for(const S of F)await bi(`/api/db/book?id=${encodeURIComponent(S)}`);ns()}catch(S){console.error(S),G.error("删除失败")}},cc=async()=>{var T;if(w.trim()){L(!0);try{const F=await Re(`/api/search?q=${encodeURIComponent(w)}`);F!=null&&F.success&&((T=F.data)!=null&&T.results)?M(F.data.results):(M([]),F&&!F.success&&G.error("搜索失败: "+F.error))}catch(F){console.error(F),M([]),G.error("搜索失败")}finally{L(!1)}}},Hi=dn.find(T=>T.id===R.partId),Ui=(Hi==null?void 0:Hi.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:["共 ",dn.length," 篇 · ",sl," 节内容"]})]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(J,{onClick:()=>dt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Bh,{className:"w-4 h-4 mr-2"}),"排名算法"]})})]}),s.jsx(It,{open:h,onOpenChange:f,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(Rt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"章节ID *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:R.id,onChange:T=>W({...R,id:T.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:R.isFree?0:R.price,onChange:T=>W({...R,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:R.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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:R.isFree,onChange:T=>W({...R,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(ne,{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:R.isNew,onChange:T=>W({...R,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(ne,{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:R.isPinned,onChange:T=>W({...R,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(ne,{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:R.editionPremium!==!0,onChange:()=>W({...R,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:R.editionPremium===!0,onChange:()=>W({...R,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(ne,{className:"text-gray-300",children:"热度分"}),s.jsx(le,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:R.hotScore??0,onChange:T=>W({...R,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:R.title,onChange:T=>W({...R,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(ne,{className:"text-gray-300",children:"所属篇"}),s.jsxs(go,{value:R.partId,onValueChange:T=>{var S;const F=dn.find(D=>D.id===T);W({...R,partId:T,chapterId:((S=F==null?void 0:F.chapters[0])==null?void 0:S.id)??"chapter-1"})},children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(yo,{})}),s.jsxs(Ni,{className:"bg-[#0f2137] border-gray-700",children:[dn.map(T=>s.jsx(Gn,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),dn.length===0&&s.jsx(Gn,{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(ne,{className:"text-gray-300",children:"所属章"}),s.jsxs(go,{value:R.chapterId,onValueChange:T=>W({...R,chapterId:T}),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(yo,{})}),s.jsxs(Ni,{className:"bg-[#0f2137] border-gray-700",children:[Ui.map(T=>s.jsx(Gn,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id)),Ui.length===0&&s.jsx(Gn,{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(ne,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(R0,{content:R.content||"",onChange:T=>W({...R,content:T}),onImageUpload:Ka,onMediaUpload:Qs,persons:Ss,linkTags:da,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(Xt,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(J,{variant:"outline",onClick:()=>f(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:ac,disabled:b||!R.id||!R.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(He,{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(It,{open:!!P,onOpenChange:T=>!T&&B(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),P&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"篇名"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.title,onChange:T=>B({...P,title:T.target.value}),placeholder:"输入篇名"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"左侧图标文字(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.badgeText||"",onChange:T=>B({...P,badgeText:ps(T.target.value)}),placeholder:"例如:派 / 新 / 热",maxLength:8}),s.jsx("p",{className:"text-xs text-gray-500",children:"保存后会同步到目录左侧图标文字(小程序与管理端目录树)。"})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>B(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:bd,disabled:O||!((dl=P==null?void 0:P.title)!=null&&dl.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:O?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(It,{open:!!se,onOpenChange:T=>!T&&ce(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsxs(Rt,{children:[s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),s.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),se&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:se.title,onChange:T=>ce({...se,title:T.target.value}),placeholder:"输入章节名称"})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[s.jsxs(ne,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",se.chapter.sections.length," 节)"]}),se.priceMixed&&s.jsx("p",{className:"text-amber-400/90 text-xs",children:"当前各节定价不一致,保存后将按下方设置全部统一。"}),s.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[s.jsxs("div",{className:"space-y-1 flex-1 min-w-[120px]",children:[s.jsx("span",{className:"text-gray-500 text-xs",children:"价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:se.isFree?0:se.price,onChange:T=>ce({...se,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:se.isFree,min:0,step:.01})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pb-2",children:[s.jsx("input",{type:"checkbox",checked:se.isFree||se.price===0,onChange:T=>ce({...se,isFree:T.target.checked,price:T.target.checked?0:se.initialPrice>0?se.initialPrice:1}),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac]"}),s.jsx("span",{className:"text-gray-400 text-sm",children:"本章全部免费"})]})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>ce(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:lc,disabled:me||!((ul=se==null?void 0:se.title)!=null&&ul.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(It,{open:xe,onOpenChange:T=>{var F;if(ee(T),T&&dn.length>0){const S=dn[0];K(S.id),he(((F=S.chapters[0])==null?void 0:F.id)??"")}},children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsx(Lt,{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:Z.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"目标篇"}),s.jsxs(go,{value:H,onValueChange:T=>{var S;K(T);const F=dn.find(D=>D.id===T);he(((S=F==null?void 0:F.chapters[0])==null?void 0:S.id)??"")},children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(yo,{placeholder:"选择篇"})}),s.jsx(Ni,{className:"bg-[#0f2137] border-gray-700",children:dn.map(T=>s.jsx(Gn,{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(ne,{className:"text-gray-300",children:"目标章"}),s.jsxs(go,{value:fe,onValueChange:he,children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(yo,{placeholder:"选择章"})}),s.jsx(Ni,{className:"bg-[#0f2137] border-gray-700",children:(((hl=dn.find(T=>T.id===H))==null?void 0:hl.chapters)??[]).map(T=>s.jsx(Gn,{value:T.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:T.title},T.id))})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>ee(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:wd,disabled:ue||Z.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:ue?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(It,{open:!!we,onOpenChange:T=>!T&&Be(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white",children:["付款记录 — ",(we==null?void 0:we.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:Ue?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):we&&we.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):we?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:we.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 F=T.userId??T.openId??"-";return F.length>12?F.slice(0,6)+"..."+F.slice(-4):F})()})}),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(It,{open:vn,onOpenChange:dt,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(Bh,{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)"}),Dn?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(ne,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(le,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.readWeight,onChange:T=>ln(F=>({...F,readWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(le,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.recencyWeight,onChange:T=>ln(F=>({...F,recencyWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(le,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Tt.payWeight,onChange:T=>ln(F=>({...F,payWeight:Math.max(0,Math.min(1,parseFloat(T.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(Tt.readWeight+Tt.recencyWeight+Tt.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(J,{onClick:_i,disabled:Dt||Math.abs(Tt.readWeight+Tt.recencyWeight+Tt.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Dt?"保存中...":"保存权重"})]})]})]})}),s.jsx(It,{open:ae,onOpenChange:_,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:Q,onChange:T=>z(T.target.value),placeholder:"输入篇名"})]})}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>{_(!1),z("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(J,{onClick:Nd,disabled:te||!Q.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:te?s.jsxs(s.Fragment,{children:[s.jsx(He,{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(It,{open:!!c,onOpenChange:()=>u(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white inset-0 translate-x-0 translate-y-0 w-screen h-screen max-w-none max-h-none rounded-none flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(Rt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),c&&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(ne,{className:"text-gray-300",children:"章节ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.id,onChange:T=>u({...c,id:T.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:c.isFree?0:c.price,onChange:T=>u({...c,price:Number(T.target.value),isFree:Number(T.target.value)===0}),disabled:c.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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:c.isFree||c.price===0,onChange:T=>u({...c,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(ne,{className:"text-gray-300",children:"预览%"}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",placeholder:`全局 ${ft}%`,value:c.previewPercent!=null?String(c.previewPercent):"",onChange:T=>{const F=T.target.value.trim();if(F===""){u({...c,previewPercent:null});return}const S=Number(F);Number.isFinite(S)&&u({...c,previewPercent:Math.min(100,Math.max(1,Math.round(S)))})}})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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:c.isNew??!1,onChange:T=>u({...c,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(ne,{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:c.isPinned??!1,onChange:T=>u({...c,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(ne,{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:c.editionPremium!==!0,onChange:()=>u({...c,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:c.editionPremium===!0,onChange:()=>u({...c,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(ne,{className:"text-gray-300",children:"热度分"}),s.jsx(le,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:c.hotScore??0,onChange:T=>u({...c,hotScore:Math.max(0,parseFloat(T.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"章节标题"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.title,onChange:T=>u({...c,title:T.target.value})})]}),c.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"文件路径"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:c.filePath,disabled:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),m?s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(R0,{ref:nl,content:c.content||"",onChange:T=>u({...c,content:T}),onImageUpload:Ka,onMediaUpload:Qs,persons:Ss,linkTags:da,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(Xt,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[c&&s.jsxs(J,{variant:"outline",onClick:()=>al({id:c.id,title:c.title,price:c.price}),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent mr-auto",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(J,{variant:"outline",onClick:()=>u(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(J,{onClick:ol,disabled:b,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(Vl,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Do,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Bt,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(Bt,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(Vg,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(Bt,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(lr,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(Bt,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(Aa,{className:"w-4 h-4 mr-2"}),"@列表"]}),s.jsxs(Bt,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(L1,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),s.jsxs(Vt,{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(or,{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:sl}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(J,{onClick:()=>f(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(J,{onClick:()=>_(!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(Mn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(J,{variant:"outline",onClick:()=>ee(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",Z.length," 节)"]})]}),r?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(He,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(yV,{parts:dn,expandedParts:i,onTogglePart:xd,onReorder:Qa,onReadSection:il,onDeleteSection:Ya,onAddSectionInPart:ic,onAddChapterInPart:gs,onDeleteChapter:vd,onEditPart:yd,onDeletePart:cl,onEditChapter:oc,selectedSectionIds:Z,onToggleSectionSelect:ll,onShowSectionOrders:al,pinnedSectionIds:Te})]}),s.jsx(Vt,{value:"search",className:"space-y-4",children:s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{children:s.jsx(ot,{className:"text-white",children:"内容搜索"})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:w,onChange:T=>v(T.target.value),onKeyDown:T=>T.key==="Enter"&&cc()}),s.jsx(J,{onClick:cc,disabled:E||!w.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:E?s.jsx(He,{className:"w-4 h-4 animate-spin"}):s.jsx(lr,{className:"w-4 h-4"})})]}),k.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",k.length," 个结果"]}),k.map(T=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>{const F=e.find(S=>S.id===T.id);il({id:T.id,mid:T.mid,title:T.title,price:T.price??1,filePath:"",previewPercent:F==null?void 0:F.previewPercent})},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:T.id}),s.jsx("span",{className:"text-white",children:T.title}),Te.includes(T.id)&&s.jsx(Hc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Ve,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:T.matchType==="title"?"标题匹配":"内容匹配"})]}),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(Vt,{value:"ranking",className:"space-y-4",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Bh,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsxs(ze,{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(ne,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(le,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:ft,onChange:T=>_e(Math.max(1,Math.min(100,Number(T.target.value)||20))),disabled:U}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(J,{size:"sm",onClick:Bi,disabled:yt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:yt?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",ft,"% 内容;章节「预览%」可单独覆盖"]})]}),s.jsxs("div",{className:"mt-6 space-y-2",children:[s.jsx(ne,{className:"text-gray-400 text-sm",children:"阅读页 / 朋友圈文案(JSON)"}),s.jsxs("p",{className:"text-xs text-gray-500",children:["占位符:",s.jsx("code",{className:"text-gray-400",children:"{percent}"})," 为预览比例、",s.jsx("code",{className:"text-gray-400",children:"{price}"})," 为章节价;与小程序付费墙、复制发圈、单页模式弹窗一致。"]}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-gray-200 font-mono text-xs min-h-[280px]",value:mt,onChange:T=>lt(T.target.value),disabled:Mt,spellCheck:!1}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>Vi(),disabled:Mt,children:"重新加载"}),s.jsx(J,{type:"button",size:"sm",onClick:gd,disabled:Nn||Mt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Nn?"保存中...":"保存文案配置"})]})]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(it,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Vg,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",Xn.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>Bs(),disabled:xn,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(He,{className:`w-4 h-4 ${xn?"animate-spin":""}`})}),s.jsx(J,{variant:"ghost",size:"sm",disabled:Sn<=1||xn,onClick:()=>_n(T=>Math.max(1,T-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(MT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[Sn," / ",Wr]}),s.jsx(J,{variant:"ghost",size:"sm",disabled:Sn>=Wr||xn,onClick:()=>_n(T=>Math.min(Wr,T+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(wi,{className:"w-4 h-4"})})]})]})}),s.jsx(ze,{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:"编辑"})]}),rc.map((T,F)=>{const S=(Sn-1)*Ga+F+1,D=T.isPinned??Te.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 ${D?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${S<=3?"text-amber-400":"text-gray-500"}`,children:S<=3?["🥇","🥈","🥉"][S-1]:`#${S}`}),s.jsx(J,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${D?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>Fi(T.id),disabled:tt,title:D?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:D?s.jsx(Hc,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(D1,{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(J,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>il({id:T.id,mid:T.mid,title:T.title,price:T.price,filePath:"",previewPercent:T.previewPercent}),title:"编辑文章",children:s.jsx(pn,{className:"w-3 h-3"})})})]},T.id)}),rc.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(Vt,{value:"link-person",className:"space-y-4",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — @列表(编辑器内输入 @ 可链接)"]}),s.jsxs("div",{className:"text-xs text-gray-500 mt-1 space-y-1",children:[s.jsxs("p",{children:["文章 @ 存 ",s.jsx("span",{className:"text-gray-400",children:"token"}),";小程序点 @ 用 token 换存客宝密钥后加好友/拉群。"]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-purple-300",children:"超级个体"}),":开通且昵称合法会自动进本列表可 @;共用「超级个体拉群」统一获客计划(话术由技术侧在系统里配置,本页不填 plan/apiKey,避免误操作)。"]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-[#38bdac]",children:"飞书群 Webhook"}),"(按人推线索到群):在下方表格「飞书群」列查看状态,操作栏点 Webhook 图标配置;与绑定会员用户维度一致。"]}),s.jsx("p",{children:"点「添加」新建的人物:每人单独一条存客宝计划(SOUL链接人与事-名称)。"})]})]}),s.jsxs(ze,{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:"本页只管理可 @ 的人物列表"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>{xs()},title:"刷新",children:s.jsx(He,{className:"w-4 h-4"})}),s.jsxs(J,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{ur(null),Hr(!0)},children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),s.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:Ss.length>0?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("th",{className:"text-left py-1.5 px-3 w-[280px] font-normal",children:"token"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-24 font-normal",children:"@的人"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[72px] font-normal text-xs",children:"来源"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-[100px] font-normal text-xs",children:"会员"}),s.jsx("th",{className:"py-1.5 px-3 w-16 font-normal text-center",children:"获客数"}),s.jsx("th",{className:"text-left py-1.5 px-3 font-normal",children:"获客计划"}),s.jsx("th",{className:"text-left py-1.5 px-2 w-[72px] font-normal text-xs",children:"飞书群"}),s.jsx("th",{className:"text-center py-1.5 px-2 w-14 font-normal text-xs",children:"置顶"}),s.jsx("th",{className:"text-left py-1.5 px-3 w-16 font-normal",children:"状态"}),s.jsx("th",{className:"text-left py-1.5 px-2 w-24 font-normal",children:"操作"})]})}),s.jsx("tbody",{children:Ss.map(T=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-[#0a1628]/80",children:[s.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs font-mono",title:"32位token",children:T.id}),s.jsx("td",{className:"py-2 px-3 truncate max-w-[96px]",children:s.jsx("button",{type:"button",className:"text-amber-400 hover:text-amber-300 hover:underline text-left",onClick:()=>{zs[T.id]&&Cr(T.id,T.name)},title:zs[T.id]?"点击查看获客详情":T.name,children:T.name})}),s.jsx("td",{className:"py-2 px-3",children:T.personSource==="vip_sync"?s.jsx("span",{className:"text-[10px] text-purple-300 bg-purple-500/15 px-1.5 py-0.5 rounded whitespace-nowrap",children:"超级个体"}):s.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 py-0.5 rounded whitespace-nowrap",children:"手工"})}),s.jsx("td",{className:"py-2 px-3 text-xs",children:T.userId?s.jsxs("div",{className:"flex flex-col gap-0.5 items-start max-w-[100px]",children:[T.personSource==="vip_sync"&&s.jsx("span",{className:"text-[10px] text-purple-300/90 leading-tight",children:"已绑定超级个体"}),s.jsx("button",{type:"button",className:"text-[#38bdac] hover:underline truncate max-w-[96px] block text-left",title:`用户ID: ${T.userId}`,onClick:()=>t(`/users?search=${encodeURIComponent(T.userId||"")}`),children:T.name})]}):s.jsx("span",{className:"text-gray-600",children:"—"})}),(()=>{const F=zs[T.id]||0;return s.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold cursor-pointer ${F>0?"text-green-400 hover:text-green-300 hover:underline":"text-gray-600"}`,title:F>0?"点击查看获客详情":"暂无获客",onClick:()=>{F>0&&Cr(T.id,T.name)},children:F})})(),s.jsx("td",{className:"py-2 px-3 text-white truncate max-w-[220px]",title:`planId: ${T.ckbPlanId??"-"}`,children:s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"truncate",children:T.ckbPlanId?T.personSource==="vip_sync"?"超级个体拉群(统一计划)":`SOUL链接人与事-${T.name}`:"—"})})}),s.jsx("td",{className:"py-2 px-2 text-xs",children:T.userId?Ha[(T.userId||"").trim()]?s.jsx("span",{className:"text-[#38bdac]",title:Ha[(T.userId||"").trim()],children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"}):s.jsx("span",{className:"text-gray-600",children:"—"})}),s.jsx("td",{className:"py-2 px-2 text-center",children:s.jsx(J,{type:"button",variant:"ghost",size:"sm",className:T.isPinned?"text-amber-400 hover:text-amber-300 h-7 px-2":"text-gray-500 hover:text-amber-400/90 h-7 px-2",title:T.isPinned?"取消小程序首页置顶":"设为小程序首页置顶(全局唯一)",onClick:()=>void Za(T,!T.isPinned),children:s.jsx(D1,{className:`w-3.5 h-3.5 ${T.isPinned?"fill-amber-400":""}`})})}),s.jsx("td",{className:"py-2 px-3 text-center",children:T.ckbPlanId?s.jsx("span",{className:"text-[10px] text-green-400 bg-green-400/10 px-1.5 py-0.5 rounded",children:"启用"}):s.jsx("span",{className:"text-[10px] text-gray-500 bg-gray-500/10 px-1.5 py-0.5 rounded",children:"未配置"})}),s.jsx("td",{className:"py-2 px-2",children:s.jsxs("div",{className:"flex items-center gap-0",children:[s.jsx(J,{variant:"ghost",size:"sm",className:`h-6 px-2 ${T.userId?"text-[#38bdac] hover:text-[#5fe0cd]":"text-gray-600 cursor-not-allowed opacity-50"}`,title:T.userId?"设置飞书群 Webhook(点击头像留资推送)":"未绑定会员,无法配置",disabled:!T.userId,onClick:()=>Kr(T),children:s.jsx($1,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const F=await vV(T.personId||"");if(F!=null&&F.success&&F.person){const S=F.person;ur({id:S.token??S.personId,personId:S.personId,name:S.name,personSource:S.personSource??"",userId:S.userId??"",label:S.label??"",ckbApiKey:S.ckbApiKey??"",remarkType:S.remarkType,remarkFormat:S.remarkFormat,addFriendInterval:S.addFriendInterval,startTime:S.startTime,endTime:S.endTime,deviceGroups:S.deviceGroups})}else ur(T),F!=null&&F.error&&G.error(F.error)}catch(F){console.error(F),ur(T),G.error(F instanceof Error?F.message:"加载人物详情失败")}Hr(!0)},children:s.jsx(Bg,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>Cr(T.id,T.name),children:s.jsx(Vn,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:T.personSource==="vip_sync"?"删除本地 @人物(不删统一获客计划)":"删除(同时删除存客宝对应获客计划)",onClick:()=>fa(T),children:s.jsx(Qn,{className:"w-3 h-3"})})]})})]},T.id))})]}):s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(NA,{className:"w-4 h-4 text-[#38bdac]"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs(ze,{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(ne,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(le,{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(ne,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(le,{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.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Bh,{className:"w-4 h-4 text-blue-400"}),"获客 Webhook 通知"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置后新获客线索将自动推送到群聊(支持企业微信/飞书 Webhook)"})]}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex gap-3 items-end",children:[s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"Webhook URL"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",value:el,onChange:T=>tl(T.target.value)})]}),s.jsxs(J,{size:"sm",className:"bg-blue-500 hover:bg-blue-600 text-white h-8",onClick:async()=>{const T=el.trim();try{const F=await gt("/api/db/config",{key:"ckb_lead_webhook_url",value:T,description:"获客线索 Webhook 通知 URL(企微/飞书)"});F!=null&&F.success?G.success(T?"Webhook 已保存":"Webhook 已清除"):G.error((F==null?void 0:F.error)??"保存失败")}catch{G.error("保存失败")}},children:[s.jsx(kn,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"配置企业微信或飞书群机器人 Webhook URL,获客成功后自动推送通知"})]})]})]}),s.jsxs(Vt,{value:"link-tag",className:"space-y-4",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"pb-3",children:[s.jsxs(ot,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(L1,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转网页/本小程序页/其他小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可跳转外链、当前小程序指定页面、或进入流量池"})]}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-end justify-between gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-400 text-xs",children:"搜索"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:Pt,onChange:T=>{Qt(T.target.value),_s(1)}})]}),s.jsx(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{hr(),ya()},title:"刷新",children:s.jsx(He,{className:"w-4 h-4"})})]}),s.jsxs(J,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{Br(null),$n({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),gn(""),Zs(!1),Zn(!0)},children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加标签"]})]}),s.jsxs("div",{className:"rounded-md border border-gray-700/50 overflow-hidden",children:[s.jsx("div",{className:"max-h-[420px] overflow-y-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-[#0a1628] border-b border-gray-700/50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-32",children:"标签"}),s.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-28",children:"别名"}),s.jsx("th",{className:"text-left px-3 py-2 text-gray-400 w-20",children:"类型"}),s.jsx("th",{className:"text-left px-3 py-2 text-gray-400",children:"目标 / AppID"}),s.jsx("th",{className:"text-right px-3 py-2 text-gray-400 w-28",children:"操作"})]})}),s.jsx("tbody",{children:wr?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"加载中..."})}):Ba.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):Ba.map(T=>s.jsxs("tr",{className:"border-b border-gray-700/30 hover:bg-white/5",children:[s.jsx("td",{className:"px-3 py-2",children:s.jsxs("button",{type:"button",className:"text-amber-400 font-semibold hover:text-amber-300 hover:underline text-left",onClick:()=>{Br(T),$n({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",appSecret:"",pagePath:T.pagePath??""}),gn(T.appId??""),Zs(!1),Zn(!0)},title:"点击编辑标签",children:["#",T.label]})}),s.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs truncate max-w-[120px]",title:T.aliases||"",children:T.aliases||"—"}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Ve,{variant:"secondary",className:`text-[10px] ${T.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":T.type==="internal"?"bg-sky-500/20 text-sky-200 border-sky-500/30":T.type==="miniprogram"||T.type==="wxlink"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:T.type==="url"?"网页":T.type==="internal"?"本小程序":T.type==="ckb"?"存客宝":T.type==="wxlink"?"小程序链接":"小程序"})}),s.jsx("td",{className:"px-3 py-2 text-gray-300",children:T.type==="internal"?s.jsx("div",{className:"text-xs font-mono text-sky-300 truncate max-w-[420px]",title:T.pagePath||"",children:T.pagePath||"—"}):T.type==="miniprogram"?s.jsxs("div",{className:"space-y-0.5",children:[(()=>{const F=qr.find(S=>S.key===T.appId);return s.jsxs(s.Fragment,{children:[F&&s.jsx("div",{className:"text-xs text-white",children:F.name}),s.jsxs("div",{className:"text-xs font-mono text-[#38bdac]",children:["AppID: ",(F==null?void 0:F.appId)||T.appId||"—"]})]})})(),T.pagePath&&s.jsx("div",{className:"text-xs text-gray-500 font-mono",children:T.pagePath}),s.jsxs("div",{className:`text-xs ${T.hasAppSecret?"text-emerald-400/90":"text-amber-500/80"}`,children:["AppSecret:",T.hasAppSecret?"已保存(仅服务端)":"未配置"]})]}):T.type==="wxlink"?s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"text-xs text-[#38bdac] truncate max-w-[420px] font-mono",title:T.url,children:T.url||"—"}),s.jsx("div",{className:"text-[11px] text-gray-500",children:"小程序内点击 → web-view 打开 → 自动唤起目标小程序"})]}):T.url?s.jsxs("a",{href:T.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[T.url," ",s.jsx(Io,{className:"w-3 h-3 shrink-0"})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"—"})}),s.jsx("td",{className:"px-3 py-2",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{Br(T),$n({tagId:T.id,label:T.label,aliases:T.aliases??"",url:T.url,type:T.type,appId:T.appId??"",appSecret:"",pagePath:T.pagePath??""}),gn(T.appId??""),Zs(!1),Zn(!0)},title:"编辑",children:s.jsx(Bg,{className:"w-3 h-3"})}),s.jsx(J,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${T.label}」吗?`))try{const F=await bi(`/api/db/link-tags?tagId=${encodeURIComponent(T.id)}`);F!=null&&F.success?(G.success("已删除"),hr(),ya()):G.error((F==null?void 0:F.error)??"删除失败")}catch(F){console.error(F),G.error("删除失败")}},title:"删除",children:s.jsx(Qn,{className:"w-3 h-3"})})]})})]},T.id))})]})}),s.jsx(us,{page:Fr,pageSize:qs,total:Gs,totalPages:de,onPageChange:T=>_s(T),onPageSizeChange:T=>{dr(T),_s(1)}})]})]})]}),s.jsx(It,{open:en,onOpenChange:Zn,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[s.jsxs(Rt,{className:"gap-1",children:[s.jsx(Lt,{className:"text-base",children:kr?"编辑链接标签":"添加链接标签"}),s.jsx(Oo,{className:"text-gray-400 text-xs",children:"配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转。「本小程序页面」仅跳转当前小程序内路径;API 跳转小程序类型需填 mpKey 或微信 AppID;AppSecret 仅存服务端(不下发小程序),供后续开放接口与台账使用。"})]}),s.jsxs("div",{className:"space-y-3 py-2",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"标签ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或自定义短 ID(如 kr),最长 50 字符",value:Nt.tagId,disabled:!!kr,onChange:T=>$n(F=>({...F,tagId:T.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"显示文字"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:Nt.label,onChange:T=>$n(F=>({...F,label:T.target.value}))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"别名(多个用逗号分隔,同指向一个目标)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 团队招募, 团队合伙人",value:Nt.aliases,onChange:T=>$n(F=>({...F,aliases:T.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"类型"}),s.jsxs(go,{value:Nt.type,onValueChange:T=>$n(F=>({...F,type:T})),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:s.jsx(yo,{})}),s.jsxs(Ni,{className:"bg-[#0f2137] border-gray-700 text-white",children:[s.jsx(Gn,{value:"url",children:"网页链接"}),s.jsx(Gn,{value:"internal",children:"本小程序页面"}),s.jsx(Gn,{value:"miniprogram",children:"小程序(API跳转)"}),s.jsx(Gn,{value:"wxlink",children:"小程序链接(右上角复制)"}),s.jsx(Gn,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:Nt.type==="url"?"URL地址":Nt.type==="ckb"?"存客宝计划URL":Nt.type==="wxlink"?"小程序链接":Nt.type==="internal"?"页面路径":"小程序 mpKey / 微信 AppID"}),Nt.type==="internal"?s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"/pages/index/index 或带参数 ?id=1",value:Nt.pagePath,onChange:T=>$n(F=>({...F,pagePath:T.target.value}))}):Nt.type==="wxlink"?s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"粘贴小程序右上角 ... → 复制链接 得到的 URL",value:Nt.url,onChange:T=>$n(F=>({...F,url:T.target.value}))}):Nt.type==="miniprogram"&&qr.length>0?s.jsxs("div",{ref:ba,className:"relative",children:[s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Er?Xs:Nt.appId,onChange:T=>{const F=T.target.value;gn(F),Zs(!0),qr.some(S=>S.key===F)||$n(S=>({...S,appId:F}))},onFocus:()=>{gn(Nt.appId),Zs(!0)},onBlur:()=>setTimeout(()=>Zs(!1),150)}),Er&&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:zi.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):zi.map(T=>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:F=>{F.preventDefault(),$n(S=>({...S,appId:T.key,pagePath:T.path||""})),gn(""),Zs(!1)},children:[s.jsx("span",{children:T.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:T.key})]},T.key))})]}):s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:Nt.type==="url"?"https://...":Nt.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联配置的 key,或直接填 wx 开头的 AppID",value:Nt.type==="url"||Nt.type==="ckb"?Nt.url:Nt.appId,onChange:T=>{Nt.type==="url"||Nt.type==="ckb"?$n(F=>({...F,url:T.target.value})):$n(F=>({...F,appId:T.target.value}))}})]})]}),Nt.type==="wxlink"&&s.jsx("p",{className:"text-[11px] text-amber-400/80 leading-snug px-0.5",children:"操作:打开目标小程序 → 右上角「...」→「复制链接」→ 粘贴到上面。小程序内点击此标签会在 web-view 中打开,微信自动唤起目标小程序,无需修改小程序版本。"}),Nt.type==="miniprogram"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:Nt.pagePath,onChange:T=>$n(F=>({...F,pagePath:T.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"AppSecret(微信公众平台 · 仅服务端存储)"}),s.jsx(le,{type:"password",autoComplete:"new-password",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:kr!=null&&kr.hasAppSecret?"已保存密钥,留空不改;填写则覆盖":"粘贴目标小程序 AppSecret",value:Nt.appSecret,onChange:T=>$n(F=>({...F,appSecret:T.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-snug",children:"与 AppID 成对落库;接口响应与小程序配置中均不会返回此字段。"})]})]})]}),s.jsxs(Xt,{className:"gap-2 pt-1",children:[s.jsx(J,{variant:"outline",onClick:()=>Zn(!1),className:"border-gray-600",children:"取消"}),s.jsx(J,{onClick:async()=>{const T={tagId:Nt.tagId.trim(),label:Nt.label.trim(),aliases:Nt.aliases.trim(),url:Nt.url.trim(),type:Nt.type,appId:Nt.appId.trim(),appSecret:Nt.appSecret.trim(),pagePath:Nt.pagePath.trim()};if(T.tagId){const F=T.tagId;if([...F].length>50){G.error("标签ID 最长 50 个字符");return}if(/[#,\n\r\t]/.test(F)){G.error("标签ID 不能含 #、逗号或换行");return}}if(!T.label){G.error("显示文字必填");return}if(T.type==="miniprogram"&&(T.url=""),T.type==="internal"){T.url="",T.appId="",T.appSecret="";let F=T.pagePath.trim();if(!F){G.error("请填写本小程序页面路径");return}if(F.startsWith("/")||(F="/"+F.replace(/^\/+/,"")),!/^\/pages\//.test(F)){G.error("路径需以 /pages/ 开头");return}T.pagePath=F}T.type==="wxlink"&&(T.appId="",T.pagePath=""),ha(!0);try{const F=await gt("/api/db/link-tags",T);F!=null&&F.success?(G.success(kr?"已更新":"已添加"),Zn(!1),hr(),ya()):G.error((F==null?void 0:F.error)??"保存失败")}catch(F){console.error(F),G.error("保存失败")}finally{ha(!1)}},disabled:Vr,className:"bg-amber-500 hover:bg-amber-600 text-white",children:Vr?"保存中...":"保存"})]})]})})]})]}),s.jsx(CV,{open:cn,onOpenChange:Hr,editingPerson:Va,onSubmit:async T=>{var D;const F={personId:T.personId||T.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:T.name,userId:T.boundUserId,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:(D=T.deviceGroups)!=null&&D.trim()?T.deviceGroups.split(",").map(Y=>parseInt(Y.trim(),10)).filter(Y=>!Number.isNaN(Y)):void 0},S=await gt("/api/db/persons",F);if(S&&S.success===!1){const Y=S;Y.ckbResponse&&console.log("存客宝返回",Y.ckbResponse);const ge=Y.error||"操作失败";throw new Error(ge)}if(xs(),G.success(Va?"已保存":"已添加"),S!=null&&S.ckbCreateResult&&Object.keys(S.ckbCreateResult).length>0){const Y=S.ckbCreateResult;console.log("存客宝创建结果",Y);const ge=Y.planId??Y.id,Se=ge!=null?[`planId: ${ge}`]:[];Y.apiKey!=null&&Se.push("apiKey: ***"),G.info(Se.length?`存客宝创建结果:${Se.join(",")}`:"存客宝创建结果见控制台")}}}),s.jsx(It,{open:!!zn,onOpenChange:T=>{T||(pa(null),Ur(""))},children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx($1,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",zn==null?void 0:zn.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(ne,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:es,onChange:T=>Ur(T.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交线索时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>{pa(null),Ur("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:()=>void ei(),disabled:Qo,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),Qo?"保存中...":"保存"]})]})]})}),s.jsx(It,{open:!!Cs,onOpenChange:T=>{T||fa(null)},children:s.jsxs(At,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(Rt,{className:"gap-1",children:[s.jsx(Lt,{className:"text-white text-base",children:"确认删除"}),s.jsx(Oo,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:Cs&&s.jsxs(s.Fragment,{children:[Cs.personSource==="vip_sync"?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["确定删除超级个体「",Cs.name,"」对应的 @人物?"]}),s.jsxs("p",{className:"mt-1.5 text-amber-200/90",children:["仅删除本系统的 Person 与独立 token,",s.jsx("strong",{children:"不会"}),"删除存客宝里的「超级个体统一获客计划」(其他超级个体仍在使用该计划)。"]})]}):s.jsx(s.Fragment,{children:s.jsxs("p",{children:["确定删除「SOUL链接人与事-",Cs.name,"」?将同时删除存客宝对应获客计划。"]})}),s.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",Cs.name," 将无法正常跳转。"]})]})})]}),s.jsxs(Xt,{className:"gap-2 sm:gap-2 pt-1",children:[s.jsx(J,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>fa(null),children:"取消"}),s.jsx(J,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{Cs&&(await bi(`/api/db/persons?personId=${Cs.personId}`),fa(null),xs(),G.success("已删除"))},children:"确定删除"})]})]})}),s.jsx(It,{open:ma,onOpenChange:xa,children:s.jsxs(At,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-green-400"}),Ua," — 获客详情(共 ",ga," 条)"]})}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:sc?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(He,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Oi.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-[40px_1fr_90px_90px_70px_60px_110px] 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:"状态"}),s.jsx("span",{children:"时间"})]}),Oi.map((T,F)=>s.jsxs("div",{className:"grid grid-cols-[40px_1fr_90px_90px_70px_60px_110px] gap-2 px-3 py-2 bg-[#0a1628] rounded text-sm",children:[s.jsx("span",{className:"text-gray-500 text-xs",children:(pt-1)*20+F+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-xs",children:T.source==="article_mention"?s.jsx("span",{className:"text-purple-400",children:"文章@"}):T.source==="index_lead"?s.jsx("span",{className:"text-blue-400",children:"首页"}):s.jsx("span",{className:"text-gray-500",children:T.source||"-"})}),s.jsx("span",{className:"text-[10px]",children:s.jsx("span",{className:"text-green-400 bg-green-400/10 px-1 py-0.5 rounded",children:"已添加"})}),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))]})}),ga>20&&s.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[s.jsx(J,{size:"sm",variant:"outline",disabled:pt<=1,onClick:()=>Cr(Yo,Ua,pt-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:[pt," / ",Math.ceil(ga/20)]}),s.jsx(J,{size:"sm",variant:"outline",disabled:pt>=Math.ceil(ga/20),onClick:()=>Cr(Yo,Ua,pt+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const gi={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 jj(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):gi.stats}function kj(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):gi.highlights}function MV(){const[t,e]=g.useState(gi),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useRef(null);g.useEffect(()=>{Re("/api/admin/author-settings").then(k=>{const M=k==null?void 0:k.data;M&&typeof M=="object"&&e({name:String(M.name??gi.name),avatar:String(M.avatar??gi.avatar),avatarImg:String(M.avatarImg??""),title:String(M.title??gi.title),bio:String(M.bio??gi.bio),stats:jj(M.stats).length?jj(M.stats):gi.stats,highlights:kj(M.highlights).length?kj(M.highlights):gi.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(L=>L.label||L.value),highlights:t.highlights.filter(Boolean)},M=await gt("/api/admin/author-settings",k);if(!M||M.success===!1){G.error("保存失败: "+(M&&typeof M=="object"&&"error"in M?M.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),G.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{i(!1)}},f=async k=>{var E;const M=(E=k.target.files)==null?void 0:E[0];if(M){c(!0);try{const L=new FormData;L.append("file",M),L.append("folder","avatars");const R=$u(),W={};R&&(W.Authorization=`Bearer ${R}`);const B=await(await fetch(zl("/api/upload"),{method:"POST",body:L,credentials:"include",headers:W})).json();B!=null&&B.success&&(B!=null&&B.url)?e(O=>({...O,avatarImg:B.url})):G.error("上传失败: "+((B==null?void 0:B.error)||"未知错误"))}catch(L){console.error(L),G.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),x=k=>e(M=>({...M,stats:M.stats.filter((E,L)=>L!==k)})),b=(k,M,E)=>e(L=>({...L,stats:L.stats.map((R,W)=>W===k?{...R,[M]:E}:R)})),N=()=>e(k=>({...k,highlights:[...k.highlights,""]})),w=k=>e(M=>({...M,highlights:M.highlights.filter((E,L)=>L!==k)})),v=(k,M)=>e(E=>({...E,highlights:E.highlights.map((L,R)=>R===k?M:L)}));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(yi,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(J,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"flex items-center gap-2 text-white",children:[s.jsx(yi,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx(qt,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs(ze,{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(ne,{className:"text-gray-300",children:"姓名"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(M=>({...M,name:k.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(M=>({...M,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(sk,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(M=>({...M,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(J,{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(Ef,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:aa(t.avatarImg.startsWith("http")?t.avatarImg:zl(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(ne,{className:"text-gray-300",children:"头衔"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(M=>({...M,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"个人简介"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(M=>({...M,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsx(ot,{className:"text-white",children:"统计数据"}),s.jsx(qt,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs(ze,{className:"space-y-3",children:[t.stats.map((k,M)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:E=>b(M,"label",E.target.value),placeholder:"标签"}),s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:E=>b(M,"value",E.target.value),placeholder:"数值"}),s.jsx(J,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>x(M),children:s.jsx(Qn,{className:"w-4 h-4"})})]},M)),s.jsxs(J,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsx(ot,{className:"text-white",children:"亮点标签"}),s.jsx(qt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(ze,{className:"space-y-3",children:[t.highlights.map((k,M)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:E=>v(M,E.target.value),placeholder:"5年私域运营经验"}),s.jsx(J,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(M),children:s.jsx(Qn,{className:"w-4 h-4"})})]},M)),s.jsxs(J,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function AV(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function PV(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o]=g.useState(10),[c,u]=g.useState(0),[h,f]=g.useState(""),m=Ra(h,300),[x,b]=g.useState(!0),[N,w]=g.useState(null),[v,k]=g.useState(!1),[M,E]=g.useState(null),[L,R]=g.useState(""),[W,P]=g.useState(""),[B,O]=g.useState(""),[X,ae]=g.useState("admin"),[_,se]=g.useState("active"),[ce,me]=g.useState(!1);async function I(){var K;b(!0),w(null);try{const fe=new URLSearchParams({page:String(a),pageSize:String(o)});m.trim()&&fe.set("search",m.trim());const he=await Re(`/api/admin/users?${fe}`);he!=null&&he.success?(e(he.records||[]),r(he.total??0),u(he.totalPages??0)):w(he.error||"加载失败")}catch(fe){const he=fe;w(he.status===403?"无权限访问":((K=he==null?void 0:he.data)==null?void 0:K.error)||"加载失败"),e([])}finally{b(!1)}}g.useEffect(()=>{I()},[a,o,m]);const Z=()=>{E(null),R(""),P(""),O(""),ae("admin"),se("active"),k(!0)},V=K=>{E(K),R(K.username),P(""),O(K.name||""),ae(K.role==="super_admin"?"super_admin":"admin"),se(K.status==="disabled"?"disabled":"active"),k(!0)},xe=async()=>{var K;if(!L.trim()){w("用户名不能为空");return}if(!M&&!W){w("新建时密码必填,至少 6 位");return}if(W&&W.length<6){w("密码至少 6 位");return}w(null),me(!0);try{if(M){const fe=await Yt("/api/admin/users",{id:M.id,password:W||void 0,name:B.trim(),role:X,status:_});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}else{const fe=await gt("/api/admin/users",{username:L.trim(),password:W,name:B.trim(),role:X});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}}catch(fe){const he=fe;w(((K=he==null?void 0:he.data)==null?void 0:K.error)||"保存失败")}finally{me(!1)}},ee=async K=>{var fe;if(!AV("管理员")){w("已取消删除");return}try{const he=await bi(`/api/admin/users?id=${K}`);he!=null&&he.success?I():w((he==null?void 0:he.error)||"删除失败")}catch(he){const ue=he;w(((fe=ue==null?void 0:ue.data)==null?void 0:fe.error)||"删除失败")}},H=K=>{if(!K)return"-";try{const fe=new Date(K);return isNaN(fe.getTime())?K:fe.toLocaleString("zh-CN")}catch{return K}};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(Vc,{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(le,{placeholder:"搜索用户名/昵称",value:h,onChange:K=>f(K.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(J,{variant:"outline",size:"sm",onClick:I,disabled:x,className:"border-gray-600 text-gray-300",children:s.jsx(He,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsxs(J,{onClick:Z,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),N&&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:N}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-0",children:x?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户名"}),s.jsx(ke,{className:"text-gray-400",children:"昵称"}),s.jsx(ke,{className:"text-gray-400",children:"角色"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[t.map(K=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:K.id}),s.jsx(je,{className:"text-white font-medium",children:K.username}),s.jsx(je,{className:"text-gray-400",children:K.name||"-"}),s.jsx(je,{children:s.jsx(Ve,{variant:"outline",className:K.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:K.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(je,{children:s.jsx(Ve,{variant:"outline",className:K.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:K.status==="active"?"正常":"已禁用"})}),s.jsx(je,{className:"text-gray-500 text-sm",children:H(K.createdAt)}),s.jsxs(je,{className:"text-right",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>V(K),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>ee(K.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Jn,{className:"w-4 h-4"})})]})]},K.id)),t.length===0&&!x&&s.jsx(ht,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:N==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&s.jsx("div",{className:"p-4 border-t border-gray-700/50",children:s.jsx(us,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),s.jsx(It,{open:v,onOpenChange:k,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Rt,{children:s.jsx(Lt,{className:"text-white",children:M?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"用户名"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:L,onChange:K=>R(K.target.value),disabled:!!M}),M&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:M?"新密码(留空不改)":"密码"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:M?"留空表示不修改":"至少 6 位",value:W,onChange:K=>P(K.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"昵称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:B,onChange:K=>O(K.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:X,onChange:K=>ae(K.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:"超级管理员"})]})]}),M&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:_,onChange:K=>se(K.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(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:xe,disabled:ce,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),ce?"保存中...":"保存"]})]})]})})]})}function Tn({method:t,url:e,desc:n,headers:r,bodyTitle:a,body:i,response:o}){const c=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 ${c}`,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(` +`)})]}),i&&s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:a??"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:i})]}),o&&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:o})]})]})}function q4(){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($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(wu,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),s.jsx(ze,{className:"space-y-4",children:s.jsx(Tn,{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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(or,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),s.jsxs($e,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/db/book?action=chapters",desc:"获取章节树",headers:t,response:`{ +}`})})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(or,{className:"w-5 h-5 text-[#38bdac]"}),"2. 章节管理 (Chapters)"]})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/db/book?action=chapters",desc:"获取章节树",headers:t,response:`{ "success": true, "data": [ { "id": "part-1", "title": "第一篇", "children": [...] }, @@ -954,7 +954,7 @@ ${b.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`}),s.jsx(Tn,{method:"DELETE",url:"/api/upload?path={encodeURIComponent(文件URL)}",desc:"按 URL 删除已上传文件(本地或 OSS,需与上传返回的 url 一致)",headers:["Authorization: Bearer {token}(建议携带)"],response:`{ "success": true, "message": "删除成功" -}`})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(yi,{className:"w-5 h-5 text-[#38bdac]"}),"3. 人物管理 (@Mentions)"]})}),s.jsxs($e,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/db/persons",desc:"人物列表",headers:t,response:`{ +}`})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(yi,{className:"w-5 h-5 text-[#38bdac]"}),"3. 人物管理 (@Mentions)"]})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/db/persons",desc:"人物列表",headers:t,response:`{ "success": true, "data": [ { "personId": "p1", "label": "张三", "aliases": ["老张"], ... } @@ -978,7 +978,7 @@ ${b.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`}),s.jsx(Tn,{method:"DELETE",url:"/api/db/persons?personId={id}",desc:"删除人物",headers:t,response:`{ "success": true, "message": "已删除" -}`})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(ou,{className:"w-5 h-5 text-[#38bdac]"}),"4. 链接标签 (#LinkTags)"]})}),s.jsxs($e,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/db/link-tags",desc:"标签列表",headers:t,response:`{ +}`})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(lu,{className:"w-5 h-5 text-[#38bdac]"}),"4. 链接标签 (#LinkTags)"]})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/db/link-tags",desc:"标签列表",headers:t,response:`{ "success": true, "data": [ { "tagId": "t1", "label": "官网", "aliases": [], "type": "url", "url": "https://..." } @@ -997,18 +997,18 @@ ${b.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`}),s.jsx(Tn,{method:"DELETE",url:"/api/db/link-tags?tagId={id}",desc:"删除标签",headers:t,response:`{ "success": true, "message": "已删除" -}`})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(lr,{className:"w-5 h-5 text-[#38bdac]"}),"5. 内容搜索"]})}),s.jsx($e,{className:"space-y-4",children:s.jsx(Tn,{method:"GET",url:"/api/search?q={keyword}",desc:"搜索(标题优先 3 条 + 内容匹配)",headers:t,response:`{ +}`})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(lr,{className:"w-5 h-5 text-[#38bdac]"}),"5. 内容搜索"]})}),s.jsx(ze,{className:"space-y-4",children:s.jsx(Tn,{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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vg,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),s.jsx($e,{className:"space-y-4",children:s.jsx(Tn,{method:"GET",url:"/api/db/book?action=ranking",desc:"排行榜数据",headers:t,response:`{ +}`})})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vg,{className:"w-5 h-5 text-[#38bdac]"}),"6. 内容排行"]})}),s.jsx(ze,{className:"space-y-4",children:s.jsx(Tn,{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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx($l,{className:"w-5 h-5 text-[#38bdac]"}),"7. 小程序接口"]})}),s.jsxs($e,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/miniprogram/config/read-extras",desc:"阅读页懒加载:linkTags、linkedMiniprograms、mentionPersons(@ 自动解析:name/label/aliases + token,与 persons 表一致;inPool 表示已绑定会员即超级个体侧流量池人物)",headers:["Content-Type: application/json"],response:`{ +}`})})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(it,{className:"pb-3",children:s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx($l,{className:"w-5 h-5 text-[#38bdac]"}),"7. 小程序接口"]})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsx(Tn,{method:"GET",url:"/api/miniprogram/config/read-extras",desc:"阅读页懒加载:linkTags、linkedMiniprograms、mentionPersons(@ 自动解析:name/label/aliases + token,与 persons 表一致;inPool 表示已绑定会员即超级个体侧流量池人物)",headers:["Content-Type: application/json"],response:`{ "linkTags": [], "linkedMiniprograms": [], "mentionPersons": [ @@ -1032,16 +1032,16 @@ ${b.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: }`,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/upload(与后台编辑器一致)。小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}const ki="/pages/member-detail/member-detail",Ea="/pages/read/read",Ma={[ki]:"成员详情",[Ea]:"文章详情 / 阅读"},Tg=[{value:"/pages/index/index",label:"首页"},{value:"/pages/chapters/chapters",label:"目录"},{value:"/pages/match/match",label:"找伙伴"},{value:"/pages/my/my",label:"我的"},{value:"/pages/read/read",label:"文章详情 / 阅读"},{value:"/pages/link-preview/link-preview",label:"链接预览"},{value:"/pages/agreement/agreement",label:"用户协议"},{value:"/pages/privacy/privacy",label:"隐私政策"},{value:"/pages/referral/referral",label:"邀请"},{value:"/pages/purchases/purchases",label:"购买记录"},{value:"/pages/reading-records/reading-records",label:"阅读记录"},{value:"/pages/settings/settings",label:"设置"},{value:"/pages/search/search",label:"搜索"},{value:"/pages/addresses/addresses",label:"地址列表"},{value:"/pages/addresses/edit",label:"编辑地址"},{value:"/pages/withdraw-records/withdraw-records",label:"提现记录"},{value:"/pages/wallet/wallet",label:"钱包"},{value:"/pages/vip/vip",label:"会员中心"},{value:"/pages/member-detail/member-detail",label:"成员详情"},{value:"/pages/mentors/mentors",label:"导师列表"},{value:"/pages/mentor-detail/mentor-detail",label:"导师详情"},{value:"/pages/profile-show/profile-show",label:"资料展示"},{value:"/pages/profile-edit/profile-edit",label:"编辑资料"},{value:"/pages/avatar-nickname/avatar-nickname",label:"头像昵称"},{value:"/pages/gift-pay/detail",label:"礼物支付 · 详情"},{value:"/pages/gift-pay/list",label:"礼物支付 · 列表"},{value:"/pages/gift-pay/redemption-detail",label:"礼物支付 · 兑换详情"},{value:"/pages/dev-login/dev-login",label:"开发登录"}],IV=Ea;function Sj(t){const e=String(t.pageName??"").trim();return e||Ma[t.pagePath]||"—"}function RV(t){const e=String(t??"").trim();return e==="singlePage"||e==="single_page"?"singlePage":"fullApp"}function Cj(t){return t==="singlePage"?"单页面":"多页面"}function So(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`pp-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function cb(t){return/^[a-zA-Z][a-zA-Z0-9_]*$/.test(t.trim())}function LV(t){if(!t||typeof t!="object"||Array.isArray(t))return[];const e=t.pagePopupItems;if(!Array.isArray(e))return[];const n=[];return e.forEach(r=>{if(!r||typeof r!="object"||Array.isArray(r))return;const a=r,i=String(a.key??"").trim();if(!cb(i))return;const o=String(a.pagePath??"").trim();o.startsWith("/")&&n.push({id:typeof a.id=="string"&&a.id.trim()?a.id.trim():So(),pageName:String(a.pageName??"").trim(),pagePath:o,scope:RV(a.scope),key:i,behavior:String(a.behavior??"").trim()||"—",content:String(a.content??"")})}),n}function OV(t){if(!t||typeof t!="object"||Array.isArray(t))return[];const e=t,n=[],r=e.memberDetailPage;if(r&&typeof r=="object"&&!Array.isArray(r)){const o=r;typeof o.unlockIntroTitle=="string"&&o.unlockIntroTitle.trim()&&n.push({id:So(),pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroTitle",behavior:"解锁前说明弹窗 · 标题(wx.showModal title)",content:o.unlockIntroTitle}),typeof o.unlockIntroBody=="string"&&o.unlockIntroBody.trim()&&n.push({id:So(),pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroBody",behavior:"解锁前说明弹窗 · 正文(wx.showModal content)",content:o.unlockIntroBody})}const a=e.readPage;if(a&&typeof a=="object"&&!Array.isArray(a)){const o=a,c=[["beforeLoginHint","未登录时付费墙上方说明","fullApp"],["singlePageTitle","朋友圈单页 · 付费区标题","singlePage"],["singlePagePaywallHint","朋友圈单页 · 付费墙说明","singlePage"]];for(const[u,h,f]of c)typeof o[u]=="string"&&String(o[u]).trim()&&n.push({id:So(),pageName:Ma[Ea],pagePath:Ea,scope:f,key:u,behavior:h,content:String(o[u])})}const i=e.customPagePopups;return Array.isArray(i)&&i.forEach((o,c)=>{if(!o||typeof o!="object"||Array.isArray(o))return;const u=o,h=String(u.pagePath??"").trim();if(!h.startsWith("/"))return;const f=String(u.pageName??"").trim(),m=(x,b,N,w)=>{if(typeof N!="string"||!N.trim())return;const v=`c${c}_${x}`;cb(v)&&n.push({id:So(),pageName:f||Ma[h]||"",pagePath:h,scope:w,key:v,behavior:`${b}(旧版 customPagePopups 迁移)`,content:N})};m("fullModalTitle","完整端弹窗标题",u.fullModalTitle,"fullApp"),m("fullModalBody","完整端弹窗正文",u.fullModalBody,"fullApp"),m("singlePageTitle","单页标题",u.singlePageTitle,"singlePage"),m("singlePageBody","单页说明",u.singlePageBody,"singlePage")}),n}const DV=new Set(["memberDetailPage","readPage","customPagePopups","pagePopupItems"]);function _V(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const n=t;for(const r of Object.keys(n))DV.has(r)||(e[r]=n[r]);return e}function $V(t){let e=LV(t);return e.length===0&&(e=OV(t)),{extra:_V(t),pagePopupItems:zV(e)}}function zV(t){const e=new Set,n=[];for(const r of t){const a=`${r.pagePath}\0${r.key}`;e.has(a)||(e.add(a),n.push(r))}return n}function FV(t,e){const n={...e};n.pagePopupItems=t.map(a=>({id:a.id,pageName:String(a.pageName??"").trim(),pagePath:a.pagePath.trim(),scope:a.scope==="singlePage"?"singlePage":"fullApp",key:a.key.trim(),behavior:a.behavior.trim()||"—",content:a.content})),delete n.memberDetailPage,delete n.readPage,delete n.customPagePopups;const r=n.chaptersPage;if(r&&typeof r=="object"&&!Array.isArray(r)){const a=r??{};delete a.sectionNewBadgeText;const i=String(a.newBadgeText??"").trim();i?a.newBadgeText=i:delete a.newBadgeText}return n}function BV(t){const e=String(t.content||"").replace(/\s+/g," ").trim();return e.length>56?`${e.slice(0,56)}…`:e||"—"}const VV=[{pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroTitle",behavior:"解锁前说明弹窗 · 标题(wx.showModal title)",content:"解锁与链接说明"},{pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroBody",behavior:"解锁前说明弹窗 · 正文(wx.showModal content)",content:`「链接」用于提交留资,由对方通过获客计划跟进;「解锁」用于复制手机/微信号后自行添加好友。 +}`})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-6",children:"管理端主要使用 /api/admin/*、/api/db/*;富文本素材上传另用公共接口 /api/upload(与后台编辑器一致)。小程序使用 /api/miniprogram/*。完整实现见 soul-api 源码。"})]})}function IV(){const[t,e]=g.useState(""),n=Ra(t,300),[r,a]=g.useState(1),[i,o]=g.useState(10),[c,u]=g.useState(0),[h,f]=g.useState(1),[m,x]=g.useState([]),[b,N]=g.useState(!1),[w,v]=g.useState(null),[k,M]=g.useState(!1),[E,L]=g.useState(""),[R,W]=g.useState(!1),[P,B]=g.useState(null),O=g.useCallback(async()=>{N(!0),v(null);try{const _=new URLSearchParams;_.set("page",String(r)),_.set("pageSize",String(i)),n.trim()&&_.set("search",n.trim());const se=await Re(`/api/admin/open-platform/keys?${_.toString()}`);if(!se.success){v(se.error||"加载失败"),x([]);return}x(se.records||[]),u(se.total??0),f(se.totalPages??1)}catch(_){v(_ instanceof Error?_.message:"网络错误"),x([])}finally{N(!1)}},[r,i,n]);g.useEffect(()=>{O()},[O]);const X=async()=>{var _;W(!0);try{const se=await gt("/api/admin/open-platform/keys",{name:E.trim()||"未命名密钥"});if(!se.success||!((_=se.data)!=null&&_.secret)){G.error(se.error||"创建失败");return}M(!1),L(""),B({secret:se.data.secret,name:se.data.name||""}),G.success("密钥已创建,请立即复制保存"),O()}catch(se){G.error(se instanceof Error?se.message:"创建失败")}finally{W(!1)}},ae=async _=>{if(window.confirm("确定吊销该密钥?吊销后无法恢复。"))try{const se=await gt(`/api/admin/open-platform/keys/${_}/revoke`,{});if(!se.success){G.error(se.error||"操作失败");return}G.success("已吊销"),O()}catch(se){G.error(se instanceof Error?se.message:"操作失败")}};return s.jsxs("div",{className:"space-y-4",children:[w&&s.jsx("div",{className:"rounded-lg border border-red-500/40 bg-red-950/40 px-4 py-2 text-sm text-red-200",children:w}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索名称、密钥前缀…",value:t,onChange:_=>{e(_.target.value),a(1)},className:"pl-9 bg-[#0f2137] border-gray-600 text-white placeholder:text-gray-500"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(J,{type:"button",variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>O(),disabled:b,children:[s.jsx(He,{className:`w-4 h-4 mr-1 ${b?"animate-spin":""}`}),"刷新"]}),s.jsxs(J,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>M(!0),children:[s.jsx(Mn,{className:"w-4 h-4 mr-1"}),"新建密钥"]})]})]}),s.jsxs("div",{className:"rounded-xl border border-gray-700/50 overflow-hidden bg-[#0f2137]/80",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/50 text-left text-gray-400",children:[s.jsx("th",{className:"px-4 py-3 font-medium",children:"ID"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"名称"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"密钥前缀"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"创建时间"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"状态"}),s.jsx("th",{className:"px-4 py-3 font-medium w-28",children:"操作"})]})}),s.jsx("tbody",{children:b&&m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-4 py-12 text-center text-gray-500",children:"加载中…"})}):m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-4 py-12 text-center text-gray-500",children:"暂无密钥,点击「新建密钥」创建"})}):m.map(_=>s.jsxs("tr",{className:"border-b border-gray-700/30 text-gray-200",children:[s.jsx("td",{className:"px-4 py-3 font-mono text-gray-400",children:_.id}),s.jsx("td",{className:"px-4 py-3",children:_.name}),s.jsxs("td",{className:"px-4 py-3 font-mono text-[#38bdac]",children:[_.keyPrefix,"••••••••"]}),s.jsx("td",{className:"px-4 py-3 text-gray-400 text-xs",children:_.createdAt?new Date(_.createdAt).toLocaleString():"—"}),s.jsx("td",{className:"px-4 py-3",children:_.revokedAt?s.jsx("span",{className:"text-red-400",children:"已吊销"}):s.jsx("span",{className:"text-emerald-400/90",children:"有效"})}),s.jsx("td",{className:"px-4 py-3",children:!_.revokedAt&&s.jsxs("button",{type:"button",onClick:()=>ae(_.id),className:"inline-flex items-center gap-1 text-amber-400 hover:text-amber-300 text-xs",children:[s.jsx(bT,{className:"w-3.5 h-3.5"}),"吊销"]})})]},_.id))})]})}),s.jsx(us,{page:r,totalPages:Math.max(1,h),total:c,pageSize:i,onPageChange:a,onPageSizeChange:_=>{o(_),a(1)}})]}),s.jsx(It,{open:k,onOpenChange:M,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-600 text-white max-w-md",children:[s.jsxs(Rt,{children:[s.jsxs(Lt,{className:"flex items-center gap-2",children:[s.jsx(wu,{className:"w-5 h-5 text-[#38bdac]"}),"新建 API Key"]}),s.jsx(Oo,{className:"text-gray-400",children:"创建后仅本次展示完整密钥,请复制保存至安全位置。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm text-gray-400",children:"名称"}),s.jsx("div",{className:"rounded-lg border border-gray-600 bg-[#0a1628] px-3 py-2",children:s.jsx("input",{className:"w-full bg-transparent text-white text-sm outline-none",placeholder:"例如:合作方 A 生产环境",value:E,onChange:_=>L(_.target.value)})})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>M(!1),children:"取消"}),s.jsx(J,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:X,disabled:R,children:R?"创建中…":"创建"})]})]})}),s.jsx(It,{open:!!P,onOpenChange:_=>!_&&B(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-600 text-white max-w-lg",children:[s.jsxs(Rt,{children:[s.jsx(Lt,{children:"请保存密钥"}),s.jsxs(Oo,{className:"text-amber-200/90",children:["「",P==null?void 0:P.name,"」的密钥仅此一次显示,关闭后无法再次查看全文。"]})]}),s.jsx("pre",{className:"text-xs break-all p-3 rounded-lg bg-black/40 text-emerald-300 font-mono select-all",children:P==null?void 0:P.secret}),s.jsxs(Xt,{className:"gap-2",children:[s.jsx(J,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>{P!=null&&P.secret&&(navigator.clipboard.writeText(P.secret),G.success("已复制到剪贴板"))},children:"复制密钥"}),s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>B(null),children:"已保存"})]})]})})]})}const RV=[{id:"open-user-profile",title:"按手机号更新测评字段(开放平台)",method:"POST",path:"/api/open/user/profile",summary:"使用管理后台创建的 API Key 调用。按手机号定位用户,仅更新请求体中出现的字段(mbti / disc / pdp);未传的字段不改。需至少传 mbti、disc、pdp 之一。",auth:"Header: Authorization: Bearer op_sk_... 或 X-API-Key: op_sk_...",headers:["Authorization: Bearer {op_sk_完整密钥}","Content-Type: application/json"],requestBody:[{name:"phone",type:"string",required:!0,desc:"用户手机号(与 users.phone 一致)"},{name:"mbti",type:"string",required:!1,desc:"有则写入 users.mbti"},{name:"disc",type:"string",required:!1,desc:"有则写入 users.disc"},{name:"pdp",type:"string",required:!1,desc:"有则写入 users.pdp"}],responseFields:[{name:"success",type:"boolean",desc:""},{name:"data.userId",type:"string",desc:"用户 id"},{name:"data.updated",type:"object",desc:"哪些字段本次被更新(布尔标记)"}],callbackNote:"失败时 success: false,error 为原因(如未找到用户、缺少 API Key)。"}],Sj=RV.filter(t=>t.path.startsWith("/api/open"));function Tg({title:t,rows:e}){return e.length?s.jsxs("div",{className:"mt-3",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:t}),s.jsx("div",{className:"rounded-lg border border-gray-700/50 overflow-hidden text-xs",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-black/20 text-gray-400 text-left",children:[s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"字段"}),s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"类型"}),s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"必填"}),s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"说明"})]})}),s.jsx("tbody",{children:e.map(n=>s.jsxs("tr",{className:"border-t border-gray-700/40 text-gray-300",children:[s.jsx("td",{className:"px-2 py-1.5 font-mono text-[#38bdac]/90",children:n.name}),s.jsx("td",{className:"px-2 py-1.5 text-gray-400",children:n.type}),s.jsx("td",{className:"px-2 py-1.5",children:n.required?"是":"否"}),s.jsx("td",{className:"px-2 py-1.5 text-gray-400",children:n.desc})]},n.name))})]})})]}):null}function LV({item:t,open:e,onToggle:n}){const r=t.method==="GET"?"text-emerald-400":t.method==="POST"?"text-amber-400":"text-blue-400";return s.jsxs("div",{className:"rounded-lg border border-gray-700/50 bg-[#0a1628]/60 overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:n,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-gray-800/40 transition-colors",children:[e?s.jsx(Ti,{className:"w-4 h-4 text-gray-500 shrink-0"}):s.jsx(wi,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsx("span",{className:`font-mono text-xs font-semibold shrink-0 ${r}`,children:t.method}),s.jsx("span",{className:"text-sm text-white font-medium truncate flex-1",children:t.title}),s.jsx("code",{className:"text-xs text-gray-500 truncate max-w-[40%] hidden sm:inline",children:t.path})]}),e&&s.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-gray-700/40 space-y-3",children:[s.jsx("p",{className:"text-sm text-gray-400 mt-3",children:t.summary}),s.jsxs("p",{className:"text-xs text-gray-500",children:["鉴权:",s.jsx("span",{className:"text-gray-300",children:t.auth})]}),t.headers&&t.headers.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500 mb-1",children:"Headers"}),s.jsx("pre",{className:"text-xs text-gray-300 font-mono p-2 rounded bg-black/30 whitespace-pre-wrap",children:t.headers.join(` +`)})]}),s.jsx(Tg,{title:"Query 参数",rows:t.queryParams||[]}),s.jsx(Tg,{title:"请求体字段",rows:t.requestBody||[]}),s.jsx(Tg,{title:"响应/回调字段",rows:t.responseFields||[]}),t.callbackNote&&s.jsx("p",{className:"text-xs text-amber-200/80 border border-amber-500/20 rounded p-2 bg-amber-950/20",children:t.callbackNote})]})]})}function OV(){const[t,e]=g.useState(""),n=Ra(t,300),[r,a]=g.useState(1),[i,o]=g.useState(10),[c,u]=g.useState({});g.useEffect(()=>{a(1)},[n]);const h=g.useMemo(()=>{const w=n.trim().toLowerCase();return w?Sj.filter(v=>v.title.toLowerCase().includes(w)||v.path.toLowerCase().includes(w)||v.method.toLowerCase().includes(w)||v.summary.toLowerCase().includes(w)):Sj},[n]),f=h.length,m=Math.max(1,Math.ceil(f/i));g.useEffect(()=>{a(w=>Math.min(w,m))},[m]);const x=(r-1)*i,b=h.slice(x,x+i),N=w=>{u(v=>({...v,[w]:!v[w]}))};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"relative max-w-md",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索接口标题、路径、说明…",value:t,onChange:w=>{e(w.target.value),a(1)},className:"pl-9 bg-[#0f2137] border-gray-600 text-white placeholder:text-gray-500"})]}),s.jsx("div",{className:"space-y-2",children:b.length===0?s.jsx("p",{className:"text-gray-500 text-sm py-8 text-center",children:"无匹配接口,请调整关键词"}):b.map(w=>s.jsx(LV,{item:w,open:!!c[w.id],onToggle:()=>N(w.id)},w.id))}),s.jsx(us,{page:r,totalPages:m,total:f,pageSize:i,onPageChange:a,onPageSizeChange:w=>{o(w),a(1)}})]})}function DV(){const[t,e]=g.useState(""),n=Ra(t,300),[r,a]=g.useState(1),[i,o]=g.useState(10),[c,u]=g.useState(0),[h,f]=g.useState(1),[m,x]=g.useState([]),[b,N]=g.useState(!1),[w,v]=g.useState(null),[k,M]=g.useState({}),E=g.useCallback(async()=>{N(!0),v(null);try{const R=new URLSearchParams;R.set("page",String(r)),R.set("pageSize",String(i)),n.trim()&&R.set("search",n.trim());const W=await Re(`/api/admin/open-platform/logs?${R.toString()}`);if(!W.success){v(W.error||"加载失败"),x([]);return}x(W.records||[]),u(W.total??0),f(W.totalPages??1)}catch(R){v(R instanceof Error?R.message:"网络错误"),x([])}finally{N(!1)}},[r,i,n]);g.useEffect(()=>{E()},[E]);const L=R=>{M(W=>({...W,[R]:!W[R]}))};return s.jsxs("div",{className:"space-y-4",children:[w&&s.jsx("div",{className:"rounded-lg border border-red-500/40 bg-red-950/40 px-4 py-2 text-sm text-red-200",children:w}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索路径、方法、IP、请求/响应片段…",value:t,onChange:R=>{e(R.target.value),a(1)},className:"pl-9 bg-[#0f2137] border-gray-600 text-white placeholder:text-gray-500"})]}),s.jsxs("button",{type:"button",onClick:()=>E(),disabled:b,className:"inline-flex items-center gap-1 px-3 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 text-sm",children:[s.jsx(He,{className:`w-4 h-4 ${b?"animate-spin":""}`}),"刷新"]})]}),s.jsxs("div",{className:"rounded-xl border border-gray-700/50 overflow-hidden bg-[#0f2137]/80",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm min-w-[960px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700/50 text-left text-gray-400",children:[s.jsx("th",{className:"px-2 py-2 w-10"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"时间"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"方法"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"路径"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"状态"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"耗时"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"IP"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"密钥前缀"})]})}),s.jsx("tbody",{children:b&&m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500",children:"加载中…"})}):m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500",children:"暂无请求记录。开放网关写入日志后将在此展示。"})}):m.map(R=>s.jsxs(g.Fragment,{children:[s.jsxs("tr",{className:"border-b border-gray-700/30 align-top text-gray-200",children:[s.jsx("td",{className:"px-2 py-2",children:s.jsx("button",{type:"button",onClick:()=>L(R.id),className:"p-1 rounded hover:bg-gray-700/50 text-gray-400","aria-label":"展开明细",children:k[R.id]?s.jsx(Ti,{className:"w-4 h-4"}):s.jsx(wi,{className:"w-4 h-4"})})}),s.jsx("td",{className:"px-3 py-2 text-xs text-gray-400 whitespace-nowrap",children:R.createdAt?new Date(R.createdAt).toLocaleString():"—"}),s.jsx("td",{className:"px-3 py-2 font-mono text-emerald-400",children:R.method||"—"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-[#38bdac] break-all max-w-[280px]",children:R.path||"—"}),s.jsx("td",{className:"px-3 py-2",children:R.statusCode}),s.jsxs("td",{className:"px-3 py-2",children:[R.durationMs," ms"]}),s.jsx("td",{className:"px-3 py-2 text-xs text-gray-400",children:R.clientIp||"—"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-400",children:R.keyPrefix||"—"})]}),k[R.id]&&s.jsx("tr",{className:"border-b border-gray-700/30 bg-[#0a1628]/80",children:s.jsx("td",{colSpan:8,className:"px-4 py-3",children:s.jsxs("div",{className:"grid gap-3 md:grid-cols-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 mb-1",children:"请求体 / 参数片段"}),s.jsx("pre",{className:"text-green-400/85 font-mono p-2 rounded bg-black/40 overflow-x-auto max-h-48 whitespace-pre-wrap",children:R.requestBody||"—"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 mb-1",children:"响应 / 回调片段"}),s.jsx("pre",{className:"text-amber-200/75 font-mono p-2 rounded bg-black/40 overflow-x-auto max-h-48 whitespace-pre-wrap",children:R.responseBody||"—"})]})]})})})]},R.id))})]})}),s.jsx(us,{page:r,totalPages:Math.max(1,h),total:c,pageSize:i,onPageChange:a,onPageSizeChange:R=>{o(R),a(1)}})]})]})}function _V({embedded:t=!1}){return s.jsxs("div",{className:t?"w-full text-white":"p-8 w-full bg-[#0a1628] text-white min-h-full",children:[s.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 开放平台"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["管理第三方访问密钥;接口文档仅收录 ",s.jsx("code",{className:"text-[#38bdac]",children:"/api/open"})," 前缀的开放能力;小程序等 C 端接口见「管理端内部 API 文档」。请求明细见日志 Tab。"]})]}),s.jsxs(Po,{to:"/settings?tab=api-docs",className:"text-sm text-[#38bdac] hover:underline inline-flex items-center gap-1 shrink-0",children:[s.jsx(Aa,{className:"w-4 h-4"}),"管理端内部 API 文档"]})]}),s.jsxs(Vl,{defaultValue:"keys",className:"w-full",children:[s.jsxs(Do,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1 flex flex-wrap h-auto gap-1",children:[s.jsxs(Bt,{value:"keys",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(wu,{className:"w-4 h-4 mr-1.5 inline"}),"API Key"]}),s.jsxs(Bt,{value:"docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(G0,{className:"w-4 h-4 mr-1.5 inline"}),"接口文档"]}),s.jsxs(Bt,{value:"logs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(rk,{className:"w-4 h-4 mr-1.5 inline"}),"请求明细"]})]}),s.jsx(Vt,{value:"keys",className:"mt-0 outline-none",children:s.jsx(IV,{})}),s.jsx(Vt,{value:"docs",className:"mt-0 outline-none",children:s.jsx(OV,{})}),s.jsx(Vt,{value:"logs",className:"mt-0 outline-none",children:s.jsx(DV,{})})]})]})}const ki="/pages/member-detail/member-detail",Ea="/pages/read/read",Ma={[ki]:"成员详情",[Ea]:"文章详情 / 阅读"},Mg=[{value:"/pages/index/index",label:"首页"},{value:"/pages/chapters/chapters",label:"目录"},{value:"/pages/match/match",label:"找伙伴"},{value:"/pages/my/my",label:"我的"},{value:"/pages/read/read",label:"文章详情 / 阅读"},{value:"/pages/link-preview/link-preview",label:"链接预览"},{value:"/pages/agreement/agreement",label:"用户协议"},{value:"/pages/privacy/privacy",label:"隐私政策"},{value:"/pages/referral/referral",label:"邀请"},{value:"/pages/purchases/purchases",label:"购买记录"},{value:"/pages/reading-records/reading-records",label:"阅读记录"},{value:"/pages/settings/settings",label:"设置"},{value:"/pages/search/search",label:"搜索"},{value:"/pages/addresses/addresses",label:"地址列表"},{value:"/pages/addresses/edit",label:"编辑地址"},{value:"/pages/withdraw-records/withdraw-records",label:"提现记录"},{value:"/pages/wallet/wallet",label:"钱包"},{value:"/pages/vip/vip",label:"会员中心"},{value:"/pages/member-detail/member-detail",label:"成员详情"},{value:"/pages/mentors/mentors",label:"导师列表"},{value:"/pages/mentor-detail/mentor-detail",label:"导师详情"},{value:"/pages/profile-show/profile-show",label:"资料展示"},{value:"/pages/profile-edit/profile-edit",label:"编辑资料"},{value:"/pages/avatar-nickname/avatar-nickname",label:"头像昵称"},{value:"/pages/gift-pay/detail",label:"礼物支付 · 详情"},{value:"/pages/gift-pay/list",label:"礼物支付 · 列表"},{value:"/pages/gift-pay/redemption-detail",label:"礼物支付 · 兑换详情"},{value:"/pages/dev-login/dev-login",label:"开发登录"}],$V=Ea;function Cj(t){const e=String(t.pageName??"").trim();return e||Ma[t.pagePath]||"—"}function zV(t){const e=String(t??"").trim();return e==="singlePage"||e==="single_page"?"singlePage":"fullApp"}function Ej(t){return t==="singlePage"?"单页面":"多页面"}function ko(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`pp-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function cb(t){return/^[a-zA-Z][a-zA-Z0-9_]*$/.test(t.trim())}function FV(t){if(!t||typeof t!="object"||Array.isArray(t))return[];const e=t.pagePopupItems;if(!Array.isArray(e))return[];const n=[];return e.forEach(r=>{if(!r||typeof r!="object"||Array.isArray(r))return;const a=r,i=String(a.key??"").trim();if(!cb(i))return;const o=String(a.pagePath??"").trim();o.startsWith("/")&&n.push({id:typeof a.id=="string"&&a.id.trim()?a.id.trim():ko(),pageName:String(a.pageName??"").trim(),pagePath:o,scope:zV(a.scope),key:i,behavior:String(a.behavior??"").trim()||"—",content:String(a.content??"")})}),n}function BV(t){if(!t||typeof t!="object"||Array.isArray(t))return[];const e=t,n=[],r=e.memberDetailPage;if(r&&typeof r=="object"&&!Array.isArray(r)){const o=r;typeof o.unlockIntroTitle=="string"&&o.unlockIntroTitle.trim()&&n.push({id:ko(),pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroTitle",behavior:"解锁前说明弹窗 · 标题(wx.showModal title)",content:o.unlockIntroTitle}),typeof o.unlockIntroBody=="string"&&o.unlockIntroBody.trim()&&n.push({id:ko(),pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroBody",behavior:"解锁前说明弹窗 · 正文(wx.showModal content)",content:o.unlockIntroBody})}const a=e.readPage;if(a&&typeof a=="object"&&!Array.isArray(a)){const o=a,c=[["beforeLoginHint","未登录时付费墙上方说明","fullApp"],["singlePageTitle","朋友圈单页 · 付费区标题","singlePage"],["singlePagePaywallHint","朋友圈单页 · 付费墙说明","singlePage"]];for(const[u,h,f]of c)typeof o[u]=="string"&&String(o[u]).trim()&&n.push({id:ko(),pageName:Ma[Ea],pagePath:Ea,scope:f,key:u,behavior:h,content:String(o[u])})}const i=e.customPagePopups;return Array.isArray(i)&&i.forEach((o,c)=>{if(!o||typeof o!="object"||Array.isArray(o))return;const u=o,h=String(u.pagePath??"").trim();if(!h.startsWith("/"))return;const f=String(u.pageName??"").trim(),m=(x,b,N,w)=>{if(typeof N!="string"||!N.trim())return;const v=`c${c}_${x}`;cb(v)&&n.push({id:ko(),pageName:f||Ma[h]||"",pagePath:h,scope:w,key:v,behavior:`${b}(旧版 customPagePopups 迁移)`,content:N})};m("fullModalTitle","完整端弹窗标题",u.fullModalTitle,"fullApp"),m("fullModalBody","完整端弹窗正文",u.fullModalBody,"fullApp"),m("singlePageTitle","单页标题",u.singlePageTitle,"singlePage"),m("singlePageBody","单页说明",u.singlePageBody,"singlePage")}),n}const VV=new Set(["memberDetailPage","readPage","customPagePopups","pagePopupItems"]);function HV(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const n=t;for(const r of Object.keys(n))VV.has(r)||(e[r]=n[r]);return e}function UV(t){let e=FV(t);return e.length===0&&(e=BV(t)),{extra:HV(t),pagePopupItems:WV(e)}}function WV(t){const e=new Set,n=[];for(const r of t){const a=`${r.pagePath}\0${r.key}`;e.has(a)||(e.add(a),n.push(r))}return n}function KV(t,e){const n={...e};n.pagePopupItems=t.map(a=>({id:a.id,pageName:String(a.pageName??"").trim(),pagePath:a.pagePath.trim(),scope:a.scope==="singlePage"?"singlePage":"fullApp",key:a.key.trim(),behavior:a.behavior.trim()||"—",content:a.content})),delete n.memberDetailPage,delete n.readPage,delete n.customPagePopups;const r=n.chaptersPage;if(r&&typeof r=="object"&&!Array.isArray(r)){const a=r??{};delete a.sectionNewBadgeText;const i=String(a.newBadgeText??"").trim();i?a.newBadgeText=i:delete a.newBadgeText}return n}function qV(t){const e=String(t.content||"").replace(/\s+/g," ").trim();return e.length>56?`${e.slice(0,56)}…`:e||"—"}const GV=[{pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroTitle",behavior:"解锁前说明弹窗 · 标题(wx.showModal title)",content:"解锁与链接说明"},{pageName:Ma[ki],pagePath:ki,scope:"fullApp",key:"unlockIntroBody",behavior:"解锁前说明弹窗 · 正文(wx.showModal content)",content:`「链接」用于提交留资,由对方通过获客计划跟进;「解锁」用于复制手机/微信号后自行添加好友。 -请确认已了解后再登录。`},{pageName:Ma[Ea],pagePath:Ea,scope:"fullApp",key:"beforeLoginHint",behavior:"未登录时付费墙上方说明",content:"试读进度与下方百分比以后台配置为准;登录后可购买解锁全文。"},{pageName:Ma[Ea],pagePath:Ea,scope:"singlePage",key:"singlePageTitle",behavior:"朋友圈单页 · 付费区标题",content:"解锁全文"},{pageName:Ma[Ea],pagePath:Ea,scope:"singlePage",key:"singlePagePaywallHint",behavior:"朋友圈单页 · 付费墙说明",content:"当前为朋友圈单页预览,无法在此登录或付款。请点击底部「前往小程序」进入完整版后再解锁本章。"}];function HV(){return VV.map(t=>({...t,id:So()}))}const _c=10,Ej=()=>({id:So(),pageName:"",pagePath:IV,scope:"fullApp",key:"",behavior:"",content:""});function UV({pagePopupItems:t,setPagePopupItems:e,extraKeysCount:n}){const[r,a]=g.useState(""),[i,o]=g.useState(!1),[c,u]=g.useState("add"),[h,f]=g.useState(Ej()),[m,x]=g.useState(null),[b,N]=g.useState(1),w=g.useMemo(()=>{const P=h.pagePath.trim();return Tg.some(B=>B.value===P)?P:"__other__"},[h.pagePath]),v=g.useMemo(()=>{const P=r.trim().toLowerCase();return P?t.filter(B=>`${B.pageName} ${B.pagePath} ${Cj(B.scope)} ${B.key} ${B.behavior} ${B.content} ${Sj(B)}`.toLowerCase().includes(P)):t},[r,t]),k=g.useMemo(()=>Math.max(1,Math.ceil(v.length/_c)),[v.length]),M=g.useMemo(()=>{const P=(b-1)*_c;return v.slice(P,P+_c)},[v,b]);g.useEffect(()=>{N(1)},[r]),g.useEffect(()=>{N(P=>Math.min(P,k))},[k]);const E=()=>{f(Ej()),u("add"),o(!0)},L=P=>{f({...P,scope:P.scope==="singlePage"?"singlePage":"fullApp"}),u("edit"),o(!0)},R=()=>{const P=h.pagePath.trim(),B=h.key.trim();if(!P.startsWith("/")){G.error("页面路径须以 / 开头");return}if(!cb(B)){G.error("键名须为英文:字母开头,仅字母、数字、下划线");return}if(!h.behavior.trim()){G.error("请填写行为说明");return}if(t.some(Y=>Y.pagePath===P&&Y.key===B&&Y.id!==h.id)){G.error("同一页面下键名不能重复");return}c==="add"?(e(Y=>[...Y,{...h,id:h.id||So()}]),G.success("已添加,请点击右上角「保存设置」提交")):(e(Y=>Y.map(ae=>ae.id===h.id?{...h}:ae)),G.success("已更新,请点击「保存设置」提交")),o(!1)},W=()=>{m&&(e(P=>P.filter(B=>B.id!==m)),G.success("已删除,请点击「保存设置」提交"),x(null))};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(ik,{className:"w-5 h-5 text-[#38bdac]"}),"弹窗文案(按页面 + 键)"]}),s.jsxs(qt,{className:"text-gray-400",children:["先",s.jsx("strong",{className:"text-gray-300",children:"新增"}),"文案:填写",s.jsx("strong",{className:"text-gray-300",children:"页面名称"}),"、路径、",s.jsx("strong",{className:"text-gray-300",children:"类型"}),"(单页面 / 多页面)、",s.jsx("strong",{className:"text-[#38bdac]",children:"英文键名"}),"、行为说明、文案内容。 小程序通过 ",s.jsx("code",{className:"text-[#38bdac]/90",children:"pagePath + key"})," 从 ",s.jsx("code",{className:"text-[#38bdac]/90",children:"mpConfig.mpUi.pagePopupItems"})," 读取。 同一页面可配置多条(不同 key)。下方表格每页展示 ",_c," 条;全部条目随右上角「保存设置」写入数据库,与分页无关。"]})]}),s.jsxs($e,{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx("p",{className:"text-xs text-gray-500",children:n>0?`另有 ${n} 类其它 mpUi 已保留,保存时一并写回。`:"保存后约 5 分钟内随配置缓存刷新。"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200",title:"用与小程序对齐的 5 条标准文案替换当前列表,再点「保存设置」写入数据库。迁移完成后可移除此按钮。",onClick:()=>{e(HV()),G.info("已填入标准 5 条,请点击「保存设置」写入数据库")},children:[s.jsx(fA,{className:"w-3.5 h-3.5 mr-1.5"}),"填入默认种子"]}),s.jsxs(J,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:E,children:[s.jsx(DT,{className:"w-3.5 h-3.5 mr-1.5"}),"新增文案"]})]})]}),s.jsxs("div",{className:"space-y-2 max-w-xl w-full",children:[s.jsxs(ne,{className:"text-gray-400 text-xs flex items-center gap-1.5",children:[s.jsx(lr,{className:"w-3.5 h-3.5"}),"筛选(页面名称 / 类型 / 路径 / 键 / 行为 / 正文)"]}),s.jsx("div",{className:"rounded-md border border-gray-700 bg-[#0a1628] px-3 h-10 flex items-center",children:s.jsx(le,{className:"border-0 bg-transparent text-white h-9 px-0 shadow-none focus-visible:ring-0 placeholder:text-gray-600",placeholder:"例如:read、beforeLogin、singlePage…",value:r,onChange:P=>a(P.target.value)})})]}),s.jsxs("div",{className:"rounded-lg border border-gray-700/80 overflow-x-auto w-full",children:[s.jsxs(ls,{className:"w-full min-w-[1320px] table-fixed",children:[s.jsx(cs,{children:s.jsxs(ht,{className:"border-gray-700 hover:bg-[#0a1628]/80 bg-[#0a1628]",children:[s.jsx(ke,{className:"text-gray-300 w-[11%] min-w-[108px]",children:"页面名称"}),s.jsx(ke,{className:"text-gray-300 w-[8%] min-w-[88px]",children:"类型"}),s.jsx(ke,{className:"text-gray-300 w-[19%] min-w-[200px]",children:"页面路径"}),s.jsx(ke,{className:"text-gray-300 w-[10%] min-w-[108px]",children:"键名(英文)"}),s.jsx(ke,{className:"text-gray-300 w-[13%] min-w-[108px]",children:"行为"}),s.jsx(ke,{className:"text-gray-300 w-[25%] min-w-[220px]",children:"文案摘要"}),s.jsx(ke,{className:"text-gray-300 text-right w-[14%] min-w-[200px] whitespace-nowrap",children:"操作"})]})}),s.jsx(ds,{children:M.map(P=>s.jsxs(ht,{className:"border-gray-800 hover:bg-[#0f2137]/90",children:[s.jsx(je,{className:"text-sm text-gray-200 align-top font-medium",children:Sj(P)}),s.jsx(je,{className:"align-top",children:s.jsx(Ve,{variant:P.scope==="singlePage"?"outline":"secondary",className:P.scope==="singlePage"?"border-amber-500/50 text-amber-200/95 text-[11px]":"text-[11px]",children:Cj(P.scope)})}),s.jsx(je,{className:"font-mono text-xs text-[#38bdac]/95 align-top break-all",children:P.pagePath}),s.jsx(je,{className:"font-mono text-xs text-amber-200/90 align-top break-all",children:P.key}),s.jsx(je,{className:"text-xs text-gray-300 align-top",children:P.behavior}),s.jsx(je,{className:"text-xs align-top max-w-[220px] min-w-0 py-2",children:s.jsx("div",{className:"line-clamp-1 min-w-0 text-gray-400 break-all cursor-default",title:String(P.content??"").replace(/\s+/g," ").trim()||"—",children:BV(P)})}),s.jsx(je,{className:"align-middle text-right",children:s.jsxs("div",{className:"inline-flex flex-nowrap items-center justify-end gap-1 min-w-[168px]",children:[s.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 px-2.5 text-[#38bdac]",onClick:()=>L(P),children:[s.jsx(Bg,{className:"w-3.5 h-3.5 mr-1"}),"编辑"]}),s.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 px-2.5 text-gray-400 hover:text-red-400",onClick:()=>x(P.id),children:[s.jsx(Jn,{className:"w-3.5 h-3.5 mr-1"}),"删除"]})]})})]},P.id))})]}),v.length===0&&s.jsx("p",{className:"text-center text-sm text-gray-500 py-8",children:"无数据,请点击「新增文案」或「填入默认种子」"}),v.length>0&&k>1&&s.jsx(us,{page:b,totalPages:k,total:v.length,pageSize:_c,onPageChange:N}),v.length>0&&k<=1&&s.jsxs("div",{className:"flex items-center py-3 px-5 border-t border-gray-700/50 text-sm text-gray-400",children:["共 ",v.length," 条,每页 ",_c," 条"]})]})]})]}),s.jsx(Pt,{open:i,onOpenChange:o,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl w-[min(100vw-2rem,42rem)] max-h-[90vh] overflow-y-auto",children:[s.jsxs(It,{children:[s.jsx(Rt,{children:c==="add"?"新增弹窗文案":"编辑弹窗文案"}),s.jsxs(Oo,{className:"text-gray-400",children:["键名在小程序代码中与 ",s.jsx("code",{className:"text-[#38bdac]/90",children:"pagePath"})," 联合使用,请与开发约定后勿随意改键。"]})]}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"页面名称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:文章详情 / 阅读",value:h.pageName,onChange:P=>f(B=>({...B,pageName:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"便于表格识别;可与路径列对照,留空时对常见路径会自动显示默认名称。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"页面路径"}),s.jsxs(yo,{value:w,onValueChange:P=>{f(P==="__other__"?B=>{const O=B.pagePath.trim(),Y=Tg.some(ae=>ae.value===O);return{...B,pagePath:Y?"/pages/":B.pagePath}}:B=>({...B,pagePath:P}))},children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm w-full",children:s.jsx(bo,{placeholder:"选择页面路径"})}),s.jsxs(Ni,{className:"max-h-[min(60vh,320px)]",children:[Tg.map(P=>s.jsxs(Gn,{value:P.value,className:"focus:bg-[#1a3a4a] focus:text-white font-mono text-xs",children:[s.jsx("span",{className:"text-gray-200",children:P.label}),s.jsx("span",{className:"text-gray-500 ml-2",children:P.value})]},P.value)),s.jsx(Gn,{value:"__other__",className:"focus:bg-[#1a3a4a] focus:text-white",children:"自定义路径…"})]})]}),w==="__other__"&&s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"/pages/xxx/xxx",value:h.pagePath,onChange:P=>f(B=>({...B,pagePath:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"从列表选择常用页面;若路径未收录(如分包页),选「自定义路径」后手动填写。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"类型"}),s.jsxs(yo,{value:h.scope,onValueChange:P=>f(B=>({...B,scope:P==="singlePage"?"singlePage":"fullApp"})),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-600 text-white",children:s.jsx(bo,{placeholder:"选择类型"})}),s.jsxs(Ni,{children:[s.jsx(Gn,{value:"fullApp",className:"focus:bg-[#1a3a4a] focus:text-white",children:"多页面(完整小程序)"}),s.jsx(Gn,{value:"singlePage",className:"focus:bg-[#1a3a4a] focus:text-white",children:"单页面(朋友圈预览等)"})]})]}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"单页面:微信单页场景(如 1154);多页面:用户进入完整小程序后的页面。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"键名(英文,自定义)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"beforeLoginHint",value:h.key,disabled:c==="edit",onChange:P=>f(B=>({...B,key:P.target.value.replace(/[^a-zA-Z0-9_]/g,"")}))}),c==="edit"&&s.jsx("p",{className:"text-[11px] text-gray-500",children:"编辑时不可改键名;需改键请删除后新建。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"行为说明"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:未登录时付费墙上方展示",value:h.behavior,onChange:P=>f(B=>({...B,behavior:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"文案内容"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-600 text-white min-h-[140px]",placeholder:"弹窗正文、提示语等",value:h.content,onChange:P=>f(B=>({...B,content:P.target.value}))})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>o(!1),children:"取消"}),s.jsx(J,{className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:R,children:"确定"})]})]})}),s.jsx(Pt,{open:!!m,onOpenChange:P=>!P&&x(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsxs(It,{children:[s.jsx(Rt,{children:"删除该条文案?"}),s.jsx(Oo,{className:"text-gray-400",children:"删除后需保存设置才会同步到小程序;若键名已被代码引用,删除后对应位置将走默认兜底。"})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>x(null),children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700",onClick:W,children:"删除"})]})]})})]})}const WV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},KV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},qV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...KV},ckbLeadApiKey:""},GV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},JV=["system","author","admin","api-docs"],Tj=["basic","mp","mp-copy","oss","features"];function QV(){const[t,e]=q0(),n=t.get("tab")??"system",r=JV.includes(n)?n:"system",a=t.get("section")??"basic",i=Tj.includes(a)?a:"basic",[o,c]=g.useState(qV),[u,h]=g.useState(GV),[f,m]=g.useState(WV),[x,b]=g.useState({}),[N,w]=g.useState([]),[v,k]=g.useState({}),[M,E]=g.useState(!1),[L,R]=g.useState(!0),[W,P]=g.useState(!1),[B,O]=g.useState(""),[Y,ae]=g.useState(""),[_,se]=g.useState(!1),[ce,me]=g.useState(!1),I=(ue,$,Q=!1)=>{O(ue),ae($),se(Q),P(!0)};g.useEffect(()=>{(async()=>{try{const $=await Re("/api/admin/settings");if(!$||$.success===!1)return;if($.featureConfig&&Object.keys($.featureConfig).length&&h(Q=>({...Q,...$.featureConfig})),$.mpConfig&&typeof $.mpConfig=="object"){const Q={...$.mpConfig};m(ie=>({...ie,...Q}));const{extra:z,pagePopupItems:te}=$V(Q.mpUi);b(z),w(te)}if($.ossConfig&&typeof $.ossConfig=="object"&&k(Q=>({...Q,...$.ossConfig})),$.siteSettings&&typeof $.siteSettings=="object"){const Q=$.siteSettings;c(z=>({...z,...typeof Q.sectionPrice=="number"&&{sectionPrice:Q.sectionPrice},...typeof Q.baseBookPrice=="number"&&{baseBookPrice:Q.baseBookPrice},...typeof Q.distributorShare=="number"&&{distributorShare:Q.distributorShare},...Q.authorInfo&&typeof Q.authorInfo=="object"&&{authorInfo:{...z.authorInfo,...Q.authorInfo}},...typeof Q.ckbLeadApiKey=="string"&&{ckbLeadApiKey:Q.ckbLeadApiKey}}))}}catch($){console.error("Load settings error:",$)}finally{R(!1)}})()},[]);const X=async(ue,$)=>{me(!0);try{const Q=await xt("/api/admin/settings",{featureConfig:ue});if(!Q||Q.success===!1){$(),I("保存失败",(Q==null?void 0:Q.error)??"未知错误",!0);return}I("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(Q){console.error("Save feature config error:",Q),$(),I("保存失败",Q instanceof Error?Q.message:String(Q),!0)}finally{me(!1)}},V=(ue,$)=>{const Q=u,z={...Q,[ue]:$};h(z),X(z,()=>h(Q))},[xe,ee]=g.useState(!1),H=async ue=>{const $=f,Q={...$,auditMode:ue};m(Q),ee(!0);try{const z=await xt("/api/admin/settings",{mpConfig:Q});if(!z||z.success===!1){m($),I("保存失败",(z==null?void 0:z.error)??"未知错误",!0);return}I("已保存",ue?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch(z){m($),I("保存失败",z instanceof Error?z.message:String(z),!0)}finally{ee(!1)}},K=async()=>{E(!0);try{const ue=FV(N,x),$=await xt("/api/admin/settings",{featureConfig:u,siteSettings:{sectionPrice:o.sectionPrice,baseBookPrice:o.baseBookPrice,distributorShare:o.distributorShare,authorInfo:o.authorInfo,ckbLeadApiKey:o.ckbLeadApiKey||void 0},mpConfig:{...f,appId:f.appId||"",withdrawSubscribeTmplId:f.withdrawSubscribeTmplId||"",mchId:f.mchId||"",minWithdraw:typeof f.minWithdraw=="number"?f.minWithdraw:10,auditMode:f.auditMode??!1,mpUi:ue},ossConfig:Object.keys(v).length?{endpoint:v.endpoint??"",bucket:v.bucket??"",region:v.region??"",accessKeyId:v.accessKeyId??"",accessKeySecret:v.accessKeySecret??""}:void 0});if(!$||$.success===!1){I("保存失败",($==null?void 0:$.error)??"未知错误",!0);return}I("已保存","设置已保存成功。")}catch(ue){console.error("Save settings error:",ue),I("保存失败",ue instanceof Error?ue.message:String(ue),!0)}finally{E(!1)}},fe=ue=>{if(ue==="system"){const $=new URLSearchParams(t);$.delete("tab"),Tj.includes($.get("section")||"basic")||$.set("section","basic"),e($);return}e({tab:ue})},he=ue=>{const $=new URLSearchParams(t);$.delete("tab"),$.set("section",ue),e($)};return L?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(J,{onClick:K,disabled:M,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),M?"保存中...":"保存设置"]})]}),s.jsxs(Vl,{value:r,onValueChange:fe,className:"w-full",children:[s.jsxs(Do,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Bt,{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(No,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(Bt,{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(zh,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(Bt,{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(Vc,{className:"w-4 h-4 mr-2"}),"管理员"]}),s.jsxs(Bt,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",onClick:ue=>{ue.preventDefault(),window.open("/api-docs","_blank")},children:[s.jsx(G0,{className:"w-4 h-4 mr-2"}),"API 文档 ↗"]})]}),s.jsxs(Vt,{value:"system",className:"mt-0",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["MBTI 默认头像已迁至"," ",s.jsx(Si,{to:"/users",className:"text-[#38bdac] underline",children:"用户管理(用户列表点头像打开)"})]}),s.jsxs(Vl,{value:i,onValueChange:he,className:"w-full",children:[s.jsxs(Do,{className:"mb-4 bg-[#0a1628] border border-gray-700/50 p-1 flex-wrap h-auto gap-1",children:[s.jsxs(Bt,{value:"basic",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(AM,{className:"w-3.5 h-3.5 mr-1"}),"基础与价格"]}),s.jsxs(Bt,{value:"mp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx($l,{className:"w-3.5 h-3.5 mr-1"}),"小程序与审核"]}),s.jsxs(Bt,{value:"mp-copy",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(ik,{className:"w-3.5 h-3.5 mr-1"}),"弹窗文案"]}),s.jsxs(Bt,{value:"oss",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(I1,{className:"w-3.5 h-3.5 mr-1"}),"OSS"]}),s.jsxs(Bt,{value:"features",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(No,{className:"w-3.5 h-3.5 mr-1"}),"功能开关"]})]}),s.jsxs(Vt,{value:"basic",className:"space-y-6 mt-0",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(zh,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx(qt,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs($e,{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(ne,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(zh,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(le,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.name??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,name:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Og,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(le,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:o.authorInfo.startDate??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,startDate:ue.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Og,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(le,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:o.authorInfo.liveTime??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,liveTime:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ak,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(le,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:o.authorInfo.platform??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,platform:ue.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(or,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(le,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.description??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,description:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(Uo,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:o.authorInfo.bio??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,bio:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Aa,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(le,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:o.ckbLeadApiKey??"",onChange:ue=>c($=>({...$,ckbLeadApiKey:ue.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-linear-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(o.authorInfo.name??"K").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-semibold",children:o.authorInfo.name}),s.jsx("p",{className:"text-gray-400 text-xs",children:o.authorInfo.description}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",o.authorInfo.liveTime," · ",o.authorInfo.platform]})]})]})]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(kf,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx($e,{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(ne,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.sectionPrice,onChange:ue=>c($=>({...$,sectionPrice:Number.parseFloat(ue.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.baseBookPrice,onChange:ue=>c($=>({...$,baseBookPrice:Number.parseFloat(ue.target.value)||9.9}))})]})]})})]})]}),s.jsxs(Vt,{value:"mp",className:"space-y-6 mt-0",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx($l,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx(qt,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsxs($e,{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(ne,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:f.appId??"",onChange:ue=>m($=>({...$,appId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:f.withdrawSubscribeTmplId??"",onChange:ue=>m($=>({...$,withdrawSubscribeTmplId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:f.mchId??"",onChange:ue=>m($=>({...$,mchId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.minWithdraw??10,onChange:ue=>m($=>({...$,minWithdraw:Number.parseFloat(ue.target.value)||10}))})]})]}),s.jsx("p",{className:"text-xs text-gray-500 pt-2 border-t border-gray-700/50",children:"弹窗类文案在「弹窗文案」子 Tab 按页面路径 + 英文键维护(pagePopupItems);目录、Tab、首页板块等仍由其它配置决定。"})]})]}),s.jsxs(_e,{className:`bg-[#0f2137] shadow-xl ${f.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vc,{className:"w-5 h-5 text-amber-400"}),"小程序审核模式"]}),s.jsx(qt,{className:"text-gray-400",children:"提交微信审核前开启,审核通过后关闭即可恢复支付功能"})]}),s.jsx($e,{children:s.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg border ${f.auditMode?"bg-amber-500/10 border-amber-500/30":"bg-[#0a1628] 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(Vc,{className:`w-4 h-4 ${f.auditMode?"text-amber-400":"text-gray-400"}`}),s.jsx(ne,{htmlFor:"audit-mode",className:"text-white font-medium cursor-pointer",children:f.auditMode?"审核模式(已开启)":"审核模式(已关闭)"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:f.auditMode?"当前已隐藏所有支付、VIP、充值、收益等入口,审核员看不到任何付费内容":"关闭状态,小程序正常显示所有功能(含支付、VIP 等)"})]}),s.jsx(Ht,{id:"audit-mode",checked:f.auditMode??!1,disabled:xe,onCheckedChange:H})]})})]})]}),s.jsx(Vt,{value:"mp-copy",className:"space-y-6 mt-0",children:s.jsx(UV,{pagePopupItems:N,setPagePopupItems:w,extraKeysCount:Object.keys(x).length})}),s.jsx(Vt,{value:"oss",className:"space-y-6 mt-0",children:s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(I1,{className:"w-5 h-5 text-[#38bdac]"}),"OSS 配置(阿里云对象存储)"]}),s.jsx(qt,{className:"text-gray-400",children:"endpoint、bucket、accessKey 等,用于图片/文件上传"})]}),s.jsx($e,{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(ne,{className:"text-gray-300",children:"Endpoint"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:v.endpoint??"",onChange:ue=>k($=>({...$,endpoint:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"Bucket"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:v.bucket??"",onChange:ue=>k($=>({...$,bucket:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"Region"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:v.region??"",onChange:ue=>k($=>({...$,region:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"AccessKey ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:v.accessKeyId??"",onChange:ue=>k($=>({...$,accessKeyId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"AccessKey Secret"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:v.accessKeySecret??"",onChange:ue=>k($=>({...$,accessKeySecret:ue.target.value}))})]})]})})]})}),s.jsxs(Vt,{value:"features",className:"space-y-6 mt-0",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(No,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx(qt,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs($e,{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(Vn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{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(Ht,{id:"match-enabled",checked:u.matchEnabled,disabled:ce,onCheckedChange:ue=>V("matchEnabled",ue)})]}),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($g,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"}),s.jsxs("p",{className:"text-xs text-amber-400/80 ml-6 mt-1",children:["佣金比例、绑定期、提现规则等与",s.jsx(Si,{to:"/distribution?tab=settings",className:"underline mx-1 text-[#38bdac]",children:"推广中心 → 推广设置"}),"为同一套接口,在此仅控制是否展示入口。"]})]}),s.jsx(Ht,{id:"referral-enabled",checked:u.referralEnabled,disabled:ce,onCheckedChange:ue=>V("referralEnabled",ue)})]}),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(or,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{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(Ht,{id:"search-enabled",checked:u.searchEnabled,disabled:ce,onCheckedChange:ue=>V("searchEnabled",ue)})]}),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(No,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{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(Ht,{id:"about-enabled",checked:u.aboutEnabled,disabled:ce,onCheckedChange:ue=>V("aboutEnabled",ue)})]})]}),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.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Sf,{className:"w-5 h-5 text-[#38bdac]"}),"小程序模块显隐说明"]}),s.jsx(qt,{className:"text-gray-400",children:"以下模块受上方开关和审核模式共同控制"})]}),s.jsx($e,{children:s.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[{mod:"找伙伴",ctrl:"找伙伴功能开关",icon:s.jsx(Vn,{className:"w-3 h-3"})},{mod:"推广中心 / 推荐好友",ctrl:"推广功能开关",icon:s.jsx($g,{className:"w-3 h-3"})},{mod:"搜索",ctrl:"搜索功能开关",icon:s.jsx(or,{className:"w-3 h-3"})},{mod:"关于页面",ctrl:"关于页面开关",icon:s.jsx(zh,{className:"w-3 h-3"})},{mod:"支付 / VIP / 充值 / 收益",ctrl:"审核模式",icon:s.jsx(Vc,{className:"w-3 h-3"})},{mod:"超级个体名片",ctrl:"审核模式",icon:s.jsx(TA,{className:"w-3 h-3"})},{mod:"首页获客入口",ctrl:"已移除",icon:s.jsx(eM,{className:"w-3 h-3"})}].map(ue=>s.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#0a1628] border border-gray-700/30",children:[ue.icon,s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:ue.mod}),s.jsxs("span",{className:"text-gray-500 ml-1",children:["← ",ue.ctrl]})]})]},ue.mod))})})]})]})]})]}),s.jsx(Vt,{value:"author",className:"mt-0",children:s.jsx(MV,{})}),s.jsx(Vt,{value:"admin",className:"mt-0",children:s.jsx(PV,{})}),s.jsx(Vt,{value:"api-docs",className:"mt-0",children:s.jsx(q4,{})})]}),s.jsx(Pt,{open:W,onOpenChange:P,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(It,{children:[s.jsx(Rt,{className:_?"text-red-400":"text-[#38bdac]",children:B}),s.jsx(Oo,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:Y})]}),s.jsx(Xt,{className:"mt-4",children:s.jsx(J,{onClick:()=>P(!1),className:_?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const Mj={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 YV(){const[t,e]=g.useState(!1),[n,r]=g.useState(Mj),[a,i]=g.useState(""),o=async()=>{e(!0);try{const k=await Re("/api/config");k!=null&&k.paymentMethods&&r({...Mj,...k.paymentMethods})}catch(k){console.error(k)}finally{e(!1)}};g.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await xt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),G.success("配置已保存!")}catch(k){console.error("保存失败:",k),G.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,M)=>{navigator.clipboard.writeText(k),i(M),setTimeout(()=>i(""),2e3)},h=(k,M)=>{r(E=>({...E,wechat:{...E.wechat,[k]:M}}))},f=(k,M)=>{r(E=>({...E,alipay:{...E.alipay,[k]:M}}))},m=(k,M)=>{r(E=>({...E,usdt:{...E.usdt,[k]:M}}))},x=(k,M)=>{r(E=>({...E,paypal:{...E.paypal,[k]:M}}))},b=n.wechat,N=n.alipay,w=n.usdt,v=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(J,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(J,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{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(Zj,{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(Vl,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Do,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(Bt,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx($l,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(Bt,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(R1,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(Bt,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(P1,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(Bt,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(zg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(Vt,{value:"wechat",className:"space-y-4",children:s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx($l,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(Ht,{checked:!!b.enabled,onCheckedChange:k=>h("enabled",k)})]}),s.jsxs($e,{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(ne,{className:"text-gray-300",children:"网站AppID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"商户号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.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(Io,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(b.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(ne,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(le,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(b.groupQrCode??""),onChange:k=>h("groupQrCode",k.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(Vt,{value:"alipay",className:"space-y-4",children:s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(R1,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(qt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(Ht,{checked:!!N.enabled,onCheckedChange:k=>f("enabled",k)})]}),s.jsxs($e,{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(ne,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),s.jsx(J,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?s.jsx(Tp,{className:"w-4 h-4 text-green-500"}):s.jsx(tk,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.securityKey??""),onChange:k=>f("securityKey",k.target.value)})]})]}),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(Io,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(N.qrCode??""),onChange:k=>f("qrCode",k.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(Vt,{value:"usdt",className:"space-y-4",children:s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(P1,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(Ht,{checked:!!w.enabled,onCheckedChange:k=>m("enabled",k)})]}),s.jsxs($e,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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(ne,{className:"text-gray-300",children:"收款地址"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(le,{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(Vt,{value:"paypal",className:"space-y-4",children:s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(zg,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(Ht,{checked:!!v.enabled,onCheckedChange:k=>x("enabled",k)})]}),s.jsxs($e,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(v.email??""),onChange:k=>x("email",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(v.exchangeRate)??7.2,onChange:k=>x("exchangeRate",Number(k.target.value)||7.2)})]})]})]})})]})]})}const XV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},ZV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},eH={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function tH(){const[t,e]=g.useState({siteConfig:{...XV},menuConfig:{...ZV},pageConfig:{...eH}}),[n,r]=g.useState(!1),[a,i]=g.useState(!1);g.useEffect(()=>{Re("/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 xt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await xt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await xt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),G.success("配置已保存")}catch(f){console.error(f),G.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(J,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(zg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx(qt,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs($e,{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(ne,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(le,{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(ne,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(le,{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(ne,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(le,{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(ne,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(le,{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(ne,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(le,{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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(QM,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx(qt,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx($e,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(ne,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(le,{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(le,{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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(VM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx(qt,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx($e,{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(Ht,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:x=>e(b=>({...b,menuConfig:{...b.menuConfig,[f]:{...m,enabled:x}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:x=>e(b=>({...b,menuConfig:{...b.menuConfig,[f]:{...m,label:x.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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(G0,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs($e,{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(ne,{className:"text-gray-300",children:"首页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"首页副标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"目录页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"我的页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function nH(){const[t,e]=g.useState(""),[n,r]=g.useState(""),[a,i]=g.useState(""),[o,c]=g.useState({}),u=async()=>{var b,N,w,v;try{const k=await Re("/api/config"),M=(N=(b=k==null?void 0:k.liveQRCodes)==null?void 0:b[0])==null?void 0:N.urls;Array.isArray(M)&&e(M.join(` +请确认已了解后再登录。`},{pageName:Ma[Ea],pagePath:Ea,scope:"fullApp",key:"beforeLoginHint",behavior:"未登录时付费墙上方说明",content:"试读进度与下方百分比以后台配置为准;登录后可购买解锁全文。"},{pageName:Ma[Ea],pagePath:Ea,scope:"singlePage",key:"singlePageTitle",behavior:"朋友圈单页 · 付费区标题",content:"解锁全文"},{pageName:Ma[Ea],pagePath:Ea,scope:"singlePage",key:"singlePagePaywallHint",behavior:"朋友圈单页 · 付费墙说明",content:"当前为朋友圈单页预览,无法在此登录或付款。请点击底部「前往小程序」进入完整版后再解锁本章。"}];function JV(){return GV.map(t=>({...t,id:ko()}))}const _c=10,Tj=()=>({id:ko(),pageName:"",pagePath:$V,scope:"fullApp",key:"",behavior:"",content:""});function QV({pagePopupItems:t,setPagePopupItems:e,extraKeysCount:n}){const[r,a]=g.useState(""),[i,o]=g.useState(!1),[c,u]=g.useState("add"),[h,f]=g.useState(Tj()),[m,x]=g.useState(null),[b,N]=g.useState(1),w=g.useMemo(()=>{const P=h.pagePath.trim();return Mg.some(B=>B.value===P)?P:"__other__"},[h.pagePath]),v=g.useMemo(()=>{const P=r.trim().toLowerCase();return P?t.filter(B=>`${B.pageName} ${B.pagePath} ${Ej(B.scope)} ${B.key} ${B.behavior} ${B.content} ${Cj(B)}`.toLowerCase().includes(P)):t},[r,t]),k=g.useMemo(()=>Math.max(1,Math.ceil(v.length/_c)),[v.length]),M=g.useMemo(()=>{const P=(b-1)*_c;return v.slice(P,P+_c)},[v,b]);g.useEffect(()=>{N(1)},[r]),g.useEffect(()=>{N(P=>Math.min(P,k))},[k]);const E=()=>{f(Tj()),u("add"),o(!0)},L=P=>{f({...P,scope:P.scope==="singlePage"?"singlePage":"fullApp"}),u("edit"),o(!0)},R=()=>{const P=h.pagePath.trim(),B=h.key.trim();if(!P.startsWith("/")){G.error("页面路径须以 / 开头");return}if(!cb(B)){G.error("键名须为英文:字母开头,仅字母、数字、下划线");return}if(!h.behavior.trim()){G.error("请填写行为说明");return}if(t.some(X=>X.pagePath===P&&X.key===B&&X.id!==h.id)){G.error("同一页面下键名不能重复");return}c==="add"?(e(X=>[...X,{...h,id:h.id||ko()}]),G.success("已添加,请点击右上角「保存设置」提交")):(e(X=>X.map(ae=>ae.id===h.id?{...h}:ae)),G.success("已更新,请点击「保存设置」提交")),o(!1)},W=()=>{m&&(e(P=>P.filter(B=>B.id!==m)),G.success("已删除,请点击「保存设置」提交"),x(null))};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(ik,{className:"w-5 h-5 text-[#38bdac]"}),"弹窗文案(按页面 + 键)"]}),s.jsxs(qt,{className:"text-gray-400",children:["先",s.jsx("strong",{className:"text-gray-300",children:"新增"}),"文案:填写",s.jsx("strong",{className:"text-gray-300",children:"页面名称"}),"、路径、",s.jsx("strong",{className:"text-gray-300",children:"类型"}),"(单页面 / 多页面)、",s.jsx("strong",{className:"text-[#38bdac]",children:"英文键名"}),"、行为说明、文案内容。 小程序通过 ",s.jsx("code",{className:"text-[#38bdac]/90",children:"pagePath + key"})," 从 ",s.jsx("code",{className:"text-[#38bdac]/90",children:"mpConfig.mpUi.pagePopupItems"})," 读取。 同一页面可配置多条(不同 key)。下方表格每页展示 ",_c," 条;全部条目随右上角「保存设置」写入数据库,与分页无关。"]})]}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx("p",{className:"text-xs text-gray-500",children:n>0?`另有 ${n} 类其它 mpUi 已保留,保存时一并写回。`:"保存后约 5 分钟内随配置缓存刷新。"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200",title:"用与小程序对齐的 5 条标准文案替换当前列表,再点「保存设置」写入数据库。迁移完成后可移除此按钮。",onClick:()=>{e(JV()),G.info("已填入标准 5 条,请点击「保存设置」写入数据库")},children:[s.jsx(fA,{className:"w-3.5 h-3.5 mr-1.5"}),"填入默认种子"]}),s.jsxs(J,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:E,children:[s.jsx(DT,{className:"w-3.5 h-3.5 mr-1.5"}),"新增文案"]})]})]}),s.jsxs("div",{className:"space-y-2 max-w-xl w-full",children:[s.jsxs(ne,{className:"text-gray-400 text-xs flex items-center gap-1.5",children:[s.jsx(lr,{className:"w-3.5 h-3.5"}),"筛选(页面名称 / 类型 / 路径 / 键 / 行为 / 正文)"]}),s.jsx("div",{className:"rounded-md border border-gray-700 bg-[#0a1628] px-3 h-10 flex items-center",children:s.jsx(le,{className:"border-0 bg-transparent text-white h-9 px-0 shadow-none focus-visible:ring-0 placeholder:text-gray-600",placeholder:"例如:read、beforeLogin、singlePage…",value:r,onChange:P=>a(P.target.value)})})]}),s.jsxs("div",{className:"rounded-lg border border-gray-700/80 overflow-x-auto w-full",children:[s.jsxs(ls,{className:"w-full min-w-[1320px] table-fixed",children:[s.jsx(cs,{children:s.jsxs(ht,{className:"border-gray-700 hover:bg-[#0a1628]/80 bg-[#0a1628]",children:[s.jsx(ke,{className:"text-gray-300 w-[11%] min-w-[108px]",children:"页面名称"}),s.jsx(ke,{className:"text-gray-300 w-[8%] min-w-[88px]",children:"类型"}),s.jsx(ke,{className:"text-gray-300 w-[19%] min-w-[200px]",children:"页面路径"}),s.jsx(ke,{className:"text-gray-300 w-[10%] min-w-[108px]",children:"键名(英文)"}),s.jsx(ke,{className:"text-gray-300 w-[13%] min-w-[108px]",children:"行为"}),s.jsx(ke,{className:"text-gray-300 w-[25%] min-w-[220px]",children:"文案摘要"}),s.jsx(ke,{className:"text-gray-300 text-right w-[14%] min-w-[200px] whitespace-nowrap",children:"操作"})]})}),s.jsx(ds,{children:M.map(P=>s.jsxs(ht,{className:"border-gray-800 hover:bg-[#0f2137]/90",children:[s.jsx(je,{className:"text-sm text-gray-200 align-top font-medium",children:Cj(P)}),s.jsx(je,{className:"align-top",children:s.jsx(Ve,{variant:P.scope==="singlePage"?"outline":"secondary",className:P.scope==="singlePage"?"border-amber-500/50 text-amber-200/95 text-[11px]":"text-[11px]",children:Ej(P.scope)})}),s.jsx(je,{className:"font-mono text-xs text-[#38bdac]/95 align-top break-all",children:P.pagePath}),s.jsx(je,{className:"font-mono text-xs text-amber-200/90 align-top break-all",children:P.key}),s.jsx(je,{className:"text-xs text-gray-300 align-top",children:P.behavior}),s.jsx(je,{className:"text-xs align-top max-w-[220px] min-w-0 py-2",children:s.jsx("div",{className:"line-clamp-1 min-w-0 text-gray-400 break-all cursor-default",title:String(P.content??"").replace(/\s+/g," ").trim()||"—",children:qV(P)})}),s.jsx(je,{className:"align-middle text-right",children:s.jsxs("div",{className:"inline-flex flex-nowrap items-center justify-end gap-1 min-w-[168px]",children:[s.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 px-2.5 text-[#38bdac]",onClick:()=>L(P),children:[s.jsx(Bg,{className:"w-3.5 h-3.5 mr-1"}),"编辑"]}),s.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 px-2.5 text-gray-400 hover:text-red-400",onClick:()=>x(P.id),children:[s.jsx(Jn,{className:"w-3.5 h-3.5 mr-1"}),"删除"]})]})})]},P.id))})]}),v.length===0&&s.jsx("p",{className:"text-center text-sm text-gray-500 py-8",children:"无数据,请点击「新增文案」或「填入默认种子」"}),v.length>0&&k>1&&s.jsx(us,{page:b,totalPages:k,total:v.length,pageSize:_c,onPageChange:N}),v.length>0&&k<=1&&s.jsxs("div",{className:"flex items-center py-3 px-5 border-t border-gray-700/50 text-sm text-gray-400",children:["共 ",v.length," 条,每页 ",_c," 条"]})]})]})]}),s.jsx(It,{open:i,onOpenChange:o,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl w-[min(100vw-2rem,42rem)] max-h-[90vh] overflow-y-auto",children:[s.jsxs(Rt,{children:[s.jsx(Lt,{children:c==="add"?"新增弹窗文案":"编辑弹窗文案"}),s.jsxs(Oo,{className:"text-gray-400",children:["键名在小程序代码中与 ",s.jsx("code",{className:"text-[#38bdac]/90",children:"pagePath"})," 联合使用,请与开发约定后勿随意改键。"]})]}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"页面名称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:文章详情 / 阅读",value:h.pageName,onChange:P=>f(B=>({...B,pageName:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"便于表格识别;可与路径列对照,留空时对常见路径会自动显示默认名称。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"页面路径"}),s.jsxs(go,{value:w,onValueChange:P=>{f(P==="__other__"?B=>{const O=B.pagePath.trim(),X=Mg.some(ae=>ae.value===O);return{...B,pagePath:X?"/pages/":B.pagePath}}:B=>({...B,pagePath:P}))},children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm w-full",children:s.jsx(yo,{placeholder:"选择页面路径"})}),s.jsxs(Ni,{className:"max-h-[min(60vh,320px)]",children:[Mg.map(P=>s.jsxs(Gn,{value:P.value,className:"focus:bg-[#1a3a4a] focus:text-white font-mono text-xs",children:[s.jsx("span",{className:"text-gray-200",children:P.label}),s.jsx("span",{className:"text-gray-500 ml-2",children:P.value})]},P.value)),s.jsx(Gn,{value:"__other__",className:"focus:bg-[#1a3a4a] focus:text-white",children:"自定义路径…"})]})]}),w==="__other__"&&s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"/pages/xxx/xxx",value:h.pagePath,onChange:P=>f(B=>({...B,pagePath:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"从列表选择常用页面;若路径未收录(如分包页),选「自定义路径」后手动填写。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"类型"}),s.jsxs(go,{value:h.scope,onValueChange:P=>f(B=>({...B,scope:P==="singlePage"?"singlePage":"fullApp"})),children:[s.jsx(vi,{className:"bg-[#0a1628] border-gray-600 text-white",children:s.jsx(yo,{placeholder:"选择类型"})}),s.jsxs(Ni,{children:[s.jsx(Gn,{value:"fullApp",className:"focus:bg-[#1a3a4a] focus:text-white",children:"多页面(完整小程序)"}),s.jsx(Gn,{value:"singlePage",className:"focus:bg-[#1a3a4a] focus:text-white",children:"单页面(朋友圈预览等)"})]})]}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"单页面:微信单页场景(如 1154);多页面:用户进入完整小程序后的页面。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"键名(英文,自定义)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"beforeLoginHint",value:h.key,disabled:c==="edit",onChange:P=>f(B=>({...B,key:P.target.value.replace(/[^a-zA-Z0-9_]/g,"")}))}),c==="edit"&&s.jsx("p",{className:"text-[11px] text-gray-500",children:"编辑时不可改键名;需改键请删除后新建。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"行为说明"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:未登录时付费墙上方展示",value:h.behavior,onChange:P=>f(B=>({...B,behavior:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"文案内容"}),s.jsx(Uo,{className:"bg-[#0a1628] border-gray-600 text-white min-h-[140px]",placeholder:"弹窗正文、提示语等",value:h.content,onChange:P=>f(B=>({...B,content:P.target.value}))})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>o(!1),children:"取消"}),s.jsx(J,{className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:R,children:"确定"})]})]})}),s.jsx(It,{open:!!m,onOpenChange:P=>!P&&x(null),children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Lt,{children:"删除该条文案?"}),s.jsx(Oo,{className:"text-gray-400",children:"删除后需保存设置才会同步到小程序;若键名已被代码引用,删除后对应位置将走默认兜底。"})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>x(null),children:"取消"}),s.jsx(J,{className:"bg-red-600 hover:bg-red-700",onClick:W,children:"删除"})]})]})})]})}const YV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},XV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},ZV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...XV},ckbLeadApiKey:""},eH={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},tH=["system","author","admin","open-platform","api-docs"],Mj=["basic","mp","mp-copy","oss","features"];function nH(){const[t,e]=q0(),n=t.get("tab")??"system",r=tH.includes(n)?n:"system",a=t.get("section")??"basic",i=Mj.includes(a)?a:"basic",[o,c]=g.useState(ZV),[u,h]=g.useState(eH),[f,m]=g.useState(YV),[x,b]=g.useState({}),[N,w]=g.useState([]),[v,k]=g.useState({}),[M,E]=g.useState(!1),[L,R]=g.useState(!0),[W,P]=g.useState(!1),[B,O]=g.useState(""),[X,ae]=g.useState(""),[_,se]=g.useState(!1),[ce,me]=g.useState(!1),I=(ue,$,Q=!1)=>{O(ue),ae($),se(Q),P(!0)};g.useEffect(()=>{(async()=>{try{const $=await Re("/api/admin/settings");if(!$||$.success===!1)return;if($.featureConfig&&Object.keys($.featureConfig).length&&h(Q=>({...Q,...$.featureConfig})),$.mpConfig&&typeof $.mpConfig=="object"){const Q={...$.mpConfig};m(ie=>({...ie,...Q}));const{extra:z,pagePopupItems:te}=UV(Q.mpUi);b(z),w(te)}if($.ossConfig&&typeof $.ossConfig=="object"&&k(Q=>({...Q,...$.ossConfig})),$.siteSettings&&typeof $.siteSettings=="object"){const Q=$.siteSettings;c(z=>({...z,...typeof Q.sectionPrice=="number"&&{sectionPrice:Q.sectionPrice},...typeof Q.baseBookPrice=="number"&&{baseBookPrice:Q.baseBookPrice},...typeof Q.distributorShare=="number"&&{distributorShare:Q.distributorShare},...Q.authorInfo&&typeof Q.authorInfo=="object"&&{authorInfo:{...z.authorInfo,...Q.authorInfo}},...typeof Q.ckbLeadApiKey=="string"&&{ckbLeadApiKey:Q.ckbLeadApiKey}}))}}catch($){console.error("Load settings error:",$)}finally{R(!1)}})()},[]);const Z=async(ue,$)=>{me(!0);try{const Q=await gt("/api/admin/settings",{featureConfig:ue});if(!Q||Q.success===!1){$(),I("保存失败",(Q==null?void 0:Q.error)??"未知错误",!0);return}I("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(Q){console.error("Save feature config error:",Q),$(),I("保存失败",Q instanceof Error?Q.message:String(Q),!0)}finally{me(!1)}},V=(ue,$)=>{const Q=u,z={...Q,[ue]:$};h(z),Z(z,()=>h(Q))},[xe,ee]=g.useState(!1),H=async ue=>{const $=f,Q={...$,auditMode:ue};m(Q),ee(!0);try{const z=await gt("/api/admin/settings",{mpConfig:Q});if(!z||z.success===!1){m($),I("保存失败",(z==null?void 0:z.error)??"未知错误",!0);return}I("已保存",ue?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch(z){m($),I("保存失败",z instanceof Error?z.message:String(z),!0)}finally{ee(!1)}},K=async()=>{E(!0);try{const ue=KV(N,x),$=await gt("/api/admin/settings",{featureConfig:u,siteSettings:{sectionPrice:o.sectionPrice,baseBookPrice:o.baseBookPrice,distributorShare:o.distributorShare,authorInfo:o.authorInfo,ckbLeadApiKey:o.ckbLeadApiKey||void 0},mpConfig:{...f,appId:f.appId||"",withdrawSubscribeTmplId:f.withdrawSubscribeTmplId||"",mchId:f.mchId||"",minWithdraw:typeof f.minWithdraw=="number"?f.minWithdraw:10,auditMode:f.auditMode??!1,mpUi:ue},ossConfig:Object.keys(v).length?{endpoint:v.endpoint??"",bucket:v.bucket??"",region:v.region??"",accessKeyId:v.accessKeyId??"",accessKeySecret:v.accessKeySecret??""}:void 0});if(!$||$.success===!1){I("保存失败",($==null?void 0:$.error)??"未知错误",!0);return}I("已保存","设置已保存成功。")}catch(ue){console.error("Save settings error:",ue),I("保存失败",ue instanceof Error?ue.message:String(ue),!0)}finally{E(!1)}},fe=ue=>{if(ue==="system"){const $=new URLSearchParams(t);$.delete("tab"),Mj.includes($.get("section")||"basic")||$.set("section","basic"),e($);return}e({tab:ue})},he=ue=>{const $=new URLSearchParams(t);$.delete("tab"),$.set("section",ue),e($)};return L?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(J,{onClick:K,disabled:M,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),M?"保存中...":"保存设置"]})]}),s.jsxs(Vl,{value:r,onValueChange:fe,className:"w-full",children:[s.jsxs(Do,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Bt,{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(vo,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(Bt,{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(zh,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(Bt,{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(Vc,{className:"w-4 h-4 mr-2"}),"管理员"]}),s.jsxs(Bt,{value:"open-platform",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(YT,{className:"w-4 h-4 mr-2"}),"API 开放平台"]}),s.jsxs(Bt,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",onClick:ue=>{ue.preventDefault(),window.open("/api-docs","_blank")},children:[s.jsx(G0,{className:"w-4 h-4 mr-2"}),"API 文档 ↗"]})]}),s.jsxs(Vt,{value:"system",className:"mt-0",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["MBTI 默认头像已迁至"," ",s.jsx(Po,{to:"/users",className:"text-[#38bdac] underline",children:"用户管理(用户列表点头像打开)"})]}),s.jsxs(Vl,{value:i,onValueChange:he,className:"w-full",children:[s.jsxs(Do,{className:"mb-4 bg-[#0a1628] border border-gray-700/50 p-1 flex-wrap h-auto gap-1",children:[s.jsxs(Bt,{value:"basic",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(AM,{className:"w-3.5 h-3.5 mr-1"}),"基础与价格"]}),s.jsxs(Bt,{value:"mp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx($l,{className:"w-3.5 h-3.5 mr-1"}),"小程序与审核"]}),s.jsxs(Bt,{value:"mp-copy",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(ik,{className:"w-3.5 h-3.5 mr-1"}),"弹窗文案"]}),s.jsxs(Bt,{value:"oss",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(I1,{className:"w-3.5 h-3.5 mr-1"}),"OSS"]}),s.jsxs(Bt,{value:"features",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(vo,{className:"w-3.5 h-3.5 mr-1"}),"功能开关"]})]}),s.jsxs(Vt,{value:"basic",className:"space-y-6 mt-0",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(zh,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx(qt,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs(ze,{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(ne,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(zh,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(le,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.name??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,name:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Og,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(le,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:o.authorInfo.startDate??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,startDate:ue.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Og,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(le,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:o.authorInfo.liveTime??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,liveTime:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ak,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(le,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:o.authorInfo.platform??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,platform:ue.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(or,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(le,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.description??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,description:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(Uo,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:o.authorInfo.bio??"",onChange:ue=>c($=>({...$,authorInfo:{...$.authorInfo,bio:ue.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Aa,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(le,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:o.ckbLeadApiKey??"",onChange:ue=>c($=>({...$,ckbLeadApiKey:ue.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-linear-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(o.authorInfo.name??"K").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-semibold",children:o.authorInfo.name}),s.jsx("p",{className:"text-gray-400 text-xs",children:o.authorInfo.description}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",o.authorInfo.liveTime," · ",o.authorInfo.platform]})]})]})]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(kf,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx(ze,{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(ne,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.sectionPrice,onChange:ue=>c($=>({...$,sectionPrice:Number.parseFloat(ue.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.baseBookPrice,onChange:ue=>c($=>({...$,baseBookPrice:Number.parseFloat(ue.target.value)||9.9}))})]})]})})]})]}),s.jsxs(Vt,{value:"mp",className:"space-y-6 mt-0",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx($l,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx(qt,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsxs(ze,{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(ne,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:f.appId??"",onChange:ue=>m($=>({...$,appId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:f.withdrawSubscribeTmplId??"",onChange:ue=>m($=>({...$,withdrawSubscribeTmplId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:f.mchId??"",onChange:ue=>m($=>({...$,mchId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.minWithdraw??10,onChange:ue=>m($=>({...$,minWithdraw:Number.parseFloat(ue.target.value)||10}))})]})]}),s.jsx("p",{className:"text-xs text-gray-500 pt-2 border-t border-gray-700/50",children:"弹窗类文案在「弹窗文案」子 Tab 按页面路径 + 英文键维护(pagePopupItems);目录、Tab、首页板块等仍由其它配置决定。"})]})]}),s.jsxs($e,{className:`bg-[#0f2137] shadow-xl ${f.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vc,{className:"w-5 h-5 text-amber-400"}),"小程序审核模式"]}),s.jsx(qt,{className:"text-gray-400",children:"提交微信审核前开启,审核通过后关闭即可恢复支付功能"})]}),s.jsx(ze,{children:s.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg border ${f.auditMode?"bg-amber-500/10 border-amber-500/30":"bg-[#0a1628] 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(Vc,{className:`w-4 h-4 ${f.auditMode?"text-amber-400":"text-gray-400"}`}),s.jsx(ne,{htmlFor:"audit-mode",className:"text-white font-medium cursor-pointer",children:f.auditMode?"审核模式(已开启)":"审核模式(已关闭)"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:f.auditMode?"当前已隐藏所有支付、VIP、充值、收益等入口,审核员看不到任何付费内容":"关闭状态,小程序正常显示所有功能(含支付、VIP 等)"})]}),s.jsx(Ut,{id:"audit-mode",checked:f.auditMode??!1,disabled:xe,onCheckedChange:H})]})})]})]}),s.jsx(Vt,{value:"mp-copy",className:"space-y-6 mt-0",children:s.jsx(QV,{pagePopupItems:N,setPagePopupItems:w,extraKeysCount:Object.keys(x).length})}),s.jsx(Vt,{value:"oss",className:"space-y-6 mt-0",children:s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(I1,{className:"w-5 h-5 text-[#38bdac]"}),"OSS 配置(阿里云对象存储)"]}),s.jsx(qt,{className:"text-gray-400",children:"endpoint、bucket、accessKey 等,用于图片/文件上传"})]}),s.jsx(ze,{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(ne,{className:"text-gray-300",children:"Endpoint"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:v.endpoint??"",onChange:ue=>k($=>({...$,endpoint:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"Bucket"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:v.bucket??"",onChange:ue=>k($=>({...$,bucket:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"Region"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:v.region??"",onChange:ue=>k($=>({...$,region:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"AccessKey ID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:v.accessKeyId??"",onChange:ue=>k($=>({...$,accessKeyId:ue.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"AccessKey Secret"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:v.accessKeySecret??"",onChange:ue=>k($=>({...$,accessKeySecret:ue.target.value}))})]})]})})]})}),s.jsxs(Vt,{value:"features",className:"space-y-6 mt-0",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(vo,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx(qt,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs(ze,{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(Vn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{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(Ut,{id:"match-enabled",checked:u.matchEnabled,disabled:ce,onCheckedChange:ue=>V("matchEnabled",ue)})]}),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($g,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"}),s.jsxs("p",{className:"text-xs text-amber-400/80 ml-6 mt-1",children:["佣金比例、绑定期、提现规则等与",s.jsx(Po,{to:"/distribution?tab=settings",className:"underline mx-1 text-[#38bdac]",children:"推广中心 → 推广设置"}),"为同一套接口,在此仅控制是否展示入口。"]})]}),s.jsx(Ut,{id:"referral-enabled",checked:u.referralEnabled,disabled:ce,onCheckedChange:ue=>V("referralEnabled",ue)})]}),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(or,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{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(Ut,{id:"search-enabled",checked:u.searchEnabled,disabled:ce,onCheckedChange:ue=>V("searchEnabled",ue)})]}),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(vo,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(ne,{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(Ut,{id:"about-enabled",checked:u.aboutEnabled,disabled:ce,onCheckedChange:ue=>V("aboutEnabled",ue)})]})]}),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.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Sf,{className:"w-5 h-5 text-[#38bdac]"}),"小程序模块显隐说明"]}),s.jsx(qt,{className:"text-gray-400",children:"以下模块受上方开关和审核模式共同控制"})]}),s.jsx(ze,{children:s.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[{mod:"找伙伴",ctrl:"找伙伴功能开关",icon:s.jsx(Vn,{className:"w-3 h-3"})},{mod:"推广中心 / 推荐好友",ctrl:"推广功能开关",icon:s.jsx($g,{className:"w-3 h-3"})},{mod:"搜索",ctrl:"搜索功能开关",icon:s.jsx(or,{className:"w-3 h-3"})},{mod:"关于页面",ctrl:"关于页面开关",icon:s.jsx(zh,{className:"w-3 h-3"})},{mod:"支付 / VIP / 充值 / 收益",ctrl:"审核模式",icon:s.jsx(Vc,{className:"w-3 h-3"})},{mod:"超级个体名片",ctrl:"审核模式",icon:s.jsx(TA,{className:"w-3 h-3"})},{mod:"首页获客入口",ctrl:"已移除",icon:s.jsx(eM,{className:"w-3 h-3"})}].map(ue=>s.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#0a1628] border border-gray-700/30",children:[ue.icon,s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:ue.mod}),s.jsxs("span",{className:"text-gray-500 ml-1",children:["← ",ue.ctrl]})]})]},ue.mod))})})]})]})]})]}),s.jsx(Vt,{value:"author",className:"mt-0",children:s.jsx(MV,{})}),s.jsx(Vt,{value:"admin",className:"mt-0",children:s.jsx(PV,{})}),s.jsx(Vt,{value:"open-platform",className:"mt-0",children:s.jsx(_V,{embedded:!0})}),s.jsx(Vt,{value:"api-docs",className:"mt-0",children:s.jsx(q4,{})})]}),s.jsx(It,{open:W,onOpenChange:P,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(Rt,{children:[s.jsx(Lt,{className:_?"text-red-400":"text-[#38bdac]",children:B}),s.jsx(Oo,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:X})]}),s.jsx(Xt,{className:"mt-4",children:s.jsx(J,{onClick:()=>P(!1),className:_?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const Aj={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 sH(){const[t,e]=g.useState(!1),[n,r]=g.useState(Aj),[a,i]=g.useState(""),o=async()=>{e(!0);try{const k=await Re("/api/config");k!=null&&k.paymentMethods&&r({...Aj,...k.paymentMethods})}catch(k){console.error(k)}finally{e(!1)}};g.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await gt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),G.success("配置已保存!")}catch(k){console.error("保存失败:",k),G.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,M)=>{navigator.clipboard.writeText(k),i(M),setTimeout(()=>i(""),2e3)},h=(k,M)=>{r(E=>({...E,wechat:{...E.wechat,[k]:M}}))},f=(k,M)=>{r(E=>({...E,alipay:{...E.alipay,[k]:M}}))},m=(k,M)=>{r(E=>({...E,usdt:{...E.usdt,[k]:M}}))},x=(k,M)=>{r(E=>({...E,paypal:{...E.paypal,[k]:M}}))},b=n.wechat,N=n.alipay,w=n.usdt,v=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(J,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(J,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{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(Zj,{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(Vl,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Do,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(Bt,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx($l,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(Bt,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(R1,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(Bt,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(P1,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(Bt,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(zg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(Vt,{value:"wechat",className:"space-y-4",children:s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx($l,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(Ut,{checked:!!b.enabled,onCheckedChange:k=>h("enabled",k)})]}),s.jsxs(ze,{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(ne,{className:"text-gray-300",children:"网站AppID"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"商户号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.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(Io,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(b.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(ne,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(le,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(b.groupQrCode??""),onChange:k=>h("groupQrCode",k.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(Vt,{value:"alipay",className:"space-y-4",children:s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(R1,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(qt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(Ut,{checked:!!N.enabled,onCheckedChange:k=>f("enabled",k)})]}),s.jsxs(ze,{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(ne,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),s.jsx(J,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?s.jsx(Tp,{className:"w-4 h-4 text-green-500"}):s.jsx(tk,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(le,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.securityKey??""),onChange:k=>f("securityKey",k.target.value)})]})]}),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(Io,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(N.qrCode??""),onChange:k=>f("qrCode",k.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(Vt,{value:"usdt",className:"space-y-4",children:s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(P1,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(Ut,{checked:!!w.enabled,onCheckedChange:k=>m("enabled",k)})]}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{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(ne,{className:"text-gray-300",children:"收款地址"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(le,{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(Vt,{value:"paypal",className:"space-y-4",children:s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ot,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(zg,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(Ut,{checked:!!v.enabled,onCheckedChange:k=>x("enabled",k)})]}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(v.email??""),onChange:k=>x("email",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(v.exchangeRate)??7.2,onChange:k=>x("exchangeRate",Number(k.target.value)||7.2)})]})]})]})})]})]})}const rH={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},aH={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},iH={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function oH(){const[t,e]=g.useState({siteConfig:{...rH},menuConfig:{...aH},pageConfig:{...iH}}),[n,r]=g.useState(!1),[a,i]=g.useState(!1);g.useEffect(()=>{Re("/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 gt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await gt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await gt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),G.success("配置已保存")}catch(f){console.error(f),G.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(J,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(zg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx(qt,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs(ze,{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(ne,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(le,{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(ne,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(le,{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(ne,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(le,{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(ne,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(le,{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(ne,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(le,{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($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(QM,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx(qt,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx(ze,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(ne,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(le,{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(le,{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($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(VM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx(qt,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx(ze,{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(Ut,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:x=>e(b=>({...b,menuConfig:{...b.menuConfig,[f]:{...m,enabled:x}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:x=>e(b=>({...b,menuConfig:{...b.menuConfig,[f]:{...m,label:x.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($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(G0,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs(ze,{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(ne,{className:"text-gray-300",children:"首页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"首页副标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"目录页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"我的页标题"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function lH(){const[t,e]=g.useState(""),[n,r]=g.useState(""),[a,i]=g.useState(""),[o,c]=g.useState({}),u=async()=>{var b,N,w,v;try{const k=await Re("/api/config"),M=(N=(b=k==null?void 0:k.liveQRCodes)==null?void 0:b[0])==null?void 0:N.urls;Array.isArray(M)&&e(M.join(` `));const E=(v=(w=k==null?void 0:k.paymentMethods)==null?void 0:w.wechat)==null?void 0:v.groupQrCode;E&&r(E),c({paymentMethods:k==null?void 0:k.paymentMethods,liveQRCodes:k==null?void 0:k.liveQRCodes})}catch(k){console.error(k)}};g.useEffect(()=>{u()},[]);const h=(b,N)=>{navigator.clipboard.writeText(b),i(N),setTimeout(()=>i(""),2e3)},f=async()=>{try{const b=t.split(` -`).map(w=>w.trim()).filter(Boolean),N=[...o.liveQRCodes||[]];N[0]?N[0].urls=b:N.push({id:"live-1",name:"微信群活码",urls:b,clickCount:0}),await xt("/api/db/config",{key:"live_qr_codes",value:N,description:"群活码配置"}),G.success("群活码配置已保存!"),await u()}catch(b){console.error(b),G.error("保存失败: "+(b instanceof Error?b.message:String(b)))}},m=async()=>{var b;try{await xt("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((b=o.paymentMethods)==null?void 0:b.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),G.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(N){console.error(N),G.error("保存失败: "+(N instanceof Error?N.message:String(N)))}},x=()=>{n?window.open(n,"_blank"):G.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(Zj,{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(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(_1,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx(qt,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs($e,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(le,{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:b=>r(b.target.value)}),s.jsx(J,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?s.jsx(Tp,{className:"w-4 h-4 text-green-500"}):s.jsx(tk,{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(Io,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(J,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(Ef,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(J,{onClick:x,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(Io,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(_1,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx(qt,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs($e,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(Uo,{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:b=>e(b.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(J,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ef,{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 Aj={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}},sH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function rH(){const[t,e]=g.useState(Aj),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),[u,h]=g.useState(null),[f,m]=g.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),x=async()=>{r(!0);try{const E=await Re("/api/db/config/full?key=match_config"),L=(E==null?void 0:E.data)??(E==null?void 0:E.config);L&&e({...Aj,...L})}catch(E){console.error("加载匹配配置失败:",E)}finally{r(!1)}};g.useEffect(()=>{x()},[]);const b=async()=>{i(!0);try{const E=await xt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});E&&E.success!==!1?G.success("配置保存成功!"):G.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:"未知错误"))}catch(E){console.error("保存配置失败:",E),G.error("保存失败")}finally{i(!1)}},N=E=>{h(E),m({id:E.id,label:E.label,matchLabel:E.matchLabel,icon:E.icon,matchFromDB:E.matchFromDB,showJoinAfterMatch:E.showJoinAfterMatch,price:E.price,enabled:E.enabled}),c(!0)},w=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},v=()=>{if(!f.id||!f.label){G.error("请填写类型ID和名称");return}const E=[...t.matchTypes];if(u){const L=E.findIndex(R=>R.id===u.id);L!==-1&&(E[L]={...f})}else{if(E.some(L=>L.id===f.id)){G.error("类型ID已存在");return}E.push({...f})}e({...t,matchTypes:E}),c(!1)},k=E=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(L=>L.id!==E)})},M=E=>{e({...t,matchTypes:t.matchTypes.map(L=>L.id===E?{...L,enabled:!L.enabled}:L)})};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(No,{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(J,{variant:"outline",onClick:x,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(J,{onClick:b,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Ro,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs($e,{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(ne,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(le,{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(Ht,{checked:t.settings.enableFreeMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enableFreeMatches:E}})}),s.jsx(ne,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ht,{checked:t.settings.enablePaidMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enablePaidMatches:E}})}),s.jsx(ne,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(J,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx($e,{children:s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"图标"}),s.jsx(ke,{className:"text-gray-400",children:"类型ID"}),s.jsx(ke,{className:"text-gray-400",children:"显示名称"}),s.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),s.jsx(ke,{className:"text-gray-400",children:"价格"}),s.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ds,{children:t.matchTypes.map(E=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx("span",{className:"text-2xl",children:E.icon})}),s.jsx(je,{className:"font-mono text-gray-300",children:E.id}),s.jsx(je,{className:"text-white font-medium",children:E.label}),s.jsx(je,{className:"text-gray-300",children:E.matchLabel}),s.jsx(je,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",E.price]})}),s.jsx(je,{children:E.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Ht,{checked:E.enabled,onCheckedChange:()=>M(E.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(E),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>k(E.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Jn,{className:"w-4 h-4"})})]})})]},E.id))})]})})]}),s.jsx(Pt,{open:o,onOpenChange:c,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:sH.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(ne,{className:"text-gray-300",children:"显示名称"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"匹配标签"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(le,{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(Ht,{checked:f.matchFromDB,onCheckedChange:E=>m({...f,matchFromDB:E})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ht,{checked:f.showJoinAfterMatch,onCheckedChange:E=>m({...f,showJoinAfterMatch:E})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ht,{checked:f.enabled,onCheckedChange:E=>m({...f,enabled:E})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(J,{onClick:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const Pj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function aH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(""),[f,m]=g.useState(!0),[x,b]=g.useState(null);async function N(){m(!0),b(null);try{const v=new URLSearchParams({page:String(a),pageSize:String(o)});u&&v.set("matchType",u);const k=await Re(`/api/db/match-records?${v}`);k!=null&&k.success?(e(k.records||[]),r(k.total??0)):b("加载匹配记录失败")}catch(v){console.error("加载匹配记录失败",v),b("加载失败,请检查网络后重试")}finally{m(!1)}}g.useEffect(()=>{N()},[a,u]);const w=Math.ceil(n/o)||1;return s.jsxs("div",{className:"p-8 w-full",children:[x&&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:x}),s.jsx("button",{type:"button",onClick:()=>b(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:v=>{h(v.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(Pj).map(([v,k])=>s.jsx("option",{value:v,children:k},v))]}),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(He,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ds,{children:[t.map(v=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{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:[v.userAvatar?s.jsx("img",{src:aa(v.userAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const M=k.currentTarget.nextElementSibling;M&&M.classList.remove("hidden")}}):null,s.jsx("span",{className:v.userAvatar?"hidden":"",children:(v.userNickname||v.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:v.userNickname||v.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.userId.slice(0,16),"..."]})]})]})}),s.jsx(je,{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:[v.matchedUserAvatar?s.jsx("img",{src:aa(v.matchedUserAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const M=k.currentTarget.nextElementSibling;M&&M.classList.remove("hidden")}}):null,s.jsx("span",{className:v.matchedUserAvatar?"hidden":"",children:(v.matchedNickname||v.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:v.matchedNickname||v.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(je,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Pj[v.matchType]||v.matchType})}),s.jsxs(je,{className:"text-gray-400 text-sm",children:[v.phone&&s.jsxs("div",{children:["📱 ",v.phone]}),v.wechatId&&s.jsxs("div",{children:["💬 ",v.wechatId]}),!v.phone&&!v.wechatId&&"-"]}),s.jsx(je,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleString():"-"})]},v.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(us,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:v=>{c(v),i(1)}})]})})})]})}function iH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0);async function a(){r(!0);try{const i=await Re("/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),G.error("加载 VIP 成员失败")}finally{r(!1)}}return g.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(Kc,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx($e,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(ke,{className:"text-gray-400",children:"成员"}),s.jsx(ke,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(ke,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(ds,{children:[t.map((i,o)=>{var c;return s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:o+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?s.jsx("img",{src:aa(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(je,{className:"text-gray-300",children:i.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(je,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function G4(t){const e=_a(),[n,r]=g.useState([]),[a,i]=g.useState(!0),[o,c]=g.useState(!1),[u,h]=g.useState(null),[f,m]=g.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0,userId:""}),[x,b]=g.useState(!1),[N,w]=g.useState(!1),v=g.useRef(null),k=async O=>{var ae;const Y=(ae=O.target.files)==null?void 0:ae[0];if(Y){w(!0);try{const _=new FormData;_.append("file",Y),_.append("folder","mentors");const se=_u(),ce={};se&&(ce.Authorization=`Bearer ${se}`);const I=await(await fetch(zl("/api/upload"),{method:"POST",body:_,credentials:"include",headers:ce})).json();I!=null&&I.success&&(I!=null&&I.url)?m(X=>({...X,avatar:I.url})):G.error("上传失败: "+((I==null?void 0:I.error)||"未知错误"))}catch(_){console.error(_),G.error("上传失败")}finally{w(!1),v.current&&(v.current.value="")}}};async function M(){i(!0);try{const O=await Re("/api/db/mentors");O!=null&&O.success&&O.data&&r(O.data)}catch(O){console.error("Load mentors error:",O)}finally{i(!1)}}g.useEffect(()=>{M()},[]);const E=()=>{m({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:n.length>0?Math.max(...n.map(O=>O.sort))+1:0,enabled:!0,userId:""})},L=()=>{h(null),E(),c(!0)},R=O=>{h(O),m({name:O.name,avatar:O.avatar||"",intro:O.intro||"",tags:O.tags||"",priceSingle:O.priceSingle!=null?String(O.priceSingle):"",priceHalfYear:O.priceHalfYear!=null?String(O.priceHalfYear):"",priceYear:O.priceYear!=null?String(O.priceYear):"",quote:O.quote||"",whyFind:O.whyFind||"",offering:O.offering||"",judgmentStyle:O.judgmentStyle||"",sort:O.sort,enabled:O.enabled??!0,userId:O.userId||""}),c(!0)},W=async()=>{if(!f.name.trim()){G.error("导师姓名不能为空");return}b(!0);try{const O=_=>_===""?void 0:parseFloat(_),Y=f.userId.trim(),ae={name:f.name.trim(),avatar:f.avatar.trim()||void 0,intro:f.intro.trim()||void 0,tags:f.tags.trim()||void 0,priceSingle:O(f.priceSingle),priceHalfYear:O(f.priceHalfYear),priceYear:O(f.priceYear),quote:f.quote.trim()||void 0,whyFind:f.whyFind.trim()||void 0,offering:f.offering.trim()||void 0,judgmentStyle:f.judgmentStyle.trim()||void 0,sort:f.sort,enabled:f.enabled};if(u){const _=await Yt("/api/db/mentors",{id:u.id,...ae,userId:Y});_!=null&&_.success?(c(!1),M()):G.error("更新失败: "+(_==null?void 0:_.error))}else{const _=await xt("/api/db/mentors",{...ae,userId:Y||void 0});_!=null&&_.success?(c(!1),M()):G.error("新增失败: "+(_==null?void 0:_.error))}}catch(O){console.error("Save error:",O),G.error("保存失败")}finally{b(!1)}},P=async O=>{if(confirm("确定删除该导师?"))try{const Y=await bi(`/api/db/mentors?id=${O}`);Y!=null&&Y.success?M():G.error("删除失败: "+(Y==null?void 0:Y.error))}catch(Y){console.error("Delete error:",Y),G.error("删除失败")}},B=O=>O!=null?`¥${O}`:"-";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(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表;填写「绑定用户 ID」后,小程序导师详情可跳转「派对会员名片」(与超级个体同页)"})]}),s.jsxs(J,{onClick:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx($e,{className:"p-0",children:a?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"姓名"}),s.jsx(ke,{className:"text-gray-400",children:"简介"}),s.jsx(ke,{className:"text-gray-400",children:"单次"}),s.jsx(ke,{className:"text-gray-400",children:"半年"}),s.jsx(ke,{className:"text-gray-400",children:"年度"}),s.jsx(ke,{className:"text-gray-400",children:"绑定用户"}),s.jsx(ke,{className:"text-gray-400",children:"排序"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[n.map(O=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:O.id}),s.jsx(je,{children:s.jsxs("button",{type:"button",onClick:()=>e(`/users?search=${encodeURIComponent(O.name)}`),className:"text-[#38bdac] hover:text-[#2da396] hover:underline flex items-center gap-1",title:"在用户管理中查看",children:[O.name,s.jsx(Io,{className:"w-3 h-3"})]})}),s.jsx(je,{className:"text-gray-400 max-w-[200px] truncate",children:O.intro||"-"}),s.jsx(je,{className:"text-gray-400",children:B(O.priceSingle)}),s.jsx(je,{className:"text-gray-400",children:B(O.priceHalfYear)}),s.jsx(je,{className:"text-gray-400",children:B(O.priceYear)}),s.jsx(je,{className:"text-gray-400 font-mono text-xs max-w-[120px] truncate",title:O.userId||"",children:O.userId?s.jsx("button",{type:"button",onClick:()=>e(`/users?search=${encodeURIComponent(O.userId||"")}`),className:"text-[#38bdac] hover:underline truncate max-w-[120px] inline-block align-bottom",children:O.userId}):"—"}),s.jsx(je,{className:"text-gray-400",children:O.sort}),s.jsxs(je,{className:"text-right",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>R(O),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Jn,{className:"w-4 h-4"})})]})]},O.id)),n.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:9,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Pt,{open:o,onOpenChange:c,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(It,{children:s.jsx(Rt,{className:"text-white",children: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(ne,{className:"text-gray-300",children:"姓名 *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:f.name,onChange:O=>m(Y=>({...Y,name:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"排序"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.sort,onChange:O=>m(Y=>({...Y,sort:parseInt(O.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:f.avatar,onChange:O=>m(Y=>({...Y,avatar:O.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:v,type:"file",accept:"image/*",className:"hidden",onChange:k}),s.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:N,onClick:()=>{var O;return(O=v.current)==null?void 0:O.click()},children:[s.jsx(Ef,{className:"w-4 h-4 mr-2"}),N?"上传中...":"上传"]})]}),f.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:aa(f.avatar.startsWith("http")?f.avatar:zl(f.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(ne,{className:"text-gray-300",children:"绑定用户 ID(可选,与名片页一致)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"小程序用户 id,填后导师详情显示「查看派对会员名片」",value:f.userId,onChange:O=>m(Y=>({...Y,userId:O.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"留空则仅展示导师资料;填写后 C 端可跳转 member-detail 与超级个体同款名片。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"简介"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:f.intro,onChange:O=>m(Y=>({...Y,intro:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:f.tags,onChange:O=>m(Y=>({...Y,tags:O.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(ne,{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(ne,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:f.priceSingle,onChange:O=>m(Y=>({...Y,priceSingle:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:f.priceHalfYear,onChange:O=>m(Y=>({...Y,priceHalfYear:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:f.priceYear,onChange:O=>m(Y=>({...Y,priceYear:O.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"引言"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:f.quote,onChange:O=>m(Y=>({...Y,quote:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.whyFind,onChange:O=>m(Y=>({...Y,whyFind:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.offering,onChange:O=>m(Y=>({...Y,offering:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:f.judgmentStyle,onChange:O=>m(Y=>({...Y,judgmentStyle:O.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:f.enabled,onChange:O=>m(Y=>({...Y,enabled:O.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(ne,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:W,disabled:x,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),x?"保存中...":"保存"]})]})]})})]})}function oH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState("");async function o(){r(!0);try{const h=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",f=await Re(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}g.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(Og,{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(J,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx($e,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户ID"}),s.jsx(ke,{className:"text-gray-400",children:"导师ID"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ds,{children:[t.map(h=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:h.id}),s.jsx(je,{className:"text-gray-400",children:h.userId}),s.jsx(je,{className:"text-gray-400",children:h.mentorId}),s.jsx(je,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(je,{className:"text-white",children:["¥",h.amount]}),s.jsx(je,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(je,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const au={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},Ij={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:au},lH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function cH(){const t=_a(),[e,n]=g.useState(Ij),[r,a]=g.useState(!0),[i,o]=g.useState(!1),[c,u]=g.useState(!1),[h,f]=g.useState(null),[m,x]=g.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[b,N]=g.useState(null),[w,v]=g.useState(!1),k=async()=>{v(!0);try{const O=await Re("/api/db/match-pool-counts");O!=null&&O.success&&O.data&&N(O.data)}catch(O){console.error("加载池子人数失败:",O)}finally{v(!1)}},M=async()=>{a(!0);try{const O=await Re("/api/db/config/full?key=match_config"),Y=(O==null?void 0:O.data)??(O==null?void 0:O.config);if(Y){let ae=Y.poolSettings??au;ae.poolSource&&!Array.isArray(ae.poolSource)&&(ae={...ae,poolSource:[ae.poolSource]}),n({...Ij,...Y,poolSettings:ae})}}catch(O){console.error("加载匹配配置失败:",O)}finally{a(!1)}};g.useEffect(()=>{M(),k()},[]);const E=async()=>{o(!0);try{const O=await xt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});G.error((O==null?void 0:O.success)!==!1?"配置保存成功!":"保存失败: "+((O==null?void 0:O.error)||"未知错误"))}catch(O){console.error(O),G.error("保存失败")}finally{o(!1)}},L=O=>{f(O),x({...O}),u(!0)},R=()=>{f(null),x({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},W=()=>{if(!m.id||!m.label){G.error("请填写类型ID和名称");return}const O=[...e.matchTypes];if(h){const Y=O.findIndex(ae=>ae.id===h.id);Y!==-1&&(O[Y]={...m})}else{if(O.some(Y=>Y.id===m.id)){G.error("类型ID已存在");return}O.push({...m})}n({...e,matchTypes:O}),u(!1)},P=O=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(Y=>Y.id!==O)})},B=O=>{n({...e,matchTypes:e.matchTypes.map(Y=>Y.id===O?{...Y,enabled:!Y.enabled}:Y)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(J,{variant:"outline",onClick:M,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(J,{onClick:E,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(nk,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx(qt,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs($e,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(ne,{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(O=>{const Y=e.poolSettings??au,_=(Array.isArray(Y.poolSource)?Y.poolSource:[Y.poolSource]).includes(O.value),se=b==null?void 0:b[O.countKey],ce=()=>{const me=Array.isArray(Y.poolSource)?[...Y.poolSource]:[Y.poolSource],I=_?me.filter(X=>X!==O.value):[...me,O.value];I.length===0&&I.push(O.value),n({...e,poolSettings:{...Y,poolSource:I}})};return s.jsxs("button",{type:"button",onClick:ce,className:`p-4 rounded-lg border text-left transition-all ${_?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[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 ${_?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:_&&"✓"}),s.jsx("span",{className:"text-xl",children:O.icon}),s.jsx("span",{className:`text-sm font-medium ${_?"text-[#38bdac]":"text-gray-300"}`,children:O.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":se??"-",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:O.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:me=>{me.stopPropagation(),t(`/users?pool=${O.value}`)},onKeyDown:me=>{me.key==="Enter"&&(me.stopPropagation(),t(`/users?pool=${O.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},O.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(ne,{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(O=>{const ae=(e.poolSettings??au)[O.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(Ht,{checked:ae,onCheckedChange:_=>n({...e,poolSettings:{...e.poolSettings??au,[O.key]:_}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:O.icon}),s.jsx(ne,{className:"text-gray-300 text-sm",children:O.label})]})]},O.key)})})]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Ro,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs($e,{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(ne,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:O=>n({...e,freeMatchLimit:parseInt(O.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(le,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:O=>n({...e,matchPrice:parseFloat(O.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(le,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:O=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(O.target.value,10)||10}})})]})]}),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(Ht,{checked:e.settings.enableFreeMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enableFreeMatches:O}})}),s.jsx(ne,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ht,{checked:e.settings.enablePaidMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enablePaidMatches:O}})}),s.jsx(ne,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(_e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(J,{onClick:R,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx($e,{children:s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"图标"}),s.jsx(ke,{className:"text-gray-400",children:"类型ID"}),s.jsx(ke,{className:"text-gray-400",children:"显示名称"}),s.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),s.jsx(ke,{className:"text-gray-400",children:"价格"}),s.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ds,{children:e.matchTypes.map(O=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx("span",{className:"text-2xl",children:O.icon})}),s.jsx(je,{className:"font-mono text-gray-300",children:O.id}),s.jsx(je,{className:"text-white font-medium",children:O.label}),s.jsx(je,{className:"text-gray-300",children:O.matchLabel}),s.jsx(je,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",O.price]})}),s.jsx(je,{children:O.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Ht,{checked:O.enabled,onCheckedChange:()=>B(O.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>L(O),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Jn,{className:"w-4 h-4"})})]})})]},O.id))})]})})]}),s.jsx(Pt,{open:c,onOpenChange:u,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(It,{children:s.jsxs(Rt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:O=>x({...m,id:O.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:lH.map(O=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===O?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>x({...m,icon:O}),children:O},O))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"显示名称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:O=>x({...m,label:O.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"匹配标签"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:O=>x({...m,matchLabel:O.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(le,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:O=>x({...m,price:parseFloat(O.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(Ht,{checked:m.matchFromDB,onCheckedChange:O=>x({...m,matchFromDB:O})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ht,{checked:m.showJoinAfterMatch,onCheckedChange:O=>x({...m,showJoinAfterMatch:O})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ht,{checked:m.enabled,onCheckedChange:O=>x({...m,enabled:O})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(J,{onClick:W,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const Rj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function dH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(""),[f,m]=g.useState(!0),[x,b]=g.useState(null),[N,w]=g.useState(null);async function v(){m(!0),b(null);try{const E=new URLSearchParams({page:String(a),pageSize:String(o)});u&&E.set("matchType",u);const L=await Re(`/api/db/match-records?${E}`);L!=null&&L.success?(e(L.records||[]),r(L.total??0)):b("加载匹配记录失败")}catch{b("加载失败,请检查网络后重试")}finally{m(!1)}}g.useEffect(()=>{v()},[a,u]);const k=Math.ceil(n/o)||1,M=({userId:E,nickname:L,avatar:R})=>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:[R?s.jsx("img",{src:aa(R),alt:"",className:"w-full h-full object-cover",onError:W=>{W.currentTarget.style.display="none"}}):null,s.jsx("span",{className:R?"hidden":"",children:(L||E||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:L||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:[x&&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:x}),s.jsx("button",{type:"button",onClick:()=>b(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(Rj).map(([E,L])=>s.jsx("option",{value:E,children:L},E))]}),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(He,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ds,{children:[t.map(E=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx(M,{userId:E.userId,nickname:E.userNickname,avatar:E.userAvatar})}),s.jsx(je,{children:E.matchedUserId?s.jsx(M,{userId:E.matchedUserId,nickname:E.matchedNickname,avatar:E.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(je,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Rj[E.matchType]||E.matchType})}),s.jsxs(je,{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(je,{className:"text-gray-400",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"})]},E.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(us,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})}),s.jsx(cy,{open:!!N,onClose:()=>w(null),userId:N,onUserUpdated:v})]})}function uH(){const[t,e]=g.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(dH,{}),t==="pool"&&s.jsx(cH,{})]})}const Lj={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function hH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(!0),[f,m]=g.useState("investor"),[x,b]=g.useState(null);async function N(){h(!0);try{const M=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),E=await Re(`/api/db/match-records?${M}`);E!=null&&E.success&&(e(E.records||[]),r(E.total??0))}catch(M){console.error(M)}finally{h(!1)}}g.useEffect(()=>{N()},[a,f]);const w=async M=>{if(!M.phone&&!M.wechatId){G.info("该记录无联系方式,无法推送到存客宝");return}b(M.id);try{const E=await xt("/api/ckb/join",{type:M.matchType||"investor",phone:M.phone||"",wechat:M.wechatId||"",userId:M.userId,name:M.userNickname||""});G.error((E==null?void 0:E.message)||(E!=null&&E.success?"推送成功":"推送失败"))}catch(E){G.error("推送失败: "+(E instanceof Error?E.message:"网络错误"))}finally{b(null)}},v=Math.ceil(n/o)||1,k=M=>!!(M.phone||M.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:M=>{m(M.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(Lj).map(([M,E])=>s.jsx("option",{value:M,children:E},M))}),s.jsxs(J,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"时间"}),s.jsx(ke,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(ds,{children:[t.map(M=>{var E,L;return s.jsxs(ht,{className:`border-gray-700/50 ${k(M)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(je,{className:"text-white",children:M.userNickname||((E=M.userId)==null?void 0:E.slice(0,12))}),s.jsx(je,{className:"text-white",children:M.matchedNickname||((L=M.matchedUserId)==null?void 0:L.slice(0,12))}),s.jsx(je,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Lj[M.matchType]||M.matchType})}),s.jsxs(je,{className:"text-sm",children:[M.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",M.phone]}),M.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",M.wechatId]}),!M.phone&&!M.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(je,{className:"text-gray-400 text-sm",children:M.createdAt?new Date(M.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-right",children:k(M)?s.jsxs(J,{size:"sm",onClick:()=>w(M),disabled:x===M.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(gA,{className:"w-3 h-3 mr-1"}),x===M.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},M.id)}),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(us,{page:a,totalPages:v,total:n,pageSize:o,onPageChange:i,onPageSizeChange:M=>{c(M),i(1)}})]})})})]})}const Oj={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},fH={single:"单次",half_year:"半年",year:"年度"};function pH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState("");async function o(){r(!0);try{const c=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",u=await Re(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return g.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(Oj).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(J,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx($e,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户ID"}),s.jsx(ke,{className:"text-gray-400",children:"导师ID"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ds,{children:[t.map(c=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:c.id}),s.jsx(je,{className:"text-gray-400",children:c.userId}),s.jsx(je,{className:"text-gray-400",children:c.mentorId}),s.jsx(je,{className:"text-gray-400",children:fH[c.consultationType]||c.consultationType}),s.jsxs(je,{className:"text-white",children:["¥",c.amount]}),s.jsx(je,{className:"text-gray-400",children:Oj[c.status]||c.status}),s.jsx(je,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function mH(){const[t,e]=g.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(pH,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(G4,{embedded:!0})})]})}function xH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(!0);async function f(){h(!0);try{const x=new URLSearchParams({page:String(a),pageSize:String(o),matchType:"team"}),b=await Re(`/api/db/match-records?${x}`);b!=null&&b.success&&(e(b.records||[]),r(b.total??0))}catch(x){console.error(x)}finally{h(!1)}}g.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(He,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(_e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx($e,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(ds,{children:[t.map(x=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{className:"text-white",children:x.userNickname||x.userId}),s.jsx(je,{className:"text-white",children:x.matchedNickname||x.matchedUserId}),s.jsxs(je,{className:"text-gray-400 text-sm",children:[x.phone&&s.jsxs("div",{children:["📱 ",x.phone]}),x.wechatId&&s.jsxs("div",{children:["💬 ",x.wechatId]}),!x.phone&&!x.wechatId&&"-"]}),s.jsx(je,{className:"text-gray-400",children:x.createdAt?new Date(x.createdAt).toLocaleString():"-"})]},x.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(us,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:x=>{c(x),i(1)}})]})})})]})}const gH=["partner","investor","mentor","team"],Mg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Dj=`# 场景获客接口摘要 +`).map(w=>w.trim()).filter(Boolean),N=[...o.liveQRCodes||[]];N[0]?N[0].urls=b:N.push({id:"live-1",name:"微信群活码",urls:b,clickCount:0}),await gt("/api/db/config",{key:"live_qr_codes",value:N,description:"群活码配置"}),G.success("群活码配置已保存!"),await u()}catch(b){console.error(b),G.error("保存失败: "+(b instanceof Error?b.message:String(b)))}},m=async()=>{var b;try{await gt("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((b=o.paymentMethods)==null?void 0:b.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),G.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(N){console.error(N),G.error("保存失败: "+(N instanceof Error?N.message:String(N)))}},x=()=>{n?window.open(n,"_blank"):G.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(Zj,{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($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(_1,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx(qt,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(le,{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:b=>r(b.target.value)}),s.jsx(J,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?s.jsx(Tp,{className:"w-4 h-4 text-green-500"}):s.jsx(tk,{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(Io,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(J,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(Ef,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(J,{onClick:x,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(Io,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(_1,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx(qt,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(ne,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Fg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(Uo,{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:b=>e(b.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(J,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ef,{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 Pj={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}},cH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function dH(){const[t,e]=g.useState(Pj),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),[u,h]=g.useState(null),[f,m]=g.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),x=async()=>{r(!0);try{const E=await Re("/api/db/config/full?key=match_config"),L=(E==null?void 0:E.data)??(E==null?void 0:E.config);L&&e({...Pj,...L})}catch(E){console.error("加载匹配配置失败:",E)}finally{r(!1)}};g.useEffect(()=>{x()},[]);const b=async()=>{i(!0);try{const E=await gt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});E&&E.success!==!1?G.success("配置保存成功!"):G.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:"未知错误"))}catch(E){console.error("保存配置失败:",E),G.error("保存失败")}finally{i(!1)}},N=E=>{h(E),m({id:E.id,label:E.label,matchLabel:E.matchLabel,icon:E.icon,matchFromDB:E.matchFromDB,showJoinAfterMatch:E.showJoinAfterMatch,price:E.price,enabled:E.enabled}),c(!0)},w=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},v=()=>{if(!f.id||!f.label){G.error("请填写类型ID和名称");return}const E=[...t.matchTypes];if(u){const L=E.findIndex(R=>R.id===u.id);L!==-1&&(E[L]={...f})}else{if(E.some(L=>L.id===f.id)){G.error("类型ID已存在");return}E.push({...f})}e({...t,matchTypes:E}),c(!1)},k=E=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(L=>L.id!==E)})},M=E=>{e({...t,matchTypes:t.matchTypes.map(L=>L.id===E?{...L,enabled:!L.enabled}:L)})};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(vo,{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(J,{variant:"outline",onClick:x,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(J,{onClick:b,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Ro,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(ze,{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(ne,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(le,{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(Ut,{checked:t.settings.enableFreeMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enableFreeMatches:E}})}),s.jsx(ne,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ut,{checked:t.settings.enablePaidMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enablePaidMatches:E}})}),s.jsx(ne,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(J,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(ze,{children:s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"图标"}),s.jsx(ke,{className:"text-gray-400",children:"类型ID"}),s.jsx(ke,{className:"text-gray-400",children:"显示名称"}),s.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),s.jsx(ke,{className:"text-gray-400",children:"价格"}),s.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ds,{children:t.matchTypes.map(E=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx("span",{className:"text-2xl",children:E.icon})}),s.jsx(je,{className:"font-mono text-gray-300",children:E.id}),s.jsx(je,{className:"text-white font-medium",children:E.label}),s.jsx(je,{className:"text-gray-300",children:E.matchLabel}),s.jsx(je,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",E.price]})}),s.jsx(je,{children:E.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Ut,{checked:E.enabled,onCheckedChange:()=>M(E.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>N(E),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>k(E.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Jn,{className:"w-4 h-4"})})]})})]},E.id))})]})})]}),s.jsx(It,{open:o,onOpenChange:c,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:cH.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(ne,{className:"text-gray-300",children:"显示名称"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"匹配标签"}),s.jsx(le,{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(ne,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(le,{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(Ut,{checked:f.matchFromDB,onCheckedChange:E=>m({...f,matchFromDB:E})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ut,{checked:f.showJoinAfterMatch,onCheckedChange:E=>m({...f,showJoinAfterMatch:E})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ut,{checked:f.enabled,onCheckedChange:E=>m({...f,enabled:E})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(J,{onClick:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const Ij={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function uH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(""),[f,m]=g.useState(!0),[x,b]=g.useState(null);async function N(){m(!0),b(null);try{const v=new URLSearchParams({page:String(a),pageSize:String(o)});u&&v.set("matchType",u);const k=await Re(`/api/db/match-records?${v}`);k!=null&&k.success?(e(k.records||[]),r(k.total??0)):b("加载匹配记录失败")}catch(v){console.error("加载匹配记录失败",v),b("加载失败,请检查网络后重试")}finally{m(!1)}}g.useEffect(()=>{N()},[a,u]);const w=Math.ceil(n/o)||1;return s.jsxs("div",{className:"p-8 w-full",children:[x&&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:x}),s.jsx("button",{type:"button",onClick:()=>b(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:v=>{h(v.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(Ij).map(([v,k])=>s.jsx("option",{value:v,children:k},v))]}),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(He,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ds,{children:[t.map(v=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{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:[v.userAvatar?s.jsx("img",{src:aa(v.userAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const M=k.currentTarget.nextElementSibling;M&&M.classList.remove("hidden")}}):null,s.jsx("span",{className:v.userAvatar?"hidden":"",children:(v.userNickname||v.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:v.userNickname||v.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.userId.slice(0,16),"..."]})]})]})}),s.jsx(je,{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:[v.matchedUserAvatar?s.jsx("img",{src:aa(v.matchedUserAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const M=k.currentTarget.nextElementSibling;M&&M.classList.remove("hidden")}}):null,s.jsx("span",{className:v.matchedUserAvatar?"hidden":"",children:(v.matchedNickname||v.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:v.matchedNickname||v.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[v.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(je,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Ij[v.matchType]||v.matchType})}),s.jsxs(je,{className:"text-gray-400 text-sm",children:[v.phone&&s.jsxs("div",{children:["📱 ",v.phone]}),v.wechatId&&s.jsxs("div",{children:["💬 ",v.wechatId]}),!v.phone&&!v.wechatId&&"-"]}),s.jsx(je,{className:"text-gray-400",children:v.createdAt?new Date(v.createdAt).toLocaleString():"-"})]},v.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(us,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:v=>{c(v),i(1)}})]})})})]})}function hH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0);async function a(){r(!0);try{const i=await Re("/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),G.error("加载 VIP 成员失败")}finally{r(!1)}}return g.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(Kc,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(ke,{className:"text-gray-400",children:"成员"}),s.jsx(ke,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(ke,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(ds,{children:[t.map((i,o)=>{var c;return s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:o+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[i.avatar?s.jsx("img",{src:aa(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(je,{className:"text-gray-300",children:i.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(je,{className:"text-gray-300",children:i.vipSort??o+1})]},i.id)}),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function G4(t){const e=_a(),[n,r]=g.useState([]),[a,i]=g.useState(!0),[o,c]=g.useState(!1),[u,h]=g.useState(null),[f,m]=g.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0,userId:""}),[x,b]=g.useState(!1),[N,w]=g.useState(!1),v=g.useRef(null),k=async O=>{var ae;const X=(ae=O.target.files)==null?void 0:ae[0];if(X){w(!0);try{const _=new FormData;_.append("file",X),_.append("folder","mentors");const se=$u(),ce={};se&&(ce.Authorization=`Bearer ${se}`);const I=await(await fetch(zl("/api/upload"),{method:"POST",body:_,credentials:"include",headers:ce})).json();I!=null&&I.success&&(I!=null&&I.url)?m(Z=>({...Z,avatar:I.url})):G.error("上传失败: "+((I==null?void 0:I.error)||"未知错误"))}catch(_){console.error(_),G.error("上传失败")}finally{w(!1),v.current&&(v.current.value="")}}};async function M(){i(!0);try{const O=await Re("/api/db/mentors");O!=null&&O.success&&O.data&&r(O.data)}catch(O){console.error("Load mentors error:",O)}finally{i(!1)}}g.useEffect(()=>{M()},[]);const E=()=>{m({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:n.length>0?Math.max(...n.map(O=>O.sort))+1:0,enabled:!0,userId:""})},L=()=>{h(null),E(),c(!0)},R=O=>{h(O),m({name:O.name,avatar:O.avatar||"",intro:O.intro||"",tags:O.tags||"",priceSingle:O.priceSingle!=null?String(O.priceSingle):"",priceHalfYear:O.priceHalfYear!=null?String(O.priceHalfYear):"",priceYear:O.priceYear!=null?String(O.priceYear):"",quote:O.quote||"",whyFind:O.whyFind||"",offering:O.offering||"",judgmentStyle:O.judgmentStyle||"",sort:O.sort,enabled:O.enabled??!0,userId:O.userId||""}),c(!0)},W=async()=>{if(!f.name.trim()){G.error("导师姓名不能为空");return}b(!0);try{const O=_=>_===""?void 0:parseFloat(_),X=f.userId.trim(),ae={name:f.name.trim(),avatar:f.avatar.trim()||void 0,intro:f.intro.trim()||void 0,tags:f.tags.trim()||void 0,priceSingle:O(f.priceSingle),priceHalfYear:O(f.priceHalfYear),priceYear:O(f.priceYear),quote:f.quote.trim()||void 0,whyFind:f.whyFind.trim()||void 0,offering:f.offering.trim()||void 0,judgmentStyle:f.judgmentStyle.trim()||void 0,sort:f.sort,enabled:f.enabled};if(u){const _=await Yt("/api/db/mentors",{id:u.id,...ae,userId:X});_!=null&&_.success?(c(!1),M()):G.error("更新失败: "+(_==null?void 0:_.error))}else{const _=await gt("/api/db/mentors",{...ae,userId:X||void 0});_!=null&&_.success?(c(!1),M()):G.error("新增失败: "+(_==null?void 0:_.error))}}catch(O){console.error("Save error:",O),G.error("保存失败")}finally{b(!1)}},P=async O=>{if(confirm("确定删除该导师?"))try{const X=await bi(`/api/db/mentors?id=${O}`);X!=null&&X.success?M():G.error("删除失败: "+(X==null?void 0:X.error))}catch(X){console.error("Delete error:",X),G.error("删除失败")}},B=O=>O!=null?`¥${O}`:"-";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(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表;填写「绑定用户 ID」后,小程序导师详情可跳转「派对会员名片」(与超级个体同页)"})]}),s.jsxs(J,{onClick:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-0",children:a?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"姓名"}),s.jsx(ke,{className:"text-gray-400",children:"简介"}),s.jsx(ke,{className:"text-gray-400",children:"单次"}),s.jsx(ke,{className:"text-gray-400",children:"半年"}),s.jsx(ke,{className:"text-gray-400",children:"年度"}),s.jsx(ke,{className:"text-gray-400",children:"绑定用户"}),s.jsx(ke,{className:"text-gray-400",children:"排序"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ds,{children:[n.map(O=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:O.id}),s.jsx(je,{children:s.jsxs("button",{type:"button",onClick:()=>e(`/users?search=${encodeURIComponent(O.name)}`),className:"text-[#38bdac] hover:text-[#2da396] hover:underline flex items-center gap-1",title:"在用户管理中查看",children:[O.name,s.jsx(Io,{className:"w-3 h-3"})]})}),s.jsx(je,{className:"text-gray-400 max-w-[200px] truncate",children:O.intro||"-"}),s.jsx(je,{className:"text-gray-400",children:B(O.priceSingle)}),s.jsx(je,{className:"text-gray-400",children:B(O.priceHalfYear)}),s.jsx(je,{className:"text-gray-400",children:B(O.priceYear)}),s.jsx(je,{className:"text-gray-400 font-mono text-xs max-w-[120px] truncate",title:O.userId||"",children:O.userId?s.jsx("button",{type:"button",onClick:()=>e(`/users?search=${encodeURIComponent(O.userId||"")}`),className:"text-[#38bdac] hover:underline truncate max-w-[120px] inline-block align-bottom",children:O.userId}):"—"}),s.jsx(je,{className:"text-gray-400",children:O.sort}),s.jsxs(je,{className:"text-right",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>R(O),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Jn,{className:"w-4 h-4"})})]})]},O.id)),n.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:9,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(It,{open:o,onOpenChange:c,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(Rt,{children:s.jsx(Lt,{className:"text-white",children: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(ne,{className:"text-gray-300",children:"姓名 *"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:f.name,onChange:O=>m(X=>({...X,name:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"排序"}),s.jsx(le,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.sort,onChange:O=>m(X=>({...X,sort:parseInt(O.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(le,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:f.avatar,onChange:O=>m(X=>({...X,avatar:O.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:v,type:"file",accept:"image/*",className:"hidden",onChange:k}),s.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:N,onClick:()=>{var O;return(O=v.current)==null?void 0:O.click()},children:[s.jsx(Ef,{className:"w-4 h-4 mr-2"}),N?"上传中...":"上传"]})]}),f.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:aa(f.avatar.startsWith("http")?f.avatar:zl(f.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(ne,{className:"text-gray-300",children:"绑定用户 ID(可选,与名片页一致)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"小程序用户 id,填后导师详情显示「查看派对会员名片」",value:f.userId,onChange:O=>m(X=>({...X,userId:O.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"留空则仅展示导师资料;填写后 C 端可跳转 member-detail 与超级个体同款名片。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"简介"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:f.intro,onChange:O=>m(X=>({...X,intro:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:f.tags,onChange:O=>m(X=>({...X,tags:O.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(ne,{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(ne,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:f.priceSingle,onChange:O=>m(X=>({...X,priceSingle:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:f.priceHalfYear,onChange:O=>m(X=>({...X,priceHalfYear:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(le,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:f.priceYear,onChange:O=>m(X=>({...X,priceYear:O.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"引言"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:f.quote,onChange:O=>m(X=>({...X,quote:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.whyFind,onChange:O=>m(X=>({...X,whyFind:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.offering,onChange:O=>m(X=>({...X,offering:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:f.judgmentStyle,onChange:O=>m(X=>({...X,judgmentStyle:O.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:f.enabled,onChange:O=>m(X=>({...X,enabled:O.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(ne,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(Xt,{children:[s.jsxs(J,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(J,{onClick:W,disabled:x,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"}),x?"保存中...":"保存"]})]})]})})]})}function fH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState("");async function o(){r(!0);try{const h=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",f=await Re(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}g.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(Og,{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(J,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户ID"}),s.jsx(ke,{className:"text-gray-400",children:"导师ID"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ds,{children:[t.map(h=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:h.id}),s.jsx(je,{className:"text-gray-400",children:h.userId}),s.jsx(je,{className:"text-gray-400",children:h.mentorId}),s.jsx(je,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(je,{className:"text-white",children:["¥",h.amount]}),s.jsx(je,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(je,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const iu={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},Rj={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:iu},pH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function mH(){const t=_a(),[e,n]=g.useState(Rj),[r,a]=g.useState(!0),[i,o]=g.useState(!1),[c,u]=g.useState(!1),[h,f]=g.useState(null),[m,x]=g.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[b,N]=g.useState(null),[w,v]=g.useState(!1),k=async()=>{v(!0);try{const O=await Re("/api/db/match-pool-counts");O!=null&&O.success&&O.data&&N(O.data)}catch(O){console.error("加载池子人数失败:",O)}finally{v(!1)}},M=async()=>{a(!0);try{const O=await Re("/api/db/config/full?key=match_config"),X=(O==null?void 0:O.data)??(O==null?void 0:O.config);if(X){let ae=X.poolSettings??iu;ae.poolSource&&!Array.isArray(ae.poolSource)&&(ae={...ae,poolSource:[ae.poolSource]}),n({...Rj,...X,poolSettings:ae})}}catch(O){console.error("加载匹配配置失败:",O)}finally{a(!1)}};g.useEffect(()=>{M(),k()},[]);const E=async()=>{o(!0);try{const O=await gt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});G.error((O==null?void 0:O.success)!==!1?"配置保存成功!":"保存失败: "+((O==null?void 0:O.error)||"未知错误"))}catch(O){console.error(O),G.error("保存失败")}finally{o(!1)}},L=O=>{f(O),x({...O}),u(!0)},R=()=>{f(null),x({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},W=()=>{if(!m.id||!m.label){G.error("请填写类型ID和名称");return}const O=[...e.matchTypes];if(h){const X=O.findIndex(ae=>ae.id===h.id);X!==-1&&(O[X]={...m})}else{if(O.some(X=>X.id===m.id)){G.error("类型ID已存在");return}O.push({...m})}n({...e,matchTypes:O}),u(!1)},P=O=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(X=>X.id!==O)})},B=O=>{n({...e,matchTypes:e.matchTypes.map(X=>X.id===O?{...X,enabled:!X.enabled}:X)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(J,{variant:"outline",onClick:M,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(J,{onClick:E,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(nk,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx(qt,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs(ze,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(ne,{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(O=>{const X=e.poolSettings??iu,_=(Array.isArray(X.poolSource)?X.poolSource:[X.poolSource]).includes(O.value),se=b==null?void 0:b[O.countKey],ce=()=>{const me=Array.isArray(X.poolSource)?[...X.poolSource]:[X.poolSource],I=_?me.filter(Z=>Z!==O.value):[...me,O.value];I.length===0&&I.push(O.value),n({...e,poolSettings:{...X,poolSource:I}})};return s.jsxs("button",{type:"button",onClick:ce,className:`p-4 rounded-lg border text-left transition-all ${_?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[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 ${_?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:_&&"✓"}),s.jsx("span",{className:"text-xl",children:O.icon}),s.jsx("span",{className:`text-sm font-medium ${_?"text-[#38bdac]":"text-gray-300"}`,children:O.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":se??"-",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:O.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:me=>{me.stopPropagation(),t(`/users?pool=${O.value}`)},onKeyDown:me=>{me.key==="Enter"&&(me.stopPropagation(),t(`/users?pool=${O.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},O.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(ne,{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(O=>{const ae=(e.poolSettings??iu)[O.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(Ut,{checked:ae,onCheckedChange:_=>n({...e,poolSettings:{...e.poolSettings??iu,[O.key]:_}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:O.icon}),s.jsx(ne,{className:"text-gray-300 text-sm",children:O.label})]})]},O.key)})})]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Ro,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx(qt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(ze,{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(ne,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(le,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:O=>n({...e,freeMatchLimit:parseInt(O.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(le,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:O=>n({...e,matchPrice:parseFloat(O.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(le,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:O=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(O.target.value,10)||10}})})]})]}),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(Ut,{checked:e.settings.enableFreeMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enableFreeMatches:O}})}),s.jsx(ne,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ut,{checked:e.settings.enablePaidMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enablePaidMatches:O}})}),s.jsx(ne,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs($e,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(it,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ot,{className:"text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(J,{onClick:R,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Mn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(ze,{children:s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"图标"}),s.jsx(ke,{className:"text-gray-400",children:"类型ID"}),s.jsx(ke,{className:"text-gray-400",children:"显示名称"}),s.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),s.jsx(ke,{className:"text-gray-400",children:"价格"}),s.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ds,{children:e.matchTypes.map(O=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx("span",{className:"text-2xl",children:O.icon})}),s.jsx(je,{className:"font-mono text-gray-300",children:O.id}),s.jsx(je,{className:"text-white font-medium",children:O.label}),s.jsx(je,{className:"text-gray-300",children:O.matchLabel}),s.jsx(je,{children:s.jsxs(Ve,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",O.price]})}),s.jsx(je,{children:O.matchFromDB?s.jsx(Ve,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ve,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Ut,{checked:O.enabled,onCheckedChange:()=>B(O.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>L(O),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(pn,{className:"w-4 h-4"})}),s.jsx(J,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Jn,{className:"w-4 h-4"})})]})})]},O.id))})]})})]}),s.jsx(It,{open:c,onOpenChange:u,children:s.jsxs(At,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Rt,{children:s.jsxs(Lt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(pn,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Mn,{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(ne,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:O=>x({...m,id:O.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:pH.map(O=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===O?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>x({...m,icon:O}),children:O},O))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"显示名称"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:O=>x({...m,label:O.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"匹配标签"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:O=>x({...m,matchLabel:O.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ne,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(le,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:O=>x({...m,price:parseFloat(O.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(Ut,{checked:m.matchFromDB,onCheckedChange:O=>x({...m,matchFromDB:O})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ut,{checked:m.showJoinAfterMatch,onCheckedChange:O=>x({...m,showJoinAfterMatch:O})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ut,{checked:m.enabled,onCheckedChange:O=>x({...m,enabled:O})}),s.jsx(ne,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(J,{onClick:W,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const Lj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function xH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(""),[f,m]=g.useState(!0),[x,b]=g.useState(null),[N,w]=g.useState(null);async function v(){m(!0),b(null);try{const E=new URLSearchParams({page:String(a),pageSize:String(o)});u&&E.set("matchType",u);const L=await Re(`/api/db/match-records?${E}`);L!=null&&L.success?(e(L.records||[]),r(L.total??0)):b("加载匹配记录失败")}catch{b("加载失败,请检查网络后重试")}finally{m(!1)}}g.useEffect(()=>{v()},[a,u]);const k=Math.ceil(n/o)||1,M=({userId:E,nickname:L,avatar:R})=>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:[R?s.jsx("img",{src:aa(R),alt:"",className:"w-full h-full object-cover",onError:W=>{W.currentTarget.style.display="none"}}):null,s.jsx("span",{className:R?"hidden":"",children:(L||E||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:L||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:[x&&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:x}),s.jsx("button",{type:"button",onClick:()=>b(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(Lj).map(([E,L])=>s.jsx("option",{value:E,children:L},E))]}),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(He,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ds,{children:[t.map(E=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx(M,{userId:E.userId,nickname:E.userNickname,avatar:E.userAvatar})}),s.jsx(je,{children:E.matchedUserId?s.jsx(M,{userId:E.matchedUserId,nickname:E.matchedNickname,avatar:E.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(je,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Lj[E.matchType]||E.matchType})}),s.jsxs(je,{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(je,{className:"text-gray-400",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"})]},E.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(us,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:E=>{c(E),i(1)}})]})})}),s.jsx(cy,{open:!!N,onClose:()=>w(null),userId:N,onUserUpdated:v})]})}function gH(){const[t,e]=g.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(xH,{}),t==="pool"&&s.jsx(mH,{})]})}const Oj={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function yH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(!0),[f,m]=g.useState("investor"),[x,b]=g.useState(null);async function N(){h(!0);try{const M=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),E=await Re(`/api/db/match-records?${M}`);E!=null&&E.success&&(e(E.records||[]),r(E.total??0))}catch(M){console.error(M)}finally{h(!1)}}g.useEffect(()=>{N()},[a,f]);const w=async M=>{if(!M.phone&&!M.wechatId){G.info("该记录无联系方式,无法推送到存客宝");return}b(M.id);try{const E=await gt("/api/ckb/join",{type:M.matchType||"investor",phone:M.phone||"",wechat:M.wechatId||"",userId:M.userId,name:M.userNickname||""});G.error((E==null?void 0:E.message)||(E!=null&&E.success?"推送成功":"推送失败"))}catch(E){G.error("推送失败: "+(E instanceof Error?E.message:"网络错误"))}finally{b(null)}},v=Math.ceil(n/o)||1,k=M=>!!(M.phone||M.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:M=>{m(M.target.value),i(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(Oj).map(([M,E])=>s.jsx("option",{value:M,children:E},M))}),s.jsxs(J,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"时间"}),s.jsx(ke,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(ds,{children:[t.map(M=>{var E,L;return s.jsxs(ht,{className:`border-gray-700/50 ${k(M)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(je,{className:"text-white",children:M.userNickname||((E=M.userId)==null?void 0:E.slice(0,12))}),s.jsx(je,{className:"text-white",children:M.matchedNickname||((L=M.matchedUserId)==null?void 0:L.slice(0,12))}),s.jsx(je,{children:s.jsx(Ve,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Oj[M.matchType]||M.matchType})}),s.jsxs(je,{className:"text-sm",children:[M.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",M.phone]}),M.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",M.wechatId]}),!M.phone&&!M.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(je,{className:"text-gray-400 text-sm",children:M.createdAt?new Date(M.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-right",children:k(M)?s.jsxs(J,{size:"sm",onClick:()=>w(M),disabled:x===M.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(gA,{className:"w-3 h-3 mr-1"}),x===M.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},M.id)}),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(us,{page:a,totalPages:v,total:n,pageSize:o,onPageChange:i,onPageSizeChange:M=>{c(M),i(1)}})]})})})]})}const Dj={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},bH={single:"单次",half_year:"半年",year:"年度"};function vH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState("");async function o(){r(!0);try{const c=a?`/api/db/mentor-consultations?status=${a}`:"/api/db/mentor-consultations",u=await Re(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return g.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(Dj).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(J,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(ze,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户ID"}),s.jsx(ke,{className:"text-gray-400",children:"导师ID"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ds,{children:[t.map(c=>s.jsxs(ht,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:c.id}),s.jsx(je,{className:"text-gray-400",children:c.userId}),s.jsx(je,{className:"text-gray-400",children:c.mentorId}),s.jsx(je,{className:"text-gray-400",children:bH[c.consultationType]||c.consultationType}),s.jsxs(je,{className:"text-white",children:["¥",c.amount]}),s.jsx(je,{className:"text-gray-400",children:Dj[c.status]||c.status}),s.jsx(je,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function NH(){const[t,e]=g.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(vH,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(G4,{embedded:!0})})]})}function wH(){const[t,e]=g.useState([]),[n,r]=g.useState(0),[a,i]=g.useState(1),[o,c]=g.useState(10),[u,h]=g.useState(!0);async function f(){h(!0);try{const x=new URLSearchParams({page:String(a),pageSize:String(o),matchType:"team"}),b=await Re(`/api/db/match-records?${x}`);b!=null&&b.success&&(e(b.records||[]),r(b.total??0))}catch(x){console.error(x)}finally{h(!1)}}g.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(He,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx($e,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(ze,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(He,{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(ls,{children:[s.jsx(cs,{children:s.jsxs(ht,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(ds,{children:[t.map(x=>s.jsxs(ht,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{className:"text-white",children:x.userNickname||x.userId}),s.jsx(je,{className:"text-white",children:x.matchedNickname||x.matchedUserId}),s.jsxs(je,{className:"text-gray-400 text-sm",children:[x.phone&&s.jsxs("div",{children:["📱 ",x.phone]}),x.wechatId&&s.jsxs("div",{children:["💬 ",x.wechatId]}),!x.phone&&!x.wechatId&&"-"]}),s.jsx(je,{className:"text-gray-400",children:x.createdAt?new Date(x.createdAt).toLocaleString():"-"})]},x.id)),t.length===0&&s.jsx(ht,{children:s.jsx(je,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(us,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:x=>{c(x),i(1)}})]})})})]})}const jH=["partner","investor","mentor","team"],Ag=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],_j=`# 场景获客接口摘要 - 地址:POST /v1/api/scenarios - 必填:apiKey、sign、timestamp - 主标识:phone 或 wechatId 至少一项 - 可选:name、source、remark、tags、siteTags、portrait - 签名:排除 sign/apiKey/portrait,键名升序拼接值后双重 MD5 -- 成功:code=200,message=新增成功 或 已存在`;function yH({initialTab:t="overview"}){const[e,n]=g.useState(t),[r,a]=g.useState("13800000000"),[i,o]=g.useState(""),[c,u]=g.useState(""),[h,f]=g.useState(Dj),[m,x]=g.useState(!1),[b,N]=g.useState(!1),[w,v]=g.useState([]),[k,M]=g.useState([]),[E,L]=g.useState({}),[R,W]=g.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"}]),P=g.useMemo(()=>{const I={};return Mg.forEach(X=>{I[X.key]=E[X.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),I},[E]),B=I=>{const X=r.trim(),V=i.trim();return I<=3?{type:gH[I],phone:X||void 0,wechat:V||void 0,userId:"admin_test",name:"后台测试"}:I===4?{matchType:"partner",phone:X||void 0,wechat:V||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:I===5?{phone:X||void 0,wechatId:V||void 0,userId:"admin_test",name:"后台测试"}:{}};async function O(){N(!0);try{const[I,X,V]=await Promise.all([Re("/api/db/config/full?key=ckb_config"),Re("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Re("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),xe=I==null?void 0:I.data;xe!=null&&xe.routes&&L(xe.routes),xe!=null&&xe.docNotes&&u(xe.docNotes),xe!=null&&xe.docContent&&f(xe.docContent),X!=null&&X.success&&v(X.records||[]),V!=null&&V.success&&M(V.records||[])}finally{N(!1)}}g.useEffect(()=>{n(t)},[t]),g.useEffect(()=>{O()},[]);const Y=g.useMemo(()=>{const I=H=>(H||"").replace(/\D/g,"")||"",X=H=>{const K=I(H.phone);if(K)return`phone:${K}`;const fe=(H.userId||"").trim();if(fe)return`user:${fe}`;const he=(H.wechatId||"").trim();return he?`wechat:${he}`:`row:${H.id}`},V=[...k].sort((H,K)=>{const fe=H.createdAt?new Date(H.createdAt).getTime():0;return(K.createdAt?new Date(K.createdAt).getTime():0)-fe}),xe=new Set,ee=[];for(const H of V){const K=X(H);xe.has(K)||(xe.add(K),ee.push(H))}return ee},[k]);async function ae(){x(!0);try{const I=await xt("/api/db/config",{key:"ckb_config",value:{routes:P,docNotes:c,docContent:h},description:"存客宝接口配置"});G.error((I==null?void 0:I.success)!==!1?"存客宝配置已保存":`保存失败: ${(I==null?void 0:I.error)||"未知错误"}`)}catch(I){G.error(`保存失败: ${I instanceof Error?I.message:"网络错误"}`)}finally{x(!1)}}const _=(I,X)=>{L(V=>({...V,[I]:{...P[I],...X}}))},se=async I=>{const X=R[I];if(X.method==="POST"&&!r.trim()&&!i.trim()){G.error("请填写测试手机号");return}const V=[...R];V[I]={...X,status:"testing",message:void 0,responseTime:void 0},W(V);const xe=performance.now();try{const ee=X.method==="GET"?await Re(X.endpoint):await xt(X.endpoint,B(I)),H=Math.round(performance.now()-xe),K=(ee==null?void 0:ee.message)||"",fe=(ee==null?void 0:ee.success)===!0||K.includes("已存在")||K.includes("已加入")||K.includes("已提交"),he=[...R];he[I]={...X,status:fe?"success":"error",message:K||(fe?"正常":"异常"),responseTime:H},W(he),await O()}catch(ee){const H=Math.round(performance.now()-xe),K=[...R];K[I]={...X,status:"error",message:ee instanceof Error?ee.message:"失败",responseTime:H},W(K)}},ce=async()=>{if(!r.trim()&&!i.trim()){G.error("请填写测试手机号");return}for(let I=0;Is.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:I.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"p-0 align-top",children:s.jsxs("div",{className:"py-14 px-6 text-center bg-[#0a1628]/40 border-t border-gray-700/30",children:[s.jsx($l,{className:"w-12 h-12 text-orange-400/25 mx-auto mb-3","aria-hidden":!0}),s.jsx("p",{className:"text-gray-300 font-medium",children:X}),V?s.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto leading-relaxed",children:V}):null]})})}):I.map(xe=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:xe.userNickname||xe.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:xe.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:xe.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:xe.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:xe.createdAt?new Date(xe.createdAt).toLocaleString():"—"})]},String(xe.id)))})]})});return s.jsx(_e,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs($e,{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(Ve,{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(Io,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(J,{onClick:()=>O(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1 ${b?"animate-spin":""}`})," 刷新"]}),s.jsxs(J,{onClick:ae,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{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(([I,X])=>s.jsx("button",{type:"button",onClick:()=>n(I),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===I?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:X},I))}),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:Y.length}),k.length!==Y.length&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",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:Mg.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"&&s.jsxs("div",{className:"space-y-2",children:[k.length>Y.length&&s.jsxs("p",{className:"text-xs text-gray-500",children:["已合并 ",k.length-Y.length," 条重复(同手机号或同用户 ID 仅保留最近一条)"]}),me(Y,"暂无有联系方式线索","存客宝留资同步后显示;完整列表与筛选请前往「用户管理 → 获客列表」。")]}),e==="config"&&s.jsx("div",{className:"space-y-4",children:Mg.map(I=>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:I.label}),s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:I.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(ne,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiUrl,onChange:X=>_(I.key,{apiUrl:X.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiKey,onChange:X=>_(I.key,{apiKey:X.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].source,onChange:X=>_(I.key,{source:X.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].tags,onChange:X=>_(I.key,{tags:X.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].siteTags,onChange:X=>_(I.key,{siteTags:X.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].notes,onChange:X=>_(I.key,{notes:X.target.value})})]})]})]},I.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($l,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:I=>a(I.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(ne,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:I=>o(I.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(J,{onClick:ce,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(Ro,{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:R.map((I,X)=>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:[I.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),I.status==="testing"&&s.jsx(He,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),I.status==="success"&&s.jsx(Xj,{className:"w-3 h-3 text-green-400 shrink-0"}),I.status==="error"&&s.jsx(ek,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:I.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[I.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[I.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>se(X),disabled:I.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${I.endpoint}-${X}`))})]}),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(Io,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Dj})]}),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:I=>u(I.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const bH=[{id:"partner",label:"找伙伴",icon:Vn,desc:"匹配池与记录"},{id:"resource",label:"资源对接",icon:hM,desc:"人脉资源"},{id:"mentor",label:"导师预约",icon:cM,desc:"预约与管理"},{id:"team",label:"团队招募",icon:Uc,desc:"团队协作"}];function vH(){const[t,e]=g.useState("partner"),[n,r]=g.useState(!1);return s.jsxs("div",{className:"p-8 w-full max-w-7xl mx-auto",children:[s.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-xl font-semibold text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"匹配、获客、导师与团队管理 · 汇总数据见「仪表盘」与「推广中心」"})]}),s.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>r(a=>!a),className:`border-orange-500/30 text-orange-300 hover:bg-orange-500/10 bg-transparent text-xs ${n?"bg-orange-500/10":""}`,children:[s.jsx(Aa,{className:"w-3.5 h-3.5 mr-1.5"}),"存客宝",s.jsx(wi,{className:`w-3 h-3 ml-1 transition-transform ${n?"rotate-90":""}`})]})]}),n&&s.jsx(yH,{initialTab:"overview"}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:bH.map(a=>{const i=t===a.id;return s.jsxs("button",{type:"button",onClick:()=>e(a.id),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${i?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})}),t==="partner"&&s.jsx(uH,{}),t==="resource"&&s.jsx(hH,{}),t==="mentor"&&s.jsx(mH,{}),t==="team"&&s.jsx(xH,{})]})}function NH(){const[t,e]=g.useState(""),n=Ra(t,300),[r,a]=g.useState(1),[i,o]=g.useState(10),[c,u]=g.useState(0),[h,f]=g.useState(1),[m,x]=g.useState([]),[b,N]=g.useState(!1),[w,v]=g.useState(null),[k,M]=g.useState(!1),[E,L]=g.useState(""),[R,W]=g.useState(!1),[P,B]=g.useState(null),O=g.useCallback(async()=>{N(!0),v(null);try{const _=new URLSearchParams;_.set("page",String(r)),_.set("pageSize",String(i)),n.trim()&&_.set("search",n.trim());const se=await Re(`/api/admin/open-platform/keys?${_.toString()}`);if(!se.success){v(se.error||"加载失败"),x([]);return}x(se.records||[]),u(se.total??0),f(se.totalPages??1)}catch(_){v(_ instanceof Error?_.message:"网络错误"),x([])}finally{N(!1)}},[r,i,n]);g.useEffect(()=>{O()},[O]);const Y=async()=>{var _;W(!0);try{const se=await xt("/api/admin/open-platform/keys",{name:E.trim()||"未命名密钥"});if(!se.success||!((_=se.data)!=null&&_.secret)){G.error(se.error||"创建失败");return}M(!1),L(""),B({secret:se.data.secret,name:se.data.name||""}),G.success("密钥已创建,请立即复制保存"),O()}catch(se){G.error(se instanceof Error?se.message:"创建失败")}finally{W(!1)}},ae=async _=>{if(window.confirm("确定吊销该密钥?吊销后无法恢复。"))try{const se=await xt(`/api/admin/open-platform/keys/${_}/revoke`,{});if(!se.success){G.error(se.error||"操作失败");return}G.success("已吊销"),O()}catch(se){G.error(se instanceof Error?se.message:"操作失败")}};return s.jsxs("div",{className:"space-y-4",children:[w&&s.jsx("div",{className:"rounded-lg border border-red-500/40 bg-red-950/40 px-4 py-2 text-sm text-red-200",children:w}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索名称、密钥前缀…",value:t,onChange:_=>{e(_.target.value),a(1)},className:"pl-9 bg-[#0f2137] border-gray-600 text-white placeholder:text-gray-500"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(J,{type:"button",variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>O(),disabled:b,children:[s.jsx(He,{className:`w-4 h-4 mr-1 ${b?"animate-spin":""}`}),"刷新"]}),s.jsxs(J,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>M(!0),children:[s.jsx(Mn,{className:"w-4 h-4 mr-1"}),"新建密钥"]})]})]}),s.jsxs("div",{className:"rounded-xl border border-gray-700/50 overflow-hidden bg-[#0f2137]/80",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/50 text-left text-gray-400",children:[s.jsx("th",{className:"px-4 py-3 font-medium",children:"ID"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"名称"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"密钥前缀"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"创建时间"}),s.jsx("th",{className:"px-4 py-3 font-medium",children:"状态"}),s.jsx("th",{className:"px-4 py-3 font-medium w-28",children:"操作"})]})}),s.jsx("tbody",{children:b&&m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-4 py-12 text-center text-gray-500",children:"加载中…"})}):m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-4 py-12 text-center text-gray-500",children:"暂无密钥,点击「新建密钥」创建"})}):m.map(_=>s.jsxs("tr",{className:"border-b border-gray-700/30 text-gray-200",children:[s.jsx("td",{className:"px-4 py-3 font-mono text-gray-400",children:_.id}),s.jsx("td",{className:"px-4 py-3",children:_.name}),s.jsxs("td",{className:"px-4 py-3 font-mono text-[#38bdac]",children:[_.keyPrefix,"••••••••"]}),s.jsx("td",{className:"px-4 py-3 text-gray-400 text-xs",children:_.createdAt?new Date(_.createdAt).toLocaleString():"—"}),s.jsx("td",{className:"px-4 py-3",children:_.revokedAt?s.jsx("span",{className:"text-red-400",children:"已吊销"}):s.jsx("span",{className:"text-emerald-400/90",children:"有效"})}),s.jsx("td",{className:"px-4 py-3",children:!_.revokedAt&&s.jsxs("button",{type:"button",onClick:()=>ae(_.id),className:"inline-flex items-center gap-1 text-amber-400 hover:text-amber-300 text-xs",children:[s.jsx(bT,{className:"w-3.5 h-3.5"}),"吊销"]})})]},_.id))})]})}),s.jsx(us,{page:r,totalPages:Math.max(1,h),total:c,pageSize:i,onPageChange:a,onPageSizeChange:_=>{o(_),a(1)}})]}),s.jsx(Pt,{open:k,onOpenChange:M,children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-600 text-white max-w-md",children:[s.jsxs(It,{children:[s.jsxs(Rt,{className:"flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-[#38bdac]"}),"新建 API Key"]}),s.jsx(Oo,{className:"text-gray-400",children:"创建后仅本次展示完整密钥,请复制保存至安全位置。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm text-gray-400",children:"名称"}),s.jsx("div",{className:"rounded-lg border border-gray-600 bg-[#0a1628] px-3 py-2",children:s.jsx("input",{className:"w-full bg-transparent text-white text-sm outline-none",placeholder:"例如:合作方 A 生产环境",value:E,onChange:_=>L(_.target.value)})})]}),s.jsxs(Xt,{children:[s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>M(!1),children:"取消"}),s.jsx(J,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:Y,disabled:R,children:R?"创建中…":"创建"})]})]})}),s.jsx(Pt,{open:!!P,onOpenChange:_=>!_&&B(null),children:s.jsxs(Mt,{className:"bg-[#0f2137] border-gray-600 text-white max-w-lg",children:[s.jsxs(It,{children:[s.jsx(Rt,{children:"请保存密钥"}),s.jsxs(Oo,{className:"text-amber-200/90",children:["「",P==null?void 0:P.name,"」的密钥仅此一次显示,关闭后无法再次查看全文。"]})]}),s.jsx("pre",{className:"text-xs break-all p-3 rounded-lg bg-black/40 text-emerald-300 font-mono select-all",children:P==null?void 0:P.secret}),s.jsxs(Xt,{className:"gap-2",children:[s.jsx(J,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>{P!=null&&P.secret&&(navigator.clipboard.writeText(P.secret),G.success("已复制到剪贴板"))},children:"复制密钥"}),s.jsx(J,{variant:"outline",className:"border-gray-600",onClick:()=>B(null),children:"已保存"})]})]})})]})}const wH=[{id:"open-user-profile",title:"按手机号更新测评字段(开放平台)",method:"POST",path:"/api/open/user/profile",summary:"使用管理后台创建的 API Key 调用。按手机号定位用户,仅更新请求体中出现的字段(mbti / disc / pdp);未传的字段不改。需至少传 mbti、disc、pdp 之一。",auth:"Header: Authorization: Bearer op_sk_... 或 X-API-Key: op_sk_...",headers:["Authorization: Bearer {op_sk_完整密钥}","Content-Type: application/json"],requestBody:[{name:"phone",type:"string",required:!0,desc:"用户手机号(与 users.phone 一致)"},{name:"mbti",type:"string",required:!1,desc:"有则写入 users.mbti"},{name:"disc",type:"string",required:!1,desc:"有则写入 users.disc"},{name:"pdp",type:"string",required:!1,desc:"有则写入 users.pdp"}],responseFields:[{name:"success",type:"boolean",desc:""},{name:"data.userId",type:"string",desc:"用户 id"},{name:"data.updated",type:"object",desc:"哪些字段本次被更新(布尔标记)"}],callbackNote:"失败时 success: false,error 为原因(如未找到用户、缺少 API Key)。"}],_j=wH.filter(t=>t.path.startsWith("/api/open"));function Ag({title:t,rows:e}){return e.length?s.jsxs("div",{className:"mt-3",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:t}),s.jsx("div",{className:"rounded-lg border border-gray-700/50 overflow-hidden text-xs",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-black/20 text-gray-400 text-left",children:[s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"字段"}),s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"类型"}),s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"必填"}),s.jsx("th",{className:"px-2 py-1.5 font-medium",children:"说明"})]})}),s.jsx("tbody",{children:e.map(n=>s.jsxs("tr",{className:"border-t border-gray-700/40 text-gray-300",children:[s.jsx("td",{className:"px-2 py-1.5 font-mono text-[#38bdac]/90",children:n.name}),s.jsx("td",{className:"px-2 py-1.5 text-gray-400",children:n.type}),s.jsx("td",{className:"px-2 py-1.5",children:n.required?"是":"否"}),s.jsx("td",{className:"px-2 py-1.5 text-gray-400",children:n.desc})]},n.name))})]})})]}):null}function jH({item:t,open:e,onToggle:n}){const r=t.method==="GET"?"text-emerald-400":t.method==="POST"?"text-amber-400":"text-blue-400";return s.jsxs("div",{className:"rounded-lg border border-gray-700/50 bg-[#0a1628]/60 overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:n,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-gray-800/40 transition-colors",children:[e?s.jsx(Mi,{className:"w-4 h-4 text-gray-500 shrink-0"}):s.jsx(wi,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsx("span",{className:`font-mono text-xs font-semibold shrink-0 ${r}`,children:t.method}),s.jsx("span",{className:"text-sm text-white font-medium truncate flex-1",children:t.title}),s.jsx("code",{className:"text-xs text-gray-500 truncate max-w-[40%] hidden sm:inline",children:t.path})]}),e&&s.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-gray-700/40 space-y-3",children:[s.jsx("p",{className:"text-sm text-gray-400 mt-3",children:t.summary}),s.jsxs("p",{className:"text-xs text-gray-500",children:["鉴权:",s.jsx("span",{className:"text-gray-300",children:t.auth})]}),t.headers&&t.headers.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-gray-500 mb-1",children:"Headers"}),s.jsx("pre",{className:"text-xs text-gray-300 font-mono p-2 rounded bg-black/30 whitespace-pre-wrap",children:t.headers.join(` -`)})]}),s.jsx(Ag,{title:"Query 参数",rows:t.queryParams||[]}),s.jsx(Ag,{title:"请求体字段",rows:t.requestBody||[]}),s.jsx(Ag,{title:"响应/回调字段",rows:t.responseFields||[]}),t.callbackNote&&s.jsx("p",{className:"text-xs text-amber-200/80 border border-amber-500/20 rounded p-2 bg-amber-950/20",children:t.callbackNote})]})]})}function kH(){const[t,e]=g.useState(""),n=Ra(t,300),[r,a]=g.useState(1),[i,o]=g.useState(10),[c,u]=g.useState({});g.useEffect(()=>{a(1)},[n]);const h=g.useMemo(()=>{const w=n.trim().toLowerCase();return w?_j.filter(v=>v.title.toLowerCase().includes(w)||v.path.toLowerCase().includes(w)||v.method.toLowerCase().includes(w)||v.summary.toLowerCase().includes(w)):_j},[n]),f=h.length,m=Math.max(1,Math.ceil(f/i));g.useEffect(()=>{a(w=>Math.min(w,m))},[m]);const x=(r-1)*i,b=h.slice(x,x+i),N=w=>{u(v=>({...v,[w]:!v[w]}))};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"relative max-w-md",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索接口标题、路径、说明…",value:t,onChange:w=>{e(w.target.value),a(1)},className:"pl-9 bg-[#0f2137] border-gray-600 text-white placeholder:text-gray-500"})]}),s.jsx("div",{className:"space-y-2",children:b.length===0?s.jsx("p",{className:"text-gray-500 text-sm py-8 text-center",children:"无匹配接口,请调整关键词"}):b.map(w=>s.jsx(jH,{item:w,open:!!c[w.id],onToggle:()=>N(w.id)},w.id))}),s.jsx(us,{page:r,totalPages:m,total:f,pageSize:i,onPageChange:a,onPageSizeChange:w=>{o(w),a(1)}})]})}function SH(){const[t,e]=g.useState(""),n=Ra(t,300),[r,a]=g.useState(1),[i,o]=g.useState(10),[c,u]=g.useState(0),[h,f]=g.useState(1),[m,x]=g.useState([]),[b,N]=g.useState(!1),[w,v]=g.useState(null),[k,M]=g.useState({}),E=g.useCallback(async()=>{N(!0),v(null);try{const R=new URLSearchParams;R.set("page",String(r)),R.set("pageSize",String(i)),n.trim()&&R.set("search",n.trim());const W=await Re(`/api/admin/open-platform/logs?${R.toString()}`);if(!W.success){v(W.error||"加载失败"),x([]);return}x(W.records||[]),u(W.total??0),f(W.totalPages??1)}catch(R){v(R instanceof Error?R.message:"网络错误"),x([])}finally{N(!1)}},[r,i,n]);g.useEffect(()=>{E()},[E]);const L=R=>{M(W=>({...W,[R]:!W[R]}))};return s.jsxs("div",{className:"space-y-4",children:[w&&s.jsx("div",{className:"rounded-lg border border-red-500/40 bg-red-950/40 px-4 py-2 text-sm text-red-200",children:w}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(le,{placeholder:"搜索路径、方法、IP、请求/响应片段…",value:t,onChange:R=>{e(R.target.value),a(1)},className:"pl-9 bg-[#0f2137] border-gray-600 text-white placeholder:text-gray-500"})]}),s.jsxs("button",{type:"button",onClick:()=>E(),disabled:b,className:"inline-flex items-center gap-1 px-3 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 text-sm",children:[s.jsx(He,{className:`w-4 h-4 ${b?"animate-spin":""}`}),"刷新"]})]}),s.jsxs("div",{className:"rounded-xl border border-gray-700/50 overflow-hidden bg-[#0f2137]/80",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm min-w-[960px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700/50 text-left text-gray-400",children:[s.jsx("th",{className:"px-2 py-2 w-10"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"时间"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"方法"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"路径"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"状态"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"耗时"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"IP"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"密钥前缀"})]})}),s.jsx("tbody",{children:b&&m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500",children:"加载中…"})}):m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500",children:"暂无请求记录。开放网关写入日志后将在此展示。"})}):m.map(R=>s.jsxs(g.Fragment,{children:[s.jsxs("tr",{className:"border-b border-gray-700/30 align-top text-gray-200",children:[s.jsx("td",{className:"px-2 py-2",children:s.jsx("button",{type:"button",onClick:()=>L(R.id),className:"p-1 rounded hover:bg-gray-700/50 text-gray-400","aria-label":"展开明细",children:k[R.id]?s.jsx(Mi,{className:"w-4 h-4"}):s.jsx(wi,{className:"w-4 h-4"})})}),s.jsx("td",{className:"px-3 py-2 text-xs text-gray-400 whitespace-nowrap",children:R.createdAt?new Date(R.createdAt).toLocaleString():"—"}),s.jsx("td",{className:"px-3 py-2 font-mono text-emerald-400",children:R.method||"—"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-[#38bdac] break-all max-w-[280px]",children:R.path||"—"}),s.jsx("td",{className:"px-3 py-2",children:R.statusCode}),s.jsxs("td",{className:"px-3 py-2",children:[R.durationMs," ms"]}),s.jsx("td",{className:"px-3 py-2 text-xs text-gray-400",children:R.clientIp||"—"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-400",children:R.keyPrefix||"—"})]}),k[R.id]&&s.jsx("tr",{className:"border-b border-gray-700/30 bg-[#0a1628]/80",children:s.jsx("td",{colSpan:8,className:"px-4 py-3",children:s.jsxs("div",{className:"grid gap-3 md:grid-cols-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 mb-1",children:"请求体 / 参数片段"}),s.jsx("pre",{className:"text-green-400/85 font-mono p-2 rounded bg-black/40 overflow-x-auto max-h-48 whitespace-pre-wrap",children:R.requestBody||"—"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 mb-1",children:"响应 / 回调片段"}),s.jsx("pre",{className:"text-amber-200/75 font-mono p-2 rounded bg-black/40 overflow-x-auto max-h-48 whitespace-pre-wrap",children:R.responseBody||"—"})]})]})})})]},R.id))})]})}),s.jsx(us,{page:r,totalPages:Math.max(1,h),total:c,pageSize:i,onPageChange:a,onPageSizeChange:R=>{o(R),a(1)}})]})]})}function CH(){return s.jsxs("div",{className:"p-8 w-full bg-[#0a1628] text-white min-h-full",children:[s.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 开放平台"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["管理第三方访问密钥;接口文档仅收录 ",s.jsx("code",{className:"text-[#38bdac]",children:"/api/open"})," 前缀的开放能力;小程序等 C 端接口见「管理端内部 API 文档」。请求明细见日志 Tab。"]})]}),s.jsxs(Si,{to:"/api-docs",className:"text-sm text-[#38bdac] hover:underline inline-flex items-center gap-1 shrink-0",children:[s.jsx(Aa,{className:"w-4 h-4"}),"管理端内部 API 文档"]})]}),s.jsxs(Vl,{defaultValue:"keys",className:"w-full",children:[s.jsxs(Do,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1 flex flex-wrap h-auto gap-1",children:[s.jsxs(Bt,{value:"keys",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(Nu,{className:"w-4 h-4 mr-1.5 inline"}),"API Key"]}),s.jsxs(Bt,{value:"docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(G0,{className:"w-4 h-4 mr-1.5 inline"}),"接口文档"]}),s.jsxs(Bt,{value:"logs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(rk,{className:"w-4 h-4 mr-1.5 inline"}),"请求明细"]})]}),s.jsx(Vt,{value:"keys",className:"mt-0 outline-none",children:s.jsx(NH,{})}),s.jsx(Vt,{value:"docs",className:"mt-0 outline-none",children:s.jsx(kH,{})}),s.jsx(Vt,{value:"logs",className:"mt-0 outline-none",children:s.jsx(SH,{})})]})]})}function EH(){const t=Vo();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(Yj,{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(J,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(Si,{to:"/",children:[s.jsx(NM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function TH(){return s.jsxs(XE,{children:[s.jsx(en,{path:"/login",element:s.jsx(nI,{})}),s.jsxs(en,{path:"/",element:s.jsx(aP,{}),children:[s.jsx(en,{index:!0,element:s.jsx($h,{to:"/dashboard",replace:!0})}),s.jsx(en,{path:"dashboard",element:s.jsx(m8,{})}),s.jsx(en,{path:"orders",element:s.jsx(x8,{})}),s.jsx(en,{path:"users",element:s.jsx(S8,{})}),s.jsx(en,{path:"distribution",element:s.jsx(q8,{})}),s.jsx(en,{path:"withdrawals",element:s.jsx(G8,{})}),s.jsx(en,{path:"content",element:s.jsx(TV,{})}),s.jsx(en,{path:"referral-settings",element:s.jsx(U2,{})}),s.jsx(en,{path:"author-settings",element:s.jsx($h,{to:"/settings?tab=author",replace:!0})}),s.jsx(en,{path:"vip-roles",element:s.jsx(iH,{})}),s.jsx(en,{path:"mentors",element:s.jsx(G4,{})}),s.jsx(en,{path:"mentor-consultations",element:s.jsx(oH,{})}),s.jsx(en,{path:"admin-users",element:s.jsx($h,{to:"/settings?tab=admin",replace:!0})}),s.jsx(en,{path:"settings",element:s.jsx(QV,{})}),s.jsx(en,{path:"payment",element:s.jsx(YV,{})}),s.jsx(en,{path:"site",element:s.jsx(tH,{})}),s.jsx(en,{path:"qrcodes",element:s.jsx(nH,{})}),s.jsx(en,{path:"find-partner",element:s.jsx(vH,{})}),s.jsx(en,{path:"match",element:s.jsx(rH,{})}),s.jsx(en,{path:"match-records",element:s.jsx(aH,{})}),s.jsx(en,{path:"api-doc",element:s.jsx($h,{to:"/api-docs",replace:!0})}),s.jsx(en,{path:"api-docs",element:s.jsx(q4,{})}),s.jsx(en,{path:"open-platform",element:s.jsx(CH,{})})]}),s.jsx(en,{path:"*",element:s.jsx(EH,{})})]})}sE.createRoot(document.getElementById("root")).render(s.jsx(g.StrictMode,{children:s.jsx(iT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(TH,{})})})); +- 成功:code=200,message=新增成功 或 已存在`;function kH({initialTab:t="overview"}){const[e,n]=g.useState(t),[r,a]=g.useState("13800000000"),[i,o]=g.useState(""),[c,u]=g.useState(""),[h,f]=g.useState(_j),[m,x]=g.useState(!1),[b,N]=g.useState(!1),[w,v]=g.useState([]),[k,M]=g.useState([]),[E,L]=g.useState({}),[R,W]=g.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"}]),P=g.useMemo(()=>{const I={};return Ag.forEach(Z=>{I[Z.key]=E[Z.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),I},[E]),B=I=>{const Z=r.trim(),V=i.trim();return I<=3?{type:jH[I],phone:Z||void 0,wechat:V||void 0,userId:"admin_test",name:"后台测试"}:I===4?{matchType:"partner",phone:Z||void 0,wechat:V||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:I===5?{phone:Z||void 0,wechatId:V||void 0,userId:"admin_test",name:"后台测试"}:{}};async function O(){N(!0);try{const[I,Z,V]=await Promise.all([Re("/api/db/config/full?key=ckb_config"),Re("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Re("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),xe=I==null?void 0:I.data;xe!=null&&xe.routes&&L(xe.routes),xe!=null&&xe.docNotes&&u(xe.docNotes),xe!=null&&xe.docContent&&f(xe.docContent),Z!=null&&Z.success&&v(Z.records||[]),V!=null&&V.success&&M(V.records||[])}finally{N(!1)}}g.useEffect(()=>{n(t)},[t]),g.useEffect(()=>{O()},[]);const X=g.useMemo(()=>{const I=H=>(H||"").replace(/\D/g,"")||"",Z=H=>{const K=I(H.phone);if(K)return`phone:${K}`;const fe=(H.userId||"").trim();if(fe)return`user:${fe}`;const he=(H.wechatId||"").trim();return he?`wechat:${he}`:`row:${H.id}`},V=[...k].sort((H,K)=>{const fe=H.createdAt?new Date(H.createdAt).getTime():0;return(K.createdAt?new Date(K.createdAt).getTime():0)-fe}),xe=new Set,ee=[];for(const H of V){const K=Z(H);xe.has(K)||(xe.add(K),ee.push(H))}return ee},[k]);async function ae(){x(!0);try{const I=await gt("/api/db/config",{key:"ckb_config",value:{routes:P,docNotes:c,docContent:h},description:"存客宝接口配置"});G.error((I==null?void 0:I.success)!==!1?"存客宝配置已保存":`保存失败: ${(I==null?void 0:I.error)||"未知错误"}`)}catch(I){G.error(`保存失败: ${I instanceof Error?I.message:"网络错误"}`)}finally{x(!1)}}const _=(I,Z)=>{L(V=>({...V,[I]:{...P[I],...Z}}))},se=async I=>{const Z=R[I];if(Z.method==="POST"&&!r.trim()&&!i.trim()){G.error("请填写测试手机号");return}const V=[...R];V[I]={...Z,status:"testing",message:void 0,responseTime:void 0},W(V);const xe=performance.now();try{const ee=Z.method==="GET"?await Re(Z.endpoint):await gt(Z.endpoint,B(I)),H=Math.round(performance.now()-xe),K=(ee==null?void 0:ee.message)||"",fe=(ee==null?void 0:ee.success)===!0||K.includes("已存在")||K.includes("已加入")||K.includes("已提交"),he=[...R];he[I]={...Z,status:fe?"success":"error",message:K||(fe?"正常":"异常"),responseTime:H},W(he),await O()}catch(ee){const H=Math.round(performance.now()-xe),K=[...R];K[I]={...Z,status:"error",message:ee instanceof Error?ee.message:"失败",responseTime:H},W(K)}},ce=async()=>{if(!r.trim()&&!i.trim()){G.error("请填写测试手机号");return}for(let I=0;Is.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:I.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"p-0 align-top",children:s.jsxs("div",{className:"py-14 px-6 text-center bg-[#0a1628]/40 border-t border-gray-700/30",children:[s.jsx($l,{className:"w-12 h-12 text-orange-400/25 mx-auto mb-3","aria-hidden":!0}),s.jsx("p",{className:"text-gray-300 font-medium",children:Z}),V?s.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto leading-relaxed",children:V}):null]})})}):I.map(xe=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:xe.userNickname||xe.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:xe.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:xe.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:xe.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:xe.createdAt?new Date(xe.createdAt).toLocaleString():"—"})]},String(xe.id)))})]})});return s.jsx($e,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs(ze,{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(Ve,{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(Io,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(J,{onClick:()=>O(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(He,{className:`w-3.5 h-3.5 mr-1 ${b?"animate-spin":""}`})," 刷新"]}),s.jsxs(J,{onClick:ae,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(kn,{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(([I,Z])=>s.jsx("button",{type:"button",onClick:()=>n(I),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===I?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:Z},I))}),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:X.length}),k.length!==X.length&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",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:Ag.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"&&s.jsxs("div",{className:"space-y-2",children:[k.length>X.length&&s.jsxs("p",{className:"text-xs text-gray-500",children:["已合并 ",k.length-X.length," 条重复(同手机号或同用户 ID 仅保留最近一条)"]}),me(X,"暂无有联系方式线索","存客宝留资同步后显示;完整列表与筛选请前往「用户管理 → 获客列表」。")]}),e==="config"&&s.jsx("div",{className:"space-y-4",children:Ag.map(I=>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:I.label}),s.jsx(Ve,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:I.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(ne,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiUrl,onChange:Z=>_(I.key,{apiUrl:Z.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiKey,onChange:Z=>_(I.key,{apiKey:Z.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].source,onChange:Z=>_(I.key,{source:Z.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].tags,onChange:Z=>_(I.key,{tags:Z.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].siteTags,onChange:Z=>_(I.key,{siteTags:Z.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(le,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].notes,onChange:Z=>_(I.key,{notes:Z.target.value})})]})]})]},I.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($l,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(ne,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:I=>a(I.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(ne,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(le,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:I=>o(I.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(J,{onClick:ce,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(Ro,{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:R.map((I,Z)=>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:[I.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),I.status==="testing"&&s.jsx(He,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),I.status==="success"&&s.jsx(Xj,{className:"w-3 h-3 text-green-400 shrink-0"}),I.status==="error"&&s.jsx(ek,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:I.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[I.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[I.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>se(Z),disabled:I.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${I.endpoint}-${Z}`))})]}),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(Io,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||_j})]}),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:I=>u(I.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const SH=[{id:"partner",label:"找伙伴",icon:Vn,desc:"匹配池与记录"},{id:"resource",label:"资源对接",icon:hM,desc:"人脉资源"},{id:"mentor",label:"导师预约",icon:cM,desc:"预约与管理"},{id:"team",label:"团队招募",icon:Uc,desc:"团队协作"}];function CH(){const[t,e]=g.useState("partner"),[n,r]=g.useState(!1);return s.jsxs("div",{className:"p-8 w-full max-w-7xl mx-auto",children:[s.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-xl font-semibold text-white flex items-center gap-2",children:[s.jsx(Vn,{className:"w-5 h-5 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"匹配、获客、导师与团队管理 · 汇总数据见「仪表盘」与「推广中心」"})]}),s.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>r(a=>!a),className:`border-orange-500/30 text-orange-300 hover:bg-orange-500/10 bg-transparent text-xs ${n?"bg-orange-500/10":""}`,children:[s.jsx(Aa,{className:"w-3.5 h-3.5 mr-1.5"}),"存客宝",s.jsx(wi,{className:`w-3 h-3 ml-1 transition-transform ${n?"rotate-90":""}`})]})]}),n&&s.jsx(kH,{initialTab:"overview"}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:SH.map(a=>{const i=t===a.id;return s.jsxs("button",{type:"button",onClick:()=>e(a.id),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-sm transition-all ${i?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})}),t==="partner"&&s.jsx(gH,{}),t==="resource"&&s.jsx(yH,{}),t==="mentor"&&s.jsx(NH,{}),t==="team"&&s.jsx(wH,{})]})}function EH(){const t=Vo();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(Yj,{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(J,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(Po,{to:"/",children:[s.jsx(NM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function TH(){return s.jsxs(XE,{children:[s.jsx(tn,{path:"/login",element:s.jsx(nI,{})}),s.jsxs(tn,{path:"/",element:s.jsx(aP,{}),children:[s.jsx(tn,{index:!0,element:s.jsx(qd,{to:"/dashboard",replace:!0})}),s.jsx(tn,{path:"dashboard",element:s.jsx(m8,{})}),s.jsx(tn,{path:"orders",element:s.jsx(x8,{})}),s.jsx(tn,{path:"users",element:s.jsx(S8,{})}),s.jsx(tn,{path:"distribution",element:s.jsx(q8,{})}),s.jsx(tn,{path:"withdrawals",element:s.jsx(G8,{})}),s.jsx(tn,{path:"content",element:s.jsx(TV,{})}),s.jsx(tn,{path:"referral-settings",element:s.jsx(U2,{})}),s.jsx(tn,{path:"author-settings",element:s.jsx(qd,{to:"/settings?tab=author",replace:!0})}),s.jsx(tn,{path:"vip-roles",element:s.jsx(hH,{})}),s.jsx(tn,{path:"mentors",element:s.jsx(G4,{})}),s.jsx(tn,{path:"mentor-consultations",element:s.jsx(fH,{})}),s.jsx(tn,{path:"admin-users",element:s.jsx(qd,{to:"/settings?tab=admin",replace:!0})}),s.jsx(tn,{path:"settings",element:s.jsx(nH,{})}),s.jsx(tn,{path:"payment",element:s.jsx(sH,{})}),s.jsx(tn,{path:"site",element:s.jsx(oH,{})}),s.jsx(tn,{path:"qrcodes",element:s.jsx(lH,{})}),s.jsx(tn,{path:"find-partner",element:s.jsx(CH,{})}),s.jsx(tn,{path:"match",element:s.jsx(dH,{})}),s.jsx(tn,{path:"match-records",element:s.jsx(uH,{})}),s.jsx(tn,{path:"api-doc",element:s.jsx(qd,{to:"/api-docs",replace:!0})}),s.jsx(tn,{path:"api-docs",element:s.jsx(q4,{})}),s.jsx(tn,{path:"open-platform",element:s.jsx(qd,{to:"/settings?tab=open-platform",replace:!0})})]}),s.jsx(tn,{path:"*",element:s.jsx(EH,{})})]})}sE.createRoot(document.getElementById("root")).render(s.jsx(g.StrictMode,{children:s.jsx(iT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(TH,{})})})); diff --git a/soul-admin/dist/assets/index-CuUAjfcM.css b/soul-admin/dist/assets/index-CuUAjfcM.css deleted file mode 100644 index 70994702..00000000 --- a/soul-admin/dist/assets/index-CuUAjfcM.css +++ /dev/null @@ -1 +0,0 @@ -.rich-editor-wrapper{border:1px solid #374151;border-radius:.5rem;background:#0a1628;overflow:hidden}.rich-editor-toolbar{display:flex;align-items:center;gap:2px;padding:6px 8px;border-bottom:1px solid #374151;background:#0f1d32;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:1px}.toolbar-divider{width:1px;height:20px;background:#374151;margin:0 4px}.rich-editor-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer;transition:all .15s}.rich-editor-toolbar button:hover{background:#1f2937;color:#d1d5db}.rich-editor-toolbar button.is-active{background:#38bdac33;color:#38bdac}.rich-editor-toolbar button:disabled{opacity:.3;cursor:not-allowed}.link-tag-select{background:#0a1628;border:1px solid #374151;color:#d1d5db;font-size:12px;padding:2px 6px;border-radius:4px;cursor:pointer;max-width:160px}.link-input-bar{display:flex;align-items:center;gap:4px;padding:4px 8px;border-bottom:1px solid #374151;background:#0f1d32}.link-input{flex:1;background:#0a1628;border:1px solid #374151;color:#fff;padding:4px 8px;border-radius:4px;font-size:13px}.link-confirm,.link-remove{padding:4px 10px;border-radius:4px;border:none;font-size:12px;cursor:pointer}.link-confirm{background:#38bdac;color:#fff}.link-remove{background:#374151;color:#9ca3af}.rich-editor-content{min-height:450px;max-height:720px;overflow-y:auto;padding:12px 16px;color:#e5e7eb;font-size:14px;line-height:1.7}.rich-editor-content:focus{outline:none}.rich-editor-content h1{font-size:1.5em;font-weight:700;margin:.8em 0 .4em;color:#fff}.rich-editor-content h2{font-size:1.3em;font-weight:600;margin:.7em 0 .3em;color:#fff}.rich-editor-content h3{font-size:1.15em;font-weight:600;margin:.6em 0 .3em;color:#fff}.rich-editor-content p{margin:.4em 0}.rich-editor-content strong{color:#fff}.rich-editor-content code{background:#1f2937;padding:2px 6px;border-radius:3px;font-size:.9em;color:#38bdac}.rich-editor-content pre{background:#1f2937;padding:12px;border-radius:6px;overflow-x:auto;margin:.6em 0}.rich-editor-content blockquote{border-left:3px solid #38bdac;padding-left:12px;margin:.6em 0;color:#9ca3af}.rich-editor-content ul,.rich-editor-content ol{padding-left:1.5em;margin:.4em 0}.rich-editor-content li{margin:.2em 0}.rich-editor-content hr{border:none;border-top:1px solid #374151;margin:1em 0}.rich-editor-content img,.rich-editor-content .ProseMirror img,.rich-editor-content img.rich-editor-img-thumb{max-width:240px!important;max-height:140px!important;width:auto!important;height:auto!important;object-fit:contain;display:inline-block;vertical-align:middle;border-radius:6px;margin:.35em .25em .35em 0;border:1px dashed rgba(56,189,172,.45);background:#0f172a99;box-sizing:border-box}.rich-editor-content .rich-attachment-line{margin:.5em 0;padding:8px 12px;border-radius:8px;border:1px dashed rgba(125,211,252,.35);background:#0f172a8c;font-size:13px;line-height:1.5}.rich-editor-content .rich-attachment-badge{display:inline-block;font-size:10px;font-weight:600;letter-spacing:.02em;padding:2px 8px;border-radius:4px;background:#38bdac38;color:#38bdac;margin-right:8px;vertical-align:middle}.rich-editor-content .rich-attachment-link{color:#7dd3fc!important;font-weight:500;text-decoration:underline;word-break:break-all}.rich-editor-content .rich-video-wrap{display:block;margin:.5em 0;max-width:280px;border:1px dashed rgba(56,189,172,.45);border-radius:8px;overflow:hidden;background:#0f172acc}.rich-editor-content .rich-video-wrap video{display:block;width:100%;max-height:160px;object-fit:contain;vertical-align:middle}.rich-editor-content .rich-video-caption{font-size:11px;color:#6b7280;padding:4px 8px;border-top:1px solid #374151}.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{display:inline;background:#ffd7001f;color:gold;border-radius:4px;padding:1px 4px;font-weight:500;cursor:default;-webkit-user-select:all;user-select:all;white-space:nowrap}.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-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--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-amber-950:oklch(27.9% .077 45.635);--color-yellow-300:oklch(90.5% .182 98.111);--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-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-cyan-200:oklch(91.7% .08 205.041);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-sky-500:oklch(68.5% .169 237.323);--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-blue-600:oklch(54.6% .245 262.881);--color-violet-300:oklch(81.1% .111 293.571);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--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-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-6xl:72rem;--container-7xl:80rem;--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-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-snug:1.375;--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;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)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-2{top:calc(var(--spacing)*2)}.top-3{top:calc(var(--spacing)*3)}.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%}.bottom-2{bottom:calc(var(--spacing)*2)}.-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-\[-13px\]{left:-13px}.left-\[11px\]{left:11px}.left-\[50\%\]{left:50%}.isolate{isolation:isolate}.isolation-auto{isolation:auto}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.col-span-3{grid-column:span 3/span 3}.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-1{margin-inline:calc(var(--spacing)*1)}.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-0\.5{margin-right:calc(var(--spacing)*.5)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-auto{margin-right:auto}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.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-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-\[52px\]{margin-left:52px}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.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-2\.5{height:calc(var(--spacing)*2.5)}.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-11{height:calc(var(--spacing)*11)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-40{height:calc(var(--spacing)*40)}.h-96{height:calc(var(--spacing)*96)}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[92vh\]{max-height:92vh}.max-h-\[120px\]{max-height:120px}.max-h-\[160px\]{max-height:160px}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[450px\]{max-height:450px}.max-h-\[520px\]{max-height:520px}.max-h-\[min\(60vh\,320px\)\]{max-height:min(60vh,320px)}.max-h-\[min\(280px\,40vh\)\]{max-height:min(280px,40vh)}.max-h-none{max-height:none}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-8{min-height:calc(var(--spacing)*8)}.min-h-\[28px\]{min-height:28px}.min-h-\[40px\]{min-height:40px}.min-h-\[60px\]{min-height:60px}.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-\[140px\]{min-height:140px}.min-h-\[260px\]{min-height:260px}.min-h-\[280px\]{min-height:280px}.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-2\.5{width:calc(var(--spacing)*2.5)}.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-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.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-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-\[5\.5rem\]{width:5.5rem}.w-\[8\%\]{width:8%}.w-\[10\%\]{width:10%}.w-\[11\%\]{width:11%}.w-\[13\%\]{width:13%}.w-\[14\%\]{width:14%}.w-\[19\%\]{width:19%}.w-\[25\%\]{width:25%}.w-\[72px\]{width:72px}.w-\[100px\]{width:100px}.w-\[280px\]{width:280px}.w-\[min\(100vw-2rem\,42rem\)\]{width:min(100vw - 2rem,42rem)}.w-fit{width:fit-content}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-7xl{max-width:var(--container-7xl)}.max-w-\[40\%\]{max-width:40%}.max-w-\[72px\]{max-width:72px}.max-w-\[96px\]{max-width:96px}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[140px\]{max-width:140px}.max-w-\[160px\]{max-width:160px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[220px\]{max-width:220px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[420px\]{max-width:420px}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-\[min\(100\%\,20rem\)\]{max-width:min(100%,20rem)}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-40{min-width:calc(var(--spacing)*40)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[60px\]{min-width:60px}.min-w-\[88px\]{min-width:88px}.min-w-\[108px\]{min-width:108px}.min-w-\[120px\]{min-width:120px}.min-w-\[148px\]{min-width:148px}.min-w-\[168px\]{min-width:168px}.min-w-\[200px\]{min-width:200px}.min-w-\[220px\]{min-width:220px}.min-w-\[960px\]{min-width:960px}.min-w-\[1024px\]{min-width:1024px}.min-w-\[1320px\]{min-width:1320px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.table-fixed{table-layout:fixed}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-90{--tw-scale-x:90%;--tw-scale-y:90%;--tw-scale-z:90%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-3d{scale:var(--tw-scale-x)var(--tw-scale-y)var(--tw-scale-z)}.scale-\[0\.98\]{scale:.98}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-pan-y{--tw-pan-y:pan-y;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.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}.list-none{list-style-type:none}.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-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-\[40px_1fr_90px_90px_70px_60px_110px\]{grid-template-columns:40px 1fr 90px 90px 70px 60px 110px}.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-nowrap{flex-wrap:nowrap}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.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-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.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-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*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-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-y-contain{overscroll-behavior-y:contain}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[\#0f2137\]{border-color:#0f2137}.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\]\/25{border-color:#38bdac40}.border-\[\#38bdac\]\/30{border-color:#38bdac4d}.border-\[\#38bdac\]\/35{border-color:#38bdac59}.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\/25{border-color:#f99c0040}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/25{border-color:color-mix(in oklab,var(--color-amber-500)25%,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-amber-600{border-color:var(--color-amber-600)}.border-amber-600\/60{border-color:#dd740099}@supports (color:color-mix(in lab,red,red)){.border-amber-600\/60{border-color:color-mix(in oklab,var(--color-amber-600)60%,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\/20{border-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/20{border-color:color-mix(in oklab,var(--color-cyan-500)20%,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-cyan-600\/60{border-color:#0092b599}@supports (color:color-mix(in lab,red,red)){.border-cyan-600\/60{border-color:color-mix(in oklab,var(--color-cyan-600)60%,transparent)}}.border-emerald-500\/30{border-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/30{border-color:color-mix(in oklab,var(--color-emerald-500)30%,transparent)}}.border-emerald-500\/50{border-color:#00bb7f80}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/50{border-color:color-mix(in oklab,var(--color-emerald-500)50%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-600\/50{border-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.border-gray-600\/50{border-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.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-gray-700\/80{border-color:#364153cc}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/80{border-color:color-mix(in oklab,var(--color-gray-700)80%,transparent)}}.border-gray-800{border-color:var(--color-gray-800)}.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\/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-purple-500\/50{border-color:#ac4bff80}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/50{border-color:color-mix(in oklab,var(--color-purple-500)50%,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\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-600\/40{border-color:#e4001466}@supports (color:color-mix(in lab,red,red)){.border-red-600\/40{border-color:color-mix(in oklab,var(--color-red-600)40%,transparent)}}.border-red-600\/50{border-color:#e4001480}@supports (color:color-mix(in lab,red,red)){.border-red-600\/50{border-color:color-mix(in oklab,var(--color-red-600)50%,transparent)}}.border-red-600\/60{border-color:#e4001499}@supports (color:color-mix(in lab,red,red)){.border-red-600\/60{border-color:color-mix(in oklab,var(--color-red-600)60%,transparent)}}.border-red-600\/70{border-color:#e40014b3}@supports (color:color-mix(in lab,red,red)){.border-red-600\/70{border-color:color-mix(in oklab,var(--color-red-600)70%,transparent)}}.border-red-900\/60{border-color:#82181a99}@supports (color:color-mix(in lab,red,red)){.border-red-900\/60{border-color:color-mix(in oklab,var(--color-red-900)60%,transparent)}}.border-sky-500\/30{border-color:#00a5ef4d}@supports (color:color-mix(in lab,red,red)){.border-sky-500\/30{border-color:color-mix(in oklab,var(--color-sky-500)30%,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\/35{border-color:#edb20059}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/35{border-color:color-mix(in oklab,var(--color-yellow-500)35%,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\]\/30{background-color:#0a16284d}.bg-\[\#0a1628\]\/40{background-color:#0a162866}.bg-\[\#0a1628\]\/50{background-color:#0a162880}.bg-\[\#0a1628\]\/60{background-color:#0a162899}.bg-\[\#0a1628\]\/80{background-color:#0a1628cc}.bg-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#0f2137\]\/80{background-color:#0f2137cc}.bg-\[\#0f2137\]\/90{background-color:#0f2137e6}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#3a1010\]\/35{background-color:#3a101059}.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\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#081322\]{background-color:#081322}.bg-\[\#162840\]{background-color:#162840}.bg-\[\#162840\]\/80{background-color:#162840cc}.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-amber-950\/20{background-color:#46190133}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/20{background-color:color-mix(in oklab,var(--color-amber-950)20%,transparent)}}.bg-amber-950\/25{background-color:#46190140}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/25{background-color:color-mix(in oklab,var(--color-amber-950)25%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab,red,red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.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{background-color:var(--color-blue-500)}.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\/15{background-color:#00b7d726}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/15{background-color:color-mix(in oklab,var(--color-cyan-500)15%,transparent)}}.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\/10{background-color:#00bb7f1a}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/10{background-color:color-mix(in oklab,var(--color-emerald-500)10%,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-emerald-600{background-color:var(--color-emerald-600)}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/10{background-color:#6a72821a}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/10{background-color:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-600\/20{background-color:#4a556533}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/20{background-color:color-mix(in oklab,var(--color-gray-600)20%,transparent)}}.bg-gray-600\/50{background-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/50{background-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.bg-gray-700{background-color:var(--color-gray-700)}.bg-gray-700\/50{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.bg-gray-700\/50{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.bg-gray-800{background-color:var(--color-gray-800)}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab,red,red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/15{background-color:#ac4bff26}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/15{background-color:color-mix(in oklab,var(--color-purple-500)15%,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\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/80{background-color:#82181acc}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/80{background-color:color-mix(in oklab,var(--color-red-900)80%,transparent)}}.bg-red-950\/40{background-color:#46080966}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/40{background-color:color-mix(in oklab,var(--color-red-950)40%,transparent)}}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500\/20{background-color:#8d54ff33}@supports (color:color-mix(in lab,red,red)){.bg-violet-500\/20{background-color:color-mix(in oklab,var(--color-violet-500)20%,transparent)}}.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{background-color:var(--color-yellow-500)}.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-linear-to-br{--tw-gradient-position:to bottom right}@supports (background-image:linear-gradient(in lab,red,red)){.bg-linear-to-br{--tw-gradient-position:to bottom right in oklab}}.bg-linear-to-br{background-image:linear-gradient(var(--tw-gradient-stops))}.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-\[\#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-\[\#38bdac\]\/50{--tw-gradient-from:oklab(72.378% -.11483 -.0053193/.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))}.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-\[\#38bdac\]{--tw-gradient-to:#38bdac;--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-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.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-0\.5{padding-inline:calc(var(--spacing)*.5)}.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-2\.5{padding-inline:calc(var(--spacing)*2.5)}.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{padding-block:calc(var(--spacing)*0)}.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-14{padding-block:calc(var(--spacing)*14)}.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-1\.5{padding-top:calc(var(--spacing)*1.5)}.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-0\.5{padding-right:calc(var(--spacing)*.5)}.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-0\.5{padding-bottom:calc(var(--spacing)*.5)}.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-1{padding-left:calc(var(--spacing)*1)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-bottom{vertical-align:bottom}.align-middle{vertical-align:middle}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif}.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-\[9px\]{font-size:9px}.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-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.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-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-wrap{text-wrap:wrap}.break-words,.wrap-break-word{overflow-wrap:break-word}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#0a1628\]{color:#0a1628}.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\]\/20{color:#38bdac33}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#38bdac\]\/90{color:#38bdace6}.text-\[\#38bdac\]\/95{color:#38bdacf2}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/75{color:#fee685bf}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/75{color:color-mix(in oklab,var(--color-amber-200)75%,transparent)}}.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-200\/90{color:#fee685e6}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/90{color:color-mix(in oklab,var(--color-amber-200)90%,transparent)}}.text-amber-200\/95{color:#fee685f2}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/95{color:color-mix(in oklab,var(--color-amber-200)95%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/30{color:#fcbb004d}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/30{color:color-mix(in oklab,var(--color-amber-400)30%,transparent)}}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400)80%,transparent)}}.text-amber-400\/90{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/90{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,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-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,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-200{color:var(--color-cyan-200)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-300\/90{color:#53eafde6}@supports (color:color-mix(in lab,red,red)){.text-cyan-300\/90{color:color-mix(in oklab,var(--color-cyan-300)90%,transparent)}}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-emerald-400\/90{color:#00d294e6}@supports (color:color-mix(in lab,red,red)){.text-emerald-400\/90{color:color-mix(in oklab,var(--color-emerald-400)90%,transparent)}}.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-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/85{color:#05df72d9}@supports (color:color-mix(in lab,red,red)){.text-green-400\/85{color:color-mix(in oklab,var(--color-green-400)85%,transparent)}}.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\/25{color:#ff8b1a40}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/25{color:color-mix(in oklab,var(--color-orange-400)25%,transparent)}}.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-300{color:var(--color-purple-300)}.text-purple-300\/90{color:#d9b3ffe6}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/90{color:color-mix(in oklab,var(--color-purple-300)90%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-red-100{color:var(--color-red-100)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/70{color:#ffa3a3b3}@supports (color:color-mix(in lab,red,red)){.text-red-300\/70{color:color-mix(in oklab,var(--color-red-300)70%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-rose-400{color:var(--color-rose-400)}.text-sky-200{color:var(--color-sky-200)}.text-sky-300{color:var(--color-sky-300)}.text-sky-300\/90{color:#77d4ffe6}@supports (color:color-mix(in lab,red,red)){.text-sky-300\/90{color:color-mix(in oklab,var(--color-sky-300)90%,transparent)}}.text-violet-300{color:var(--color-violet-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-300{color:var(--color-yellow-300)}.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)}}.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}.decoration-dotted{text-decoration-style:dotted}.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-none{--tw-shadow:0 0 #0000;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\]\/35{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.35)}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.ring-transparent{--tw-ring-color:transparent}.ring-offset-2{--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)}.ring-offset-\[\#0a1628\]{--tw-ring-offset-color:#0a1628}.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-all{-webkit-user-select:all;user-select:all}.select-none{-webkit-user-select:none;user-select:none}.\[overflow-anchor\:none\]{overflow-anchor:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}.group-open\:text-\[\#38bdac\]:is(:where(.group):is([open],:popover-open,:open) *){color:#38bdac}@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)}.placeholder\:text-gray-600::placeholder{color:var(--color-gray-600)}.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\]\/35:hover{border-color:#38bdac59}.hover\:border-\[\#38bdac\]\/40:hover{border-color:#38bdac66}.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\:bg-\[\#0a1628\]:hover{background-color:#0a1628}.hover\:bg-\[\#0a1628\]\/80:hover{background-color:#0a1628cc}.hover\:bg-\[\#0f2137\]\/90:hover{background-color:#0f2137e6}.hover\:bg-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2aa896\]:hover{background-color:#2aa896}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#2da898\]:hover{background-color:#2da898}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-cyan-500\/10:hover{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-cyan-500\/10:hover{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.hover\:bg-emerald-500:hover{background-color:var(--color-emerald-500)}.hover\:bg-emerald-500\/15:hover{background-color:#00bb7f26}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/15:hover{background-color:color-mix(in oklab,var(--color-emerald-500)15%,transparent)}}.hover\:bg-emerald-500\/20:hover{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/20:hover{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.hover\:bg-gray-500:hover{background-color:var(--color-gray-500)}.hover\:bg-gray-500\/20:hover{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-500\/20:hover{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-gray-700\/40:hover{background-color:#36415366}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-700\/40:hover{background-color:color-mix(in oklab,var(--color-gray-700)40%,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-gray-800\/40:hover{background-color:#1e293966}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-800\/40:hover{background-color:color-mix(in oklab,var(--color-gray-800)40%,transparent)}}.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-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-red-800\/50:hover{background-color:#9f071280}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-800\/50:hover{background-color:color-mix(in oklab,var(--color-red-800)50%,transparent)}}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,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-\[\#5ee0d1\]:hover{color:#5ee0d1}.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-amber-400\/90:hover{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.hover\:text-amber-400\/90:hover{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-200:hover{color:var(--color-gray-200)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-gray-400:hover{color:var(--color-gray-400)}.hover\:text-green-300:hover{color:var(--color-green-300)}.hover\:text-green-400:hover{color:var(--color-green-400)}.hover\:text-orange-300:hover{color:var(--color-orange-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-80:hover{opacity:.8}.hover\:opacity-100:hover{opacity:1}.hover\:ring-\[\#38bdac\]\/60:hover{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.6)}}.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-\[\#1a3a4a\]:focus{background-color:#1a3a4a}.focus\:bg-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:text-white:focus{color:var(--color-white)}.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-\[\#38bdac\]\/50:focus-visible{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.focus-visible\:ring-amber-600\/50:focus-visible{--tw-ring-color:#dd740080}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-amber-600\/50:focus-visible{--tw-ring-color:color-mix(in oklab,var(--color-amber-600)50%,transparent)}}.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\:col-span-2{grid-column:span 2/span 2}.sm\:inline{display:inline}.sm\:w-\[220px\]{width:220px}.sm\:max-w-\[600px\]{max-width:600px}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:items-end{align-items:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:justify-end{justify-content:flex-end}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:p-5{padding:calc(var(--spacing)*5)}.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-6{grid-template-columns:repeat(6,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))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,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)}}@keyframes pulse{50%{opacity:.5}} diff --git a/soul-admin/dist/assets/index-Gzc8q2lr.css b/soul-admin/dist/assets/index-Gzc8q2lr.css new file mode 100644 index 00000000..ed6e2e35 --- /dev/null +++ b/soul-admin/dist/assets/index-Gzc8q2lr.css @@ -0,0 +1 @@ +.rich-editor-wrapper{border:1px solid #374151;border-radius:.5rem;background:#0a1628;overflow:hidden}.rich-editor-toolbar{display:flex;align-items:center;gap:2px;padding:6px 8px;border-bottom:1px solid #374151;background:#0f1d32;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:1px}.toolbar-divider{width:1px;height:20px;background:#374151;margin:0 4px}.rich-editor-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer;transition:all .15s}.rich-editor-toolbar button:hover{background:#1f2937;color:#d1d5db}.rich-editor-toolbar button.is-active{background:#38bdac33;color:#38bdac}.rich-editor-toolbar button:disabled{opacity:.3;cursor:not-allowed}.link-tag-select{background:#0a1628;border:1px solid #374151;color:#d1d5db;font-size:12px;padding:2px 6px;border-radius:4px;cursor:pointer;max-width:160px}.link-input-bar{display:flex;align-items:center;gap:4px;padding:4px 8px;border-bottom:1px solid #374151;background:#0f1d32}.link-input{flex:1;background:#0a1628;border:1px solid #374151;color:#fff;padding:4px 8px;border-radius:4px;font-size:13px}.link-confirm,.link-remove{padding:4px 10px;border-radius:4px;border:none;font-size:12px;cursor:pointer}.link-confirm{background:#38bdac;color:#fff}.link-remove{background:#374151;color:#9ca3af}.rich-editor-content{min-height:450px;max-height:720px;overflow-y:auto;padding:12px 16px;color:#e5e7eb;font-size:14px;line-height:1.7}.rich-editor-content:focus{outline:none}.rich-editor-content h1{font-size:1.5em;font-weight:700;margin:.8em 0 .4em;color:#fff}.rich-editor-content h2{font-size:1.3em;font-weight:600;margin:.7em 0 .3em;color:#fff}.rich-editor-content h3{font-size:1.15em;font-weight:600;margin:.6em 0 .3em;color:#fff}.rich-editor-content p{margin:.4em 0}.rich-editor-content strong{color:#fff}.rich-editor-content code{background:#1f2937;padding:2px 6px;border-radius:3px;font-size:.9em;color:#38bdac}.rich-editor-content pre{background:#1f2937;padding:12px;border-radius:6px;overflow-x:auto;margin:.6em 0}.rich-editor-content blockquote{border-left:3px solid #38bdac;padding-left:12px;margin:.6em 0;color:#9ca3af}.rich-editor-content ul,.rich-editor-content ol{padding-left:1.5em;margin:.4em 0}.rich-editor-content li{margin:.2em 0}.rich-editor-content hr{border:none;border-top:1px solid #374151;margin:1em 0}.rich-editor-content img,.rich-editor-content .ProseMirror img,.rich-editor-content img.rich-editor-img-thumb{max-width:240px!important;max-height:140px!important;width:auto!important;height:auto!important;object-fit:contain;display:inline-block;vertical-align:middle;border-radius:6px;margin:.35em .25em .35em 0;border:1px dashed rgba(56,189,172,.45);background:#0f172a99;box-sizing:border-box}.rich-editor-content .rich-attachment-line{margin:.5em 0;padding:8px 12px;border-radius:8px;border:1px dashed rgba(125,211,252,.35);background:#0f172a8c;font-size:13px;line-height:1.5}.rich-editor-content .rich-attachment-badge{display:inline-block;font-size:10px;font-weight:600;letter-spacing:.02em;padding:2px 8px;border-radius:4px;background:#38bdac38;color:#38bdac;margin-right:8px;vertical-align:middle}.rich-editor-content .rich-attachment-link{color:#7dd3fc!important;font-weight:500;text-decoration:underline;word-break:break-all}.rich-editor-content .rich-video-wrap{display:block;margin:.5em 0;max-width:280px;border:1px dashed rgba(56,189,172,.45);border-radius:8px;overflow:hidden;background:#0f172acc}.rich-editor-content .rich-video-wrap video{display:block;width:100%;max-height:160px;object-fit:contain;vertical-align:middle}.rich-editor-content .rich-video-caption{font-size:11px;color:#6b7280;padding:4px 8px;border-top:1px solid #374151}.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{display:inline;background:#ffd7001f;color:gold;border-radius:4px;padding:1px 4px;font-weight:500;cursor:default;-webkit-user-select:all;user-select:all;white-space:nowrap}.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-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--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-amber-950:oklch(27.9% .077 45.635);--color-yellow-300:oklch(90.5% .182 98.111);--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-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-cyan-200:oklch(91.7% .08 205.041);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-sky-500:oklch(68.5% .169 237.323);--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-blue-600:oklch(54.6% .245 262.881);--color-violet-300:oklch(81.1% .111 293.571);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--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-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-6xl:72rem;--container-7xl:80rem;--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-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-snug:1.375;--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;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)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-2{top:calc(var(--spacing)*2)}.top-3{top:calc(var(--spacing)*3)}.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%}.bottom-2{bottom:calc(var(--spacing)*2)}.-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-\[-13px\]{left:-13px}.left-\[11px\]{left:11px}.left-\[50\%\]{left:50%}.isolate{isolation:isolate}.isolation-auto{isolation:auto}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.col-span-3{grid-column:span 3/span 3}.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-1{margin-inline:calc(var(--spacing)*1)}.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-0\.5{margin-right:calc(var(--spacing)*.5)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-auto{margin-right:auto}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.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-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-\[52px\]{margin-left:52px}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.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-2\.5{height:calc(var(--spacing)*2.5)}.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-11{height:calc(var(--spacing)*11)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-40{height:calc(var(--spacing)*40)}.h-96{height:calc(var(--spacing)*96)}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[92vh\]{max-height:92vh}.max-h-\[120px\]{max-height:120px}.max-h-\[160px\]{max-height:160px}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[420px\]{max-height:420px}.max-h-\[450px\]{max-height:450px}.max-h-\[520px\]{max-height:520px}.max-h-\[min\(60vh\,320px\)\]{max-height:min(60vh,320px)}.max-h-\[min\(280px\,40vh\)\]{max-height:min(280px,40vh)}.max-h-none{max-height:none}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-8{min-height:calc(var(--spacing)*8)}.min-h-\[28px\]{min-height:28px}.min-h-\[40px\]{min-height:40px}.min-h-\[60px\]{min-height:60px}.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-\[140px\]{min-height:140px}.min-h-\[260px\]{min-height:260px}.min-h-\[280px\]{min-height:280px}.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-2\.5{width:calc(var(--spacing)*2.5)}.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-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-28{width:calc(var(--spacing)*28)}.w-32{width:calc(var(--spacing)*32)}.w-40{width:calc(var(--spacing)*40)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-96{width:calc(var(--spacing)*96)}.w-\[5\.5rem\]{width:5.5rem}.w-\[8\%\]{width:8%}.w-\[10\%\]{width:10%}.w-\[11\%\]{width:11%}.w-\[13\%\]{width:13%}.w-\[14\%\]{width:14%}.w-\[19\%\]{width:19%}.w-\[25\%\]{width:25%}.w-\[72px\]{width:72px}.w-\[100px\]{width:100px}.w-\[280px\]{width:280px}.w-\[min\(100vw-2rem\,42rem\)\]{width:min(100vw - 2rem,42rem)}.w-fit{width:fit-content}.w-full{width:100%}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-7xl{max-width:var(--container-7xl)}.max-w-\[40\%\]{max-width:40%}.max-w-\[72px\]{max-width:72px}.max-w-\[96px\]{max-width:96px}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[140px\]{max-width:140px}.max-w-\[160px\]{max-width:160px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[220px\]{max-width:220px}.max-w-\[260px\]{max-width:260px}.max-w-\[280px\]{max-width:280px}.max-w-\[420px\]{max-width:420px}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-\[min\(100\%\,20rem\)\]{max-width:min(100%,20rem)}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-40{min-width:calc(var(--spacing)*40)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[60px\]{min-width:60px}.min-w-\[88px\]{min-width:88px}.min-w-\[108px\]{min-width:108px}.min-w-\[120px\]{min-width:120px}.min-w-\[148px\]{min-width:148px}.min-w-\[168px\]{min-width:168px}.min-w-\[200px\]{min-width:200px}.min-w-\[220px\]{min-width:220px}.min-w-\[960px\]{min-width:960px}.min-w-\[1024px\]{min-width:1024px}.min-w-\[1320px\]{min-width:1320px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.table-fixed{table-layout:fixed}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-y-0{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-90{--tw-scale-x:90%;--tw-scale-y:90%;--tw-scale-z:90%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-3d{scale:var(--tw-scale-x)var(--tw-scale-y)var(--tw-scale-z)}.scale-\[0\.98\]{scale:.98}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-pan-y{--tw-pan-y:pan-y;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.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}.list-none{list-style-type:none}.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-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-\[40px_1fr_90px_90px_70px_60px_110px\]{grid-template-columns:40px 1fr 90px 90px 70px 60px 110px}.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-nowrap{flex-wrap:nowrap}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.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-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.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-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*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-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-y-contain{overscroll-behavior-y:contain}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[\#0f2137\]{border-color:#0f2137}.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\]\/25{border-color:#38bdac40}.border-\[\#38bdac\]\/30{border-color:#38bdac4d}.border-\[\#38bdac\]\/35{border-color:#38bdac59}.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\/25{border-color:#f99c0040}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/25{border-color:color-mix(in oklab,var(--color-amber-500)25%,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-amber-600{border-color:var(--color-amber-600)}.border-amber-600\/60{border-color:#dd740099}@supports (color:color-mix(in lab,red,red)){.border-amber-600\/60{border-color:color-mix(in oklab,var(--color-amber-600)60%,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\/20{border-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/20{border-color:color-mix(in oklab,var(--color-cyan-500)20%,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-cyan-600\/60{border-color:#0092b599}@supports (color:color-mix(in lab,red,red)){.border-cyan-600\/60{border-color:color-mix(in oklab,var(--color-cyan-600)60%,transparent)}}.border-emerald-500\/30{border-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/30{border-color:color-mix(in oklab,var(--color-emerald-500)30%,transparent)}}.border-emerald-500\/50{border-color:#00bb7f80}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/50{border-color:color-mix(in oklab,var(--color-emerald-500)50%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-600\/50{border-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.border-gray-600\/50{border-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.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-gray-700\/80{border-color:#364153cc}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/80{border-color:color-mix(in oklab,var(--color-gray-700)80%,transparent)}}.border-gray-800{border-color:var(--color-gray-800)}.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\/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-purple-500\/50{border-color:#ac4bff80}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/50{border-color:color-mix(in oklab,var(--color-purple-500)50%,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\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-600\/40{border-color:#e4001466}@supports (color:color-mix(in lab,red,red)){.border-red-600\/40{border-color:color-mix(in oklab,var(--color-red-600)40%,transparent)}}.border-red-600\/50{border-color:#e4001480}@supports (color:color-mix(in lab,red,red)){.border-red-600\/50{border-color:color-mix(in oklab,var(--color-red-600)50%,transparent)}}.border-red-600\/60{border-color:#e4001499}@supports (color:color-mix(in lab,red,red)){.border-red-600\/60{border-color:color-mix(in oklab,var(--color-red-600)60%,transparent)}}.border-red-600\/70{border-color:#e40014b3}@supports (color:color-mix(in lab,red,red)){.border-red-600\/70{border-color:color-mix(in oklab,var(--color-red-600)70%,transparent)}}.border-red-900\/60{border-color:#82181a99}@supports (color:color-mix(in lab,red,red)){.border-red-900\/60{border-color:color-mix(in oklab,var(--color-red-900)60%,transparent)}}.border-sky-500\/30{border-color:#00a5ef4d}@supports (color:color-mix(in lab,red,red)){.border-sky-500\/30{border-color:color-mix(in oklab,var(--color-sky-500)30%,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\/35{border-color:#edb20059}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/35{border-color:color-mix(in oklab,var(--color-yellow-500)35%,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\]\/30{background-color:#0a16284d}.bg-\[\#0a1628\]\/40{background-color:#0a162866}.bg-\[\#0a1628\]\/50{background-color:#0a162880}.bg-\[\#0a1628\]\/60{background-color:#0a162899}.bg-\[\#0a1628\]\/80{background-color:#0a1628cc}.bg-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#0f2137\]\/80{background-color:#0f2137cc}.bg-\[\#0f2137\]\/90{background-color:#0f2137e6}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#3a1010\]\/35{background-color:#3a101059}.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\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#081322\]{background-color:#081322}.bg-\[\#162840\]{background-color:#162840}.bg-\[\#162840\]\/80{background-color:#162840cc}.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-amber-950\/20{background-color:#46190133}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/20{background-color:color-mix(in oklab,var(--color-amber-950)20%,transparent)}}.bg-amber-950\/25{background-color:#46190140}@supports (color:color-mix(in lab,red,red)){.bg-amber-950\/25{background-color:color-mix(in oklab,var(--color-amber-950)25%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab,red,red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.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{background-color:var(--color-blue-500)}.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\/15{background-color:#00b7d726}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/15{background-color:color-mix(in oklab,var(--color-cyan-500)15%,transparent)}}.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\/10{background-color:#00bb7f1a}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/10{background-color:color-mix(in oklab,var(--color-emerald-500)10%,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-emerald-600{background-color:var(--color-emerald-600)}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/10{background-color:#6a72821a}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/10{background-color:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-600\/20{background-color:#4a556533}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/20{background-color:color-mix(in oklab,var(--color-gray-600)20%,transparent)}}.bg-gray-600\/50{background-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/50{background-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.bg-gray-700{background-color:var(--color-gray-700)}.bg-gray-700\/50{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.bg-gray-700\/50{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.bg-gray-800{background-color:var(--color-gray-800)}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab,red,red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/15{background-color:#ac4bff26}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/15{background-color:color-mix(in oklab,var(--color-purple-500)15%,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\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-900\/80{background-color:#82181acc}@supports (color:color-mix(in lab,red,red)){.bg-red-900\/80{background-color:color-mix(in oklab,var(--color-red-900)80%,transparent)}}.bg-red-950\/40{background-color:#46080966}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/40{background-color:color-mix(in oklab,var(--color-red-950)40%,transparent)}}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500\/20{background-color:#8d54ff33}@supports (color:color-mix(in lab,red,red)){.bg-violet-500\/20{background-color:color-mix(in oklab,var(--color-violet-500)20%,transparent)}}.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{background-color:var(--color-yellow-500)}.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-linear-to-br{--tw-gradient-position:to bottom right}@supports (background-image:linear-gradient(in lab,red,red)){.bg-linear-to-br{--tw-gradient-position:to bottom right in oklab}}.bg-linear-to-br{background-image:linear-gradient(var(--tw-gradient-stops))}.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-\[\#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-\[\#38bdac\]\/50{--tw-gradient-from:oklab(72.378% -.11483 -.0053193/.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))}.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-\[\#38bdac\]{--tw-gradient-to:#38bdac;--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-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.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-0\.5{padding-inline:calc(var(--spacing)*.5)}.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-2\.5{padding-inline:calc(var(--spacing)*2.5)}.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{padding-block:calc(var(--spacing)*0)}.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-14{padding-block:calc(var(--spacing)*14)}.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-1\.5{padding-top:calc(var(--spacing)*1.5)}.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-0\.5{padding-right:calc(var(--spacing)*.5)}.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-0\.5{padding-bottom:calc(var(--spacing)*.5)}.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-1{padding-left:calc(var(--spacing)*1)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-bottom{vertical-align:bottom}.align-middle{vertical-align:middle}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif}.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-\[9px\]{font-size:9px}.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-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.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-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-wrap{text-wrap:wrap}.break-words,.wrap-break-word{overflow-wrap:break-word}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#0a1628\]{color:#0a1628}.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\]\/20{color:#38bdac33}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#38bdac\]\/90{color:#38bdace6}.text-\[\#38bdac\]\/95{color:#38bdacf2}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/75{color:#fee685bf}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/75{color:color-mix(in oklab,var(--color-amber-200)75%,transparent)}}.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-200\/90{color:#fee685e6}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/90{color:color-mix(in oklab,var(--color-amber-200)90%,transparent)}}.text-amber-200\/95{color:#fee685f2}@supports (color:color-mix(in lab,red,red)){.text-amber-200\/95{color:color-mix(in oklab,var(--color-amber-200)95%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/30{color:#fcbb004d}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/30{color:color-mix(in oklab,var(--color-amber-400)30%,transparent)}}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400)80%,transparent)}}.text-amber-400\/90{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/90{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,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-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,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-200{color:var(--color-cyan-200)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-300\/90{color:#53eafde6}@supports (color:color-mix(in lab,red,red)){.text-cyan-300\/90{color:color-mix(in oklab,var(--color-cyan-300)90%,transparent)}}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-emerald-400\/90{color:#00d294e6}@supports (color:color-mix(in lab,red,red)){.text-emerald-400\/90{color:color-mix(in oklab,var(--color-emerald-400)90%,transparent)}}.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-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/85{color:#05df72d9}@supports (color:color-mix(in lab,red,red)){.text-green-400\/85{color:color-mix(in oklab,var(--color-green-400)85%,transparent)}}.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\/25{color:#ff8b1a40}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/25{color:color-mix(in oklab,var(--color-orange-400)25%,transparent)}}.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-300{color:var(--color-purple-300)}.text-purple-300\/90{color:#d9b3ffe6}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/90{color:color-mix(in oklab,var(--color-purple-300)90%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-red-100{color:var(--color-red-100)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/70{color:#ffa3a3b3}@supports (color:color-mix(in lab,red,red)){.text-red-300\/70{color:color-mix(in oklab,var(--color-red-300)70%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-rose-400{color:var(--color-rose-400)}.text-sky-200{color:var(--color-sky-200)}.text-sky-300{color:var(--color-sky-300)}.text-sky-300\/90{color:#77d4ffe6}@supports (color:color-mix(in lab,red,red)){.text-sky-300\/90{color:color-mix(in oklab,var(--color-sky-300)90%,transparent)}}.text-violet-300{color:var(--color-violet-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-300{color:var(--color-yellow-300)}.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)}}.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}.decoration-dotted{text-decoration-style:dotted}.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-none{--tw-shadow:0 0 #0000;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\]\/35{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.35)}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.ring-transparent{--tw-ring-color:transparent}.ring-offset-2{--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)}.ring-offset-\[\#0a1628\]{--tw-ring-offset-color:#0a1628}.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-all{-webkit-user-select:all;user-select:all}.select-none{-webkit-user-select:none;user-select:none}.\[overflow-anchor\:none\]{overflow-anchor:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}.group-open\:text-\[\#38bdac\]:is(:where(.group):is([open],:popover-open,:open) *){color:#38bdac}@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)}.placeholder\:text-gray-600::placeholder{color:var(--color-gray-600)}.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\]\/35:hover{border-color:#38bdac59}.hover\:border-\[\#38bdac\]\/40:hover{border-color:#38bdac66}.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\:bg-\[\#0a1628\]:hover{background-color:#0a1628}.hover\:bg-\[\#0a1628\]\/80:hover{background-color:#0a1628cc}.hover\:bg-\[\#0f2137\]\/90:hover{background-color:#0f2137e6}.hover\:bg-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2aa896\]:hover{background-color:#2aa896}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#2da898\]:hover{background-color:#2da898}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-cyan-500\/10:hover{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-cyan-500\/10:hover{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.hover\:bg-emerald-500:hover{background-color:var(--color-emerald-500)}.hover\:bg-emerald-500\/15:hover{background-color:#00bb7f26}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/15:hover{background-color:color-mix(in oklab,var(--color-emerald-500)15%,transparent)}}.hover\:bg-emerald-500\/20:hover{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/20:hover{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.hover\:bg-gray-500:hover{background-color:var(--color-gray-500)}.hover\:bg-gray-500\/20:hover{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-500\/20:hover{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-gray-700\/40:hover{background-color:#36415366}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-700\/40:hover{background-color:color-mix(in oklab,var(--color-gray-700)40%,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-gray-800\/40:hover{background-color:#1e293966}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-800\/40:hover{background-color:color-mix(in oklab,var(--color-gray-800)40%,transparent)}}.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-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-red-800\/50:hover{background-color:#9f071280}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-800\/50:hover{background-color:color-mix(in oklab,var(--color-red-800)50%,transparent)}}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,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-\[\#5ee0d1\]:hover{color:#5ee0d1}.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-amber-400\/90:hover{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.hover\:text-amber-400\/90:hover{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-200:hover{color:var(--color-gray-200)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-gray-400:hover{color:var(--color-gray-400)}.hover\:text-green-300:hover{color:var(--color-green-300)}.hover\:text-green-400:hover{color:var(--color-green-400)}.hover\:text-orange-300:hover{color:var(--color-orange-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-80:hover{opacity:.8}.hover\:opacity-100:hover{opacity:1}.hover\:ring-\[\#38bdac\]\/60:hover{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.6)}}.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-\[\#1a3a4a\]:focus{background-color:#1a3a4a}.focus\:bg-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:text-white:focus{color:var(--color-white)}.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-\[\#38bdac\]\/50:focus-visible{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.focus-visible\:ring-amber-600\/50:focus-visible{--tw-ring-color:#dd740080}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-amber-600\/50:focus-visible{--tw-ring-color:color-mix(in oklab,var(--color-amber-600)50%,transparent)}}.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\:col-span-2{grid-column:span 2/span 2}.sm\:inline{display:inline}.sm\:w-\[220px\]{width:220px}.sm\:max-w-\[600px\]{max-width:600px}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:items-end{align-items:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:justify-end{justify-content:flex-end}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:p-5{padding:calc(var(--spacing)*5)}.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-6{grid-template-columns:repeat(6,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))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,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)}}@keyframes pulse{50%{opacity:.5}} diff --git a/soul-admin/dist/index.html b/soul-admin/dist/index.html index f489f8f3..dc58db2a 100644 --- a/soul-admin/dist/index.html +++ b/soul-admin/dist/index.html @@ -4,8 +4,8 @@ 管理后台 - Soul创业派对 - - + +
diff --git a/soul-admin/src/App.tsx b/soul-admin/src/App.tsx index 5d14d11b..311b6ea1 100644 --- a/soul-admin/src/App.tsx +++ b/soul-admin/src/App.tsx @@ -19,7 +19,6 @@ import { MentorsPage } from './pages/mentors/MentorsPage' import { MentorConsultationsPage } from './pages/mentor-consultations/MentorConsultationsPage' import { FindPartnerPage } from './pages/find-partner/FindPartnerPage' import { ApiDocsPage } from './pages/api-docs/ApiDocsPage' -import { OpenPlatformPage } from './pages/open-platform/OpenPlatformPage' import { NotFoundPage } from './pages/not-found/NotFoundPage' function App() { @@ -49,7 +48,7 @@ function App() { } /> } /> } /> - } /> + } /> } /> diff --git a/soul-admin/src/layouts/AdminLayout.tsx b/soul-admin/src/layouts/AdminLayout.tsx index 9c60c29c..6e57d95d 100644 --- a/soul-admin/src/layouts/AdminLayout.tsx +++ b/soul-admin/src/layouts/AdminLayout.tsx @@ -8,7 +8,6 @@ import { Wallet, BookOpen, GitMerge, - Globe2, } from 'lucide-react' import { get, post } from '@/api/client' import { clearAdminToken, getAdminToken } from '@/api/auth' @@ -123,17 +122,6 @@ export function AdminLayout() { 系统设置 - - - API开放平台 - diff --git a/soul-admin/src/pages/content/ContentPage.tsx b/soul-admin/src/pages/content/ContentPage.tsx index 9320a10f..1b9937ff 100644 --- a/soul-admin/src/pages/content/ContentPage.tsx +++ b/soul-admin/src/pages/content/ContentPage.tsx @@ -592,12 +592,24 @@ export function ContentPage() { isPinned?: boolean } type VipRow = { id: string; webhookUrl?: string | null } - const [data, vipRes] = await Promise.all([ + const [data, vipRes, whCfg] = await Promise.all([ get<{ success?: boolean; persons?: PersonResp[] }>('/api/db/persons'), get<{ success?: boolean; data?: VipRow[]; error?: string }>('/api/db/vip-members?limit=500').catch(() => null), + get<{ success?: boolean; data?: Record }>( + '/api/db/config/full?key=super_individual_webhook_map', + { cache: 'no-store' as RequestCache }, + ).catch(() => null), ]) const whMap: Record = {} - if (vipRes?.success && Array.isArray(vipRes.data)) { + // 与 DBVipMemberWebhookSet 一致:完整映射存在 system_config,勿仅从 vip-members 列表合并 + // (列表仅含当前有效 VIP,过期会员绑定的人物会导致弹窗空白) + if (whCfg?.success && whCfg.data && typeof whCfg.data === 'object' && !Array.isArray(whCfg.data)) { + for (const [k, v] of Object.entries(whCfg.data)) { + const uid = String(k || '').trim() + const w = v != null ? String(v).trim() : '' + if (uid && w) whMap[uid] = w + } + } else if (vipRes?.success && Array.isArray(vipRes.data)) { for (const m of vipRes.data) { const uid = (m.id || '').trim() if (!uid) continue @@ -2826,7 +2838,7 @@ export function ContentPage() { 文章 @ 存 token;小程序点 @ 用 token 换存客宝密钥后加好友/拉群。

- 超级个体:开通且昵称合法会自动进本列表可 @;共用「超级个体拉群」统一获客计划(话术由技术侧在系统里配置,本页不填 plan/apiKey,避免误操作)。 + 超级个体:与「用户管理 → 超级个体列表」同口径的有效 VIP;每次打开/刷新本页时,后端会为尚未出现在本表的用户自动补一条可 @ 人物(昵称须合法、存客宝可用)。已配置统一计划时走「超级个体同步」获客计划。

飞书群 Webhook(按人推线索到群):在下方表格「飞书群」列查看状态,操作栏点 Webhook 图标配置;与绑定会员用户维度一致。 diff --git a/soul-admin/src/pages/dashboard/DashboardPage.tsx b/soul-admin/src/pages/dashboard/DashboardPage.tsx index 381318f1..9c895267 100644 --- a/soul-admin/src/pages/dashboard/DashboardPage.tsx +++ b/soul-admin/src/pages/dashboard/DashboardPage.tsx @@ -390,8 +390,19 @@ export function DashboardPage() { const t = target.trim() const lower = t.toLowerCase() + // 首页卡片:trackClick('home','card_click','超级个体_'+userId) — 中文前缀,不能依赖 lower.includes('super') + if (/^超级个体[_::]/.test(t)) { + const raw = t.replace(/^超级个体[_::]/, '').trim() + const vipName = resolveVipNameByToken(raw) || resolveVipNameByToken(normalizeTrackToken(raw)) + if (vipName) return `超级个体:${vipName}` + return `超级个体:${normalizeTrackToken(raw) || raw || '未知'}` + } + if (/^链接头像[_-]/.test(t)) { - const rawName = normalizeTrackToken(t.replace(/^链接头像[_-]/, '')) + const rawId = t.replace(/^链接头像[_-]/, '').trim() + const nick = resolveVipNameByToken(rawId) || resolveVipNameByToken(normalizeTrackToken(rawId)) + if (nick) return `头像:${nick}` + const rawName = normalizeTrackToken(rawId) return rawName ? `头像:${rawName}` : '头像点击' } if (/^member[_-]?detail$/i.test(lower) || lower.includes('member detail')) return '成员详情' diff --git a/soul-admin/src/pages/open-platform/OpenPlatformPage.tsx b/soul-admin/src/pages/open-platform/OpenPlatformPage.tsx index eb6e0ce9..24a3ecfc 100644 --- a/soul-admin/src/pages/open-platform/OpenPlatformPage.tsx +++ b/soul-admin/src/pages/open-platform/OpenPlatformPage.tsx @@ -8,9 +8,15 @@ import { OpenPlatformKeysTab } from './OpenPlatformKeysTab' import { OpenPlatformDocsTab } from './OpenPlatformDocsTab' import { OpenPlatformLogsTab } from './OpenPlatformLogsTab' -export function OpenPlatformPage() { +export function OpenPlatformPage({ embedded = false }: { embedded?: boolean }) { return ( -

+

API 开放平台

@@ -20,7 +26,7 @@ export function OpenPlatformPage() {

diff --git a/soul-admin/src/pages/settings/SettingsPage.tsx b/soul-admin/src/pages/settings/SettingsPage.tsx index 6b241601..db74ec65 100644 --- a/soul-admin/src/pages/settings/SettingsPage.tsx +++ b/soul-admin/src/pages/settings/SettingsPage.tsx @@ -41,11 +41,13 @@ import { LayoutGrid, Sparkles, MessageSquare, + Globe2, } from 'lucide-react' import { get, post } from '@/api/client' import { AuthorSettingsPage } from '@/pages/author-settings/AuthorSettingsPage' import { AdminUsersPage } from '@/pages/admin-users/AdminUsersPage' import { ApiDocsPage } from '@/pages/api-docs/ApiDocsPage' +import { OpenPlatformPage } from '@/pages/open-platform/OpenPlatformPage' import { MpUiPopupTableSection } from '@/pages/settings/MpUiPopupTableSection' import type { PagePopupItem } from '@/pages/settings/mpUiCopyConfig' import { buildMpUiPayload, splitMpUiForPopupEditor } from '@/pages/settings/mpUiCopyConfig' @@ -123,7 +125,7 @@ const defaultFeatures: FeatureConfig = { aboutEnabled: true, } -const TAB_KEYS = ['system', 'author', 'admin', 'api-docs'] as const +const TAB_KEYS = ['system', 'author', 'admin', 'open-platform', 'api-docs'] as const type TabKey = (typeof TAB_KEYS)[number] const SYSTEM_SECTION_KEYS = ['basic', 'mp', 'mp-copy', 'oss', 'features'] as const @@ -368,6 +370,13 @@ export function SettingsPage() { 管理员 + + + API 开放平台 + + + + + diff --git a/soul-api/docs/master.py b/soul-api/docs/master.py index 8ddbe90d..904a21d3 100644 --- a/soul-api/docs/master.py +++ b/soul-api/docs/master.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -soulApp (soul-api) Go 项目一键部署到宝塔(正式环境) +soulApi(soul-api 后端)Go 项目一键部署到宝塔(正式环境) - 打包使用 .env.production 作为服务器 .env - 本地交叉编译 Linux 二进制 - 上传到 /www/wwwroot/self/soul-api @@ -322,7 +322,7 @@ def upload_and_extract(cfg, tarball_path, no_restart=False, restart_method="auto print(" [成功] 已解压到: %s" % project_path) if not no_restart: - print("[4/4] 重启 soulApp 服务 ...") + print("[4/4] 重启 soulApi 服务 ...") ok = False if restart_method in ("auto", "btapi") and (cfg.get("bt_panel_url") and cfg.get("bt_api_key")): ok = restart_via_bt_api(cfg) @@ -342,7 +342,7 @@ def upload_and_extract(cfg, tarball_path, no_restart=False, restart_method="auto print(" [stderr] %s" % err[:200]) ok = "RESTART_OK" in out if ok: - print(" [成功] soulApp 已通过 SSH 重启") + print(" [成功] soulApi 已通过 SSH 重启") else: print(" [警告] SSH 重启状态未知,请到宝塔 Go 项目里手动点击启动,或执行: cd %s && ./soul-api" % project_path) else: @@ -368,7 +368,7 @@ def upload_and_extract(cfg, tarball_path, no_restart=False, restart_method="auto def main(): parser = argparse.ArgumentParser( - description="soulApp (soul-api) Go 项目一键部署到宝塔", + description="soulApi(soul-api 后端)Go 项目一键部署到宝塔", formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument("--no-build", action="store_true", help="跳过本地编译(使用已有 soul-api 二进制)") @@ -387,7 +387,7 @@ def main(): cfg = get_cfg() print("=" * 60) - print(" soulApp 一键部署到宝塔") + print(" soulApi(soul-api)一键部署到宝塔") print("=" * 60) print(" 服务器: %s@%s:%s" % (cfg["user"], cfg["host"], DEFAULT_SSH_PORT)) print(" 目标目录: %s" % cfg["project_path"]) diff --git a/soul-api/internal/handler/db_person.go b/soul-api/internal/handler/db_person.go index 6540d44a..45f786ae 100644 --- a/soul-api/internal/handler/db_person.go +++ b/soul-api/internal/handler/db_person.go @@ -6,6 +6,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "log" "net/http" "strings" "time" @@ -108,10 +109,52 @@ func invalidateReadExtrasCache() { cache.Del(context.Background(), cache.KeyConfigReadExtras) } +// syncMissingSuperIndividualsAsPersons 将当前有效超级个体(VIP 口径与 vip-members 一致)中尚未绑定 persons.user_id 的用户, +// 通过 ensurePersonForUser 追加为可 @ 人物(昵称不合法或存客宝失败时跳过并打日志)。 +func syncMissingSuperIndividualsAsPersons(db *gorm.DB) { + ids := activeSuperIndividualUserIDs(db) + if len(ids) == 0 { + return + } + var bound []string + if err := db.Model(&model.Person{}). + Where("user_id IS NOT NULL AND user_id != ?", ""). + Distinct("user_id"). + Pluck("user_id", &bound).Error; err != nil { + log.Printf("[persons] sync: list bound user_id failed: %v", err) + return + } + boundSet := make(map[string]struct{}, len(bound)) + for _, b := range bound { + boundSet[strings.TrimSpace(b)] = struct{}{} + } + any := false + for _, uid := range ids { + uid = strings.TrimSpace(uid) + if uid == "" { + continue + } + if _, ok := boundSet[uid]; ok { + continue + } + if err := ensurePersonForUser(db, uid); err != nil { + log.Printf("[persons] sync super-individual userId=%s: %v", uid, err) + continue + } + boundSet[uid] = struct{}{} + any = true + } + if any { + invalidateReadExtrasCache() + } +} + // DBPersonList GET /api/db/persons 管理端-@提及人物列表 func DBPersonList(c *gin.Context) { + db := database.DB() + syncMissingSuperIndividualsAsPersons(db) var rows []model.Person - if err := database.DB().Order("name ASC").Find(&rows).Error; err != nil { + if err := db.Order("name ASC").Find(&rows).Error; err != nil { c.JSON(http.StatusOK, gin.H{"success": false, "error": err.Error()}) return } diff --git a/soul-api/internal/handler/vip_members_admin.go b/soul-api/internal/handler/vip_members_admin.go index 81e76c9a..f9302ee4 100644 --- a/soul-api/internal/handler/vip_members_admin.go +++ b/soul-api/internal/handler/vip_members_admin.go @@ -151,6 +151,37 @@ func DBVipMembersList(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"success": true, "data": list, "total": len(list)}) } +// activeSuperIndividualUserIDs 与 DBVipMembersList / 小程序超级个体口径一致的有效用户 id(无条数上限,供 @ 列表自动补人) +func activeSuperIndividualUserIDs(db *gorm.DB) []string { + var users []model.User + err := db.Table("users"). + Select("id"). + Where("is_vip = 1 AND vip_expire_date > ?", time.Now()). + Order("id ASC"). + Find(&users).Error + + if err != nil || len(users) == 0 { + var userIDs []string + db.Model(&model.Order{}).Select("DISTINCT user_id"). + Where("(status = ? OR status = ?) AND (product_type = ? OR product_type = ?)", "paid", "completed", "fullbook", "vip"). + Pluck("user_id", &userIDs) + if len(userIDs) == 0 { + return nil + } + if err := db.Select("id").Where("id IN ?", userIDs).Find(&users).Error; err != nil { + return nil + } + } + out := make([]string, 0, len(users)) + for _, u := range users { + id := strings.TrimSpace(u.ID) + if id != "" { + out = append(out, id) + } + } + return out +} + // DBVipMemberWebhookSet PUT /api/db/vip-members/webhook // 按超级个体用户维度配置飞书群 webhook(VOX 地址)。 func DBVipMemberWebhookSet(c *gin.Context) { diff --git a/soul-api/master.py b/soul-api/master.py index 8ef0b7be..a6d7affd 100644 --- a/soul-api/master.py +++ b/soul-api/master.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -soulApp (soul-api) Go 项目一键部署到宝塔(正式环境) +soulApi(soul-api 后端)Go 项目一键部署到宝塔(正式环境) - 打包使用 .env.production 作为服务器 .env - 本地交叉编译 Linux 二进制 - 上传到 /www/wwwroot/self/soul-api @@ -336,7 +336,7 @@ def upload_and_extract(cfg, tarball_path, no_restart=False, restart_method="auto print(" [成功] 已解压到: %s" % project_path) if not no_restart: - print("[4/4] 重启 soulApp 服务 ...") + print("[4/4] 重启 soulApi 服务 ...") ok = False if restart_method in ("auto", "btapi") and (cfg.get("bt_panel_url") and cfg.get("bt_api_key")): ok = restart_via_bt_api(cfg) @@ -371,7 +371,7 @@ def upload_and_extract(cfg, tarball_path, no_restart=False, restart_method="auto out = stdout.read().decode("utf-8", errors="replace").strip() ok = "RESTART_OK" in out if ok: - print(" [成功] soulApp 已通过 SSH 重启") + print(" [成功] soulApi 已通过 SSH 重启") else: print(" [警告] SSH 重启状态未知,请到宝塔 Go 项目里手动点击启动,或执行: cd %s && ./soul-api" % project_path) else: @@ -397,7 +397,7 @@ def upload_and_extract(cfg, tarball_path, no_restart=False, restart_method="auto def main(): parser = argparse.ArgumentParser( - description="soulApp (soul-api) Go 项目一键部署到宝塔", + description="soulApi(soul-api 后端)Go 项目一键部署到宝塔", formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument("--no-build", action="store_true", help="跳过本地编译(使用已有 soul-api 二进制)") @@ -416,7 +416,7 @@ def main(): cfg = get_cfg() print("=" * 60) - print(" soulApp 一键部署到宝塔") + print(" soulApi(soul-api)一键部署到宝塔") print("=" * 60) print(" 服务器: %s@%s:%s" % (cfg["user"], cfg["host"], DEFAULT_SSH_PORT)) print(" 目标目录: %s" % cfg["project_path"])