diff --git a/miniprogram/pages/match/match.js b/miniprogram/pages/match/match.js index 4ac3403c..b8a83d40 100644 --- a/miniprogram/pages/match/match.js +++ b/miniprogram/pages/match/match.js @@ -32,7 +32,7 @@ let MATCH_TYPES = [ { id: 'team', label: '团队招募', matchLabel: '团队招募', icon: 'gamepad', matchFromDB: true, showJoinAfterMatch: true } ] -let FREE_MATCH_LIMIT = 3 // 每日免费匹配次数 +let FREE_MATCH_LIMIT = 1 // 终身免费匹配次数(不按日重置,与后端 match_config 一致) Page({ data: { @@ -48,8 +48,7 @@ Page({ hasPurchased: false, hasFullBook: false, - // 匹配次数 - todayMatchCount: 0, + // 匹配次数(以服务端 purchase-status.matchQuota 为准) totalMatchesAllowed: FREE_MATCH_LIMIT, matchesRemaining: FREE_MATCH_LIMIT, needPayToMatch: false, @@ -86,20 +85,21 @@ Page({ contactWechat: '', contactSaving: false, - // 匹配价格(可配置) + // 匹配价格(可配置);matchPriceOriginal 为划线原价展示 matchPrice: 1, + matchPriceOriginal: 9.9, extraMatches: 0 }, - onLoad() { + async onLoad() { wx.showShareMenu({ withShareTimeline: true }) this.setData({ statusBarHeight: app.globalData.statusBarHeight || 44 }) - this.loadMatchConfig() + await this.loadMatchConfig() this.loadStoredContact() - this.loadTodayMatchCount() this.initUserStatus() + await this.refreshMatchQuotaFromServer() }, onShow() { @@ -112,6 +112,7 @@ Page({ } } this.initUserStatus() + this.refreshMatchQuotaFromServer() }, // 加载匹配配置 @@ -132,12 +133,15 @@ Page({ }) MATCH_TYPES = types FREE_MATCH_LIMIT = res.data.freeMatchLimit || FREE_MATCH_LIMIT + if (FREE_MATCH_LIMIT > 1) FREE_MATCH_LIMIT = 1 const matchPrice = res.data.matchPrice || 1 + const matchPriceOriginal = res.data.matchPriceOriginal != null ? res.data.matchPriceOriginal : 9.9 this.setData({ matchTypes: MATCH_TYPES, totalMatchesAllowed: FREE_MATCH_LIMIT, - matchPrice: matchPrice + matchPrice: matchPrice, + matchPriceOriginal: matchPriceOriginal }) console.log('[Match] 加载匹配配置成功:', { @@ -162,49 +166,64 @@ Page({ }) }, - // 加载今日匹配次数 - loadTodayMatchCount() { - try { - const today = new Date().toISOString().split('T')[0] - const stored = wx.getStorageSync('match_count_data') - if (stored) { - const data = typeof stored === 'string' ? JSON.parse(stored) : stored - if (data.date === today) { - this.setData({ todayMatchCount: data.count }) - } - } - } catch (e) { - console.error('加载匹配次数失败:', e) + /** 从服务端同步匹配配额(终身免费 + 已购次数,不按自然日重置) */ + async refreshMatchQuotaFromServer() { + const userId = app.globalData.userInfo?.id + const hasFullBookGlobal = !!app.globalData.hasFullBook + if (!userId) { + this.setData({ + matchesRemaining: FREE_MATCH_LIMIT, + needPayToMatch: false, + extraMatches: 0, + totalMatchesAllowed: FREE_MATCH_LIMIT + }) + return + } + try { + const res = await app.request({ + url: `/api/miniprogram/user/purchase-status?userId=${encodeURIComponent(userId)}`, + silent: true + }) + if (!res.success || !res.data) return + const hasFullBook = res.data.hasFullBook === true + const mq = res.data.matchQuota || {} + const remain = mq.remainToday != null ? Number(mq.remainToday) : 0 + const purchasedRemain = mq.purchasedRemain != null ? Number(mq.purchasedRemain) : 0 + const purchasedTotal = mq.purchasedTotal != null ? Number(mq.purchasedTotal) : 0 + if (hasFullBook) { + this.setData({ + hasFullBook: true, + matchesRemaining: 999999, + needPayToMatch: false, + extraMatches: purchasedRemain, + totalMatchesAllowed: 999999 + }) + return + } + this.setData({ + hasFullBook: false, + matchesRemaining: Math.max(0, remain), + needPayToMatch: remain <= 0, + extraMatches: purchasedRemain, + totalMatchesAllowed: FREE_MATCH_LIMIT + purchasedTotal + }) + } catch (e) { + console.log('[Match] 同步匹配配额失败', e) + this.setData({ + hasFullBook: hasFullBookGlobal, + matchesRemaining: hasFullBookGlobal ? 999999 : this.data.matchesRemaining, + needPayToMatch: !hasFullBookGlobal && this.data.matchesRemaining <= 0 + }) } - }, - - // 保存今日匹配次数 - saveTodayMatchCount(count) { - const today = new Date().toISOString().split('T')[0] - wx.setStorageSync('match_count_data', { date: today, count }) }, // 初始化用户状态 initUserStatus() { - const { isLoggedIn, hasFullBook, purchasedSections } = app.globalData - - // 获取额外购买的匹配次数 - const extraMatches = wx.getStorageSync('extra_match_count') || 0 - - // 总匹配次数 = 每日免费(3) + 额外购买次数 - // 全书用户无限制 - const totalMatchesAllowed = hasFullBook ? 999999 : FREE_MATCH_LIMIT + extraMatches - const matchesRemaining = hasFullBook ? 999999 : Math.max(0, totalMatchesAllowed - this.data.todayMatchCount) - const needPayToMatch = !hasFullBook && matchesRemaining <= 0 - + const { isLoggedIn, hasFullBook } = app.globalData this.setData({ isLoggedIn, hasFullBook, - hasPurchased: true, // 所有用户都可以使用匹配功能 - totalMatchesAllowed, - matchesRemaining, - needPayToMatch, - extraMatches + hasPurchased: true }) }, @@ -473,7 +492,7 @@ Page({ } else if (res && !res.success) { matchFailHint = res.message || res.error || '' if (res.code === 'QUOTA_EXCEEDED') { - matchFailHint = matchFailHint || '今日免费次数已用完,可购买额外匹配次数后再试' + matchFailHint = matchFailHint || '免费次数已用完,可付费购买匹配次数后再试' } else if (res.code === 'NO_USERS') { matchFailHint = matchFailHint || '当前流量池暂无可匹配用户,可稍后再试;补全档案后匹配范围通常更大。' } @@ -500,18 +519,11 @@ Page({ return } - // 增加今日匹配次数 - const newCount = this.data.todayMatchCount + 1 - const matchesRemaining = this.data.hasFullBook ? 999999 : Math.max(0, this.data.totalMatchesAllowed - newCount) - this.setData({ isMatching: false, - currentMatch: matchedUser, - todayMatchCount: newCount, - matchesRemaining, - needPayToMatch: !this.data.hasFullBook && matchesRemaining <= 0 + currentMatch: matchedUser }) - this.saveTodayMatchCount(newCount) + this.refreshMatchQuotaFromServer() // 上报匹配行为到存客宝 this.reportMatch(matchedUser) @@ -729,12 +741,8 @@ Page({ }) }) - // 支付成功,增加匹配次数 - const extraMatches = (wx.getStorageSync('extra_match_count') || 0) + 1 - wx.setStorageSync('extra_match_count', extraMatches) - wx.showToast({ title: '购买成功', icon: 'success' }) - this.initUserStatus() + await this.refreshMatchQuotaFromServer() } else { throw new Error(res.error || '创建订单失败') } diff --git a/miniprogram/pages/match/match.wxml b/miniprogram/pages/match/match.wxml index 24d3146b..ae7c9470 100644 --- a/miniprogram/pages/match/match.wxml +++ b/miniprogram/pages/match/match.wxml @@ -15,9 +15,9 @@ - + - 今日免费次数已用完 + 免费次数已用完,可付费继续匹配 购买次数 @@ -302,22 +302,25 @@ 购买匹配次数 - 今日3次免费匹配已用完,可付费购买额外次数 + 每位用户仅有 1 次免费匹配(不按天重置),之后每次 ¥{{matchPrice || 1}} - + 单价 - ¥{{matchPrice || 1}} / 次 + + ¥{{matchPriceOriginal}} + ¥{{matchPrice || 1}} / 次 + - 已购买 + 已购未用 {{extraMatches || 0}} 次 - 立即购买 ¥{{matchPrice || 1}} - 明天再来 + 立即购买 ¥{{matchPrice || 1}} / 次 + 稍后再说 diff --git a/miniprogram/pages/match/match.wxss b/miniprogram/pages/match/match.wxss index 106966af..84166183 100644 --- a/miniprogram/pages/match/match.wxss +++ b/miniprogram/pages/match/match.wxss @@ -80,6 +80,25 @@ border-radius: 20rpx; } +.info-row-price { + align-items: flex-start; +} + +.price-line { + display: flex; + flex-direction: row; + align-items: baseline; + flex-wrap: wrap; + justify-content: flex-end; + gap: 12rpx; +} + +.price-original { + font-size: 26rpx; + color: rgba(255, 255, 255, 0.45); + text-decoration: line-through; +} + .text-brand { color: #00CED1; } diff --git a/miniprogram/pages/read/read.js b/miniprogram/pages/read/read.js index d94da466..3e1466bd 100644 --- a/miniprogram/pages/read/read.js +++ b/miniprogram/pages/read/read.js @@ -146,6 +146,15 @@ function appendQueryToPath(path, key, value) { return `${base}${sep}${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` } +/** 本小程序 wx.navigateTo / switchTab 用的路径:补全前导 / */ +function normalizeMiniProgramNavPath(p) { + if (p == null || typeof p !== 'string') return '' + let s = p.trim() + if (!s) return '' + if (!s.startsWith('/')) s = '/' + s.replace(/^\/+/, '') + return s +} + /** 当前用户已绑定手机号(与 app 内登录态一致) */ function getLoggedInUserPhone() { const u = app.globalData.userInfo || {} @@ -903,6 +912,27 @@ Page({ return } + // 本小程序内页(链接标签类型 internal,#标签 跳转当前小程序页面) + if (tagType === 'internal') { + const path = normalizeMiniProgramNavPath(pagePath || url) + if (!path) { + wx.showToast({ title: '未配置页面路径', icon: 'none' }) + return + } + wx.navigateTo({ + url: path, + fail: () => { + wx.switchTab({ + url: path, + fail: (err) => { + wx.showToast({ title: err.errMsg || '跳转失败', icon: 'none' }) + }, + }) + }, + }) + return + } + // 小程序类型:用密钥查 linkedMiniprograms 得 appId,再唤醒(需在 app.json 的 navigateToMiniProgramAppIdList 中配置) if (tagType === 'miniprogram') { if (!mpKey && label) { @@ -930,10 +960,22 @@ Page({ if (mpKey) wx.showToast({ title: '未找到关联小程序配置', icon: 'none' }) } - // 小程序内部路径(pagePath 或 url 以 /pages/ 开头) - const internalPath = pagePath || (url.startsWith('/pages/') ? url : '') + // 兼容:仅填 pagePath、或 url 为内页路径(非 internal 类型也可走此分支) + const rawInternal = + pagePath || (url.startsWith('/pages/') || url.startsWith('pages/') ? url : '') + const internalPath = normalizeMiniProgramNavPath(rawInternal) if (internalPath) { - wx.navigateTo({ url: internalPath, fail: () => wx.switchTab({ url: internalPath }) }) + wx.navigateTo({ + url: internalPath, + fail: () => { + wx.switchTab({ + url: internalPath, + fail: (err) => { + wx.showToast({ title: err.errMsg || '跳转失败', icon: 'none' }) + }, + }) + }, + }) return } diff --git a/soul-admin/dist/assets/index-CDvJkLCc.js b/soul-admin/dist/assets/index-BSvDfqaj.js similarity index 93% rename from soul-admin/dist/assets/index-CDvJkLCc.js rename to soul-admin/dist/assets/index-BSvDfqaj.js index 828f4813..8b3d1fb8 100644 --- a/soul-admin/dist/assets/index-CDvJkLCc.js +++ b/soul-admin/dist/assets/index-BSvDfqaj.js @@ -6,7 +6,7 @@ function G5(t,e){for(var n=0;n>>1,W=F[V];if(0>>1;Va(de,X))_a(J,de)?(F[V]=J,F[_]=X,V=_):(F[V]=de,F[he]=X,V=he);else if(_a(J,X))F[V]=J,F[_]=X,V=_;else break e}}return xe}function a(F,xe){var X=F.sortIndex-xe.sortIndex;return X!==0?X:F.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,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(F){for(var xe=n(h);xe!==null;){if(xe.callback===null)r(h);else if(xe.startTime<=F)r(h),xe.sortIndex=xe.expirationTime,e(u,xe);else break;xe=n(h)}}function L(F){if(w=!1,C(F),!N)if(n(u)!==null)N=!0,I(R);else{var xe=n(h);xe!==null&&Y(L,xe.startTime-F)}}function R(F,xe){N=!1,w&&(w=!1,k(z),z=-1),b=!0;var X=x;try{for(C(xe),m=n(u);m!==null&&(!(m.expirationTime>xe)||F&&!re());){var V=m.callback;if(typeof V=="function"){m.callback=null,x=m.priorityLevel;var W=V(m.expirationTime<=xe);xe=t.unstable_now(),typeof W=="function"?m.callback=W:m===n(u)&&r(u),C(xe)}else r(u);m=n(u)}if(m!==null)var fe=!0;else{var he=n(h);he!==null&&Y(L,he.startTime-xe),fe=!1}return fe}finally{m=null,x=X,b=!1}}var U=!1,P=null,z=-1,O=5,Q=-1;function re(){return!(t.unstable_now()-QF||125V?(F.sortIndex=X,e(h,F),n(u)===null&&F===n(h)&&(w?(k(z),z=-1):w=!0,Y(L,X-V))):(F.sortIndex=W,e(u,F),N||b||(N=!0,I(R))),F},t.unstable_shouldYield=re,t.unstable_wrapCallback=function(F){var xe=x;return function(){var X=x;x=xe;try{return F.apply(this,arguments)}finally{x=X}}}})(Ox)),Ox}var b1;function Z5(){return b1||(b1=1,Lx.exports=X5()),Lx.exports}/** + */var y1;function X5(){return y1||(y1=1,(function(t){function e(B,xe){var X=B.length;B.push(xe);e:for(;0>>1,W=B[V];if(0>>1;Va(de,X))_a(J,de)?(B[V]=J,B[_]=X,V=_):(B[V]=de,B[he]=X,V=he);else if(_a(J,X))B[V]=J,B[_]=X,V=_;else break e}}return xe}function a(B,xe){var X=B.sortIndex-xe.sortIndex;return X!==0?X:B.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,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(B){for(var xe=n(h);xe!==null;){if(xe.callback===null)r(h);else if(xe.startTime<=B)r(h),xe.sortIndex=xe.expirationTime,e(u,xe);else break;xe=n(h)}}function L(B){if(w=!1,C(B),!N)if(n(u)!==null)N=!0,I(R);else{var xe=n(h);xe!==null&&Y(L,xe.startTime-B)}}function R(B,xe){N=!1,w&&(w=!1,k(F),F=-1),b=!0;var X=x;try{for(C(xe),m=n(u);m!==null&&(!(m.expirationTime>xe)||B&&!re());){var V=m.callback;if(typeof V=="function"){m.callback=null,x=m.priorityLevel;var W=V(m.expirationTime<=xe);xe=t.unstable_now(),typeof W=="function"?m.callback=W:m===n(u)&&r(u),C(xe)}else r(u);m=n(u)}if(m!==null)var fe=!0;else{var he=n(h);he!==null&&Y(L,he.startTime-xe),fe=!1}return fe}finally{m=null,x=X,b=!1}}var U=!1,P=null,F=-1,O=5,Q=-1;function re(){return!(t.unstable_now()-QB||125V?(B.sortIndex=X,e(h,B),n(u)===null&&B===n(h)&&(w?(k(F),F=-1):w=!0,Y(L,X-V))):(B.sortIndex=W,e(u,B),N||b||(N=!0,I(R))),B},t.unstable_shouldYield=re,t.unstable_wrapCallback=function(B){var xe=x;return function(){var X=x;x=xe;try{return B.apply(this,arguments)}finally{x=X}}}})(Ox)),Ox}var b1;function Z5(){return b1||(b1=1,Lx.exports=X5()),Lx.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ function G5(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,S,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=S,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 T(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,T);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,T);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,T);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 C(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,S,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=S,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 T(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,T);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,T);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,T);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 C(l,d,p,y){var j=v.hasOwnProperty(d)?v[d]:null;(j!==null?j.type!==0:y||!(2K||j[A]!==S[K]){var se=` -`+j[A].replace(" at new "," at ");return l.displayName&&se.includes("")&&(se=se.replace("",l.displayName)),se}while(1<=A&&0<=K);break}}}finally{fe=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?W(l):""}function de(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=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 U:return"Portal";case O:return"Profiler";case z:return"StrictMode";case ne:return"Suspense";case le:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case re:return(l.displayName||"Context")+".Consumer";case Q:return(l._context.displayName||"Context")+".Provider";case D: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 J(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===z?"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 $(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function Z(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ae(l){var d=Z(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,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return j.call(this)},set:function(A){y=""+A,S.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=ae(l))}function Fe(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),y="";return l&&(y=Z(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 wt(l,d){var p=d.checked;return X({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function jn(l,d){var p=d.defaultValue==null?"":d.defaultValue,y=d.checked!=null?d.checked:d.defaultChecked;p=$(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 pt(l,d){d=d.checked,d!=null&&C(l,"checked",d,!1)}function At(l,d){pt(l,d);var p=$(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")?Vn(l,d.type,p):d.hasOwnProperty("defaultValue")&&Vn(l,d.type,$(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function fn(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 Vn(l,d,p){(d!=="number"||Ue(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var pn=Array.isArray;function qt(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 rt={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},$t=["Webkit","ms","Moz","O"];Object.keys(rt).forEach(function(l){$t.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),rt[d]=rt[l]})});function kt(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||rt.hasOwnProperty(l)&&rt[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=kt(p,d[p],y);p==="float"&&(p="cssFloat"),y?l.setProperty(p,j):l[p]=j}}var H=X({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(H[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 vt(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 Ft=null;function yt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var ht=null,Pt=null,Gt=null;function kn(l){if(l=Fd(l)){if(typeof ht!="function")throw Error(n(280));var d=l.stateNode;d&&(d=oh(d),ht(l.stateNode,l.type,d))}}function Ts(l){Pt?Gt?Gt.push(l):Gt=[l]:Pt=l}function Ms(){if(Pt){var l=Pt,d=Gt;if(Gt=Pt=null,kn(l),d)for(l=0;l>>=0,l===0?32:31-(il(l)/Ji|0)|0}var er=64,tr=4194304;function xr(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 si(l,d){var p=l.pendingLanes;if(p===0)return 0;var y=0,j=l.suspendedLanes,S=l.pingedLanes,A=p&268435455;if(A!==0){var K=A&~j;K!==0?y=xr(K):(S&=A,S!==0&&(y=xr(S)))}else A=p&~j,A!==0?y=xr(A):S!==0&&(y=xr(S));if(y===0)return 0;if(d!==0&&d!==y&&(d&j)===0&&(j=y&-y,S=d&-d,j>=S||j===16&&(S&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 Ea(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-bs(d),l[d]=p}function ll(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=eo),Td=" ",Md=!1;function Ad(l,d){switch(l){case"keyup":return Sd.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pd(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var M=!1;function ee(l,d){switch(l){case"compositionend":return Pd(d);case"keypress":return d.which!==32?null:(Md=!0,Td);case"textInput":return l=d.data,l===Td&&Md?null:l;default:return null}}function be(l,d){if(M)return l==="compositionend"||!Cd&&Ad(l,d)?(l=aa(),Or=Xi=Nr=null,M=!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=gb(p)}}function bb(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?bb(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function vb(){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 pm(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 t5(l){var d=vb(),p=l.focusedElem,y=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&bb(p.ownerDocument.documentElement,p)){if(y!==null&&pm(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,S=Math.min(y.start,j);y=y.end===void 0?S:Math.min(y.end,j),!l.extend&&S>y&&(j=y,y=S,S=j),j=yb(p,S);var A=yb(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(),S>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,gc=null,mm=null,Od=null,xm=!1;function Nb(l,d,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;xm||gc==null||gc!==Ue(y)||(y=gc,"selectionStart"in y&&pm(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}),Od&&Ld(Od,y)||(Od=y,y=rh(mm,"onSelect"),0wc||(l.current=Tm[wc],Tm[wc]=null,wc--)}function dn(l,d){wc++,Tm[wc]=l.current,l.current=d}var ao={},Rs=ro(ao),rr=ro(!1),yl=ao;function jc(l,d){var p=l.type.contextTypes;if(!p)return ao;var y=l.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===d)return y.__reactInternalMemoizedMaskedChildContext;var j={},S;for(S in p)j[S]=d[S];return y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=j),j}function ar(l){return l=l.childContextTypes,l!=null}function lh(){gn(rr),gn(Rs)}function Db(l,d,p){if(Rs.current!==ao)throw Error(n(168));dn(Rs,d),dn(rr,p)}function _b(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,J(l)||"Unknown",j));return X({},p,y)}function ch(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||ao,yl=Rs.current,dn(Rs,l),dn(rr,rr.current),!0}function $b(l,d,p){var y=l.stateNode;if(!y)throw Error(n(169));p?(l=_b(l,d,yl),y.__reactInternalMemoizedMergedChildContext=l,gn(rr),gn(Rs),dn(Rs,l)):gn(rr),dn(rr,p)}var pi=null,dh=!1,Mm=!1;function zb(l){pi===null?pi=[l]:pi.push(l)}function f5(l){dh=!0,zb(l)}function io(){if(!Mm&&pi!==null){Mm=!0;var l=0,d=Nt;try{var p=pi;for(Nt=1;l>=A,j-=A,mi=1<<32-bs(d)+j|p<mt?(ds=ct,ct=null):ds=ct.sibling;var Ht=Te(pe,ct,ge[mt],Oe);if(Ht===null){ct===null&&(ct=ds);break}l&&ct&&Ht.alternate===null&&d(pe,ct),ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht,ct=ds}if(mt===ge.length)return p(pe,ct),Nn&&vl(pe,mt),nt;if(ct===null){for(;mtmt?(ds=ct,ct=null):ds=ct.sibling;var xo=Te(pe,ct,Ht.value,Oe);if(xo===null){ct===null&&(ct=ds);break}l&&ct&&xo.alternate===null&&d(pe,ct),ie=S(xo,ie,mt),lt===null?nt=xo:lt.sibling=xo,lt=xo,ct=ds}if(Ht.done)return p(pe,ct),Nn&&vl(pe,mt),nt;if(ct===null){for(;!Ht.done;mt++,Ht=ge.next())Ht=Ie(pe,Ht.value,Oe),Ht!==null&&(ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht);return Nn&&vl(pe,mt),nt}for(ct=y(pe,ct);!Ht.done;mt++,Ht=ge.next())Ht=qe(ct,pe,mt,Ht.value,Oe),Ht!==null&&(l&&Ht.alternate!==null&&ct.delete(Ht.key===null?mt:Ht.key),ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht);return l&&ct.forEach(function(q5){return d(pe,q5)}),Nn&&vl(pe,mt),nt}function zn(pe,ie,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 nt=ge.key,lt=ie;lt!==null;){if(lt.key===nt){if(nt=ge.type,nt===P){if(lt.tag===7){p(pe,lt.sibling),ie=j(lt,ge.props.children),ie.return=pe,pe=ie;break e}}else if(lt.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===I&&Wb(nt)===lt.type){p(pe,lt.sibling),ie=j(lt,ge.props),ie.ref=Bd(pe,lt,ge),ie.return=pe,pe=ie;break e}p(pe,lt);break}else d(pe,lt);lt=lt.sibling}ge.type===P?(ie=Tl(ge.props.children,pe.mode,Oe,ge.key),ie.return=pe,pe=ie):(Oe=$h(ge.type,ge.key,ge.props,null,pe.mode,Oe),Oe.ref=Bd(pe,ie,ge),Oe.return=pe,pe=Oe)}return A(pe);case U:e:{for(lt=ge.key;ie!==null;){if(ie.key===lt)if(ie.tag===4&&ie.stateNode.containerInfo===ge.containerInfo&&ie.stateNode.implementation===ge.implementation){p(pe,ie.sibling),ie=j(ie,ge.children||[]),ie.return=pe,pe=ie;break e}else{p(pe,ie);break}else d(pe,ie);ie=ie.sibling}ie=Cx(ge,pe.mode,Oe),ie.return=pe,pe=ie}return A(pe);case I:return lt=ge._init,zn(pe,ie,lt(ge._payload),Oe)}if(pn(ge))return Xe(pe,ie,ge,Oe);if(xe(ge))return tt(pe,ie,ge,Oe);ph(pe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,ie!==null&&ie.tag===6?(p(pe,ie.sibling),ie=j(ie,ge),ie.return=pe,pe=ie):(p(pe,ie),ie=Sx(ge,pe.mode,Oe),ie.return=pe,pe=ie),A(pe)):p(pe,ie)}return zn}var Ec=Kb(!0),qb=Kb(!1),mh=ro(null),xh=null,Tc=null,Om=null;function Dm(){Om=Tc=xh=null}function _m(l){var d=mh.current;gn(mh),l._currentValue=d}function $m(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 Mc(l,d){xh=l,Om=Tc=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(ir=!0),l.firstContext=null)}function Fr(l){var d=l._currentValue;if(Om!==l)if(l={context:l,memoizedValue:d,next:null},Tc===null){if(xh===null)throw Error(n(308));Tc=l,xh.dependencies={lanes:0,firstContext:l}}else Tc=Tc.next=l;return d}var Nl=null;function zm(l){Nl===null?Nl=[l]:Nl.push(l)}function Gb(l,d,p,y){var j=d.interleaved;return j===null?(p.next=p,zm(d)):(p.next=j.next,j.next=p),d.interleaved=p,gi(l,y)}function gi(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 oo=!1;function Fm(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Jb(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 yi(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function lo(l,d,p){var y=l.updateQueue;if(y===null)return null;if(y=y.shared,(Bt&2)!==0){var j=y.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),y.pending=d,gi(l,p)}return j=y.interleaved,j===null?(d.next=d,zm(y)):(d.next=j.next,j.next=d),y.interleaved=d,gi(l,p)}function gh(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,Ta(l,p)}}function Qb(l,d){var p=l.updateQueue,y=l.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var j=null,S=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};S===null?j=S=A:S=S.next=A,p=p.next}while(p!==null);S===null?j=S=d:S=S.next=d}else j=S=d;p={baseState:y.baseState,firstBaseUpdate:j,lastBaseUpdate:S,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 yh(l,d,p,y){var j=l.updateQueue;oo=!1;var S=j.firstBaseUpdate,A=j.lastBaseUpdate,K=j.shared.pending;if(K!==null){j.shared.pending=null;var se=K,ye=se.next;se.next=null,A===null?S=ye:A.next=ye,A=se;var Pe=l.alternate;Pe!==null&&(Pe=Pe.updateQueue,K=Pe.lastBaseUpdate,K!==A&&(K===null?Pe.firstBaseUpdate=ye:K.next=ye,Pe.lastBaseUpdate=se))}if(S!==null){var Ie=j.baseState;A=0,Pe=ye=se=null,K=S;do{var Te=K.lane,qe=K.eventTime;if((y&Te)===Te){Pe!==null&&(Pe=Pe.next={eventTime:qe,lane:0,tag:K.tag,payload:K.payload,callback:K.callback,next:null});e:{var Xe=l,tt=K;switch(Te=d,qe=p,tt.tag){case 1:if(Xe=tt.payload,typeof Xe=="function"){Ie=Xe.call(qe,Ie,Te);break e}Ie=Xe;break e;case 3:Xe.flags=Xe.flags&-65537|128;case 0:if(Xe=tt.payload,Te=typeof Xe=="function"?Xe.call(qe,Ie,Te):Xe,Te==null)break e;Ie=X({},Ie,Te);break e;case 2:oo=!0}}K.callback!==null&&K.lane!==0&&(l.flags|=64,Te=j.effects,Te===null?j.effects=[K]:Te.push(K))}else qe={eventTime:qe,lane:Te,tag:K.tag,payload:K.payload,callback:K.callback,next:null},Pe===null?(ye=Pe=qe,se=Ie):Pe=Pe.next=qe,A|=Te;if(K=K.next,K===null){if(K=j.shared.pending,K===null)break;Te=K,K=Te.next,Te.next=null,j.lastBaseUpdate=Te,j.shared.pending=null}}while(!0);if(Pe===null&&(se=Ie),j.baseState=se,j.firstBaseUpdate=ye,j.lastBaseUpdate=Pe,d=j.shared.interleaved,d!==null){j=d;do A|=j.lane,j=j.next;while(j!==d)}else S===null&&(j.shared.lanes=0);kl|=A,l.lanes=A,l.memoizedState=Ie}}function Yb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var y=Wm.transition;Wm.transition={};try{l(!1),d()}finally{Nt=p,Wm.transition=y}}function xv(){return Br().memoizedState}function g5(l,d,p){var y=fo(l);if(p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},gv(l))yv(d,p);else if(p=Gb(l,d,p,y),p!==null){var j=Ks();fa(p,l,y,j),bv(p,d,y)}}function y5(l,d,p){var y=fo(l),j={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(gv(l))yv(d,j);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var A=d.lastRenderedState,K=S(A,p);if(j.hasEagerState=!0,j.eagerState=K,la(K,A)){var se=d.interleaved;se===null?(j.next=j,zm(d)):(j.next=se.next,se.next=j),d.interleaved=j;return}}catch{}finally{}p=Gb(l,d,j,y),p!==null&&(j=Ks(),fa(p,l,y,j),bv(p,d,y))}}function gv(l){var d=l.alternate;return l===En||d!==null&&d===En}function yv(l,d){Wd=Nh=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function bv(l,d,p){if((p&4194240)!==0){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Ta(l,p)}}var kh={readContext:Fr,useCallback:Ls,useContext:Ls,useEffect:Ls,useImperativeHandle:Ls,useInsertionEffect:Ls,useLayoutEffect:Ls,useMemo:Ls,useReducer:Ls,useRef:Ls,useState:Ls,useDebugValue:Ls,useDeferredValue:Ls,useTransition:Ls,useMutableSource:Ls,useSyncExternalStore:Ls,useId:Ls,unstable_isNewReconciler:!1},b5={readContext:Fr,useCallback:function(l,d){return _a().memoizedState=[l,d===void 0?null:d],l},useContext:Fr,useEffect:lv,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,wh(4194308,4,uv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return wh(4194308,4,l,d)},useInsertionEffect:function(l,d){return wh(4,2,l,d)},useMemo:function(l,d){var p=_a();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var y=_a();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=g5.bind(null,En,l),[y.memoizedState,l]},useRef:function(l){var d=_a();return l={current:l},d.memoizedState=l},useState:iv,useDebugValue:Xm,useDeferredValue:function(l){return _a().memoizedState=l},useTransition:function(){var l=iv(!1),d=l[0];return l=x5.bind(null,l[1]),_a().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var y=En,j=_a();if(Nn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),cs===null)throw Error(n(349));(jl&30)!==0||tv(y,d,p)}j.memoizedState=p;var S={value:p,getSnapshot:d};return j.queue=S,lv(sv.bind(null,y,S,l),[l]),y.flags|=2048,Gd(9,nv.bind(null,y,S,p,d),void 0,null),p},useId:function(){var l=_a(),d=cs.identifierPrefix;if(Nn){var p=xi,y=mi;p=(y&~(1<<32-bs(y)-1)).toString(32)+p,d=":"+d+"R"+p,p=Kd++,0")&&(se=se.replace("",l.displayName)),se}while(1<=A&&0<=K);break}}}finally{fe=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?W(l):""}function de(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=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 U:return"Portal";case O:return"Profiler";case F:return"StrictMode";case ne:return"Suspense";case le:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case re:return(l.displayName||"Context")+".Consumer";case Q:return(l._context.displayName||"Context")+".Provider";case D: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 J(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===F?"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 $(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function Z(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ae(l){var d=Z(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,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return j.call(this)},set:function(A){y=""+A,S.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=ae(l))}function Fe(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),y="";return l&&(y=Z(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 wt(l,d){var p=d.checked;return X({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function jn(l,d){var p=d.defaultValue==null?"":d.defaultValue,y=d.checked!=null?d.checked:d.defaultChecked;p=$(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 pt(l,d){d=d.checked,d!=null&&C(l,"checked",d,!1)}function At(l,d){pt(l,d);var p=$(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")?Vn(l,d.type,p):d.hasOwnProperty("defaultValue")&&Vn(l,d.type,$(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function fn(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 Vn(l,d,p){(d!=="number"||Ue(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var pn=Array.isArray;function qt(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 rt={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},$t=["Webkit","ms","Moz","O"];Object.keys(rt).forEach(function(l){$t.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),rt[d]=rt[l]})});function St(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||rt.hasOwnProperty(l)&&rt[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=St(p,d[p],y);p==="float"&&(p="cssFloat"),y?l.setProperty(p,j):l[p]=j}}var H=X({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(H[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 vt(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 Ft=null;function yt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var ht=null,Pt=null,Gt=null;function kn(l){if(l=Fd(l)){if(typeof ht!="function")throw Error(n(280));var d=l.stateNode;d&&(d=oh(d),ht(l.stateNode,l.type,d))}}function Ts(l){Pt?Gt?Gt.push(l):Gt=[l]:Pt=l}function Ms(){if(Pt){var l=Pt,d=Gt;if(Gt=Pt=null,kn(l),d)for(l=0;l>>=0,l===0?32:31-(il(l)/Ji|0)|0}var er=64,tr=4194304;function xr(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 si(l,d){var p=l.pendingLanes;if(p===0)return 0;var y=0,j=l.suspendedLanes,S=l.pingedLanes,A=p&268435455;if(A!==0){var K=A&~j;K!==0?y=xr(K):(S&=A,S!==0&&(y=xr(S)))}else A=p&~j,A!==0?y=xr(A):S!==0&&(y=xr(S));if(y===0)return 0;if(d!==0&&d!==y&&(d&j)===0&&(j=y&-y,S=d&-d,j>=S||j===16&&(S&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 Ea(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-bs(d),l[d]=p}function ll(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=eo),Td=" ",Md=!1;function Ad(l,d){switch(l){case"keyup":return Sd.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pd(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var M=!1;function ee(l,d){switch(l){case"compositionend":return Pd(d);case"keypress":return d.which!==32?null:(Md=!0,Td);case"textInput":return l=d.data,l===Td&&Md?null:l;default:return null}}function be(l,d){if(M)return l==="compositionend"||!Cd&&Ad(l,d)?(l=aa(),Or=Xi=Nr=null,M=!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=gb(p)}}function bb(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?bb(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function vb(){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 pm(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 t5(l){var d=vb(),p=l.focusedElem,y=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&bb(p.ownerDocument.documentElement,p)){if(y!==null&&pm(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,S=Math.min(y.start,j);y=y.end===void 0?S:Math.min(y.end,j),!l.extend&&S>y&&(j=y,y=S,S=j),j=yb(p,S);var A=yb(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(),S>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,gc=null,mm=null,Od=null,xm=!1;function Nb(l,d,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;xm||gc==null||gc!==Ue(y)||(y=gc,"selectionStart"in y&&pm(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}),Od&&Ld(Od,y)||(Od=y,y=rh(mm,"onSelect"),0wc||(l.current=Tm[wc],Tm[wc]=null,wc--)}function dn(l,d){wc++,Tm[wc]=l.current,l.current=d}var ao={},Rs=ro(ao),rr=ro(!1),yl=ao;function jc(l,d){var p=l.type.contextTypes;if(!p)return ao;var y=l.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===d)return y.__reactInternalMemoizedMaskedChildContext;var j={},S;for(S in p)j[S]=d[S];return y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=j),j}function ar(l){return l=l.childContextTypes,l!=null}function lh(){gn(rr),gn(Rs)}function Db(l,d,p){if(Rs.current!==ao)throw Error(n(168));dn(Rs,d),dn(rr,p)}function _b(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,J(l)||"Unknown",j));return X({},p,y)}function ch(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||ao,yl=Rs.current,dn(Rs,l),dn(rr,rr.current),!0}function $b(l,d,p){var y=l.stateNode;if(!y)throw Error(n(169));p?(l=_b(l,d,yl),y.__reactInternalMemoizedMergedChildContext=l,gn(rr),gn(Rs),dn(Rs,l)):gn(rr),dn(rr,p)}var pi=null,dh=!1,Mm=!1;function zb(l){pi===null?pi=[l]:pi.push(l)}function f5(l){dh=!0,zb(l)}function io(){if(!Mm&&pi!==null){Mm=!0;var l=0,d=Nt;try{var p=pi;for(Nt=1;l>=A,j-=A,mi=1<<32-bs(d)+j|p<mt?(us=ct,ct=null):us=ct.sibling;var Ht=Te(pe,ct,ge[mt],Oe);if(Ht===null){ct===null&&(ct=us);break}l&&ct&&Ht.alternate===null&&d(pe,ct),ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht,ct=us}if(mt===ge.length)return p(pe,ct),Nn&&vl(pe,mt),nt;if(ct===null){for(;mtmt?(us=ct,ct=null):us=ct.sibling;var xo=Te(pe,ct,Ht.value,Oe);if(xo===null){ct===null&&(ct=us);break}l&&ct&&xo.alternate===null&&d(pe,ct),ie=S(xo,ie,mt),lt===null?nt=xo:lt.sibling=xo,lt=xo,ct=us}if(Ht.done)return p(pe,ct),Nn&&vl(pe,mt),nt;if(ct===null){for(;!Ht.done;mt++,Ht=ge.next())Ht=Ie(pe,Ht.value,Oe),Ht!==null&&(ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht);return Nn&&vl(pe,mt),nt}for(ct=y(pe,ct);!Ht.done;mt++,Ht=ge.next())Ht=qe(ct,pe,mt,Ht.value,Oe),Ht!==null&&(l&&Ht.alternate!==null&&ct.delete(Ht.key===null?mt:Ht.key),ie=S(Ht,ie,mt),lt===null?nt=Ht:lt.sibling=Ht,lt=Ht);return l&&ct.forEach(function(q5){return d(pe,q5)}),Nn&&vl(pe,mt),nt}function zn(pe,ie,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 nt=ge.key,lt=ie;lt!==null;){if(lt.key===nt){if(nt=ge.type,nt===P){if(lt.tag===7){p(pe,lt.sibling),ie=j(lt,ge.props.children),ie.return=pe,pe=ie;break e}}else if(lt.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===I&&Wb(nt)===lt.type){p(pe,lt.sibling),ie=j(lt,ge.props),ie.ref=Bd(pe,lt,ge),ie.return=pe,pe=ie;break e}p(pe,lt);break}else d(pe,lt);lt=lt.sibling}ge.type===P?(ie=Tl(ge.props.children,pe.mode,Oe,ge.key),ie.return=pe,pe=ie):(Oe=$h(ge.type,ge.key,ge.props,null,pe.mode,Oe),Oe.ref=Bd(pe,ie,ge),Oe.return=pe,pe=Oe)}return A(pe);case U:e:{for(lt=ge.key;ie!==null;){if(ie.key===lt)if(ie.tag===4&&ie.stateNode.containerInfo===ge.containerInfo&&ie.stateNode.implementation===ge.implementation){p(pe,ie.sibling),ie=j(ie,ge.children||[]),ie.return=pe,pe=ie;break e}else{p(pe,ie);break}else d(pe,ie);ie=ie.sibling}ie=Cx(ge,pe.mode,Oe),ie.return=pe,pe=ie}return A(pe);case I:return lt=ge._init,zn(pe,ie,lt(ge._payload),Oe)}if(pn(ge))return Xe(pe,ie,ge,Oe);if(xe(ge))return tt(pe,ie,ge,Oe);ph(pe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,ie!==null&&ie.tag===6?(p(pe,ie.sibling),ie=j(ie,ge),ie.return=pe,pe=ie):(p(pe,ie),ie=Sx(ge,pe.mode,Oe),ie.return=pe,pe=ie),A(pe)):p(pe,ie)}return zn}var Ec=Kb(!0),qb=Kb(!1),mh=ro(null),xh=null,Tc=null,Om=null;function Dm(){Om=Tc=xh=null}function _m(l){var d=mh.current;gn(mh),l._currentValue=d}function $m(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 Mc(l,d){xh=l,Om=Tc=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(ir=!0),l.firstContext=null)}function Fr(l){var d=l._currentValue;if(Om!==l)if(l={context:l,memoizedValue:d,next:null},Tc===null){if(xh===null)throw Error(n(308));Tc=l,xh.dependencies={lanes:0,firstContext:l}}else Tc=Tc.next=l;return d}var Nl=null;function zm(l){Nl===null?Nl=[l]:Nl.push(l)}function Gb(l,d,p,y){var j=d.interleaved;return j===null?(p.next=p,zm(d)):(p.next=j.next,j.next=p),d.interleaved=p,gi(l,y)}function gi(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 oo=!1;function Fm(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Jb(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 yi(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function lo(l,d,p){var y=l.updateQueue;if(y===null)return null;if(y=y.shared,(Bt&2)!==0){var j=y.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),y.pending=d,gi(l,p)}return j=y.interleaved,j===null?(d.next=d,zm(y)):(d.next=j.next,j.next=d),y.interleaved=d,gi(l,p)}function gh(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,Ta(l,p)}}function Qb(l,d){var p=l.updateQueue,y=l.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var j=null,S=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};S===null?j=S=A:S=S.next=A,p=p.next}while(p!==null);S===null?j=S=d:S=S.next=d}else j=S=d;p={baseState:y.baseState,firstBaseUpdate:j,lastBaseUpdate:S,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 yh(l,d,p,y){var j=l.updateQueue;oo=!1;var S=j.firstBaseUpdate,A=j.lastBaseUpdate,K=j.shared.pending;if(K!==null){j.shared.pending=null;var se=K,ye=se.next;se.next=null,A===null?S=ye:A.next=ye,A=se;var Pe=l.alternate;Pe!==null&&(Pe=Pe.updateQueue,K=Pe.lastBaseUpdate,K!==A&&(K===null?Pe.firstBaseUpdate=ye:K.next=ye,Pe.lastBaseUpdate=se))}if(S!==null){var Ie=j.baseState;A=0,Pe=ye=se=null,K=S;do{var Te=K.lane,qe=K.eventTime;if((y&Te)===Te){Pe!==null&&(Pe=Pe.next={eventTime:qe,lane:0,tag:K.tag,payload:K.payload,callback:K.callback,next:null});e:{var Xe=l,tt=K;switch(Te=d,qe=p,tt.tag){case 1:if(Xe=tt.payload,typeof Xe=="function"){Ie=Xe.call(qe,Ie,Te);break e}Ie=Xe;break e;case 3:Xe.flags=Xe.flags&-65537|128;case 0:if(Xe=tt.payload,Te=typeof Xe=="function"?Xe.call(qe,Ie,Te):Xe,Te==null)break e;Ie=X({},Ie,Te);break e;case 2:oo=!0}}K.callback!==null&&K.lane!==0&&(l.flags|=64,Te=j.effects,Te===null?j.effects=[K]:Te.push(K))}else qe={eventTime:qe,lane:Te,tag:K.tag,payload:K.payload,callback:K.callback,next:null},Pe===null?(ye=Pe=qe,se=Ie):Pe=Pe.next=qe,A|=Te;if(K=K.next,K===null){if(K=j.shared.pending,K===null)break;Te=K,K=Te.next,Te.next=null,j.lastBaseUpdate=Te,j.shared.pending=null}}while(!0);if(Pe===null&&(se=Ie),j.baseState=se,j.firstBaseUpdate=ye,j.lastBaseUpdate=Pe,d=j.shared.interleaved,d!==null){j=d;do A|=j.lane,j=j.next;while(j!==d)}else S===null&&(j.shared.lanes=0);kl|=A,l.lanes=A,l.memoizedState=Ie}}function Yb(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var y=Wm.transition;Wm.transition={};try{l(!1),d()}finally{Nt=p,Wm.transition=y}}function xv(){return Br().memoizedState}function g5(l,d,p){var y=fo(l);if(p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},gv(l))yv(d,p);else if(p=Gb(l,d,p,y),p!==null){var j=Ks();fa(p,l,y,j),bv(p,d,y)}}function y5(l,d,p){var y=fo(l),j={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(gv(l))yv(d,j);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var A=d.lastRenderedState,K=S(A,p);if(j.hasEagerState=!0,j.eagerState=K,la(K,A)){var se=d.interleaved;se===null?(j.next=j,zm(d)):(j.next=se.next,se.next=j),d.interleaved=j;return}}catch{}finally{}p=Gb(l,d,j,y),p!==null&&(j=Ks(),fa(p,l,y,j),bv(p,d,y))}}function gv(l){var d=l.alternate;return l===En||d!==null&&d===En}function yv(l,d){Wd=Nh=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function bv(l,d,p){if((p&4194240)!==0){var y=d.lanes;y&=l.pendingLanes,p|=y,d.lanes=p,Ta(l,p)}}var kh={readContext:Fr,useCallback:Ls,useContext:Ls,useEffect:Ls,useImperativeHandle:Ls,useInsertionEffect:Ls,useLayoutEffect:Ls,useMemo:Ls,useReducer:Ls,useRef:Ls,useState:Ls,useDebugValue:Ls,useDeferredValue:Ls,useTransition:Ls,useMutableSource:Ls,useSyncExternalStore:Ls,useId:Ls,unstable_isNewReconciler:!1},b5={readContext:Fr,useCallback:function(l,d){return _a().memoizedState=[l,d===void 0?null:d],l},useContext:Fr,useEffect:lv,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,wh(4194308,4,uv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return wh(4194308,4,l,d)},useInsertionEffect:function(l,d){return wh(4,2,l,d)},useMemo:function(l,d){var p=_a();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var y=_a();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=g5.bind(null,En,l),[y.memoizedState,l]},useRef:function(l){var d=_a();return l={current:l},d.memoizedState=l},useState:iv,useDebugValue:Xm,useDeferredValue:function(l){return _a().memoizedState=l},useTransition:function(){var l=iv(!1),d=l[0];return l=x5.bind(null,l[1]),_a().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var y=En,j=_a();if(Nn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),ds===null)throw Error(n(349));(jl&30)!==0||tv(y,d,p)}j.memoizedState=p;var S={value:p,getSnapshot:d};return j.queue=S,lv(sv.bind(null,y,S,l),[l]),y.flags|=2048,Gd(9,nv.bind(null,y,S,p,d),void 0,null),p},useId:function(){var l=_a(),d=ds.identifierPrefix;if(Nn){var p=xi,y=mi;p=(y&~(1<<32-bs(y)-1)).toString(32)+p,d=":"+d+"R"+p,p=Kd++,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[Oa]=d,l[zd]=y,zv(l,d,!1,!1),d.stateNode=l;e:{switch(A=vt(p,y),p){case"dialog":xn("cancel",l),xn("close",l),j=y;break;case"iframe":case"object":case"embed":xn("load",l),j=y;break;case"video":case"audio":for(j=0;jLc&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304)}else{if(!y)if(l=bh(A),l!==null){if(d.flags|=128,y=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Jd(S,!0),S.tail===null&&S.tailMode==="hidden"&&!A.alternate&&!Nn)return Os(d),null}else 2*mn()-S.renderingStartTime>Lc&&p!==1073741824&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304);S.isBackwards?(A.sibling=d.child,d.child=A):(p=S.last,p!==null?p.sibling=A:d.child=A,S.last=A)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=mn(),d.sibling=null,p=Cn.current,dn(Cn,y?p&1|2:p&1),d):(Os(d),null);case 22:case 23:return wx(),y=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(d.flags|=8192),y&&(d.mode&1)!==0?(kr&1073741824)!==0&&(Os(d),d.subtreeFlags&6&&(d.flags|=8192)):Os(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function E5(l,d){switch(Pm(d),d.tag){case 1:return ar(d.type)&&lh(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Ac(),gn(rr),gn(Rs),Um(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Vm(d),null;case 13:if(gn(Cn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Cc()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return gn(Cn),null;case 4:return Ac(),null;case 10:return _m(d.type._context),null;case 22:case 23:return wx(),null;case 24:return null;default:return null}}var Th=!1,Ds=!1,T5=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function Ic(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){An(l,d,y)}else p.current=null}function dx(l,d,p){try{p()}catch(y){An(l,d,y)}}var Vv=!1;function M5(l,d){if(wm=Lr,l=vb(),pm(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,S=y.focusNode;y=y.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var A=0,K=-1,se=-1,ye=0,Pe=0,Ie=l,Te=null;t:for(;;){for(var qe;Ie!==p||j!==0&&Ie.nodeType!==3||(K=A+j),Ie!==S||y!==0&&Ie.nodeType!==3||(se=A+y),Ie.nodeType===3&&(A+=Ie.nodeValue.length),(qe=Ie.firstChild)!==null;)Te=Ie,Ie=qe;for(;;){if(Ie===l)break t;if(Te===p&&++ye===j&&(K=A),Te===S&&++Pe===y&&(se=A),(qe=Ie.nextSibling)!==null)break;Ie=Te,Te=Ie.parentNode}Ie=qe}p=K===-1||se===-1?null:{start:K,end:se}}else p=null}p=p||{start:0,end:0}}else p=null;for(jm={focusedElem:l,selectionRange:p},Lr=!1,Ye=d;Ye!==null;)if(d=Ye,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ye=l;else for(;Ye!==null;){d=Ye;try{var Xe=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Xe!==null){var tt=Xe.memoizedProps,zn=Xe.memoizedState,pe=d.stateNode,ie=pe.getSnapshotBeforeUpdate(d.elementType===d.type?tt:da(d.type,tt),zn);pe.__reactInternalSnapshotBeforeUpdate=ie}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){An(d,d.return,Oe)}if(l=d.sibling,l!==null){l.return=d.return,Ye=l;break}Ye=d.return}return Xe=Vv,Vv=!1,Xe}function Qd(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 S=j.destroy;j.destroy=void 0,S!==void 0&&dx(d,p,S)}j=j.next}while(j!==y)}}function Mh(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 ux(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 Hv(l){var d=l.alternate;d!==null&&(l.alternate=null,Hv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Oa],delete d[zd],delete d[Em],delete d[u5],delete d[h5])),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 Uv(l){return l.tag===5||l.tag===3||l.tag===4}function Wv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Uv(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 hx(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=ih));else if(y!==4&&(l=l.child,l!==null))for(hx(l,d,p),l=l.sibling;l!==null;)hx(l,d,p),l=l.sibling}function fx(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(fx(l,d,p),l=l.sibling;l!==null;)fx(l,d,p),l=l.sibling}var ws=null,ua=!1;function co(l,d,p){for(p=p.child;p!==null;)Kv(l,d,p),p=p.sibling}function Kv(l,d,p){if(Zs&&typeof Zs.onCommitFiberUnmount=="function")try{Zs.onCommitFiberUnmount(Xs,p)}catch{}switch(p.tag){case 5:Ds||Ic(p,d);case 6:var y=ws,j=ua;ws=null,co(l,d,p),ws=y,ua=j,ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):ws.removeChild(p.stateNode));break;case 18:ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?Cm(l.parentNode,p):l.nodeType===1&&Cm(l,p),Ia(l)):Cm(ws,p.stateNode));break;case 4:y=ws,j=ua,ws=p.stateNode.containerInfo,ua=!0,co(l,d,p),ws=y,ua=j;break;case 0:case 11:case 14:case 15:if(!Ds&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var S=j,A=S.destroy;S=S.tag,A!==void 0&&((S&2)!==0||(S&4)!==0)&&dx(p,d,A),j=j.next}while(j!==y)}co(l,d,p);break;case 1:if(!Ds&&(Ic(p,d),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(K){An(p,d,K)}co(l,d,p);break;case 21:co(l,d,p);break;case 22:p.mode&1?(Ds=(y=Ds)||p.memoizedState!==null,co(l,d,p),Ds=y):co(l,d,p);break;default:co(l,d,p)}}function qv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new T5),d.forEach(function(y){var j=$5.bind(null,l,y);p.has(y)||(p.add(y),y.then(j,j))})}}function ha(l,d){var p=d.deletions;if(p!==null)for(var y=0;yj&&(j=A),y&=~S}if(y=j,y=mn()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*P5(y/1960))-y,10l?16:l,ho===null)var y=!1;else{if(l=ho,ho=null,Lh=0,(Bt&6)!==0)throw Error(n(331));var j=Bt;for(Bt|=4,Ye=l.current;Ye!==null;){var S=Ye,A=S.child;if((Ye.flags&16)!==0){var K=S.deletions;if(K!==null){for(var se=0;semn()-xx?Cl(l,0):mx|=p),lr(l,d)}function i1(l,d){d===0&&((l.mode&1)===0?d=1:(d=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var p=Ks();l=gi(l,d),l!==null&&(Ea(l,d,p),lr(l,p))}function _5(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),i1(l,p)}function $5(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),i1(l,p)}var o1;o1=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||rr.current)ir=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return ir=!1,S5(l,d,p);ir=(l.flags&131072)!==0}else ir=!1,Nn&&(d.flags&1048576)!==0&&Fb(d,hh,d.index);switch(d.lanes=0,d.tag){case 2:var y=d.type;Eh(l,d),l=d.pendingProps;var j=jc(d,Rs.current);Mc(d,p),j=qm(null,d,y,l,j,p);var S=Gm();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,ar(y)?(S=!0,ch(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Fm(d),j.updater=Sh,d.stateNode=j,j._reactInternals=d,ex(d,y,l,p),d=rx(null,d,y,!0,S,p)):(d.tag=0,Nn&&S&&Am(d),Ws(null,d,j,p),d=d.child),d;case 16:y=d.elementType;e:{switch(Eh(l,d),l=d.pendingProps,j=y._init,y=j(y._payload),d.type=y,j=d.tag=F5(y),l=da(y,l),j){case 0:d=sx(null,d,y,l,p);break e;case 1:d=Rv(null,d,y,l,p);break e;case 11:d=Tv(null,d,y,l,p);break e;case 14:d=Mv(null,d,y,da(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:da(y,j),sx(l,d,y,j,p);case 1:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Rv(l,d,y,j,p);case 3:e:{if(Lv(d),l===null)throw Error(n(387));y=d.pendingProps,S=d.memoizedState,j=S.element,Jb(l,d),yh(d,y,null,p);var A=d.memoizedState;if(y=A.element,S.isDehydrated)if(S={element:y,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=Pc(Error(n(423)),d),d=Ov(l,d,y,p,j);break e}else if(y!==j){j=Pc(Error(n(424)),d),d=Ov(l,d,y,p,j);break e}else for(jr=so(d.stateNode.containerInfo.firstChild),wr=d,Nn=!0,ca=null,p=qb(d,null,y,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Cc(),y===j){d=bi(l,d,p);break e}Ws(l,d,y,p)}d=d.child}return d;case 5:return Xb(d),l===null&&Rm(d),y=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,A=j.children,km(y,j)?A=null:S!==null&&km(y,S)&&(d.flags|=32),Iv(l,d),Ws(l,d,A,p),d.child;case 6:return l===null&&Rm(d),null;case 13:return Dv(l,d,p);case 4:return Bm(d,d.stateNode.containerInfo),y=d.pendingProps,l===null?d.child=Ec(d,null,y,p):Ws(l,d,y,p),d.child;case 11:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Tv(l,d,y,j,p);case 7:return Ws(l,d,d.pendingProps,p),d.child;case 8:return Ws(l,d,d.pendingProps.children,p),d.child;case 12:return Ws(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(y=d.type._context,j=d.pendingProps,S=d.memoizedProps,A=j.value,dn(mh,y._currentValue),y._currentValue=A,S!==null)if(la(S.value,A)){if(S.children===j.children&&!rr.current){d=bi(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var K=S.dependencies;if(K!==null){A=S.child;for(var se=K.firstContext;se!==null;){if(se.context===y){if(S.tag===1){se=yi(-1,p&-p),se.tag=2;var ye=S.updateQueue;if(ye!==null){ye=ye.shared;var Pe=ye.pending;Pe===null?se.next=se:(se.next=Pe.next,Pe.next=se),ye.pending=se}}S.lanes|=p,se=S.alternate,se!==null&&(se.lanes|=p),$m(S.return,p,d),K.lanes|=p;break}se=se.next}}else if(S.tag===10)A=S.type===d.type?null:S.child;else if(S.tag===18){if(A=S.return,A===null)throw Error(n(341));A.lanes|=p,K=A.alternate,K!==null&&(K.lanes|=p),$m(A,p,d),A=S.sibling}else A=S.child;if(A!==null)A.return=S;else for(A=S;A!==null;){if(A===d){A=null;break}if(S=A.sibling,S!==null){S.return=A.return,A=S;break}A=A.return}S=A}Ws(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,y=d.pendingProps.children,Mc(d,p),j=Fr(j),y=y(j),d.flags|=1,Ws(l,d,y,p),d.child;case 14:return y=d.type,j=da(y,d.pendingProps),j=da(y.type,j),Mv(l,d,y,j,p);case 15:return Av(l,d,d.type,d.pendingProps,p);case 17:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Eh(l,d),d.tag=1,ar(y)?(l=!0,ch(d)):l=!1,Mc(d,p),Nv(d,y,j),ex(d,y,j,p),rx(null,d,y,!0,l,p);case 19:return $v(l,d,p);case 22:return Pv(l,d,p)}throw Error(n(156,d.tag))};function l1(l,d){return Tt(l,d)}function z5(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 Hr(l,d,p,y){return new z5(l,d,p,y)}function kx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function F5(l){if(typeof l=="function")return kx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===D)return 11;if(l===me)return 14}return 2}function mo(l,d){var p=l.alternate;return p===null?(p=Hr(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 $h(l,d,p,y,j,S){var A=2;if(y=l,typeof l=="function")kx(l)&&(A=1);else if(typeof l=="string")A=5;else e:switch(l){case P:return Tl(p.children,j,S,d);case z:A=8,j|=8;break;case O:return l=Hr(12,p,d,j|2),l.elementType=O,l.lanes=S,l;case ne:return l=Hr(13,p,d,j),l.elementType=ne,l.lanes=S,l;case le:return l=Hr(19,p,d,j),l.elementType=le,l.lanes=S,l;case Y:return zh(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case Q:A=10;break e;case re:A=9;break e;case D: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=Hr(A,p,d,j),d.elementType=l,d.type=y,d.lanes=S,d}function Tl(l,d,p,y){return l=Hr(7,l,y,d),l.lanes=p,l}function zh(l,d,p,y){return l=Hr(22,l,y,d),l.elementType=Y,l.lanes=p,l.stateNode={isHidden:!1},l}function Sx(l,d,p){return l=Hr(6,l,null,d),l.lanes=p,l}function Cx(l,d,p){return d=Hr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function B5(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=Qi(0),this.expirationTimes=Qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qi(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function Ex(l,d,p,y,j,S,A,K,se){return l=new B5(l,d,p,K,se),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Hr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fm(S),l}function V5(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(),Rx.exports=eE(),Rx.exports}var w1;function tE(){if(w1)return Kh;w1=1;var t=Fj();return Kh.createRoot=t.createRoot,Kh.hydrateRoot=t.hydrateRoot,Kh}var nE=tE(),hd=Fj();const Bj=zj(hd);/** +`+S.stack}return{value:l,source:d,stack:j,digest:null}}function tx(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function nx(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var w5=typeof WeakMap=="function"?WeakMap:Map;function jv(l,d,p){p=yi(-1,p),p.tag=3,p.payload={element:null};var y=d.value;return p.callback=function(){Ih||(Ih=!0,gx=y),nx(l,d)},p}function kv(l,d,p){p=yi(-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(){nx(l,d)}}var S=l.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){nx(l,d),typeof y!="function"&&(uo===null?uo=new Set([this]):uo.add(this));var A=d.stack;this.componentDidCatch(d.value,{componentStack:A!==null?A:""})}),p}function Sv(l,d,p){var y=l.pingCache;if(y===null){y=l.pingCache=new w5;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=D5.bind(null,l,d,p),d.then(l,l))}function Cv(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 Ev(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=yi(-1,1),d.tag=2,lo(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=j,l)}var j5=L.ReactCurrentOwner,ir=!1;function Ws(l,d,p,y){d.child=l===null?qb(d,null,p,y):Ec(d,l.child,p,y)}function Tv(l,d,p,y,j){p=p.render;var S=d.ref;return Mc(d,j),y=qm(l,d,p,y,S,j),p=Gm(),l!==null&&!ir?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,bi(l,d,j)):(Nn&&p&&Am(d),d.flags|=1,Ws(l,d,y,j),d.child)}function Mv(l,d,p,y,j){if(l===null){var S=p.type;return typeof S=="function"&&!kx(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=S,Av(l,d,S,y,j)):(l=$h(p.type,null,y,d,d.mode,j),l.ref=d.ref,l.return=d,d.child=l)}if(S=l.child,(l.lanes&j)===0){var A=S.memoizedProps;if(p=p.compare,p=p!==null?p:Ld,p(A,y)&&l.ref===d.ref)return bi(l,d,j)}return d.flags|=1,l=mo(S,y),l.ref=d.ref,l.return=d,d.child=l}function Av(l,d,p,y,j){if(l!==null){var S=l.memoizedProps;if(Ld(S,y)&&l.ref===d.ref)if(ir=!1,d.pendingProps=y=S,(l.lanes&j)!==0)(l.flags&131072)!==0&&(ir=!0);else return d.lanes=l.lanes,bi(l,d,j)}return sx(l,d,p,y,j)}function Pv(l,d,p){var y=d.pendingProps,j=y.children,S=l!==null?l.memoizedState:null;if(y.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},dn(Rc,kr),kr|=p;else{if((p&1073741824)===0)return l=S!==null?S.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,dn(Rc,kr),kr|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=S!==null?S.baseLanes:p,dn(Rc,kr),kr|=y}else S!==null?(y=S.baseLanes|p,d.memoizedState=null):y=p,dn(Rc,kr),kr|=y;return Ws(l,d,j,p),d.child}function Iv(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function sx(l,d,p,y,j){var S=ar(p)?yl:Rs.current;return S=jc(d,S),Mc(d,j),p=qm(l,d,p,y,S,j),y=Gm(),l!==null&&!ir?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~j,bi(l,d,j)):(Nn&&y&&Am(d),d.flags|=1,Ws(l,d,p,j),d.child)}function Rv(l,d,p,y,j){if(ar(p)){var S=!0;ch(d)}else S=!1;if(Mc(d,j),d.stateNode===null)Eh(l,d),Nv(d,p,y),ex(d,p,y,j),y=!0;else if(l===null){var A=d.stateNode,K=d.memoizedProps;A.props=K;var se=A.context,ye=p.contextType;typeof ye=="object"&&ye!==null?ye=Fr(ye):(ye=ar(p)?yl:Rs.current,ye=jc(d,ye));var Pe=p.getDerivedStateFromProps,Ie=typeof Pe=="function"||typeof A.getSnapshotBeforeUpdate=="function";Ie||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(K!==y||se!==ye)&&wv(d,A,y,ye),oo=!1;var Te=d.memoizedState;A.state=Te,yh(d,y,A,j),se=d.memoizedState,K!==y||Te!==se||rr.current||oo?(typeof Pe=="function"&&(Zm(d,p,Pe,y),se=d.memoizedState),(K=oo||vv(d,p,K,y,Te,se,ye))?(Ie||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=se),A.props=y,A.state=se,A.context=ye,y=K):(typeof A.componentDidMount=="function"&&(d.flags|=4194308),y=!1)}else{A=d.stateNode,Jb(l,d),K=d.memoizedProps,ye=d.type===d.elementType?K:da(d.type,K),A.props=ye,Ie=d.pendingProps,Te=A.context,se=p.contextType,typeof se=="object"&&se!==null?se=Fr(se):(se=ar(p)?yl:Rs.current,se=jc(d,se));var qe=p.getDerivedStateFromProps;(Pe=typeof qe=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(K!==Ie||Te!==se)&&wv(d,A,y,se),oo=!1,Te=d.memoizedState,A.state=Te,yh(d,y,A,j);var Xe=d.memoizedState;K!==Ie||Te!==Xe||rr.current||oo?(typeof qe=="function"&&(Zm(d,p,qe,y),Xe=d.memoizedState),(ye=oo||vv(d,p,ye,y,Te,Xe,se)||!1)?(Pe||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(y,Xe,se),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(y,Xe,se)),typeof A.componentDidUpdate=="function"&&(d.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof A.componentDidUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=1024),d.memoizedProps=y,d.memoizedState=Xe),A.props=y,A.state=Xe,A.context=se,y=ye):(typeof A.componentDidUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||K===l.memoizedProps&&Te===l.memoizedState||(d.flags|=1024),y=!1)}return rx(l,d,p,y,S,j)}function rx(l,d,p,y,j,S){Iv(l,d);var A=(d.flags&128)!==0;if(!y&&!A)return j&&$b(d,p,!1),bi(l,d,S);y=d.stateNode,j5.current=d;var K=A&&typeof p.getDerivedStateFromError!="function"?null:y.render();return d.flags|=1,l!==null&&A?(d.child=Ec(d,l.child,null,S),d.child=Ec(d,null,K,S)):Ws(l,d,K,S),d.memoizedState=y.state,j&&$b(d,p,!0),d.child}function Lv(l){var d=l.stateNode;d.pendingContext?Db(l,d.pendingContext,d.pendingContext!==d.context):d.context&&Db(l,d.context,!1),Bm(l,d.containerInfo)}function Ov(l,d,p,y,j){return Cc(),Lm(j),d.flags|=256,Ws(l,d,p,y),d.child}var ax={dehydrated:null,treeContext:null,retryLane:0};function ix(l){return{baseLanes:l,cachePool:null,transitions:null}}function Dv(l,d,p){var y=d.pendingProps,j=Cn.current,S=!1,A=(d.flags&128)!==0,K;if((K=A)||(K=l!==null&&l.memoizedState===null?!1:(j&2)!==0),K?(S=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(j|=1),dn(Cn,j&1),l===null)return Rm(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,S?(y=d.mode,S=d.child,A={mode:"hidden",children:A},(y&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=A):S=zh(A,y,0,null),l=Tl(l,y,p,null),S.return=d,l.return=d,S.sibling=l,d.child=S,d.child.memoizedState=ix(p),d.memoizedState=ax,l):ox(d,A));if(j=l.memoizedState,j!==null&&(K=j.dehydrated,K!==null))return k5(l,d,A,y,K,j,p);if(S){S=y.fallback,A=d.mode,j=l.child,K=j.sibling;var se={mode:"hidden",children:y.children};return(A&1)===0&&d.child!==j?(y=d.child,y.childLanes=0,y.pendingProps=se,d.deletions=null):(y=mo(j,se),y.subtreeFlags=j.subtreeFlags&14680064),K!==null?S=mo(K,S):(S=Tl(S,A,p,null),S.flags|=2),S.return=d,y.return=d,y.sibling=S,d.child=y,y=S,S=d.child,A=l.child.memoizedState,A=A===null?ix(p):{baseLanes:A.baseLanes|p,cachePool:null,transitions:A.transitions},S.memoizedState=A,S.childLanes=l.childLanes&~p,d.memoizedState=ax,y}return S=l.child,l=S.sibling,y=mo(S,{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 ox(l,d){return d=zh({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function Ch(l,d,p,y){return y!==null&&Lm(y),Ec(d,l.child,null,p),l=ox(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function k5(l,d,p,y,j,S,A){if(p)return d.flags&256?(d.flags&=-257,y=tx(Error(n(422))),Ch(l,d,A,y)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(S=y.fallback,j=d.mode,y=zh({mode:"visible",children:y.children},j,0,null),S=Tl(S,j,A,null),S.flags|=2,y.return=d,S.return=d,y.sibling=S,d.child=y,(d.mode&1)!==0&&Ec(d,l.child,null,A),d.child.memoizedState=ix(A),d.memoizedState=ax,S);if((d.mode&1)===0)return Ch(l,d,A,null);if(j.data==="$!"){if(y=j.nextSibling&&j.nextSibling.dataset,y)var K=y.dgst;return y=K,S=Error(n(419)),y=tx(S,y,void 0),Ch(l,d,A,y)}if(K=(A&l.childLanes)!==0,ir||K){if(y=ds,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!==S.retryLane&&(S.retryLane=j,gi(l,j),fa(y,l,j,-1))}return jx(),y=tx(Error(n(421))),Ch(l,d,A,y)}return j.data==="$?"?(d.flags|=128,d.child=l.child,d=_5.bind(null,l),j._reactRetry=d,null):(l=S.treeContext,jr=so(j.nextSibling),wr=d,Nn=!0,ca=null,l!==null&&($r[zr++]=mi,$r[zr++]=xi,$r[zr++]=bl,mi=l.id,xi=l.overflow,bl=d),d=ox(d,y.children),d.flags|=4096,d)}function _v(l,d,p){l.lanes|=d;var y=l.alternate;y!==null&&(y.lanes|=d),$m(l.return,d,p)}function lx(l,d,p,y,j){var S=l.memoizedState;S===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:j}:(S.isBackwards=d,S.rendering=null,S.renderingStartTime=0,S.last=y,S.tail=p,S.tailMode=j)}function $v(l,d,p){var y=d.pendingProps,j=y.revealOrder,S=y.tail;if(Ws(l,d,y.children,p),y=Cn.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&&_v(l,p,d);else if(l.tag===19)_v(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(dn(Cn,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&&bh(l)===null&&(j=p),p=p.sibling;p=j,p===null?(j=d.child,d.child=null):(j=p.sibling,p.sibling=null),lx(d,!1,j,p,S);break;case"backwards":for(p=null,j=d.child,d.child=null;j!==null;){if(l=j.alternate,l!==null&&bh(l)===null){d.child=j;break}l=j.sibling,j.sibling=p,p=j,j=l}lx(d,!0,p,null,S);break;case"together":lx(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function Eh(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function bi(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),kl|=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=mo(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=mo(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function S5(l,d,p){switch(d.tag){case 3:Lv(d),Cc();break;case 5:Xb(d);break;case 1:ar(d.type)&&ch(d);break;case 4:Bm(d,d.stateNode.containerInfo);break;case 10:var y=d.type._context,j=d.memoizedProps.value;dn(mh,y._currentValue),y._currentValue=j;break;case 13:if(y=d.memoizedState,y!==null)return y.dehydrated!==null?(dn(Cn,Cn.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?Dv(l,d,p):(dn(Cn,Cn.current&1),l=bi(l,d,p),l!==null?l.sibling:null);dn(Cn,Cn.current&1);break;case 19:if(y=(p&d.childLanes)!==0,(l.flags&128)!==0){if(y)return $v(l,d,p);d.flags|=128}if(j=d.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),dn(Cn,Cn.current),y)break;return null;case 22:case 23:return d.lanes=0,Pv(l,d,p)}return bi(l,d,p)}var zv,cx,Fv,Bv;zv=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}},cx=function(){},Fv=function(l,d,p,y){var j=l.memoizedProps;if(j!==y){l=d.stateNode,wl(Da.current);var S=null;switch(p){case"input":j=wt(l,j),y=wt(l,y),S=[];break;case"select":j=X({},j,{value:void 0}),y=X({},y,{value:void 0}),S=[];break;case"textarea":j=bn(l,j),y=bn(l,y),S=[];break;default:typeof j.onClick!="function"&&typeof y.onClick=="function"&&(l.onclick=ih)}Qe(p,y);var A;p=null;for(ye in j)if(!y.hasOwnProperty(ye)&&j.hasOwnProperty(ye)&&j[ye]!=null)if(ye==="style"){var K=j[ye];for(A in K)K.hasOwnProperty(A)&&(p||(p={}),p[A]="")}else ye!=="dangerouslySetInnerHTML"&&ye!=="children"&&ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&ye!=="autoFocus"&&(a.hasOwnProperty(ye)?S||(S=[]):(S=S||[]).push(ye,null));for(ye in y){var se=y[ye];if(K=j!=null?j[ye]:void 0,y.hasOwnProperty(ye)&&se!==K&&(se!=null||K!=null))if(ye==="style")if(K){for(A in K)!K.hasOwnProperty(A)||se&&se.hasOwnProperty(A)||(p||(p={}),p[A]="");for(A in se)se.hasOwnProperty(A)&&K[A]!==se[A]&&(p||(p={}),p[A]=se[A])}else p||(S||(S=[]),S.push(ye,p)),p=se;else ye==="dangerouslySetInnerHTML"?(se=se?se.__html:void 0,K=K?K.__html:void 0,se!=null&&K!==se&&(S=S||[]).push(ye,se)):ye==="children"?typeof se!="string"&&typeof se!="number"||(S=S||[]).push(ye,""+se):ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&(a.hasOwnProperty(ye)?(se!=null&&ye==="onScroll"&&xn("scroll",l),S||K===se||(S=[])):(S=S||[]).push(ye,se))}p&&(S=S||[]).push("style",p);var ye=S;(d.updateQueue=ye)&&(d.flags|=4)}},Bv=function(l,d,p,y){p!==y&&(d.flags|=4)};function Jd(l,d){if(!Nn)switch(l.tailMode){case"hidden":d=l.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var 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 Os(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 C5(l,d,p){var y=d.pendingProps;switch(Pm(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Os(d),null;case 1:return ar(d.type)&&lh(),Os(d),null;case 3:return y=d.stateNode,Ac(),gn(rr),gn(Rs),Um(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(l===null||l.child===null)&&(fh(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,ca!==null&&(vx(ca),ca=null))),cx(l,d),Os(d),null;case 5:Vm(d);var j=wl(Ud.current);if(p=d.type,l!==null&&d.stateNode!=null)Fv(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 Os(d),null}if(l=wl(Da.current),fh(d)){y=d.stateNode,p=d.type;var S=d.memoizedProps;switch(y[Oa]=d,y[zd]=S,l=(d.mode&1)!==0,p){case"dialog":xn("cancel",y),xn("close",y);break;case"iframe":case"object":case"embed":xn("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[Oa]=d,l[zd]=y,zv(l,d,!1,!1),d.stateNode=l;e:{switch(A=vt(p,y),p){case"dialog":xn("cancel",l),xn("close",l),j=y;break;case"iframe":case"object":case"embed":xn("load",l),j=y;break;case"video":case"audio":for(j=0;jLc&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304)}else{if(!y)if(l=bh(A),l!==null){if(d.flags|=128,y=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Jd(S,!0),S.tail===null&&S.tailMode==="hidden"&&!A.alternate&&!Nn)return Os(d),null}else 2*mn()-S.renderingStartTime>Lc&&p!==1073741824&&(d.flags|=128,y=!0,Jd(S,!1),d.lanes=4194304);S.isBackwards?(A.sibling=d.child,d.child=A):(p=S.last,p!==null?p.sibling=A:d.child=A,S.last=A)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=mn(),d.sibling=null,p=Cn.current,dn(Cn,y?p&1|2:p&1),d):(Os(d),null);case 22:case 23:return wx(),y=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(d.flags|=8192),y&&(d.mode&1)!==0?(kr&1073741824)!==0&&(Os(d),d.subtreeFlags&6&&(d.flags|=8192)):Os(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function E5(l,d){switch(Pm(d),d.tag){case 1:return ar(d.type)&&lh(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Ac(),gn(rr),gn(Rs),Um(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Vm(d),null;case 13:if(gn(Cn),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Cc()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return gn(Cn),null;case 4:return Ac(),null;case 10:return _m(d.type._context),null;case 22:case 23:return wx(),null;case 24:return null;default:return null}}var Th=!1,Ds=!1,T5=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function Ic(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){An(l,d,y)}else p.current=null}function dx(l,d,p){try{p()}catch(y){An(l,d,y)}}var Vv=!1;function M5(l,d){if(wm=Lr,l=vb(),pm(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,S=y.focusNode;y=y.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var A=0,K=-1,se=-1,ye=0,Pe=0,Ie=l,Te=null;t:for(;;){for(var qe;Ie!==p||j!==0&&Ie.nodeType!==3||(K=A+j),Ie!==S||y!==0&&Ie.nodeType!==3||(se=A+y),Ie.nodeType===3&&(A+=Ie.nodeValue.length),(qe=Ie.firstChild)!==null;)Te=Ie,Ie=qe;for(;;){if(Ie===l)break t;if(Te===p&&++ye===j&&(K=A),Te===S&&++Pe===y&&(se=A),(qe=Ie.nextSibling)!==null)break;Ie=Te,Te=Ie.parentNode}Ie=qe}p=K===-1||se===-1?null:{start:K,end:se}}else p=null}p=p||{start:0,end:0}}else p=null;for(jm={focusedElem:l,selectionRange:p},Lr=!1,Ye=d;Ye!==null;)if(d=Ye,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Ye=l;else for(;Ye!==null;){d=Ye;try{var Xe=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Xe!==null){var tt=Xe.memoizedProps,zn=Xe.memoizedState,pe=d.stateNode,ie=pe.getSnapshotBeforeUpdate(d.elementType===d.type?tt:da(d.type,tt),zn);pe.__reactInternalSnapshotBeforeUpdate=ie}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){An(d,d.return,Oe)}if(l=d.sibling,l!==null){l.return=d.return,Ye=l;break}Ye=d.return}return Xe=Vv,Vv=!1,Xe}function Qd(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 S=j.destroy;j.destroy=void 0,S!==void 0&&dx(d,p,S)}j=j.next}while(j!==y)}}function Mh(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 ux(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 Hv(l){var d=l.alternate;d!==null&&(l.alternate=null,Hv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Oa],delete d[zd],delete d[Em],delete d[u5],delete d[h5])),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 Uv(l){return l.tag===5||l.tag===3||l.tag===4}function Wv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Uv(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 hx(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=ih));else if(y!==4&&(l=l.child,l!==null))for(hx(l,d,p),l=l.sibling;l!==null;)hx(l,d,p),l=l.sibling}function fx(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(fx(l,d,p),l=l.sibling;l!==null;)fx(l,d,p),l=l.sibling}var ws=null,ua=!1;function co(l,d,p){for(p=p.child;p!==null;)Kv(l,d,p),p=p.sibling}function Kv(l,d,p){if(Zs&&typeof Zs.onCommitFiberUnmount=="function")try{Zs.onCommitFiberUnmount(Xs,p)}catch{}switch(p.tag){case 5:Ds||Ic(p,d);case 6:var y=ws,j=ua;ws=null,co(l,d,p),ws=y,ua=j,ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):ws.removeChild(p.stateNode));break;case 18:ws!==null&&(ua?(l=ws,p=p.stateNode,l.nodeType===8?Cm(l.parentNode,p):l.nodeType===1&&Cm(l,p),Ia(l)):Cm(ws,p.stateNode));break;case 4:y=ws,j=ua,ws=p.stateNode.containerInfo,ua=!0,co(l,d,p),ws=y,ua=j;break;case 0:case 11:case 14:case 15:if(!Ds&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){j=y=y.next;do{var S=j,A=S.destroy;S=S.tag,A!==void 0&&((S&2)!==0||(S&4)!==0)&&dx(p,d,A),j=j.next}while(j!==y)}co(l,d,p);break;case 1:if(!Ds&&(Ic(p,d),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(K){An(p,d,K)}co(l,d,p);break;case 21:co(l,d,p);break;case 22:p.mode&1?(Ds=(y=Ds)||p.memoizedState!==null,co(l,d,p),Ds=y):co(l,d,p);break;default:co(l,d,p)}}function qv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new T5),d.forEach(function(y){var j=$5.bind(null,l,y);p.has(y)||(p.add(y),y.then(j,j))})}}function ha(l,d){var p=d.deletions;if(p!==null)for(var y=0;yj&&(j=A),y&=~S}if(y=j,y=mn()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*P5(y/1960))-y,10l?16:l,ho===null)var y=!1;else{if(l=ho,ho=null,Lh=0,(Bt&6)!==0)throw Error(n(331));var j=Bt;for(Bt|=4,Ye=l.current;Ye!==null;){var S=Ye,A=S.child;if((Ye.flags&16)!==0){var K=S.deletions;if(K!==null){for(var se=0;semn()-xx?Cl(l,0):mx|=p),lr(l,d)}function i1(l,d){d===0&&((l.mode&1)===0?d=1:(d=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var p=Ks();l=gi(l,d),l!==null&&(Ea(l,d,p),lr(l,p))}function _5(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),i1(l,p)}function $5(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),i1(l,p)}var o1;o1=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||rr.current)ir=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return ir=!1,S5(l,d,p);ir=(l.flags&131072)!==0}else ir=!1,Nn&&(d.flags&1048576)!==0&&Fb(d,hh,d.index);switch(d.lanes=0,d.tag){case 2:var y=d.type;Eh(l,d),l=d.pendingProps;var j=jc(d,Rs.current);Mc(d,p),j=qm(null,d,y,l,j,p);var S=Gm();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,ar(y)?(S=!0,ch(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Fm(d),j.updater=Sh,d.stateNode=j,j._reactInternals=d,ex(d,y,l,p),d=rx(null,d,y,!0,S,p)):(d.tag=0,Nn&&S&&Am(d),Ws(null,d,j,p),d=d.child),d;case 16:y=d.elementType;e:{switch(Eh(l,d),l=d.pendingProps,j=y._init,y=j(y._payload),d.type=y,j=d.tag=F5(y),l=da(y,l),j){case 0:d=sx(null,d,y,l,p);break e;case 1:d=Rv(null,d,y,l,p);break e;case 11:d=Tv(null,d,y,l,p);break e;case 14:d=Mv(null,d,y,da(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:da(y,j),sx(l,d,y,j,p);case 1:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Rv(l,d,y,j,p);case 3:e:{if(Lv(d),l===null)throw Error(n(387));y=d.pendingProps,S=d.memoizedState,j=S.element,Jb(l,d),yh(d,y,null,p);var A=d.memoizedState;if(y=A.element,S.isDehydrated)if(S={element:y,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=Pc(Error(n(423)),d),d=Ov(l,d,y,p,j);break e}else if(y!==j){j=Pc(Error(n(424)),d),d=Ov(l,d,y,p,j);break e}else for(jr=so(d.stateNode.containerInfo.firstChild),wr=d,Nn=!0,ca=null,p=qb(d,null,y,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Cc(),y===j){d=bi(l,d,p);break e}Ws(l,d,y,p)}d=d.child}return d;case 5:return Xb(d),l===null&&Rm(d),y=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,A=j.children,km(y,j)?A=null:S!==null&&km(y,S)&&(d.flags|=32),Iv(l,d),Ws(l,d,A,p),d.child;case 6:return l===null&&Rm(d),null;case 13:return Dv(l,d,p);case 4:return Bm(d,d.stateNode.containerInfo),y=d.pendingProps,l===null?d.child=Ec(d,null,y,p):Ws(l,d,y,p),d.child;case 11:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Tv(l,d,y,j,p);case 7:return Ws(l,d,d.pendingProps,p),d.child;case 8:return Ws(l,d,d.pendingProps.children,p),d.child;case 12:return Ws(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(y=d.type._context,j=d.pendingProps,S=d.memoizedProps,A=j.value,dn(mh,y._currentValue),y._currentValue=A,S!==null)if(la(S.value,A)){if(S.children===j.children&&!rr.current){d=bi(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var K=S.dependencies;if(K!==null){A=S.child;for(var se=K.firstContext;se!==null;){if(se.context===y){if(S.tag===1){se=yi(-1,p&-p),se.tag=2;var ye=S.updateQueue;if(ye!==null){ye=ye.shared;var Pe=ye.pending;Pe===null?se.next=se:(se.next=Pe.next,Pe.next=se),ye.pending=se}}S.lanes|=p,se=S.alternate,se!==null&&(se.lanes|=p),$m(S.return,p,d),K.lanes|=p;break}se=se.next}}else if(S.tag===10)A=S.type===d.type?null:S.child;else if(S.tag===18){if(A=S.return,A===null)throw Error(n(341));A.lanes|=p,K=A.alternate,K!==null&&(K.lanes|=p),$m(A,p,d),A=S.sibling}else A=S.child;if(A!==null)A.return=S;else for(A=S;A!==null;){if(A===d){A=null;break}if(S=A.sibling,S!==null){S.return=A.return,A=S;break}A=A.return}S=A}Ws(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,y=d.pendingProps.children,Mc(d,p),j=Fr(j),y=y(j),d.flags|=1,Ws(l,d,y,p),d.child;case 14:return y=d.type,j=da(y,d.pendingProps),j=da(y.type,j),Mv(l,d,y,j,p);case 15:return Av(l,d,d.type,d.pendingProps,p);case 17:return y=d.type,j=d.pendingProps,j=d.elementType===y?j:da(y,j),Eh(l,d),d.tag=1,ar(y)?(l=!0,ch(d)):l=!1,Mc(d,p),Nv(d,y,j),ex(d,y,j,p),rx(null,d,y,!0,l,p);case 19:return $v(l,d,p);case 22:return Pv(l,d,p)}throw Error(n(156,d.tag))};function l1(l,d){return jt(l,d)}function z5(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 Hr(l,d,p,y){return new z5(l,d,p,y)}function kx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function F5(l){if(typeof l=="function")return kx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===D)return 11;if(l===me)return 14}return 2}function mo(l,d){var p=l.alternate;return p===null?(p=Hr(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 $h(l,d,p,y,j,S){var A=2;if(y=l,typeof l=="function")kx(l)&&(A=1);else if(typeof l=="string")A=5;else e:switch(l){case P:return Tl(p.children,j,S,d);case F:A=8,j|=8;break;case O:return l=Hr(12,p,d,j|2),l.elementType=O,l.lanes=S,l;case ne:return l=Hr(13,p,d,j),l.elementType=ne,l.lanes=S,l;case le:return l=Hr(19,p,d,j),l.elementType=le,l.lanes=S,l;case Y:return zh(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case Q:A=10;break e;case re:A=9;break e;case D: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=Hr(A,p,d,j),d.elementType=l,d.type=y,d.lanes=S,d}function Tl(l,d,p,y){return l=Hr(7,l,y,d),l.lanes=p,l}function zh(l,d,p,y){return l=Hr(22,l,y,d),l.elementType=Y,l.lanes=p,l.stateNode={isHidden:!1},l}function Sx(l,d,p){return l=Hr(6,l,null,d),l.lanes=p,l}function Cx(l,d,p){return d=Hr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function B5(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=Qi(0),this.expirationTimes=Qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qi(0),this.identifierPrefix=y,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function Ex(l,d,p,y,j,S,A,K,se){return l=new B5(l,d,p,K,se),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Hr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fm(S),l}function V5(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(),Rx.exports=eE(),Rx.exports}var w1;function tE(){if(w1)return Kh;w1=1;var t=Fj();return Kh.createRoot=t.createRoot,Kh.hydrateRoot=t.hydrateRoot,Kh}var nE=tE(),hd=Fj();const Bj=zj(hd);/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. @@ -544,7 +544,7 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const LA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ts=Ee("trash-2",LA);/** + */const LA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ns=Ee("trash-2",LA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -584,7 +584,7 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const HA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Kn=Ee("users",HA);/** + */const HA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],qn=Ee("users",HA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. @@ -604,12 +604,12 @@ Error generating stack: `+S.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const JA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ns=Ee("x",JA);/** + */const JA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ss=Ee("x",JA);/** * @license lucide-react v0.562.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const QA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Ho=Ee("zap",QA),ey="admin_token";function Ku(){try{return localStorage.getItem(ey)}catch{return null}}function YA(t){try{localStorage.setItem(ey,t)}catch{}}function zx(){try{localStorage.removeItem(ey)}catch{}}const XA="https://soulapi.quwanzhi.com",ZA=15e3,F1=6e4,eP=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return XA};function Vl(t){const e=eP(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function $p(t,e={}){const{data:n,...r}=e,a=Vl(t),i=new Headers(r.headers),o=Ku();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??ZA,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 Le(t,e){return $p(t,{...e,method:"GET"})}function bt(t,e,n){return $p(t,{...n,method:"POST",data:e})}function tn(t,e,n){return $p(t,{...n,method:"PUT",data:e})}function Pi(t,e){return $p(t,{...e,method:"DELETE"})}function tP(){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(Xj,{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(ns,{className:"w-4 h-4"})})]}):null}const nP=[{icon:EM,label:"数据概览",href:"/dashboard"},{icon:ur,label:"内容管理",href:"/content"},{icon:Kn,label:"用户管理",href:"/users"},{icon:aM,label:"找伙伴",href:"/find-partner"},{icon:sd,label:"推广中心",href:"/distribution"}];function sP(){const t=Xo(),e=g.useRef(t.pathname);e.current=t.pathname;const n=Ya(),[r,a]=g.useState(!1),[i,o]=g.useState(!1);g.useEffect(()=>{a(!0)},[]),g.useEffect(()=>{if(!r)return;let u=!1;if(!Ku()){n("/login",{replace:!0});return}return Le("/api/admin").then(h=>{u||(h&&h.success!==!1?o(!0):(zx(),n("/login",{replace:!0,state:{from:e.current}})))}).catch(()=>{u||(zx(),n("/login",{replace:!0,state:{from:e.current}}))}),()=>{u=!0}},[r,n]);const c=async()=>{zx();try{await bt("/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:[nP.map(u=>{const h=t.pathname===u.href;return s.jsxs(_i,{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(_i,{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(Po,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]}),s.jsxs(_i,{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(QT,{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($M,{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(tP,{}),s.jsx("div",{className:"w-full min-w-0 min-h-full flex-1",children:s.jsx(JE,{})})]})]})}function B1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ty(...t){return e=>{let n=!1;const r=t.map(a=>{const i=B1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;ck(i)&&typeof _f=="function"&&(i=_f(i._payload));const c=g.Children.toArray(i),u=c.find(lP);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 uk=dk("Slot");function iP(t){const e=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(ck(a)&&typeof _f=="function"&&(a=_f(a._payload)),g.isValidElement(a)){const o=dP(a),c=cP(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(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 oP=Symbol("radix.slottable");function lP(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===oP}function cP(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 dP(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 hk(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,H1=fk,pk=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return H1(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=V1(f)||V1(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 H1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},uP=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),mk=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),$f="-",U1=[],fP="arbitrary..",pP=t=>{const e=xP(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return mP(o);const c=o.split($f),u=c[0]===""&&c.length>1?1:0;return xk(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?uP(h,u):u:h||U1}return n[o]||U1}}},xk=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=xk(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join($f):t.slice(e).join($f),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?fP+r:void 0})(),xP=t=>{const{theme:e,classGroups:n}=t;return gP(n,e)},gP=(t,e)=>{const n=mk();for(const r in t){const a=t[r];ny(a,n,r,e)}return n},ny=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){bP(t,e,n);return}if(typeof t=="function"){vP(t,e,n,r);return}NP(t,e,n,r)},bP=(t,e,n)=>{const r=t===""?e:gk(e,t);r.classGroupId=n},vP=(t,e,n,r)=>{if(wP(t)){ny(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(hP(n,t))},NP=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split($f),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,jP=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)}}},Gg="!",W1=":",kP=[],K1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),SP=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 K1(i,b,x,N)};if(e){const a=e+W1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):K1(kP,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},CP=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}},EP=t=>({cache:jP(t.cacheSize),parseClassName:SP(t),sortModifiers:CP(t),...pP(t)}),TP=/\s+/,MP=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(TP);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 T=x.length===0?"":x.length===1?x[0]:i(x).join(":"),C=b?T+Gg:T,L=C+k;if(o.indexOf(L)>-1)continue;o.push(L);const R=a(k,v);for(let U=0;U0?" "+u:u)}return u},AP=(...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=EP(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=MP(u,n);return a(u,f),f};return i=o,(...u)=>i(AP(...u))},IP=[],es=t=>{const e=n=>n[t]||IP;return e.isThemeGetter=!0,e},bk=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vk=/^\((?:(\w[\w-]*):)?(.+)\)$/i,RP=/^\d+\/\d+$/,LP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,OP=/\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$/,DP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_P=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$P=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dc=t=>RP.test(t),Ct=t=>!!t&&!Number.isNaN(Number(t)),go=t=>!!t&&Number.isInteger(Number(t)),Fx=t=>t.endsWith("%")&&Ct(t.slice(0,-1)),wi=t=>LP.test(t),zP=()=>!0,FP=t=>OP.test(t)&&!DP.test(t),Nk=()=>!1,BP=t=>_P.test(t),VP=t=>$P.test(t),HP=t=>!Ze(t)&&!et(t),UP=t=>md(t,kk,Nk),Ze=t=>bk.test(t),Ml=t=>md(t,Sk,FP),Bx=t=>md(t,JP,Ct),q1=t=>md(t,wk,Nk),WP=t=>md(t,jk,VP),Yh=t=>md(t,Ck,BP),et=t=>vk.test(t),su=t=>xd(t,Sk),KP=t=>xd(t,QP),G1=t=>xd(t,wk),qP=t=>xd(t,kk),GP=t=>xd(t,jk),Xh=t=>xd(t,Ck,!0),md=(t,e,n)=>{const r=bk.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},xd=(t,e,n=!1)=>{const r=vk.exec(t);return r?r[1]?e(r[1]):n:!1},wk=t=>t==="position"||t==="percentage",jk=t=>t==="image"||t==="url",kk=t=>t==="length"||t==="size"||t==="bg-size",Sk=t=>t==="length",JP=t=>t==="number",QP=t=>t==="family-name",Ck=t=>t==="shadow",YP=()=>{const t=es("color"),e=es("font"),n=es("text"),r=es("font-weight"),a=es("tracking"),i=es("leading"),o=es("breakpoint"),c=es("container"),u=es("spacing"),h=es("radius"),f=es("shadow"),m=es("inset-shadow"),x=es("text-shadow"),b=es("drop-shadow"),N=es("blur"),w=es("perspective"),v=es("aspect"),k=es("ease"),T=es("animate"),C=()=>["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(),et,Ze],U=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],z=()=>[et,Ze,u],O=()=>[Dc,"full","auto",...z()],Q=()=>[go,"none","subgrid",et,Ze],re=()=>["auto",{span:["full",go,et,Ze]},go,et,Ze],D=()=>[go,"auto",et,Ze],ne=()=>["auto","min","max","fr",et,Ze],le=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],me=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...z()],Y=()=>[Dc,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...z()],F=()=>[t,et,Ze],xe=()=>[...L(),G1,q1,{position:[et,Ze]}],X=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",qP,UP,{size:[et,Ze]}],W=()=>[Fx,su,Ml],fe=()=>["","none","full",h,et,Ze],he=()=>["",Ct,su,Ml],de=()=>["solid","dashed","dotted","double"],_=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[Ct,Fx,G1,q1],$=()=>["","none",N,et,Ze],Z=()=>["none",Ct,et,Ze],ae=()=>["none",Ct,et,Ze],we=()=>[Ct,et,Ze],Fe=()=>[Dc,"full",...z()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[wi],breakpoint:[wi],color:[zP],container:[wi],"drop-shadow":[wi],ease:["in","out","in-out"],font:[HP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[wi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[wi],shadow:[wi],spacing:["px",Ct],text:[wi],"text-shadow":[wi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Dc,Ze,et,v]}],container:["container"],columns:[{columns:[Ct,Ze,et,c]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"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:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],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:[go,"auto",et,Ze]}],basis:[{basis:[Dc,"full","auto",c,...z()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ct,Dc,"auto","initial","none",Ze]}],grow:[{grow:["",Ct,et,Ze]}],shrink:[{shrink:["",Ct,et,Ze]}],order:[{order:[go,"first","last","none",et,Ze]}],"grid-cols":[{"grid-cols":Q()}],"col-start-end":[{col:re()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":Q()}],"row-start-end":[{row:re()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:z()}],"gap-x":[{"gap-x":z()}],"gap-y":[{"gap-y":z()}],"justify-content":[{justify:[...le(),"normal"]}],"justify-items":[{"justify-items":[...me(),"normal"]}],"justify-self":[{"justify-self":["auto",...me()]}],"align-content":[{content:["normal",...le()]}],"align-items":[{items:[...me(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...me(),{baseline:["","last"]}]}],"place-content":[{"place-content":le()}],"place-items":[{"place-items":[...me(),"baseline"]}],"place-self":[{"place-self":["auto",...me()]}],p:[{p:z()}],px:[{px:z()}],py:[{py:z()}],ps:[{ps:z()}],pe:[{pe:z()}],pt:[{pt:z()}],pr:[{pr:z()}],pb:[{pb:z()}],pl:[{pl:z()}],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":z()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":z()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],w:[{w:[c,"screen",...Y()]}],"min-w":[{"min-w":[c,"screen","none",...Y()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",n,su,Ml]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,et,Bx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Fx,Ze]}],"font-family":[{font:[KP,Ze,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,et,Ze]}],"line-clamp":[{"line-clamp":[Ct,"none",et,Bx]}],leading:[{leading:[i,...z()]}],"list-image":[{"list-image":["none",et,Ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",et,Ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...de(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ct,"from-font","auto",et,Ml]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Ct,"auto",et,Ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",et,Ze]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",et,Ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:X()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},go,et,Ze],radial:["",et,Ze],conic:[go,et,Ze]},GP,WP]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],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:[...de(),"hidden","none"]}],"divide-style":[{divide:[...de(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...de(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ct,et,Ze]}],"outline-w":[{outline:["",Ct,su,Ml]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",f,Xh,Yh]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",m,Xh,Yh]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:he()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Ct,Ml]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",x,Xh,Yh]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Ct,et,Ze]}],"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":[Ct]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[et,Ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"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":[Ct]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:X()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",et,Ze]}],filter:[{filter:["","none",et,Ze]}],blur:[{blur:$()}],brightness:[{brightness:[Ct,et,Ze]}],contrast:[{contrast:[Ct,et,Ze]}],"drop-shadow":[{"drop-shadow":["","none",b,Xh,Yh]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Ct,et,Ze]}],"hue-rotate":[{"hue-rotate":[Ct,et,Ze]}],invert:[{invert:["",Ct,et,Ze]}],saturate:[{saturate:[Ct,et,Ze]}],sepia:[{sepia:["",Ct,et,Ze]}],"backdrop-filter":[{"backdrop-filter":["","none",et,Ze]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[Ct,et,Ze]}],"backdrop-contrast":[{"backdrop-contrast":[Ct,et,Ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ct,et,Ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ct,et,Ze]}],"backdrop-invert":[{"backdrop-invert":["",Ct,et,Ze]}],"backdrop-opacity":[{"backdrop-opacity":[Ct,et,Ze]}],"backdrop-saturate":[{"backdrop-saturate":[Ct,et,Ze]}],"backdrop-sepia":[{"backdrop-sepia":["",Ct,et,Ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":z()}],"border-spacing-x":[{"border-spacing-x":z()}],"border-spacing-y":[{"border-spacing-y":z()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",et,Ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ct,"initial",et,Ze]}],ease:[{ease:["linear","initial",k,et,Ze]}],delay:[{delay:[Ct,et,Ze]}],animate:[{animate:["none",T,et,Ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,et,Ze]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:Z()}],"rotate-x":[{"rotate-x":Z()}],"rotate-y":[{"rotate-y":Z()}],"rotate-z":[{"rotate-z":Z()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[et,Ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Fe()}],"translate-x":[{"translate-x":Fe()}],"translate-y":[{"translate-y":Fe()}],"translate-z":[{"translate-z":Fe()}],"translate-none":["translate-none"],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"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",et,Ze]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"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",et,Ze]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Ct,su,Ml,Bx]}],stroke:[{stroke:["none",...F()]}],"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"]}},XP=PP(YP);function zt(...t){return XP(fk(t))}function ya(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const ZP=pk("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 G({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?uk:"button";return s.jsx(i,{"data-slot":"button",className:zt(ZP({variant:e,size:n,className:t})),...a})}function oe({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:zt("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 eI(){const t=Ya(),[e,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(""),[c,u]=g.useState(!1);g.useEffect(()=>{Ku()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await bt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){YA(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(Gc,{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(Ai,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"text",value:e,onChange:f=>{n(f.target.value),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(DM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"password",value:r,onChange:f=>{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(G,{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 De=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));De.displayName="Card";const dt=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex flex-col space-y-1.5 p-6",t),...e}));dt.displayName="CardHeader";const ut=g.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:zt("font-semibold leading-none tracking-tight",t),...e}));ut.displayName="CardTitle";const Qt=g.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:zt("text-sm text-muted-foreground",t),...e}));Qt.displayName="CardDescription";const _e=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("p-6 pt-0",t),...e}));_e.displayName="CardContent";const tI=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex items-center p-6 pt-0",t),...e}));tI.displayName="CardFooter";const nI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Vx(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=nI[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 q={success:(t,e)=>Vx(t,"success",e),error:(t,e)=>Vx(t,"error",e),info:(t,e)=>Vx(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 sI(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 Zo(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,rI(a,...e)]}function rI(...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 $s=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},aI=Op[" useId ".trim().toString()]||(()=>{}),iI=0;function _o(t){const[e,n]=g.useState(aI());return $s(()=>{n(r=>r??String(iI++))},[t]),e?`radix-${e}`:""}var oI=Op[" useInsertionEffect ".trim().toString()]||$s;function Hl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=lI({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=cI(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 lI({defaultProp:t,onChange:e}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(e);return oI(()=>{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 cI(t){return typeof t=="function"}function Pu(t){const e=dI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,c=g.Children.toArray(i),u=c.find(hI);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 dI(t){const e=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=pI(a),c=fI(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(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 uI=Symbol("radix.slottable");function hI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uI}function fI(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 pI(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 mI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Et=mI.reduce((t,e)=>{const n=Pu(`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 xI(t,e){t&&hd.flushSync(()=>t.dispatchEvent(e))}function Uo(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 gI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(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 yI="DismissableLayer",Jg="dismissableLayer.update",bI="dismissableLayer.pointerDownOutside",vI="dismissableLayer.focusOutside",J1,Ek=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),sy=g.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=g.useContext(Ek),[f,m]=g.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=g.useState({}),N=Xt(e,P=>m(P)),w=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(v),T=f?w.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,L=T>=k,R=jI(P=>{const z=P.target,O=[...h.branches].some(Q=>Q.contains(z));!L||O||(a==null||a(P),o==null||o(P),P.defaultPrevented||c==null||c())},x),U=kI(P=>{const z=P.target;[...h.branches].some(Q=>Q.contains(z))||(i==null||i(P),o==null||o(P),P.defaultPrevented||c==null||c())},x);return gI(P=>{T===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&&(J1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),Q1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=J1)}},[f,x,n,h]),g.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),Q1())},[f,h]),g.useEffect(()=>{const P=()=>b({});return document.addEventListener(Jg,P),()=>document.removeEventListener(Jg,P)},[]),s.jsx(Et.div,{...u,ref:N,style:{pointerEvents:C?L?"auto":"none":void 0,...t.style},onFocusCapture:jt(t.onFocusCapture,U.onFocusCapture),onBlurCapture:jt(t.onBlurCapture,U.onBlurCapture),onPointerDownCapture:jt(t.onPointerDownCapture,R.onPointerDownCapture)})});sy.displayName=yI;var NI="DismissableLayerBranch",wI=g.forwardRef((t,e)=>{const n=g.useContext(Ek),r=g.useRef(null),a=Xt(e,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Et.div,{...t,ref:a})});wI.displayName=NI;function jI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Tk(bI,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 kI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&Tk(vI,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 Q1(){const t=new CustomEvent(Jg);document.dispatchEvent(t)}function Tk(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?xI(a,i):a.dispatchEvent(i)}var Hx="focusScope.autoFocusOnMount",Ux="focusScope.autoFocusOnUnmount",Y1={bubbles:!1,cancelable:!0},SI="FocusScope",ry=g.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=g.useState(null),h=Uo(a),f=Uo(i),m=g.useRef(null),x=Xt(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(C){if(b.paused||!c)return;const L=C.target;c.contains(L)?m.current=L:vo(m.current,{select:!0})},v=function(C){if(b.paused||!c)return;const L=C.relatedTarget;L!==null&&(c.contains(L)||vo(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&vo(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",v);const T=new MutationObserver(k);return c&&T.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",v),T.disconnect()}}},[r,c,b.paused]),g.useEffect(()=>{if(c){Z1.add(b);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(Hx,Y1);c.addEventListener(Hx,h),c.dispatchEvent(k),k.defaultPrevented||(CI(PI(Mk(c)),{select:!0}),document.activeElement===w&&vo(c))}return()=>{c.removeEventListener(Hx,h),setTimeout(()=>{const k=new CustomEvent(Ux,Y1);c.addEventListener(Ux,f),c.dispatchEvent(k),k.defaultPrevented||vo(w??document.body,{select:!0}),c.removeEventListener(Ux,f),Z1.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 T=w.currentTarget,[C,L]=EI(T);C&&L?!w.shiftKey&&k===L?(w.preventDefault(),n&&vo(C,{select:!0})):w.shiftKey&&k===C&&(w.preventDefault(),n&&vo(L,{select:!0})):k===T&&w.preventDefault()}},[n,r,b.paused]);return s.jsx(Et.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});ry.displayName=SI;function CI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(vo(r,{select:e}),document.activeElement!==n)return}function EI(t){const e=Mk(t),n=X1(e,t),r=X1(e.reverse(),t);return[n,r]}function Mk(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 X1(t,e){for(const n of t)if(!TI(n,{upTo:e}))return n}function TI(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 MI(t){return t instanceof HTMLInputElement&&"select"in t}function vo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&MI(t)&&e&&t.select()}}var Z1=AI();function AI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=eN(t,e),t.unshift(e)},remove(e){var n;t=eN(t,e),(n=t[0])==null||n.resume()}}}function eN(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function PI(t){return t.filter(e=>e.tagName!=="A")}var II="Portal",ay=g.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=g.useState(!1);$s(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Bj.createPortal(s.jsx(Et.div,{...r,ref:e}),o):null});ay.displayName=II;function RI(t,e){return g.useReducer((n,r)=>e[n][r]??n,t)}var qu=t=>{const{present:e,children:n}=t,r=LI(e),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Xt(r.ref,OI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};qu.displayName="Presence";function LI(t){const[e,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[c,u]=RI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const h=Zh(r.current);i.current=c==="mounted"?h:"none"},[c]),$s(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,b=Zh(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]),$s(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=b=>{const w=Zh(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=Zh(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 Zh(t){return(t==null?void 0:t.animationName)||"none"}function OI(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 Wx=0;function Ak(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??tN()),document.body.insertAdjacentElement("beforeend",t[1]??tN()),Wx++,()=>{Wx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Wx--}},[])}function tN(){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 Va=function(){return Va=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return XI;var e=ZI(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])}},tR=Lk(),Zc="data-scroll-locked",nR=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 QA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Ho=Ee("zap",QA),ey="admin_token";function Ku(){try{return localStorage.getItem(ey)}catch{return null}}function YA(t){try{localStorage.setItem(ey,t)}catch{}}function zx(){try{localStorage.removeItem(ey)}catch{}}const XA="https://soulapi.quwanzhi.com",ZA=15e3,F1=6e4,eP=()=>{const t="https://soulapi.quwanzhi.com";{const e=t.trim();if(e.length>0)return e.replace(/\/$/,"")}return XA};function Vl(t){const e=eP(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function $p(t,e={}){const{data:n,...r}=e,a=Vl(t),i=new Headers(r.headers),o=Ku();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??ZA,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 Le(t,e){return $p(t,{...e,method:"GET"})}function bt(t,e,n){return $p(t,{...n,method:"POST",data:e})}function tn(t,e,n){return $p(t,{...n,method:"PUT",data:e})}function Pi(t,e){return $p(t,{...e,method:"DELETE"})}function tP(){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(Xj,{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(ss,{className:"w-4 h-4"})})]}):null}const nP=[{icon:EM,label:"数据概览",href:"/dashboard"},{icon:ur,label:"内容管理",href:"/content"},{icon:qn,label:"用户管理",href:"/users"},{icon:aM,label:"找伙伴",href:"/find-partner"},{icon:sd,label:"推广中心",href:"/distribution"}];function sP(){const t=Xo(),e=g.useRef(t.pathname);e.current=t.pathname;const n=Ya(),[r,a]=g.useState(!1),[i,o]=g.useState(!1);g.useEffect(()=>{a(!0)},[]),g.useEffect(()=>{if(!r)return;let u=!1;if(!Ku()){n("/login",{replace:!0});return}return Le("/api/admin").then(h=>{u||(h&&h.success!==!1?o(!0):(zx(),n("/login",{replace:!0,state:{from:e.current}})))}).catch(()=>{u||(zx(),n("/login",{replace:!0,state:{from:e.current}}))}),()=>{u=!0}},[r,n]);const c=async()=>{zx();try{await bt("/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:[nP.map(u=>{const h=t.pathname===u.href;return s.jsxs(_i,{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(_i,{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(Po,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]}),s.jsxs(_i,{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(QT,{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($M,{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(tP,{}),s.jsx("div",{className:"w-full min-w-0 min-h-full flex-1",children:s.jsx(JE,{})})]})]})}function B1(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ty(...t){return e=>{let n=!1;const r=t.map(a=>{const i=B1(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a{let{children:i,...o}=r;ck(i)&&typeof _f=="function"&&(i=_f(i._payload));const c=g.Children.toArray(i),u=c.find(lP);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 uk=dk("Slot");function iP(t){const e=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(ck(a)&&typeof _f=="function"&&(a=_f(a._payload)),g.isValidElement(a)){const o=dP(a),c=cP(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(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 oP=Symbol("radix.slottable");function lP(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===oP}function cP(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 dP(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 hk(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,H1=fk,pk=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return H1(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=V1(f)||V1(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 H1(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},uP=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),mk=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),$f="-",U1=[],fP="arbitrary..",pP=t=>{const e=xP(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return mP(o);const c=o.split($f),u=c[0]===""&&c.length>1?1:0;return xk(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?uP(h,u):u:h||U1}return n[o]||U1}}},xk=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const a=t[e],i=n.nextPart.get(a);if(i){const h=xk(t,e+1,i);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join($f):t.slice(e).join($f),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?fP+r:void 0})(),xP=t=>{const{theme:e,classGroups:n}=t;return gP(n,e)},gP=(t,e)=>{const n=mk();for(const r in t){const a=t[r];ny(a,n,r,e)}return n},ny=(t,e,n,r)=>{const a=t.length;for(let i=0;i{if(typeof t=="string"){bP(t,e,n);return}if(typeof t=="function"){vP(t,e,n,r);return}NP(t,e,n,r)},bP=(t,e,n)=>{const r=t===""?e:gk(e,t);r.classGroupId=n},vP=(t,e,n,r)=>{if(wP(t)){ny(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(hP(n,t))},NP=(t,e,n,r)=>{const a=Object.entries(t),i=a.length;for(let o=0;o{let n=t;const r=e.split($f),a=r.length;for(let i=0;i"isThemeGetter"in t&&t.isThemeGetter===!0,jP=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)}}},Gg="!",W1=":",kP=[],K1=(t,e,n,r,a)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),SP=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 K1(i,b,x,N)};if(e){const a=e+W1,i=r;r=o=>o.startsWith(a)?i(o.slice(a.length)):K1(kP,!1,o,void 0,!0)}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},CP=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}},EP=t=>({cache:jP(t.cacheSize),parseClassName:SP(t),sortModifiers:CP(t),...pP(t)}),TP=/\s+/,MP=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=e,o=[],c=t.trim().split(TP);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 T=x.length===0?"":x.length===1?x[0]:i(x).join(":"),C=b?T+Gg:T,L=C+k;if(o.indexOf(L)>-1)continue;o.push(L);const R=a(k,v);for(let U=0;U0?" "+u:u)}return u},AP=(...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=EP(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=MP(u,n);return a(u,f),f};return i=o,(...u)=>i(AP(...u))},IP=[],es=t=>{const e=n=>n[t]||IP;return e.isThemeGetter=!0,e},bk=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vk=/^\((?:(\w[\w-]*):)?(.+)\)$/i,RP=/^\d+\/\d+$/,LP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,OP=/\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$/,DP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_P=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$P=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dc=t=>RP.test(t),Et=t=>!!t&&!Number.isNaN(Number(t)),go=t=>!!t&&Number.isInteger(Number(t)),Fx=t=>t.endsWith("%")&&Et(t.slice(0,-1)),wi=t=>LP.test(t),zP=()=>!0,FP=t=>OP.test(t)&&!DP.test(t),Nk=()=>!1,BP=t=>_P.test(t),VP=t=>$P.test(t),HP=t=>!Ze(t)&&!et(t),UP=t=>md(t,kk,Nk),Ze=t=>bk.test(t),Ml=t=>md(t,Sk,FP),Bx=t=>md(t,JP,Et),q1=t=>md(t,wk,Nk),WP=t=>md(t,jk,VP),Yh=t=>md(t,Ck,BP),et=t=>vk.test(t),su=t=>xd(t,Sk),KP=t=>xd(t,QP),G1=t=>xd(t,wk),qP=t=>xd(t,kk),GP=t=>xd(t,jk),Xh=t=>xd(t,Ck,!0),md=(t,e,n)=>{const r=bk.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},xd=(t,e,n=!1)=>{const r=vk.exec(t);return r?r[1]?e(r[1]):n:!1},wk=t=>t==="position"||t==="percentage",jk=t=>t==="image"||t==="url",kk=t=>t==="length"||t==="size"||t==="bg-size",Sk=t=>t==="length",JP=t=>t==="number",QP=t=>t==="family-name",Ck=t=>t==="shadow",YP=()=>{const t=es("color"),e=es("font"),n=es("text"),r=es("font-weight"),a=es("tracking"),i=es("leading"),o=es("breakpoint"),c=es("container"),u=es("spacing"),h=es("radius"),f=es("shadow"),m=es("inset-shadow"),x=es("text-shadow"),b=es("drop-shadow"),N=es("blur"),w=es("perspective"),v=es("aspect"),k=es("ease"),T=es("animate"),C=()=>["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(),et,Ze],U=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],F=()=>[et,Ze,u],O=()=>[Dc,"full","auto",...F()],Q=()=>[go,"none","subgrid",et,Ze],re=()=>["auto",{span:["full",go,et,Ze]},go,et,Ze],D=()=>[go,"auto",et,Ze],ne=()=>["auto","min","max","fr",et,Ze],le=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],me=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...F()],Y=()=>[Dc,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...F()],B=()=>[t,et,Ze],xe=()=>[...L(),G1,q1,{position:[et,Ze]}],X=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",qP,UP,{size:[et,Ze]}],W=()=>[Fx,su,Ml],fe=()=>["","none","full",h,et,Ze],he=()=>["",Et,su,Ml],de=()=>["solid","dashed","dotted","double"],_=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[Et,Fx,G1,q1],$=()=>["","none",N,et,Ze],Z=()=>["none",Et,et,Ze],ae=()=>["none",Et,et,Ze],we=()=>[Et,et,Ze],Fe=()=>[Dc,"full",...F()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[wi],breakpoint:[wi],color:[zP],container:[wi],"drop-shadow":[wi],ease:["in","out","in-out"],font:[HP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[wi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[wi],shadow:[wi],spacing:["px",Et],text:[wi],"text-shadow":[wi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Dc,Ze,et,v]}],container:["container"],columns:[{columns:[Et,Ze,et,c]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"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:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],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:[go,"auto",et,Ze]}],basis:[{basis:[Dc,"full","auto",c,...F()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Et,Dc,"auto","initial","none",Ze]}],grow:[{grow:["",Et,et,Ze]}],shrink:[{shrink:["",Et,et,Ze]}],order:[{order:[go,"first","last","none",et,Ze]}],"grid-cols":[{"grid-cols":Q()}],"col-start-end":[{col:re()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":Q()}],"row-start-end":[{row:re()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:F()}],"gap-x":[{"gap-x":F()}],"gap-y":[{"gap-y":F()}],"justify-content":[{justify:[...le(),"normal"]}],"justify-items":[{"justify-items":[...me(),"normal"]}],"justify-self":[{"justify-self":["auto",...me()]}],"align-content":[{content:["normal",...le()]}],"align-items":[{items:[...me(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...me(),{baseline:["","last"]}]}],"place-content":[{"place-content":le()}],"place-items":[{"place-items":[...me(),"baseline"]}],"place-self":[{"place-self":["auto",...me()]}],p:[{p:F()}],px:[{px:F()}],py:[{py:F()}],ps:[{ps:F()}],pe:[{pe:F()}],pt:[{pt:F()}],pr:[{pr:F()}],pb:[{pb:F()}],pl:[{pl:F()}],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":F()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":F()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],w:[{w:[c,"screen",...Y()]}],"min-w":[{"min-w":[c,"screen","none",...Y()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",n,su,Ml]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,et,Bx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Fx,Ze]}],"font-family":[{font:[KP,Ze,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,et,Ze]}],"line-clamp":[{"line-clamp":[Et,"none",et,Bx]}],leading:[{leading:[i,...F()]}],"list-image":[{"list-image":["none",et,Ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",et,Ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...de(),"wavy"]}],"text-decoration-thickness":[{decoration:[Et,"from-font","auto",et,Ml]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[Et,"auto",et,Ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",et,Ze]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",et,Ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:X()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},go,et,Ze],radial:["",et,Ze],conic:[go,et,Ze]},GP,WP]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],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:[...de(),"hidden","none"]}],"divide-style":[{divide:[...de(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...de(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Et,et,Ze]}],"outline-w":[{outline:["",Et,su,Ml]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",f,Xh,Yh]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",m,Xh,Yh]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:he()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[Et,Ml]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",x,Xh,Yh]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[Et,et,Ze]}],"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":[Et]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[et,Ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"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":[Et]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:X()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",et,Ze]}],filter:[{filter:["","none",et,Ze]}],blur:[{blur:$()}],brightness:[{brightness:[Et,et,Ze]}],contrast:[{contrast:[Et,et,Ze]}],"drop-shadow":[{"drop-shadow":["","none",b,Xh,Yh]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",Et,et,Ze]}],"hue-rotate":[{"hue-rotate":[Et,et,Ze]}],invert:[{invert:["",Et,et,Ze]}],saturate:[{saturate:[Et,et,Ze]}],sepia:[{sepia:["",Et,et,Ze]}],"backdrop-filter":[{"backdrop-filter":["","none",et,Ze]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[Et,et,Ze]}],"backdrop-contrast":[{"backdrop-contrast":[Et,et,Ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Et,et,Ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Et,et,Ze]}],"backdrop-invert":[{"backdrop-invert":["",Et,et,Ze]}],"backdrop-opacity":[{"backdrop-opacity":[Et,et,Ze]}],"backdrop-saturate":[{"backdrop-saturate":[Et,et,Ze]}],"backdrop-sepia":[{"backdrop-sepia":["",Et,et,Ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":F()}],"border-spacing-x":[{"border-spacing-x":F()}],"border-spacing-y":[{"border-spacing-y":F()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",et,Ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Et,"initial",et,Ze]}],ease:[{ease:["linear","initial",k,et,Ze]}],delay:[{delay:[Et,et,Ze]}],animate:[{animate:["none",T,et,Ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,et,Ze]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:Z()}],"rotate-x":[{"rotate-x":Z()}],"rotate-y":[{"rotate-y":Z()}],"rotate-z":[{"rotate-z":Z()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[et,Ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Fe()}],"translate-x":[{"translate-x":Fe()}],"translate-y":[{"translate-y":Fe()}],"translate-z":[{"translate-z":Fe()}],"translate-none":["translate-none"],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"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",et,Ze]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"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",et,Ze]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[Et,su,Ml,Bx]}],stroke:[{stroke:["none",...B()]}],"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"]}},XP=PP(YP);function zt(...t){return XP(fk(t))}function ya(t){if(!t)return"";let e=t.trim();return e?(e=e.replace(/^(https?)\/\//,"$1://"),e):""}const ZP=pk("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 G({className:t,variant:e,size:n,asChild:r=!1,...a}){const i=r?uk:"button";return s.jsx(i,{"data-slot":"button",className:zt(ZP({variant:e,size:n,className:t})),...a})}function oe({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:zt("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 eI(){const t=Ya(),[e,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(""),[c,u]=g.useState(!1);g.useEffect(()=>{Ku()&&t("/dashboard",{replace:!0})},[t]);const h=async()=>{o(""),u(!0);try{const f=await bt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){YA(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(Gc,{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(Ai,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"text",value:e,onChange:f=>{n(f.target.value),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(DM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"password",value:r,onChange:f=>{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(G,{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 De=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));De.displayName="Card";const dt=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex flex-col space-y-1.5 p-6",t),...e}));dt.displayName="CardHeader";const ut=g.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:zt("font-semibold leading-none tracking-tight",t),...e}));ut.displayName="CardTitle";const Qt=g.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:zt("text-sm text-muted-foreground",t),...e}));Qt.displayName="CardDescription";const _e=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("p-6 pt-0",t),...e}));_e.displayName="CardContent";const tI=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:zt("flex items-center p-6 pt-0",t),...e}));tI.displayName="CardFooter";const nI={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Vx(t,e="info",n=3e3){const r=`toast-${Date.now()}`,a=nI[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 q={success:(t,e)=>Vx(t,"success",e),error:(t,e)=>Vx(t,"error",e),info:(t,e)=>Vx(t,"info",e)};function kt(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 sI(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 Zo(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,rI(a,...e)]}function rI(...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 $s=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},aI=Op[" useId ".trim().toString()]||(()=>{}),iI=0;function _o(t){const[e,n]=g.useState(aI());return $s(()=>{n(r=>r??String(iI++))},[t]),e?`radix-${e}`:""}var oI=Op[" useInsertionEffect ".trim().toString()]||$s;function Hl({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=lI({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=cI(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 lI({defaultProp:t,onChange:e}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(e);return oI(()=>{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 cI(t){return typeof t=="function"}function Pu(t){const e=dI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,c=g.Children.toArray(i),u=c.find(hI);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 dI(t){const e=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=pI(a),c=fI(i,a.props);return a.type!==g.Fragment&&(c.ref=r?ty(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 uI=Symbol("radix.slottable");function hI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===uI}function fI(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 pI(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 mI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tt=mI.reduce((t,e)=>{const n=Pu(`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 xI(t,e){t&&hd.flushSync(()=>t.dispatchEvent(e))}function Uo(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 gI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(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 yI="DismissableLayer",Jg="dismissableLayer.update",bI="dismissableLayer.pointerDownOutside",vI="dismissableLayer.focusOutside",J1,Ek=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),sy=g.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:c,...u}=t,h=g.useContext(Ek),[f,m]=g.useState(null),x=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=g.useState({}),N=Xt(e,P=>m(P)),w=Array.from(h.layers),[v]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(v),T=f?w.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,L=T>=k,R=jI(P=>{const F=P.target,O=[...h.branches].some(Q=>Q.contains(F));!L||O||(a==null||a(P),o==null||o(P),P.defaultPrevented||c==null||c())},x),U=kI(P=>{const F=P.target;[...h.branches].some(Q=>Q.contains(F))||(i==null||i(P),o==null||o(P),P.defaultPrevented||c==null||c())},x);return gI(P=>{T===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&&(J1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),Q1(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=J1)}},[f,x,n,h]),g.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),Q1())},[f,h]),g.useEffect(()=>{const P=()=>b({});return document.addEventListener(Jg,P),()=>document.removeEventListener(Jg,P)},[]),s.jsx(Tt.div,{...u,ref:N,style:{pointerEvents:C?L?"auto":"none":void 0,...t.style},onFocusCapture:kt(t.onFocusCapture,U.onFocusCapture),onBlurCapture:kt(t.onBlurCapture,U.onBlurCapture),onPointerDownCapture:kt(t.onPointerDownCapture,R.onPointerDownCapture)})});sy.displayName=yI;var NI="DismissableLayerBranch",wI=g.forwardRef((t,e)=>{const n=g.useContext(Ek),r=g.useRef(null),a=Xt(e,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Tt.div,{...t,ref:a})});wI.displayName=NI;function jI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=c=>{if(c.target&&!r.current){let u=function(){Tk(bI,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 kI(t,e=globalThis==null?void 0:globalThis.document){const n=Uo(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&Tk(vI,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 Q1(){const t=new CustomEvent(Jg);document.dispatchEvent(t)}function Tk(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?xI(a,i):a.dispatchEvent(i)}var Hx="focusScope.autoFocusOnMount",Ux="focusScope.autoFocusOnUnmount",Y1={bubbles:!1,cancelable:!0},SI="FocusScope",ry=g.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[c,u]=g.useState(null),h=Uo(a),f=Uo(i),m=g.useRef(null),x=Xt(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(C){if(b.paused||!c)return;const L=C.target;c.contains(L)?m.current=L:vo(m.current,{select:!0})},v=function(C){if(b.paused||!c)return;const L=C.relatedTarget;L!==null&&(c.contains(L)||vo(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&vo(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",v);const T=new MutationObserver(k);return c&&T.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",v),T.disconnect()}}},[r,c,b.paused]),g.useEffect(()=>{if(c){Z1.add(b);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(Hx,Y1);c.addEventListener(Hx,h),c.dispatchEvent(k),k.defaultPrevented||(CI(PI(Mk(c)),{select:!0}),document.activeElement===w&&vo(c))}return()=>{c.removeEventListener(Hx,h),setTimeout(()=>{const k=new CustomEvent(Ux,Y1);c.addEventListener(Ux,f),c.dispatchEvent(k),k.defaultPrevented||vo(w??document.body,{select:!0}),c.removeEventListener(Ux,f),Z1.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 T=w.currentTarget,[C,L]=EI(T);C&&L?!w.shiftKey&&k===L?(w.preventDefault(),n&&vo(C,{select:!0})):w.shiftKey&&k===C&&(w.preventDefault(),n&&vo(L,{select:!0})):k===T&&w.preventDefault()}},[n,r,b.paused]);return s.jsx(Tt.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});ry.displayName=SI;function CI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(vo(r,{select:e}),document.activeElement!==n)return}function EI(t){const e=Mk(t),n=X1(e,t),r=X1(e.reverse(),t);return[n,r]}function Mk(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 X1(t,e){for(const n of t)if(!TI(n,{upTo:e}))return n}function TI(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 MI(t){return t instanceof HTMLInputElement&&"select"in t}function vo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&MI(t)&&e&&t.select()}}var Z1=AI();function AI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=eN(t,e),t.unshift(e)},remove(e){var n;t=eN(t,e),(n=t[0])==null||n.resume()}}}function eN(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function PI(t){return t.filter(e=>e.tagName!=="A")}var II="Portal",ay=g.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[a,i]=g.useState(!1);$s(()=>i(!0),[]);const o=n||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Bj.createPortal(s.jsx(Tt.div,{...r,ref:e}),o):null});ay.displayName=II;function RI(t,e){return g.useReducer((n,r)=>e[n][r]??n,t)}var qu=t=>{const{present:e,children:n}=t,r=LI(e),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Xt(r.ref,OI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};qu.displayName="Presence";function LI(t){const[e,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[c,u]=RI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const h=Zh(r.current);i.current=c==="mounted"?h:"none"},[c]),$s(()=>{const h=r.current,f=a.current;if(f!==t){const x=i.current,b=Zh(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]),$s(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=b=>{const w=Zh(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=Zh(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 Zh(t){return(t==null?void 0:t.animationName)||"none"}function OI(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 Wx=0;function Ak(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??tN()),document.body.insertAdjacentElement("beforeend",t[1]??tN()),Wx++,()=>{Wx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Wx--}},[])}function tN(){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 Va=function(){return Va=Object.assign||function(e){for(var n,r=1,a=arguments.length;r"u")return XI;var e=ZI(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])}},tR=Lk(),Zc="data-scroll-locked",nR=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(_I,` { overflow: hidden `).concat(r,`; padding-right: `).concat(c,"px ").concat(r,`; @@ -649,12 +649,12 @@ Error generating stack: `+S.message+` `)},sN=function(){var t=parseInt(document.body.getAttribute(Zc)||"0",10);return isFinite(t)?t:0},sR=function(){g.useEffect(function(){return document.body.setAttribute(Zc,(sN()+1).toString()),function(){var t=sN()-1;t<=0?document.body.removeAttribute(Zc):document.body.setAttribute(Zc,t.toString())}},[])},rR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;sR();var i=g.useMemo(function(){return eR(a)},[a]);return g.createElement(tR,{styles:nR(i,!e,a,n?"":"!important")})},Qg=!1;if(typeof window<"u")try{var ef=Object.defineProperty({},"passive",{get:function(){return Qg=!0,!0}});window.addEventListener("test",ef,ef),window.removeEventListener("test",ef,ef)}catch{Qg=!1}var _c=Qg?{passive:!1}:!1,aR=function(t){return t.tagName==="TEXTAREA"},Ok=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!aR(t)&&n[e]==="visible")},iR=function(t){return Ok(t,"overflowY")},oR=function(t){return Ok(t,"overflowX")},rN=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Dk(t,r);if(a){var i=_k(t,r),o=i[1],c=i[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},lR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},cR=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},Dk=function(t,e){return t==="v"?iR(e):oR(e)},_k=function(t,e){return t==="v"?lR(e):cR(e)},dR=function(t,e){return t==="h"&&e==="rtl"?-1:1},uR=function(t,e,n,r,a){var i=dR(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=_k(t,c),N=b[0],w=b[1],v=b[2],k=w-v-i*N;(N||k)&&Dk(t,c)&&(m+=k,x+=N);var T=c.parentNode;c=T&&T.nodeType===Node.DOCUMENT_FRAGMENT_NODE?T.host:T}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},tf=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},aN=function(t){return[t.deltaX,t.deltaY]},iN=function(t){return t&&"current"in t?t.current:t},hR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},fR=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} -`)},pR=0,$c=[];function mR(t){var e=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(pR++)[0],i=g.useState(Lk)[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=DI([t.lockRef.current],(t.shards||[]).map(iN),!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=tf(w),T=n.current,C="deltaX"in w?w.deltaX:T[0]-k[0],L="deltaY"in w?w.deltaY:T[1]-k[1],R,U=w.target,P=Math.abs(C)>Math.abs(L)?"h":"v";if("touches"in w&&P==="h"&&U.type==="range")return!1;var z=window.getSelection(),O=z&&z.anchorNode,Q=O?O===U||O.contains(U):!1;if(Q)return!1;var re=rN(P,U);if(!re)return!0;if(re?R=P:(R=P==="v"?"h":"v",re=rN(P,U)),!re)return!1;if(!r.current&&"changedTouches"in w&&(C||L)&&(r.current=R),!R)return!0;var D=r.current||R;return uR(D,v,w,D==="h"?C:L)},[]),u=g.useCallback(function(w){var v=w;if(!(!$c.length||$c[$c.length-1]!==i)){var k="deltaY"in v?aN(v):tf(v),T=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&hR(R.delta,k)})[0];if(T&&T.should){v.cancelable&&v.preventDefault();return}if(!T){var C=(o.current.shards||[]).map(iN).filter(Boolean).filter(function(R){return R.contains(v.target)}),L=C.length>0?c(v,C[0]):!o.current.noIsolation;L&&v.cancelable&&v.preventDefault()}}},[]),h=g.useCallback(function(w,v,k,T){var C={name:w,delta:v,target:k,should:T,shadowParent:xR(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(L){return L!==C})},1)},[]),f=g.useCallback(function(w){n.current=tf(w),r.current=void 0},[]),m=g.useCallback(function(w){h(w.type,aN(w),w.target,c(w,t.lockRef.current))},[]),x=g.useCallback(function(w){h(w.type,tf(w),w.target,c(w,t.lockRef.current))},[]);g.useEffect(function(){return $c.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,_c),document.addEventListener("touchmove",u,_c),document.addEventListener("touchstart",f,_c),function(){$c=$c.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,_c),document.removeEventListener("touchmove",u,_c),document.removeEventListener("touchstart",f,_c)}},[]);var b=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:fR(a)}):null,b?g.createElement(rR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function xR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const gR=WI(Rk,mR);var iy=g.forwardRef(function(t,e){return g.createElement(zp,Va({},t,{ref:e,sideCar:gR}))});iy.classNames=zp.classNames;var yR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},zc=new WeakMap,nf=new WeakMap,sf={},Jx=0,$k=function(t){return t&&(t.host||$k(t.parentNode))},bR=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})},vR=function(t,e,n,r){var a=bR(e,Array.isArray(t)?t:[t]);sf[n]||(sf[n]=new WeakMap);var i=sf[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=(zc.get(x)||0)+1,v=(i.get(x)||0)+1;zc.set(x,w),i.set(x,v),o.push(x),w===1&&N&&nf.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(),Jx++,function(){o.forEach(function(m){var x=zc.get(m)-1,b=i.get(m)-1;zc.set(m,x),i.set(m,b),x||(nf.has(m)||m.removeAttribute(r),nf.delete(m)),b||m.removeAttribute(n)}),Jx--,Jx||(zc=new WeakMap,zc=new WeakMap,nf=new WeakMap,sf={})}},zk=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=yR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),vR(r,a,n,"aria-hidden")):function(){return null}},Fp="Dialog",[Fk]=Zo(Fp),[NR,Na]=Fk(Fp),Bk=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]=Hl({prop:r,defaultProp:a??!1,onChange:i,caller:Fp});return s.jsx(NR,{scope:e,triggerRef:c,contentRef:u,contentId:_o(),titleId:_o(),descriptionId:_o(),open:h,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Bk.displayName=Fp;var Vk="DialogTrigger",wR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Vk,n),i=Xt(e,a.triggerRef);return s.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":cy(a.open),...r,ref:i,onClick:jt(t.onClick,a.onOpenToggle)})});wR.displayName=Vk;var oy="DialogPortal",[jR,Hk]=Fk(oy,{forceMount:void 0}),Uk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=Na(oy,e);return s.jsx(jR,{scope:e,forceMount:n,children:g.Children.map(r,o=>s.jsx(qu,{present:n||i.open,children:s.jsx(ay,{asChild:!0,container:a,children:o})}))})};Uk.displayName=oy;var zf="DialogOverlay",Wk=g.forwardRef((t,e)=>{const n=Hk(zf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(zf,t.__scopeDialog);return i.modal?s.jsx(qu,{present:r||i.open,children:s.jsx(SR,{...a,ref:e})}):null});Wk.displayName=zf;var kR=Pu("DialogOverlay.RemoveScroll"),SR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(zf,n);return s.jsx(iy,{as:kR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Et.div,{"data-state":cy(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ul="DialogContent",Kk=g.forwardRef((t,e)=>{const n=Hk(Ul,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(Ul,t.__scopeDialog);return s.jsx(qu,{present:r||i.open,children:i.modal?s.jsx(CR,{...a,ref:e}):s.jsx(ER,{...a,ref:e})})});Kk.displayName=Ul;var CR=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(null),a=Xt(e,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return zk(i)},[]),s.jsx(qk,{...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())})}),ER=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return s.jsx(qk,{...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()}})}),qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Na(Ul,n),u=g.useRef(null),h=Xt(e,u);return Ak(),s.jsxs(s.Fragment,{children:[s.jsx(ry,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(sy,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":cy(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(TR,{titleId:c.titleId}),s.jsx(AR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),ly="DialogTitle",Gk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(ly,n);return s.jsx(Et.h2,{id:a.titleId,...r,ref:e})});Gk.displayName=ly;var Jk="DialogDescription",Qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Jk,n);return s.jsx(Et.p,{id:a.descriptionId,...r,ref:e})});Qk.displayName=Jk;var Yk="DialogClose",Xk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Yk,n);return s.jsx(Et.button,{type:"button",...r,ref:e,onClick:jt(t.onClick,()=>a.onOpenChange(!1))})});Xk.displayName=Yk;function cy(t){return t?"open":"closed"}var Zk="DialogTitleWarning",[EH,e2]=sI(Zk,{contentName:Ul,titleName:ly,docsSlug:"dialog"}),TR=({titleId:t})=>{const e=e2(Zk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. +`)},pR=0,$c=[];function mR(t){var e=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(pR++)[0],i=g.useState(Lk)[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=DI([t.lockRef.current],(t.shards||[]).map(iN),!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=tf(w),T=n.current,C="deltaX"in w?w.deltaX:T[0]-k[0],L="deltaY"in w?w.deltaY:T[1]-k[1],R,U=w.target,P=Math.abs(C)>Math.abs(L)?"h":"v";if("touches"in w&&P==="h"&&U.type==="range")return!1;var F=window.getSelection(),O=F&&F.anchorNode,Q=O?O===U||O.contains(U):!1;if(Q)return!1;var re=rN(P,U);if(!re)return!0;if(re?R=P:(R=P==="v"?"h":"v",re=rN(P,U)),!re)return!1;if(!r.current&&"changedTouches"in w&&(C||L)&&(r.current=R),!R)return!0;var D=r.current||R;return uR(D,v,w,D==="h"?C:L)},[]),u=g.useCallback(function(w){var v=w;if(!(!$c.length||$c[$c.length-1]!==i)){var k="deltaY"in v?aN(v):tf(v),T=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&hR(R.delta,k)})[0];if(T&&T.should){v.cancelable&&v.preventDefault();return}if(!T){var C=(o.current.shards||[]).map(iN).filter(Boolean).filter(function(R){return R.contains(v.target)}),L=C.length>0?c(v,C[0]):!o.current.noIsolation;L&&v.cancelable&&v.preventDefault()}}},[]),h=g.useCallback(function(w,v,k,T){var C={name:w,delta:v,target:k,should:T,shadowParent:xR(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(L){return L!==C})},1)},[]),f=g.useCallback(function(w){n.current=tf(w),r.current=void 0},[]),m=g.useCallback(function(w){h(w.type,aN(w),w.target,c(w,t.lockRef.current))},[]),x=g.useCallback(function(w){h(w.type,tf(w),w.target,c(w,t.lockRef.current))},[]);g.useEffect(function(){return $c.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",u,_c),document.addEventListener("touchmove",u,_c),document.addEventListener("touchstart",f,_c),function(){$c=$c.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,_c),document.removeEventListener("touchmove",u,_c),document.removeEventListener("touchstart",f,_c)}},[]);var b=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:fR(a)}):null,b?g.createElement(rR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function xR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const gR=WI(Rk,mR);var iy=g.forwardRef(function(t,e){return g.createElement(zp,Va({},t,{ref:e,sideCar:gR}))});iy.classNames=zp.classNames;var yR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},zc=new WeakMap,nf=new WeakMap,sf={},Jx=0,$k=function(t){return t&&(t.host||$k(t.parentNode))},bR=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})},vR=function(t,e,n,r){var a=bR(e,Array.isArray(t)?t:[t]);sf[n]||(sf[n]=new WeakMap);var i=sf[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=(zc.get(x)||0)+1,v=(i.get(x)||0)+1;zc.set(x,w),i.set(x,v),o.push(x),w===1&&N&&nf.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(),Jx++,function(){o.forEach(function(m){var x=zc.get(m)-1,b=i.get(m)-1;zc.set(m,x),i.set(m,b),x||(nf.has(m)||m.removeAttribute(r),nf.delete(m)),b||m.removeAttribute(n)}),Jx--,Jx||(zc=new WeakMap,zc=new WeakMap,nf=new WeakMap,sf={})}},zk=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=yR(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),vR(r,a,n,"aria-hidden")):function(){return null}},Fp="Dialog",[Fk]=Zo(Fp),[NR,Na]=Fk(Fp),Bk=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]=Hl({prop:r,defaultProp:a??!1,onChange:i,caller:Fp});return s.jsx(NR,{scope:e,triggerRef:c,contentRef:u,contentId:_o(),titleId:_o(),descriptionId:_o(),open:h,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Bk.displayName=Fp;var Vk="DialogTrigger",wR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Vk,n),i=Xt(e,a.triggerRef);return s.jsx(Tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":cy(a.open),...r,ref:i,onClick:kt(t.onClick,a.onOpenToggle)})});wR.displayName=Vk;var oy="DialogPortal",[jR,Hk]=Fk(oy,{forceMount:void 0}),Uk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:a}=t,i=Na(oy,e);return s.jsx(jR,{scope:e,forceMount:n,children:g.Children.map(r,o=>s.jsx(qu,{present:n||i.open,children:s.jsx(ay,{asChild:!0,container:a,children:o})}))})};Uk.displayName=oy;var zf="DialogOverlay",Wk=g.forwardRef((t,e)=>{const n=Hk(zf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(zf,t.__scopeDialog);return i.modal?s.jsx(qu,{present:r||i.open,children:s.jsx(SR,{...a,ref:e})}):null});Wk.displayName=zf;var kR=Pu("DialogOverlay.RemoveScroll"),SR=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(zf,n);return s.jsx(iy,{as:kR,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Tt.div,{"data-state":cy(a.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Ul="DialogContent",Kk=g.forwardRef((t,e)=>{const n=Hk(Ul,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=Na(Ul,t.__scopeDialog);return s.jsx(qu,{present:r||i.open,children:i.modal?s.jsx(CR,{...a,ref:e}):s.jsx(ER,{...a,ref:e})})});Kk.displayName=Ul;var CR=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(null),a=Xt(e,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return zk(i)},[]),s.jsx(qk,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:kt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:kt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&i.preventDefault()}),onFocusOutside:kt(t.onFocusOutside,i=>i.preventDefault())})}),ER=g.forwardRef((t,e)=>{const n=Na(Ul,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return s.jsx(qk,{...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()}})}),qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,c=Na(Ul,n),u=g.useRef(null),h=Xt(e,u);return Ak(),s.jsxs(s.Fragment,{children:[s.jsx(ry,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(sy,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":cy(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(TR,{titleId:c.titleId}),s.jsx(AR,{contentRef:u,descriptionId:c.descriptionId})]})]})}),ly="DialogTitle",Gk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(ly,n);return s.jsx(Tt.h2,{id:a.titleId,...r,ref:e})});Gk.displayName=ly;var Jk="DialogDescription",Qk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Jk,n);return s.jsx(Tt.p,{id:a.descriptionId,...r,ref:e})});Qk.displayName=Jk;var Yk="DialogClose",Xk=g.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,a=Na(Yk,n);return s.jsx(Tt.button,{type:"button",...r,ref:e,onClick:kt(t.onClick,()=>a.onOpenChange(!1))})});Xk.displayName=Yk;function cy(t){return t?"open":"closed"}var Zk="DialogTitleWarning",[EH,e2]=sI(Zk,{contentName:Ul,titleName:ly,docsSlug:"dialog"}),TR=({titleId:t})=>{const e=e2(Zk),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},MR="DialogDescriptionWarning",AR=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${e2(MR).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},PR=Bk,IR=Uk,RR=Wk,LR=Kk,OR=Gk,DR=Qk,_R=Xk;function Lt(t){return s.jsx(PR,{"data-slot":"dialog",...t})}function $R(t){return s.jsx(IR,{...t})}const t2=g.forwardRef(({className:t,...e},n)=>s.jsx(RR,{ref:n,className:zt("fixed inset-0 z-50 bg-black/50",t),...e}));t2.displayName="DialogOverlay";const It=g.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs($R,{children:[s.jsx(t2,{}),s.jsxs(LR,{ref:a,"aria-describedby":void 0,className:zt("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(_R,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(ns,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));It.displayName="DialogContent";function Ot({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function nn({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Dt(t){return s.jsx(OR,{className:"text-lg font-semibold leading-none",...t})}function Wo(t){return s.jsx(DR,{className:"text-sm text-muted-foreground",...t})}const zR=pk("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 Be({className:t,variant:e,asChild:n=!1,...r}){const a=n?uk:"span";return s.jsx(a,{className:zt(zR({variant:e}),t),...r})}var FR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],BR=FR.reduce((t,e)=>{const n=dk(`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}},{}),VR="Label",n2=g.forwardRef((t,e)=>s.jsx(BR.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())}}));n2.displayName=VR;var s2=n2;const te=g.forwardRef(({className:t,...e},n)=>s.jsx(s2,{ref:n,className:zt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));te.displayName=s2.displayName;function dy(t){const e=t+"CollectionProvider",[n,r]=Zo(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:v,children:k}=w,T=qs.useRef(null),C=qs.useRef(new Map).current;return s.jsx(a,{scope:v,itemMap:C,collectionRef:T,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Pu(c),h=qs.forwardRef((w,v)=>{const{scope:k,children:T}=w,C=i(c,k),L=Xt(v,C.collectionRef);return s.jsx(u,{ref:L,children:T})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=Pu(f),b=qs.forwardRef((w,v)=>{const{scope:k,children:T,...C}=w,L=qs.useRef(null),R=Xt(v,L),U=i(f,k);return qs.useEffect(()=>(U.itemMap.set(L,{ref:L,...C}),()=>void U.itemMap.delete(L))),s.jsx(x,{[m]:"",ref:R,children:T})});b.displayName=f;function N(w){const v=i(t+"CollectionConsumer",w);return qs.useCallback(()=>{const T=v.collectionRef.current;if(!T)return[];const C=Array.from(T.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((U,P)=>C.indexOf(U.ref.current)-C.indexOf(P.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:b},N,r]}var HR=g.createContext(void 0);function Bp(t){const e=g.useContext(HR);return t||e||"ltr"}var Qx="rovingFocusGroup.onEntryFocus",UR={bubbles:!1,cancelable:!0},Gu="RovingFocusGroup",[Yg,r2,WR]=dy(Gu),[KR,a2]=Zo(Gu,[WR]),[qR,GR]=KR(Gu),i2=g.forwardRef((t,e)=>s.jsx(Yg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Yg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(JR,{...t,ref:e})})}));i2.displayName=Gu;var JR=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=Xt(e,x),N=Bp(i),[w,v]=Hl({prop:o,defaultProp:c??null,onChange:u,caller:Gu}),[k,T]=g.useState(!1),C=Uo(h),L=r2(n),R=g.useRef(!1),[U,P]=g.useState(0);return g.useEffect(()=>{const z=x.current;if(z)return z.addEventListener(Qx,C),()=>z.removeEventListener(Qx,C)},[C]),s.jsx(qR,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:g.useCallback(z=>v(z),[v]),onItemShiftTab:g.useCallback(()=>T(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(z=>z+1),[]),onFocusableItemRemove:g.useCallback(()=>P(z=>z-1),[]),children:s.jsx(Et.div,{tabIndex:k||U===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,z=>{const O=!R.current;if(z.target===z.currentTarget&&O&&!k){const Q=new CustomEvent(Qx,UR);if(z.currentTarget.dispatchEvent(Q),!Q.defaultPrevented){const re=L().filter(I=>I.focusable),D=re.find(I=>I.active),ne=re.find(I=>I.id===w),me=[D,ne,...re].filter(Boolean).map(I=>I.ref.current);c2(me,f)}}R.current=!1}),onBlur:jt(t.onBlur,()=>T(!1))})})}),o2="RovingFocusGroupItem",l2=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=_o(),h=i||u,f=GR(o2,n),m=f.currentTabStopId===h,x=r2(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:w}=f;return g.useEffect(()=>{if(r)return b(),()=>N()},[r,b,N]),s.jsx(Yg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(Et.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=XR(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=x().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const L=C.indexOf(v.currentTarget);C=f.loop?ZR(C,L+1):C.slice(L+1)}setTimeout(()=>c2(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});l2.displayName=o2;var QR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function YR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function XR(t,e,n){const r=YR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return QR[r]}function c2(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function ZR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var e8=i2,t8=l2,Vp="Tabs",[n8]=Zo(Vp,[a2]),d2=a2(),[s8,uy]=n8(Vp),u2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Bp(c),[m,x]=Hl({prop:r,onChange:a,defaultProp:i??"",caller:Vp});return s.jsx(s8,{scope:n,baseId:_o(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(Et.div,{dir:f,"data-orientation":o,...h,ref:e})})});u2.displayName=Vp;var h2="TabsList",f2=g.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=uy(h2,n),o=d2(n);return s.jsx(e8,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Et.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});f2.displayName=h2;var p2="TabsTrigger",m2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=uy(p2,n),c=d2(n),u=y2(o.baseId,r),h=b2(o.baseId,r),f=r===o.value;return s.jsx(t8,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(Et.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)})})})});m2.displayName=p2;var x2="TabsContent",g2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=uy(x2,n),u=y2(c.baseId,r),h=b2(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(qu,{present:a||f,children:({present:x})=>s.jsx(Et.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})})});g2.displayName=x2;function y2(t,e){return`${t}-trigger-${e}`}function b2(t,e){return`${t}-content-${e}`}var r8=u2,v2=f2,N2=m2,w2=g2;const Wl=r8,Ko=g.forwardRef(({className:t,...e},n)=>s.jsx(v2,{ref:n,className:zt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ko.displayName=v2.displayName;const Ut=g.forwardRef(({className:t,...e},n)=>s.jsx(N2,{ref:n,className:zt("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}));Ut.displayName=N2.displayName;const Wt=g.forwardRef(({className:t,...e},n)=>s.jsx(w2,{ref:n,className:zt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Wt.displayName=w2.displayName;function hy(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 fy(t){const[e,n]=g.useState(void 0);return $s(()=>{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 Hp="Switch",[a8]=Zo(Hp),[i8,o8]=a8(Hp),j2=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=Xt(e,C=>b(C)),w=g.useRef(!1),v=x?f||!!x.closest("form"):!0,[k,T]=Hl({prop:a,defaultProp:i??!1,onChange:h,caller:Hp});return s.jsxs(i8,{scope:n,checked:k,disabled:c,children:[s.jsx(Et.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":E2(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:jt(t.onClick,C=>{T(L=>!L),v&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),v&&s.jsx(C2,{control:x,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});j2.displayName=Hp;var k2="SwitchThumb",S2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=o8(k2,n);return s.jsx(Et.span,{"data-state":E2(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});S2.displayName=k2;var l8="SwitchBubbleInput",C2=g.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),c=Xt(o,i),u=hy(n),h=fy(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}})});C2.displayName=l8;function E2(t){return t?"checked":"unchecked"}var T2=j2,c8=S2;const Kt=g.forwardRef(({className:t,...e},n)=>s.jsx(T2,{className:zt("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(c8,{className:zt("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")})}));Kt.displayName=T2.displayName;const d8={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 u8(t){return d8[t]||t||"行为"}function h8(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 py({open:t,onClose:e,userId:n,onUserUpdated:r}){var Qr,Vs,Qs,pr,Ys,ka;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),[T,C]=g.useState(!1),[L,R]=g.useState(!1),[U,P]=g.useState("info"),[z,O]=g.useState(""),[Q,re]=g.useState(""),[D,ne]=g.useState(""),[le,me]=g.useState([]),[I,Y]=g.useState(""),[F,xe]=g.useState(""),[X,V]=g.useState(""),[W,fe]=g.useState(!1),[he,de]=g.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[_,J]=g.useState([]),[$,Z]=g.useState(!1),[ae,we]=g.useState(""),[Fe,Ue]=g.useState(""),[wt,jn]=g.useState(!1),[pt,At]=g.useState(!1),[fn,Vn]=g.useState(null),[pn,qt]=g.useState(null),[bn,Mn]=g.useState(""),[Hn,rs]=g.useState(""),[_t,vn]=g.useState(""),[Ne,Me]=g.useState(!1),[We,rt]=g.useState(null),[$t,kt]=g.useState(!1),[$e,H]=g.useState({}),[Qe,vt]=g.useState([]);g.useEffect(()=>{t&&n&&(kt(!1),P("info"),Vn(null),qt(null),rt(null),xe(""),V(""),yt(),Le("/api/db/vip-roles").then(ce=>{ce!=null&&ce.success&&ce.data&&J(ce.data)}).catch(()=>{}))},[t,n]),g.useEffect(()=>{t&&Le("/api/admin/mbti-avatars").then(ce=>{ce!=null&&ce.avatars&&typeof ce.avatars=="object"?H(ce.avatars):H({})}).catch(()=>H({}))},[t]);const Ft=(ce,ve)=>{const Rt=(ce||"").trim();if(Rt)return ya(Rt);const Zt=(ve||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Zt)?($e[Zt]||"").trim():""};async function yt(){if(n){k(!0);try{const ce=await Le(`/api/db/users?id=${encodeURIComponent(n)}`);if(ce!=null&&ce.success&&ce.user){const ve=ce.user;i(ve),O(ve.phone||""),re(ve.wechatId||""),ne(ve.nickname||""),Mn(ve.phone||""),rs(ve.wechatId||""),vn(ve.openId||"");try{me(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{me([])}de({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Le(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ve!=null&&ve.success){h(ve.stats&&typeof ve.stats=="object"?ve.stats:{});const Rt=ve.tracks||[];c(Rt.map(Zt=>({...Zt,actionLabel:Zt.actionLabel||Zt.action,timeAgo:Zt.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ve=await Le(`/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 Le(`/api/admin/users/${encodeURIComponent(n)}/balance`);ve!=null&&ve.success&&ve.data?w(ve.data):w(null)}catch{w(null)}try{const ve=await Le(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ve!=null&&ve.success&&ve.orders?vt(ve.orders):vt([])}catch{vt([])}}catch(ce){console.error("Load user detail error:",ce)}finally{k(!1)}}}async function ht(){if(!(a!=null&&a.phone)){q.info("用户未绑定手机号,无法同步");return}C(!0);try{const ce=await bt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});ce!=null&&ce.success?(q.success("同步成功"),yt()):q.error("同步失败: "+(ce==null?void 0:ce.error))}catch(ce){console.error("Sync CKB error:",ce),q.error("同步失败")}finally{C(!1)}}async function Pt(){if(a){if(he.isVip&&!he.vipExpireDate.trim()){q.error("开启 VIP 请填写有效到期日");return}R(!0);try{const ce={id:a.id,phone:z.trim()||void 0,wechatId:Q.trim(),nickname:D||void 0,tags:JSON.stringify(le),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 tn("/api/db/users",ce);ve!=null&&ve.success?(q.success("保存成功"),yt(),r==null||r()):q.error("保存失败: "+(ve==null?void 0:ve.error))}catch(ce){console.error("Save user error:",ce),q.error("保存失败")}finally{R(!1)}}}const Gt=()=>{I&&!le.includes(I)&&(me([...le,I]),Y(""))},kn=ce=>me(le.filter(ve=>ve!==ce));async function Ts(){if(a){if(!F){q.error("请输入新密码");return}if(F!==X){q.error("两次密码不一致");return}if(F.length<6){q.error("密码至少 6 位");return}fe(!0);try{const ce=await tn("/api/db/users",{id:a.id,password:F});ce!=null&&ce.success?(q.success("修改成功"),xe(""),V("")):q.error("修改失败: "+((ce==null?void 0:ce.error)||""))}catch{q.error("修改失败")}finally{fe(!1)}}}async function Ms(){if(!a)return;const ce=parseFloat(ae);if(Number.isNaN(ce)||ce===0){q.error("请输入有效金额(正数增加、负数扣减)");return}jn(!0);try{const ve=await bt(`/api/admin/users/${a.id}/balance/adjust`,{amount:ce,remark:Fe||void 0});ve!=null&&ve.success?(q.success("余额已调整"),Z(!1),we(""),Ue(""),yt(),r==null||r()):q.error("调整失败: "+((ve==null?void 0:ve.error)||""))}catch{q.error("调整失败")}finally{jn(!1)}}async function Ki(){if(!bn&&!_t&&!Hn){qt("请至少输入手机号、微信号或 OpenID 中的一项");return}At(!0),qt(null),Vn(null);try{const ce=new URLSearchParams;bn&&ce.set("phone",bn),_t&&ce.set("openId",_t),Hn&&ce.set("wechatId",Hn);const ve=await Le(`/api/admin/shensheshou/query?${ce}`);ve!=null&&ve.success&&ve.data?(Vn(ve.data),a&&await ja(ve.data)):qt((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(ce){console.error("SSS query error:",ce),qt("请求失败,请检查神射手接口配置")}finally{At(!1)}}async function ja(ce){if(a)try{await bt("/api/admin/shensheshou/enrich",{userId:a.id,phone:bn||a.phone||"",openId:_t||a.openId||"",wechatId:Hn||a.wechatId||""}),yt()}catch(ve){console.error("SSS enrich error:",ve)}}async function ei(){if(a){Me(!0),rt(null);try{const ce=Array.from(new Set(o.filter(as=>as.action==="view_chapter"||as.action==="purchase"||as.action==="first_pay").map(as=>(as.chapterTitle||as.target||"").trim()).filter(Boolean))).slice(0,12),ve={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Rt=ce.length>0?`意向章节:${ce.join("、")}`:"",Zt={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:le,purchaseIntent:ve,purchaseIntentChapters:ce,remark:Rt}]},sn=await bt("/api/admin/shensheshou/ingest",Zt);sn!=null&&sn.success&&sn.data?rt(sn.data):rt({error:(sn==null?void 0:sn.error)||"推送失败"})}catch(ce){console.error("SSS ingest error:",ce),rt({error:"请求失败"})}finally{Me(!1)}}}const ti=ce=>{const Rt={view_chapter:ur,purchase:mu,match:Kn,login:Ai,register:Ai,share:Ua,bind_phone:_1,bind_wechat:HM,fill_profile:xu,fill_avatar:Ai,visit_page:ma,first_pay:mu,vip_activate:Xc,click_super:Kn,lead_submit:_1,withdraw:Au,referral_bind:Ua,card_click:Ai,btn_click:Ho,tab_click:ma,nav_click:ma,page_view:ma,search:ma}[ce]||Vg;return s.jsx(Rt,{className:"w-4 h-4"})};function Ar(ce){const ve=String(ce||"").trim();return ve.length>22&&/^[a-zA-Z0-9_-]+$/.test(ve)}const Pr=g.useMemo(()=>h8(u,a),[u,a]);function Ir(){const ce=[...le];for(const ve of Pr)ce.includes(ve)||ce.push(ve);me(ce),q.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Lt,{open:t,onOpenChange:()=>e(),children:s.jsxs(It,{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(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ai,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Be,{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(Ve,{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:Ft(a.avatar,a.mbti)&&!$t?s.jsx("img",{src:Ft(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>kt(!0)}):((Qr=a.nickname)==null?void 0:Qr.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(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Be,{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:D||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:z||"—"})]}),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:Q||"—"})]}),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(G,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{we(""),Ue(""),Z(!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(Wl,{value:U,onValueChange:P,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(Ko,{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(Ut,{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(Ut,{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(ma,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Ut,{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(Ut,{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(Wt,{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(te,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:D,onChange:ce=>ne(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:z,onChange:ce=>O(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:Q,onChange:ce=>re(ce.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(ik,{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(Xc,{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(Be,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx(Kt,{className:"scale-90",checked:he.isVip,onCheckedChange:ce=>de(ve=>({...ve,isVip:ce}))})]}),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(te,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(oe,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:he.vipExpireDate,onChange:ce=>de(ve=>({...ve,vipExpireDate:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{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:ce=>de(ve=>({...ve,vipRole:ce.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),_.map(ce=>s.jsx("option",{value:ce.name,children:ce.name},ce.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:he.vipName,onChange:ce=>de(ve=>({...ve,vipName:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:he.vipProject,onChange:ce=>de(ve=>({...ve,vipProject:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:he.vipContact,onChange:ce=>de(ve=>({...ve,vipContact:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:he.vipBio,onChange:ce=>de(ve=>({...ve,vipBio:ce.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(Ho,{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(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:bn,onChange:ce=>Mn(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:Hn,onChange:ce=>rs(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:_t,onChange:ce=>vn(ce.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(G,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:Ki,disabled:pt,children:[pt?s.jsx(Ve,{className:"w-3 h-3 animate-spin"}):s.jsx(hr,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:ei,disabled:Ne||!a.phone,children:Ne?"推送…":"推神射手"}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:ht,disabled:T||!a.phone,children:T?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),pn&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:pn}),fn&&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:fn.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:fn.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(Au,{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(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:F,onChange:ce=>xe(ce.target.value)}),s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:X,onChange:ce=>V(ce.target.value)}),s.jsx(G,{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:Ts,disabled:W||!F||!X,children:W?"保存中":"确认修改"})]})]})]}),s.jsxs(Wt,{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(mu,{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((ce,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:ce.productType==="fullbook"||ce.productType==="vip"?"全书/VIP":`章节 ${ce.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(ce.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.createdAt?new Date(ce.createdAt).toLocaleString("zh-CN"):""})]},ce.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(ma,{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((ce,ve)=>ve[1]-ce[1]).map(([ce,ve])=>s.jsxs(Be,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[u8(ce)," ×",ve]},ce))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((ce,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:ti(ce.action)}),ve0?((x==null?void 0:x.visits)||[]).map((ce,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:["第 ",ce.seq||ve+1," 次 · ",ce.referrerNickname||"微信用户",ce.referrerId?`(${ce.referrerId})`:""]}),ce.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:ce.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.visitedAt?new Date(ce.visitedAt).toLocaleString():""})]},`${ce.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(Ua,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Be,{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((ce,ve)=>{var Zt;const Rt=ce;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:((Zt=Rt.nickname)==null?void 0:Zt.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Rt.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Rt.status==="vip"&&s.jsx(Be,{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:Rt.createdAt?new Date(Rt.createdAt).toLocaleDateString():""})]})]},Rt.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Wt,{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(xu,{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(Zj,{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(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:Pr.length===0,onClick:Ir,children:"合并到已选"})]}),Pr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:Pr.map(ce=>s.jsxs(Be,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${le.includes(ce)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[le.includes(ce)?"✓ ":"",ce]},ce))}):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(ce=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:ce.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:ce.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{le.includes(ve)?kn(ve):me([...le,ve])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${le.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:[le.includes(ve)?"✓ ":"",ve]},ve))})]},ce.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:[le.map((ce,ve)=>s.jsxs(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[ce,s.jsx("button",{type:"button",onClick:()=>kn(ce),className:"ml-1 hover:text-red-400",children:s.jsx(ns,{className:"w-3 h-3"})})]},ve)),le.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:I,onChange:ce=>Y(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&Gt()}),s.jsx(G,{onClick:Gt,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const ce=a.tags||a.ckbTags||"";let ve=[];try{const Zt=typeof ce=="string"?JSON.parse(ce||"[]"):[];ve=Array.isArray(Zt)?Zt:typeof ce=="string"?ce.split(","):[]}catch{ve=typeof ce=="string"?ce.split(","):[]}const Rt=ve.map(Zt=>String(Zt).trim()).filter(Boolean);return Rt.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(xu,{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:Rt.map((Zt,sn)=>s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:Zt},sn))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(G,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(G,{onClick:Pt,disabled:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),L?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Lt,{open:$,onOpenChange:Z,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsx(Dt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ae,onChange:ce=>we(ce.target.value)})]}),s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Fe,onChange:ce=>Ue(ce.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{variant:"outline",onClick:()=>Z(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(G,{onClick:Ms,disabled:wt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:wt?"提交中...":"确认调整"})]})]})})]}):null}function f8(){const t=Ya(),[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,T]=g.useState(0),[C,L]=g.useState(null),[R,U]=g.useState(null),[P,z]=g.useState(!1),[O,Q]=g.useState(0),[re,D]=g.useState(!1),[ne,le]=g.useState(null),[me,I]=g.useState("overview"),[Y,F]=g.useState([]),[xe,X]=g.useState(!1),[V,W]=g.useState("today"),[fe,he]=g.useState(null),[de,_]=g.useState(!1),[J,$]=g.useState(!0),[Z,ae]=g.useState(null),[we,Fe]=g.useState(null),[Ue,wt]=g.useState([]),jn=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 pt(Ne){var $t,kt;const Me=Ne?{signal:Ne}:void 0;n(!0),L(null);try{const $e=await Le("/api/admin/dashboard/stats",Me);$e!=null&&$e.success&&(x($e.totalUsers??0),N($e.paidOrderCount??0),v($e.totalRevenue??0),T($e.conversionRate??0))}catch($e){if(($e==null?void 0:$e.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",$e);try{const H=await Le("/api/admin/dashboard/overview",Me);H!=null&&H.success&&(x(H.totalUsers??0),N(H.paidOrderCount??0),v(H.totalRevenue??0),T(H.conversionRate??0))}catch(H){jn(H)}}}finally{n(!1)}try{const $e=await Le("/api/admin/balance/summary",Me);$e!=null&&$e.success&&$e.data&&Q($e.data.totalGifted??0)}catch{}try{const $e=await Le("/api/db/ckb-plan-stats",Me);$e!=null&&$e.success&&$e.data?le({ckbTotal:$e.data.ckbTotal??0,withContact:$e.data.withContact??0}):le(null)}catch{le(null)}$(!0);try{const[$e,H]=await Promise.allSettled([Le("/api/db/match-records?stats=true",Me),Le("/api/admin/distribution/overview",Me)]);$e.status==="fulfilled"&&(($t=$e.value)!=null&&$t.success)&&$e.value.data?ae({totalMatches:$e.value.data.totalMatches??0,todayMatches:$e.value.data.todayMatches??0,uniqueUsers:$e.value.data.uniqueUsers??0,paidMatchCount:$e.value.data.paidMatchCount??0}):ae(null),H.status==="fulfilled"&&((kt=H.value)!=null&&kt.success)&&H.value.overview?Fe({todayClicks:H.value.overview.todayClicks??0,todayBindings:H.value.overview.todayBindings??0,todayConversions:H.value.overview.todayConversions??0,monthClicks:H.value.overview.monthClicks??0,monthBindings:H.value.overview.monthBindings??0,monthConversions:H.value.overview.monthConversions??0,totalClicks:H.value.overview.totalClicks??0,totalBindings:H.value.overview.totalBindings??0,totalConversions:H.value.overview.totalConversions??0,conversionRate:H.value.overview.conversionRate}):Fe(null)}catch{ae(null),Fe(null)}finally{$(!1)}try{const $e=await Le("/api/db/vip-members?limit=500",Me);$e!=null&&$e.success&&Array.isArray($e.data)?wt($e.data):wt([])}catch{wt([])}a(!0),o(!0);const We=async()=>{try{const $e=await Le("/api/admin/dashboard/recent-orders?limit=10",Me);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 H=await Le("/api/admin/orders?page=1&pageSize=20&status=paid",Me),vt=((H==null?void 0:H.orders)??[]).filter(Ft=>["paid","completed","success"].includes(Ft.status||""));f(vt.slice(0,5))}catch{f([])}}finally{a(!1)}},rt=async()=>{try{const $e=await Le("/api/admin/dashboard/new-users",Me);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 H=await Le("/api/db/users?page=1&pageSize=10",Me);u((H==null?void 0:H.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([We(),rt()])}async function At(Ne){const Me=Ne||V;_(!0);try{const We=await Le(`/api/admin/track/stats?period=${Me}`);We!=null&&We.success&&he({total:We.total??0,byModule:We.byModule??{}})}catch{he(null)}finally{_(!1)}}const fn={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},Vn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},pn=Ne=>Ne?Ne.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",qt=Ne=>{if(!Ne)return"";const Me=Ne.trim().toLowerCase();if(!Me)return"";const We=Ue.find($t=>{const kt=String($t.id||"").toLowerCase();return kt===Me||kt.includes(Me)||Me.includes(kt)});if(We)return We.name||We.nickname||"";const rt=Ue.find($t=>{const kt=String($t.token||"").toLowerCase();return kt&&(kt===Me||kt.includes(Me)||Me.includes(kt))});return rt&&(rt.name||rt.nickname)||""},bn=Ne=>{if(!Ne)return"未命名点击";const Me=Ne.trim(),We=Me.toLowerCase();if(/^链接头像[_-]/.test(Me)){const $t=pn(Me.replace(/^链接头像[_-]/,""));return $t?`头像:${$t}`:"头像点击"}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`章节:${pn(Me)}`;if(We.includes("soulvip")||We.includes("super")){const $t=Me.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),kt=qt($t)||qt(pn($t));return kt?`超级个体:${kt}`:`超级个体:${pn($t)}`}if(We.includes("qgdtw")||We.includes("token")||We.includes("0000"))return`对象:${pn(Me)}`;const rt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return rt[Me]?rt[Me]:/^[a-z0-9_-]+$/i.test(Me)&&pn(Me)||Me},Mn=Ne=>{const Me=fn[Ne.module]||fn[Ne.page]||Ne.module||Ne.page||"其他",We=Vn[Ne.action]||Ne.action||"点击",rt=bn(Ne.target);return`${Me} · ${We} · ${rt}`};async function Hn(){X(!0);try{const Ne=await Le("/api/admin/super-individual/stats");Ne!=null&&Ne.success&&Array.isArray(Ne.data)&&F(Ne.data)}catch{}finally{X(!1)}}g.useEffect(()=>{const Ne=new AbortController;return pt(Ne.signal),At(),Hn(),()=>{Ne.abort()}},[]);const rs=m,_t=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 rt=typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2);return{title:We||`代付分享 ¥${rt}`,subtitle:"代付分享"}}if(Me==="section"&&We.includes("代付领取"))return{title:We.replace("代付领取 - ",""),subtitle:"代付领取"};if(We){if(Me==="section"&&We.includes("章节")){if(We.includes("-")){const rt=We.split("-");if(rt.length>=3)return{title:`第${rt[1]}章 第${rt[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||"其他"}},vn=[{title:"总用户数",value:e?null:rs,sub:null,icon:Kn,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:Of,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:b,sub:null,icon:mu,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:ur,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ne?ne.ckbTotal??0:null,sub:(ne==null?void 0:ne.withContact)!=null?`含联系方式 ${ne.withContact} 人`:null,icon:Qc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:J?null:((Z==null?void 0:Z.totalMatches)??0)+((we==null?void 0:we.totalClicks)??0),sub:J?null:`找伙伴 ${(Z==null?void 0:Z.totalMatches)??0} / 推广 ${(we==null?void 0:we.totalClicks)??0}`,icon:nu,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:"数据概览"}),C&&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:C}),s.jsx("button",{type:"button",onClick:()=>pt(),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:vn.map((Ne,Me)=>s.jsxs(De,{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(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(ut,{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(Ve,{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(Li,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>pt(),disabled:J,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 ${J?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(_e,{children:[J&&!Z&&!we?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(Ve,{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:(Z==null?void 0:Z.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:(Z==null?void 0:Z.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:(Z==null?void 0:Z.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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>pt(),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(Ve,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ve,{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(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,re?10:4).map(Ne=>{var kt;const Me=Ne.referrerId?c.find($e=>$e.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):""),rt=_t(Ne),$t=Ne.userNickname||((kt=c.find($e=>$e.id===Ne.userId))==null?void 0:kt.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:$t,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:$e=>{$e.currentTarget.style.display="none";const H=$e.currentTarget.nextElementSibling;H&&H.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:$t.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&&(U(Ne.userId),z(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:$t}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:rt.title,children:rt.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[rt.subtitle&&rt.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:rt.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&&!re&&s.jsx("button",{type:"button",onClick:()=>D(!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(mu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{children:s.jsx(ut,{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(Ve,{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:()=>{U(Ne.id),z(!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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{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:()=>{W(Ne),At(Ne)},className:`px-3 py-1 text-xs rounded-full transition-colors ${V===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:de&&!fe?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{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,rt)=>We+rt.count,0)-Ne[1].reduce((We,rt)=>We+rt.count,0)).slice(0,5).map(([Ne,Me])=>{const We=Me.reduce((rt,$t)=>rt+$t.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:fn[Ne]||Ne}),s.jsxs("span",{className:"text-xs text-gray-500",children:[We," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Me.sort((rt,$t)=>$t.count-rt.count).slice(0,8).map((rt,$t)=>{const kt=Mn(rt);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:kt,children:kt}),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?rt.count/We*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:rt.count})]})]},$t)})})]},Ne)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(nu,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:Hn,disabled:xe,children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${xe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{children:xe&&Y.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):Y.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:Y.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(nu,{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(py,{open:P,onClose:()=>{z(!1),U(null)},userId:R,onUserUpdated:()=>pt()})]})}const fs=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:zt("w-full caption-bottom text-sm",t),...e})}));fs.displayName="Table";const ps=g.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:zt("[&_tr]:border-b",t),...e}));ps.displayName="TableHeader";const ms=g.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:zt("[&_tr:last-child]:border-0",t),...e}));ms.displayName="TableBody";const xt=g.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:zt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));xt.displayName="TableRow";const Se=g.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:zt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));Se.displayName="TableHead";const je=g.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:zt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableCell";function qa(t,e){const[n,r]=g.useState(t);return g.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function xs({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 p8(){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=qa(N,300),[k,T]=g.useState("all"),[C,L]=g.useState(!0),[R,U]=g.useState(null),[P,z]=g.useState(null),[O,Q]=g.useState(""),[re,D]=g.useState(!1);async function ne(){L(!0),U(null);try{const X=k==="all"?"":k==="completed"?"completed":k,V=new URLSearchParams({page:String(f),pageSize:String(x),...X&&{status:X},...v&&{search:v}}),[W,fe]=await Promise.all([Le(`/api/admin/orders?${V}`),Le("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),fe!=null&&fe.success&&fe.users&&r(fe.users)}catch(X){console.error("加载订单失败",X),U("加载订单失败,请检查网络后重试")}finally{L(!1)}}g.useEffect(()=>{m(1)},[v,k]),g.useEffect(()=>{ne()},[f,x,v,k]);const le=X=>{var V;return X.userNickname||((V=n.find(W=>W.id===X.userId))==null?void 0:V.nickname)||"匿名用户"},me=X=>{var V;return((V=n.find(W=>W.id===X))==null?void 0:V.phone)||"-"},I=X=>{const V=X.productType||X.type||"",W=X.description||"";if(V==="balance_recharge")return{name:`余额充值 ¥${Number(X.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(V==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const fe=W.split("-");if(fe.length>=3)return{name:`第${fe[1]}章 第${fe[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return V==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:V==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:V==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return V==="section"?{name:`章节 ${X.productId||X.sectionId||""}`,type:"单章"}:V==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:V==="vip"?{name:"超级个体开通费用",type:"超级个体"}:V==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:V||"其他"}},Y=Math.ceil(a/x)||1;async function F(){var X;if(!(!(P!=null&&P.orderSn)&&!(P!=null&&P.id))){D(!0),U(null);try{const V=await tn("/api/admin/orders/refund",{orderSn:P.orderSn||P.id,reason:O||void 0});V!=null&&V.success?(z(null),Q(""),ne()):U((V==null?void 0:V.error)||"退款失败")}catch(V){const W=V;U(((X=W==null?void 0:W.data)==null?void 0:X.error)||"退款失败,请检查网络后重试")}finally{D(!1)}}}function xe(){if(t.length===0){q.info("暂无数据可导出");return}const X=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],V=t.map(_=>{const J=I(_);return[_.orderSn||_.id||"",le(_),me(_.userId),J.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(",")}),W="\uFEFF"+[X.join(","),...V].join(` -`),fe=new Blob([W],{type:"text/csv;charset=utf-8"}),he=URL.createObjectURL(fe),de=document.createElement("a");de.href=he,de.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,de.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:()=>U(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(G,{variant:"outline",onClick:ne,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${C?"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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:X=>w(X.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(sk,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:X=>T(X.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(G,{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(GT,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:C?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"订单号"}),s.jsx(Se,{className:"text-gray-400",children:"用户"}),s.jsx(Se,{className:"text-gray-400",children:"商品"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"支付方式"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"退款原因"}),s.jsx(Se,{className:"text-gray-400",children:"分销佣金"}),s.jsx(Se,{className:"text-gray-400",children:"下单时间"}),s.jsx(Se,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(X=>{const V=I(X);return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(je,{className:"font-mono text-xs text-gray-400",children:[(X.orderSn||X.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:[le(X),X.paymentMethod==="gift_pay"&&s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),X.payerUserId&&X.paymentMethod!=="gift_pay"&&s.jsx(Be,{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(X.userId)}),X.payerUserId&&X.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[X.paymentMethod==="gift_pay"?"赠送人:":"代付人:",X.payerNickname]})]})}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[V.name,(X.productType||X.type)==="vip"&&s.jsx(Be,{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:V.type})]})}),s.jsxs(je,{className:"text-[#38bdac] font-bold",children:["¥",Number(X.amount||0).toFixed(2)]}),s.jsx(je,{className:"text-gray-300",children:X.paymentMethod==="wechat"?"微信支付":X.paymentMethod==="balance"?"余额支付":X.paymentMethod==="alipay"?"支付宝":X.paymentMethod||"微信支付"}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):X.status==="paid"||X.status==="completed"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):X.status==="pending"||X.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(X.status==="paid"||X.status==="completed")&&(X.webhookPushStatus==="sent"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Be,{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:X.refundReason,children:X.status==="refunded"&&X.refundReason?X.refundReason:"-"}),s.jsx(je,{className:"text-[#FFD700]",children:X.referrerEarnings?`¥${Number(X.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(je,{className:"text-gray-400 text-sm",children:new Date(X.createdAt).toLocaleString("zh-CN")}),s.jsx(je,{children:(X.status==="paid"||X.status==="completed")&&X.paymentMethod!=="balance"&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{z(X),Q("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},X.id)}),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(xs,{page:f,totalPages:Y,total:a,pageSize:x,onPageChange:m,onPageSizeChange:X=>{b(X),m(1)}})]})})}),s.jsx(Lt,{open:!!P,onOpenChange:X=>!X&&z(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{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(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:X=>Q(X.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>z(null),disabled:re,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:F,disabled:re,children:re?"退款中...":"确认退款"})]})]})})]})}const el=g.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:zt("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}));el.displayName="Textarea";const oN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],M2={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 m8(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 x8(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 g8(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 lN(t){const e=M2[t],n=m8(e.group),r=x8(e.mood),a=g8(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},MR="DialogDescriptionWarning",AR=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${e2(MR).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},PR=Bk,IR=Uk,RR=Wk,LR=Kk,OR=Gk,DR=Qk,_R=Xk;function Lt(t){return s.jsx(PR,{"data-slot":"dialog",...t})}function $R(t){return s.jsx(IR,{...t})}const t2=g.forwardRef(({className:t,...e},n)=>s.jsx(RR,{ref:n,className:zt("fixed inset-0 z-50 bg-black/50",t),...e}));t2.displayName="DialogOverlay";const It=g.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},a)=>s.jsxs($R,{children:[s.jsx(t2,{}),s.jsxs(LR,{ref:a,"aria-describedby":void 0,className:zt("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(_R,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(ss,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));It.displayName="DialogContent";function Ot({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function nn({className:t,...e}){return s.jsx("div",{className:zt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Dt(t){return s.jsx(OR,{className:"text-lg font-semibold leading-none",...t})}function Wo(t){return s.jsx(DR,{className:"text-sm text-muted-foreground",...t})}const zR=pk("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 Be({className:t,variant:e,asChild:n=!1,...r}){const a=n?uk:"span";return s.jsx(a,{className:zt(zR({variant:e}),t),...r})}var FR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],BR=FR.reduce((t,e)=>{const n=dk(`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}},{}),VR="Label",n2=g.forwardRef((t,e)=>s.jsx(BR.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())}}));n2.displayName=VR;var s2=n2;const te=g.forwardRef(({className:t,...e},n)=>s.jsx(s2,{ref:n,className:zt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));te.displayName=s2.displayName;function dy(t){const e=t+"CollectionProvider",[n,r]=Zo(e),[a,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:v,children:k}=w,T=qs.useRef(null),C=qs.useRef(new Map).current;return s.jsx(a,{scope:v,itemMap:C,collectionRef:T,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Pu(c),h=qs.forwardRef((w,v)=>{const{scope:k,children:T}=w,C=i(c,k),L=Xt(v,C.collectionRef);return s.jsx(u,{ref:L,children:T})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",x=Pu(f),b=qs.forwardRef((w,v)=>{const{scope:k,children:T,...C}=w,L=qs.useRef(null),R=Xt(v,L),U=i(f,k);return qs.useEffect(()=>(U.itemMap.set(L,{ref:L,...C}),()=>void U.itemMap.delete(L))),s.jsx(x,{[m]:"",ref:R,children:T})});b.displayName=f;function N(w){const v=i(t+"CollectionConsumer",w);return qs.useCallback(()=>{const T=v.collectionRef.current;if(!T)return[];const C=Array.from(T.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((U,P)=>C.indexOf(U.ref.current)-C.indexOf(P.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:h,ItemSlot:b},N,r]}var HR=g.createContext(void 0);function Bp(t){const e=g.useContext(HR);return t||e||"ltr"}var Qx="rovingFocusGroup.onEntryFocus",UR={bubbles:!1,cancelable:!0},Gu="RovingFocusGroup",[Yg,r2,WR]=dy(Gu),[KR,a2]=Zo(Gu,[WR]),[qR,GR]=KR(Gu),i2=g.forwardRef((t,e)=>s.jsx(Yg.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Yg.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(JR,{...t,ref:e})})}));i2.displayName=Gu;var JR=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=Xt(e,x),N=Bp(i),[w,v]=Hl({prop:o,defaultProp:c??null,onChange:u,caller:Gu}),[k,T]=g.useState(!1),C=Uo(h),L=r2(n),R=g.useRef(!1),[U,P]=g.useState(0);return g.useEffect(()=>{const F=x.current;if(F)return F.addEventListener(Qx,C),()=>F.removeEventListener(Qx,C)},[C]),s.jsx(qR,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:w,onItemFocus:g.useCallback(F=>v(F),[v]),onItemShiftTab:g.useCallback(()=>T(!0),[]),onFocusableItemAdd:g.useCallback(()=>P(F=>F+1),[]),onFocusableItemRemove:g.useCallback(()=>P(F=>F-1),[]),children:s.jsx(Tt.div,{tabIndex:k||U===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:kt(t.onMouseDown,()=>{R.current=!0}),onFocus:kt(t.onFocus,F=>{const O=!R.current;if(F.target===F.currentTarget&&O&&!k){const Q=new CustomEvent(Qx,UR);if(F.currentTarget.dispatchEvent(Q),!Q.defaultPrevented){const re=L().filter(I=>I.focusable),D=re.find(I=>I.active),ne=re.find(I=>I.id===w),me=[D,ne,...re].filter(Boolean).map(I=>I.ref.current);c2(me,f)}}R.current=!1}),onBlur:kt(t.onBlur,()=>T(!1))})})}),o2="RovingFocusGroupItem",l2=g.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=t,u=_o(),h=i||u,f=GR(o2,n),m=f.currentTabStopId===h,x=r2(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:w}=f;return g.useEffect(()=>{if(r)return b(),()=>N()},[r,b,N]),s.jsx(Yg.ItemSlot,{scope:n,id:h,focusable:r,active:a,children:s.jsx(Tt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:kt(t.onMouseDown,v=>{r?f.onItemFocus(h):v.preventDefault()}),onFocus:kt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:kt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=XR(v,f.orientation,f.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=x().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const L=C.indexOf(v.currentTarget);C=f.loop?ZR(C,L+1):C.slice(L+1)}setTimeout(()=>c2(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});l2.displayName=o2;var QR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function YR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function XR(t,e,n){const r=YR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return QR[r]}function c2(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function ZR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var e8=i2,t8=l2,Vp="Tabs",[n8]=Zo(Vp,[a2]),d2=a2(),[s8,uy]=n8(Vp),u2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Bp(c),[m,x]=Hl({prop:r,onChange:a,defaultProp:i??"",caller:Vp});return s.jsx(s8,{scope:n,baseId:_o(),value:m,onValueChange:x,orientation:o,dir:f,activationMode:u,children:s.jsx(Tt.div,{dir:f,"data-orientation":o,...h,ref:e})})});u2.displayName=Vp;var h2="TabsList",f2=g.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=uy(h2,n),o=d2(n);return s.jsx(e8,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Tt.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:e})})});f2.displayName=h2;var p2="TabsTrigger",m2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=uy(p2,n),c=d2(n),u=y2(o.baseId,r),h=b2(o.baseId,r),f=r===o.value;return s.jsx(t8,{asChild:!0,...c,focusable:!a,active:f,children:s.jsx(Tt.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:kt(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:kt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:kt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(r)})})})});m2.displayName=p2;var x2="TabsContent",g2=g.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,c=uy(x2,n),u=y2(c.baseId,r),h=b2(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(qu,{present:a||f,children:({present:x})=>s.jsx(Tt.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})})});g2.displayName=x2;function y2(t,e){return`${t}-trigger-${e}`}function b2(t,e){return`${t}-content-${e}`}var r8=u2,v2=f2,N2=m2,w2=g2;const Wl=r8,Ko=g.forwardRef(({className:t,...e},n)=>s.jsx(v2,{ref:n,className:zt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ko.displayName=v2.displayName;const Ut=g.forwardRef(({className:t,...e},n)=>s.jsx(N2,{ref:n,className:zt("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}));Ut.displayName=N2.displayName;const Wt=g.forwardRef(({className:t,...e},n)=>s.jsx(w2,{ref:n,className:zt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Wt.displayName=w2.displayName;function hy(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 fy(t){const[e,n]=g.useState(void 0);return $s(()=>{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 Hp="Switch",[a8]=Zo(Hp),[i8,o8]=a8(Hp),j2=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=Xt(e,C=>b(C)),w=g.useRef(!1),v=x?f||!!x.closest("form"):!0,[k,T]=Hl({prop:a,defaultProp:i??!1,onChange:h,caller:Hp});return s.jsxs(i8,{scope:n,checked:k,disabled:c,children:[s.jsx(Tt.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":E2(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:N,onClick:kt(t.onClick,C=>{T(L=>!L),v&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),v&&s.jsx(C2,{control:x,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});j2.displayName=Hp;var k2="SwitchThumb",S2=g.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,a=o8(k2,n);return s.jsx(Tt.span,{"data-state":E2(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});S2.displayName=k2;var l8="SwitchBubbleInput",C2=g.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),c=Xt(o,i),u=hy(n),h=fy(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}})});C2.displayName=l8;function E2(t){return t?"checked":"unchecked"}var T2=j2,c8=S2;const Kt=g.forwardRef(({className:t,...e},n)=>s.jsx(T2,{className:zt("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(c8,{className:zt("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")})}));Kt.displayName=T2.displayName;const d8={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 u8(t){return d8[t]||t||"行为"}function h8(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 py({open:t,onClose:e,userId:n,onUserUpdated:r}){var Qr,Vs,Qs,pr,Ys,ka;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),[T,C]=g.useState(!1),[L,R]=g.useState(!1),[U,P]=g.useState("info"),[F,O]=g.useState(""),[Q,re]=g.useState(""),[D,ne]=g.useState(""),[le,me]=g.useState([]),[I,Y]=g.useState(""),[B,xe]=g.useState(""),[X,V]=g.useState(""),[W,fe]=g.useState(!1),[he,de]=g.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[_,J]=g.useState([]),[$,Z]=g.useState(!1),[ae,we]=g.useState(""),[Fe,Ue]=g.useState(""),[wt,jn]=g.useState(!1),[pt,At]=g.useState(!1),[fn,Vn]=g.useState(null),[pn,qt]=g.useState(null),[bn,Mn]=g.useState(""),[Hn,as]=g.useState(""),[_t,vn]=g.useState(""),[Ne,Me]=g.useState(!1),[We,rt]=g.useState(null),[$t,St]=g.useState(!1),[$e,H]=g.useState({}),[Qe,vt]=g.useState([]);g.useEffect(()=>{t&&n&&(St(!1),P("info"),Vn(null),qt(null),rt(null),xe(""),V(""),yt(),Le("/api/db/vip-roles").then(ce=>{ce!=null&&ce.success&&ce.data&&J(ce.data)}).catch(()=>{}))},[t,n]),g.useEffect(()=>{t&&Le("/api/admin/mbti-avatars").then(ce=>{ce!=null&&ce.avatars&&typeof ce.avatars=="object"?H(ce.avatars):H({})}).catch(()=>H({}))},[t]);const Ft=(ce,ve)=>{const Rt=(ce||"").trim();if(Rt)return ya(Rt);const Zt=(ve||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Zt)?($e[Zt]||"").trim():""};async function yt(){if(n){k(!0);try{const ce=await Le(`/api/db/users?id=${encodeURIComponent(n)}`);if(ce!=null&&ce.success&&ce.user){const ve=ce.user;i(ve),O(ve.phone||""),re(ve.wechatId||""),ne(ve.nickname||""),Mn(ve.phone||""),as(ve.wechatId||""),vn(ve.openId||"");try{me(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{me([])}de({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Le(`/api/admin/user/track?userId=${encodeURIComponent(n)}&limit=100`);if(ve!=null&&ve.success){h(ve.stats&&typeof ve.stats=="object"?ve.stats:{});const Rt=ve.tracks||[];c(Rt.map(Zt=>({...Zt,actionLabel:Zt.actionLabel||Zt.action,timeAgo:Zt.timeAgo||""})))}else h({}),c([])}catch{h({}),c([])}try{const ve=await Le(`/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 Le(`/api/admin/users/${encodeURIComponent(n)}/balance`);ve!=null&&ve.success&&ve.data?w(ve.data):w(null)}catch{w(null)}try{const ve=await Le(`/api/orders?userId=${encodeURIComponent(n)}&status=paid&pageSize=50`);ve!=null&&ve.success&&ve.orders?vt(ve.orders):vt([])}catch{vt([])}}catch(ce){console.error("Load user detail error:",ce)}finally{k(!1)}}}async function ht(){if(!(a!=null&&a.phone)){q.info("用户未绑定手机号,无法同步");return}C(!0);try{const ce=await bt("/api/ckb/sync",{action:"full_sync",phone:a.phone,userId:a.id});ce!=null&&ce.success?(q.success("同步成功"),yt()):q.error("同步失败: "+(ce==null?void 0:ce.error))}catch(ce){console.error("Sync CKB error:",ce),q.error("同步失败")}finally{C(!1)}}async function Pt(){if(a){if(he.isVip&&!he.vipExpireDate.trim()){q.error("开启 VIP 请填写有效到期日");return}R(!0);try{const ce={id:a.id,phone:F.trim()||void 0,wechatId:Q.trim(),nickname:D||void 0,tags:JSON.stringify(le),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 tn("/api/db/users",ce);ve!=null&&ve.success?(q.success("保存成功"),yt(),r==null||r()):q.error("保存失败: "+(ve==null?void 0:ve.error))}catch(ce){console.error("Save user error:",ce),q.error("保存失败")}finally{R(!1)}}}const Gt=()=>{I&&!le.includes(I)&&(me([...le,I]),Y(""))},kn=ce=>me(le.filter(ve=>ve!==ce));async function Ts(){if(a){if(!B){q.error("请输入新密码");return}if(B!==X){q.error("两次密码不一致");return}if(B.length<6){q.error("密码至少 6 位");return}fe(!0);try{const ce=await tn("/api/db/users",{id:a.id,password:B});ce!=null&&ce.success?(q.success("修改成功"),xe(""),V("")):q.error("修改失败: "+((ce==null?void 0:ce.error)||""))}catch{q.error("修改失败")}finally{fe(!1)}}}async function Ms(){if(!a)return;const ce=parseFloat(ae);if(Number.isNaN(ce)||ce===0){q.error("请输入有效金额(正数增加、负数扣减)");return}jn(!0);try{const ve=await bt(`/api/admin/users/${a.id}/balance/adjust`,{amount:ce,remark:Fe||void 0});ve!=null&&ve.success?(q.success("余额已调整"),Z(!1),we(""),Ue(""),yt(),r==null||r()):q.error("调整失败: "+((ve==null?void 0:ve.error)||""))}catch{q.error("调整失败")}finally{jn(!1)}}async function Ki(){if(!bn&&!_t&&!Hn){qt("请至少输入手机号、微信号或 OpenID 中的一项");return}At(!0),qt(null),Vn(null);try{const ce=new URLSearchParams;bn&&ce.set("phone",bn),_t&&ce.set("openId",_t),Hn&&ce.set("wechatId",Hn);const ve=await Le(`/api/admin/shensheshou/query?${ce}`);ve!=null&&ve.success&&ve.data?(Vn(ve.data),a&&await ja(ve.data)):qt((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(ce){console.error("SSS query error:",ce),qt("请求失败,请检查神射手接口配置")}finally{At(!1)}}async function ja(ce){if(a)try{await bt("/api/admin/shensheshou/enrich",{userId:a.id,phone:bn||a.phone||"",openId:_t||a.openId||"",wechatId:Hn||a.wechatId||""}),yt()}catch(ve){console.error("SSS enrich error:",ve)}}async function ei(){if(a){Me(!0),rt(null);try{const ce=Array.from(new Set(o.filter(is=>is.action==="view_chapter"||is.action==="purchase"||is.action==="first_pay").map(is=>(is.chapterTitle||is.target||"").trim()).filter(Boolean))).slice(0,12),ve={viewChapter:u.view_chapter||0,purchase:u.purchase||0,firstPay:u.first_pay||0},Rt=ce.length>0?`意向章节:${ce.join("、")}`:"",Zt={users:[{phone:a.phone||"",name:a.nickname||"",openId:a.openId||"",tags:le,purchaseIntent:ve,purchaseIntentChapters:ce,remark:Rt}]},sn=await bt("/api/admin/shensheshou/ingest",Zt);sn!=null&&sn.success&&sn.data?rt(sn.data):rt({error:(sn==null?void 0:sn.error)||"推送失败"})}catch(ce){console.error("SSS ingest error:",ce),rt({error:"请求失败"})}finally{Me(!1)}}}const ti=ce=>{const Rt={view_chapter:ur,purchase:mu,match:qn,login:Ai,register:Ai,share:Ua,bind_phone:_1,bind_wechat:HM,fill_profile:xu,fill_avatar:Ai,visit_page:ma,first_pay:mu,vip_activate:Xc,click_super:qn,lead_submit:_1,withdraw:Au,referral_bind:Ua,card_click:Ai,btn_click:Ho,tab_click:ma,nav_click:ma,page_view:ma,search:ma}[ce]||Vg;return s.jsx(Rt,{className:"w-4 h-4"})};function Ar(ce){const ve=String(ce||"").trim();return ve.length>22&&/^[a-zA-Z0-9_-]+$/.test(ve)}const Pr=g.useMemo(()=>h8(u,a),[u,a]);function Ir(){const ce=[...le];for(const ve of Pr)ce.includes(ve)||ce.push(ve);me(ce),q.success("已将旅程推断标签合并到已选")}return t?s.jsxs(s.Fragment,{children:[s.jsx(Lt,{open:t,onOpenChange:()=>e(),children:s.jsxs(It,{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(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ai,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(a==null?void 0:a.phone)&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(a==null?void 0:a.isVip)&&s.jsx(Be,{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(Ve,{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:Ft(a.avatar,a.mbti)&&!$t?s.jsx("img",{src:Ft(a.avatar,a.mbti),className:"w-full h-full rounded-full object-cover",alt:"",onError:()=>St(!0)}):((Qr=a.nickname)==null?void 0:Qr.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(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[10px] py-0",children:"管理员"}),a.hasFullBook&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-[10px] py-0",children:"全书已购"}),a.vipRole&&s.jsx(Be,{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:D||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:F||"—"})]}),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:Q||"—"})]}),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(G,{type:"button",size:"sm",variant:"ghost",className:"h-5 px-1 text-[9px] text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>{we(""),Ue(""),Z(!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(Wl,{value:U,onValueChange:P,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[s.jsxs(Ko,{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(Ut,{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(Ut,{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(ma,{className:"w-3 h-3 mr-0.5"}),"旅程与轨迹"]}),s.jsx(Ut,{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(Ut,{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(Wt,{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(te,{className:"text-gray-400 text-[11px]",children:"昵称"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"昵称",value:D,onChange:ce=>ne(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"手机号(可改,点底部保存生效)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"11 位手机号",value:F,onChange:ce=>O(ce.target.value)})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-[11px]",children:"微信标识(微信号/wxid,非 OpenID)"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-8 text-xs",placeholder:"如 wxid_xxx 或自定义微信号",value:Q,onChange:ce=>re(ce.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(ik,{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(Xc,{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(Be,{className:"bg-amber-500/20 text-amber-400 border-0 text-[10px] py-0 shrink-0",children:a.vipRole||"VIP"})]}),s.jsx(Kt,{className:"scale-90",checked:he.isVip,onCheckedChange:ce=>de(ve=>({...ve,isVip:ce}))})]}),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(te,{className:"text-gray-500 text-[10px]",children:"到期日"}),s.jsx(oe,{type:"date",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",value:he.vipExpireDate,onChange:ce=>de(ve=>({...ve,vipExpireDate:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{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:ce=>de(ve=>({...ve,vipRole:ce.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),_.map(ce=>s.jsx("option",{value:ce.name,children:ce.name},ce.id))]})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"展示名"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"展示名",value:he.vipName,onChange:ce=>de(ve=>({...ve,vipName:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"项目"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"项目",value:he.vipProject,onChange:ce=>de(ve=>({...ve,vipProject:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"联系方式"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"微信/手机",value:he.vipContact,onChange:ce=>de(ve=>({...ve,vipContact:ce.target.value}))})]}),s.jsxs("div",{className:"space-y-0.5 sm:col-span-2",children:[s.jsx(te,{className:"text-gray-500 text-[10px]",children:"简介"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"简短介绍",value:he.vipBio,onChange:ce=>de(ve=>({...ve,vipBio:ce.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(Ho,{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(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:手机",value:bn,onChange:ce=>Mn(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:微信号",value:Hn,onChange:ce=>as(ce.target.value)}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white h-7 text-xs",placeholder:"查:OpenID",value:_t,onChange:ce=>vn(ce.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsxs(G,{size:"sm",className:"h-7 text-[11px] px-2 bg-[#38bdac] hover:bg-[#2da396]",onClick:Ki,disabled:pt,children:[pt?s.jsx(Ve,{className:"w-3 h-3 animate-spin"}):s.jsx(hr,{className:"w-3 h-3 mr-0.5"}),"查询回填"]}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2 border-purple-500/40 text-purple-300",onClick:ei,disabled:Ne||!a.phone,children:Ne?"推送…":"推神射手"}),s.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] px-2",onClick:ht,disabled:T||!a.phone,children:T?"同步…":"存客宝同步"})]}),a.ckbSyncedAt&&s.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:["最近存客宝同步:",new Date(a.ckbSyncedAt).toLocaleString()]}),pn&&s.jsx("p",{className:"mt-1 text-red-400 text-[11px]",children:pn}),fn&&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:fn.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:fn.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(Au,{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(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"新密码 ≥6 位",value:B,onChange:ce=>xe(ce.target.value)}),s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white h-7 text-xs flex-1",placeholder:"确认密码",value:X,onChange:ce=>V(ce.target.value)}),s.jsx(G,{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:Ts,disabled:W||!B||!X,children:W?"保存中":"确认修改"})]})]})]}),s.jsxs(Wt,{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(mu,{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((ce,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:ce.productType==="fullbook"||ce.productType==="vip"?"全书/VIP":`章节 ${ce.productId||""}`}),s.jsxs("span",{className:"text-gray-500 ml-2",children:["¥",Number(ce.amount||0).toFixed(2)]})]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.createdAt?new Date(ce.createdAt).toLocaleString("zh-CN"):""})]},ce.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(ma,{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((ce,ve)=>ve[1]-ce[1]).map(([ce,ve])=>s.jsxs(Be,{variant:"outline",className:"text-[10px] border-gray-600 text-gray-300 bg-[#162840] py-0 h-5",children:[u8(ce)," ×",ve]},ce))})]}),s.jsx("div",{className:"space-y-1.5",children:o.length>0?o.map((ce,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:ti(ce.action)}),ve0?((x==null?void 0:x.visits)||[]).map((ce,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:["第 ",ce.seq||ve+1," 次 · ",ce.referrerNickname||"微信用户",ce.referrerId?`(${ce.referrerId})`:""]}),ce.page?s.jsx("p",{className:"text-gray-500 text-[10px] truncate",children:ce.page}):null]}),s.jsx("span",{className:"text-gray-500 text-[10px] shrink-0",children:ce.visitedAt?new Date(ce.visitedAt).toLocaleString():""})]},`${ce.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(Ua,{className:"w-3.5 h-3.5 text-[#38bdac]"}),s.jsx("span",{className:"text-white text-sm font-medium",children:"推荐的用户"})]}),s.jsxs(Be,{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((ce,ve)=>{var Zt;const Rt=ce;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:((Zt=Rt.nickname)==null?void 0:Zt.charAt(0))||"?"}),s.jsx("span",{className:"text-white truncate",children:Rt.nickname})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Rt.status==="vip"&&s.jsx(Be,{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:Rt.createdAt?new Date(Rt.createdAt).toLocaleDateString():""})]})]},Rt.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-3",children:"暂无推荐用户"})})]})]}),s.jsxs(Wt,{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(xu,{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(Zj,{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(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-cyan-500/40 text-cyan-200 hover:bg-cyan-500/10",disabled:Pr.length===0,onClick:Ir,children:"合并到已选"})]}),Pr.length>0?s.jsx("div",{className:"flex flex-wrap gap-1",children:Pr.map(ce=>s.jsxs(Be,{variant:"outline",className:`text-[10px] py-0 h-5 border-cyan-500/30 ${le.includes(ce)?"bg-cyan-500/15 text-cyan-200":"text-gray-300"}`,children:[le.includes(ce)?"✓ ":"",ce]},ce))}):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(ce=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-[11px] mb-1",children:ce.category}),s.jsx("div",{className:"flex flex-wrap gap-1",children:ce.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{le.includes(ve)?kn(ve):me([...le,ve])},className:`px-1.5 py-0.5 rounded text-[11px] border transition-all ${le.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:[le.includes(ve)?"✓ ":"",ve]},ve))})]},ce.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:[le.map((ce,ve)=>s.jsxs(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1 text-[11px] py-0",children:[ce,s.jsx("button",{type:"button",onClick:()=>kn(ce),className:"ml-1 hover:text-red-400",children:s.jsx(ss,{className:"w-3 h-3"})})]},ve)),le.length===0&&s.jsx("span",{className:"text-gray-600 text-xs",children:"暂未选择"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1 h-8 text-xs",placeholder:"自定义标签,回车添加",value:I,onChange:ce=>Y(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&Gt()}),s.jsx(G,{onClick:Gt,className:"bg-[#38bdac] hover:bg-[#2da396] h-8 text-xs px-3",children:"添加"})]})]})]}),(()=>{const ce=a.tags||a.ckbTags||"";let ve=[];try{const Zt=typeof ce=="string"?JSON.parse(ce||"[]"):[];ve=Array.isArray(Zt)?Zt:typeof ce=="string"?ce.split(","):[]}catch{ve=typeof ce=="string"?ce.split(","):[]}const Rt=ve.map(Zt=>String(Zt).trim()).filter(Boolean);return Rt.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(xu,{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:Rt.map((Zt,sn)=>s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 border-0 text-[11px] py-0",children:Zt},sn))})]})})()]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3 shrink-0",children:[s.jsxs(G,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(G,{onClick:Pt,disabled:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),L?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}),s.jsx(Lt,{open:$,onOpenChange:Z,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsx(Dt,{children:"调整余额"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"调整金额(元)"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"正数增加,负数扣减,如 10 或 -5",value:ae,onChange:ce=>we(ce.target.value)})]}),s.jsxs("div",{children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"备注(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white mt-1",placeholder:"如:活动补偿",value:Fe,onChange:ce=>Ue(ce.target.value)})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{variant:"outline",onClick:()=>Z(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(G,{onClick:Ms,disabled:wt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:wt?"提交中...":"确认调整"})]})]})})]}):null}function f8(){const t=Ya(),[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,T]=g.useState(0),[C,L]=g.useState(null),[R,U]=g.useState(null),[P,F]=g.useState(!1),[O,Q]=g.useState(0),[re,D]=g.useState(!1),[ne,le]=g.useState(null),[me,I]=g.useState("overview"),[Y,B]=g.useState([]),[xe,X]=g.useState(!1),[V,W]=g.useState("today"),[fe,he]=g.useState(null),[de,_]=g.useState(!1),[J,$]=g.useState(!0),[Z,ae]=g.useState(null),[we,Fe]=g.useState(null),[Ue,wt]=g.useState([]),jn=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 pt(Ne){var $t,St;const Me=Ne?{signal:Ne}:void 0;n(!0),L(null);try{const $e=await Le("/api/admin/dashboard/stats",Me);$e!=null&&$e.success&&(x($e.totalUsers??0),N($e.paidOrderCount??0),v($e.totalRevenue??0),T($e.conversionRate??0))}catch($e){if(($e==null?void 0:$e.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",$e);try{const H=await Le("/api/admin/dashboard/overview",Me);H!=null&&H.success&&(x(H.totalUsers??0),N(H.paidOrderCount??0),v(H.totalRevenue??0),T(H.conversionRate??0))}catch(H){jn(H)}}}finally{n(!1)}try{const $e=await Le("/api/admin/balance/summary",Me);$e!=null&&$e.success&&$e.data&&Q($e.data.totalGifted??0)}catch{}try{const $e=await Le("/api/db/ckb-plan-stats",Me);$e!=null&&$e.success&&$e.data?le({ckbTotal:$e.data.ckbTotal??0,withContact:$e.data.withContact??0}):le(null)}catch{le(null)}$(!0);try{const[$e,H]=await Promise.allSettled([Le("/api/db/match-records?stats=true",Me),Le("/api/admin/distribution/overview",Me)]);$e.status==="fulfilled"&&(($t=$e.value)!=null&&$t.success)&&$e.value.data?ae({totalMatches:$e.value.data.totalMatches??0,todayMatches:$e.value.data.todayMatches??0,uniqueUsers:$e.value.data.uniqueUsers??0,paidMatchCount:$e.value.data.paidMatchCount??0}):ae(null),H.status==="fulfilled"&&((St=H.value)!=null&&St.success)&&H.value.overview?Fe({todayClicks:H.value.overview.todayClicks??0,todayBindings:H.value.overview.todayBindings??0,todayConversions:H.value.overview.todayConversions??0,monthClicks:H.value.overview.monthClicks??0,monthBindings:H.value.overview.monthBindings??0,monthConversions:H.value.overview.monthConversions??0,totalClicks:H.value.overview.totalClicks??0,totalBindings:H.value.overview.totalBindings??0,totalConversions:H.value.overview.totalConversions??0,conversionRate:H.value.overview.conversionRate}):Fe(null)}catch{ae(null),Fe(null)}finally{$(!1)}try{const $e=await Le("/api/db/vip-members?limit=500",Me);$e!=null&&$e.success&&Array.isArray($e.data)?wt($e.data):wt([])}catch{wt([])}a(!0),o(!0);const We=async()=>{try{const $e=await Le("/api/admin/dashboard/recent-orders?limit=10",Me);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 H=await Le("/api/admin/orders?page=1&pageSize=20&status=paid",Me),vt=((H==null?void 0:H.orders)??[]).filter(Ft=>["paid","completed","success"].includes(Ft.status||""));f(vt.slice(0,5))}catch{f([])}}finally{a(!1)}},rt=async()=>{try{const $e=await Le("/api/admin/dashboard/new-users",Me);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 H=await Le("/api/db/users?page=1&pageSize=10",Me);u((H==null?void 0:H.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([We(),rt()])}async function At(Ne){const Me=Ne||V;_(!0);try{const We=await Le(`/api/admin/track/stats?period=${Me}`);We!=null&&We.success&&he({total:We.total??0,byModule:We.byModule??{}})}catch{he(null)}finally{_(!1)}}const fn={home:"首页",chapters:"目录",read:"阅读页",my:"我的",vip:"超级个体",wallet:"钱包",match:"找伙伴",referral:"推广中心",search:"搜索",settings:"设置",about:"关于",member_detail:"成员详情",other:"其他"},Vn={btn_click:"按钮点击",nav_click:"导航点击",card_click:"卡片点击",tab_click:"标签切换",page_view:"页面浏览",share:"分享",purchase:"购买",register:"注册",rule_trigger:"规则触发",view_chapter:"浏览章节",link_click:"链接点击"},pn=Ne=>Ne?Ne.replace(/^part-/,"").replace(/^soulvip_/,"").replace(/^super_?/,"").replace(/^user_/,"").replace(/[_-]+/g," ").trim():"",qt=Ne=>{if(!Ne)return"";const Me=Ne.trim().toLowerCase();if(!Me)return"";const We=Ue.find($t=>{const St=String($t.id||"").toLowerCase();return St===Me||St.includes(Me)||Me.includes(St)});if(We)return We.name||We.nickname||"";const rt=Ue.find($t=>{const St=String($t.token||"").toLowerCase();return St&&(St===Me||St.includes(Me)||Me.includes(St))});return rt&&(rt.name||rt.nickname)||""},bn=Ne=>{if(!Ne)return"未命名点击";const Me=Ne.trim(),We=Me.toLowerCase();if(/^链接头像[_-]/.test(Me)){const $t=pn(Me.replace(/^链接头像[_-]/,""));return $t?`头像:${$t}`:"头像点击"}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`章节:${pn(Me)}`;if(We.includes("soulvip")||We.includes("super")){const $t=Me.replace(/^超级个体[::]?/i,"").replace(/^super[_-]?/i,"").replace(/^soulvip[_-]?/i,"").replace(/^user[_-]?/i,"").trim(),St=qt($t)||qt(pn($t));return St?`超级个体:${St}`:`超级个体:${pn($t)}`}if(We.includes("qgdtw")||We.includes("token")||We.includes("0000"))return`对象:${pn(Me)}`;const rt={开始匹配:"开始匹配",mentor:"导师顾问",team:"团队招募",investor:"资源对接",充值:"充值",退款:"退款",wallet:"钱包",设置:"设置",VIP:"VIP会员",推广:"推广中心",目录:"目录",搜索:"搜索",匹配:"找伙伴",settings:"设置",expired:"已过期",active:"活跃",converted:"已转化",fill_profile:"完善资料",register:"注册",purchase:"购买",链接卡若:"链接卡若",更多分享:"更多分享",分享朋友圈文案:"分享朋友圈",选择金额10:"选择金额10元",member_detail:"成员详情",giftPay:"代付入口"};return rt[Me]?rt[Me]:/^[a-z0-9_-]+$/i.test(Me)&&pn(Me)||Me},Mn=Ne=>{const Me=fn[Ne.module]||fn[Ne.page]||Ne.module||Ne.page||"其他",We=Vn[Ne.action]||Ne.action||"点击",rt=bn(Ne.target);return`${Me} · ${We} · ${rt}`};async function Hn(){X(!0);try{const Ne=await Le("/api/admin/super-individual/stats");Ne!=null&&Ne.success&&Array.isArray(Ne.data)&&B(Ne.data)}catch{}finally{X(!1)}}g.useEffect(()=>{const Ne=new AbortController;return pt(Ne.signal),At(),Hn(),()=>{Ne.abort()}},[]);const as=m,_t=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 rt=typeof Ne.amount=="number"?Ne.amount.toFixed(2):parseFloat(String(Ne.amount||"0")).toFixed(2);return{title:We||`代付分享 ¥${rt}`,subtitle:"代付分享"}}if(Me==="section"&&We.includes("代付领取"))return{title:We.replace("代付领取 - ",""),subtitle:"代付领取"};if(We){if(Me==="section"&&We.includes("章节")){if(We.includes("-")){const rt=We.split("-");if(rt.length>=3)return{title:`第${rt[1]}章 第${rt[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||"其他"}},vn=[{title:"总用户数",value:e?null:as,sub:null,icon:qn,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:Of,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:b,sub:null,icon:mu,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:ur,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"},{title:"存客宝获客",value:ne?ne.ckbTotal??0:null,sub:(ne==null?void 0:ne.withContact)!=null?`含联系方式 ${ne.withContact} 人`:null,icon:Qc,color:"text-cyan-400",bg:"bg-cyan-500/20",link:"/users?tab=leads"},{title:"伙伴&推广协同",value:J?null:((Z==null?void 0:Z.totalMatches)??0)+((we==null?void 0:we.totalClicks)??0),sub:J?null:`找伙伴 ${(Z==null?void 0:Z.totalMatches)??0} / 推广 ${(we==null?void 0:we.totalClicks)??0}`,icon:nu,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:"数据概览"}),C&&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:C}),s.jsx("button",{type:"button",onClick:()=>pt(),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:vn.map((Ne,Me)=>s.jsxs(De,{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(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(ut,{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(Ve,{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(Li,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"找伙伴 × 推广中心(共统计)"}),s.jsxs("button",{type:"button",onClick:()=>pt(),disabled:J,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新共统计",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 ${J?"animate-spin":""}`}),"刷新"]})]}),s.jsxs(_e,{children:[J&&!Z&&!we?s.jsxs("div",{className:"flex items-center justify-center py-10 text-gray-500",children:[s.jsx(Ve,{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:(Z==null?void 0:Z.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:(Z==null?void 0:Z.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:(Z==null?void 0:Z.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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsx(ut,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>pt(),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(Ve,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ve,{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(Ve,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,re?10:4).map(Ne=>{var St;const Me=Ne.referrerId?c.find($e=>$e.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):""),rt=_t(Ne),$t=Ne.userNickname||((St=c.find($e=>$e.id===Ne.userId))==null?void 0:St.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:$t,className:"w-9 h-9 rounded-full object-cover shrink-0 mt-0.5",onError:$e=>{$e.currentTarget.style.display="none";const H=$e.currentTarget.nextElementSibling;H&&H.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:$t.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&&(U(Ne.userId),F(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:$t}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",title:rt.title,children:rt.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[rt.subtitle&&rt.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:rt.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&&!re&&s.jsx("button",{type:"button",onClick:()=>D(!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(mu,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{children:s.jsx(ut,{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(Ve,{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:()=>{U(Ne.id),F(!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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{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:()=>{W(Ne),At(Ne)},className:`px-3 py-1 text-xs rounded-full transition-colors ${V===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:de&&!fe?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{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,rt)=>We+rt.count,0)-Ne[1].reduce((We,rt)=>We+rt.count,0)).slice(0,5).map(([Ne,Me])=>{const We=Me.reduce((rt,$t)=>rt+$t.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:fn[Ne]||Ne}),s.jsxs("span",{className:"text-xs text-gray-500",children:[We," 次"]})]}),s.jsx("div",{className:"space-y-2",children:Me.sort((rt,$t)=>$t.count-rt.count).slice(0,8).map((rt,$t)=>{const St=Mn(rt);return s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-gray-300 truncate mr-2",title:St,children:St}),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?rt.count/We*100:0}%`}})}),s.jsx("span",{className:"text-gray-400 w-8 text-right",children:rt.count})]})]},$t)})})]},Ne)})})]}):s.jsxs("div",{className:"text-center py-12",children:[s.jsx(nu,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(nu,{className:"w-5 h-5 text-amber-400"}),"超级个体点击统计"]}),s.jsxs(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300 h-8",onClick:Hn,disabled:xe,children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${xe?"animate-spin":""}`}),"刷新"]})]}),s.jsx(_e,{children:xe&&Y.length===0?s.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-500",children:[s.jsx(Ve,{className:"w-6 h-6 animate-spin mr-2"}),s.jsx("span",{children:"加载中..."})]}):Y.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:Y.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(nu,{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(py,{open:P,onClose:()=>{F(!1),U(null)},userId:R,onUserUpdated:()=>pt()})]})}const fs=g.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:zt("w-full caption-bottom text-sm",t),...e})}));fs.displayName="Table";const ps=g.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:zt("[&_tr]:border-b",t),...e}));ps.displayName="TableHeader";const ms=g.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:zt("[&_tr:last-child]:border-0",t),...e}));ms.displayName="TableBody";const xt=g.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:zt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));xt.displayName="TableRow";const Se=g.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:zt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));Se.displayName="TableHead";const je=g.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:zt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableCell";function qa(t,e){const[n,r]=g.useState(t);return g.useEffect(()=>{const a=setTimeout(()=>r(t),e);return()=>clearTimeout(a)},[t,e]),n}function xs({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 p8(){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=qa(N,300),[k,T]=g.useState("all"),[C,L]=g.useState(!0),[R,U]=g.useState(null),[P,F]=g.useState(null),[O,Q]=g.useState(""),[re,D]=g.useState(!1);async function ne(){L(!0),U(null);try{const X=k==="all"?"":k==="completed"?"completed":k,V=new URLSearchParams({page:String(f),pageSize:String(x),...X&&{status:X},...v&&{search:v}}),[W,fe]=await Promise.all([Le(`/api/admin/orders?${V}`),Le("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),i(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),fe!=null&&fe.success&&fe.users&&r(fe.users)}catch(X){console.error("加载订单失败",X),U("加载订单失败,请检查网络后重试")}finally{L(!1)}}g.useEffect(()=>{m(1)},[v,k]),g.useEffect(()=>{ne()},[f,x,v,k]);const le=X=>{var V;return X.userNickname||((V=n.find(W=>W.id===X.userId))==null?void 0:V.nickname)||"匿名用户"},me=X=>{var V;return((V=n.find(W=>W.id===X))==null?void 0:V.phone)||"-"},I=X=>{const V=X.productType||X.type||"",W=X.description||"";if(V==="balance_recharge")return{name:`余额充值 ¥${Number(X.amount||0).toFixed(2)}`,type:"余额充值"};if(W){if(V==="section"&&(W.includes("章节")||W.includes("代付领取"))){if(W.includes("代付领取"))return{name:W.replace("代付领取 - ",""),type:"代付领取"};if(W.includes("-")){const fe=W.split("-");if(fe.length>=3)return{name:`第${fe[1]}章 第${fe[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return V==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:V==="vip"||W.includes("VIP")?{name:"超级个体开通费用",type:"超级个体"}:V==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return V==="section"?{name:`章节 ${X.productId||X.sectionId||""}`,type:"单章"}:V==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:V==="vip"?{name:"超级个体开通费用",type:"超级个体"}:V==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:V||"其他"}},Y=Math.ceil(a/x)||1;async function B(){var X;if(!(!(P!=null&&P.orderSn)&&!(P!=null&&P.id))){D(!0),U(null);try{const V=await tn("/api/admin/orders/refund",{orderSn:P.orderSn||P.id,reason:O||void 0});V!=null&&V.success?(F(null),Q(""),ne()):U((V==null?void 0:V.error)||"退款失败")}catch(V){const W=V;U(((X=W==null?void 0:W.data)==null?void 0:X.error)||"退款失败,请检查网络后重试")}finally{D(!1)}}}function xe(){if(t.length===0){q.info("暂无数据可导出");return}const X=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],V=t.map(_=>{const J=I(_);return[_.orderSn||_.id||"",le(_),me(_.userId),J.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(",")}),W="\uFEFF"+[X.join(","),...V].join(` +`),fe=new Blob([W],{type:"text/csv;charset=utf-8"}),he=URL.createObjectURL(fe),de=document.createElement("a");de.href=he,de.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,de.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:()=>U(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(G,{variant:"outline",onClick:ne,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${C?"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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:N,onChange:X=>w(X.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(sk,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:X=>T(X.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(G,{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(GT,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:C?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"订单号"}),s.jsx(Se,{className:"text-gray-400",children:"用户"}),s.jsx(Se,{className:"text-gray-400",children:"商品"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"支付方式"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"退款原因"}),s.jsx(Se,{className:"text-gray-400",children:"分销佣金"}),s.jsx(Se,{className:"text-gray-400",children:"下单时间"}),s.jsx(Se,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(X=>{const V=I(X);return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(je,{className:"font-mono text-xs text-gray-400",children:[(X.orderSn||X.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:[le(X),X.paymentMethod==="gift_pay"&&s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 border-0 text-xs",children:"代付领取"}),X.payerUserId&&X.paymentMethod!=="gift_pay"&&s.jsx(Be,{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(X.userId)}),X.payerUserId&&X.payerNickname&&s.jsxs("p",{className:"text-amber-400/80 text-xs mt-0.5",children:[X.paymentMethod==="gift_pay"?"赠送人:":"代付人:",X.payerNickname]})]})}),s.jsx(je,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[V.name,(X.productType||X.type)==="vip"&&s.jsx(Be,{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:V.type})]})}),s.jsxs(je,{className:"text-[#38bdac] font-bold",children:["¥",Number(X.amount||0).toFixed(2)]}),s.jsx(je,{className:"text-gray-300",children:X.paymentMethod==="wechat"?"微信支付":X.paymentMethod==="balance"?"余额支付":X.paymentMethod==="alipay"?"支付宝":X.paymentMethod||"微信支付"}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):X.status==="paid"||X.status==="completed"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):X.status==="pending"||X.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"}),(X.status==="paid"||X.status==="completed")&&(X.webhookPushStatus==="sent"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/20 border-0",children:"已推送"}):s.jsx(Be,{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:X.refundReason,children:X.status==="refunded"&&X.refundReason?X.refundReason:"-"}),s.jsx(je,{className:"text-[#FFD700]",children:X.referrerEarnings?`¥${Number(X.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(je,{className:"text-gray-400 text-sm",children:new Date(X.createdAt).toLocaleString("zh-CN")}),s.jsx(je,{children:(X.status==="paid"||X.status==="completed")&&X.paymentMethod!=="balance"&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{F(X),Q("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},X.id)}),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(xs,{page:f,totalPages:Y,total:a,pageSize:x,onPageChange:m,onPageSizeChange:X=>{b(X),m(1)}})]})})}),s.jsx(Lt,{open:!!P,onOpenChange:X=>!X&&F(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{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(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:O,onChange:X=>Q(X.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>F(null),disabled:re,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:B,disabled:re,children:re?"退款中...":"确认退款"})]})]})})]})}const el=g.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:zt("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}));el.displayName="Textarea";const oN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],M2={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 m8(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 x8(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 g8(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 lN(t){const e=M2[t],n=m8(e.group),r=x8(e.mood),a=g8(e.mood),i=` @@ -680,19 +680,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do -`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function y8(){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 Le("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{q.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);g.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await bt("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){q.error((x==null?void 0:x.error)||"保存失败");return}q.success("已保存,后台与小程序默认头像同步生效"),u()}catch{q.error("保存失败")}finally{i(!1)}},f=x=>{const b=lN(x);e(N=>({...N,[x]:b})),q.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};oN.forEach(b=>{x[b]=lN(b)}),e(x),q.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(Ve,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(dt,{className:"pb-2",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(SA,{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(G,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(GA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(Ve,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(G,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(Tn,{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:oN.map(x=>{const b=t[x]??"",N=M2[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(Be,{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(oe,{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(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const cN=[{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:"用户状态"}],dN=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}];function A2(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 b8(t){return{...t,triggerConditions:A2(t.triggerConditions)}}const v8=[{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:"待激活"}],Fc=[{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 uN(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function N8({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:ya(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 w8(t){const e=(t||"").trim();if(!e)return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function j8(){var eo,eh,Ed,Td,Md,Ad,Pd;const[t,e]=X0(),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=qa(N,300),k=n==="vip"?"vip":n==="complete"?"complete":"all",[T,C]=g.useState(k),[L,R]=g.useState(!0),[U,P]=g.useState(!1),[z,O]=g.useState(null),[Q,re]=g.useState(!1),[D,ne]=g.useState(!1),[le,me]=g.useState("desc");g.useEffect(()=>{n==="vip"?C("vip"):n==="complete"?C("complete"):n==="all"&&C("all")},[n]);const[I,Y]=g.useState(!1),[F,xe]=g.useState(null),[X,V]=g.useState(!1),[W,fe]=g.useState(!1),[he,de]=g.useState({referrals:[],stats:{}}),[_,J]=g.useState(!1),[$,Z]=g.useState(null),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState(null),[wt,jn]=g.useState(!1),[pt,At]=g.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[fn,Vn]=g.useState([]),[pn,qt]=g.useState(!1),[bn,Mn]=g.useState(!1),[Hn,rs]=g.useState(null),[_t,vn]=g.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[Ne,Me]=g.useState([]),[We,rt]=g.useState(!1),[$t,kt]=g.useState(null),[$e,H]=g.useState(null),[Qe,vt]=g.useState({}),[Ft,yt]=g.useState(!1),[ht,Pt]=g.useState(null),[Gt,kn]=g.useState([]),[Ts,Ms]=g.useState(!1),[Ki,ja]=g.useState(null),[ei,ti]=g.useState(""),[Ar,Pr]=g.useState([]),[Ir,Qr]=g.useState(!1),[Vs,Qs]=g.useState({}),[pr,Ys]=g.useState([]),[ka,ce]=g.useState(0),[ve,Rt]=g.useState(1),[Zt]=g.useState(10),[sn,as]=g.useState(!1),[Rr,Yr]=g.useState(null),[Tt,Jn]=g.useState(""),Xr=qa(Tt,300),[Sa,mn]=g.useState(""),[Zr,ni]=g.useState(""),[mr,As]=g.useState(""),[Ca,qi]=g.useState(!1),[Xs,Zs]=g.useState({}),[Gi,bs]=g.useState(null),[il,Ji]=g.useState(null),[vs,er]=g.useState([]),[tr,xr]=g.useState(!1),si=g.useRef(null),[ea,ac]=g.useState(!1),[ol,ri]=g.useState(!1),[Qi,Ea]=g.useState("存客宝返回 data"),[ll,Ta]=g.useState(""),Nt=g.useCallback(async(M,ee)=>{as(!0),Yr(null);try{const be=new URLSearchParams({mode:"contact",page:String(ve),pageSize:String(Zt)}),Ae=M??Xr;Ae&&be.set("search",Ae);const Ge=ee??Sa;Ge&&be.set("source",Ge),Zr&&be.set("action",Zr),mr&&be.set("pushStatus",mr);const Je=await Le(`/api/db/ckb-leads?${be}`);if(Je!=null&&Je.success)Ys(Je.records||[]),ce(Je.total??0),Je.stats&&Zs(Je.stats);else{const Vt=(Je==null?void 0:Je.error)||"加载获客列表失败";Yr(Vt),q.error(Vt),Ys([]),ce(0)}}catch(be){const Ae=be instanceof Error?be.message:"网络错误";Yr(Ae),q.error("加载获客列表失败: "+Ae),Ys([]),ce(0)}finally{as(!1)}},[ve,Zt,Xr,Sa,Zr,mr]);g.useEffect(()=>{er([])},[Xr,Sa,Zr,mr]),g.useEffect(()=>{a==="leads"&&ni(i)},[a,i]);function Yi(M,ee){return{...M,...ee.pushStatus!==void 0?{pushStatus:ee.pushStatus}:{},...typeof ee.retryCount=="number"?{retryCount:ee.retryCount}:{},...typeof ee.ckbCode=="number"?{ckbCode:ee.ckbCode}:{},...ee.ckbMessage!==void 0?{ckbMessage:ee.ckbMessage}:{},...ee.ckbData!==void 0?{ckbData:ee.ckbData}:{},...ee.ckbError!==void 0?{ckbError:ee.ckbError}:{},...ee.lastPushAt!==void 0?{lastPushAt:ee.lastPushAt??void 0}:{},...ee.nextRetryAt!==void 0?{nextRetryAt:ee.nextRetryAt??void 0}:{}}}async function cl(M){if(M){bs(M);try{const ee=await bt("/api/db/ckb-leads/retry",{id:M});ee!=null&&ee.success?(q.success(ee.pushed?"重推成功":"已发起重推,请刷新查看状态"),ee.record&&Ys(be=>be.map(Ae=>Ae.id===M?Yi(Ae,ee.record):Ae))):q.error((ee==null?void 0:ee.error)||"重推失败")}catch(ee){q.error(ee instanceof Error?ee.message:"重推请求失败")}finally{bs(null)}}}async function ai(M){if(M&&confirm("确定删除该条获客记录?删除后不可恢复。")){Ji(M);try{const ee=await bt("/api/db/ckb-leads/delete",{id:M});ee!=null&&ee.success?q.success("已删除"):q.error((ee==null?void 0:ee.error)||"删除失败")}catch(ee){q.error(ee instanceof Error?ee.message:"删除请求失败")}finally{Ji(null),Nt()}}}async function ii(){const M=at.filter(Ae=>Ae.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}ac(!0);let ee=0;for(const Ae of M)try{const Ge=await bt("/api/db/ckb-leads/retry",{id:Ae.id});if(Ge!=null&&Ge.success&&Ge.pushed&&ee++,Ge!=null&&Ge.success&&Ge.record){const Je=Ge.record;Ys(Vt=>Vt.map(He=>He.id===Ae.id?Yi(He,Je):He))}}catch{}ac(!1);const be=M.length;q.success(`批量重推完成:成功 ${ee} / ${be}`)}function ic(){const M=at.filter(He=>He.pushStatus==="failed");if(M.length===0){q.info("当前筛选下无失败记录可导出");return}const ee=He=>`"${String(He??"").replace(/"/g,'""')}"`,Ae=[["ID","昵称","手机号","微信号","对应@人","计划Key","来源","推送状态","重试次数","失败原因","下次重试时间","创建时间"].join(",")];for(const He of M)Ae.push([ee(He.id),ee(He.userNickname||He.name||""),ee(He.phone||""),ee(He.wechatId||""),ee(He.personName||""),ee(He.planApiKey||""),ee(He.source||""),ee(He.pushStatus||""),ee(typeof He.retryCount=="number"?He.retryCount:""),ee(He.ckbError||""),ee(He.nextRetryAt?new Date(He.nextRetryAt).toLocaleString():""),ee(He.createdAt?new Date(He.createdAt).toLocaleString():"")].join(","));const Ge=new Blob(["\uFEFF"+Ae.join(` -`)],{type:"text/csv;charset=utf-8;"}),Je=URL.createObjectURL(Ge),Vt=document.createElement("a");Vt.href=Je,Vt.download=`获客失败清单-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,document.body.appendChild(Vt),Vt.click(),document.body.removeChild(Vt),URL.revokeObjectURL(Je),q.success(`已导出失败清单(${M.length} 条)`)}const Qn=g.useCallback(async()=>{try{const M=await Le("/api/admin/mbti-avatars"),ee=M!=null&&M.avatars&&typeof M.avatars=="object"?M.avatars:{};Qs(ee)}catch{Qs({})}},[]);g.useEffect(()=>{t.get("tab")==="leads"&&Nt()},[t.get("tab"),ve,Nt]),g.useEffect(()=>{if(a!=="leads")return;const M=window.setInterval(()=>{Nt()},3e4);return()=>window.clearInterval(M)},[a,Nt]),g.useEffect(()=>{Qn()},[Qn]);const Ma=g.useCallback((M,ee)=>{const be=(M||"").trim();if(be)return be;const Ae=(ee||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Ae)?(Vs[Ae]||"").trim():""},[Vs]),ta=g.useCallback(M=>{const ee=!!M.hasFullBook,be=Number(M.purchasedSectionCount||0);return ee?{tone:"vip",main:"已购全书",sub:be>0?`另购单章 ${be} 章`:"购买项:VIP / 全书"}:be>0?{tone:"paid",main:`已购 ${be} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Hs,Us]=g.useState(null),cn=g.useCallback(async()=>{try{const M=await Le("/api/admin/users/online-stats");M!=null&&M.success&&typeof M.onlineCount=="number"?Us(M.onlineCount):Us(0)}catch{Us(null)}},[]);g.useEffect(()=>{cn();const M=setInterval(cn,1e4);return()=>clearInterval(M)},[cn]);async function nr(M=!1){var ee;R(!0),M&&P(!0),O(null);try{if(Q){const be=new URLSearchParams({search:v,limit:String(x*5)}),Ae=await Le(`/api/db/users/rfm?${be}`);if(Ae!=null&&Ae.success){let Ge=Ae.users||[];le==="asc"&&(Ge=[...Ge].reverse());const Je=(f-1)*x;c(Ge.slice(Je,Je+x)),h(((ee=Ae.users)==null?void 0:ee.length)??0),Ge.length===0&&(re(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else re(!1),O((Ae==null?void 0:Ae.error)||"RFM 加载失败,已切回普通模式")}else{const be=new URLSearchParams({page:String(f),pageSize:String(x),search:v,...T==="vip"&&{vip:"true"},...T==="complete"&&{pool:"complete"}}),Ae=await Le(`/api/db/users?${be}`);Ae!=null&&Ae.success?(c(Ae.users||[]),h(Ae.total??0)):O((Ae==null?void 0:Ae.error)||"加载失败")}}catch(be){console.error("Load users error:",be),O("网络错误")}finally{R(!1),M&&P(!1)}}g.useEffect(()=>{m(1)},[v,T,Q]),g.useEffect(()=>{nr()},[f,x,v,T,Q,le]);const gr=Math.ceil(u/x)||1,yr=()=>{Q?le==="desc"?me("asc"):(re(!1),me("desc")):(re(!0),me("desc"))},oc=M=>({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"})[M||""]||"bg-gray-500/20 text-gray-400";async function lc(M){var ee;if(!uN("用户")){q.info("已取消删除");return}try{const be=await Pi(`/api/db/users?id=${encodeURIComponent(M)}`);be!=null&&be.success?(q.success("已删除"),nr()):q.error("删除失败: "+((be==null?void 0:be.error)||"未知错误"))}catch(be){const Ae=be,Ge=((ee=Ae==null?void 0:Ae.data)==null?void 0:ee.error)||(Ae==null?void 0:Ae.message)||"网络错误";q.error("删除失败: "+Ge)}}const Aa=M=>{xe(M),At({phone:M.phone||"",nickname:M.nickname||"",password:"",isAdmin:!!(M.isAdmin??!1),hasFullBook:!!(M.hasFullBook??!1)}),Y(!0)},wd=()=>{xe(null),At({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),Y(!0)};async function dl(){if(!pt.phone||!pt.nickname){q.error("请填写手机号和昵称");return}V(!0);try{if(F){const M=await tn("/api/db/users",{id:F.id,phone:pt.phone||void 0,nickname:pt.nickname,isAdmin:pt.isAdmin,hasFullBook:pt.hasFullBook,...pt.password&&{password:pt.password}});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/users",{phone:pt.phone,nickname:pt.nickname,password:pt.password,isAdmin:pt.isAdmin});if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Y(!1),nr()}catch{q.error("保存失败")}finally{V(!1)}}async function Ns(M){Z(M),fe(!0),J(!0);try{const ee=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(M.id)}`);ee!=null&&ee.success?de({referrals:ee.referrals||[],stats:ee.stats||{}}):de({referrals:[],stats:{}})}catch{de({referrals:[],stats:{}})}finally{J(!1)}}const na=g.useCallback(async()=>{qt(!0);try{const M=await Le("/api/db/user-rules");M!=null&&M.success&&Vn((M.rules||[]).map(ee=>b8(ee)))}catch{}finally{qt(!1)}},[]);async function sa(){if(!_t.title){q.error("请填写规则标题");return}V(!0);try{if(Hn){const M=await tn("/api/db/user-rules",{id:Hn.id,..._t});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/user-rules",_t);if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Mn(!1),na()}catch{q.error("保存失败")}finally{V(!1)}}async function Pa(M){if(!uN("规则")){q.info("已取消删除");return}try{const ee=await Pi(`/api/db/user-rules?id=${M}`);ee!=null&&ee.success&&na()}catch{}}async function Ia(M){try{await tn("/api/db/user-rules",{id:M.id,enabled:!M.enabled}),na()}catch{}}const _n=g.useCallback(async()=>{rt(!0);try{const M=await Le("/api/db/vip-members?limit=500");if(M!=null&&M.success&&M.data){const ee=[...M.data].map((be,Ae)=>({...be,vipSort:typeof be.vipSort=="number"?be.vipSort:Ae+1}));ee.sort((be,Ae)=>(be.vipSort??999999)-(Ae.vipSort??999999)),Me(ee)}else M&&M.error&&q.error(M.error)}catch{q.error("加载超级个体列表失败")}finally{rt(!1)}},[]),[Lr,ra]=g.useState(!1),[oi,br]=g.useState(null),[Ps,Ra]=g.useState(""),[vr,Nr]=g.useState(!1),[Xi,Or]=g.useState(!1),[aa,ia]=g.useState(null),[li,ci]=g.useState(""),[is,Dr]=g.useState(!1),di=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],ui=M=>{br(M),Ra(M.vipRole||""),ra(!0)},jd=M=>{ia(M),ci((M.webhookUrl||"").trim()),Or(!0)},ul=async M=>{const ee=M.trim();if(oi){if(!ee){q.error("请选择或输入标签");return}Nr(!0);try{const be=await tn("/api/db/users",{id:oi.id,vipRole:ee});if(!(be!=null&&be.success)){q.error((be==null?void 0:be.error)||"更新超级个体标签失败");return}q.success("已更新超级个体标签"),ra(!1),br(null),await _n()}catch{q.error("更新超级个体标签失败")}finally{Nr(!1)}}},hl=async()=>{if(!aa)return;const M=li.trim();if(M&&!/^https?:\/\//i.test(M)){q.error("Webhook 地址需以 http/https 开头");return}Dr(!0);try{const ee=await tn("/api/db/vip-members/webhook",{userId:aa.id,webhookUrl:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"保存飞书群 Webhook 失败");return}q.success(M?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),Or(!1),ia(null),await _n()}catch{q.error("保存飞书群 Webhook 失败")}finally{Dr(!1)}},[hi,oa]=g.useState(!1),[La,fl]=g.useState(null),[cc,dc]=g.useState(""),[Zi,uc]=g.useState(!1),kd=M=>{fl(M),dc(M.vipSort!=null?String(M.vipSort):""),oa(!0)},hc=async()=>{if(!La)return;const M=Number(cc);if(!Number.isFinite(M)){q.error("请输入有效的数字序号");return}uc(!0);try{const ee=await tn("/api/db/users",{id:La.id,vipSort:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"更新排序序号失败");return}q.success("已更新排序序号"),oa(!1),fl(null),await _n()}catch{q.error("更新排序序号失败")}finally{uc(!1)}},pl=(M,ee)=>{M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",ee),kt(ee)},fc=(M,ee)=>{M.preventDefault(),$e!==ee&&H(ee)},ml=()=>{kt(null),H(null)},pc=async(M,ee)=>{M.preventDefault();const be=M.dataTransfer.getData("text/plain")||$t;if(kt(null),H(null),!be||be===ee)return;const Ae=Ne.find(He=>He.id===be),Ge=Ne.find(He=>He.id===ee);if(!Ae||!Ge)return;const Je=Ae.vipSort??Ne.findIndex(He=>He.id===be)+1,Vt=Ge.vipSort??Ne.findIndex(He=>He.id===ee)+1;Me(He=>{const en=[...He],Is=en.findIndex(xc=>xc.id===be),_r=en.findIndex(xc=>xc.id===ee);if(Is===-1||_r===-1)return He;const to=[...en],[Id,Rd]=[to[Is],to[_r]];return to[Is]={...Rd,vipSort:Je},to[_r]={...Id,vipSort:Vt},to});try{const[He,en]=await Promise.all([tn("/api/db/users",{id:be,vipSort:Vt}),tn("/api/db/users",{id:ee,vipSort:Je})]);if(!(He!=null&&He.success)||!(en!=null&&en.success)){q.error((He==null?void 0:He.error)||(en==null?void 0:en.error)||"更新排序失败"),await _n();return}q.success("已更新排序"),await _n()}catch{q.error("更新排序失败"),await _n()}},xl=g.useCallback(async()=>{yt(!0);try{const M=await Le("/api/db/users/journey-stats");M!=null&&M.success&&M.stats&&vt(M.stats)}catch{}finally{yt(!1)}},[]),E=g.useCallback(async M=>{Pt(M),Ms(!0);try{const ee=await Le(`/api/db/users/journey-users?stage=${M}&limit=50`);ee!=null&&ee.success&&ee.users&&kn(ee.users)}catch{}finally{Ms(!1)}},[]),B=g.useCallback(async(M,ee)=>{ja(M),ti(ee),Qr(!0);try{const be=await Le(`/api/db/users/tracks?userId=${M}&limit=50`);be!=null&&be.success&&be.tracks&&Pr(be.tracks)}catch{}finally{Qr(!1)}},[]),[ue,ke]=g.useState(!1),Ke=async()=>{ke(!0);try{const M=await bt("/api/admin/shensheshou/batch-enrich",{limit:20});M!=null&&M.success?(q.success(`批量补全完成:${M.enriched} 人已补全,${M.skipped} 人跳过`),nr()):q.error((M==null?void 0:M.error)||"批量补全失败")}catch{q.error("批量补全请求失败")}finally{ke(!1)}},gt=M=>{const ee=[M.phone,M.nickname,M.avatar,M.wechatId,M.mbti,M.industry,M.region,M.position],be=ee.filter(Ae=>Ae!=null&&Ae!=="").length;return Math.round(be/ee.length*100)},{leadsRows:at,leadsRawCount:$n,leadsDeduped:Yn}=g.useMemo(()=>{const M=He=>(He||"").replace(/\D/g,"")||"",ee=He=>{const en=M(He.phone);if(en)return`phone:${en}`;const Is=(He.userId||"").trim();if(Is)return`user:${Is}`;const _r=(He.wechatId||"").trim();return _r?`wechat:${_r}`:`row:${He.id}`},be=Xr.trim().toLowerCase();let Ae=pr;be&&(Ae=pr.filter(He=>[He.userNickname,He.name,He.phone,He.wechatId,He.personName,He.source,He.planApiKey].filter(Boolean).join(" ").toLowerCase().includes(be)));const Ge=[...Ae].sort((He,en)=>{const Is=He.createdAt?new Date(He.createdAt).getTime():0;return(en.createdAt?new Date(en.createdAt).getTime():0)-Is});if(!Ca)return{leadsRows:Ge,leadsRawCount:Ae.length,leadsDeduped:0};const Je=new Set,Vt=[];for(const He of Ge){const en=ee(He);Je.has(en)||(Je.add(en),Vt.push(He))}return{leadsRows:Vt,leadsRawCount:Ae.length,leadsDeduped:Ae.length-Vt.length}},[pr,Xr,Ca]);g.useEffect(()=>{const M=at.map(Ae=>Ae.id),ee=M.filter(Ae=>vs.includes(Ae)).length,be=si.current;be&&(be.indeterminate=ee>0&&eebe.id),ee=M.length>0&&M.every(be=>vs.includes(be));er(ee?be=>be.filter(Ae=>!M.includes(Ae)):be=>[...new Set([...be,...M])])}function sr(M){er(ee=>ee.includes(M)?ee.filter(be=>be!==M):[...ee,M])}async function Un(){if(vs.length===0){q.info("请先勾选要删除的记录");return}const M=vs.length;if(!confirm(`确定批量删除选中的 ${M} 条获客记录?删除后不可恢复。`))return;const ee=500;xr(!0);try{let be=0;for(let Ae=0;Ae{const ee=M||"";return ee==="success"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"已推送(存客宝已接收)"}):ee==="pending_verify"?s.jsx(Be,{className:"bg-sky-500/20 text-sky-300 border-0 text-xs",children:"待通过 / 处理中"}):ee==="expired"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-300 border-0 text-xs",children:"已过期"}):ee==="failed"?s.jsx(Be,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):ee==="pending"?s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"}):ee?s.jsx(Be,{className:"bg-violet-500/20 text-violet-300 border-0 text-xs",title:ee,children:ee}):s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"})},Sd=g.useMemo(()=>{const M=new Map;for(const ee of at){if(ee.pushStatus!=="failed")continue;const be=(ee.ckbError||"未知错误").trim()||"未知错误";M.set(be,(M.get(be)||0)+1)}return Array.from(M.entries()).map(([ee,be])=>({reason:ee,count:be})).sort((ee,be)=>be.count-ee.count)},[at]);async function Cd(){const M=at.filter(Je=>Je.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}const ee=Sd.slice(0,8).map(Je=>`- ${Je.reason}:${Je.count} 条`).join(` +`;return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function y8(){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 Le("/api/admin/mbti-avatars");x!=null&&x.avatars?e(x.avatars):e({})}catch{q.error("加载 MBTI 头像配置失败")}finally{r(!1)}},[]);g.useEffect(()=>{u()},[u]);const h=async()=>{i(!0);try{const x=await bt("/api/admin/mbti-avatars",{avatars:t});if(!x||x.success===!1){q.error((x==null?void 0:x.error)||"保存失败");return}q.success("已保存,后台与小程序默认头像同步生效"),u()}catch{q.error("保存失败")}finally{i(!1)}},f=x=>{const b=lN(x);e(N=>({...N,[x]:b})),q.success(`${x} 已生成`)},m=()=>{c(!0);try{const x={...t};oN.forEach(b=>{x[b]=lN(b)}),e(x),q.success("16 型头像已生成(仅人物)")}finally{c(!1)}};return n?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[s.jsx(Ve,{className:"w-5 h-5 mr-2 animate-spin text-[#38bdac]"}),"加载配置…"]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-[#38bdac]/25 shadow-xl",children:[s.jsxs(dt,{className:"pb-2",children:[s.jsxs(ut,{className:"text-white flex items-center gap-2 text-lg",children:[s.jsx(SA,{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(G,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396]",onClick:m,disabled:o,children:[s.jsx(GA,{className:"w-3.5 h-3.5 mr-1"}),o?"生成中…":"一键生成16头像"]}),s.jsxs(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-300",onClick:u,children:[s.jsx(Ve,{className:"w-3.5 h-3.5 mr-1"}),"重新加载"]}),s.jsxs(G,{type:"button",size:"sm",className:"bg-emerald-600 hover:bg-emerald-500",onClick:h,disabled:a,children:[s.jsx(Tn,{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:oN.map(x=>{const b=t[x]??"",N=M2[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(Be,{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(oe,{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(G,{type:"button",size:"sm",variant:"outline",className:"h-7 text-[11px] border-[#38bdac]/40 text-[#38bdac]",onClick:()=>f(x),children:"生成这张"}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-[11px] text-gray-400",onClick:()=>e(w=>({...w,[x]:""})),children:"清空"})]})]},x)})})]})}const cN=[{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:"用户状态"}],dN=[{value:"popup",label:"弹窗提示",desc:"在小程序内弹窗引导用户完成下一步"},{value:"navigate",label:"跳转页面",desc:"引导用户跳转到指定页面"},{value:"webhook",label:"推送飞书群",desc:"触发后推送消息到飞书群Webhook"},{value:"tag",label:"自动打标签",desc:"触发后自动给用户打上指定标签"}];function A2(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 b8(t){return{...t,triggerConditions:A2(t.triggerConditions)}}const v8=[{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:"待激活"}],Fc=[{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 uN(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function N8({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:ya(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 w8(t){const e=(t||"").trim();if(!e)return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function j8(){var eo,eh,Ed,Td,Md,Ad,Pd;const[t,e]=X0(),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=qa(N,300),k=n==="vip"?"vip":n==="complete"?"complete":"all",[T,C]=g.useState(k),[L,R]=g.useState(!0),[U,P]=g.useState(!1),[F,O]=g.useState(null),[Q,re]=g.useState(!1),[D,ne]=g.useState(!1),[le,me]=g.useState("desc");g.useEffect(()=>{n==="vip"?C("vip"):n==="complete"?C("complete"):n==="all"&&C("all")},[n]);const[I,Y]=g.useState(!1),[B,xe]=g.useState(null),[X,V]=g.useState(!1),[W,fe]=g.useState(!1),[he,de]=g.useState({referrals:[],stats:{}}),[_,J]=g.useState(!1),[$,Z]=g.useState(null),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState(null),[wt,jn]=g.useState(!1),[pt,At]=g.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[fn,Vn]=g.useState([]),[pn,qt]=g.useState(!1),[bn,Mn]=g.useState(!1),[Hn,as]=g.useState(null),[_t,vn]=g.useState({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),[Ne,Me]=g.useState([]),[We,rt]=g.useState(!1),[$t,St]=g.useState(null),[$e,H]=g.useState(null),[Qe,vt]=g.useState({}),[Ft,yt]=g.useState(!1),[ht,Pt]=g.useState(null),[Gt,kn]=g.useState([]),[Ts,Ms]=g.useState(!1),[Ki,ja]=g.useState(null),[ei,ti]=g.useState(""),[Ar,Pr]=g.useState([]),[Ir,Qr]=g.useState(!1),[Vs,Qs]=g.useState({}),[pr,Ys]=g.useState([]),[ka,ce]=g.useState(0),[ve,Rt]=g.useState(1),[Zt]=g.useState(10),[sn,is]=g.useState(!1),[Rr,Yr]=g.useState(null),[jt,Un]=g.useState(""),Xr=qa(jt,300),[Sa,mn]=g.useState(""),[Zr,ni]=g.useState(""),[mr,As]=g.useState(""),[Ca,qi]=g.useState(!1),[Xs,Zs]=g.useState({}),[Gi,bs]=g.useState(null),[il,Ji]=g.useState(null),[vs,er]=g.useState([]),[tr,xr]=g.useState(!1),si=g.useRef(null),[ea,ac]=g.useState(!1),[ol,ri]=g.useState(!1),[Qi,Ea]=g.useState("存客宝返回 data"),[ll,Ta]=g.useState(""),Nt=g.useCallback(async(M,ee)=>{is(!0),Yr(null);try{const be=new URLSearchParams({mode:"contact",page:String(ve),pageSize:String(Zt)}),Ae=M??Xr;Ae&&be.set("search",Ae);const Ge=ee??Sa;Ge&&be.set("source",Ge),Zr&&be.set("action",Zr),mr&&be.set("pushStatus",mr);const Je=await Le(`/api/db/ckb-leads?${be}`);if(Je!=null&&Je.success)Ys(Je.records||[]),ce(Je.total??0),Je.stats&&Zs(Je.stats);else{const Vt=(Je==null?void 0:Je.error)||"加载获客列表失败";Yr(Vt),q.error(Vt),Ys([]),ce(0)}}catch(be){const Ae=be instanceof Error?be.message:"网络错误";Yr(Ae),q.error("加载获客列表失败: "+Ae),Ys([]),ce(0)}finally{is(!1)}},[ve,Zt,Xr,Sa,Zr,mr]);g.useEffect(()=>{er([])},[Xr,Sa,Zr,mr]),g.useEffect(()=>{a==="leads"&&ni(i)},[a,i]);function Yi(M,ee){return{...M,...ee.pushStatus!==void 0?{pushStatus:ee.pushStatus}:{},...typeof ee.retryCount=="number"?{retryCount:ee.retryCount}:{},...typeof ee.ckbCode=="number"?{ckbCode:ee.ckbCode}:{},...ee.ckbMessage!==void 0?{ckbMessage:ee.ckbMessage}:{},...ee.ckbData!==void 0?{ckbData:ee.ckbData}:{},...ee.ckbError!==void 0?{ckbError:ee.ckbError}:{},...ee.lastPushAt!==void 0?{lastPushAt:ee.lastPushAt??void 0}:{},...ee.nextRetryAt!==void 0?{nextRetryAt:ee.nextRetryAt??void 0}:{}}}async function cl(M){if(M){bs(M);try{const ee=await bt("/api/db/ckb-leads/retry",{id:M});ee!=null&&ee.success?(q.success(ee.pushed?"重推成功":"已发起重推,请刷新查看状态"),ee.record&&Ys(be=>be.map(Ae=>Ae.id===M?Yi(Ae,ee.record):Ae))):q.error((ee==null?void 0:ee.error)||"重推失败")}catch(ee){q.error(ee instanceof Error?ee.message:"重推请求失败")}finally{bs(null)}}}async function ai(M){if(M&&confirm("确定删除该条获客记录?删除后不可恢复。")){Ji(M);try{const ee=await bt("/api/db/ckb-leads/delete",{id:M});ee!=null&&ee.success?q.success("已删除"):q.error((ee==null?void 0:ee.error)||"删除失败")}catch(ee){q.error(ee instanceof Error?ee.message:"删除请求失败")}finally{Ji(null),Nt()}}}async function ii(){const M=at.filter(Ae=>Ae.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}ac(!0);let ee=0;for(const Ae of M)try{const Ge=await bt("/api/db/ckb-leads/retry",{id:Ae.id});if(Ge!=null&&Ge.success&&Ge.pushed&&ee++,Ge!=null&&Ge.success&&Ge.record){const Je=Ge.record;Ys(Vt=>Vt.map(He=>He.id===Ae.id?Yi(He,Je):He))}}catch{}ac(!1);const be=M.length;q.success(`批量重推完成:成功 ${ee} / ${be}`)}function ic(){const M=at.filter(He=>He.pushStatus==="failed");if(M.length===0){q.info("当前筛选下无失败记录可导出");return}const ee=He=>`"${String(He??"").replace(/"/g,'""')}"`,Ae=[["ID","昵称","手机号","微信号","对应@人","计划Key","来源","推送状态","重试次数","失败原因","下次重试时间","创建时间"].join(",")];for(const He of M)Ae.push([ee(He.id),ee(He.userNickname||He.name||""),ee(He.phone||""),ee(He.wechatId||""),ee(He.personName||""),ee(He.planApiKey||""),ee(He.source||""),ee(He.pushStatus||""),ee(typeof He.retryCount=="number"?He.retryCount:""),ee(He.ckbError||""),ee(He.nextRetryAt?new Date(He.nextRetryAt).toLocaleString():""),ee(He.createdAt?new Date(He.createdAt).toLocaleString():"")].join(","));const Ge=new Blob(["\uFEFF"+Ae.join(` +`)],{type:"text/csv;charset=utf-8;"}),Je=URL.createObjectURL(Ge),Vt=document.createElement("a");Vt.href=Je,Vt.download=`获客失败清单-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,document.body.appendChild(Vt),Vt.click(),document.body.removeChild(Vt),URL.revokeObjectURL(Je),q.success(`已导出失败清单(${M.length} 条)`)}const Qn=g.useCallback(async()=>{try{const M=await Le("/api/admin/mbti-avatars"),ee=M!=null&&M.avatars&&typeof M.avatars=="object"?M.avatars:{};Qs(ee)}catch{Qs({})}},[]);g.useEffect(()=>{t.get("tab")==="leads"&&Nt()},[t.get("tab"),ve,Nt]),g.useEffect(()=>{if(a!=="leads")return;const M=window.setInterval(()=>{Nt()},3e4);return()=>window.clearInterval(M)},[a,Nt]),g.useEffect(()=>{Qn()},[Qn]);const Ma=g.useCallback((M,ee)=>{const be=(M||"").trim();if(be)return be;const Ae=(ee||"").trim().toUpperCase();return/^[EI][NS][FT][JP]$/.test(Ae)?(Vs[Ae]||"").trim():""},[Vs]),ta=g.useCallback(M=>{const ee=!!M.hasFullBook,be=Number(M.purchasedSectionCount||0);return ee?{tone:"vip",main:"已购全书",sub:be>0?`另购单章 ${be} 章`:"购买项:VIP / 全书"}:be>0?{tone:"paid",main:`已购 ${be} 章`,sub:"购买项:章节"}:{tone:"free",main:"未购买",sub:""}},[]),[Hs,Us]=g.useState(null),cn=g.useCallback(async()=>{try{const M=await Le("/api/admin/users/online-stats");M!=null&&M.success&&typeof M.onlineCount=="number"?Us(M.onlineCount):Us(0)}catch{Us(null)}},[]);g.useEffect(()=>{cn();const M=setInterval(cn,1e4);return()=>clearInterval(M)},[cn]);async function nr(M=!1){var ee;R(!0),M&&P(!0),O(null);try{if(Q){const be=new URLSearchParams({search:v,limit:String(x*5)}),Ae=await Le(`/api/db/users/rfm?${be}`);if(Ae!=null&&Ae.success){let Ge=Ae.users||[];le==="asc"&&(Ge=[...Ge].reverse());const Je=(f-1)*x;c(Ge.slice(Je,Je+x)),h(((ee=Ae.users)==null?void 0:ee.length)??0),Ge.length===0&&(re(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else re(!1),O((Ae==null?void 0:Ae.error)||"RFM 加载失败,已切回普通模式")}else{const be=new URLSearchParams({page:String(f),pageSize:String(x),search:v,...T==="vip"&&{vip:"true"},...T==="complete"&&{pool:"complete"}}),Ae=await Le(`/api/db/users?${be}`);Ae!=null&&Ae.success?(c(Ae.users||[]),h(Ae.total??0)):O((Ae==null?void 0:Ae.error)||"加载失败")}}catch(be){console.error("Load users error:",be),O("网络错误")}finally{R(!1),M&&P(!1)}}g.useEffect(()=>{m(1)},[v,T,Q]),g.useEffect(()=>{nr()},[f,x,v,T,Q,le]);const gr=Math.ceil(u/x)||1,yr=()=>{Q?le==="desc"?me("asc"):(re(!1),me("desc")):(re(!0),me("desc"))},oc=M=>({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"})[M||""]||"bg-gray-500/20 text-gray-400";async function lc(M){var ee;if(!uN("用户")){q.info("已取消删除");return}try{const be=await Pi(`/api/db/users?id=${encodeURIComponent(M)}`);be!=null&&be.success?(q.success("已删除"),nr()):q.error("删除失败: "+((be==null?void 0:be.error)||"未知错误"))}catch(be){const Ae=be,Ge=((ee=Ae==null?void 0:Ae.data)==null?void 0:ee.error)||(Ae==null?void 0:Ae.message)||"网络错误";q.error("删除失败: "+Ge)}}const Aa=M=>{xe(M),At({phone:M.phone||"",nickname:M.nickname||"",password:"",isAdmin:!!(M.isAdmin??!1),hasFullBook:!!(M.hasFullBook??!1)}),Y(!0)},wd=()=>{xe(null),At({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),Y(!0)};async function dl(){if(!pt.phone||!pt.nickname){q.error("请填写手机号和昵称");return}V(!0);try{if(B){const M=await tn("/api/db/users",{id:B.id,phone:pt.phone||void 0,nickname:pt.nickname,isAdmin:pt.isAdmin,hasFullBook:pt.hasFullBook,...pt.password&&{password:pt.password}});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/users",{phone:pt.phone,nickname:pt.nickname,password:pt.password,isAdmin:pt.isAdmin});if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Y(!1),nr()}catch{q.error("保存失败")}finally{V(!1)}}async function Ns(M){Z(M),fe(!0),J(!0);try{const ee=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(M.id)}`);ee!=null&&ee.success?de({referrals:ee.referrals||[],stats:ee.stats||{}}):de({referrals:[],stats:{}})}catch{de({referrals:[],stats:{}})}finally{J(!1)}}const na=g.useCallback(async()=>{qt(!0);try{const M=await Le("/api/db/user-rules");M!=null&&M.success&&Vn((M.rules||[]).map(ee=>b8(ee)))}catch{}finally{qt(!1)}},[]);async function sa(){if(!_t.title){q.error("请填写规则标题");return}V(!0);try{if(Hn){const M=await tn("/api/db/user-rules",{id:Hn.id,..._t});if(!(M!=null&&M.success)){q.error("更新失败: "+((M==null?void 0:M.error)||""));return}}else{const M=await bt("/api/db/user-rules",_t);if(!(M!=null&&M.success)){q.error("创建失败: "+((M==null?void 0:M.error)||""));return}}Mn(!1),na()}catch{q.error("保存失败")}finally{V(!1)}}async function Pa(M){if(!uN("规则")){q.info("已取消删除");return}try{const ee=await Pi(`/api/db/user-rules?id=${M}`);ee!=null&&ee.success&&na()}catch{}}async function Ia(M){try{await tn("/api/db/user-rules",{id:M.id,enabled:!M.enabled}),na()}catch{}}const _n=g.useCallback(async()=>{rt(!0);try{const M=await Le("/api/db/vip-members?limit=500");if(M!=null&&M.success&&M.data){const ee=[...M.data].map((be,Ae)=>({...be,vipSort:typeof be.vipSort=="number"?be.vipSort:Ae+1}));ee.sort((be,Ae)=>(be.vipSort??999999)-(Ae.vipSort??999999)),Me(ee)}else M&&M.error&&q.error(M.error)}catch{q.error("加载超级个体列表失败")}finally{rt(!1)}},[]),[Lr,ra]=g.useState(!1),[oi,br]=g.useState(null),[Ps,Ra]=g.useState(""),[vr,Nr]=g.useState(!1),[Xi,Or]=g.useState(!1),[aa,ia]=g.useState(null),[li,ci]=g.useState(""),[ls,Dr]=g.useState(!1),di=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],ui=M=>{br(M),Ra(M.vipRole||""),ra(!0)},jd=M=>{ia(M),ci((M.webhookUrl||"").trim()),Or(!0)},ul=async M=>{const ee=M.trim();if(oi){if(!ee){q.error("请选择或输入标签");return}Nr(!0);try{const be=await tn("/api/db/users",{id:oi.id,vipRole:ee});if(!(be!=null&&be.success)){q.error((be==null?void 0:be.error)||"更新超级个体标签失败");return}q.success("已更新超级个体标签"),ra(!1),br(null),await _n()}catch{q.error("更新超级个体标签失败")}finally{Nr(!1)}}},hl=async()=>{if(!aa)return;const M=li.trim();if(M&&!/^https?:\/\//i.test(M)){q.error("Webhook 地址需以 http/https 开头");return}Dr(!0);try{const ee=await tn("/api/db/vip-members/webhook",{userId:aa.id,webhookUrl:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"保存飞书群 Webhook 失败");return}q.success(M?"已保存该超级个体的飞书群 Webhook":"已清空该超级个体的飞书群 Webhook"),Or(!1),ia(null),await _n()}catch{q.error("保存飞书群 Webhook 失败")}finally{Dr(!1)}},[hi,oa]=g.useState(!1),[La,fl]=g.useState(null),[cc,dc]=g.useState(""),[Zi,uc]=g.useState(!1),kd=M=>{fl(M),dc(M.vipSort!=null?String(M.vipSort):""),oa(!0)},hc=async()=>{if(!La)return;const M=Number(cc);if(!Number.isFinite(M)){q.error("请输入有效的数字序号");return}uc(!0);try{const ee=await tn("/api/db/users",{id:La.id,vipSort:M});if(!(ee!=null&&ee.success)){q.error((ee==null?void 0:ee.error)||"更新排序序号失败");return}q.success("已更新排序序号"),oa(!1),fl(null),await _n()}catch{q.error("更新排序序号失败")}finally{uc(!1)}},pl=(M,ee)=>{M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",ee),St(ee)},fc=(M,ee)=>{M.preventDefault(),$e!==ee&&H(ee)},ml=()=>{St(null),H(null)},pc=async(M,ee)=>{M.preventDefault();const be=M.dataTransfer.getData("text/plain")||$t;if(St(null),H(null),!be||be===ee)return;const Ae=Ne.find(He=>He.id===be),Ge=Ne.find(He=>He.id===ee);if(!Ae||!Ge)return;const Je=Ae.vipSort??Ne.findIndex(He=>He.id===be)+1,Vt=Ge.vipSort??Ne.findIndex(He=>He.id===ee)+1;Me(He=>{const en=[...He],Is=en.findIndex(xc=>xc.id===be),_r=en.findIndex(xc=>xc.id===ee);if(Is===-1||_r===-1)return He;const to=[...en],[Id,Rd]=[to[Is],to[_r]];return to[Is]={...Rd,vipSort:Je},to[_r]={...Id,vipSort:Vt},to});try{const[He,en]=await Promise.all([tn("/api/db/users",{id:be,vipSort:Vt}),tn("/api/db/users",{id:ee,vipSort:Je})]);if(!(He!=null&&He.success)||!(en!=null&&en.success)){q.error((He==null?void 0:He.error)||(en==null?void 0:en.error)||"更新排序失败"),await _n();return}q.success("已更新排序"),await _n()}catch{q.error("更新排序失败"),await _n()}},xl=g.useCallback(async()=>{yt(!0);try{const M=await Le("/api/db/users/journey-stats");M!=null&&M.success&&M.stats&&vt(M.stats)}catch{}finally{yt(!1)}},[]),E=g.useCallback(async M=>{Pt(M),Ms(!0);try{const ee=await Le(`/api/db/users/journey-users?stage=${M}&limit=50`);ee!=null&&ee.success&&ee.users&&kn(ee.users)}catch{}finally{Ms(!1)}},[]),z=g.useCallback(async(M,ee)=>{ja(M),ti(ee),Qr(!0);try{const be=await Le(`/api/db/users/tracks?userId=${M}&limit=50`);be!=null&&be.success&&be.tracks&&Pr(be.tracks)}catch{}finally{Qr(!1)}},[]),[ue,ke]=g.useState(!1),Ke=async()=>{ke(!0);try{const M=await bt("/api/admin/shensheshou/batch-enrich",{limit:20});M!=null&&M.success?(q.success(`批量补全完成:${M.enriched} 人已补全,${M.skipped} 人跳过`),nr()):q.error((M==null?void 0:M.error)||"批量补全失败")}catch{q.error("批量补全请求失败")}finally{ke(!1)}},gt=M=>{const ee=[M.phone,M.nickname,M.avatar,M.wechatId,M.mbti,M.industry,M.region,M.position],be=ee.filter(Ae=>Ae!=null&&Ae!=="").length;return Math.round(be/ee.length*100)},{leadsRows:at,leadsRawCount:$n,leadsDeduped:Yn}=g.useMemo(()=>{const M=He=>(He||"").replace(/\D/g,"")||"",ee=He=>{const en=M(He.phone);if(en)return`phone:${en}`;const Is=(He.userId||"").trim();if(Is)return`user:${Is}`;const _r=(He.wechatId||"").trim();return _r?`wechat:${_r}`:`row:${He.id}`},be=Xr.trim().toLowerCase();let Ae=pr;be&&(Ae=pr.filter(He=>[He.userNickname,He.name,He.phone,He.wechatId,He.personName,He.source,He.planApiKey].filter(Boolean).join(" ").toLowerCase().includes(be)));const Ge=[...Ae].sort((He,en)=>{const Is=He.createdAt?new Date(He.createdAt).getTime():0;return(en.createdAt?new Date(en.createdAt).getTime():0)-Is});if(!Ca)return{leadsRows:Ge,leadsRawCount:Ae.length,leadsDeduped:0};const Je=new Set,Vt=[];for(const He of Ge){const en=ee(He);Je.has(en)||(Je.add(en),Vt.push(He))}return{leadsRows:Vt,leadsRawCount:Ae.length,leadsDeduped:Ae.length-Vt.length}},[pr,Xr,Ca]);g.useEffect(()=>{const M=at.map(Ae=>Ae.id),ee=M.filter(Ae=>vs.includes(Ae)).length,be=si.current;be&&(be.indeterminate=ee>0&&eebe.id),ee=M.length>0&&M.every(be=>vs.includes(be));er(ee?be=>be.filter(Ae=>!M.includes(Ae)):be=>[...new Set([...be,...M])])}function sr(M){er(ee=>ee.includes(M)?ee.filter(be=>be!==M):[...ee,M])}async function Wn(){if(vs.length===0){q.info("请先勾选要删除的记录");return}const M=vs.length;if(!confirm(`确定批量删除选中的 ${M} 条获客记录?删除后不可恢复。`))return;const ee=500;xr(!0);try{let be=0;for(let Ae=0;Ae{const ee=M||"";return ee==="success"?s.jsx(Be,{className:"bg-emerald-500/20 text-emerald-300 border-0 text-xs",children:"已推送(存客宝已接收)"}):ee==="pending_verify"?s.jsx(Be,{className:"bg-sky-500/20 text-sky-300 border-0 text-xs",children:"待通过 / 处理中"}):ee==="expired"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-300 border-0 text-xs",children:"已过期"}):ee==="failed"?s.jsx(Be,{className:"bg-red-500/20 text-red-300 border-0 text-xs",children:"失败"}):ee==="pending"?s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"}):ee?s.jsx(Be,{className:"bg-violet-500/20 text-violet-300 border-0 text-xs",title:ee,children:ee}):s.jsx(Be,{className:"bg-amber-500/20 text-amber-300 border-0 text-xs",children:"待推送"})},Sd=g.useMemo(()=>{const M=new Map;for(const ee of at){if(ee.pushStatus!=="failed")continue;const be=(ee.ckbError||"未知错误").trim()||"未知错误";M.set(be,(M.get(be)||0)+1)}return Array.from(M.entries()).map(([ee,be])=>({reason:ee,count:be})).sort((ee,be)=>be.count-ee.count)},[at]);async function Cd(){const M=at.filter(Je=>Je.pushStatus==="failed");if(M.length===0){q.info("当前页无失败记录");return}const ee=Sd.slice(0,8).map(Je=>`- ${Je.reason}:${Je.count} 条`).join(` `),be=M.slice(0,30).map(Je=>Je.id).join(", "),Ae=M.slice(0,20).map(Je=>`#${Je.id} | ${Je.userNickname||Je.name||"-"} | 手机:${Je.phone||"-"} | 来源:${Je.source||"-"} | 重试:${Je.retryCount??0} | 错误:${Je.ckbError||"-"}`).join(` `),Ge=["【获客失败排障信息】",`时间:${new Date().toLocaleString()}`,`当前页失败总数:${M.length}`,"主要失败原因:",ee||"- 无",`最近失败记录ID(最多30条):${be||"无"}`,"","失败记录明细(最多20条):",Ae||"无"].join(` -`);try{await navigator.clipboard.writeText(Ge),q.success("已复制排障信息")}catch{q.error("复制失败,请检查浏览器剪贴板权限")}}return s.jsxs("div",{className:"p-8 w-full",children:[z&&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:z}),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," 位注册用户",Hs!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Hs," 人"]}),Q&&" · RFM 排序中"]})]}),s.jsx(De,{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:()=>ne(M=>!M),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":D,children:[s.jsx(Of,{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:D?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),D?s.jsx(Bg,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(Bi,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:yr,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:Q?le==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),D&&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:v8.map(({level:M,range:ee,label:be})=>s.jsxs(Be,{variant:"outline",className:`text-[10px] border-0 ${oc(M)}`,children:[M," ",ee," · ",be]},M))})]})]})})]}),s.jsxs(Wl,{value:a,onValueChange:M=>{const ee=new URLSearchParams(t);M==="users"?ee.delete("tab"):ee.set("tab",M),e(ee)},className:"w-full",children:[s.jsxs(Ko,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Ut,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Kn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Ut,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Nt(),children:[s.jsx(Qc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Ut,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:xl,children:[s.jsx(ma,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Ut,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:na,children:[s.jsx(Po,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Ut,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:_n,children:[s.jsx(Xc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Wt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(G,{variant:"outline",onClick:Ke,disabled:ue,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[ue?s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ho,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(G,{variant:"outline",onClick:()=>nr(!0),disabled:U,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${U?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:T,onChange:M=>{const ee=M.target.value;C(ee),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:Q,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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:N,onChange:M=>w(M.target.value)})]}),s.jsxs(G,{onClick:wd,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Qc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"用户信息"}),s.jsx(Se,{className:"text-gray-400",children:"绑定信息"}),s.jsx(Se,{className:"text-gray-400",children:"购买状态"}),s.jsx(Se,{className:"text-gray-400",children:"分销收益"}),s.jsxs(Se,{className:"text-gray-400 cursor-pointer select-none",onClick:yr,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Of,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),Q?le==="desc"?s.jsx(Bi,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Bg,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(_x,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),Q&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(Se,{className:"text-gray-400",children:"资料完善"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[o.map(M=>{var ee,be,Ae;return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var Vt;const Ge=Ma(M.avatar,M.mbti),Je=((Vt=M.nickname)==null?void 0:Vt.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>jn(!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:Ge?s.jsx("img",{src:Ge,className:"w-full h-full rounded-full object-cover",alt:"",onError:He=>{var _r;const en=He.target;if(en.style.display="none",en.nextElementSibling)return;const Is=document.createElement("span");Is.textContent=Je,(_r=en.parentElement)==null||_r.appendChild(Is)}}):Je})})(),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(M.id),we(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:M.nickname}),M.isAdmin&&s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),M.openId&&!((ee=M.id)!=null&&ee.startsWith("user_"))&&s.jsx(Be,{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:M.id,children:[(be=M.id)==null?void 0:be.slice(0,16),(((Ae=M.id)==null?void 0:Ae.length)??0)>16?"…":""]})]})]})}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[M.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:M.phone})]}),M.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:M.wechatId})]}),!M.phone&&!M.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(je,{children:(()=>{const Ge=ta(M);return Ge.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:Ge.sub})]}):Ge.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:Ge.sub})]}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:Ge.main})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(M.earnings||0)).toFixed(2)]}),parseFloat(String(M.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(M.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Ns(M),role:"button",tabIndex:0,onKeyDown:Ge=>Ge.key==="Enter"&&Ns(M),children:[s.jsx(Kn,{className:"w-3 h-3"})," 绑定",M.referralCount||0,"人"]})]})}),s.jsx(je,{children:M.rfmScore!=null&&M.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:M.rfmScore}),s.jsx(Be,{className:`border-0 text-xs ${oc(M.rfmLevel)}`,children:M.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(je,{children:(()=>{const Ge=gt(M),Je=Ge>=75?"text-green-400":Ge>=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 ${Ge>=75?"bg-green-500":Ge>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${Ge}%`}})}),s.jsxs("span",{className:`text-xs ${Je}`,children:[Ge,"%"]})]})})()}),s.jsx(je,{className:"text-gray-400",children:M.createdAt?new Date(M.createdAt).toLocaleDateString():"-"}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{Ue(M.id),we(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(Lf,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Aa(M),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>lc(M.id),title:"删除",children:s.jsx(ts,{className:"w-4 h-4"})})]})})]},M.id)}),o.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(xs,{page:f,totalPages:gr,total:u,pageSize:x,onPageChange:m,onPageSizeChange:M=>{b(M),m(1)}})]})})})]}),s.jsxs(Wt,{value:"leads",children:[Rr&&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:Rr}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Yr(null),"aria-label":"关闭",children:"×"})]}),!sn&&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:ka})]}),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:Xs.uniqueUsers??0})]}),(Xs.sourceStats&&Xs.sourceStats.length>0?Xs.sourceStats.slice(0,2):[]).map(M=>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:["来源:",M.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:M.cnt})]},M.source))]}),!sn&&Sd.length>0&&s.jsx(De,{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(G,{type:"button",variant:"outline",onClick:Cd,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:Sd.slice(0,8).map(M=>s.jsxs(Be,{className:"bg-red-500/15 text-red-200 border border-red-600/40",children:[M.reason," · ",M.count]},M.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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{placeholder:"搜索昵称/手机/微信/@人/来源/类型…",value:Tt,onChange:M=>Jn(M.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),Xs.sourceStats&&Xs.sourceStats.length>0&&s.jsxs("select",{value:Sa,onChange:M=>{mn(M.target.value),Rt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),Xs.sourceStats.map(M=>s.jsxs("option",{value:M.source,children:[M.source,"(",M.cnt,")"]},M.source))]}),s.jsxs("select",{value:Zr,onChange:M=>{const ee=M.target.value;ni(ee),Rt(1),e(be=>{const Ae=new URLSearchParams(be);return Ae.set("tab","leads"),ee?Ae.set("leadAction",ee):Ae.delete("leadAction"),Ae})},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:Ca,onChange:M=>qi(M.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"}),"去重展示"]}),s.jsxs("select",{value:mr,onChange:M=>{As(M.target.value),Rt(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(G,{type:"button",variant:"outline",onClick:()=>{As("failed"),Rt(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:["本页 ",$n," 条",Yn>0?` · 已合并 ${Yn} 条重复`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(G,{variant:"outline",onClick:ic,disabled:sn,className:"border-cyan-600/60 text-cyan-300 hover:bg-cyan-500/10 bg-transparent",children:"导出失败清单"}),s.jsxs(G,{variant:"outline",onClick:ii,disabled:ea||tr||sn,className:"border-amber-600/60 text-amber-300 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${ea?"animate-spin":""}`}),"重推本页失败项"]}),s.jsxs(G,{variant:"outline",onClick:()=>void Un(),disabled:tr||vs.length===0||sn,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ts,{className:`w-4 h-4 mr-2 ${tr?"animate-pulse":""}`}),tr?"删除中…":`批量删除(${vs.length})`]}),s.jsxs(G,{variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`})," 刷新"]})]})]}),!sn&&at.length>0&&s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["已选 ",s.jsx("span",{className:"text-[#38bdac]",children:vs.length})," 条 · 可翻页继续勾选 · 改搜索/筛选会清空选择",vs.length>0&&s.jsx("button",{type:"button",className:"ml-2 text-gray-400 hover:text-gray-200 underline",onClick:()=>er([]),children:"清空"})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:sn?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-10 text-center",children:s.jsx("input",{ref:si,type:"checkbox",checked:at.length>0&&at.every(M=>vs.includes(M.id)),onChange:Sn,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页(展示行)"})}),s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"微信号"}),s.jsx(Se,{className:"text-gray-400",children:"对应 @人"}),s.jsx(Se,{className:"text-gray-400",children:"获客计划(Key)"}),s.jsx(Se,{className:"text-gray-400",children:"推送状态"}),s.jsx(Se,{className:"text-gray-400",children:"时间"}),s.jsx(Se,{className:"text-gray-400",children:"重试"})]})}),s.jsxs(ms,{children:[at.map(M=>s.jsxs(xt,{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:vs.includes(M.id),onChange:()=>sr(M.id),disabled:tr,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(N8,{userId:M.userId,userAvatar:M.userAvatar,nickname:M.userNickname,name:M.name,onOpenDetail:ee=>{Ue(ee),we(!0)}})}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-300",children:M.wechatId||"-"}),s.jsx(je,{className:"text-[#38bdac]",children:M.personName||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:(()=>{const ee=(M.planApiKey||"").trim();if(!ee)return"-";const be=ee.length<=10?ee:`${ee.slice(0,6)}…${ee.slice(-4)}`;return s.jsx("button",{type:"button",className:"font-mono text-gray-400 hover:text-gray-200 underline decoration-dotted",title:ee,onClick:async()=>{try{await navigator.clipboard.writeText(ee),q.success("已复制计划Key")}catch{q.error("复制失败,请手动复制")}},children:be})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[mc(M.pushStatus),(typeof M.ckbCode=="number"||(M.ckbMessage||"").trim())&&s.jsx("p",{className:"text-[11px] text-gray-500 max-w-[260px] truncate",title:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?`message=${String(M.ckbMessage).trim()}`:"",(M.ckbData||"").trim()?`data=${String(M.ckbData).trim()}`:""].filter(Boolean).join(" | "),children:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?String(M.ckbMessage).trim():""].filter(Boolean).join(" · ")}),!!(M.ckbData||"").trim()&&s.jsx("button",{type:"button",className:"text-[11px] text-sky-300/90 hover:text-sky-200 underline decoration-dotted",onClick:()=>{const ee=String(M.ckbData||"").trim();Ea(`存客宝返回 data(#${M.id})`),Ta(w8(ee)),ri(!0)},children:"查看 data"}),!!M.ckbError&&s.jsx("p",{className:"text-[11px] text-red-300 max-w-[220px] truncate",title:M.ckbError,children:M.ckbError})]})}),s.jsx(je,{className:"text-gray-400 whitespace-nowrap",children:M.createdAt?new Date(M.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 M.retryCount=="number"?`第 ${M.retryCount} 次`:"-"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||Gi===M.id||il===M.id,onClick:()=>cl(M.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(Ve,{className:`w-3 h-3 mr-1 ${Gi===M.id?"animate-spin":""}`}),"重推"]}),s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||il===M.id||Gi===M.id,onClick:()=>ai(M.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(ts,{className:`w-3 h-3 mr-1 ${il===M.id?"animate-pulse":""}`}),"删除"]})]})]})})]},M.id)),at.length===0&&s.jsx(xt,{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(Qc,{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:Xr.trim()||Sa?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(xs,{page:ve,totalPages:Math.ceil(ka/Zt)||1,total:ka,pageSize:Zt,onPageChange:Rt,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Wt,{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(G,{variant:"outline",onClick:xl,disabled:Ft,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Ft?"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:Fc.map((M,ee)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${M.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${ht===M.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>E(M.id),title:`点击查看「${M.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:M.icon}),s.jsx("div",{className:`text-xs font-medium ${M.color.split(" ").find(be=>be.startsWith("text-"))}`,children:M.label}),Qe[M.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[M.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:ee+1})]}),ees.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:M.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:M.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",M.next]})]})]},M.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(ur,{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:"实时更新"})]}),Ft?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Qe).length>0?s.jsx("div",{className:"space-y-2",children:(()=>{const M=Fc.reduce((ee,be)=>ee+(Qe[be.id]||0),0);return Fc.map(ee=>{const be=Qe[ee.id]||0,Ae=M>0?Math.round(be/M*100):0,Ge=be>0?Math.max(Ae,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:[ee.icon," ",ee.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:`${Ge}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-14 text-right tabular-nums",children:be}),s.jsx("span",{className:"text-gray-600 text-[10px] w-8 text-right tabular-nums",children:M>0?`${Ae}%`:"—"})]},ee.id)})})()}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),ht&&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(Kn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(eo=Fc.find(M=>M.id===ht))==null?void 0:eo.icon," ",(eh=Fc.find(M=>M.id===ht))==null?void 0:eh.label," 阶段用户"]}),s.jsxs(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Gt.length," 人"]})]}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pt(null),className:"text-gray-400 hover:text-white",children:s.jsx(ns,{className:"w-4 h-4"})})]}),Ts?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Gt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(ms,{children:Gt.map(M=>s.jsxs(xt,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(je,{className:"text-white",children:M.nickname||"微信用户"}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(je,{className:"text-right",children:s.jsxs(G,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>B(M.id,M.nickname||"微信用户"),children:[s.jsx(Lf,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},M.id))})]})]}),s.jsx(Lt,{open:!!Ki,onOpenChange:M=>{M||ja(null)},children:s.jsxs(It,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(ma,{className:"w-5 h-5 text-[#38bdac]"}),ei," 的行为轨迹"]})}),Ir?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Ar.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"}),Ar.map((M,ee)=>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:M.actionLabel}),M.module&&s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:M.module})]}),(M.chapterTitle||M.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:M.chapterTitle||M.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[M.timeAgo," · ",M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):""]})]})]},M.id||ee))]})]})})]}),s.jsxs(Wt,{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(G,{variant:"outline",onClick:na,disabled:pn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${pn?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:()=>{rs(null),vn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),Mn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),pn?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):fn.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(ur,{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(G,{onClick:na,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ve,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:fn.map(M=>{var be;const ee=A2(M.triggerConditions);return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${M.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:["#",M.sort]}),s.jsx(an,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:M.title}),M.trigger&&s.jsx(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:M.trigger}),ee.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[ee.slice(0,3).map(Ae=>{const Ge=cN.find(Je=>Je.value===Ae);return s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(Ge==null?void 0:Ge.label)||Ae},Ae)}),ee.length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",ee.length-3]})]}),M.actionType&&M.actionType!=="popup"&&s.jsx(Be,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((be=dN.find(Ae=>Ae.value===M.actionType))==null?void 0:be.label)||M.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx(Kt,{checked:M.enabled,onCheckedChange:()=>Ia(M)}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{rs(M),vn({title:M.title,description:M.description,trigger:M.trigger,triggerConditions:ee,actionType:M.actionType||"popup",sort:M.sort,enabled:M.enabled}),Mn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pa(M.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]}),M.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:["(",M.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:M.description})]})]},M.id)})})]}),s.jsxs(Wt,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(G,{variant:"outline",onClick:_n,disabled:We,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{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(Ve,{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(Xc,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(Se,{className:"text-gray-400",children:"成员"}),s.jsx(Se,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(Se,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(Se,{className:"text-gray-400 w-36",children:"飞书群"}),s.jsx(Se,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),s.jsx(ms,{children:Ne.map((M,ee)=>{var Ge;const be=$t===M.id,Ae=$e===M.id;return s.jsxs(xt,{draggable:!0,onDragStart:Je=>pl(Je,M.id),onDragOver:Je=>fc(Je,M.id),onDrop:Je=>pc(Je,M.id),onDragEnd:ml,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${be?"opacity-60":""} ${Ae?"bg-[#38bdac]/10":""}`,children:[s.jsx(je,{className:"text-gray-300",children:ee+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Ma(M.avatar,M.mbti)?s.jsx("img",{src:Ma(M.avatar,M.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:Je=>{var He,en;Je.target.style.display="none";const Vt=document.createElement("div");Vt.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",Vt.textContent=((He=M.name)==null?void 0:He[0])||"创",(en=Je.target.parentElement)==null||en.appendChild(Vt)}}):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:((Ge=M.name)==null?void 0:Ge[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:M.name})})]})}),s.jsx(je,{className:"text-gray-300 whitespace-nowrap",children:M.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(je,{className:"text-center text-blue-400 text-xs font-mono",children:M.clickCount!=null?String(M.clickCount):"-"}),s.jsx(je,{className:"text-center text-green-400 text-xs font-mono",children:M.leadCount!=null?String(M.leadCount):"-"}),s.jsx(je,{className:"text-gray-300",children:M.vipSort??ee+1}),s.jsx(je,{className:"text-xs",children:M.webhookUrl?s.jsx("span",{className:"text-[#38bdac] truncate block max-w-[180px]",title:M.webhookUrl,children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"})}),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(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>ui(M),title:"设置超级个体标签",children:s.jsx(xu,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>jd(M),title:"编辑飞书群Webhook",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>kd(M),title:"设置排序序号",children:s.jsx(_x,{className:"w-3.5 h-3.5"})})]})})]},M.id)})})]})})})]})]}),s.jsx(Lt,{open:wt,onOpenChange:jn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(y8,{})]})}),s.jsx(Lt,{open:hi,onOpenChange:M=>{oa(M),M||fl(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(_x,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",La==null?void 0:La.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:cc,onChange:M=>dc(M.target.value)})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>oa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hc,disabled:Zi,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),Zi?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Lr,onOpenChange:M=>{ra(M),M||br(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Xc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",oi==null?void 0:oi.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:di.map(M=>s.jsx(G,{variant:Ps===M?"default":"outline",size:"sm",className:Ps===M?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Ra(M),children:M},M))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Ps,onChange:M=>Ra(M.target.value)})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>ra(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:()=>ul(Ps),disabled:vr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),vr?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Xi,onOpenChange:M=>{Or(M),M||ia(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",aa==null?void 0:aa.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:li,onChange:M=>ci(M.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交链接时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Or(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hl,disabled:is,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),is?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:I,onOpenChange:Y,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[F?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Qc,{className:"w-5 h-5 text-[#38bdac]"}),F?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:pt.phone,onChange:M=>At({...pt,phone:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:pt.nickname,onChange:M=>At({...pt,nickname:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:F?"新密码 (留空则不修改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:F?"留空则不修改":"请输入密码",value:pt.password,onChange:M=>At({...pt,password:M.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Kt,{checked:pt.isAdmin,onCheckedChange:M=>At({...pt,isAdmin:M})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"已购全书"}),s.jsx(Kt,{checked:pt.hasFullBook,onCheckedChange:M=>At({...pt,hasFullBook:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:dl,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:bn,onOpenChange:Mn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),Hn?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:_t.title,onChange:M=>vn({..._t,title:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则描述"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:_t.description,onChange:M=>vn({..._t,description:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(M=>{const ee=cN.filter(be=>be.group===M);return ee.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:M}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:ee.map(be=>{const Ae=(_t.triggerConditions||[]).includes(be.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${Ae?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const Ge=_t.triggerConditions||[],Je=Ae?Ge.filter(Vt=>Vt!==be.value):[...Ge,be.value];vn({..._t,triggerConditions:Je})},children:be.label},be.value)})})]},M)})}),(_t.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(_t.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"与小程序一致:注册、完成付款、update_avatar、update_nickname 等",value:_t.trigger,onChange:M=>vn({..._t,trigger:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:dN.map(M=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${_t.actionType===M.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>vn({..._t,actionType:M.value}),children:[s.jsx("span",{className:`text-xs font-medium ${_t.actionType===M.value?"text-[#38bdac]":"text-gray-300"}`,children:M.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:M.desc})]},M.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(te,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Kt,{checked:_t.enabled,onCheckedChange:M=>vn({..._t,enabled:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Mn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:sa,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:W,onOpenChange:fe,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Kn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",$==null?void 0:$.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:((Ed=he.stats)==null?void 0:Ed.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:((Td=he.stats)==null?void 0:Td.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:["¥",(((Md=he.stats)==null?void 0:Md.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:["¥",(((Ad=he.stats)==null?void 0:Ad.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(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Pd=he.referrals)==null?void 0:Pd.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(he.referrals??[]).map((M,ee)=>{var Ae;const be=M;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:((Ae=be.nickname)==null?void 0:Ae.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:be.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:be.phone||(be.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[be.status==="vip"&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),be.status==="paid"&&s.jsxs(Be,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",be.purchasedSections,"章"]}),be.status==="free"&&s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:be.createdAt?new Date(be.createdAt).toLocaleDateString():""})]})]},be.id||ee)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(nn,{children:s.jsx(G,{variant:"outline",onClick:()=>fe(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(py,{open:ae,onClose:()=>we(!1),userId:Fe,onUserUpdated:nr}),s.jsx(Lt,{open:ol,onOpenChange:ri,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700/60 text-white max-w-2xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:Qi})}),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:ll||"—"})}),s.jsxs(nn,{children:[s.jsx(G,{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(ll||""),q.success("已复制 data")}catch{q.error("复制失败,请手动复制")}},disabled:!ll,children:"复制 data"}),s.jsx(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2aa896] text-white",onClick:()=>ri(!1),children:"关闭"})]})]})})]})}function Ff(t,[e,n]){return Math.min(n,Math.max(e,t))}var P2=["PageUp","PageDown"],I2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gd="Slider",[Xg,k8,S8]=dy(gd),[L2]=Zo(gd,[S8]),[C8,Up]=L2(gd),O2=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),C=o==="horizontal"?E8:T8,[L=[],R]=Hl({prop:f,defaultProp:h,onChange:re=>{var ne;(ne=[...v.current][k.current])==null||ne.focus(),m(re)}}),U=g.useRef(L);function P(re){const D=R8(L,re);Q(re,D)}function z(re){Q(re,k.current)}function O(){const re=U.current[k.current];L[k.current]!==re&&x(L)}function Q(re,D,{commit:ne}={commit:!1}){const le=_8(i),me=$8(Math.round((re-r)/i)*i+r,le),I=Ff(me,[r,a]);R((Y=[])=>{const F=P8(Y,I,D);if(D8(F,u*i)){k.current=F.indexOf(I);const xe=String(F)!==String(Y);return xe&&ne&&x(F),xe?F:Y}else return Y})}return s.jsx(C8,{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(Xg.Provider,{scope:t.__scopeSlider,children:s.jsx(Xg.Slot,{scope:t.__scopeSlider,children:s.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:jt(w.onPointerDown,()=>{c||(U.current=L)}),min:r,max:a,inverted:b,onSlideStart:c?void 0:P,onSlideMove:c?void 0:z,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&Q(r,0,{commit:!0}),onEndKeyDown:()=>!c&&Q(a,L.length-1,{commit:!0}),onStepKeyDown:({event:re,direction:D})=>{if(!c){const me=P2.includes(re.key)||re.shiftKey&&I2.includes(re.key)?10:1,I=k.current,Y=L[I],F=i*me*D;Q(Y+F,I,{commit:!0})}}})})})})});O2.displayName=gd;var[D2,_2]=L2(gd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),E8=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=Xt(e,C=>x(C)),N=g.useRef(void 0),w=Bp(a),v=w==="ltr",k=v&&!i||!v&&i;function T(C){const L=N.current||m.getBoundingClientRect(),R=[0,L.width],P=my(R,k?[n,r]:[r,n]);return N.current=L,P(C-L.left)}return s.jsx(D2,{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:C=>{const L=T(C.clientX);o==null||o(L)},onSlideMove:C=>{const L=T(C.clientX);c==null||c(L)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:C=>{const R=R2[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:R?-1:1})}})})}),T8=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=Xt(e,f),x=g.useRef(void 0),b=!a;function N(w){const v=x.current||f.current.getBoundingClientRect(),k=[0,v.height],C=my(k,b?[r,n]:[n,r]);return x.current=v,C(w-v.top)}return s.jsx(D2,{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=R2[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=Up(gd,n);return s.jsx(Et.span,{...h,ref:e,onKeyDown:jt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):P2.concat(I2).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))})})}),z2="SliderTrack",F2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(z2,n);return s.jsx(Et.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});F2.displayName=z2;var Zg="SliderRange",B2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(Zg,n),i=_2(Zg,n),o=g.useRef(null),c=Xt(e,o),u=a.values.length,h=a.values.map(x=>U2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(Et.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});B2.displayName=Zg;var e0="SliderThumb",V2=g.forwardRef((t,e)=>{const n=k8(t.__scopeSlider),[r,a]=g.useState(null),i=Xt(e,c=>a(c)),o=g.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(M8,{...t,ref:i,index:o})}),M8=g.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=Up(e0,n),c=_2(e0,n),[u,h]=g.useState(null),f=Xt(e,T=>h(T)),m=u?o.form||!!u.closest("form"):!0,x=fy(u),b=o.values[r],N=b===void 0?0:U2(b,o.min,o.max),w=I8(r,o.values.length),v=x==null?void 0:x[c.size],k=v?L8(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(Xg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(Et.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(H2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});V2.displayName=e0;var A8="RadioBubbleInput",H2=g.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=g.useRef(null),i=Xt(a,r),o=hy(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(Et.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});H2.displayName=A8;function P8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function U2(t,e,n){const i=100/(n-e)*(t-e);return Ff(i,[0,100])}function I8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function R8(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 L8(t,e,n){const r=t/2,i=my([0,50],[0,r]);return(r-i(e)*n)*n}function O8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function D8(t,e){if(e>0){const n=O8(t);return Math.min(...n)>=e}return!0}function my(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 _8(t){return(String(t).split(".")[1]||"").length}function $8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var z8=O2,F8=F2,B8=B2,V8=V2;function H8({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(z8,{defaultValue:e,value:n,min:r,max:a,className:zt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(F8,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(B8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(V8,{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 U8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function W2(t){const e=!!(t!=null&&t.embedded),[n,r]=g.useState(U8),[a,i]=g.useState(!0),[o,c]=g.useState(!1);g.useEffect(()=>{Le("/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 bt("/api/admin/referral-settings",f);if(!m||m.success===!1){q.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}q.success(`✅ 分销配置已保存成功! +`);try{await navigator.clipboard.writeText(Ge),q.success("已复制排障信息")}catch{q.error("复制失败,请检查浏览器剪贴板权限")}}return s.jsxs("div",{className:"p-8 w-full",children:[F&&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:F}),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," 位注册用户",Hs!==null&&s.jsxs("span",{className:"text-[#38bdac] ml-1",children:["· 在线 ",Hs," 人"]}),Q&&" · RFM 排序中"]})]}),s.jsx(De,{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:()=>ne(M=>!M),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":D,children:[s.jsx(Of,{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:D?"RFM · Are you good(用户价值分层)":"RFM · 点击展开说明"})]}),D?s.jsx(Bg,{className:"w-4 h-4 text-gray-400 shrink-0"}):s.jsx(Bi,{className:"w-4 h-4 text-gray-400 shrink-0"})]}),s.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:yr,className:"border-[#38bdac]/50 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent shrink-0",children:Q?le==="desc"?"RFM 降序":"RFM 升序":"按 RFM 排序"})]}),D&&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:v8.map(({level:M,range:ee,label:be})=>s.jsxs(Be,{variant:"outline",className:`text-[10px] border-0 ${oc(M)}`,children:[M," ",ee," · ",be]},M))})]})]})})]}),s.jsxs(Wl,{value:a,onValueChange:M=>{const ee=new URLSearchParams(t);M==="users"?ee.delete("tab"):ee.set("tab",M),e(ee)},className:"w-full",children:[s.jsxs(Ko,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Ut,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(qn,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Ut,{value:"leads",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:()=>Nt(),children:[s.jsx(Qc,{className:"w-4 h-4"})," 获客列表"]}),s.jsxs(Ut,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:xl,children:[s.jsx(ma,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Ut,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:na,children:[s.jsx(Po,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Ut,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:_n,children:[s.jsx(Xc,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Wt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(G,{variant:"outline",onClick:Ke,disabled:ue,className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10 bg-transparent",title:"批量调用神射手补全有手机号用户的资料",children:[ue?s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ho,{className:"w-4 h-4 mr-2"}),"批量补全"]}),s.jsxs(G,{variant:"outline",onClick:()=>nr(!0),disabled:U,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${U?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:T,onChange:M=>{const ee=M.target.value;C(ee),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:Q,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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:N,onChange:M=>w(M.target.value)})]}),s.jsxs(G,{onClick:wd,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Qc,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"用户信息"}),s.jsx(Se,{className:"text-gray-400",children:"绑定信息"}),s.jsx(Se,{className:"text-gray-400",children:"购买状态"}),s.jsx(Se,{className:"text-gray-400",children:"分销收益"}),s.jsxs(Se,{className:"text-gray-400 cursor-pointer select-none",onClick:yr,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Of,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),Q?le==="desc"?s.jsx(Bi,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Bg,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(_x,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),Q&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(Se,{className:"text-gray-400",children:"资料完善"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[o.map(M=>{var ee,be,Ae;return s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{var Vt;const Ge=Ma(M.avatar,M.mbti),Je=((Vt=M.nickname)==null?void 0:Vt.charAt(0))||"?";return s.jsx("button",{type:"button",title:"点击管理 MBTI 默认头像库",onClick:()=>jn(!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:Ge?s.jsx("img",{src:Ge,className:"w-full h-full rounded-full object-cover",alt:"",onError:He=>{var _r;const en=He.target;if(en.style.display="none",en.nextElementSibling)return;const Is=document.createElement("span");Is.textContent=Je,(_r=en.parentElement)==null||_r.appendChild(Is)}}):Je})})(),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(M.id),we(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[120px]",children:M.nickname}),M.isAdmin&&s.jsx(Be,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),M.openId&&!((ee=M.id)!=null&&ee.startsWith("user_"))&&s.jsx(Be,{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:M.id,children:[(be=M.id)==null?void 0:be.slice(0,16),(((Ae=M.id)==null?void 0:Ae.length)??0)>16?"…":""]})]})]})}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[M.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:M.phone})]}),M.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:M.wechatId})]}),!M.phone&&!M.wechatId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(je,{children:(()=>{const Ge=ta(M);return Ge.tone==="vip"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-amber-300/80",children:Ge.sub})]}):Ge.tone==="paid"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:Ge.main}),Ge.sub&&s.jsx("p",{className:"text-[11px] text-blue-300/80",children:Ge.sub})]}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:Ge.main})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(M.earnings||0)).toFixed(2)]}),parseFloat(String(M.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(M.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Ns(M),role:"button",tabIndex:0,onKeyDown:Ge=>Ge.key==="Enter"&&Ns(M),children:[s.jsx(qn,{className:"w-3 h-3"})," 绑定",M.referralCount||0,"人"]})]})}),s.jsx(je,{children:M.rfmScore!=null&&M.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:M.rfmScore}),s.jsx(Be,{className:`border-0 text-xs ${oc(M.rfmLevel)}`,children:M.rfmLevel})]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"无订单"})}),s.jsx(je,{children:(()=>{const Ge=gt(M),Je=Ge>=75?"text-green-400":Ge>=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 ${Ge>=75?"bg-green-500":Ge>=50?"bg-yellow-500":"bg-gray-500"}`,style:{width:`${Ge}%`}})}),s.jsxs("span",{className:`text-xs ${Je}`,children:[Ge,"%"]})]})})()}),s.jsx(je,{className:"text-gray-400",children:M.createdAt?new Date(M.createdAt).toLocaleDateString():"-"}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{Ue(M.id),we(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(Lf,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Aa(M),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>lc(M.id),title:"删除",children:s.jsx(ns,{className:"w-4 h-4"})})]})})]},M.id)}),o.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(xs,{page:f,totalPages:gr,total:u,pageSize:x,onPageChange:m,onPageSizeChange:M=>{b(M),m(1)}})]})})})]}),s.jsxs(Wt,{value:"leads",children:[Rr&&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:Rr}),s.jsx("button",{type:"button",className:"shrink-0 ml-2",onClick:()=>Yr(null),"aria-label":"关闭",children:"×"})]}),!sn&&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:ka})]}),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:Xs.uniqueUsers??0})]}),(Xs.sourceStats&&Xs.sourceStats.length>0?Xs.sourceStats.slice(0,2):[]).map(M=>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:["来源:",M.source]}),s.jsx("p",{className:"text-xl font-bold text-purple-400",children:M.cnt})]},M.source))]}),!sn&&Sd.length>0&&s.jsx(De,{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(G,{type:"button",variant:"outline",onClick:Cd,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:Sd.slice(0,8).map(M=>s.jsxs(Be,{className:"bg-red-500/15 text-red-200 border border-red-600/40",children:[M.reason," · ",M.count]},M.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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{placeholder:"搜索昵称/手机/微信/@人/来源/类型…",value:jt,onChange:M=>Un(M.target.value),className:"pl-9 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"})]}),Xs.sourceStats&&Xs.sourceStats.length>0&&s.jsxs("select",{value:Sa,onChange:M=>{mn(M.target.value),Rt(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部来源"}),Xs.sourceStats.map(M=>s.jsxs("option",{value:M.source,children:[M.source,"(",M.cnt,")"]},M.source))]}),s.jsxs("select",{value:Zr,onChange:M=>{const ee=M.target.value;ni(ee),Rt(1),e(be=>{const Ae=new URLSearchParams(be);return Ae.set("tab","leads"),ee?Ae.set("leadAction",ee):Ae.delete("leadAction"),Ae})},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:Ca,onChange:M=>qi(M.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer"}),"去重展示"]}),s.jsxs("select",{value:mr,onChange:M=>{As(M.target.value),Rt(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(G,{type:"button",variant:"outline",onClick:()=>{As("failed"),Rt(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:["本页 ",$n," 条",Yn>0?` · 已合并 ${Yn} 条重复`:""]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(G,{variant:"outline",onClick:ic,disabled:sn,className:"border-cyan-600/60 text-cyan-300 hover:bg-cyan-500/10 bg-transparent",children:"导出失败清单"}),s.jsxs(G,{variant:"outline",onClick:ii,disabled:ea||tr||sn,className:"border-amber-600/60 text-amber-300 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${ea?"animate-spin":""}`}),"重推本页失败项"]}),s.jsxs(G,{variant:"outline",onClick:()=>void Wn(),disabled:tr||vs.length===0||sn,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ns,{className:`w-4 h-4 mr-2 ${tr?"animate-pulse":""}`}),tr?"删除中…":`批量删除(${vs.length})`]}),s.jsxs(G,{variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`})," 刷新"]})]})]}),!sn&&at.length>0&&s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["已选 ",s.jsx("span",{className:"text-[#38bdac]",children:vs.length})," 条 · 可翻页继续勾选 · 改搜索/筛选会清空选择",vs.length>0&&s.jsx("button",{type:"button",className:"ml-2 text-gray-400 hover:text-gray-200 underline",onClick:()=>er([]),children:"清空"})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:sn?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-10 text-center",children:s.jsx("input",{ref:si,type:"checkbox",checked:at.length>0&&at.every(M=>vs.includes(M.id)),onChange:Sn,className:"w-4 h-4 rounded border-gray-600 bg-[#0f2137] accent-[#38bdac] cursor-pointer",title:"全选本页(展示行)"})}),s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"微信号"}),s.jsx(Se,{className:"text-gray-400",children:"对应 @人"}),s.jsx(Se,{className:"text-gray-400",children:"获客计划(Key)"}),s.jsx(Se,{className:"text-gray-400",children:"推送状态"}),s.jsx(Se,{className:"text-gray-400",children:"时间"}),s.jsx(Se,{className:"text-gray-400",children:"重试"})]})}),s.jsxs(ms,{children:[at.map(M=>s.jsxs(xt,{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:vs.includes(M.id),onChange:()=>sr(M.id),disabled:tr,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(N8,{userId:M.userId,userAvatar:M.userAvatar,nickname:M.userNickname,name:M.name,onOpenDetail:ee=>{Ue(ee),we(!0)}})}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-300",children:M.wechatId||"-"}),s.jsx(je,{className:"text-[#38bdac]",children:M.personName||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:(()=>{const ee=(M.planApiKey||"").trim();if(!ee)return"-";const be=ee.length<=10?ee:`${ee.slice(0,6)}…${ee.slice(-4)}`;return s.jsx("button",{type:"button",className:"font-mono text-gray-400 hover:text-gray-200 underline decoration-dotted",title:ee,onClick:async()=>{try{await navigator.clipboard.writeText(ee),q.success("已复制计划Key")}catch{q.error("复制失败,请手动复制")}},children:be})})()}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-1",children:[mc(M.pushStatus),(typeof M.ckbCode=="number"||(M.ckbMessage||"").trim())&&s.jsx("p",{className:"text-[11px] text-gray-500 max-w-[260px] truncate",title:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?`message=${String(M.ckbMessage).trim()}`:"",(M.ckbData||"").trim()?`data=${String(M.ckbData).trim()}`:""].filter(Boolean).join(" | "),children:[typeof M.ckbCode=="number"?`code=${M.ckbCode}`:"",(M.ckbMessage||"").trim()?String(M.ckbMessage).trim():""].filter(Boolean).join(" · ")}),!!(M.ckbData||"").trim()&&s.jsx("button",{type:"button",className:"text-[11px] text-sky-300/90 hover:text-sky-200 underline decoration-dotted",onClick:()=>{const ee=String(M.ckbData||"").trim();Ea(`存客宝返回 data(#${M.id})`),Ta(w8(ee)),ri(!0)},children:"查看 data"}),!!M.ckbError&&s.jsx("p",{className:"text-[11px] text-red-300 max-w-[220px] truncate",title:M.ckbError,children:M.ckbError})]})}),s.jsx(je,{className:"text-gray-400 whitespace-nowrap",children:M.createdAt?new Date(M.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 M.retryCount=="number"?`第 ${M.retryCount} 次`:"-"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||Gi===M.id||il===M.id,onClick:()=>cl(M.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(Ve,{className:`w-3 h-3 mr-1 ${Gi===M.id?"animate-spin":""}`}),"重推"]}),s.jsxs(G,{size:"sm",variant:"outline",disabled:tr||il===M.id||Gi===M.id,onClick:()=>ai(M.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(ns,{className:`w-3 h-3 mr-1 ${il===M.id?"animate-pulse":""}`}),"删除"]})]})]})})]},M.id)),at.length===0&&s.jsx(xt,{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(Qc,{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:Xr.trim()||Sa?"当前搜索或来源筛选下没有匹配记录,可清空条件后重试。":"存客宝场景产生的手机号 / 微信留资会出现在此列表。请确认获客计划已开启,并有用户完成留资。"}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>Nt(),disabled:sn,className:"border-[#38bdac]/40 text-[#38bdac] hover:bg-[#38bdac]/10 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${sn?"animate-spin":""}`}),"重新加载"]})]})})})]})]}),s.jsx(xs,{page:ve,totalPages:Math.ceil(ka/Zt)||1,total:ka,pageSize:Zt,onPageChange:Rt,onPageSizeChange:()=>{}})]})})})]}),s.jsxs(Wt,{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(G,{variant:"outline",onClick:xl,disabled:Ft,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${Ft?"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:Fc.map((M,ee)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${M.color} text-center cursor-pointer hover:opacity-80 transition-opacity ${ht===M.id?"ring-2 ring-[#38bdac]":""}`,onClick:()=>E(M.id),title:`点击查看「${M.label}」阶段的用户`,children:[s.jsx("div",{className:"text-2xl mb-1",children:M.icon}),s.jsx("div",{className:`text-xs font-medium ${M.color.split(" ").find(be=>be.startsWith("text-"))}`,children:M.label}),Qe[M.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[M.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:ee+1})]}),ees.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:M.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:M.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",M.next]})]})]},M.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(ur,{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:"实时更新"})]}),Ft?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Qe).length>0?s.jsx("div",{className:"space-y-2",children:(()=>{const M=Fc.reduce((ee,be)=>ee+(Qe[be.id]||0),0);return Fc.map(ee=>{const be=Qe[ee.id]||0,Ae=M>0?Math.round(be/M*100):0,Ge=be>0?Math.max(Ae,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:[ee.icon," ",ee.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:`${Ge}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-14 text-right tabular-nums",children:be}),s.jsx("span",{className:"text-gray-600 text-[10px] w-8 text-right tabular-nums",children:M>0?`${Ae}%`:"—"})]},ee.id)})})()}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]}),ht&&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(qn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-white font-medium",children:[(eo=Fc.find(M=>M.id===ht))==null?void 0:eo.icon," ",(eh=Fc.find(M=>M.id===ht))==null?void 0:eh.label," 阶段用户"]}),s.jsxs(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:[Gt.length," 人"]})]}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pt(null),className:"text-gray-400 hover:text-white",children:s.jsx(ss,{className:"w-4 h-4"})})]}),Ts?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Gt.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"该阶段暂无用户"}):s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"手机号"}),s.jsx(Se,{className:"text-gray-400",children:"注册时间"}),s.jsx(Se,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsx(ms,{children:Gt.map(M=>s.jsxs(xt,{className:"border-gray-700/50 hover:bg-[#0a1628]",children:[s.jsx(je,{className:"text-white",children:M.nickname||"微信用户"}),s.jsx(je,{className:"text-gray-300",children:M.phone||"-"}),s.jsx(je,{className:"text-gray-400 text-xs",children:M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx(je,{className:"text-right",children:s.jsxs(G,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/10",onClick:()=>z(M.id,M.nickname||"微信用户"),children:[s.jsx(Lf,{className:"w-4 h-4 mr-1"})," 行为轨迹"]})})]},M.id))})]})]}),s.jsx(Lt,{open:!!Ki,onOpenChange:M=>{M||ja(null)},children:s.jsxs(It,{className:"sm:max-w-[600px] bg-[#0f2137] border-gray-700 text-white max-h-[80vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(ma,{className:"w-5 h-5 text-[#38bdac]"}),ei," 的行为轨迹"]})}),Ir?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Ar.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"}),Ar.map((M,ee)=>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:M.actionLabel}),M.module&&s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[10px]",children:M.module})]}),(M.chapterTitle||M.target)&&s.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:M.chapterTitle||M.target}),s.jsxs("p",{className:"text-gray-600 text-[10px] mt-0.5",children:[M.timeAgo," · ",M.createdAt?new Date(M.createdAt).toLocaleString("zh-CN"):""]})]})]},M.id||ee))]})]})})]}),s.jsxs(Wt,{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(G,{variant:"outline",onClick:na,disabled:pn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${pn?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:()=>{as(null),vn({title:"",description:"",trigger:"",triggerConditions:[],actionType:"popup",sort:0,enabled:!0}),Mn(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),pn?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):fn.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(ur,{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(G,{onClick:na,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ve,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:fn.map(M=>{var be;const ee=A2(M.triggerConditions);return s.jsxs("div",{className:`p-3 rounded-lg border transition-all ${M.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:["#",M.sort]}),s.jsx(an,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium text-sm truncate",children:M.title}),M.trigger&&s.jsx(Be,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-[10px] shrink-0",children:M.trigger}),ee.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-0.5 ml-1",children:[ee.slice(0,3).map(Ae=>{const Ge=cN.find(Je=>Je.value===Ae);return s.jsx(Be,{className:"bg-purple-500/10 text-purple-400 border border-purple-500/30 text-[9px]",children:(Ge==null?void 0:Ge.label)||Ae},Ae)}),ee.length>3&&s.jsxs("span",{className:"text-gray-500 text-[9px]",children:["+",ee.length-3]})]}),M.actionType&&M.actionType!=="popup"&&s.jsx(Be,{className:"bg-amber-500/10 text-amber-400 border border-amber-500/30 text-[9px] shrink-0",children:((be=dN.find(Ae=>Ae.value===M.actionType))==null?void 0:be.label)||M.actionType})]}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-3 shrink-0",children:[s.jsx(Kt,{checked:M.enabled,onCheckedChange:()=>Ia(M)}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{as(M),vn({title:M.title,description:M.description,trigger:M.trigger,triggerConditions:ee,actionType:M.actionType||"popup",sort:M.sort,enabled:M.enabled}),Mn(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10 h-7 w-7 p-0",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Pa(M.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 h-7 w-7 p-0",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]}),M.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:["(",M.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:M.description})]})]},M.id)})})]}),s.jsxs(Wt,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(G,{variant:"outline",onClick:_n,disabled:We,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{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(Ve,{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(Xc,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(_e,{className:"p-0",children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-12",children:"序号"}),s.jsx(Se,{className:"text-gray-400",children:"成员"}),s.jsx(Se,{className:"text-gray-400 min-w-40",children:"超级个体标签"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"头像点击"}),s.jsx(Se,{className:"text-gray-400 w-16 text-center",children:"获客数"}),s.jsx(Se,{className:"text-gray-400 w-20",children:"排序值"}),s.jsx(Se,{className:"text-gray-400 w-36",children:"飞书群"}),s.jsx(Se,{className:"text-gray-400 w-36 text-right",children:"操作"})]})}),s.jsx(ms,{children:Ne.map((M,ee)=>{var Ge;const be=$t===M.id,Ae=$e===M.id;return s.jsxs(xt,{draggable:!0,onDragStart:Je=>pl(Je,M.id),onDragOver:Je=>fc(Je,M.id),onDrop:Je=>pc(Je,M.id),onDragEnd:ml,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${be?"opacity-60":""} ${Ae?"bg-[#38bdac]/10":""}`,children:[s.jsx(je,{className:"text-gray-300",children:ee+1}),s.jsx(je,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[Ma(M.avatar,M.mbti)?s.jsx("img",{src:Ma(M.avatar,M.mbti),className:"w-8 h-8 rounded-full object-cover border border-amber-400/60",alt:"",onError:Je=>{var He,en;Je.target.style.display="none";const Vt=document.createElement("div");Vt.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",Vt.textContent=((He=M.name)==null?void 0:He[0])||"创",(en=Je.target.parentElement)==null||en.appendChild(Vt)}}):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:((Ge=M.name)==null?void 0:Ge[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:M.name})})]})}),s.jsx(je,{className:"text-gray-300 whitespace-nowrap",children:M.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置)"})}),s.jsx(je,{className:"text-center text-blue-400 text-xs font-mono",children:M.clickCount!=null?String(M.clickCount):"-"}),s.jsx(je,{className:"text-center text-green-400 text-xs font-mono",children:M.leadCount!=null?String(M.leadCount):"-"}),s.jsx(je,{className:"text-gray-300",children:M.vipSort??ee+1}),s.jsx(je,{className:"text-xs",children:M.webhookUrl?s.jsx("span",{className:"text-[#38bdac] truncate block max-w-[180px]",title:M.webhookUrl,children:"已配置"}):s.jsx("span",{className:"text-gray-500",children:"未配置"})}),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(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>ui(M),title:"设置超级个体标签",children:s.jsx(xu,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>jd(M),title:"编辑飞书群Webhook",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>kd(M),title:"设置排序序号",children:s.jsx(_x,{className:"w-3.5 h-3.5"})})]})})]},M.id)})})]})})})]})]}),s.jsx(Lt,{open:wt,onOpenChange:jn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-6xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"MBTI 默认头像库"})}),s.jsx(y8,{})]})}),s.jsx(Lt,{open:hi,onOpenChange:M=>{oa(M),M||fl(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(_x,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",La==null?void 0:La.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:cc,onChange:M=>dc(M.target.value)})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>oa(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hc,disabled:Zi,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),Zi?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Lr,onOpenChange:M=>{ra(M),M||br(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Xc,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",oi==null?void 0:oi.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:di.map(M=>s.jsx(G,{variant:Ps===M?"default":"outline",size:"sm",className:Ps===M?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Ra(M),children:M},M))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Ps,onChange:M=>Ra(M.target.value)})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>ra(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:()=>ul(Ps),disabled:vr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),vr?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:Xi,onOpenChange:M=>{Or(M),M||ia(null)},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-xl",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),"设置飞书群 Webhook — ",aa==null?void 0:aa.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"VOX Webhook 地址(留空即清空)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",value:li,onChange:M=>ci(M.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"当用户点击该超级个体头像并提交链接时,线索将优先推送到这里配置的飞书群。"})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Or(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:hl,disabled:ls,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),ls?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:I,onOpenChange:Y,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[B?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Qc,{className:"w-5 h-5 text-[#38bdac]"}),B?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:pt.phone,onChange:M=>At({...pt,phone:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:pt.nickname,onChange:M=>At({...pt,nickname:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:B?"新密码 (留空则不修改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:B?"留空则不修改":"请输入密码",value:pt.password,onChange:M=>At({...pt,password:M.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Kt,{checked:pt.isAdmin,onCheckedChange:M=>At({...pt,isAdmin:M})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(te,{className:"text-gray-300",children:"已购全书"}),s.jsx(Kt,{checked:pt.hasFullBook,onCheckedChange:M=>At({...pt,hasFullBook:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Y(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:dl,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:bn,onOpenChange:Mn,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),Hn?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:_t.title,onChange:M=>vn({..._t,title:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"规则描述"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[60px] resize-none",placeholder:"弹窗内容/推送文案...",value:_t.description,onChange:M=>vn({..._t,description:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"触发条件(可多选)"}),s.jsx("div",{className:"space-y-2",children:["用户状态","阅读行为","付费行为","社交行为","分销行为"].map(M=>{const ee=cN.filter(be=>be.group===M);return ee.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] text-gray-500 mb-1",children:M}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:ee.map(be=>{const Ae=(_t.triggerConditions||[]).includes(be.value);return s.jsx("button",{type:"button",className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${Ae?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-[#0a1628] border-gray-700 text-gray-400 hover:border-gray-500"}`,onClick:()=>{const Ge=_t.triggerConditions||[],Je=Ae?Ge.filter(Vt=>Vt!==be.value):[...Ge,be.value];vn({..._t,triggerConditions:Je})},children:be.label},be.value)})})]},M)})}),(_t.triggerConditions||[]).length>0&&s.jsxs("p",{className:"text-[10px] text-[#38bdac]",children:["已选 ",(_t.triggerConditions||[]).length," 个触发条件(满足任一即触发)"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"兼容触发标识(旧版)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white text-xs h-8",placeholder:"与小程序一致:注册、完成付款、update_avatar、update_nickname 等",value:_t.trigger,onChange:M=>vn({..._t,trigger:M.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"推送动作"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:dN.map(M=>s.jsxs("button",{type:"button",className:`p-2 rounded-lg border text-left transition-colors ${_t.actionType===M.value?"bg-[#38bdac]/15 border-[#38bdac]/50":"bg-[#0a1628] border-gray-700 hover:border-gray-500"}`,onClick:()=>vn({..._t,actionType:M.value}),children:[s.jsx("span",{className:`text-xs font-medium ${_t.actionType===M.value?"text-[#38bdac]":"text-gray-300"}`,children:M.label}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:M.desc})]},M.value))})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(te,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Kt,{checked:_t.enabled,onCheckedChange:M=>vn({..._t,enabled:M})})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>Mn(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:sa,disabled:X,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),X?"保存中...":"保存"]})]})]})}),s.jsx(Lt,{open:W,onOpenChange:fe,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(qn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",$==null?void 0:$.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:((Ed=he.stats)==null?void 0:Ed.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:((Td=he.stats)==null?void 0:Td.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:["¥",(((Md=he.stats)==null?void 0:Md.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:["¥",(((Ad=he.stats)==null?void 0:Ad.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(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Pd=he.referrals)==null?void 0:Pd.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(he.referrals??[]).map((M,ee)=>{var Ae;const be=M;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:((Ae=be.nickname)==null?void 0:Ae.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:be.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:be.phone||(be.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[be.status==="vip"&&s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),be.status==="paid"&&s.jsxs(Be,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",be.purchasedSections,"章"]}),be.status==="free"&&s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:be.createdAt?new Date(be.createdAt).toLocaleDateString():""})]})]},be.id||ee)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(nn,{children:s.jsx(G,{variant:"outline",onClick:()=>fe(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(py,{open:ae,onClose:()=>we(!1),userId:Fe,onUserUpdated:nr}),s.jsx(Lt,{open:ol,onOpenChange:ri,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700/60 text-white max-w-2xl",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:Qi})}),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:ll||"—"})}),s.jsxs(nn,{children:[s.jsx(G,{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(ll||""),q.success("已复制 data")}catch{q.error("复制失败,请手动复制")}},disabled:!ll,children:"复制 data"}),s.jsx(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2aa896] text-white",onClick:()=>ri(!1),children:"关闭"})]})]})})]})}function Ff(t,[e,n]){return Math.min(n,Math.max(e,t))}var P2=["PageUp","PageDown"],I2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gd="Slider",[Xg,k8,S8]=dy(gd),[L2]=Zo(gd,[S8]),[C8,Up]=L2(gd),O2=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),C=o==="horizontal"?E8:T8,[L=[],R]=Hl({prop:f,defaultProp:h,onChange:re=>{var ne;(ne=[...v.current][k.current])==null||ne.focus(),m(re)}}),U=g.useRef(L);function P(re){const D=R8(L,re);Q(re,D)}function F(re){Q(re,k.current)}function O(){const re=U.current[k.current];L[k.current]!==re&&x(L)}function Q(re,D,{commit:ne}={commit:!1}){const le=_8(i),me=$8(Math.round((re-r)/i)*i+r,le),I=Ff(me,[r,a]);R((Y=[])=>{const B=P8(Y,I,D);if(D8(B,u*i)){k.current=B.indexOf(I);const xe=String(B)!==String(Y);return xe&&ne&&x(B),xe?B:Y}else return Y})}return s.jsx(C8,{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(Xg.Provider,{scope:t.__scopeSlider,children:s.jsx(Xg.Slot,{scope:t.__scopeSlider,children:s.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:kt(w.onPointerDown,()=>{c||(U.current=L)}),min:r,max:a,inverted:b,onSlideStart:c?void 0:P,onSlideMove:c?void 0:F,onSlideEnd:c?void 0:O,onHomeKeyDown:()=>!c&&Q(r,0,{commit:!0}),onEndKeyDown:()=>!c&&Q(a,L.length-1,{commit:!0}),onStepKeyDown:({event:re,direction:D})=>{if(!c){const me=P2.includes(re.key)||re.shiftKey&&I2.includes(re.key)?10:1,I=k.current,Y=L[I],B=i*me*D;Q(Y+B,I,{commit:!0})}}})})})})});O2.displayName=gd;var[D2,_2]=L2(gd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),E8=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=Xt(e,C=>x(C)),N=g.useRef(void 0),w=Bp(a),v=w==="ltr",k=v&&!i||!v&&i;function T(C){const L=N.current||m.getBoundingClientRect(),R=[0,L.width],P=my(R,k?[n,r]:[r,n]);return N.current=L,P(C-L.left)}return s.jsx(D2,{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:C=>{const L=T(C.clientX);o==null||o(L)},onSlideMove:C=>{const L=T(C.clientX);c==null||c(L)},onSlideEnd:()=>{N.current=void 0,u==null||u()},onStepKeyDown:C=>{const R=R2[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:R?-1:1})}})})}),T8=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=Xt(e,f),x=g.useRef(void 0),b=!a;function N(w){const v=x.current||f.current.getBoundingClientRect(),k=[0,v.height],C=my(k,b?[r,n]:[n,r]);return x.current=v,C(w-v.top)}return s.jsx(D2,{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=R2[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=Up(gd,n);return s.jsx(Tt.span,{...h,ref:e,onKeyDown:kt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):P2.concat(I2).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:kt(t.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(x)?x.focus():r(m)}),onPointerMove:kt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:kt(t.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),i(m))})})}),z2="SliderTrack",F2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(z2,n);return s.jsx(Tt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});F2.displayName=z2;var Zg="SliderRange",B2=g.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=Up(Zg,n),i=_2(Zg,n),o=g.useRef(null),c=Xt(e,o),u=a.values.length,h=a.values.map(x=>U2(x,a.min,a.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(Tt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...t.style,[i.startEdge]:f+"%",[i.endEdge]:m+"%"}})});B2.displayName=Zg;var e0="SliderThumb",V2=g.forwardRef((t,e)=>{const n=k8(t.__scopeSlider),[r,a]=g.useState(null),i=Xt(e,c=>a(c)),o=g.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(M8,{...t,ref:i,index:o})}),M8=g.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=Up(e0,n),c=_2(e0,n),[u,h]=g.useState(null),f=Xt(e,T=>h(T)),m=u?o.form||!!u.closest("form"):!0,x=fy(u),b=o.values[r],N=b===void 0?0:U2(b,o.min,o.max),w=I8(r,o.values.length),v=x==null?void 0:x[c.size],k=v?L8(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(Xg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(Tt.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:kt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(H2,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});V2.displayName=e0;var A8="RadioBubbleInput",H2=g.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=g.useRef(null),i=Xt(a,r),o=hy(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(Tt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});H2.displayName=A8;function P8(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function U2(t,e,n){const i=100/(n-e)*(t-e);return Ff(i,[0,100])}function I8(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function R8(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 L8(t,e,n){const r=t/2,i=my([0,50],[0,r]);return(r-i(e)*n)*n}function O8(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function D8(t,e){if(e>0){const n=O8(t);return Math.min(...n)>=e}return!0}function my(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 _8(t){return(String(t).split(".")[1]||"").length}function $8(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var z8=O2,F8=F2,B8=B2,V8=V2;function H8({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(z8,{defaultValue:e,value:n,min:r,max:a,className:zt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...i,children:[s.jsx(F8,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(B8,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(V8,{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 U8={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,withdrawFee:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function W2(t){const e=!!(t!=null&&t.embedded),[n,r]=g.useState(U8),[a,i]=g.useState(!0),[o,c]=g.useState(!1);g.useEffect(()=>{Le("/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 bt("/api/admin/referral-settings",f);if(!m||m.success===!1){q.error("保存失败: "+(m&&typeof m=="object"&&"error"in m?m.error:""));return}q.success(`✅ 分销配置已保存成功! • 小程序与网站的推广规则会一起生效 • 绑定关系会使用新的天数配置 • 佣金比例会立即应用到新订单 -如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),q.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(sd,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(_i,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(G,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(tA,{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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value: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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Kn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(H8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(oe,{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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value: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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value: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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Kn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(oe,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(sd,{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(te,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(oe,{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(te,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Be,{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(Kt,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs(ut,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(Jh,{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 W8(){const[t]=X0(),e=Ya(),[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),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState("all"),[z,O]=g.useState(1),[Q,re]=g.useState(10),[D,ne]=g.useState(0),[le,me]=g.useState(new Set),[I,Y]=g.useState(null),[F,xe]=g.useState(""),[X,V]=g.useState(!1),[W,fe]=g.useState(null),[he,de]=g.useState(""),[_,J]=g.useState(!1),[$,Z]=g.useState(!1),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState([]),[wt,jn]=g.useState(1),[pt,At]=g.useState(0),[fn,Vn]=g.useState("");g.useEffect(()=>{t.get("tab")==="leads"&&e("/users?tab=leads",{replace:!0})},[t,e]),g.useEffect(()=>{pn()},[]),g.useEffect(()=>{const H=t.get("tab");(H==="overview"||H==="orders"||H==="bindings"||H==="withdrawals"||H==="settings")&&r(H)},[t]),g.useEffect(()=>{O(1)},[n,U]),g.useEffect(()=>{qt(n)},[n]),g.useEffect(()=>{if(n==="orders"&&a==="giftpay"){qt("giftPay",!0);return}["orders","bindings","withdrawals"].includes(n)&&qt(n,!0)},[z,Q,U,L,n,a,wt,fn]),g.useEffect(()=>{n==="withdrawals"&&_t()},[n]);async function pn(){C(null);try{const H=await Le("/api/admin/distribution/overview");H!=null&&H.success&&H.overview&&h(H.overview)}catch(H){console.error("[Admin] 概览接口异常:",H),C("加载概览失败")}try{const H=await Le("/api/db/users");w((H==null?void 0:H.users)||[])}catch(H){console.error("[Admin] 用户数据加载失败:",H)}}async function qt(H,Qe=!1){var vt;if(!(!Qe&&le.has(H))){k(!0);try{const Ft=N;switch(H){case"overview":break;case"orders":{try{const yt=new URLSearchParams({page:String(z),pageSize:String(Q),...U!=="all"&&{status:U},...L&&{search:L}}),ht=await Le(`/api/admin/orders?${yt}`);if(ht!=null&&ht.success&&ht.orders){const Pt=ht.orders.map(Gt=>{const kn=Ft.find(Ms=>Ms.id===Gt.userId),Ts=Gt.referrerId?Ft.find(Ms=>Ms.id===Gt.referrerId):null;return{...Gt,amount:parseFloat(String(Gt.amount))||0,userNickname:(kn==null?void 0:kn.nickname)||Gt.userNickname||"未知用户",userPhone:(kn==null?void 0:kn.phone)||Gt.userPhone||"-",referrerNickname:(Ts==null?void 0:Ts.nickname)||null,referrerCode:(Ts==null?void 0:Ts.referralCode)??null,type:Gt.productType||Gt.type}});c(Pt),ne(ht.total??Pt.length)}else c([]),ne(0)}catch(yt){console.error(yt),C("加载订单失败"),c([])}break}case"bindings":{try{const yt=new URLSearchParams({page:String(z),pageSize:String(Q),...U!=="all"&&{status:U}}),ht=await Le(`/api/db/distribution?${yt}`);m((ht==null?void 0:ht.bindings)||[]),ne((ht==null?void 0:ht.total)??((vt=ht==null?void 0:ht.bindings)==null?void 0:vt.length)??0)}catch(yt){console.error(yt),C("加载绑定数据失败"),m([])}break}case"withdrawals":{try{const yt=U==="completed"?"success":U==="rejected"?"failed":U,ht=new URLSearchParams({...yt&&yt!=="all"&&{status:yt},page:String(z),pageSize:String(Q)}),Pt=await Le(`/api/admin/withdrawals?${ht}`);if(Pt!=null&&Pt.success&&Pt.withdrawals){const Gt=Pt.withdrawals.map(kn=>({...kn,account:kn.account??"未绑定微信号",status:kn.status==="success"?"completed":kn.status==="failed"?"rejected":kn.status}));b(Gt),ne((Pt==null?void 0:Pt.total)??Gt.length)}else Pt!=null&&Pt.success||C(`获取提现记录失败: ${(Pt==null?void 0:Pt.error)||"未知错误"}`),b([])}catch(yt){console.error(yt),C("加载提现数据失败"),b([])}break}case"giftPay":{try{const yt=new URLSearchParams({page:String(wt),pageSize:"20",...fn&&{status:fn}}),ht=await Le(`/api/admin/gift-pay-requests?${yt}`);ht!=null&&ht.success&&ht.data?(Ue(ht.data),At(ht.total??ht.data.length)):(Ue([]),At(0))}catch(yt){console.error(yt),C("加载代付请求失败"),Ue([])}break}}me(yt=>new Set(yt).add(H))}catch(Ft){console.error(Ft)}finally{k(!1)}}}async function bn(){C(null),me(H=>{const Qe=new Set(H);return Qe.delete(n),n==="orders"&&a==="giftpay"&&Qe.delete("giftPay"),Qe}),n==="overview"&&pn(),n==="orders"&&a==="giftpay"?await qt("giftPay",!0):await qt(n,!0)}async function Mn(H){if(confirm("确认审核通过并打款?"))try{const Qe=await tn("/api/admin/withdrawals",{id:H,action:"approve"});if(!(Qe!=null&&Qe.success)){const vt=(Qe==null?void 0:Qe.message)||(Qe==null?void 0:Qe.error)||"操作失败";q.error(vt);return}await bn()}catch(Qe){console.error(Qe),q.error("操作失败")}}function Hn(H){fe(H),de("")}async function rs(){const H=W;if(!H)return;const Qe=he.trim();if(!Qe){q.error("请填写拒绝原因");return}J(!0);try{const vt=await tn("/api/admin/withdrawals",{id:H,action:"reject",errorMessage:Qe});if(!(vt!=null&&vt.success)){q.error((vt==null?void 0:vt.error)||"操作失败");return}q.success("已拒绝该提现申请"),fe(null),de(""),await bn()}catch(vt){console.error(vt),q.error("操作失败")}finally{J(!1)}}async function _t(){try{const H=await Le("/api/admin/withdrawals/auto-approve");H!=null&&H.success&&typeof H.enableAutoApprove=="boolean"&&Z(H.enableAutoApprove)}catch{}}async function vn(H){we(!0);try{const Qe=await tn("/api/admin/withdrawals/auto-approve",{enableAutoApprove:H});Qe!=null&&Qe.success?(Z(H),q.success(H?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):q.error("更新失败: "+((Qe==null?void 0:Qe.error)??""))}catch{q.error("更新失败")}finally{we(!1)}}function Ne(){W&&q.info("已取消操作"),fe(null),de("")}async function Me(){var H;if(!(!(I!=null&&I.orderSn)&&!(I!=null&&I.id))){V(!0),C(null);try{const Qe=await tn("/api/admin/orders/refund",{orderSn:I.orderSn||I.id,reason:F||void 0});Qe!=null&&Qe.success?(Y(null),xe(""),await qt("orders",!0)):C((Qe==null?void 0:Qe.error)||"退款失败")}catch(Qe){const vt=Qe;C(((H=vt==null?void 0:vt.data)==null?void 0:H.error)||"退款失败,请检查网络后重试")}finally{V(!1)}}}function We(H){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"},vt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Be,{className:`${Qe[H]||"bg-gray-500/20 text-gray-400"} border-0`,children:vt[H]||H})}const rt=Math.ceil(D/Q)||1,$t=o,kt=f.filter(H=>{var vt,Ft,yt,ht;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.refereeNickname)==null?void 0:vt.toLowerCase().includes(Qe))||((Ft=H.refereePhone)==null?void 0:Ft.includes(Qe))||((yt=H.referrerName)==null?void 0:yt.toLowerCase().includes(Qe))||((ht=H.referrerCode)==null?void 0:ht.toLowerCase().includes(Qe))}),$e=x.filter(H=>{var vt;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.userName)==null?void 0:vt.toLowerCase().includes(Qe))||H.account&&H.account.toLowerCase().includes(Qe)});return s.jsxs("div",{className:"p-8 w-full",children:[T&&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:T}),s.jsx("button",{type:"button",onClick:()=>C(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(G,{onClick:bn,disabled:v,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ve,{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:Of},{key:"orders",label:"订单与代付",icon:Rf},{key:"bindings",label:"绑定管理",icon:Ua},{key:"withdrawals",label:"提现审核",icon:sd},{key:"settings",label:"推广设置",icon:Po}].map(H=>s.jsxs("button",{type:"button",onClick:()=>{r(H.key),P("all"),R(""),H.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===H.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(H.icon,{className:"w-3.5 h-3.5"}),H.label]},H.key))}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{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(De,{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(Ho,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>void bn(),disabled:v,className:"text-gray-400 h-7",children:s.jsx(Ve,{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(Lf,{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(Ua,{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($x,{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(Rf,{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(De,{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(Vg,{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(De,{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(sd,{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(G,{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(De,{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(_i,{to:"/users?tab=leads",className:"shrink-0",children:s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-emerald-500/50 text-emerald-400 hover:bg-emerald-500/15 bg-transparent",children:"打开获客列表"})})]})}),s.jsx(De,{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(Kn,{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($x,{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"),qt("giftPay",!0)},children:[s.jsx(Hg,{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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.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(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{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:$t.map(H=>{var Qe,vt;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=H.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:H.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?`余额充值 ¥${typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)}`:Pt?"超级个体开通费用":Ft==="fullbook"?`${H.bookName||"《底层逻辑》"} - 全本`:Ft==="match"?"匹配次数购买":`${H.bookName||"《底层逻辑》"} - ${H.sectionTitle||H.chapterTitle||`章节${H.productId||H.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?"余额充值":Pt?"超级个体":Ft==="fullbook"?"全书解锁":Ft==="match"?"功能权益":H.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:H.paymentMethod==="wechat"?"微信支付":H.paymentMethod==="balance"?"余额支付":H.paymentMethod==="alipay"?"支付宝":H.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:H.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):H.status==="completed"||H.status==="paid"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):H.status==="pending"||H.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Be,{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:H.refundReason,children:H.status==="refunded"&&H.refundReason?H.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:H.referrerId||H.referralCode?s.jsxs("span",{title:H.referralCode||H.referrerCode||H.referrerId||"",children:[H.referrerNickname||H.referralCode||H.referrerCode||((vt=H.referrerId)==null?void 0:vt.slice(0,8)),(H.referralCode||H.referrerCode)&&` (${H.referralCode||H.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:H.referrerEarnings?`¥${(typeof H.referrerEarnings=="number"?H.referrerEarnings:parseFloat(String(H.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(H.status==="paid"||H.status==="completed")&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{Y(H),xe("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},H.id)})})]})}),n==="orders"&&s.jsx(xs,{page:z,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]}),a==="giftpay"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(ut,{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:fn,onChange:H=>{Vn(H.target.value),jn(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(G,{size:"sm",variant:"outline",onClick:()=>void qt("giftPay",!0),disabled:v,className:"border-gray-600 text-gray-300",children:[s.jsx(Ve,{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:Fe.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:H.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:H.initiatorNick||H.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[H.productType," · ¥",H.amount.toFixed(2)]}),H.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:H.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(H.quantity??1)>1?`${H.quantity}份 / 已领${H.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:H.payerNick||(H.payerUserId?H.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Be,{className:H.status==="paid"?"bg-green-500/20 text-green-400 border-0":H.status==="pending"||H.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":H.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:H.status==="paid"?"已支付":H.status==="pending"||H.status==="pending_pay"?"待支付":H.status==="refunded"?"已退款":H.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"})]},H.id))})]})}),Fe.length===0&&!v&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),pt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(xs,{page:wt,totalPages:Math.ceil(pt/20),total:pt,pageSize:20,onPageChange:jn,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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.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(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[kt.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:kt.map(H=>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:H.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:H.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:H.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.boundAt?new Date(H.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:H.expiresAt?new Date(H.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4",children:H.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",H.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},H.id))})]})}),n==="bindings"&&s.jsx(xs,{page:z,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.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(Ho,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx(Kt,{checked:$,onCheckedChange:vn,disabled:ae,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{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(H=>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:[H.userAvatar?s.jsx("img",{src:H.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:(H.userName||H.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:H.userName||H.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",H.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Be,{className:H.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:H.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:H.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${H.status==="rejected"||H.status==="failed"?"text-red-400":"text-gray-400"}`,title:H.remark,children:H.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:H.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(G,{size:"sm",onClick:()=>Mn(H.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx($x,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>Hn(H.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(tk,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},H.id))})]})}),n==="withdrawals"&&s.jsx(xs,{page:z,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]})]}),s.jsx(Lt,{open:!!I,onOpenChange:H=>!H&&Y(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{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(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:F,onChange:H=>xe(H.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>Y(null),disabled:X,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Me,disabled:X,children:X?"退款中...":"确认退款"})]})]})}),s.jsx(Lt,{open:!!W,onOpenChange:H=>!H&&Ne(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:he,onChange:H=>de(H.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Ne,disabled:_,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:rs,disabled:_||!he.trim(),children:_?"提交中...":"确认拒绝"})]})]})}),n==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(W2,{embedded:!0})})]})}function K8(){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),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState(!1);async function z(){var I,Y,F,xe,X,V,W;i(!0),c(null);try{const fe=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),he=await Le(`/api/admin/withdrawals?${fe}`);if(he!=null&&he.success){const de=he.withdrawals||[];e(de),w(he.total??((I=he.stats)==null?void 0:I.total)??de.length),r({total:((Y=he.stats)==null?void 0:Y.total)??he.total??de.length,pendingCount:((F=he.stats)==null?void 0:F.pendingCount)??0,pendingAmount:((xe=he.stats)==null?void 0:xe.pendingAmount)??0,successCount:((X=he.stats)==null?void 0:X.successCount)??0,successAmount:((V=he.stats)==null?void 0:V.successAmount)??0,failedCount:((W=he.stats)==null?void 0:W.failedCount)??0})}else c("加载提现记录失败")}catch(fe){console.error("Load withdrawals error:",fe),c("加载失败,请检查网络后重试")}finally{i(!1)}}g.useEffect(()=>{m(1)},[u]),g.useEffect(()=>{z()},[u,f,x]);const O=Math.ceil(N/x)||1;async function Q(I){const Y=t.find(F=>F.id===I);if(Y!=null&&Y.userCommissionInfo&&Y.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${Y.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 +如有缓存,请刷新前台/小程序页面。`)}catch(f){console.error(f),q.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(sd,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置(与系统设置中的「推广功能」开关配合:开关在"," ",s.jsx(_i,{to:"/settings",className:"text-[#38bdac] underline hover:text-[#5ee0d1]",children:"系统设置 → 功能开关"}),")。"]})]}),s.jsxs(G,{onClick:u,disabled:o||a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),o?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(tA,{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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value: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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(qn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(H8,{className:"flex-1",min:10,max:100,step:1,value:[n.distributorShare],onValueChange:([f])=>r(m=>({...m,distributorShare:f}))}),s.jsx(oe,{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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value: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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Jh,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value: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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(qn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(oe,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:n.bindingDays,onChange:h("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(sd,{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(te,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"提现手续费(%)"}),s.jsx(oe,{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(te,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Be,{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(Kt,{checked:n.enableAutoWithdraw,onCheckedChange:f=>r(m=>({...m,enableAutoWithdraw:f}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs(ut,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(Jh,{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 W8(){const[t]=X0(),e=Ya(),[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),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState("all"),[F,O]=g.useState(1),[Q,re]=g.useState(10),[D,ne]=g.useState(0),[le,me]=g.useState(new Set),[I,Y]=g.useState(null),[B,xe]=g.useState(""),[X,V]=g.useState(!1),[W,fe]=g.useState(null),[he,de]=g.useState(""),[_,J]=g.useState(!1),[$,Z]=g.useState(!1),[ae,we]=g.useState(!1),[Fe,Ue]=g.useState([]),[wt,jn]=g.useState(1),[pt,At]=g.useState(0),[fn,Vn]=g.useState("");g.useEffect(()=>{t.get("tab")==="leads"&&e("/users?tab=leads",{replace:!0})},[t,e]),g.useEffect(()=>{pn()},[]),g.useEffect(()=>{const H=t.get("tab");(H==="overview"||H==="orders"||H==="bindings"||H==="withdrawals"||H==="settings")&&r(H)},[t]),g.useEffect(()=>{O(1)},[n,U]),g.useEffect(()=>{qt(n)},[n]),g.useEffect(()=>{if(n==="orders"&&a==="giftpay"){qt("giftPay",!0);return}["orders","bindings","withdrawals"].includes(n)&&qt(n,!0)},[F,Q,U,L,n,a,wt,fn]),g.useEffect(()=>{n==="withdrawals"&&_t()},[n]);async function pn(){C(null);try{const H=await Le("/api/admin/distribution/overview");H!=null&&H.success&&H.overview&&h(H.overview)}catch(H){console.error("[Admin] 概览接口异常:",H),C("加载概览失败")}try{const H=await Le("/api/db/users");w((H==null?void 0:H.users)||[])}catch(H){console.error("[Admin] 用户数据加载失败:",H)}}async function qt(H,Qe=!1){var vt;if(!(!Qe&&le.has(H))){k(!0);try{const Ft=N;switch(H){case"overview":break;case"orders":{try{const yt=new URLSearchParams({page:String(F),pageSize:String(Q),...U!=="all"&&{status:U},...L&&{search:L}}),ht=await Le(`/api/admin/orders?${yt}`);if(ht!=null&&ht.success&&ht.orders){const Pt=ht.orders.map(Gt=>{const kn=Ft.find(Ms=>Ms.id===Gt.userId),Ts=Gt.referrerId?Ft.find(Ms=>Ms.id===Gt.referrerId):null;return{...Gt,amount:parseFloat(String(Gt.amount))||0,userNickname:(kn==null?void 0:kn.nickname)||Gt.userNickname||"未知用户",userPhone:(kn==null?void 0:kn.phone)||Gt.userPhone||"-",referrerNickname:(Ts==null?void 0:Ts.nickname)||null,referrerCode:(Ts==null?void 0:Ts.referralCode)??null,type:Gt.productType||Gt.type}});c(Pt),ne(ht.total??Pt.length)}else c([]),ne(0)}catch(yt){console.error(yt),C("加载订单失败"),c([])}break}case"bindings":{try{const yt=new URLSearchParams({page:String(F),pageSize:String(Q),...U!=="all"&&{status:U}}),ht=await Le(`/api/db/distribution?${yt}`);m((ht==null?void 0:ht.bindings)||[]),ne((ht==null?void 0:ht.total)??((vt=ht==null?void 0:ht.bindings)==null?void 0:vt.length)??0)}catch(yt){console.error(yt),C("加载绑定数据失败"),m([])}break}case"withdrawals":{try{const yt=U==="completed"?"success":U==="rejected"?"failed":U,ht=new URLSearchParams({...yt&&yt!=="all"&&{status:yt},page:String(F),pageSize:String(Q)}),Pt=await Le(`/api/admin/withdrawals?${ht}`);if(Pt!=null&&Pt.success&&Pt.withdrawals){const Gt=Pt.withdrawals.map(kn=>({...kn,account:kn.account??"未绑定微信号",status:kn.status==="success"?"completed":kn.status==="failed"?"rejected":kn.status}));b(Gt),ne((Pt==null?void 0:Pt.total)??Gt.length)}else Pt!=null&&Pt.success||C(`获取提现记录失败: ${(Pt==null?void 0:Pt.error)||"未知错误"}`),b([])}catch(yt){console.error(yt),C("加载提现数据失败"),b([])}break}case"giftPay":{try{const yt=new URLSearchParams({page:String(wt),pageSize:"20",...fn&&{status:fn}}),ht=await Le(`/api/admin/gift-pay-requests?${yt}`);ht!=null&&ht.success&&ht.data?(Ue(ht.data),At(ht.total??ht.data.length)):(Ue([]),At(0))}catch(yt){console.error(yt),C("加载代付请求失败"),Ue([])}break}}me(yt=>new Set(yt).add(H))}catch(Ft){console.error(Ft)}finally{k(!1)}}}async function bn(){C(null),me(H=>{const Qe=new Set(H);return Qe.delete(n),n==="orders"&&a==="giftpay"&&Qe.delete("giftPay"),Qe}),n==="overview"&&pn(),n==="orders"&&a==="giftpay"?await qt("giftPay",!0):await qt(n,!0)}async function Mn(H){if(confirm("确认审核通过并打款?"))try{const Qe=await tn("/api/admin/withdrawals",{id:H,action:"approve"});if(!(Qe!=null&&Qe.success)){const vt=(Qe==null?void 0:Qe.message)||(Qe==null?void 0:Qe.error)||"操作失败";q.error(vt);return}await bn()}catch(Qe){console.error(Qe),q.error("操作失败")}}function Hn(H){fe(H),de("")}async function as(){const H=W;if(!H)return;const Qe=he.trim();if(!Qe){q.error("请填写拒绝原因");return}J(!0);try{const vt=await tn("/api/admin/withdrawals",{id:H,action:"reject",errorMessage:Qe});if(!(vt!=null&&vt.success)){q.error((vt==null?void 0:vt.error)||"操作失败");return}q.success("已拒绝该提现申请"),fe(null),de(""),await bn()}catch(vt){console.error(vt),q.error("操作失败")}finally{J(!1)}}async function _t(){try{const H=await Le("/api/admin/withdrawals/auto-approve");H!=null&&H.success&&typeof H.enableAutoApprove=="boolean"&&Z(H.enableAutoApprove)}catch{}}async function vn(H){we(!0);try{const Qe=await tn("/api/admin/withdrawals/auto-approve",{enableAutoApprove:H});Qe!=null&&Qe.success?(Z(H),q.success(H?"已开启自动审批,新提现将自动打款":"已关闭自动审批")):q.error("更新失败: "+((Qe==null?void 0:Qe.error)??""))}catch{q.error("更新失败")}finally{we(!1)}}function Ne(){W&&q.info("已取消操作"),fe(null),de("")}async function Me(){var H;if(!(!(I!=null&&I.orderSn)&&!(I!=null&&I.id))){V(!0),C(null);try{const Qe=await tn("/api/admin/orders/refund",{orderSn:I.orderSn||I.id,reason:B||void 0});Qe!=null&&Qe.success?(Y(null),xe(""),await qt("orders",!0)):C((Qe==null?void 0:Qe.error)||"退款失败")}catch(Qe){const vt=Qe;C(((H=vt==null?void 0:vt.data)==null?void 0:H.error)||"退款失败,请检查网络后重试")}finally{V(!1)}}}function We(H){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"},vt={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Be,{className:`${Qe[H]||"bg-gray-500/20 text-gray-400"} border-0`,children:vt[H]||H})}const rt=Math.ceil(D/Q)||1,$t=o,St=f.filter(H=>{var vt,Ft,yt,ht;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.refereeNickname)==null?void 0:vt.toLowerCase().includes(Qe))||((Ft=H.refereePhone)==null?void 0:Ft.includes(Qe))||((yt=H.referrerName)==null?void 0:yt.toLowerCase().includes(Qe))||((ht=H.referrerCode)==null?void 0:ht.toLowerCase().includes(Qe))}),$e=x.filter(H=>{var vt;if(!L)return!0;const Qe=L.toLowerCase();return((vt=H.userName)==null?void 0:vt.toLowerCase().includes(Qe))||H.account&&H.account.toLowerCase().includes(Qe)});return s.jsxs("div",{className:"p-8 w-full",children:[T&&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:T}),s.jsx("button",{type:"button",onClick:()=>C(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(G,{onClick:bn,disabled:v,variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ve,{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:Of},{key:"orders",label:"订单与代付",icon:Rf},{key:"bindings",label:"绑定管理",icon:Ua},{key:"withdrawals",label:"提现审核",icon:sd},{key:"settings",label:"推广设置",icon:Po}].map(H=>s.jsxs("button",{type:"button",onClick:()=>{r(H.key),P("all"),R(""),H.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===H.key?"bg-[#38bdac] text-white shadow-md":"text-gray-400 hover:text-white hover:bg-gray-700/40"}`,children:[s.jsx(H.icon,{className:"w-3.5 h-3.5"}),H.label]},H.key))}),v?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ve,{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(De,{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(Ho,{className:"w-4 h-4 text-amber-400"}),"推广转化漏斗"]}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>void bn(),disabled:v,className:"text-gray-400 h-7",children:s.jsx(Ve,{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(Lf,{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(Ua,{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($x,{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(Rf,{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(De,{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(Vg,{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(De,{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(sd,{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(G,{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(De,{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(_i,{to:"/users?tab=leads",className:"shrink-0",children:s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-emerald-500/50 text-emerald-400 hover:bg-emerald-500/15 bg-transparent",children:"打开获客列表"})})]})}),s.jsx(De,{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(qn,{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($x,{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"),qt("giftPay",!0)},children:[s.jsx(Hg,{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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.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(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{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:$t.map(H=>{var Qe,vt;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=H.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:H.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?`余额充值 ¥${typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)}`:Pt?"超级个体开通费用":Ft==="fullbook"?`${H.bookName||"《底层逻辑》"} - 全本`:Ft==="match"?"匹配次数购买":`${H.bookName||"《底层逻辑》"} - ${H.sectionTitle||H.chapterTitle||`章节${H.productId||H.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const Ft=H.productType||H.type,yt=H.description||"",ht=String(H.productId||H.sectionId||""),Pt=Ft==="vip"||yt.includes("VIP")||yt.toLowerCase().includes("vip")||ht.toLowerCase().includes("vip");return Ft==="balance_recharge"?"余额充值":Pt?"超级个体":Ft==="fullbook"?"全书解锁":Ft==="match"?"功能权益":H.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof H.amount=="number"?H.amount.toFixed(2):parseFloat(String(H.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:H.paymentMethod==="wechat"?"微信支付":H.paymentMethod==="balance"?"余额支付":H.paymentMethod==="alipay"?"支付宝":H.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:H.status==="refunded"?s.jsx(Be,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):H.status==="completed"||H.status==="paid"?s.jsx(Be,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):H.status==="pending"||H.status==="created"?s.jsx(Be,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Be,{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:H.refundReason,children:H.status==="refunded"&&H.refundReason?H.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:H.referrerId||H.referralCode?s.jsxs("span",{title:H.referralCode||H.referrerCode||H.referrerId||"",children:[H.referrerNickname||H.referralCode||H.referrerCode||((vt=H.referrerId)==null?void 0:vt.slice(0,8)),(H.referralCode||H.referrerCode)&&` (${H.referralCode||H.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:H.referrerEarnings?`¥${(typeof H.referrerEarnings=="number"?H.referrerEarnings:parseFloat(String(H.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(H.status==="paid"||H.status==="completed")&&s.jsxs(G,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{Y(H),xe("")},children:[s.jsx(lk,{className:"w-3 h-3 mr-1"}),"退款"]})})]},H.id)})})]})}),n==="orders"&&s.jsx(xs,{page:F,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]}),a==="giftpay"&&s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(dt,{children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsx(ut,{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:fn,onChange:H=>{Vn(H.target.value),jn(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(G,{size:"sm",variant:"outline",onClick:()=>void qt("giftPay",!0),disabled:v,className:"border-gray-600 text-gray-300",children:[s.jsx(Ve,{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:Fe.map(H=>s.jsxs("tr",{className:"hover:bg-[#0a1628]",children:[s.jsx("td",{className:"p-3 font-mono text-xs text-gray-400",children:H.requestSn}),s.jsx("td",{className:"p-3 text-white text-sm",children:H.initiatorNick||H.initiatorUserId}),s.jsxs("td",{className:"p-3",children:[s.jsxs("p",{className:"text-white",children:[H.productType," · ¥",H.amount.toFixed(2)]}),H.description&&s.jsx("p",{className:"text-gray-500 text-xs",children:H.description})]}),s.jsx("td",{className:"p-3 text-gray-400",children:(H.quantity??1)>1?`${H.quantity}份 / 已领${H.redeemedCount??0}`:"-"}),s.jsx("td",{className:"p-3 text-gray-400",children:H.payerNick||(H.payerUserId?H.payerUserId:"-")}),s.jsx("td",{className:"p-3",children:s.jsx(Be,{className:H.status==="paid"?"bg-green-500/20 text-green-400 border-0":H.status==="pending"||H.status==="pending_pay"?"bg-amber-500/20 text-amber-400 border-0":H.status==="refunded"?"bg-red-500/20 text-red-400 border-0":"bg-gray-500/20 text-gray-400 border-0",children:H.status==="paid"?"已支付":H.status==="pending"||H.status==="pending_pay"?"待支付":H.status==="refunded"?"已退款":H.status==="cancelled"?"已取消":"已过期"})}),s.jsx("td",{className:"p-3 text-gray-400 text-xs",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"})]},H.id))})]})}),Fe.length===0&&!v&&s.jsx("p",{className:"text-center py-8 text-gray-500",children:"暂无代付请求"}),pt>20&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(xs,{page:wt,totalPages:Math.ceil(pt/20),total:pt,pageSize:20,onPageChange:jn,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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.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(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{className:"p-0",children:[St.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:St.map(H=>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:H.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:H.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:H.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.boundAt?new Date(H.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:H.expiresAt?new Date(H.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4",children:H.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",H.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},H.id))})]})}),n==="bindings"&&s.jsx(xs,{page:F,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:L,onChange:H=>R(H.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:U,onChange:H=>P(H.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(Ho,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-sm text-gray-300",children:"自动审批"}),s.jsx(Kt,{checked:$,onCheckedChange:vn,disabled:ae,className:"data-[state=checked]:bg-[#38bdac]"})]}),s.jsxs(G,{type:"button",variant:"outline",onClick:()=>void bn(),disabled:v,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent shrink-0",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${v?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(_e,{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(H=>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:[H.userAvatar?s.jsx("img",{src:H.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:(H.userName||H.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:H.userName||H.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",H.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Be,{className:H.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:H.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:H.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:H.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:H.createdAt?new Date(H.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:We(H.status)}),s.jsx("td",{className:"p-4 max-w-[160px]",children:s.jsx("span",{className:`text-xs ${H.status==="rejected"||H.status==="failed"?"text-red-400":"text-gray-400"}`,title:H.remark,children:H.remark||"-"})}),s.jsx("td",{className:"p-4 text-right",children:H.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(G,{size:"sm",onClick:()=>Mn(H.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx($x,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>Hn(H.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(tk,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},H.id))})]})}),n==="withdrawals"&&s.jsx(xs,{page:F,totalPages:rt,total:D,pageSize:Q,onPageChange:O,onPageSizeChange:H=>{re(H),O(1)}})]})})]})]}),s.jsx(Lt,{open:!!I,onOpenChange:H=>!H&&Y(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{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(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:B,onChange:H=>xe(H.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>Y(null),disabled:X,children:"取消"}),s.jsx(G,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Me,disabled:X,children:X?"退款中...":"确认退款"})]})]})}),s.jsx(Lt,{open:!!W,onOpenChange:H=>!H&&Ne(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:he,onChange:H=>de(H.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Ne,disabled:_,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:as,disabled:_||!he.trim(),children:_?"提交中...":"确认拒绝"})]})]})}),n==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(W2,{embedded:!0})})]})}function K8(){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),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState(!1);async function F(){var I,Y,B,xe,X,V,W;i(!0),c(null);try{const fe=new URLSearchParams({status:u,page:String(f),pageSize:String(x)}),he=await Le(`/api/admin/withdrawals?${fe}`);if(he!=null&&he.success){const de=he.withdrawals||[];e(de),w(he.total??((I=he.stats)==null?void 0:I.total)??de.length),r({total:((Y=he.stats)==null?void 0:Y.total)??he.total??de.length,pendingCount:((B=he.stats)==null?void 0:B.pendingCount)??0,pendingAmount:((xe=he.stats)==null?void 0:xe.pendingAmount)??0,successCount:((X=he.stats)==null?void 0:X.successCount)??0,successAmount:((V=he.stats)==null?void 0:V.successAmount)??0,failedCount:((W=he.stats)==null?void 0:W.failedCount)??0})}else c("加载提现记录失败")}catch(fe){console.error("Load withdrawals error:",fe),c("加载失败,请检查网络后重试")}finally{i(!1)}}g.useEffect(()=>{m(1)},[u]),g.useEffect(()=>{F()},[u,f,x]);const O=Math.ceil(N/x)||1;async function Q(I){const Y=t.find(B=>B.id===I);if(Y!=null&&Y.userCommissionInfo&&Y.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${Y.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 -确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const F=await tn("/api/admin/withdrawals",{id:I,action:"approve"});F!=null&&F.success?z():q.error("操作失败: "+((F==null?void 0:F.error)??""))}catch{q.error("操作失败")}finally{k(null)}}async function re(I){if(confirm("确认撤回该笔打款?仅在用户未确认收款前可撤回。")){k(I);try{const Y=await bt("/api/admin/withdrawals/cancel",{id:I});Y!=null&&Y.success?(q.success("已撤回打款"),z()):q.error("撤回失败: "+((Y==null?void 0:Y.error)??"未知错误"))}catch{q.error("撤回失败")}finally{k(null)}}}function D(I){C(I),R("")}async function ne(){const I=T;if(!I)return;const Y=L.trim();if(!Y){q.error("请填写拒绝原因");return}P(!0);try{const F=await tn("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:Y});F!=null&&F.success?(q.success("已拒绝该提现申请"),C(null),R(""),z()):q.error("操作失败: "+((F==null?void 0:F.error)??""))}catch{q.error("操作失败")}finally{P(!1)}}function le(){T&&q.info("已取消操作"),C(null),R("")}function me(I){switch(I){case"pending":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Be,{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(G,{variant:"outline",onClick:z,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{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(Rf,{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(De,{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(De,{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(De,{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(De,{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(G,{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(De,{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(Ve,{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(sd,{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:ya(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(G,{size:"sm",onClick:()=>Q(I.id),disabled:v===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(_p,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>D(I.id),disabled:v===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ns,{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(G,{size:"sm",variant:"outline",onClick:()=>re(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(xs,{page:f,totalPages:O,total:N,pageSize:x,onPageChange:m,onPageSizeChange:I=>{b(I),m(1)}})]})})}),s.jsx(Lt,{open:!!T,onOpenChange:I=>!I&&le(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:L,onChange:I=>R(I.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:le,disabled:U,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ne,disabled:U||!L.trim(),children:U?"提交中...":"确认拒绝"})]})]})})]})}var Yx={exports:{}},Xx={};/** +确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const B=await tn("/api/admin/withdrawals",{id:I,action:"approve"});B!=null&&B.success?F():q.error("操作失败: "+((B==null?void 0:B.error)??""))}catch{q.error("操作失败")}finally{k(null)}}async function re(I){if(confirm("确认撤回该笔打款?仅在用户未确认收款前可撤回。")){k(I);try{const Y=await bt("/api/admin/withdrawals/cancel",{id:I});Y!=null&&Y.success?(q.success("已撤回打款"),F()):q.error("撤回失败: "+((Y==null?void 0:Y.error)??"未知错误"))}catch{q.error("撤回失败")}finally{k(null)}}}function D(I){C(I),R("")}async function ne(){const I=T;if(!I)return;const Y=L.trim();if(!Y){q.error("请填写拒绝原因");return}P(!0);try{const B=await tn("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:Y});B!=null&&B.success?(q.success("已拒绝该提现申请"),C(null),R(""),F()):q.error("操作失败: "+((B==null?void 0:B.error)??""))}catch{q.error("操作失败")}finally{P(!1)}}function le(){T&&q.info("已取消操作"),C(null),R("")}function me(I){switch(I){case"pending":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Be,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Be,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Be,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Be,{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(G,{variant:"outline",onClick:F,disabled:a,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"刷新"]})]}),s.jsx(De,{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(Rf,{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(De,{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(De,{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(De,{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(De,{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(G,{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(De,{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(Ve,{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(sd,{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:ya(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(G,{size:"sm",onClick:()=>Q(I.id),disabled:v===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(_p,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(G,{size:"sm",variant:"outline",onClick:()=>D(I.id),disabled:v===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(ss,{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(G,{size:"sm",variant:"outline",onClick:()=>re(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(xs,{page:f,totalPages:O,total:N,pageSize:x,onPageChange:m,onPageSizeChange:I=>{b(I),m(1)}})]})})}),s.jsx(Lt,{open:!!T,onOpenChange:I=>!I&&le(),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:L,onChange:I=>R(I.target.value)})})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:le,disabled:U,children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ne,disabled:U||!L.trim(),children:U?"提交中...":"确认拒绝"})]})]})})]})}var Yx={exports:{}},Xx={};/** * @license React * use-sync-external-store-shim.production.js * @@ -703,16 +703,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do */var hN;function q8(){if(hN)return Xx;hN=1;var t=Wu();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 Xx.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Xx}var fN;function K2(){return fN||(fN=1,Yx.exports=q8()),Yx.exports}var q2=K2();function ks(t){this.content=t}ks.prototype={constructor:ks,find:function(t){for(var e=0;e>1}};ks.from=function(t){if(t instanceof ks)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ks(e)};function G2(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=G2(a.content,i.content,n+1);if(o!=null)return o}n+=a.nodeSize}}function J2(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?rf(n+1,i):rf(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}};ln.none=[];class Vf extends Error{}class ze{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=Y2(this.content,e+this.openStart,n);return r&&new ze(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ze(Q2(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 ze.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 ze(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 ze(e,r,a)}}ze.empty=new ze(Ce.empty,0,0);function Q2(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(Q2(i.content,e-a-1,n-a-1)))}function Y2(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=Y2(o.content,e-i-1,n,o);return c&&t.replaceChild(a,o.copy(c))}function G8(t,e,n){if(n.openStart>t.depth)throw new Vf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Vf("Inconsistent open depths");return X2(t,e,n,0)}function X2(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 gu(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&&(Dl(t.nodeAfter,r),i++));for(let c=i;ca&&n0(t,e,a+1),o=r.depth>a&&n0(n,r,a+1),c=[];return gu(null,t,a,c),i&&o&&e.index(a)==n.index(a)?(Z2(i,o),Dl(_l(i,eS(t,e,n,r,a+1)),c)):(i&&Dl(_l(i,Hf(t,e,a+1)),c),gu(e,n,a,c),o&&Dl(_l(o,Hf(n,r,a+1)),c)),gu(r,null,a,c),new Ce(c)}function Hf(t,e,n){let r=[];if(gu(null,t,n,r),t.depth>n){let a=n0(t,e,n+1);Dl(_l(a,Hf(t,e,n+1)),r)}return gu(e,null,n,r),new Ce(r)}function J8(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 Iu{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 Uf(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 Iu(n,r,i)}static resolveCached(e,n){let r=pN.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()+")"),tS(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}};$i.prototype.text=void 0;class Wf extends $i{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):tS(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 Wf(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Wf(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 tS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Kl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Z8(e,n);if(r.next==null)return Kl.empty;let a=nS(r);r.next&&r.err("Unexpected trailing text");let i=i6(a6(a));return o6(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(` `)}}Kl.empty=new Kl(!0);class Z8{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 nS(t){let e=[];do e.push(e6(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function e6(t){let e=[];do e.push(t6(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function t6(t){let e=r6(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=n6(t,e);else break;return e}function mN(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function n6(t,e){let n=mN(t),r=n;return t.eat(",")&&(t.next!="}"?r=mN(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function s6(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 r6(t){if(t.eat("(")){let e=nS(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=s6(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 a6(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 Kl(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:aS(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $i(this,this.computeAttrs(e),Ce.from(n),ln.setFrom(r))}createChecked(e=null,n,r){return n=Ce.from(n),this.checkContent(n),new $i(this,this.computeAttrs(e),n,ln.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 $i(this,e,n.append(i),ln.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 lS(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 l6(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 c6{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?l6(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Wp{constructor(e,n,r,a){this.name=e,this.rank=n,this.schema=r,this.spec=a,this.attrs=oS(e,a.attrs),this.excluded=null;let i=rS(this.attrs);this.instance=i?new ln(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ln(this,aS(this.attrs,e))}static compile(e,n){let r=Object.create(null),a=0;return e.forEach((i,o)=>r[i]=new Wp(i,a++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class cS{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=ks.from(e.nodes),n.marks=ks.from(e.marks||{}),this.nodes=gN.compile(this.spec.nodes,this),this.marks=Wp.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]=Kl.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?yN(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==""?[]:yN(this,o.split(" "))}this.nodeFromJSON=a=>$i.fromJSON(this,a),this.markFromJSON=a=>ln.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 gN){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 Wf(r,r.defaultAttrs,e,ln.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 yN(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 d6(t){return t.tag!=null}function u6(t){return t.style!=null}class $o{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(a=>{if(d6(a))this.tags.push(a);else if(u6(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 vN(this,n,!1);return r.addAll(e,ln.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new vN(this,n,!0);return r.addAll(e,ln.none,n.from,n.to),ze.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=NN(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=NN(o)),o.node||o.ignore||o.mark||(o.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $o(e,$o.schemaRules(e)))}}const dS={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},h6={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},uS={ol:!0,ul:!0},Ru=1,r0=2,yu=4;function bN(t,e,n){return e!=null?(e?Ru:0)|(e==="full"?r0:0):t&&t.whitespace=="pre"?Ru|r0:n&~yu}class af{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=ln.none,this.match=i||(o&yu?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&Ru)){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&&!dS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class vN{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=bN(null,n.preserveWhitespace,0)|(r?yu:0);a?i=new af(a.type,a.attrs,ln.none,!0,n.topMatch||a.type.contentMatch,o):r?i=new af(null,null,ln.none,!0,null,o):i=new af(e.schema.topNodeType,null,ln.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&r0?"full":this.localPreserveWS||(a.options&Ru)>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):wN(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new af(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|=Ru)}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 f6(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&uS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function p6(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function NN(t){let e={};for(let n in t)e[n]=t[n];return e}function wN(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&&kf(eg(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return kf(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nc(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=jN(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return jN(e.marks)}}function jN(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function eg(t){return t.document||window.document}const kN=new WeakMap;function m6(t){let e=kN.get(t);return e===void 0&&kN.set(t,e=x6(t)),e}function x6(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}=kf(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 hS=65535,fS=Math.pow(2,16);function g6(t,e){return t+e*fS}function SN(t){return t&hS}function y6(t){return(t-(t&hS))/fS}const pS=1,mS=2,Sf=4,xS=8;class a0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&xS)>0}get deletedBefore(){return(this.delInfo&(pS|Sf))>0}get deletedAfter(){return(this.delInfo&(mS|Sf))>0}get deletedAcross(){return(this.delInfo&Sf)>0}}class Cr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Cr.empty)return Cr.empty}recover(e){let n=0,r=SN(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:g6(c/3,e-u),w=e==u?mS:e==m?pS:Sf;return(n<0?e!=u:e!=m)&&(w|=xS),new a0(b,w,N)}a+=f-h}return r?e+a:new a0(e+a,0,null)}touches(e,n){let r=0,a=SN(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 Lu;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 qn.fromReplace(e,this.from,this.to,i)}invert(){return new ga(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 Io(n.pos,r.pos,this.mark)}merge(e){return e instanceof Io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Io(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 Io(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("addMark",Io);class ga extends Bs{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 ze(xy(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return qn.fromReplace(e,this.from,this.to,r)}invert(){return new Io(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 ga(n.pos,r.pos,this.mark)}merge(e){return e instanceof ga&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ga(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 ga(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("removeMark",ga);class Ro extends Bs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return qn.fromReplace(e,this.pos,this.pos+1,new ze(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 gs(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 gs(n.from,n.to,n.gapFrom,n.gapTo,ze.fromJSON(e,n.slice),n.insert,!!n.structure)}}Bs.jsonID("replaceAround",gs);function i0(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 b6(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 v6(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 Wp){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 ga(o.from,o.to,o.style)))}function gy(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 N6(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function yd(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 gs(a,i,a,i,new ze(r,0,0),n.length,!0))}function C6(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)&&E6(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&&yS(t,o,c,i),gy(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 gs(m,x,m+1,x-1,new ze(Ce.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&gS(t,o,c,i),!1}})}function gS(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 yS(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 E6(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function T6(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 gs(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ze(Ce.from(o),0,0),1,!0))}function zi(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 M6(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 hs(e,e,new ze(i.append(o),n,n),!0))}function tl(t,e){let n=t.resolve(e),r=n.index();return bS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function A6(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&&bS(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 P6(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);yS(t,f.node(),f.before(),c)}o.inlineContent&&gy(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 hs(h,u.map(e+n,-1),ze.empty,!0)),r===!0){let f=t.doc.resolve(h);gS(t,f.node(),f.before(),t.steps.length)}return t}function I6(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 qp(t,e,n=e,r=ze.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return NS(a,i,r)?new hs(e,n,r):new R6(a,i,r).fit()}function NS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class R6{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 ze(i,o,c);return e>-1?new gs(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new hs(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=ng(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=ng(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new ze(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=ng(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new ze(lu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ze(lu(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(wS(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=cu(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=sg(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=cu(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=cu(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=cu(this.placed,this.frontier.length,n))}}function lu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(lu(t.firstChild.content,e-1,n)))}function cu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(cu(t.lastChild.content,e-1,n)))}function ng(t,e){for(let n=0;n1&&(r=r.replaceChild(0,wS(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 sg(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&&!L6(n,i.content,o)?c:null}function L6(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=O6(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 jS(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 _6(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=I6(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new ze(Ce.from(r),0,0))}function $6(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=kS(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 kS(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 ed extends Bs{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 qn.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 qn.fromReplace(e,this.pos,this.pos+1,new ze(Ce.from(a),0,n.isLeaf?0:1))}getMap(){return Cr.empty}invert(e){return new ed(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 ed(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 ed(n.pos,n.attr,n.value)}}Bs.jsonID("attr",ed);class Ou extends Bs{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 qn.ok(r)}getMap(){return Cr.empty}invert(e){return new Ou(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 Ou(n.attr,n.value)}}Bs.jsonID("docAttr",Ou);let rd=class extends Error{};rd=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rd.prototype=Object.create(Error.prototype);rd.prototype.constructor=rd;rd.prototype.name="TransformError";class by{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Lu}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rd(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=ze.empty){let a=qp(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new ze(Ce.from(r),0,0))}delete(e,n){return this.replace(e,n,ze.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return D6(this,e,n,r),this}replaceRangeWith(e,n,r){return _6(this,e,n,r),this}deleteRange(e,n){return $6(this,e,n),this}lift(e,n){return w6(this,e,n),this}join(e,n=1){return P6(this,e,n),this}wrap(e,n){return S6(this,e,n),this}setBlockType(e,n=e,r,a=null){return C6(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return T6(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new ed(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ou(e,n)),this}addNodeMark(e,n){return this.step(new Ro(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 ln)n.isInSet(r.marks)&&this.step(new ql(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new ql(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 M6(this,e,n,r),this}addMark(e,n,r){return b6(this,e,n,r),this}removeMark(e,n,r){return v6(this,e,n,r),this}clearIncompatible(e,n,r){return gy(this,e,n,r),this}}const rg=Object.create(null);class ft{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new SS(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?Uc(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Uc(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 Tr(e.node(0))}static atStart(e){return Uc(e,e,0,0,1)||new Tr(e)}static atEnd(e){return Uc(e,e,e.content.size,e.childCount,-1)||new Tr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=rg[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 rg)throw new RangeError("Duplicate use of selection JSON ID "+e);return rg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ot.between(this.$anchor,this.$head).getBookmark()}}ft.prototype.visible=!0;class SS{constructor(e,n){this.$from=e,this.$to=n}}let EN=!1;function TN(t){!EN&&!t.parent.inlineContent&&(EN=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ot extends ft{constructor(e,n=e){TN(e),TN(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 ft.near(r);let a=e.resolve(n.map(this.anchor));return new ot(a.parent.inlineContent?a:r,r)}replace(e,n=ze.empty){if(super.replace(e,n),n==ze.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ot&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gp(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 ot(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=ft.findFrom(n,r,!0)||ft.findFrom(n,-r,!0);if(i)n=i.$head;else return ft.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ft.findFrom(e,-r,!0)||ft.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&&it.isSelectable(c))return it.create(t,n-(a<0?c.nodeSize:0))}else{let u=Uc(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function MN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ft.near(t.doc.resolve(o),n))}const AN=1,of=2,PN=4;class F6 extends by{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|=of,this}ensureMarks(e){return ln.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&of)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~of,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)||ln.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(ft.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|=PN,this}get scrolledIntoView(){return(this.updated&PN)>0}}function IN(t,e){return!e||!t?t:t.bind(e)}class du{constructor(e,n,r){this.name=e,this.init=IN(n.init,r),this.apply=IN(n.apply,r)}}const B6=[new du("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new du("selection",{init(t,e){return t.selection||ft.atStart(e.doc)},apply(t){return t.selection}}),new du("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new du("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ag{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=B6.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 du(r.key,r.spec.state,r))})}}class Yc{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 ag(e.schema,e.plugins),i=new Yc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=$i.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ft.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 CS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=CS(a,e,{})),n[r]=a}return n}class hn{constructor(e){this.spec=e,this.props={},e.props&&CS(e.props,this,this.props),this.key=e.key?e.key.key:ES("plugin")}getState(e){return e[this.key]}}const ig=Object.create(null);function ES(t){return t in ig?t+"$"+ ++ig[t]:(ig[t]=0,t+"$")}class wn{constructor(e="key"){this.key=ES(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ny=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function TS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const MS=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);if(!a){let o=r.blockRange(),c=o&&yd(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&&(ad(i,"end")||it.isSelectable(i)))for(let o=r.depth;;o--){let c=qp(t.doc,r.before(o),r.after(o),ze.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},V6=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);return a?AS(t,a,e):!1},H6=(t,e,n)=>{let r=IS(t,n);if(!r)return!1;let a=jy(r);return a?AS(t,a,e):!1};function AS(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=qp(t.doc,i,u,ze.empty);if(!h||h.from!=i||h instanceof hs&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(ot.create(f.doc,i)),n(f.scrollIntoView())}return!0}function ad(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 PS=(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=wy(r)}let o=i&&i.nodeBefore;return!o||!it.isSelectable(o)?!1:(e&&e(t.tr.setSelection(it.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function wy(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 IS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=IS(t,n);if(!r)return!1;let a=jy(r);if(!a)return!1;let i=a.nodeAfter;if($S(t,a,e,1))return!0;if(r.parent.content.size==0&&(ad(i,"start")||it.isSelectable(i))){let o=qp(t.doc,r.before(),r.after(),ze.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 it,a;if(r){if(n.node.isTextblock||!tl(t.doc,n.from))return!1;a=n.from}else if(a=Kp(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(it.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},W6=(t,e)=>{let n=t.selection,r;if(n instanceof it){if(n.node.isTextblock||!tl(t.doc,n.to))return!1;r=n.to}else if(r=Kp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},K6=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&yd(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},OS=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` +`),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):wN(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new af(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|=Ru)}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 f6(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&uS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function p6(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function NN(t){let e={};for(let n in t)e[n]=t[n];return e}function wN(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&&kf(eg(r),a(e,n),null,e.attrs)}static renderSpec(e,n,r=null,a){return kf(e,n,r,a)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nc(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=jN(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return jN(e.marks)}}function jN(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function eg(t){return t.document||window.document}const kN=new WeakMap;function m6(t){let e=kN.get(t);return e===void 0&&kN.set(t,e=x6(t)),e}function x6(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}=kf(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 hS=65535,fS=Math.pow(2,16);function g6(t,e){return t+e*fS}function SN(t){return t&hS}function y6(t){return(t-(t&hS))/fS}const pS=1,mS=2,Sf=4,xS=8;class a0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&xS)>0}get deletedBefore(){return(this.delInfo&(pS|Sf))>0}get deletedAfter(){return(this.delInfo&(mS|Sf))>0}get deletedAcross(){return(this.delInfo&Sf)>0}}class Cr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Cr.empty)return Cr.empty}recover(e){let n=0,r=SN(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:g6(c/3,e-u),w=e==u?mS:e==m?pS:Sf;return(n<0?e!=u:e!=m)&&(w|=xS),new a0(b,w,N)}a+=f-h}return r?e+a:new a0(e+a,0,null)}touches(e,n){let r=0,a=SN(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 Lu;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 Gn.fromReplace(e,this.from,this.to,i)}invert(){return new ga(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 Io(n.pos,r.pos,this.mark)}merge(e){return e instanceof Io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Io(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 Io(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("addMark",Io);class ga extends Bs{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 ze(xy(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return Gn.fromReplace(e,this.from,this.to,r)}invert(){return new Io(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 ga(n.pos,r.pos,this.mark)}merge(e){return e instanceof ga&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ga(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 ga(n.from,n.to,e.markFromJSON(n.mark))}}Bs.jsonID("removeMark",ga);class Ro extends Bs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Gn.fromReplace(e,this.pos,this.pos+1,new ze(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 gs(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 gs(n.from,n.to,n.gapFrom,n.gapTo,ze.fromJSON(e,n.slice),n.insert,!!n.structure)}}Bs.jsonID("replaceAround",gs);function i0(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 b6(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 v6(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 Wp){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 ga(o.from,o.to,o.style)))}function gy(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 N6(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function yd(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 gs(a,i,a,i,new ze(r,0,0),n.length,!0))}function C6(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)&&E6(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&&yS(t,o,c,i),gy(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 gs(m,x,m+1,x-1,new ze(Ce.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&gS(t,o,c,i),!1}})}function gS(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 yS(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 E6(t,e,n){let r=t.resolve(e),a=r.index();return r.parent.canReplaceWith(a,a+1,n)}function T6(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 gs(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ze(Ce.from(o),0,0),1,!0))}function zi(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 M6(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 hs(e,e,new ze(i.append(o),n,n),!0))}function tl(t,e){let n=t.resolve(e),r=n.index();return bS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function A6(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&&bS(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 P6(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);yS(t,f.node(),f.before(),c)}o.inlineContent&&gy(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 hs(h,u.map(e+n,-1),ze.empty,!0)),r===!0){let f=t.doc.resolve(h);gS(t,f.node(),f.before(),t.steps.length)}return t}function I6(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 qp(t,e,n=e,r=ze.empty){if(e==n&&!r.size)return null;let a=t.resolve(e),i=t.resolve(n);return NS(a,i,r)?new hs(e,n,r):new R6(a,i,r).fit()}function NS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class R6{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 ze(i,o,c);return e>-1?new gs(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new hs(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=ng(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=ng(e,n);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new ze(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=ng(e,n);if(a.childCount<=1&&n>0){let i=e.size-n<=n+a.size;this.unplaced=new ze(lu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ze(lu(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(wS(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=cu(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=sg(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=cu(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=cu(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=cu(this.placed,this.frontier.length,n))}}function lu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(lu(t.firstChild.content,e-1,n)))}function cu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(cu(t.lastChild.content,e-1,n)))}function ng(t,e){for(let n=0;n1&&(r=r.replaceChild(0,wS(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 sg(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&&!L6(n,i.content,o)?c:null}function L6(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=O6(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 jS(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 _6(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let a=I6(t.doc,e,r.type);a!=null&&(e=n=a)}t.replaceRange(e,n,new ze(Ce.from(r),0,0))}function $6(t,e,n){let r=t.doc.resolve(e),a=t.doc.resolve(n),i=kS(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 kS(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 ed extends Bs{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 Gn.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 Gn.fromReplace(e,this.pos,this.pos+1,new ze(Ce.from(a),0,n.isLeaf?0:1))}getMap(){return Cr.empty}invert(e){return new ed(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 ed(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 ed(n.pos,n.attr,n.value)}}Bs.jsonID("attr",ed);class Ou extends Bs{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 Gn.ok(r)}getMap(){return Cr.empty}invert(e){return new Ou(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 Ou(n.attr,n.value)}}Bs.jsonID("docAttr",Ou);let rd=class extends Error{};rd=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rd.prototype=Object.create(Error.prototype);rd.prototype.constructor=rd;rd.prototype.name="TransformError";class by{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Lu}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rd(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=ze.empty){let a=qp(this.doc,e,n,r);return a&&this.step(a),this}replaceWith(e,n,r){return this.replace(e,n,new ze(Ce.from(r),0,0))}delete(e,n){return this.replace(e,n,ze.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return D6(this,e,n,r),this}replaceRangeWith(e,n,r){return _6(this,e,n,r),this}deleteRange(e,n){return $6(this,e,n),this}lift(e,n){return w6(this,e,n),this}join(e,n=1){return P6(this,e,n),this}wrap(e,n){return S6(this,e,n),this}setBlockType(e,n=e,r,a=null){return C6(this,e,n,r,a),this}setNodeMarkup(e,n,r=null,a){return T6(this,e,n,r,a),this}setNodeAttribute(e,n,r){return this.step(new ed(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ou(e,n)),this}addNodeMark(e,n){return this.step(new Ro(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 ln)n.isInSet(r.marks)&&this.step(new ql(e,n));else{let a=r.marks,i,o=[];for(;i=n.isInSet(a);)o.push(new ql(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 M6(this,e,n,r),this}addMark(e,n,r){return b6(this,e,n,r),this}removeMark(e,n,r){return v6(this,e,n,r),this}clearIncompatible(e,n,r){return gy(this,e,n,r),this}}const rg=Object.create(null);class ft{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new SS(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?Uc(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Uc(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 Tr(e.node(0))}static atStart(e){return Uc(e,e,0,0,1)||new Tr(e)}static atEnd(e){return Uc(e,e,e.content.size,e.childCount,-1)||new Tr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=rg[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 rg)throw new RangeError("Duplicate use of selection JSON ID "+e);return rg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ot.between(this.$anchor,this.$head).getBookmark()}}ft.prototype.visible=!0;class SS{constructor(e,n){this.$from=e,this.$to=n}}let EN=!1;function TN(t){!EN&&!t.parent.inlineContent&&(EN=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ot extends ft{constructor(e,n=e){TN(e),TN(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 ft.near(r);let a=e.resolve(n.map(this.anchor));return new ot(a.parent.inlineContent?a:r,r)}replace(e,n=ze.empty){if(super.replace(e,n),n==ze.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ot&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gp(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 ot(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=ft.findFrom(n,r,!0)||ft.findFrom(n,-r,!0);if(i)n=i.$head;else return ft.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(ft.findFrom(e,-r,!0)||ft.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&&it.isSelectable(c))return it.create(t,n-(a<0?c.nodeSize:0))}else{let u=Uc(t,c,n+a,a<0?c.childCount:0,a,i);if(u)return u}n+=c.nodeSize*a}return null}function MN(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(ft.near(t.doc.resolve(o),n))}const AN=1,of=2,PN=4;class F6 extends by{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|=of,this}ensureMarks(e){return ln.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&of)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~of,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)||ln.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(ft.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|=PN,this}get scrolledIntoView(){return(this.updated&PN)>0}}function IN(t,e){return!e||!t?t:t.bind(e)}class du{constructor(e,n,r){this.name=e,this.init=IN(n.init,r),this.apply=IN(n.apply,r)}}const B6=[new du("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new du("selection",{init(t,e){return t.selection||ft.atStart(e.doc)},apply(t){return t.selection}}),new du("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new du("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ag{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=B6.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 du(r.key,r.spec.state,r))})}}class Yc{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 ag(e.schema,e.plugins),i=new Yc(a);return a.fields.forEach(o=>{if(o.name=="doc")i.doc=$i.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ft.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 CS(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=CS(a,e,{})),n[r]=a}return n}class hn{constructor(e){this.spec=e,this.props={},e.props&&CS(e.props,this,this.props),this.key=e.key?e.key.key:ES("plugin")}getState(e){return e[this.key]}}const ig=Object.create(null);function ES(t){return t in ig?t+"$"+ ++ig[t]:(ig[t]=0,t+"$")}class wn{constructor(e="key"){this.key=ES(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ny=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function TS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const MS=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);if(!a){let o=r.blockRange(),c=o&&yd(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&&(ad(i,"end")||it.isSelectable(i)))for(let o=r.depth;;o--){let c=qp(t.doc,r.before(o),r.after(o),ze.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},V6=(t,e,n)=>{let r=TS(t,n);if(!r)return!1;let a=wy(r);return a?AS(t,a,e):!1},H6=(t,e,n)=>{let r=IS(t,n);if(!r)return!1;let a=jy(r);return a?AS(t,a,e):!1};function AS(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=qp(t.doc,i,u,ze.empty);if(!h||h.from!=i||h instanceof hs&&h.slice.size>=u-i)return!1;if(n){let f=t.tr.step(h);f.setSelection(ot.create(f.doc,i)),n(f.scrollIntoView())}return!0}function ad(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 PS=(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=wy(r)}let o=i&&i.nodeBefore;return!o||!it.isSelectable(o)?!1:(e&&e(t.tr.setSelection(it.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function wy(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 IS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=IS(t,n);if(!r)return!1;let a=jy(r);if(!a)return!1;let i=a.nodeAfter;if($S(t,a,e,1))return!0;if(r.parent.content.size==0&&(ad(i,"start")||it.isSelectable(i))){let o=qp(t.doc,r.before(),r.after(),ze.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 it,a;if(r){if(n.node.isTextblock||!tl(t.doc,n.from))return!1;a=n.from}else if(a=Kp(t.doc,n.from,-1),a==null)return!1;if(e){let i=t.tr.join(a);r&&i.setSelection(it.create(i.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},W6=(t,e)=>{let n=t.selection,r;if(n instanceof it){if(n.node.isTextblock||!tl(t.doc,n.to))return!1;r=n.to}else if(r=Kp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},K6=(t,e)=>{let{$from:n,$to:r}=t.selection,a=n.blockRange(r),i=a&&yd(a);return i==null?!1:(e&&e(t.tr.lift(a,i).scrollIntoView()),!0)},OS=(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 ky(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=ky(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(ft.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},DS=(t,e)=>{let n=t.selection,{$from:r,$to:a}=n;if(n instanceof Tr||r.parent.inlineContent||a.parent.inlineContent)return!1;let i=ky(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(zi(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),a=r&&yd(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)};function G6(t){return(e,n)=>{let{$from:r,$to:a}=e.selection;if(e.selection instanceof it&&e.selection.node.isBlock)return!r.parentOffset||!zi(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=ky(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 ot||e.selection instanceof Tr)&&f.deleteSelection();let m=f.mapping.map(r.pos),x=zi(f.doc,m,i.length,i);if(x||(i[0]=c?{type:c}:null,x=zi(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 J6=G6(),Q6=(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(it.create(t.doc,a))),!0)};function Y6(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||tl(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&&Y6(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 gs(e.pos-1,b,e.pos,b,new ze(N,1,0),o.length,!0)),v=w.doc.resolve(b+2*o.length);v.nodeAfter&&v.nodeAfter.type==a.type&&tl(w.doc,v.pos)&&w.join(v.pos),n(w.scrollIntoView())}return!0}let f=i.type.spec.isolating||r>0&&u?null:ft.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),x=m&&yd(m);if(x!=null&&x>=e.depth)return n&&n(t.tr.lift(m,x).scrollIntoView()),!0;if(h&&ad(i,"start",!0)&&ad(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 C=N.length-1;C>=0;C--)k=Ce.from(N[C].copy(k));let T=t.tr.step(new gs(e.pos-N.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new ze(k,N.length,0),0,!0));n(T.scrollIntoView())}return!0}}return!1}function zS(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(ot.create(e.doc,t<0?a.start(i):a.end(i)))),!0):!1}}const X6=zS(-1),Z6=zS(1);function eL(t,e=null){return function(n,r){let{$from:a,$to:i}=n.selection,o=a.blockRange(i),c=o&&yy(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function RN(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 Uf(u,u,e.depth),e.endIndex=0;f--)i=Ce.from(n[f].type.create(n[f].attrs,i));t.step(new gs(e.start-(r?2:0),e.end,e.start,e.end,new ze(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?aL(e,n,t,i):iL(e,n,i):!0:!1}}function aL(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 gs(m-(c?1:0),x+(u?1:0),m+1,x-1,new ze((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 oL(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 ze(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 gs(x-(h?3:1),b,x,b,m,1,!0)).scrollIntoView())}return!0}}const Ss=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},id=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let o0=null;const Ti=function(t,e,n){let r=o0||(o0=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},lL=function(){o0=null},Gl=function(t,e,n,r){return n&&(LN(t,e,n,r,-1)||LN(t,e,n,r,1))},cL=/^(img|br|input|textarea|hr)$/i;function LN(t,e,n,r,a){for(var i;;){if(t==n&&e==r)return!0;if(e==(a<0?0:qr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ju(t)||cL.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ss(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?qr(t):0}else return!1}}function qr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function dL(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=qr(t)}else if(t.parentNode&&!Ju(t))e=Ss(t),t=t.parentNode;else return null}}function uL(t,e){for(;;){if(t.nodeType==3&&e2),Kr=od||(Ga?/Mac/.test(Ga.platform):!1),VS=Ga?/Win/.test(Ga.platform):!1,Oi=/Android \d/.test(nl),Qu=!!ON&&"webkitFontSmoothing"in ON.documentElement.style,mL=Qu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function xL(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 ji(t,e){return typeof t=="number"?t:t[e]}function gL(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 DN(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=id(o);continue}let c=o,u=c==i.body,h=u?xL(i):gL(c),f=0,m=0;if(e.toph.bottom-ji(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ji(a,"top")-h.top:e.bottom-h.bottom+ji(a,"bottom")),e.lefth.right-ji(r,"right")&&(f=e.right-h.right+ji(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:id(o)}}function yL(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:HS(t.dom)}}function HS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=id(r));return e}function bL({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;US(n,r==0?0:r-e)}function US(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?NL(n,a):!n||r&&n.nodeType==1?{node:t,offset:i}:WS(n,a)}function NL(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 Cy(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function wL(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 kL(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 KS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&a++}let h;Qu&&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=kL(t,r,a,e))}c==null&&(c=jL(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function _N(t){return t.top=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:h++,ru(No(Ti(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&a&&(n<0||a==qr(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return og(u.getBoundingClientRect(),!1)}if(i==null&&a=0)}if(i==null&&a&&(n<0||a==qr(r))){let u=r.childNodes[a-1],h=u.nodeType==3?Ti(u,qr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return ru(No(h,1),!1)}if(i==null&&a=0)}function ru(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 og(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 GS(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 EL(t,e,n){let r=e.selection,a=n=="up"?r.$from:r.$to;return GS(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=qS(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=Ti(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 TL=/[\u0590-\u08ac]/;function ML(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?!TL.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:GS(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,zN=null,FN=!1;function AL(t,e,n){return $N==e&&zN==n?FN:($N=e,zN=n,FN=n=="up"||n=="down"?EL(t,e,n):ML(t,e,n))}const Jr=0,BN=1,Il=2,Ja=3;class Yu{constructor(e,n,r,a){this.parent=e,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=Jr,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;nSs(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 QS){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 JS&&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?Ss(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=Ss(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?Il:BN,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ja:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Il:Ja}r=o}this.dirty=Il}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Il:BN;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==Jr&&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 PL extends Yu{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 Jl extends Yu{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=nc.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Jl(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ja||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ja&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Jr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=h0(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}=nc.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=ZS(f,r,n),h?u=new IL(e,n,r,a,f,m||null,x,h,i,o+1):n.isText?new Qp(e,n,r,a,f,x,i):new Fo(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==Jr&&e.eq(this.node)&&Kf(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 LL(this,o&&o.node,e);_L(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?ln.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==Il)&&(o&&this.protectLocalComposition(e,o),YS(this.contentDOM,this.children,e),od&&$L(this.dom))}localCompositionInfo(e,n){let{from:r,to:a}=e.state.selection;if(!(e.state.selection instanceof ot)||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=zL(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 PL(this,i,n,a);e.input.compositionNodes.push(o),this.children=h0(this.children,r,r+a.length,e,o)}update(e,n,r,a){return this.dirty==Ja||!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=Jr}updateOuterDeco(e){if(Kf(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=XS(this.dom,this.nodeDOM,u0(this.outerDeco,this.node,n),u0(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 VN(t,e,n,r,a){ZS(r,e,t);let i=new Fo(void 0,t,e,n,r,r,r,a,0);return i.contentDOM&&i.updateChildren(a,0),i}class Qp extends Fo{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==Ja||this.dirty!=Jr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Jr||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=Jr,!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 Qp(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=Ja)}get domAtom(){return!1}isText(e){return this.node.text==e}}class QS extends Yu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Jr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class IL extends Fo{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==Ja)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 YS(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=Jl.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 Jl)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 DL(t,e){return t.type.side-e.type.side}function _L(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 $L(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 zL(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 h0(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 Ey(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(Jp(n)){for(u=o;a&&!a.node;)a=a.parent;let m=a.node;if(a&&m.isAtom&&it.isSelectable(m)&&a.parent&&!(m.isInline&&hL(n.focusNode,n.focusOffset,a.dom))){let x=a.posBefore;h=new it(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(()=>{(!eC(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function BL(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ss(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&fr&&zo<=11&&(n.disabled=!0,n.disabled=!1)}function tC(t,e){if(e instanceof it){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(qN(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else qN(t)}function qN(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ty(t,e,n,r){return t.someProp("createSelectionBetween",a=>a(t,e,n))||ot.between(e,n,r)}function GN(t){return t.editable&&!t.hasFocus()?!1:nC(t)}function nC(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 VL(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Gl(e.node,e.offset,n.anchorNode,n.anchorOffset)}function f0(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&&ft.findFrom(i,e)}function wo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function JN(t,e,n){let r=t.state.selection;if(r instanceof ot)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 wo(t,new ot(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let a=f0(t.state,e);return a&&a instanceof it?wo(t,a):!1}else if(!(Kr&&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?it.isSelectable(i)?wo(t,new it(e<0?t.state.doc.resolve(a.pos-i.nodeSize):a)):Qu?wo(t,new ot(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof it&&r.node.isInline)return wo(t,new ot(e>0?r.$to:r.$from));{let a=f0(t.state,e);return a?wo(t,a):!1}}}function qf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function vu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Vc(t,e){return e<0?HL(t):UL(t)}function HL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a,i,o=!1;for(Gr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(vu(c,-1))a=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(sC(n))break;{let c=n.previousSibling;for(;c&&vu(c,-1);)a=n.parentNode,i=Ss(c),c=c.previousSibling;if(c)n=c,r=qf(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?p0(t,n,r):a&&p0(t,a,i)}function UL(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let a=qf(n),i,o;for(;;)if(r{t.state==a&&Fi(t)},50)}function QN(t,e){let n=t.state.doc.resolve(e);if(!(Es||VS)&&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 YN(t,e,n){let r=t.state.selection;if(r instanceof ot&&!r.empty||n.indexOf("s")>-1||Kr&&n.indexOf("m")>-1)return!1;let{$from:a,$to:i}=r;if(!a.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=f0(t.state,e);if(o&&o instanceof it)return wo(t,o)}if(!a.parent.inlineContent){let o=e<0?a:i,c=r instanceof Tr?ft.near(o,e):ft.findFrom(o,e);return c?wo(t,c):!1}return!1}function XN(t,e){if(!(t.state.selection instanceof ot))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 ZN(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function qL(t){if(!zs||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;ZN(t,r,"true"),setTimeout(()=>ZN(t,r,"false"),20)}return!1}function GL(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function JL(t,e){let n=e.keyCode,r=GL(e);if(n==8||Kr&&n==72&&r=="c")return XN(t,-1)||Vc(t,-1);if(n==46&&!e.shiftKey||Kr&&n==68&&r=="c")return XN(t,1)||Vc(t,1);if(n==13||n==27)return!0;if(n==37||Kr&&n==66&&r=="c"){let a=n==37?QN(t,t.state.selection.from)=="ltr"?-1:1:-1;return JN(t,a,r)||Vc(t,a)}else if(n==39||Kr&&n==70&&r=="c"){let a=n==39?QN(t,t.state.selection.from)=="ltr"?1:-1:1;return JN(t,a,r)||Vc(t,a)}else{if(n==38||Kr&&n==80&&r=="c")return YN(t,-1,r)||Vc(t,-1);if(n==40||Kr&&n==78&&r=="c")return qL(t)||YN(t,1,r)||Vc(t,1);if(r==(Kr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function My(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")||nc.fromSchema(t.state.schema),c=cC(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=lC[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 rC(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 ze(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=nc.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=ZL(n),Qu&&eO(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")||$o.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(x){return x.nodeName=="BR"&&!x.nextSibling&&x.parentNode&&!QL.test(x.parentNode.nodeName)?{ignore:!0}:null}})),f)c=tO(ew(c,+f[1],+f[2]),f[4]);else if(c=ze.maxOpen(YL(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 QL=/^(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 YL(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&&iC(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=oC(o[o.length-1],i.length));let f=aC(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ce.from(o)}return t}function aC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ce.from(t));return t}function iC(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 ew(t,e,n){return en})),cg.createHTML(t)):t}function ZL(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=cC().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&lC[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=XL(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 ze(a,i,o)}const Gs={},Js={},nO={touchstart:!0,touchmove:!0};class sO{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 rO(t){for(let e in Gs){let n=Gs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{iO(t,r)&&!Ay(t,r)&&(t.editable||!(r.type in Js))&&n(t,r)},nO[e]?{passive:!0}:void 0)}zs&&t.dom.addEventListener("input",()=>null),x0(t)}function Lo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function aO(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 x0(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Ay(t,r))})}function Ay(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function iO(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 oO(t,e){!Ay(t,e)&&Gs[e.type]&&(t.editable||!(e.type in Js))&&Gs[e.type](t,e)}Js.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!uC(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Oi&&Es&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),od&&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,Pl(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||JL(t,n)?n.preventDefault():Lo(t,"key")};Js.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Js.keypress=(t,e)=>{let n=e;if(uC(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Kr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ot)||!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 Yp(t){return{left:t.clientX,top:t.clientY}}function lO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Py(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 td(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 cO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&it.isSelectable(r)?(td(t,new it(n)),!0):!1}function dO(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof it&&(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(it.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?(td(t,it.create(t.state.doc,a)),!0):!1}function uO(t,e,n,r,a){return Py(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?dO(t,n):cO(t,n))}function hO(t,e,n,r){return Py(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function fO(t,e,n,r){return Py(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||pO(t,n,r)}function pO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(td(t,ot.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)td(t,ot.create(r,c+1,c+1+o.content.size));else if(it.isSelectable(o))td(t,it.create(r,c));else continue;return!0}}function Iy(t){return Gf(t)}const dC=Kr?"metaKey":"ctrlKey";Gs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Iy(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&lO(n,t.input.lastClick)&&!n[dC]&&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(Yp(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new mO(t,o,n,!!r)):(i=="doubleClick"?hO:fO)(t,o.pos,o.inside,n)?n.preventDefault():Lo(t,"pointer"))};class mO{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[dC],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 it&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Gr&&!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)),Lo(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(()=>Fi(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(Yp(e))),this.updateAllowDefault(e),this.allowDefault||!n?Lo(this.view,"pointer"):uO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||zs&&this.mightDrag&&!this.mightDrag.node.isAtom||Es&&!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)?(td(this.view,ft.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Lo(this.view,"pointer")}move(e){this.updateAllowDefault(e),Lo(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)}}Gs.touchstart=t=>{t.input.lastTouch=Date.now(),Iy(t),Lo(t,"pointer")};Gs.touchmove=t=>{t.input.lastTouch=Date.now(),Lo(t,"pointer")};Gs.contextmenu=t=>Iy(t);function uC(t,e){return t.composing?!0:zs&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const xO=Oi?5e3:-1;Js.compositionstart=Js.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ot&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Es&&VS&&gO(t)))t.markCursor=t.state.storedMarks||n.marks(),Gf(t,!0),t.markCursor=null;else if(Gf(t,!e.selection.empty),Gr&&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}hC(t,xO)};function gO(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"}Js.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++,hC(t,20))};function hC(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Gf(t),e))}function fC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=bO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function yO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=dL(e.focusNode,e.focusOffset),r=uL(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 bO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Gf(t,e=!1){if(!(Oi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),fC(t),e||t.docView&&t.docView.dirty){let n=Ey(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 vO(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 Du=fr&&zo<15||od&&mL<604;Gs.copy=Js.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=Du?null:n.clipboardData,o=r.content(),{dom:c,text:u}=My(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):vO(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function NO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function wO(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?_u(t,r.value,null,a,e):_u(t,r.textContent,r.innerHTML,a,e)},50)}function _u(t,e,n,r,a){let i=rC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||ze.empty)))return!0;if(!i)return!1;let o=NO(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 pC(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," "):""}Js.paste=(t,e)=>{let n=e;if(t.composing&&!Oi)return;let r=Du?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&_u(t,pC(r),r.getData("text/html"),a,n)?n.preventDefault():wO(t,n)};class mC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const jO=Kr?"altKey":"ctrlKey";function xC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[jO]}Gs.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(Yp(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof it?a.to-1:a.to))){if(r&&r.mightDrag)o=it.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=it.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=My(t,c);(!n.dataTransfer.files.length||!Es||BS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Du?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Du||n.dataTransfer.setData("text/plain",h),t.dragging=new mC(f,xC(t,n),o)};Gs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Js.dragover=Js.dragenter=(t,e)=>e.preventDefault();Js.drop=(t,e)=>{try{kO(t,e,t.dragging)}finally{t.dragging=null}};function kO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Yp(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=rC(t,pC(e.dataTransfer),Du?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&xC(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||ze.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?vS(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&&it.isSelectable(i.content.firstChild)&&x.nodeAfter&&x.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new it(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(Ty(t,x,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Gs.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())&&Fi(t)},20))};Gs.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)};Gs.beforeinput=(t,e)=>{if(Es&&Oi&&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,Pl(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 Js)Gs[t]=Js[t];function $u(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 Jf{constructor(e,n){this.toDOM=e,this.spec=n||$l,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 ss(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Jf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$u(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Bo{constructor(e,n){this.attrs=e,this.spec=n||$l}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 ss(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==_s||e.maps.length==0?this:this.mapInner(e,n,0,0,r||$l)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=yC(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 Bo){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,$l));return So.from(r)}forChild(e,n){if(n.isLeaf)return on.empty;let r=[];for(let a=0;an instanceof on)?e:e.reduce((n,r)=>n.concat(r instanceof on?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let v=w-N-(b-x);for(let k=0;kT+f-m)continue;let C=c[k]+f-m;b>=C?c[k+1]=x<=C?-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!=_s?(c[h]=m,c[h+1]=b,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=CO(c,t,e,n,a,i,o),f=Qf(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=yC(t,c,u+n);if(h){i=!0;let f=Qf(h,c,n+u+1,r);f!=_s&&a.push(u,u+c.nodeSize,f)}});let o=gC(i?bC(t):t,-n).sort(zl);for(let c=0;c0;)e++;t.splice(e,0,n)}function dg(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=_s&&e.push(r)}),t.cursorWrapper&&e.push(on.create(t.state.doc,[t.cursorWrapper.deco])),So.from(e)}const EO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},TO=fr&&zo<=11;class MO{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 AO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new MO,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():zs&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),TO&&(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,EO)),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(GN(this.view)){if(this.suppressingSelectionUpdates)return Fi(this.view);if(fr&&zo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Gl(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=id(i))n.add(i);for(let i=e.anchorNode;i;i=id(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)&&GN(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(Gr&&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||RO(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),PO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,LO(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Fi(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],T=k.pmViewDesc;if(k.nodeName=="BR"&&!T){i=v;break}if(!T||T.size)break}let m=t.state.doc,x=t.someProp("domParser")||$o.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:DO,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 DO(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(zs&&/^(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||zs&&/^(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 _O=/^(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 $O(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,z=Ey(t,P);if(z&&!t.state.selection.eq(z)){if(Es&&Oi&&t.input.lastKeyCode===13&&Date.now()-100Q(t,Pl(13,"Enter"))))return;let O=t.state.tr.setSelection(z);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=OO(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||Oi)&&a.some(P=>P.nodeType==1&&!_O.test(P.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",P=>P(t,Pl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(r&&u instanceof ot&&!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=iw(t,t.state.doc,h.sel);if(P&&!P.eq(t.state.selection)){let z=t.state.tr.setSelection(P);i&&z.setMeta("composition",i),t.dispatch(z)}}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)),fr&&zo<=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),T=w.sameParent(v)&&w.parent.inlineContent&&k.end()>=N.endA;if((od&&t.input.lastIOSEnter>Date.now()-225&&(!T||a.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!T&&w.posP(t,Pl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&FO(f,N.start,N.endA,w,v)&&t.someProp("handleKeyDown",P=>P(t,Pl(8,"Backspace")))){Oi&&Es&&t.domObserver.suppressSelectionUpdates();return}Es&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),Oi&&!T&&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,Pl(13,"Enter"))})},20));let C=N.start,L=N.endA,R=P=>{let z=P||t.state.tr.replace(C,L,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let O=iw(t,z.doc,h.sel);O&&!(Es&&t.composing&&O.empty&&(N.start!=N.endB||t.input.lastChromeDeleteFi(t),20));let P=R(t.state.tr.delete(C,L)),z=f.resolve(N.start).marksAcross(f.resolve(N.endA));z&&P.ensureMarks(z),t.dispatch(P)}else if(N.endA==N.endB&&(U=zO(w.parent.content.cut(w.parentOffset,v.parentOffset),k.parent.content.cut(k.parentOffset,N.endA-k.start())))){let P=R(t.state.tr);U.type=="add"?P.addMark(C,L,U.mark):P.removeMark(C,L,U.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),z=()=>R(t.state.tr.insertText(P,C,L));t.someProp("handleTextInput",O=>O(t,C,L,P,z))||t.dispatch(z())}else t.dispatch(R());else t.dispatch(R())}function iw(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ty(t,e.resolve(n.anchor),e.resolve(n.head))}function zO(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||ug(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 BO(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 vC{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 sO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(hw),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=dw(this),cw(this),this.nodeViews=uw(this),this.docView=VN(this.state.doc,lw(this),dg(this),this.dom,this),this.domObserver=new AO(this,(r,a,i,o)=>$O(this,r,a,i,o)),this.domObserver.start(),rO(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&&x0(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(hw),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&&(fC(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=uw(this);HO(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&x0(this),this.editable=dw(this),cw(this);let u=dg(this),h=lw(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&&yL(this);if(o){this.domObserver.stop();let b=m&&(fr||Es)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&VO(a.selection,e.selection);if(m){let N=Es?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=yO(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=VN(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())&&VL(this))?Fi(this,b):(tC(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&&bL(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 it){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&DN(this,n.getBoundingClientRect(),e)}else DN(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 mC(e.slice,e.move,a<0?void 0:it.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 SL(this,e)}coordsAtPos(e,n=1){return qS(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 AL(this,n||this.state,e)}pasteHTML(e,n){return _u(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return _u(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return My(this,e)}destroy(){this.docView&&(aO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],dg(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,lL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return oO(this,e)}domSelectionRange(){let e=this.domSelection();return e?zs&&this.root.nodeType===11&&fL(this.dom.ownerDocument)==this.dom&&IO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}vC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function lw(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"),[ss.node(0,t.state.doc.content.size,e)]}function cw(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:ss.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function dw(t){return!t.someProp("editable",e=>e(t.state)===!1)}function VO(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 uw(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 HO(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 hw(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 qo={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:"'"},Yf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},UO=typeof navigator<"u"&&/Mac/.test(navigator.platform),WO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Cs=0;Cs<10;Cs++)qo[48+Cs]=qo[96+Cs]=String(Cs);for(var Cs=1;Cs<=24;Cs++)qo[Cs+111]="F"+Cs;for(var Cs=65;Cs<=90;Cs++)qo[Cs]=String.fromCharCode(Cs+32),Yf[Cs]=String.fromCharCode(Cs);for(var hg in qo)Yf.hasOwnProperty(hg)||(Yf[hg]=qo[hg]);function KO(t){var e=UO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||WO&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Yf:qo)[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 qO=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),GO=typeof navigator<"u"&&/Win/.test(navigator.platform);function JO(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)XO(t,n,{get:e[n],enumerable:!0})};function Xp(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 Zp=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:Xp({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}},NC={};Dy(NC,{blur:()=>ZO,clearContent:()=>eD,clearNodes:()=>tD,command:()=>nD,createParagraphNear:()=>sD,cut:()=>rD,deleteCurrentNode:()=>aD,deleteNode:()=>iD,deleteRange:()=>oD,deleteSelection:()=>lD,enter:()=>cD,exitCode:()=>dD,extendMarkRange:()=>uD,first:()=>hD,focus:()=>pD,forEach:()=>mD,insertContent:()=>xD,insertContentAt:()=>bD,joinBackward:()=>wD,joinDown:()=>ND,joinForward:()=>jD,joinItemBackward:()=>kD,joinItemForward:()=>SD,joinTextblockBackward:()=>CD,joinTextblockForward:()=>ED,joinUp:()=>vD,keyboardShortcut:()=>MD,lift:()=>AD,liftEmptyBlock:()=>PD,liftListItem:()=>ID,newlineInCode:()=>RD,resetAttributes:()=>LD,scrollIntoView:()=>OD,selectAll:()=>DD,selectNodeBackward:()=>_D,selectNodeForward:()=>$D,selectParentNode:()=>zD,selectTextblockEnd:()=>FD,selectTextblockStart:()=>BD,setContent:()=>VD,setMark:()=>l_,setMeta:()=>c_,setNode:()=>d_,setNodeSelection:()=>u_,setTextDirection:()=>h_,setTextSelection:()=>f_,sinkListItem:()=>p_,splitBlock:()=>m_,splitListItem:()=>x_,toggleList:()=>g_,toggleMark:()=>y_,toggleNode:()=>b_,toggleWrap:()=>v_,undoInputRule:()=>N_,unsetAllMarks:()=>w_,unsetMark:()=>j_,unsetTextDirection:()=>k_,updateAttributes:()=>S_,wrapIn:()=>C_,wrapInList:()=>E_});var ZO=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),eD=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),tD=()=>({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=yd(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},nD=t=>e=>t(e),sD=()=>({state:t,dispatch:e})=>DS(t,e),rD=(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 ot(r.doc.resolve(Math.max(o-1,0)))),!0},aD=()=>({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 Gn(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 iD=t=>({tr:e,state:n,dispatch:r})=>{const a=Gn(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},oD=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},lD=()=>({state:t,dispatch:e})=>Ny(t,e),cD=()=>({commands:t})=>t.keyboardShortcut("Enter"),dD=()=>({state:t,dispatch:e})=>q6(t,e);function _y(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Xf(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:_y(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function wC(t,e,n={}){return t.find(r=>r.type===e&&Xf(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function fw(t,e,n={}){return!!wC(t,e,n)}function $y(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),!wC([...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&&fw([...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=Wi(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=$y(u,i,e);if(m&&m.from<=h&&m.to>=f){const x=ot.create(o,m.from,m.to);n.setSelection(x)}}return!0},hD=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=()=>{(Zf()||pw())&&r.dom.focus(),fD()&&!Zf()&&!pw()&&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&&!jC(n.state.selection))return o(),!0;const c=kC(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},mD=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),xD=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),SC=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&&SC(r)}return t};function lf(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 SC(n)}function zu(t,e,n){if(t instanceof $i||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),zu("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new cS({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?$o.fromSchema(u).parseSlice(lf(t),n.parseOptions):$o.fromSchema(u).parse(lf(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=$o.fromSchema(e);return n.slice?i.parseSlice(lf(t),n.parseOptions).content:i.parse(lf(t),n.parseOptions)}return zu("",e,n)}function gD(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(ft.near(t.doc.resolve(o),n))}var yD=t=>!("type"in t),bD=(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{zu(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(v){u(v)}try{c=zu(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((yD(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(),T=v.parentOffset===0,C=k.isText||k.isTextblock,L=k.content.size>0;T&&C&&L&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&gD(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},vD=()=>({state:t,dispatch:e})=>U6(t,e),ND=()=>({state:t,dispatch:e})=>W6(t,e),wD=()=>({state:t,dispatch:e})=>MS(t,e),jD=()=>({state:t,dispatch:e})=>RS(t,e),kD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Kp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},SD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Kp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},CD=()=>({state:t,dispatch:e})=>V6(t,e),ED=()=>({state:t,dispatch:e})=>H6(t,e);function CC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function TD(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=TD(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 Go(t,e,n={}){const{from:r,to:a,empty:i}=t.selection,o=e?Gn(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=>Xf(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,x)=>m+x.to-x.from,0)>=u}var AD=(t,e={})=>({state:n,dispatch:r})=>{const a=Gn(t,n.schema);return Go(n,a,e)?K6(n,r):!1},PD=()=>({state:t,dispatch:e})=>_S(t,e),ID=t=>({state:e,dispatch:n})=>{const r=Gn(t,e.schema);return rL(r)(e,n)},RD=()=>({state:t,dispatch:e})=>OS(t,e);function em(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function mw(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 LD=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=em(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Gn(t,r.schema)),c==="mark"&&(o=Wi(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,mw(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(mw(x.attrs,e))))})})}),u},OD=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),DD=()=>({tr:t,dispatch:e})=>{if(e){const n=new Tr(t.doc);t.setSelection(n)}return!0},_D=()=>({state:t,dispatch:e})=>PS(t,e),$D=()=>({state:t,dispatch:e})=>LS(t,e),zD=()=>({state:t,dispatch:e})=>Q6(t,e),FD=()=>({state:t,dispatch:e})=>Z6(t,e),BD=()=>({state:t,dispatch:e})=>X6(t,e);function g0(t,e,n={},r={}){return zu(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var VD=(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=g0(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 EC(t,e){const n=Wi(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 TC(t,e){const n=new by(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function HD(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function MC(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 tm(t){return e=>MC(e.$from,t)}function st(t,e,n){return t.config[e]===void 0&&t.parent?st(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?st(t.parent,e,n):null}):t.config[e]}function zy(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=st(e,"addExtensions",n);return r?[e,...zy(r())]:e}).flat(10)}function Fy(t,e){const n=nc.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function AC(t){return typeof t=="function"}function Jt(t,e=void 0,...n){return AC(t)?e?t.bind(e)(...n):t(...n):t}function WD(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ld(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 PC(t){const e=[],{nodeExtensions:n,markExtensions:r}=ld(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=st(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=st(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 KD(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 xw(t){const e=[],n=KD(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([...xw(r[a]),...xw(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function Fu(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)=>Yt(n,r),{})}function qD(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function gw(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):qD(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function yw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&WD(n)?!1:n!=null))}function bw(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 GD(t,e){var n;const r=PC(t),{nodeExtensions:a,markExtensions:i}=ld(t),o=(n=a.find(h=>st(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,T)=>{const C=st(T,"extendNodeSchema",m);return{...k,...C?C(h):{}}},{}),b=yw({...x,content:Jt(st(h,"content",m)),marks:Jt(st(h,"marks",m)),group:Jt(st(h,"group",m)),inline:Jt(st(h,"inline",m)),atom:Jt(st(h,"atom",m)),selectable:Jt(st(h,"selectable",m)),draggable:Jt(st(h,"draggable",m)),code:Jt(st(h,"code",m)),whitespace:Jt(st(h,"whitespace",m)),linebreakReplacement:Jt(st(h,"linebreakReplacement",m)),defining:Jt(st(h,"defining",m)),isolating:Jt(st(h,"isolating",m)),attrs:Object.fromEntries(f.map(bw))}),N=Jt(st(h,"parseHTML",m));N&&(b.parseDOM=N.map(k=>gw(k,f)));const w=st(h,"renderHTML",m);w&&(b.toDOM=k=>w({node:k,HTMLAttributes:Fu(k,f)}));const v=st(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 T=st(k,"extendMarkSchema",m);return{...v,...T?T(h):{}}},{}),b=yw({...x,inclusive:Jt(st(h,"inclusive",m)),excludes:Jt(st(h,"excludes",m)),group:Jt(st(h,"group",m)),spanning:Jt(st(h,"spanning",m)),code:Jt(st(h,"code",m)),attrs:Object.fromEntries(f.map(bw))}),N=Jt(st(h,"parseHTML",m));N&&(b.parseDOM=N.map(v=>gw(v,f)));const w=st(h,"renderHTML",m);return w&&(b.toDOM=v=>w({mark:v,HTMLAttributes:Fu(v,f)})),[h.name,b]}));return new cS({topNode:o,nodes:c,marks:u})}function JD(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Nu(t){return t.sort((n,r)=>{const a=st(n,"priority")||100,i=st(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 RC(t,e,n){const{from:r,to:a}=e,{blockSeparator:i=` +`))),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=nc.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=ZL(n),Qu&&eO(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")||$o.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:a,ruleFromNode(x){return x.nodeName=="BR"&&!x.nextSibling&&x.parentNode&&!QL.test(x.parentNode.nodeName)?{ignore:!0}:null}})),f)c=tO(ew(c,+f[1],+f[2]),f[4]);else if(c=ze.maxOpen(YL(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 QL=/^(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 YL(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&&iC(u,i,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=oC(o[o.length-1],i.length));let f=aC(c,u);o.push(f),a=a.matchType(f.type),i=u}}),o)return Ce.from(o)}return t}function aC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ce.from(t));return t}function iC(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 ew(t,e,n){return en})),cg.createHTML(t)):t}function ZL(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=cC().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),a;if((a=r&&lC[r[1].toLowerCase()])&&(t=a.map(i=>"<"+i+">").join("")+t+a.map(i=>"").reverse().join("")),n.innerHTML=XL(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 ze(a,i,o)}const Gs={},Js={},nO={touchstart:!0,touchmove:!0};class sO{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 rO(t){for(let e in Gs){let n=Gs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{iO(t,r)&&!Ay(t,r)&&(t.editable||!(r.type in Js))&&n(t,r)},nO[e]?{passive:!0}:void 0)}zs&&t.dom.addEventListener("input",()=>null),x0(t)}function Lo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function aO(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 x0(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Ay(t,r))})}function Ay(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function iO(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 oO(t,e){!Ay(t,e)&&Gs[e.type]&&(t.editable||!(e.type in Js))&&Gs[e.type](t,e)}Js.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!uC(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Oi&&Es&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),od&&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,Pl(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||JL(t,n)?n.preventDefault():Lo(t,"key")};Js.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Js.keypress=(t,e)=>{let n=e;if(uC(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Kr&&n.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ot)||!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 Yp(t){return{left:t.clientX,top:t.clientY}}function lO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Py(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 td(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 cO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&it.isSelectable(r)?(td(t,new it(n)),!0):!1}function dO(t,e){if(e==-1)return!1;let n=t.state.selection,r,a;n instanceof it&&(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(it.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?(td(t,it.create(t.state.doc,a)),!0):!1}function uO(t,e,n,r,a){return Py(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(a?dO(t,n):cO(t,n))}function hO(t,e,n,r){return Py(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",a=>a(t,e,r))}function fO(t,e,n,r){return Py(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",a=>a(t,e,r))||pO(t,n,r)}function pO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(td(t,ot.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)td(t,ot.create(r,c+1,c+1+o.content.size));else if(it.isSelectable(o))td(t,it.create(r,c));else continue;return!0}}function Iy(t){return Gf(t)}const dC=Kr?"metaKey":"ctrlKey";Gs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Iy(t),a=Date.now(),i="singleClick";a-t.input.lastClick.time<500&&lO(n,t.input.lastClick)&&!n[dC]&&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(Yp(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new mO(t,o,n,!!r)):(i=="doubleClick"?hO:fO)(t,o.pos,o.inside,n)?n.preventDefault():Lo(t,"pointer"))};class mO{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[dC],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 it&&h.from<=o&&h.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Gr&&!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)),Lo(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(()=>Fi(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(Yp(e))),this.updateAllowDefault(e),this.allowDefault||!n?Lo(this.view,"pointer"):uO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||zs&&this.mightDrag&&!this.mightDrag.node.isAtom||Es&&!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)?(td(this.view,ft.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Lo(this.view,"pointer")}move(e){this.updateAllowDefault(e),Lo(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)}}Gs.touchstart=t=>{t.input.lastTouch=Date.now(),Iy(t),Lo(t,"pointer")};Gs.touchmove=t=>{t.input.lastTouch=Date.now(),Lo(t,"pointer")};Gs.contextmenu=t=>Iy(t);function uC(t,e){return t.composing?!0:zs&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const xO=Oi?5e3:-1;Js.compositionstart=Js.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ot&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Es&&VS&&gO(t)))t.markCursor=t.state.storedMarks||n.marks(),Gf(t,!0),t.markCursor=null;else if(Gf(t,!e.selection.empty),Gr&&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}hC(t,xO)};function gO(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"}Js.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++,hC(t,20))};function hC(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Gf(t),e))}function fC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=bO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function yO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=dL(e.focusNode,e.focusOffset),r=uL(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 bO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Gf(t,e=!1){if(!(Oi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),fC(t),e||t.docView&&t.docView.dirty){let n=Ey(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 vO(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 Du=fr&&zo<15||od&&mL<604;Gs.copy=Js.cut=(t,e)=>{let n=e,r=t.state.selection,a=n.type=="cut";if(r.empty)return;let i=Du?null:n.clipboardData,o=r.content(),{dom:c,text:u}=My(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):vO(t,c),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function NO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function wO(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?_u(t,r.value,null,a,e):_u(t,r.textContent,r.innerHTML,a,e)},50)}function _u(t,e,n,r,a){let i=rC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,a,i||ze.empty)))return!0;if(!i)return!1;let o=NO(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 pC(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," "):""}Js.paste=(t,e)=>{let n=e;if(t.composing&&!Oi)return;let r=Du?null:n.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&_u(t,pC(r),r.getData("text/html"),a,n)?n.preventDefault():wO(t,n)};class mC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const jO=Kr?"altKey":"ctrlKey";function xC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[jO]}Gs.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(Yp(n)),o;if(!(i&&i.pos>=a.from&&i.pos<=(a instanceof it?a.to-1:a.to))){if(r&&r.mightDrag)o=it.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=it.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=My(t,c);(!n.dataTransfer.files.length||!Es||BS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Du?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Du||n.dataTransfer.setData("text/plain",h),t.dragging=new mC(f,xC(t,n),o)};Gs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Js.dragover=Js.dragenter=(t,e)=>e.preventDefault();Js.drop=(t,e)=>{try{kO(t,e,t.dragging)}finally{t.dragging=null}};function kO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Yp(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=rC(t,pC(e.dataTransfer),Du?null:e.dataTransfer.getData("text/html"),!1,a);let o=!!(n&&xC(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||ze.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?vS(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&&it.isSelectable(i.content.firstChild)&&x.nodeAfter&&x.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new it(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(Ty(t,x,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Gs.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())&&Fi(t)},20))};Gs.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)};Gs.beforeinput=(t,e)=>{if(Es&&Oi&&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,Pl(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 Js)Gs[t]=Js[t];function $u(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 Jf{constructor(e,n){this.toDOM=e,this.spec=n||$l,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 rs(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Jf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$u(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Bo{constructor(e,n){this.attrs=e,this.spec=n||$l}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 rs(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==_s||e.maps.length==0?this:this.mapInner(e,n,0,0,r||$l)}mapInner(e,n,r,a,i){let o;for(let c=0;c{let h=u+r,f;if(f=yC(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 Bo){let h=Math.max(i,u.from)-i,f=Math.min(o,u.to)-i;ha.map(e,n,$l));return So.from(r)}forChild(e,n){if(n.isLeaf)return on.empty;let r=[];for(let a=0;an instanceof on)?e:e.reduce((n,r)=>n.concat(r instanceof on?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let v=w-N-(b-x);for(let k=0;kT+f-m)continue;let C=c[k]+f-m;b>=C?c[k+1]=x<=C?-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!=_s?(c[h]=m,c[h+1]=b,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=CO(c,t,e,n,a,i,o),f=Qf(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=yC(t,c,u+n);if(h){i=!0;let f=Qf(h,c,n+u+1,r);f!=_s&&a.push(u,u+c.nodeSize,f)}});let o=gC(i?bC(t):t,-n).sort(zl);for(let c=0;c0;)e++;t.splice(e,0,n)}function dg(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=_s&&e.push(r)}),t.cursorWrapper&&e.push(on.create(t.state.doc,[t.cursorWrapper.deco])),So.from(e)}const EO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},TO=fr&&zo<=11;class MO{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 AO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new MO,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():zs&&e.composing&&r.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),TO&&(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,EO)),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(GN(this.view)){if(this.suppressingSelectionUpdates)return Fi(this.view);if(fr&&zo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Gl(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=id(i))n.add(i);for(let i=e.anchorNode;i;i=id(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)&&GN(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(Gr&&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||RO(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),PO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,LO(e,u)),this.handleDOMChange(i,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Fi(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],T=k.pmViewDesc;if(k.nodeName=="BR"&&!T){i=v;break}if(!T||T.size)break}let m=t.state.doc,x=t.someProp("domParser")||$o.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:DO,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 DO(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(zs&&/^(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||zs&&/^(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 _O=/^(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 $O(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,F=Ey(t,P);if(F&&!t.state.selection.eq(F)){if(Es&&Oi&&t.input.lastKeyCode===13&&Date.now()-100Q(t,Pl(13,"Enter"))))return;let O=t.state.tr.setSelection(F);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=OO(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||Oi)&&a.some(P=>P.nodeType==1&&!_O.test(P.nodeName))&&(!N||N.endA>=N.endB)&&t.someProp("handleKeyDown",P=>P(t,Pl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!N)if(r&&u instanceof ot&&!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=iw(t,t.state.doc,h.sel);if(P&&!P.eq(t.state.selection)){let F=t.state.tr.setSelection(P);i&&F.setMeta("composition",i),t.dispatch(F)}}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)),fr&&zo<=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),T=w.sameParent(v)&&w.parent.inlineContent&&k.end()>=N.endA;if((od&&t.input.lastIOSEnter>Date.now()-225&&(!T||a.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!T&&w.posP(t,Pl(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>N.start&&FO(f,N.start,N.endA,w,v)&&t.someProp("handleKeyDown",P=>P(t,Pl(8,"Backspace")))){Oi&&Es&&t.domObserver.suppressSelectionUpdates();return}Es&&N.endB==N.start&&(t.input.lastChromeDelete=Date.now()),Oi&&!T&&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,Pl(13,"Enter"))})},20));let C=N.start,L=N.endA,R=P=>{let F=P||t.state.tr.replace(C,L,h.doc.slice(N.start-h.from,N.endB-h.from));if(h.sel){let O=iw(t,F.doc,h.sel);O&&!(Es&&t.composing&&O.empty&&(N.start!=N.endB||t.input.lastChromeDeleteFi(t),20));let P=R(t.state.tr.delete(C,L)),F=f.resolve(N.start).marksAcross(f.resolve(N.endA));F&&P.ensureMarks(F),t.dispatch(P)}else if(N.endA==N.endB&&(U=zO(w.parent.content.cut(w.parentOffset,v.parentOffset),k.parent.content.cut(k.parentOffset,N.endA-k.start())))){let P=R(t.state.tr);U.type=="add"?P.addMark(C,L,U.mark):P.removeMark(C,L,U.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),F=()=>R(t.state.tr.insertText(P,C,L));t.someProp("handleTextInput",O=>O(t,C,L,P,F))||t.dispatch(F())}else t.dispatch(R());else t.dispatch(R())}function iw(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ty(t,e.resolve(n.anchor),e.resolve(n.head))}function zO(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||ug(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 BO(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 vC{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 sO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(hw),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=dw(this),cw(this),this.nodeViews=uw(this),this.docView=VN(this.state.doc,lw(this),dg(this),this.dom,this),this.domObserver=new AO(this,(r,a,i,o)=>$O(this,r,a,i,o)),this.domObserver.start(),rO(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&&x0(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(hw),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&&(fC(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=uw(this);HO(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&x0(this),this.editable=dw(this),cw(this);let u=dg(this),h=lw(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&&yL(this);if(o){this.domObserver.stop();let b=m&&(fr||Es)&&!this.composing&&!a.selection.empty&&!e.selection.empty&&VO(a.selection,e.selection);if(m){let N=Es?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=yO(this)),(i||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=VN(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())&&VL(this))?Fi(this,b):(tC(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&&bL(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 it){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&DN(this,n.getBoundingClientRect(),e)}else DN(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 mC(e.slice,e.move,a<0?void 0:it.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 SL(this,e)}coordsAtPos(e,n=1){return qS(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 AL(this,n||this.state,e)}pasteHTML(e,n){return _u(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return _u(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return My(this,e)}destroy(){this.docView&&(aO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],dg(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,lL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return oO(this,e)}domSelectionRange(){let e=this.domSelection();return e?zs&&this.root.nodeType===11&&fL(this.dom.ownerDocument)==this.dom&&IO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}vC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function lw(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"),[rs.node(0,t.state.doc.content.size,e)]}function cw(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:rs.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function dw(t){return!t.someProp("editable",e=>e(t.state)===!1)}function VO(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 uw(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 HO(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 hw(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 qo={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:"'"},Yf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},UO=typeof navigator<"u"&&/Mac/.test(navigator.platform),WO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Cs=0;Cs<10;Cs++)qo[48+Cs]=qo[96+Cs]=String(Cs);for(var Cs=1;Cs<=24;Cs++)qo[Cs+111]="F"+Cs;for(var Cs=65;Cs<=90;Cs++)qo[Cs]=String.fromCharCode(Cs+32),Yf[Cs]=String.fromCharCode(Cs);for(var hg in qo)Yf.hasOwnProperty(hg)||(Yf[hg]=qo[hg]);function KO(t){var e=UO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||WO&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Yf:qo)[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 qO=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),GO=typeof navigator<"u"&&/Win/.test(navigator.platform);function JO(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)XO(t,n,{get:e[n],enumerable:!0})};function Xp(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 Zp=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:Xp({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}},NC={};Dy(NC,{blur:()=>ZO,clearContent:()=>eD,clearNodes:()=>tD,command:()=>nD,createParagraphNear:()=>sD,cut:()=>rD,deleteCurrentNode:()=>aD,deleteNode:()=>iD,deleteRange:()=>oD,deleteSelection:()=>lD,enter:()=>cD,exitCode:()=>dD,extendMarkRange:()=>uD,first:()=>hD,focus:()=>pD,forEach:()=>mD,insertContent:()=>xD,insertContentAt:()=>bD,joinBackward:()=>wD,joinDown:()=>ND,joinForward:()=>jD,joinItemBackward:()=>kD,joinItemForward:()=>SD,joinTextblockBackward:()=>CD,joinTextblockForward:()=>ED,joinUp:()=>vD,keyboardShortcut:()=>MD,lift:()=>AD,liftEmptyBlock:()=>PD,liftListItem:()=>ID,newlineInCode:()=>RD,resetAttributes:()=>LD,scrollIntoView:()=>OD,selectAll:()=>DD,selectNodeBackward:()=>_D,selectNodeForward:()=>$D,selectParentNode:()=>zD,selectTextblockEnd:()=>FD,selectTextblockStart:()=>BD,setContent:()=>VD,setMark:()=>l_,setMeta:()=>c_,setNode:()=>d_,setNodeSelection:()=>u_,setTextDirection:()=>h_,setTextSelection:()=>f_,sinkListItem:()=>p_,splitBlock:()=>m_,splitListItem:()=>x_,toggleList:()=>g_,toggleMark:()=>y_,toggleNode:()=>b_,toggleWrap:()=>v_,undoInputRule:()=>N_,unsetAllMarks:()=>w_,unsetMark:()=>j_,unsetTextDirection:()=>k_,updateAttributes:()=>S_,wrapIn:()=>C_,wrapInList:()=>E_});var ZO=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),eD=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),tD=()=>({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=yd(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},nD=t=>e=>t(e),sD=()=>({state:t,dispatch:e})=>DS(t,e),rD=(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 ot(r.doc.resolve(Math.max(o-1,0)))),!0},aD=()=>({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 Jn(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 iD=t=>({tr:e,state:n,dispatch:r})=>{const a=Jn(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},oD=t=>({tr:e,dispatch:n})=>{const{from:r,to:a}=t;return n&&e.delete(r,a),!0},lD=()=>({state:t,dispatch:e})=>Ny(t,e),cD=()=>({commands:t})=>t.keyboardShortcut("Enter"),dD=()=>({state:t,dispatch:e})=>q6(t,e);function _y(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Xf(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(a=>n.strict?e[a]===t[a]:_y(e[a])?e[a].test(t[a]):e[a]===t[a]):!0}function wC(t,e,n={}){return t.find(r=>r.type===e&&Xf(Object.fromEntries(Object.keys(n).map(a=>[a,r.attrs[a]])),n))}function fw(t,e,n={}){return!!wC(t,e,n)}function $y(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),!wC([...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&&fw([...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=Wi(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(a){const m=$y(u,i,e);if(m&&m.from<=h&&m.to>=f){const x=ot.create(o,m.from,m.to);n.setSelection(x)}}return!0},hD=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=()=>{(Zf()||pw())&&r.dom.focus(),fD()&&!Zf()&&!pw()&&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&&!jC(n.state.selection))return o(),!0;const c=kC(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},mD=(t,e)=>n=>t.every((r,a)=>e(r,{...n,index:a})),xD=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),SC=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&&SC(r)}return t};function lf(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 SC(n)}function zu(t,e,n){if(t instanceof $i||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),zu("",e,n)}if(a){if(n.errorOnInvalidContent){let o=!1,c="";const u=new cS({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?$o.fromSchema(u).parseSlice(lf(t),n.parseOptions):$o.fromSchema(u).parse(lf(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=$o.fromSchema(e);return n.slice?i.parseSlice(lf(t),n.parseOptions).content:i.parse(lf(t),n.parseOptions)}return zu("",e,n)}function gD(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(ft.near(t.doc.resolve(o),n))}var yD=t=>!("type"in t),bD=(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{zu(e,i.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(v){u(v)}try{c=zu(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((yD(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(),T=v.parentOffset===0,C=k.isText||k.isTextblock,L=k.content.size>0;T&&C&&L&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&gD(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},vD=()=>({state:t,dispatch:e})=>U6(t,e),ND=()=>({state:t,dispatch:e})=>W6(t,e),wD=()=>({state:t,dispatch:e})=>MS(t,e),jD=()=>({state:t,dispatch:e})=>RS(t,e),kD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Kp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},SD=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Kp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},CD=()=>({state:t,dispatch:e})=>V6(t,e),ED=()=>({state:t,dispatch:e})=>H6(t,e);function CC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function TD(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=TD(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 Go(t,e,n={}){const{from:r,to:a,empty:i}=t.selection,o=e?Jn(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=>Xf(m.node.attrs,n,{strict:!1}));return i?!!h.length:h.reduce((m,x)=>m+x.to-x.from,0)>=u}var AD=(t,e={})=>({state:n,dispatch:r})=>{const a=Jn(t,n.schema);return Go(n,a,e)?K6(n,r):!1},PD=()=>({state:t,dispatch:e})=>_S(t,e),ID=t=>({state:e,dispatch:n})=>{const r=Jn(t,e.schema);return rL(r)(e,n)},RD=()=>({state:t,dispatch:e})=>OS(t,e);function em(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function mw(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 LD=(t,e)=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=em(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Jn(t,r.schema)),c==="mark"&&(o=Wi(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,mw(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(mw(x.attrs,e))))})})}),u},OD=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),DD=()=>({tr:t,dispatch:e})=>{if(e){const n=new Tr(t.doc);t.setSelection(n)}return!0},_D=()=>({state:t,dispatch:e})=>PS(t,e),$D=()=>({state:t,dispatch:e})=>LS(t,e),zD=()=>({state:t,dispatch:e})=>Q6(t,e),FD=()=>({state:t,dispatch:e})=>Z6(t,e),BD=()=>({state:t,dispatch:e})=>X6(t,e);function g0(t,e,n={},r={}){return zu(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var VD=(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=g0(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 EC(t,e){const n=Wi(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 TC(t,e){const n=new by(t);return e.forEach(r=>{r.steps.forEach(a=>{n.step(a)})}),n}function HD(t){for(let e=0;e{n(a)&&r.push({node:a,pos:i})}),r}function MC(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 tm(t){return e=>MC(e.$from,t)}function st(t,e,n){return t.config[e]===void 0&&t.parent?st(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?st(t.parent,e,n):null}):t.config[e]}function zy(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=st(e,"addExtensions",n);return r?[e,...zy(r())]:e}).flat(10)}function Fy(t,e){const n=nc.fromSchema(e).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(n),a.innerHTML}function AC(t){return typeof t=="function"}function Jt(t,e=void 0,...n){return AC(t)?e?t.bind(e)(...n):t(...n):t}function WD(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ld(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 PC(t){const e=[],{nodeExtensions:n,markExtensions:r}=ld(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=st(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=st(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 KD(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 xw(t){const e=[],n=KD(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([...xw(r[a]),...xw(i)]);r[a]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[a]=i}),r},{})}function Fu(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)=>Yt(n,r),{})}function qD(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function gw(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):qD(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...a}}}}function yw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&WD(n)?!1:n!=null))}function bw(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 GD(t,e){var n;const r=PC(t),{nodeExtensions:a,markExtensions:i}=ld(t),o=(n=a.find(h=>st(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,T)=>{const C=st(T,"extendNodeSchema",m);return{...k,...C?C(h):{}}},{}),b=yw({...x,content:Jt(st(h,"content",m)),marks:Jt(st(h,"marks",m)),group:Jt(st(h,"group",m)),inline:Jt(st(h,"inline",m)),atom:Jt(st(h,"atom",m)),selectable:Jt(st(h,"selectable",m)),draggable:Jt(st(h,"draggable",m)),code:Jt(st(h,"code",m)),whitespace:Jt(st(h,"whitespace",m)),linebreakReplacement:Jt(st(h,"linebreakReplacement",m)),defining:Jt(st(h,"defining",m)),isolating:Jt(st(h,"isolating",m)),attrs:Object.fromEntries(f.map(bw))}),N=Jt(st(h,"parseHTML",m));N&&(b.parseDOM=N.map(k=>gw(k,f)));const w=st(h,"renderHTML",m);w&&(b.toDOM=k=>w({node:k,HTMLAttributes:Fu(k,f)}));const v=st(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 T=st(k,"extendMarkSchema",m);return{...v,...T?T(h):{}}},{}),b=yw({...x,inclusive:Jt(st(h,"inclusive",m)),excludes:Jt(st(h,"excludes",m)),group:Jt(st(h,"group",m)),spanning:Jt(st(h,"spanning",m)),code:Jt(st(h,"code",m)),attrs:Object.fromEntries(f.map(bw))}),N=Jt(st(h,"parseHTML",m));N&&(b.parseDOM=N.map(v=>gw(v,f)));const w=st(h,"renderHTML",m);return w&&(b.toDOM=v=>w({mark:v,HTMLAttributes:Fu(v,f)})),[h.name,b]}));return new cS({topNode:o,nodes:c,marks:u})}function JD(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Nu(t){return t.sort((n,r)=>{const a=st(n,"priority")||100,i=st(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 RC(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 QD(t,e){const n={from:0,to:t.content.size};return RC(t,n,e)}function LC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function YD(t,e){const n=Gn(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 OC(t,e){const n=em(typeof e=="string"?e:e.name,t.schema);return n==="node"?YD(t,e):n==="mark"?EC(t,e):{}}function XD(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 ZD(t){const e=XD(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 DC(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}})})}),ZD(r)}function By(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=$y(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 e_=(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 au(t,e){return e.nodes[t]||e.marks[t]||null}function Cf(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 t_=(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 y0(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?Wi(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Xf(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),T=Math.min(N,v+w.nodeSize),C=T-k;o+=C,c.push(...w.marks.map(L=>({mark:L,from:k,to:T})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Xf(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 n_(t,e,n={}){if(!e)return Go(t,null,n)||y0(t,null,n);const r=em(e,t.schema);return r==="node"?Go(t,e,n):r==="mark"?y0(t,e,n):!1}var s_=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=tm(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 vw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Nw(t,e){const{nodeExtensions:n}=ld(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=Jt(st(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function nm(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&&(nm(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function _C(t){return t instanceof it}var $C=class zC{constructor(e){this.position=e}static fromJSON(e){return new zC(e.position)}toJSON(){return{position:this.position}}};function a_(t,e){const n=e.mapping.mapResult(t.position);return{position:new $C(n.pos),mapResult:n}}function i_(t){return new $C(t)}function o_(t,e,n){var r;const{selection:a}=e;let i=null;if(jC(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 l_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=Wi(t,r.schema);if(a)if(o){const h=EC(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 o_(r,n,u)},c_=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),d_=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=Gn(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})=>RN(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>RN(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},u_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=Ll(t,0,r.content.size),i=it.create(r,a);e.setSelection(i)}return!0},h_=(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},f_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=ot.atStart(r).from,c=ot.atEnd(r).to,u=Ll(a,o,c),h=Ll(i,o,c),f=ot.create(r,u,h);e.setSelection(f)}return!0},p_=t=>({state:e,dispatch:n})=>{const r=Gn(t,e.schema);return oL(r)(e,n)};function ww(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 m_=({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=Cf(h,c.node().type.name,c.node().attrs);if(i instanceof it&&i.node.isBlock)return!c.parentOffset||!zi(o,c.pos)?!1:(r&&(t&&ww(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:HD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&x?[{type:x,attrs:f}]:void 0,N=zi(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!N&&zi(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 ot&&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&&ww(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},x_=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=Gn(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 T=u.index(-1)?1:u.index(-2)?2:3;for(let z=u.depth-T;z>=u.depth-3;z-=1)k=Ce.from(u.node(z).copy(k));const C=u.indexAfter(-1){if(P>-1)return!1;z.isTextblock&&z.content.size===0&&(P=O+1)}),P>-1&&n.setSelection(ot.near(n.doc.resolve(P))),n.scrollIntoView()}return!0}const b=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...Cf(x,m.type.name,m.attrs),...e},w={...Cf(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(!zi(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:T}=r,{splittableMarks:C}=i.extensionManager,L=T||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,v).scrollIntoView(),!L||!a)return!0;const R=L.filter(U=>C.includes(U.type.name));n.ensureMarks(R)}return!0},pg=(t,e)=>{const n=tm(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)&&tl(t.doc,n.pos)&&t.join(n.pos),!0},mg=(t,e)=>{const n=tm(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)&&tl(t.doc,r)&&t.join(r),!0},g_=(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=Gn(t,o.schema),N=Gn(e,o.schema),{selection:w,storedMarks:v}=o,{$from:k,$to:T}=w,C=k.blockRange(T),L=v||w.$to.parentOffset&&w.$from.marks();if(!C)return!1;const R=tm(U=>Nw(U.type.name,m))(w);if(C.depth>=1&&R&&C.depth-R.depth<=1){if(R.node.type===b)return h.liftListItem(N);if(Nw(R.node.type.name,m)&&b.validContent(R.node.content)&&c)return u().command(()=>(i.setNodeMarkup(R.pos,b),!0)).command(()=>pg(i,b)).command(()=>mg(i,b)).run()}return!n||!L||!c?u().command(()=>f().wrapInList(b,r)?!0:h.clearNodes()).wrapInList(b,r).command(()=>pg(i,b)).command(()=>mg(i,b)).run():u().command(()=>{const U=f().wrapInList(b,r),P=L.filter(z=>x.includes(z.type.name));return i.ensureMarks(P),U?!0:h.clearNodes()}).wrapInList(b,r).command(()=>pg(i,b)).command(()=>mg(i,b)).run()},y_=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=Wi(t,r.schema);return y0(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},b_=(t,e,n={})=>({state:r,commands:a})=>{const i=Gn(t,r.schema),o=Gn(e,r.schema),c=Go(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})},v_=(t,e={})=>({state:n,commands:r})=>{const a=Gn(t,n.schema);return Go(n,a,e)?r.lift(a):r.wrapIn(a,e)},N_=()=>({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},w_=()=>({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},j_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=Wi(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=$y(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},k_=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},S_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=em(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Gn(t,r.schema)),c==="mark"&&(o=Wi(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(T=>{if(o===T.type&&(u=!0,a)){const C=Math.max(k,f),L=Math.min(k+v.nodeSize,m);n.addMark(C,L,o.create({...T.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},C_=(t,e={})=>({state:n,dispatch:r})=>{const a=Gn(t,n.schema);return eL(a,e)(n,r)},E_=(t,e={})=>({state:n,dispatch:r})=>{const a=Gn(t,n.schema);return tL(a,e)(n,r)},T_=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={}}},sm=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},M_=(t,e)=>{if(_y(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 cf(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=t_(h)+i;return o.forEach(x=>{if(f)return;const b=M_(m,x.find);if(!b)return;const N=u.state.tr,w=Xp({state:u.state,transaction:N}),v={from:r-(b[0].length-i.length),to:a},{commands:k,chain:T,can:C}=new Zp({editor:n,state:w});x.handler({state:w,range:v,match:b,commands:k,chain:T,can:C})===null||!N.steps.length||(x.undoable&&N.setMeta(c,{transform:N,from:r,to:a,text:i}),u.dispatch(N),f=!0)}),f}function A_(t){const{editor:e,rules:n}=t,r=new hn({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=Fy(Ce.from(f),o.schema);const{from:m}=u,x=m+f.length;cf({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 cf({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&cf({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?cf({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function P_(t){return Object.prototype.toString.call(t).slice(8,-1)}function df(t){return P_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function FC(t,e){const n={...t};return df(t)&&df(e)&&Object.keys(e).forEach(r=>{df(e[r])&&df(t[r])?n[r]=FC(t[r],e[r]):n[r]=e[r]}),n}var Vy=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Jt(st(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Jt(st(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>FC(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}},sc=class BC extends Vy{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new BC(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 I_(t){return typeof t=="number"}var R_=class{constructor(t){this.find=t.find,this.handler=t.handler}},L_=(t,e,n)=>{if(_y(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 O_(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Zp({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(b,N)=>{var w,v,k,T,C;if((v=(w=b.type)==null?void 0:w.spec)!=null&&v.code||!(b.isText||b.isTextblock||b.isInline))return;const L=(C=(T=(k=b.content)==null?void 0:k.size)!=null?T:b.nodeSize)!=null?C:0,R=Math.max(r,N),U=Math.min(a,N+L);if(R>=U)return;const P=b.isText?b.text||"":b.textBetween(R-N,U-N,void 0,"");L_(P,i.find,o).forEach(O=>{if(O.index===void 0)return;const Q=R+O.index+1,re=Q+O[0].length,D={from:n.tr.mapping.map(Q),to:n.tr.mapping.map(re)},ne=i.handler({state:n,range:D,match:O,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(ne)})}),m.every(b=>b!==null)}var uf=null,D_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function __(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=Xp({state:f,transaction:w});if(!(!O_({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 hn({view(m){const x=N=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(N.target)?m.dom.parentElement:null,r&&(uf=e)},b=()=>{uf&&(uf=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=uf;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"),T=!!k;if(!w&&!v&&!T)return;if(T){let{text:R}=k;typeof R=="string"?R=R:R=Fy(Ce.from(R),b.schema);const{from:U}=k,P=U+R.length,z=D_(R);return u({rule:f,state:b,from:U,to:{b:P},pasteEvt:z})}const C=x.doc.content.findDiffStart(b.doc.content),L=x.doc.content.findDiffEnd(b.doc.content);if(!(!I_(C)||!L||C===L.b))return u({rule:f,state:b,from:C,to:L,pasteEvt:o})}}))}var rm=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=IC(t),this.schema=GD(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:au(e.name,this.schema)},r=st(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Nu([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:au(r.name,this.schema)},i=[],o=st(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&st(r,"exitable",a)&&(c.ArrowRight=()=>sc.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=YO(c);i.push(u);const h=st(r,"addInputRules",a);if(vw(r,t.options.enableInputRules)&&h){const x=h();if(x&&x.length){const b=A_({editor:t,rules:x}),N=Array.isArray(b)?b:[b];i.push(...N)}}const f=st(r,"addPasteRules",a);if(vw(r,t.options.enablePasteRules)&&f){const x=f();if(x&&x.length){const b=__({editor:t,rules:x});i.push(...b)}}const m=st(r,"addProseMirrorPlugins",a);if(m){const x=m();i.push(...x)}return i})}get attributes(){return PC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ld(this.extensions);return Object.fromEntries(e.filter(n=>!!st(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:Gn(n.name,this.schema)},i=st(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,x)=>{const b=Fu(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 Nu([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:au(a.name,this.schema)},o=st(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Nu([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:au(a.name,this.schema)},o=st(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}=ld(this.extensions);return Object.fromEntries(e.filter(n=>!!st(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:Wi(n.name,this.schema)},i=st(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Fu(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{X_(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:au(e.name,this.schema)};e.type==="mark"&&((n=Jt(st(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=st(e,"onBeforeCreate",r),i=st(e,"onCreate",r),o=st(e,"onUpdate",r),c=st(e,"onSelectionUpdate",r),u=st(e,"onTransaction",r),h=st(e,"onFocus",r),f=st(e,"onBlur",r),m=st(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)})}};rm.resolve=IC;rm.sort=Nu;rm.flatten=zy;var $_={};Dy($_,{ClipboardTextSerializer:()=>HC,Commands:()=>UC,Delete:()=>WC,Drop:()=>KC,Editable:()=>qC,FocusEvents:()=>JC,Keymap:()=>QC,Paste:()=>YC,Tabindex:()=>XC,TextDirection:()=>ZC,focusEventsPluginKey:()=>GC});var Dn=class VC extends Vy{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new VC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},HC=Dn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new hn({key:new wn("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=LC(n);return RC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),UC=Dn.create({name:"commands",addCommands(){return{...NC}}}),WC=Dn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,a;const i=()=>{var o,c,u,h;if((h=(u=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?h:t.getMeta("y-sync$"))return;const f=TC(t.before,[t,...e]);DC(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 ga){const k=x.slice(N).map(b.from,-1),T=x.slice(N).map(b.to),C=x.invert().map(k,-1),L=x.invert().map(T),R=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(P=>P.eq(b.mark)),U=(v=f.doc.nodeAt(T))==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:C,to:L},newRange:{from:k,to:T},partial:!!(U||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()}}),KC=Dn.create({name:"drop",addProseMirrorPlugins(){return[new hn({key:new wn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),qC=Dn.create({name:"editable",addProseMirrorPlugins(){return[new hn({key:new wn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),GC=new wn("focusEvents"),JC=Dn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new hn({key:GC,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}}}})]}}),QC=Dn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos: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:ft.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 Zf()||CC()?i:a},addProseMirrorPlugins(){return[new hn({key:new wn("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=ft.atStart(e.doc).from,h=ft.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!nm(n.doc))return;const x=n.tr,b=Xp({state:n,transaction:x}),{commands:N}=new Zp({editor:this.editor,state:b});if(N.clearNodes(),!!x.steps.length)return x}})]}}),YC=Dn.create({name:"paste",addProseMirrorPlugins(){return[new hn({key:new wn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),XC=Dn.create({name:"tabindex",addProseMirrorPlugins(){return[new hn({key:new wn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ZC=Dn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ld(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 hn({key:new wn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),z_=class uu{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 uu(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 uu(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 uu(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 uu(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)}},F_=`.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 QD(t,e){const n={from:0,to:t.content.size};return RC(t,n,e)}function LC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function YD(t,e){const n=Jn(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 OC(t,e){const n=em(typeof e=="string"?e:e.name,t.schema);return n==="node"?YD(t,e):n==="mark"?EC(t,e):{}}function XD(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 ZD(t){const e=XD(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 DC(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}})})}),ZD(r)}function By(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(a=>{const i=n.resolve(t),o=$y(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 e_=(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 au(t,e){return e.nodes[t]||e.marks[t]||null}function Cf(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 t_=(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 y0(t,e,n={}){const{empty:r,ranges:a}=t.selection,i=e?Wi(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Xf(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),T=Math.min(N,v+w.nodeSize),C=T-k;o+=C,c.push(...w.marks.map(L=>({mark:L,from:k,to:T})))})}),o===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Xf(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 n_(t,e,n={}){if(!e)return Go(t,null,n)||y0(t,null,n);const r=em(e,t.schema);return r==="node"?Go(t,e,n):r==="mark"?y0(t,e,n):!1}var s_=(t,e)=>{const{$from:n,$to:r,$anchor:a}=t.selection;if(e){const i=tm(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 vw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Nw(t,e){const{nodeExtensions:n}=ld(e),r=n.find(o=>o.name===t);if(!r)return!1;const a={name:r.name,options:r.options,storage:r.storage},i=Jt(st(r,"group",a));return typeof i!="string"?!1:i.split(" ").includes("list")}function nm(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&&(nm(i,{ignoreWhitespace:n,checkChildren:e})||(a=!1))}),a}return!1}function _C(t){return t instanceof it}var $C=class zC{constructor(e){this.position=e}static fromJSON(e){return new zC(e.position)}toJSON(){return{position:this.position}}};function a_(t,e){const n=e.mapping.mapResult(t.position);return{position:new $C(n.pos),mapResult:n}}function i_(t){return new $C(t)}function o_(t,e,n){var r;const{selection:a}=e;let i=null;if(jC(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 l_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{const{selection:i}=n,{empty:o,ranges:c}=i,u=Wi(t,r.schema);if(a)if(o){const h=EC(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 o_(r,n,u)},c_=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),d_=(t,e={})=>({state:n,dispatch:r,chain:a})=>{const i=Jn(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})=>RN(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>RN(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},u_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,a=Ll(t,0,r.content.size),i=it.create(r,a);e.setSelection(i)}return!0},h_=(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},f_=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:a,to:i}=typeof t=="number"?{from:t,to:t}:t,o=ot.atStart(r).from,c=ot.atEnd(r).to,u=Ll(a,o,c),h=Ll(i,o,c),f=ot.create(r,u,h);e.setSelection(f)}return!0},p_=t=>({state:e,dispatch:n})=>{const r=Jn(t,e.schema);return oL(r)(e,n)};function ww(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 m_=({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=Cf(h,c.node().type.name,c.node().attrs);if(i instanceof it&&i.node.isBlock)return!c.parentOffset||!zi(o,c.pos)?!1:(r&&(t&&ww(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:HD(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&x?[{type:x,attrs:f}]:void 0,N=zi(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!N&&zi(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 ot&&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&&ww(n,a.extensionManager.splittableMarks),e.scrollIntoView()}return N},x_=(t,e={})=>({tr:n,state:r,dispatch:a,editor:i})=>{var o;const c=Jn(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 T=u.index(-1)?1:u.index(-2)?2:3;for(let F=u.depth-T;F>=u.depth-3;F-=1)k=Ce.from(u.node(F).copy(k));const C=u.indexAfter(-1){if(P>-1)return!1;F.isTextblock&&F.content.size===0&&(P=O+1)}),P>-1&&n.setSelection(ot.near(n.doc.resolve(P))),n.scrollIntoView()}return!0}const b=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,N={...Cf(x,m.type.name,m.attrs),...e},w={...Cf(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(!zi(n.doc,u.pos,2))return!1;if(a){const{selection:k,storedMarks:T}=r,{splittableMarks:C}=i.extensionManager,L=T||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,v).scrollIntoView(),!L||!a)return!0;const R=L.filter(U=>C.includes(U.type.name));n.ensureMarks(R)}return!0},pg=(t,e)=>{const n=tm(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)&&tl(t.doc,n.pos)&&t.join(n.pos),!0},mg=(t,e)=>{const n=tm(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)&&tl(t.doc,r)&&t.join(r),!0},g_=(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=Jn(t,o.schema),N=Jn(e,o.schema),{selection:w,storedMarks:v}=o,{$from:k,$to:T}=w,C=k.blockRange(T),L=v||w.$to.parentOffset&&w.$from.marks();if(!C)return!1;const R=tm(U=>Nw(U.type.name,m))(w);if(C.depth>=1&&R&&C.depth-R.depth<=1){if(R.node.type===b)return h.liftListItem(N);if(Nw(R.node.type.name,m)&&b.validContent(R.node.content)&&c)return u().command(()=>(i.setNodeMarkup(R.pos,b),!0)).command(()=>pg(i,b)).command(()=>mg(i,b)).run()}return!n||!L||!c?u().command(()=>f().wrapInList(b,r)?!0:h.clearNodes()).wrapInList(b,r).command(()=>pg(i,b)).command(()=>mg(i,b)).run():u().command(()=>{const U=f().wrapInList(b,r),P=L.filter(F=>x.includes(F.type.name));return i.ensureMarks(P),U?!0:h.clearNodes()}).wrapInList(b,r).command(()=>pg(i,b)).command(()=>mg(i,b)).run()},y_=(t,e={},n={})=>({state:r,commands:a})=>{const{extendEmptyMarkRange:i=!1}=n,o=Wi(t,r.schema);return y0(r,o,e)?a.unsetMark(o,{extendEmptyMarkRange:i}):a.setMark(o,e)},b_=(t,e,n={})=>({state:r,commands:a})=>{const i=Jn(t,r.schema),o=Jn(e,r.schema),c=Go(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})},v_=(t,e={})=>({state:n,commands:r})=>{const a=Jn(t,n.schema);return Go(n,a,e)?r.lift(a):r.wrapIn(a,e)},N_=()=>({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},w_=()=>({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},j_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=Wi(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=$y(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},k_=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},S_=(t,e={})=>({tr:n,state:r,dispatch:a})=>{let i=null,o=null;const c=em(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Jn(t,r.schema)),c==="mark"&&(o=Wi(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(T=>{if(o===T.type&&(u=!0,a)){const C=Math.max(k,f),L=Math.min(k+v.nodeSize,m);n.addMark(C,L,o.create({...T.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},C_=(t,e={})=>({state:n,dispatch:r})=>{const a=Jn(t,n.schema);return eL(a,e)(n,r)},E_=(t,e={})=>({state:n,dispatch:r})=>{const a=Jn(t,n.schema);return tL(a,e)(n,r)},T_=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={}}},sm=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},M_=(t,e)=>{if(_y(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 cf(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=t_(h)+i;return o.forEach(x=>{if(f)return;const b=M_(m,x.find);if(!b)return;const N=u.state.tr,w=Xp({state:u.state,transaction:N}),v={from:r-(b[0].length-i.length),to:a},{commands:k,chain:T,can:C}=new Zp({editor:n,state:w});x.handler({state:w,range:v,match:b,commands:k,chain:T,can:C})===null||!N.steps.length||(x.undoable&&N.setMeta(c,{transform:N,from:r,to:a,text:i}),u.dispatch(N),f=!0)}),f}function A_(t){const{editor:e,rules:n}=t,r=new hn({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=Fy(Ce.from(f),o.schema);const{from:m}=u,x=m+f.length;cf({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 cf({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:i}=a.state.selection;i&&cf({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?cf({editor:e,from:o.pos,to:o.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function P_(t){return Object.prototype.toString.call(t).slice(8,-1)}function df(t){return P_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function FC(t,e){const n={...t};return df(t)&&df(e)&&Object.keys(e).forEach(r=>{df(e[r])&&df(t[r])?n[r]=FC(t[r],e[r]):n[r]=e[r]}),n}var Vy=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Jt(st(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Jt(st(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>FC(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}},sc=class BC extends Vy{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new BC(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 I_(t){return typeof t=="number"}var R_=class{constructor(t){this.find=t.find,this.handler=t.handler}},L_=(t,e,n)=>{if(_y(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 O_(t){const{editor:e,state:n,from:r,to:a,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Zp({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,a,(b,N)=>{var w,v,k,T,C;if((v=(w=b.type)==null?void 0:w.spec)!=null&&v.code||!(b.isText||b.isTextblock||b.isInline))return;const L=(C=(T=(k=b.content)==null?void 0:k.size)!=null?T:b.nodeSize)!=null?C:0,R=Math.max(r,N),U=Math.min(a,N+L);if(R>=U)return;const P=b.isText?b.text||"":b.textBetween(R-N,U-N,void 0,"");L_(P,i.find,o).forEach(O=>{if(O.index===void 0)return;const Q=R+O.index+1,re=Q+O[0].length,D={from:n.tr.mapping.map(Q),to:n.tr.mapping.map(re)},ne=i.handler({state:n,range:D,match:O,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(ne)})}),m.every(b=>b!==null)}var uf=null,D_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function __(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=Xp({state:f,transaction:w});if(!(!O_({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 hn({view(m){const x=N=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(N.target)?m.dom.parentElement:null,r&&(uf=e)},b=()=>{uf&&(uf=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=uf;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"),T=!!k;if(!w&&!v&&!T)return;if(T){let{text:R}=k;typeof R=="string"?R=R:R=Fy(Ce.from(R),b.schema);const{from:U}=k,P=U+R.length,F=D_(R);return u({rule:f,state:b,from:U,to:{b:P},pasteEvt:F})}const C=x.doc.content.findDiffStart(b.doc.content),L=x.doc.content.findDiffEnd(b.doc.content);if(!(!I_(C)||!L||C===L.b))return u({rule:f,state:b,from:C,to:L,pasteEvt:o})}}))}var rm=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=IC(t),this.schema=GD(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:au(e.name,this.schema)},r=st(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Nu([...this.extensions].reverse()).flatMap(r=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:au(r.name,this.schema)},i=[],o=st(r,"addKeyboardShortcuts",a);let c={};if(r.type==="mark"&&st(r,"exitable",a)&&(c.ArrowRight=()=>sc.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=YO(c);i.push(u);const h=st(r,"addInputRules",a);if(vw(r,t.options.enableInputRules)&&h){const x=h();if(x&&x.length){const b=A_({editor:t,rules:x}),N=Array.isArray(b)?b:[b];i.push(...N)}}const f=st(r,"addPasteRules",a);if(vw(r,t.options.enablePasteRules)&&f){const x=f();if(x&&x.length){const b=__({editor:t,rules:x});i.push(...b)}}const m=st(r,"addProseMirrorPlugins",a);if(m){const x=m();i.push(...x)}return i})}get attributes(){return PC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ld(this.extensions);return Object.fromEntries(e.filter(n=>!!st(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:Jn(n.name,this.schema)},i=st(n,"addNodeView",a);if(!i)return[];const o=i();if(!o)return[];const c=(u,h,f,m,x)=>{const b=Fu(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 Nu([...this.extensions].reverse()).reduceRight((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:au(a.name,this.schema)},o=st(a,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Nu([...this.extensions]).reduce((r,a)=>{const i={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:e,type:au(a.name,this.schema)},o=st(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}=ld(this.extensions);return Object.fromEntries(e.filter(n=>!!st(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:Wi(n.name,this.schema)},i=st(n,"addMarkView",a);if(!i)return[];const o=(c,u,h)=>{const f=Fu(c,r);return i()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{X_(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:au(e.name,this.schema)};e.type==="mark"&&((n=Jt(st(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const a=st(e,"onBeforeCreate",r),i=st(e,"onCreate",r),o=st(e,"onUpdate",r),c=st(e,"onSelectionUpdate",r),u=st(e,"onTransaction",r),h=st(e,"onFocus",r),f=st(e,"onBlur",r),m=st(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)})}};rm.resolve=IC;rm.sort=Nu;rm.flatten=zy;var $_={};Dy($_,{ClipboardTextSerializer:()=>HC,Commands:()=>UC,Delete:()=>WC,Drop:()=>KC,Editable:()=>qC,FocusEvents:()=>JC,Keymap:()=>QC,Paste:()=>YC,Tabindex:()=>XC,TextDirection:()=>ZC,focusEventsPluginKey:()=>GC});var Dn=class VC extends Vy{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new VC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},HC=Dn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new hn({key:new wn("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=LC(n);return RC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),UC=Dn.create({name:"commands",addCommands(){return{...NC}}}),WC=Dn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,a;const i=()=>{var o,c,u,h;if((h=(u=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?h:t.getMeta("y-sync$"))return;const f=TC(t.before,[t,...e]);DC(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 ga){const k=x.slice(N).map(b.from,-1),T=x.slice(N).map(b.to),C=x.invert().map(k,-1),L=x.invert().map(T),R=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(P=>P.eq(b.mark)),U=(v=f.doc.nodeAt(T))==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:C,to:L},newRange:{from:k,to:T},partial:!!(U||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()}}),KC=Dn.create({name:"drop",addProseMirrorPlugins(){return[new hn({key:new wn("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),qC=Dn.create({name:"editable",addProseMirrorPlugins(){return[new hn({key:new wn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),GC=new wn("focusEvents"),JC=Dn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new hn({key:GC,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}}}})]}}),QC=Dn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos: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:ft.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 Zf()||CC()?i:a},addProseMirrorPlugins(){return[new hn({key:new wn("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=ft.atStart(e.doc).from,h=ft.atEnd(e.doc).to;if(i||!(o===u&&c===h)||!nm(n.doc))return;const x=n.tr,b=Xp({state:n,transaction:x}),{commands:N}=new Zp({editor:this.editor,state:b});if(N.clearNodes(),!!x.steps.length)return x}})]}}),YC=Dn.create({name:"paste",addProseMirrorPlugins(){return[new hn({key:new wn("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),XC=Dn.create({name:"tabindex",addProseMirrorPlugins(){return[new hn({key:new wn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ZC=Dn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ld(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 hn({key:new wn("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),z_=class uu{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 uu(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 uu(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 uu(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 uu(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)}},F_=`.ProseMirror { position: relative; } @@ -784,7 +784,7 @@ img.ProseMirror-separator { display: block; }`;function B_(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 V_=class extends T_{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:a_,createMappablePosition:i_},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=kC(e,this.options.autofocus);this.editorState=Yc.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=B_(F_,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=AC(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?[qC,HC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),UC,JC,QC,XC,KC,YC,WC,ZC.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 rm(r,this)}createCommandManager(){this.commandManager=new Zp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=g0(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=g0(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 vC(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 OC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return n_(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Fy(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` -`,textSerializers:n={}}=t||{};return QD(this.state.doc,{blockSeparator:e,textSerializers:{...LC(this.schema),...n}})}get isEmpty(){return nm(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 z_(e,this)}get $doc(){return this.$pos(0)}};function cd(t){return new sm({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Jt(t.getAttributes,void 0,r);if(a===!1||a===null)return null;const{tr:i}=e,o=r[r.length-1],c=r[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(By(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 e3(t){return new sm({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Jt(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let c=n.to;const u=t.type.create(a);if(r[1]){const h=r[0].lastIndexOf(r[1]);let f=o+h;f>c?f=c:c=f+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,o+r[0].length-1),i.replaceWith(f,c,u)}else if(r[0]){const h=t.type.isInline?o:o-1;i.insert(h,t.type.create(a)).delete(i.mapping.map(o),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function b0(t){return new sm({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=Jt(t.getAttributes,void 0,r)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function dd(t){return new sm({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=Jt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&yy(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&&tl(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var H_=t=>"touches"in t,U_=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,H_(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 W_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof it){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 K_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var q_={};Dy(q_,{createAtomBlockMarkdownSpec:()=>G_,createBlockMarkdownSpec:()=>J_,createInlineMarkdownSpec:()=>t3,parseAttributes:()=>Hy,parseIndentedBlocks:()=>v0,renderNestedMarkdownContent:()=>Wy,serializeAttributes:()=>Uy});function Hy(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 Uy(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 G_(t){const{nodeName:e,name:n,parseAttributes:r=Hy,serializeAttributes:a=Uy,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(T=>!(T 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 J_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=Hy,serializeAttributes:i=Uy,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,T=""]=v,C=a(T);let L=1;const R=k.length;let U="";const P=/^:::([\w-]*)(\s.*)?/gm,z=m.slice(R);for(P.lastIndex=0;;){const O=P.exec(z);if(O===null)break;const Q=O.index,re=O[1];if(!((N=O[2])!=null&&N.endsWith(":::"))){if(re)L+=1;else if(L-=1,L===0){const D=z.slice(0,Q);U=D.trim();const ne=m.slice(0,R+Q+O[0].length);let le=[];if(U)if(c==="block")for(le=b.blockTokens(D),le.forEach(me=>{me.text&&(!me.tokens||me.tokens.length===0)&&(me.tokens=b.inlineTokens(me.text))});le.length>0;){const me=le[le.length-1];if(me.type==="paragraph"&&(!me.text||me.text.trim()===""))le.pop();else break}else le=b.inlineTokens(U);return{type:e,raw:ne,attributes:C,content:U,tokens:le}}}}}},renderMarkdown:(m,x)=>{const b=f(m.attrs||{}),N=i(b),w=N?` {${N}}`:"",v=x.renderChildren(m.content||[],` +`,textSerializers:n={}}=t||{};return QD(this.state.doc,{blockSeparator:e,textSerializers:{...LC(this.schema),...n}})}get isEmpty(){return nm(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 z_(e,this)}get $doc(){return this.$pos(0)}};function cd(t){return new sm({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Jt(t.getAttributes,void 0,r);if(a===!1||a===null)return null;const{tr:i}=e,o=r[r.length-1],c=r[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(By(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 e3(t){return new sm({find:t.find,handler:({state:e,range:n,match:r})=>{const a=Jt(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let c=n.to;const u=t.type.create(a);if(r[1]){const h=r[0].lastIndexOf(r[1]);let f=o+h;f>c?f=c:c=f+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,o+r[0].length-1),i.replaceWith(f,c,u)}else if(r[0]){const h=t.type.isInline?o:o-1;i.insert(h,t.type.create(a)).delete(i.mapping.map(o),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function b0(t){return new sm({find:t.find,handler:({state:e,range:n,match:r})=>{const a=e.doc.resolve(n.from),i=Jt(t.getAttributes,void 0,r)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function dd(t){return new sm({find:t.find,handler:({state:e,range:n,match:r,chain:a})=>{const i=Jt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&yy(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&&tl(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var H_=t=>"touches"in t,U_=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,H_(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 W_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof it){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 K_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var q_={};Dy(q_,{createAtomBlockMarkdownSpec:()=>G_,createBlockMarkdownSpec:()=>J_,createInlineMarkdownSpec:()=>t3,parseAttributes:()=>Hy,parseIndentedBlocks:()=>v0,renderNestedMarkdownContent:()=>Wy,serializeAttributes:()=>Uy});function Hy(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 Uy(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 G_(t){const{nodeName:e,name:n,parseAttributes:r=Hy,serializeAttributes:a=Uy,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(T=>!(T 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 J_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:a=Hy,serializeAttributes:i=Uy,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,T=""]=v,C=a(T);let L=1;const R=k.length;let U="";const P=/^:::([\w-]*)(\s.*)?/gm,F=m.slice(R);for(P.lastIndex=0;;){const O=P.exec(F);if(O===null)break;const Q=O.index,re=O[1];if(!((N=O[2])!=null&&N.endsWith(":::"))){if(re)L+=1;else if(L-=1,L===0){const D=F.slice(0,Q);U=D.trim();const ne=m.slice(0,R+Q+O[0].length);let le=[];if(U)if(c==="block")for(le=b.blockTokens(D),le.forEach(me=>{me.text&&(!me.tokens||me.tokens.length===0)&&(me.tokens=b.inlineTokens(me.text))});le.length>0;){const me=le[le.length-1];if(me.type==="paragraph"&&(!me.text||me.text.trim()===""))le.pop();else break}else le=b.inlineTokens(U);return{type:e,raw:ne,attributes:C,content:U,tokens:le}}}}}},renderMarkdown:(m,x)=>{const b=f(m.attrs||{}),N=i(b),w=N?` {${N}}`:"",v=x.renderChildren(m.content||[],` `);return`:::${h}${w} @@ -807,7 +807,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 Tw;function $7(){if(Tw)return yg;Tw=1;var t=Wu(),e=K2();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 yg.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(U){if(!T){if(T=!0,C=U,U=x(U),b!==void 0&&w.hasValue){var P=w.value;if(b(P,U))return L=P}return L=U}if(P=L,r(C,U))return P;var z=x(U);return b!==void 0&&b(P,z)?(C=U,P):(C=U,L=z)}var T=!1,C,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},yg}var Mw;function z7(){return Mw||(Mw=1,gg.exports=$7()),gg.exports}var F7=z7(),B7=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},V7=({contentComponent:t})=>{const e=q2.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function H7(){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]:Bj.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 U7=class extends qs.Component{constructor(t){var e;super(t),this.editorContentRef=qs.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=H7(),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:B7(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(V7,{contentComponent:t.contentComponent})]})}},W7=g.forwardRef((t,e)=>{const n=qs.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return qs.createElement(U7,{key:n,innerRef:e,...t})}),r3=qs.memo(W7),K7=typeof window<"u"?g.useLayoutEffect:g.useEffect,q7=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 G7(t){var e;const[n]=g.useState(()=>new q7(t.editor)),r=F7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:_7);return K7(()=>n.watch(t.editor),[t.editor,n]),g.useDebugValue(r),r}var J7=!1,N0=typeof window>"u",Q7=N0||!!(typeof window<"u"&&window.next),Y7=class a3{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?N0||Q7?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 V_(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?a3.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 X7(t={},e=[]){const n=g.useRef(t);n.current=t;const[r]=g.useState(()=>new Y7(n)),a=q2.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return g.useDebugValue(a),g.useEffect(r.onRender(e)),G7({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var i3=g.createContext({editor:null});i3.Consumer;var Z7=g.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),e$=()=>g.useContext(Z7);qs.forwardRef((t,e)=>{const{onDragStart:n}=e$(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});qs.createContext({markViewContentRef:()=>{}});var Ky=g.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});Ky.displayName="TiptapContext";var t$=()=>g.useContext(Ky);function o3({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(i3.Provider,{value:i,children:s.jsx(Ky.Provider,{value:a,children:n})})}o3.displayName="Tiptap";function l3({...t}){const{editor:e}=t$();return s.jsx(r3,{editor:e,...t})}l3.displayName="Tiptap.Content";Object.assign(o3,{Content:l3});var tp=(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]},n$=/^\s*>\s$/,s$=Bn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return tp("blockquote",{...Yt(this.options.HTMLAttributes,t),children:tp("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 Tw;function $7(){if(Tw)return yg;Tw=1;var t=Wu(),e=K2();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 yg.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(U){if(!T){if(T=!0,C=U,U=x(U),b!==void 0&&w.hasValue){var P=w.value;if(b(P,U))return L=P}return L=U}if(P=L,r(C,U))return P;var F=x(U);return b!==void 0&&b(P,F)?(C=U,P):(C=U,L=F)}var T=!1,C,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},yg}var Mw;function z7(){return Mw||(Mw=1,gg.exports=$7()),gg.exports}var F7=z7(),B7=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},V7=({contentComponent:t})=>{const e=q2.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function H7(){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]:Bj.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 U7=class extends qs.Component{constructor(t){var e;super(t),this.editorContentRef=qs.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=H7(),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:B7(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(V7,{contentComponent:t.contentComponent})]})}},W7=g.forwardRef((t,e)=>{const n=qs.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return qs.createElement(U7,{key:n,innerRef:e,...t})}),r3=qs.memo(W7),K7=typeof window<"u"?g.useLayoutEffect:g.useEffect,q7=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 G7(t){var e;const[n]=g.useState(()=>new q7(t.editor)),r=F7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:_7);return K7(()=>n.watch(t.editor),[t.editor,n]),g.useDebugValue(r),r}var J7=!1,N0=typeof window>"u",Q7=N0||!!(typeof window<"u"&&window.next),Y7=class a3{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?N0||Q7?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 V_(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?a3.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 X7(t={},e=[]){const n=g.useRef(t);n.current=t;const[r]=g.useState(()=>new Y7(n)),a=q2.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return g.useDebugValue(a),g.useEffect(r.onRender(e)),G7({editor:a,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),a}var i3=g.createContext({editor:null});i3.Consumer;var Z7=g.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),e$=()=>g.useContext(Z7);qs.forwardRef((t,e)=>{const{onDragStart:n}=e$(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});qs.createContext({markViewContentRef:()=>{}});var Ky=g.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});Ky.displayName="TiptapContext";var t$=()=>g.useContext(Ky);function o3({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(i3.Provider,{value:i,children:s.jsx(Ky.Provider,{value:a,children:n})})}o3.displayName="Tiptap";function l3({...t}){const{editor:e}=t$();return s.jsx(r3,{editor:e,...t})}l3.displayName="Tiptap.Content";Object.assign(o3,{Content:l3});var tp=(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]},n$=/^\s*>\s$/,s$=Bn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return tp("blockquote",{...Yt(this.options.HTMLAttributes,t),children:tp("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,12 +832,12 @@ ${n} `):""}),x$=Bn.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",Yt(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()}}}),g$=Bn.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]}`,Yt(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=>b0({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),y$=Bn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Yt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!W_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,a=t();return _C(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(ot.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(it.create(o.doc,u.pos)):o.setSelection(ot.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(ot.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[e3({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),b$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,v$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,N$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,w$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,j$=sc.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",Yt(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[cd({find:b$,type:this.type}),cd({find:N$,type:this.type})]},addPasteRules(){return[Ql({find:v$,type:this.type}),Ql({find:w$,type:this.type})]}});const k$="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",S$="ελ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",w0="numeric",j0="ascii",k0="alpha",wu="asciinumeric",hu="alphanumeric",S0="domain",c3="emoji",C$="scheme",E$="slashscheme",vg="whitespace";function T$(t,e){return t in e||(e[t]=[]),e[t]}function Ol(t,e,n){e[w0]&&(e[wu]=!0,e[hu]=!0),e[j0]&&(e[wu]=!0,e[k0]=!0),e[wu]&&(e[hu]=!0),e[k0]&&(e[hu]=!0),e[hu]&&(e[S0]=!0),e[c3]&&(e[S0]=!0);for(const r in e){const a=T$(r,n);a.indexOf(t)<0&&a.push(t)}}function M$(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function dr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}dr.groups={};dr.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),Pn=(t,e,n,r,a)=>t.tr(e,n,r,a),Aw=(t,e,n,r,a)=>t.ts(e,n,r,a),Re=(t,e,n,r,a)=>t.tt(e,n,r,a),Ci="WORD",C0="UWORD",d3="ASCIINUMERICAL",u3="ALPHANUMERICAL",Bu="LOCALHOST",E0="TLD",T0="UTLD",Ef="SCHEME",Kc="SLASH_SCHEME",qy="NUM",M0="WS",Gy="NL",ju="OPENBRACE",ku="CLOSEBRACE",np="OPENBRACKET",sp="CLOSEBRACKET",rp="OPENPAREN",ap="CLOSEPAREN",ip="OPENANGLEBRACKET",op="CLOSEANGLEBRACKET",lp="FULLWIDTHLEFTPAREN",cp="FULLWIDTHRIGHTPAREN",dp="LEFTCORNERBRACKET",up="RIGHTCORNERBRACKET",hp="LEFTWHITECORNERBRACKET",fp="RIGHTWHITECORNERBRACKET",pp="FULLWIDTHLESSTHAN",mp="FULLWIDTHGREATERTHAN",xp="AMPERSAND",gp="APOSTROPHE",yp="ASTERISK",jo="AT",bp="BACKSLASH",vp="BACKTICK",Np="CARET",Co="COLON",Jy="COMMA",wp="DOLLAR",za="DOT",jp="EQUALS",Qy="EXCLAMATION",Wr="HYPHEN",Su="PERCENT",kp="PIPE",Sp="PLUS",Cp="POUND",Cu="QUERY",Yy="QUOTE",h3="FULLWIDTHMIDDLEDOT",Xy="SEMI",Fa="SLASH",Eu="TILDE",Ep="UNDERSCORE",f3="EMOJI",Tp="SYM";var p3=Object.freeze({__proto__:null,ALPHANUMERICAL:u3,AMPERSAND:xp,APOSTROPHE:gp,ASCIINUMERICAL:d3,ASTERISK:yp,AT:jo,BACKSLASH:bp,BACKTICK:vp,CARET:Np,CLOSEANGLEBRACKET:op,CLOSEBRACE:ku,CLOSEBRACKET:sp,CLOSEPAREN:ap,COLON:Co,COMMA:Jy,DOLLAR:wp,DOT:za,EMOJI:f3,EQUALS:jp,EXCLAMATION:Qy,FULLWIDTHGREATERTHAN:mp,FULLWIDTHLEFTPAREN:lp,FULLWIDTHLESSTHAN:pp,FULLWIDTHMIDDLEDOT:h3,FULLWIDTHRIGHTPAREN:cp,HYPHEN:Wr,LEFTCORNERBRACKET:dp,LEFTWHITECORNERBRACKET:hp,LOCALHOST:Bu,NL:Gy,NUM:qy,OPENANGLEBRACKET:ip,OPENBRACE:ju,OPENBRACKET:np,OPENPAREN:rp,PERCENT:Su,PIPE:kp,PLUS:Sp,POUND:Cp,QUERY:Cu,QUOTE:Yy,RIGHTCORNERBRACKET:up,RIGHTWHITECORNERBRACKET:fp,SCHEME:Ef,SEMI:Xy,SLASH:Fa,SLASH_SCHEME:Kc,SYM:Tp,TILDE:Eu,TLD:E0,UNDERSCORE:Ep,UTLD:T0,UWORD:C0,WORD:Ci,WS:M0});const ki=/[a-z]/,ou=new RegExp("\\p{L}","u"),Ng=new RegExp("\\p{Emoji}","u"),Si=/\d/,wg=/\s/,Pw="\r",jg=` -`,A$="️",P$="‍",kg="";let ff=null,pf=null;function I$(t=[]){const e={};dr.groups=e;const n=new dr;ff==null&&(ff=Iw(k$)),pf==null&&(pf=Iw(S$)),Re(n,"'",gp),Re(n,"{",ju),Re(n,"}",ku),Re(n,"[",np),Re(n,"]",sp),Re(n,"(",rp),Re(n,")",ap),Re(n,"<",ip),Re(n,">",op),Re(n,"(",lp),Re(n,")",cp),Re(n,"「",dp),Re(n,"」",up),Re(n,"『",hp),Re(n,"』",fp),Re(n,"<",pp),Re(n,">",mp),Re(n,"&",xp),Re(n,"*",yp),Re(n,"@",jo),Re(n,"`",vp),Re(n,"^",Np),Re(n,":",Co),Re(n,",",Jy),Re(n,"$",wp),Re(n,".",za),Re(n,"=",jp),Re(n,"!",Qy),Re(n,"-",Wr),Re(n,"%",Su),Re(n,"|",kp),Re(n,"+",Sp),Re(n,"#",Cp),Re(n,"?",Cu),Re(n,'"',Yy),Re(n,"/",Fa),Re(n,";",Xy),Re(n,"~",Eu),Re(n,"_",Ep),Re(n,"\\",bp),Re(n,"・",h3);const r=Pn(n,Si,qy,{[w0]:!0});Pn(r,Si,r);const a=Pn(r,ki,d3,{[wu]:!0}),i=Pn(r,ou,u3,{[hu]:!0}),o=Pn(n,ki,Ci,{[j0]:!0});Pn(o,Si,a),Pn(o,ki,o),Pn(a,Si,a),Pn(a,ki,a);const c=Pn(n,ou,C0,{[k0]:!0});Pn(c,ki),Pn(c,Si,i),Pn(c,ou,c),Pn(i,Si,i),Pn(i,ki),Pn(i,ou,i);const u=Re(n,jg,Gy,{[vg]:!0}),h=Re(n,Pw,M0,{[vg]:!0}),f=Pn(n,wg,M0,{[vg]:!0});Re(n,kg,f),Re(h,jg,u),Re(h,kg,f),Pn(h,wg,f),Re(f,Pw),Re(f,jg),Pn(f,wg,f),Re(f,kg,f);const m=Pn(n,Ng,f3,{[c3]:!0});Re(m,"#"),Pn(m,Ng,m),Re(m,A$,m);const x=Re(m,P$);Re(x,"#"),Pn(x,Ng,m);const b=[[ki,o],[Si,a]],N=[[ki,null],[ou,c],[Si,i]];for(let w=0;ww[0]>v[0]?1:-1);for(let w=0;w=0?T[S0]=!0:ki.test(v)?Si.test(v)?T[wu]=!0:T[j0]=!0:T[w0]=!0,Aw(n,v,v,T)}return Aw(n,"localhost",Bu,{ascii:!0}),n.jd=new dr(Tp),{start:n,tokens:Object.assign({groups:e},p3)}}function m3(t,e){const n=R$(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 R$(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 yo(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 Vu={defaultProtocol:"http",events:null,format:Rw,formatHref:Rw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Zy(t,e=null){let n=Object.assign({},Vu);t&&(n=Object.assign(n,t instanceof Zy?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=Vu.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 am(t,e){class n extends x3{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 Lw=am("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ow=am("text"),L$=am("nl"),mf=am("url",{isLink:!0,toHref(t=Vu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Bu&&t[1].t===Co}}),Ur=t=>new dr(t);function O$({groups:t}){const e=t.domain.concat([xp,yp,jo,bp,vp,Np,wp,jp,Wr,qy,Su,kp,Sp,Cp,Fa,Tp,Eu,Ep]),n=[gp,Co,Jy,za,Qy,Su,Cu,Yy,Xy,ip,op,ju,ku,sp,np,rp,ap,lp,cp,dp,up,hp,fp,pp,mp],r=[xp,gp,yp,bp,vp,Np,wp,jp,Wr,ju,ku,Su,kp,Sp,Cp,Cu,Fa,Tp,Eu,Ep],a=Ur(),i=Re(a,Eu);St(i,r,i),St(i,t.domain,i);const o=Ur(),c=Ur(),u=Ur();St(a,t.domain,o),St(a,t.scheme,c),St(a,t.slashscheme,u),St(o,r,i),St(o,t.domain,o);const h=Re(o,jo);Re(i,jo,h),Re(c,jo,h),Re(u,jo,h);const f=Re(i,za);St(f,r,i),St(f,t.domain,i);const m=Ur();St(h,t.domain,m),St(m,t.domain,m);const x=Re(m,za);St(x,t.domain,m);const b=Ur(Lw);St(x,t.tld,b),St(x,t.utld,b),Re(h,Bu,b);const N=Re(m,Wr);Re(N,Wr,N),St(N,t.domain,m),St(b,t.domain,m),Re(b,za,x),Re(b,Wr,N);const w=Re(b,Co);St(w,t.numeric,Lw);const v=Re(o,Wr),k=Re(o,za);Re(v,Wr,v),St(v,t.domain,o),St(k,r,i),St(k,t.domain,o);const T=Ur(mf);St(k,t.tld,T),St(k,t.utld,T),St(T,t.domain,o),St(T,r,i),Re(T,za,k),Re(T,Wr,v),Re(T,jo,h);const C=Re(T,Co),L=Ur(mf);St(C,t.numeric,L);const R=Ur(mf),U=Ur();St(R,e,R),St(R,n,U),St(U,e,R),St(U,n,U),Re(T,Fa,R),Re(L,Fa,R);const P=Re(c,Co),z=Re(u,Co),O=Re(z,Fa),Q=Re(O,Fa);St(c,t.domain,o),Re(c,za,k),Re(c,Wr,v),St(u,t.domain,o),Re(u,za,k),Re(u,Wr,v),St(P,t.domain,R),Re(P,Fa,R),Re(P,Cu,R),St(Q,t.domain,R),St(Q,e,R),Re(Q,Fa,R);const re=[[ju,ku],[np,sp],[rp,ap],[ip,op],[lp,cp],[dp,up],[hp,fp],[pp,mp]];for(let D=0;D=0&&x++,a++,f++;if(x<0)a-=f,a0&&(i.push(Sg(Ow,e,o)),o=[]),a-=x,f-=x;const b=m.t,N=n.slice(a-f,a);i.push(Sg(b,e,N))}}return o.length>0&&i.push(Sg(Ow,e,o)),i}function Sg(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 _$=typeof console<"u"&&console&&console.warn||(()=>{}),$$="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",yn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function z$(){return dr.groups={},yn.scanner=null,yn.parser=null,yn.tokenQueue=[],yn.pluginQueue=[],yn.customSchemes=[],yn.initialized=!1,yn}function Dw(t,e=!1){if(yn.initialized&&_$(`linkifyjs: already initialized - will not register custom scheme "${t}" ${$$}`),!/^[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()}}}),g$=Bn.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]}`,Yt(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=>b0({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),y$=Bn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Yt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!W_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,a=t();return _C(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(ot.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(it.create(o.doc,u.pos)):o.setSelection(ot.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(ot.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[e3({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),b$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,v$=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,N$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,w$=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,j$=sc.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",Yt(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[cd({find:b$,type:this.type}),cd({find:N$,type:this.type})]},addPasteRules(){return[Ql({find:v$,type:this.type}),Ql({find:w$,type:this.type})]}});const k$="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",S$="ελ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",w0="numeric",j0="ascii",k0="alpha",wu="asciinumeric",hu="alphanumeric",S0="domain",c3="emoji",C$="scheme",E$="slashscheme",vg="whitespace";function T$(t,e){return t in e||(e[t]=[]),e[t]}function Ol(t,e,n){e[w0]&&(e[wu]=!0,e[hu]=!0),e[j0]&&(e[wu]=!0,e[k0]=!0),e[wu]&&(e[hu]=!0),e[k0]&&(e[hu]=!0),e[hu]&&(e[S0]=!0),e[c3]&&(e[S0]=!0);for(const r in e){const a=T$(r,n);a.indexOf(t)<0&&a.push(t)}}function M$(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function dr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}dr.groups={};dr.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),Pn=(t,e,n,r,a)=>t.tr(e,n,r,a),Aw=(t,e,n,r,a)=>t.ts(e,n,r,a),Re=(t,e,n,r,a)=>t.tt(e,n,r,a),Ci="WORD",C0="UWORD",d3="ASCIINUMERICAL",u3="ALPHANUMERICAL",Bu="LOCALHOST",E0="TLD",T0="UTLD",Ef="SCHEME",Kc="SLASH_SCHEME",qy="NUM",M0="WS",Gy="NL",ju="OPENBRACE",ku="CLOSEBRACE",np="OPENBRACKET",sp="CLOSEBRACKET",rp="OPENPAREN",ap="CLOSEPAREN",ip="OPENANGLEBRACKET",op="CLOSEANGLEBRACKET",lp="FULLWIDTHLEFTPAREN",cp="FULLWIDTHRIGHTPAREN",dp="LEFTCORNERBRACKET",up="RIGHTCORNERBRACKET",hp="LEFTWHITECORNERBRACKET",fp="RIGHTWHITECORNERBRACKET",pp="FULLWIDTHLESSTHAN",mp="FULLWIDTHGREATERTHAN",xp="AMPERSAND",gp="APOSTROPHE",yp="ASTERISK",jo="AT",bp="BACKSLASH",vp="BACKTICK",Np="CARET",Co="COLON",Jy="COMMA",wp="DOLLAR",za="DOT",jp="EQUALS",Qy="EXCLAMATION",Wr="HYPHEN",Su="PERCENT",kp="PIPE",Sp="PLUS",Cp="POUND",Cu="QUERY",Yy="QUOTE",h3="FULLWIDTHMIDDLEDOT",Xy="SEMI",Fa="SLASH",Eu="TILDE",Ep="UNDERSCORE",f3="EMOJI",Tp="SYM";var p3=Object.freeze({__proto__:null,ALPHANUMERICAL:u3,AMPERSAND:xp,APOSTROPHE:gp,ASCIINUMERICAL:d3,ASTERISK:yp,AT:jo,BACKSLASH:bp,BACKTICK:vp,CARET:Np,CLOSEANGLEBRACKET:op,CLOSEBRACE:ku,CLOSEBRACKET:sp,CLOSEPAREN:ap,COLON:Co,COMMA:Jy,DOLLAR:wp,DOT:za,EMOJI:f3,EQUALS:jp,EXCLAMATION:Qy,FULLWIDTHGREATERTHAN:mp,FULLWIDTHLEFTPAREN:lp,FULLWIDTHLESSTHAN:pp,FULLWIDTHMIDDLEDOT:h3,FULLWIDTHRIGHTPAREN:cp,HYPHEN:Wr,LEFTCORNERBRACKET:dp,LEFTWHITECORNERBRACKET:hp,LOCALHOST:Bu,NL:Gy,NUM:qy,OPENANGLEBRACKET:ip,OPENBRACE:ju,OPENBRACKET:np,OPENPAREN:rp,PERCENT:Su,PIPE:kp,PLUS:Sp,POUND:Cp,QUERY:Cu,QUOTE:Yy,RIGHTCORNERBRACKET:up,RIGHTWHITECORNERBRACKET:fp,SCHEME:Ef,SEMI:Xy,SLASH:Fa,SLASH_SCHEME:Kc,SYM:Tp,TILDE:Eu,TLD:E0,UNDERSCORE:Ep,UTLD:T0,UWORD:C0,WORD:Ci,WS:M0});const ki=/[a-z]/,ou=new RegExp("\\p{L}","u"),Ng=new RegExp("\\p{Emoji}","u"),Si=/\d/,wg=/\s/,Pw="\r",jg=` +`,A$="️",P$="‍",kg="";let ff=null,pf=null;function I$(t=[]){const e={};dr.groups=e;const n=new dr;ff==null&&(ff=Iw(k$)),pf==null&&(pf=Iw(S$)),Re(n,"'",gp),Re(n,"{",ju),Re(n,"}",ku),Re(n,"[",np),Re(n,"]",sp),Re(n,"(",rp),Re(n,")",ap),Re(n,"<",ip),Re(n,">",op),Re(n,"(",lp),Re(n,")",cp),Re(n,"「",dp),Re(n,"」",up),Re(n,"『",hp),Re(n,"』",fp),Re(n,"<",pp),Re(n,">",mp),Re(n,"&",xp),Re(n,"*",yp),Re(n,"@",jo),Re(n,"`",vp),Re(n,"^",Np),Re(n,":",Co),Re(n,",",Jy),Re(n,"$",wp),Re(n,".",za),Re(n,"=",jp),Re(n,"!",Qy),Re(n,"-",Wr),Re(n,"%",Su),Re(n,"|",kp),Re(n,"+",Sp),Re(n,"#",Cp),Re(n,"?",Cu),Re(n,'"',Yy),Re(n,"/",Fa),Re(n,";",Xy),Re(n,"~",Eu),Re(n,"_",Ep),Re(n,"\\",bp),Re(n,"・",h3);const r=Pn(n,Si,qy,{[w0]:!0});Pn(r,Si,r);const a=Pn(r,ki,d3,{[wu]:!0}),i=Pn(r,ou,u3,{[hu]:!0}),o=Pn(n,ki,Ci,{[j0]:!0});Pn(o,Si,a),Pn(o,ki,o),Pn(a,Si,a),Pn(a,ki,a);const c=Pn(n,ou,C0,{[k0]:!0});Pn(c,ki),Pn(c,Si,i),Pn(c,ou,c),Pn(i,Si,i),Pn(i,ki),Pn(i,ou,i);const u=Re(n,jg,Gy,{[vg]:!0}),h=Re(n,Pw,M0,{[vg]:!0}),f=Pn(n,wg,M0,{[vg]:!0});Re(n,kg,f),Re(h,jg,u),Re(h,kg,f),Pn(h,wg,f),Re(f,Pw),Re(f,jg),Pn(f,wg,f),Re(f,kg,f);const m=Pn(n,Ng,f3,{[c3]:!0});Re(m,"#"),Pn(m,Ng,m),Re(m,A$,m);const x=Re(m,P$);Re(x,"#"),Pn(x,Ng,m);const b=[[ki,o],[Si,a]],N=[[ki,null],[ou,c],[Si,i]];for(let w=0;ww[0]>v[0]?1:-1);for(let w=0;w=0?T[S0]=!0:ki.test(v)?Si.test(v)?T[wu]=!0:T[j0]=!0:T[w0]=!0,Aw(n,v,v,T)}return Aw(n,"localhost",Bu,{ascii:!0}),n.jd=new dr(Tp),{start:n,tokens:Object.assign({groups:e},p3)}}function m3(t,e){const n=R$(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 R$(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 yo(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 Vu={defaultProtocol:"http",events:null,format:Rw,formatHref:Rw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Zy(t,e=null){let n=Object.assign({},Vu);t&&(n=Object.assign(n,t instanceof Zy?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=Vu.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 am(t,e){class n extends x3{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 Lw=am("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ow=am("text"),L$=am("nl"),mf=am("url",{isLink:!0,toHref(t=Vu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Bu&&t[1].t===Co}}),Ur=t=>new dr(t);function O$({groups:t}){const e=t.domain.concat([xp,yp,jo,bp,vp,Np,wp,jp,Wr,qy,Su,kp,Sp,Cp,Fa,Tp,Eu,Ep]),n=[gp,Co,Jy,za,Qy,Su,Cu,Yy,Xy,ip,op,ju,ku,sp,np,rp,ap,lp,cp,dp,up,hp,fp,pp,mp],r=[xp,gp,yp,bp,vp,Np,wp,jp,Wr,ju,ku,Su,kp,Sp,Cp,Cu,Fa,Tp,Eu,Ep],a=Ur(),i=Re(a,Eu);Ct(i,r,i),Ct(i,t.domain,i);const o=Ur(),c=Ur(),u=Ur();Ct(a,t.domain,o),Ct(a,t.scheme,c),Ct(a,t.slashscheme,u),Ct(o,r,i),Ct(o,t.domain,o);const h=Re(o,jo);Re(i,jo,h),Re(c,jo,h),Re(u,jo,h);const f=Re(i,za);Ct(f,r,i),Ct(f,t.domain,i);const m=Ur();Ct(h,t.domain,m),Ct(m,t.domain,m);const x=Re(m,za);Ct(x,t.domain,m);const b=Ur(Lw);Ct(x,t.tld,b),Ct(x,t.utld,b),Re(h,Bu,b);const N=Re(m,Wr);Re(N,Wr,N),Ct(N,t.domain,m),Ct(b,t.domain,m),Re(b,za,x),Re(b,Wr,N);const w=Re(b,Co);Ct(w,t.numeric,Lw);const v=Re(o,Wr),k=Re(o,za);Re(v,Wr,v),Ct(v,t.domain,o),Ct(k,r,i),Ct(k,t.domain,o);const T=Ur(mf);Ct(k,t.tld,T),Ct(k,t.utld,T),Ct(T,t.domain,o),Ct(T,r,i),Re(T,za,k),Re(T,Wr,v),Re(T,jo,h);const C=Re(T,Co),L=Ur(mf);Ct(C,t.numeric,L);const R=Ur(mf),U=Ur();Ct(R,e,R),Ct(R,n,U),Ct(U,e,R),Ct(U,n,U),Re(T,Fa,R),Re(L,Fa,R);const P=Re(c,Co),F=Re(u,Co),O=Re(F,Fa),Q=Re(O,Fa);Ct(c,t.domain,o),Re(c,za,k),Re(c,Wr,v),Ct(u,t.domain,o),Re(u,za,k),Re(u,Wr,v),Ct(P,t.domain,R),Re(P,Fa,R),Re(P,Cu,R),Ct(Q,t.domain,R),Ct(Q,e,R),Re(Q,Fa,R);const re=[[ju,ku],[np,sp],[rp,ap],[ip,op],[lp,cp],[dp,up],[hp,fp],[pp,mp]];for(let D=0;D=0&&x++,a++,f++;if(x<0)a-=f,a0&&(i.push(Sg(Ow,e,o)),o=[]),a-=x,f-=x;const b=m.t,N=n.slice(a-f,a);i.push(Sg(b,e,N))}}return o.length>0&&i.push(Sg(Ow,e,o)),i}function Sg(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 _$=typeof console<"u"&&console&&console.warn||(()=>{}),$$="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",yn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function z$(){return dr.groups={},yn.scanner=null,yn.parser=null,yn.tokenQueue=[],yn.pluginQueue=[],yn.customSchemes=[],yn.initialized=!1,yn}function Dw(t,e=!1){if(yn.initialized&&_$(`linkifyjs: already initialized - will not register custom scheme "${t}" ${$$}`),!/^[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`);yn.customSchemes.push([t,e])}function F$(){yn.scanner=I$(yn.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=TC(n.doc,[...e]);if(DC(c).forEach(({newRange:h})=>{const f=UD(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(!V$.test(b))return;m=f[0],x=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&x){const b=x.split(B$).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=eb(N).map(k=>k.toObject(t.defaultProtocol));if(!U$(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=>{By(k.from,k.to,r.doc).some(T=>T.mark.type===t.type)||o.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!o.steps.length)return o}})}function K$(t){return new hn({key:new wn("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=OC(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 q$(t){return new hn({key:new wn("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=g3(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 Al(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(H$,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var G$=sc.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"){Dw(t);return}Dw(t.scheme,t.optionalSlashes)})},onDestroy(){z$()},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)=>!!Al(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=>!!Al(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=>!!Al(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Yt(this.options.HTMLAttributes,t),0]:["a",Yt(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=>!!Al(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=>!!Al(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=g3(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Al(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(W$({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:a=>!!Al(a,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(K$({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(q$({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),J$=Object.defineProperty,Q$=(t,e)=>{for(var n in e)J$(t,n,{get:e[n],enumerable:!0})},Y$="listItem",_w="textStyle",$w=/^\s*([-+*])\s$/,y3=Bn.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",Yt(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(Y$,this.editor.getAttributes(_w)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=dd({find:$w,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=dd({find:$w,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(_w),editor:this.editor})),[t]}}),b3=Bn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Yt(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)=>Wy(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)}}}),X$={};Q$(X$,{findListItemPos:()=>Xu,getNextListDepth:()=>nb,handleBackspace:()=>A0,handleDelete:()=>P0,hasListBefore:()=>v3,hasListItemAfter:()=>Z$,hasListItemBefore:()=>N3,listItemHasSubList:()=>w3,nextListIsDeeper:()=>j3,nextListIsHigher:()=>k3});var Xu=(t,e)=>{const{$from:n}=e.selection,r=Gn(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}},nb=(t,e)=>{const n=Xu(t,e);if(!n)return!1;const[,r]=e_(e,t,n.$pos.pos+4);return r},v3=(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))},N3=(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)},w3=(t,e,n)=>{if(!n)return!1;const r=Gn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===r&&(a=!0)}),a},A0=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Go(t.state,e)&&v3(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(!Go(t.state,e)||!r_(t.state))return!1;const r=Xu(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=w3(e,t.state,i);return N3(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},j3=(t,e)=>{const n=nb(t,e),r=Xu(t,e);return!r||!n?!1:n>r.depth},k3=(t,e)=>{const n=nb(t,e),r=Xu(t,e);return!r||!n?!1:n{if(!Go(t.state,e)||!s_(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:a}=n;return!n.empty&&r.sameParent(a)?!1:j3(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():k3(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Z$=(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)},S3=Dn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&P0(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&&P0(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&&A0(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&&A0(t,n,r)&&(e=!0)}),e}}}}),zw=/^(\s*)(\d+)\.\s+(.*)$/,ez=/^\s/;function tz(t){const e=[];let n=0,r=0;for(;n({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Y$,this.editor.getAttributes(_w)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=dd({find:$w,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=dd({find:$w,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(_w),editor:this.editor})),[t]}}),b3=Bn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Yt(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)=>Wy(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)}}}),X$={};Q$(X$,{findListItemPos:()=>Xu,getNextListDepth:()=>nb,handleBackspace:()=>A0,handleDelete:()=>P0,hasListBefore:()=>v3,hasListItemAfter:()=>Z$,hasListItemBefore:()=>N3,listItemHasSubList:()=>w3,nextListIsDeeper:()=>j3,nextListIsHigher:()=>k3});var Xu=(t,e)=>{const{$from:n}=e.selection,r=Jn(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}},nb=(t,e)=>{const n=Xu(t,e);if(!n)return!1;const[,r]=e_(e,t,n.$pos.pos+4);return r},v3=(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))},N3=(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)},w3=(t,e,n)=>{if(!n)return!1;const r=Jn(t,e.schema);let a=!1;return n.descendants(i=>{i.type===r&&(a=!0)}),a},A0=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Go(t.state,e)&&v3(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(!Go(t.state,e)||!r_(t.state))return!1;const r=Xu(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=w3(e,t.state,i);return N3(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},j3=(t,e)=>{const n=nb(t,e),r=Xu(t,e);return!r||!n?!1:n>r.depth},k3=(t,e)=>{const n=nb(t,e),r=Xu(t,e);return!r||!n?!1:n{if(!Go(t.state,e)||!s_(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:a}=n;return!n.empty&&r.sameParent(a)?!1:j3(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():k3(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Z$=(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)},S3=Dn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&P0(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&&P0(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&&A0(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&&A0(t,n,r)&&(e=!0)}),e}}}}),zw=/^(\s*)(\d+)\.\s+(.*)$/,ez=/^\s/;function tz(t){const e=[];let n=0,r=0;for(;n{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]=tz(a);if(i.length===0)return;const c=C3(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(sz,this.editor.getAttributes(Fw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=dd({find:Bw,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=dd({find:Bw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Fw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),rz=/^\s*(\[([( |x])?\])\s$/,az=Bn.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",Yt(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 Wy(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=Fu(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[dd({find:rz,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),iz=Bn.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",Yt(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=v0(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=v0(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(a)return{type:"taskList",raw:a.raw,items:a.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Dn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(y3.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(b3.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(S3.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(E3.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(az.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(iz.configure(this.options.taskList)),t}});var Vw=" ",oz=" ",lz=Bn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Yt(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===Vw||r[0].text===oz)?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?Vw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,dz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,uz=sc.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",Yt(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[cd({find:cz,type:this.type})]},addPasteRules(){return[Ql({find:dz,type:this.type})]}}),hz=Bn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),fz=sc.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",Yt(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 pz(t={}){return new hn({view(e){return new mz(e,t)}})}class mz{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=vS(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 Ln extends ft{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ln.valid(r)?new Ln(r):ft.near(r)}content(){return ze.empty}eq(e){return e instanceof Ln&&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 Ln(e.resolve(n.pos))}getBookmark(){return new sb(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!xz(e)||!gz(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&&Ln.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(Ln.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!it.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(Ln.valid(c))return c}return null}}}Ln.prototype.visible=!1;Ln.findFrom=Ln.findGapCursorFrom;ft.jsonID("gapcursor",Ln);class sb{constructor(e){this.pos=e}map(e){return new sb(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ln.valid(n)?new Ln(n):ft.near(n)}}function T3(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function xz(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||T3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function gz(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||T3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function yz(){return new hn({props:{decorations:wz,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ln.valid(n)?new Ln(n):null},handleClick:vz,handleKeyDown:bz,handleDOMEvents:{beforeinput:Nz}}})}const bz=Oy({ArrowLeft:xf("horiz",-1),ArrowRight:xf("horiz",1),ArrowUp:xf("vert",-1),ArrowDown:xf("vert",1)});function xf(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 ot){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=Ln.findGapCursorFrom(c,e,u);return h?(a&&a(r.tr.setSelection(new Ln(h))),!0):!1}}function vz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ln.valid(r))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&it.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ln(r))),!0)}function Nz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ln))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 ze(a,0,0));return i.setSelection(ot.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function wz(t){if(!(t.selection instanceof Ln))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",on.create(t.doc,[ss.widget(t.selection.head,e,{key:"gapcursor"})])}var Mp=200,ys=function(){};ys.prototype.append=function(e){return e.length?(e=ys.from(e),!this.length&&e||e.length=n?ys.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ys.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ys.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)};ys.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};ys.from=function(e){return e instanceof ys?e:e&&e.length?new M3(e):ys.empty};var M3=(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<=Mp)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=Mp)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})(ys);ys.empty=new M3([]);var jz=(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})(ys);const kz=500;class xa{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 bo(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 bo(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 xa(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;fCz&&(c=Sz(c,h),o-=h),new xa(c.append(i),o)}remapping(e,n){let r=new Lu;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 xa(this.items.append(e.map(n=>new bo(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 bo(N,w,v))}else r.push(new bo(N))},a);let h=[];for(let x=n;xkz&&(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 bo(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 xa(ys.from(a.reverse()),i)}}xa.empty=new xa(ys.empty,0);function Sz(t,e){let n;return t.forEach((r,a)=>{if(r.selection&&e--==0)return n=a,!1}),t.slice(n)}let bo=class A3{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 A3(n.getMap().invert(),n,this.selection)}}};class ko{constructor(e,n,r,a,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=a,this.prevComposition=i}}const Cz=20;function Ez(t,e,n,r){let a=n.getMeta(Fl),i;if(a)return a.historyState;n.getMeta(Az)&&(t=new ko(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Fl))return o.getMeta(Fl).redo?new ko(t.done.addTransform(n,void 0,r,Tf(e)),t.undone,Hw(n.mapping.maps),t.prevTime,t.prevComposition):new ko(t.done,t.undone.addTransform(n,void 0,r,Tf(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||!Tz(n,t.prevRanges)),h=o?Cg(t.prevRanges,n.mapping):Hw(n.mapping.maps);return new ko(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Tf(e)),xa.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new ko(t.done.rebased(n,i),t.undone.rebased(n,i),Cg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ko(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Cg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Tz(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 Hw(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 Cg(t,e){if(!t)return null;let n=[];for(let r=0;r{let a=Fl.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(r){let i=Mz(a,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const I3=P3(!1,!0),R3=P3(!0,!0);Dn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new hn({key:new wn("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 Iz=Dn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pz(this.options)]}});Dn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new hn({key:new wn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:a}=e,i=[];if(!n||!r)return on.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(ss.node(h,h+u.nodeSize,{class:this.options.className}))}),on.create(t,i)}}})]}});var Rz=Dn.create({name:"gapCursor",addProseMirrorPlugins(){return[yz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Jt(st(t,"allowGapCursor",n)))!=null?e:null}}}),Ww="placeholder";function Lz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Oz=Dn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ww,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Lz(this.options.dataAttribute)}`:`data-${Ww}`;return[new hn({key:new wn("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&&nm(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const x=ss.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}),on.create(e,i)}}})]}});Dn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new hn({key:new wn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||_C(n.selection)||t.view.dragging?null:on.create(n.doc,[ss.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Kw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Dz=Dn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new wn(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 hn({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!Kw({node:o,types:r})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!Kw({node:o,types:r})}}})]}}),_z=Dn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>I3(t,e),redo:()=>({state:t,dispatch:e})=>R3(t,e)}},addProseMirrorPlugins(){return[Pz(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()}}}),$z=Dn.create({name:"starterKit",addExtensions(){var t,e,n,r;const a=[];return this.options.bold!==!1&&a.push(l$.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(s$.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(y3.configure(this.options.bulletList)),this.options.code!==!1&&a.push(u$.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(p$.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(m$.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(Iz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Rz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(x$.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(g$.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(_z.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(y$.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(j$.configure(this.options.italic)),this.options.listItem!==!1&&a.push(b3.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(S3.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(G$.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(E3.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(lz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(uz.configure(this.options.strike)),this.options.text!==!1&&a.push(hz.configure(this.options.text)),this.options.underline!==!1&&a.push(fz.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push(Dz.configure((r=this.options)==null?void 0:r.trailingNode)),a}}),zz=$z,Fz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Bz=Bn.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",Yt(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 U_({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[e3({find:Fz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Vz=Bz;function Hz(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=r&&!a,h=K_(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),T=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!T)return null;const C=w+v.index;let L=C+v[0].length;return u&&f.test(N.slice(L-1,L+1))&&(v[0]+=" ",L+=1),C=c.pos?{range:{from:C,to:L},query:v[0].slice(n.length),text:v[0]}:null}var Uz=new wn("suggestion");function Wz({pluginKey:t=Uz,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=Hz,shouldShow:v}){let k;const T=b==null?void 0:b(),C=()=>{const P=e.state.selection.$anchor.pos,z=e.view.coordsAtPos(P),{top:O,right:Q,bottom:re,left:D}=z;try{return new DOMRect(D,O,Q-D,re-O)}catch{return null}},L=(P,z)=>z?()=>{const O=t.getState(e.state),Q=O==null?void 0:O.decorationId,re=P.dom.querySelector(`[data-decoration-id="${Q}"]`);return(re==null?void 0:re.getBoundingClientRect())||null}:C;function R(P,z){var O;try{const re=t.getState(P.state),D=re!=null&&re.decorationId?P.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`):null,ne={editor:e,range:(re==null?void 0:re.range)||{from:0,to:0},query:(re==null?void 0:re.query)||null,text:(re==null?void 0:re.text)||null,items:[],command:le=>m({editor:e,range:(re==null?void 0:re.range)||{from:0,to:0},props:le}),decorationNode:D,clientRect:L(P,D)};(O=T==null?void 0:T.onExit)==null||O.call(T,ne)}catch{}const Q=P.state.tr.setMeta(z,{exit:!0});P.dispatch(Q)}const U=new hn({key:t,view(){return{update:async(P,z)=>{var O,Q,re,D,ne,le,me;const I=(O=this.key)==null?void 0:O.getState(z),Y=(Q=this.key)==null?void 0:Q.getState(P.state),F=I.active&&Y.active&&I.range.from!==Y.range.from,xe=!I.active&&Y.active,X=I.active&&!Y.active,V=!xe&&!X&&I.query!==Y.query,W=xe||F&&V,fe=V||F,he=X||F&&V;if(!W&&!fe&&!he)return;const de=he&&!W?I:Y,_=P.dom.querySelector(`[data-decoration-id="${de.decorationId}"]`);k={editor:e,range:de.range,query:de.query,text:de.text,items:[],command:J=>m({editor:e,range:de.range,props:J}),decorationNode:_,clientRect:L(P,_)},W&&((re=T==null?void 0:T.onBeforeStart)==null||re.call(T,k)),fe&&((D=T==null?void 0:T.onBeforeUpdate)==null||D.call(T,k)),(fe||W)&&(k.items=await x({editor:e,query:de.query})),he&&((ne=T==null?void 0:T.onExit)==null||ne.call(T,k)),fe&&((le=T==null?void 0:T.onUpdate)==null||le.call(T,k)),W&&((me=T==null?void 0:T.onStart)==null||me.call(T,k))},destroy:()=>{var P;k&&((P=T==null?void 0:T.onExit)==null||P.call(T,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(P,z,O,Q){const{isEditable:re}=e,{composing:D}=e.view,{selection:ne}=P,{empty:le,from:me}=ne,I={...z},Y=P.getMeta(t);if(Y&&Y.exit)return I.active=!1,I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null,I;if(I.composing=D,re&&(le||e.view.composing)){(mez.range.to)&&!D&&!z.composing&&(I.active=!1);const F=w({char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:ne.$from}),xe=`id_${Math.floor(Math.random()*4294967295)}`;F&&N({editor:e,state:Q,range:F.range,isActive:z.active})&&(!v||v({editor:e,range:F.range,query:F.query,text:F.text,transaction:P}))?(I.active=!0,I.decorationId=z.decorationId?z.decorationId:xe,I.range=F.range,I.query=F.query,I.text=F.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,z){var O,Q,re,D;const{active:ne,range:le}=U.getState(P.state);if(!ne)return!1;if(z.key==="Escape"||z.key==="Esc"){const I=U.getState(P.state),Y=(O=k==null?void 0:k.decorationNode)!=null?O:null,F=Y??(I!=null&&I.decorationId?P.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null);if(((Q=T==null?void 0:T.onKeyDown)==null?void 0:Q.call(T,{view:P,event:z,range:I.range}))||!1)return!0;const X={editor:e,range:I.range,query:I.query,text:I.text,items:[],command:V=>m({editor:e,range:I.range,props:V}),decorationNode:F,clientRect:F?()=>F.getBoundingClientRect()||null:null};return(re=T==null?void 0:T.onExit)==null||re.call(T,X),R(P,t),!0}return((D=T==null?void 0:T.onKeyDown)==null?void 0:D.call(T,{view:P,event:z,range:le}))||!1},decorations(P){const{active:z,range:O,decorationId:Q,query:re}=U.getState(P);if(!z)return null;const D=!(re!=null&&re.length),ne=[u];return D&&ne.push(f),on.create(P.doc,[ss.inline(O.from,O.to,{nodeName:c,class:ne.join(" "),"data-decoration-id":Q,"data-decoration-content":h})])}}});return U}function Kz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const a=new wn;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 L3(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Kz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function qw(t,e){const n=L3(t),r=n.find(a=>a.char===e);return r||(n.length?n[0]:null)}var qz=Bn.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",Yt(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=qw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Yt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Yt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof a=="string"?["span",Yt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...t3({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:qw(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 $i,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 L3(this).map(Wz)}}),Gz=qz,Jz=Oz;let I0,R0;if(typeof WeakMap<"u"){let t=new WeakMap;I0=e=>t.get(e),R0=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;I0=r=>{for(let a=0;a(n==10&&(n=0),t[n++]=r,t[n++]=a)}var On=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-C});break}const L=a+C*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 Xz(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 eF(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 wa(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 im(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=Yl(e.$head)||tF(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function tF(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 L0(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function nF(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function rb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function O3(t,e,n){const r=t.node(-1),a=On.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 Xl(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 D3(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 SS(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(L0(r)&&L0(a)&&rb(r,a)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ei.rowSelection(r,a):i&&this.isColSelection()?Ei.colSelection(r,a):new Ei(r,a)}return ot.between(r,a)}content(){const e=this.$anchorCell.node(-1),n=On.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=Xl(k,0,w)),v>0&&(k=Xl(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=On.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 Ei&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),a=On.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(ss.node(r,r+n.nodeSize,{class:"selectedCell"}))}),on.create(t.doc,e)}function iF({$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 oF({$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 lF(t,e,n){const r=(e||t).selection,a=(e||t).doc;let i,o;if(r instanceof it&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=un.create(a,r.from);else if(o=="row"){const c=a.resolve(r.from+1);i=un.rowSelection(c,c)}else if(!n){const c=On.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];i=un.create(a,u+1,h)}}else r instanceof ot&&iF(r)?i=ot.create(a,r.from):r instanceof ot&&oF(r)&&(i=ot.create(a,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const cF=new wn("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=dF(t,a,i,n))};return e?e.doc!=t.doc&&$3(e.doc,t.doc,0,r):t.doc.descendants(r),n}function dF(t,e,n,r){const a=On.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;sF(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;mF(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=Gw(h)?u+1:f;i.replaceWith(m+r.tableStart,f+r.tableStart,c)}i.setSelection(new un(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function Qw(t,e){const n=Fs(t.schema);return NF(({node:r})=>n[r.type.spec.tableRole])(t,e)}function NF(t){return(e,n)=>{const r=e.selection;let a,i;if(r instanceof un){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;a=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(a=eF(r.$from),!a)return!1;i=(o=Yl(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=Xa(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 jF(t){return function(e,n){if(!wa(e))return!1;if(n){const r=Fs(e.schema),a=Xa(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}}Hu("row",{useDeprecatedLogic:!0});Hu("column",{useDeprecatedLogic:!0});const kF=Hu("cell",{useDeprecatedLogic:!0});function SF(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 gf(t,e){const n=t.selection;if(!(n instanceof un))return!1;if(e){const r=t.tr,a=Fs(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 ze(a,0,0))}),r.docChanged&&e(r)}return!0}function EF(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(Xl(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 AF(t,e,n,r,a,i,o){const c=t.doc.type.schema,u=Fs(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 un)return Mf(n,r,ft.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=V3(a,t,e);if(o==null)return!1;if(t=="horiz")return Mf(n,r,ft.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=O3(c,t,e);let h;return u?h=ft.near(u,1):e<0?h=ft.near(n.doc.resolve(c.before(-1)),-1):h=ft.near(n.doc.resolve(c.after(-1)),1),Mf(n,r,h)}}}function bf(t,e){return(n,r,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof un)o=i;else{const u=V3(a,t,e);if(u==null)return!1;o=new un(n.doc.resolve(u))}const c=O3(o.$headCell,t,e);return c?Mf(n,r,new un(o.$anchorCell,c)):!1}}function IF(t,e){const n=t.state.doc,r=Yl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new un(r))),!0):!1}function RF(t,e,n){if(!wa(t.state))return!1;let r=EF(n);const a=t.state.selection;if(a instanceof un){r||(r={width:1,height:1,rows:[Ce.from(O0(Fs(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=On.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return r=MF(r,c.right-c.left,c.bottom-c.top),tj(t.state,t.dispatch,o,c,r),!0}else if(r){const i=im(t.state),o=i.start(-1);return tj(t.state,t.dispatch,o,On.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function LF(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=nj(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof un)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(a=Yl(t.state.selection.$anchor))!=null&&((n=Tg(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=Tg(t,h);const m=Eo.getState(t.state)==null;if(!f||!rb(u,f))if(m)f=u;else return;const x=new un(u,f);if(m||!t.state.selection.eq(x)){const b=t.state.tr.setSelection(x);m&&b.setMeta(Eo,u.pos),t.dispatch(b)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),Eo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Eo,-1))}function c(u){const h=u,f=Eo.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(nj(t,h.target)!=r&&(m=Tg(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 V3(t,e,n){if(!(t.state.selection instanceof ot))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 nj(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Tg(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&&Yl(t.state.doc.resolve(r))||Yl(t.state.doc.resolve(a))}var OF=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")),D0(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,D0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function D0(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 _F(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=Er.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{$F(o,c,t,a)},mouseleave:o=>{zF(o)},mousedown:(o,c)=>{FF(o,c,e,n)}},decorations:o=>{const c=Er.getState(o);if(c&&c.activeHandle>-1)return WF(o,c.activeHandle)},nodeViews:{}}});return i}var _F=class Af{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Er);if(r&&r.setHandle!=null)return new Af(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Af(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return L0(e.doc.resolve(a))||(a=-1),new Af(a,n.dragging)}return n}};function $F(t,e,n,r){if(!t.editable)return;const a=Er.getState(t.state);if(a&&!a.dragging){const i=VF(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=sj(t,e,"left",n):u-e.clientX<=n&&(o=sj(t,e,"right",n))}if(o!=a.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=On.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}H3(t,o)}}}function zF(t){if(!t.editable)return;const e=Er.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&H3(t,-1)}function FF(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=Er.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=BF(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Er,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const x=Er.getState(t.state);x!=null&&x.dragging&&(HF(t,x.activeHandle,rj(x.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Er,{setDragging:null})))}function f(m){if(!m.which)return h(m);const x=Er.getState(t.state);if(x&&x.dragging){const b=rj(x.dragging,m,n);aj(t,x.activeHandle,b,r)}}return aj(t,o.activeHandle,u,r),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function BF(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",Yt(this.options.HTMLAttributes,t),0]}}),W3=Bn.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",Yt(this.options.HTMLAttributes,t),0]}}),K3=Bn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Yt(this.options.HTMLAttributes,t),0]}});function _0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function ij(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 QF(t,e,n,r,a){const i=JF(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!YF(e))return!1;let n=0;const r=MC(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},XF="";function ZF(t){return(t||"").replace(/\s+/g," ").trim()}function eB(t,e,n={}){var r;const a=(r=n.cellLineSeparator)!=null?r:XF;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 T=ZF(k),C=v.type==="tableHeader";w.push({text:T,isHeader:C})}),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]=T),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=` +`):"",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=v0(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=v0(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(a)return{type:"taskList",raw:a.raw,items:a.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Dn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(y3.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(b3.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(S3.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(E3.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(az.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(iz.configure(this.options.taskList)),t}});var Vw=" ",oz=" ",lz=Bn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Yt(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===Vw||r[0].text===oz)?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?Vw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,dz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,uz=sc.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",Yt(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[cd({find:cz,type:this.type})]},addPasteRules(){return[Ql({find:dz,type:this.type})]}}),hz=Bn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),fz=sc.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",Yt(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 pz(t={}){return new hn({view(e){return new mz(e,t)}})}class mz{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=vS(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 Ln extends ft{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ln.valid(r)?new Ln(r):ft.near(r)}content(){return ze.empty}eq(e){return e instanceof Ln&&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 Ln(e.resolve(n.pos))}getBookmark(){return new sb(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!xz(e)||!gz(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&&Ln.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(Ln.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!it.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(Ln.valid(c))return c}return null}}}Ln.prototype.visible=!1;Ln.findFrom=Ln.findGapCursorFrom;ft.jsonID("gapcursor",Ln);class sb{constructor(e){this.pos=e}map(e){return new sb(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ln.valid(n)?new Ln(n):ft.near(n)}}function T3(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function xz(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||T3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function gz(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||T3(a.type))return!0;if(a.inlineContent)return!1}}return!0}function yz(){return new hn({props:{decorations:wz,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ln.valid(n)?new Ln(n):null},handleClick:vz,handleKeyDown:bz,handleDOMEvents:{beforeinput:Nz}}})}const bz=Oy({ArrowLeft:xf("horiz",-1),ArrowRight:xf("horiz",1),ArrowUp:xf("vert",-1),ArrowDown:xf("vert",1)});function xf(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 ot){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=Ln.findGapCursorFrom(c,e,u);return h?(a&&a(r.tr.setSelection(new Ln(h))),!0):!1}}function vz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ln.valid(r))return!1;let a=t.posAtCoords({left:n.clientX,top:n.clientY});return a&&a.inside>-1&&it.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ln(r))),!0)}function Nz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ln))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 ze(a,0,0));return i.setSelection(ot.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function wz(t){if(!(t.selection instanceof Ln))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",on.create(t.doc,[rs.widget(t.selection.head,e,{key:"gapcursor"})])}var Mp=200,ys=function(){};ys.prototype.append=function(e){return e.length?(e=ys.from(e),!this.length&&e||e.length=n?ys.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ys.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ys.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)};ys.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};ys.from=function(e){return e instanceof ys?e:e&&e.length?new M3(e):ys.empty};var M3=(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<=Mp)return new e(this.values.concat(a.flatten()))},e.prototype.leafPrepend=function(a){if(this.length+a.length<=Mp)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})(ys);ys.empty=new M3([]);var jz=(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})(ys);const kz=500;class xa{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 bo(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 bo(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 xa(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;fCz&&(c=Sz(c,h),o-=h),new xa(c.append(i),o)}remapping(e,n){let r=new Lu;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 xa(this.items.append(e.map(n=>new bo(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 bo(N,w,v))}else r.push(new bo(N))},a);let h=[];for(let x=n;xkz&&(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 bo(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 xa(ys.from(a.reverse()),i)}}xa.empty=new xa(ys.empty,0);function Sz(t,e){let n;return t.forEach((r,a)=>{if(r.selection&&e--==0)return n=a,!1}),t.slice(n)}let bo=class A3{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 A3(n.getMap().invert(),n,this.selection)}}};class ko{constructor(e,n,r,a,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=a,this.prevComposition=i}}const Cz=20;function Ez(t,e,n,r){let a=n.getMeta(Fl),i;if(a)return a.historyState;n.getMeta(Az)&&(t=new ko(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Fl))return o.getMeta(Fl).redo?new ko(t.done.addTransform(n,void 0,r,Tf(e)),t.undone,Hw(n.mapping.maps),t.prevTime,t.prevComposition):new ko(t.done,t.undone.addTransform(n,void 0,r,Tf(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||!Tz(n,t.prevRanges)),h=o?Cg(t.prevRanges,n.mapping):Hw(n.mapping.maps);return new ko(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Tf(e)),xa.empty,h,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new ko(t.done.rebased(n,i),t.undone.rebased(n,i),Cg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ko(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Cg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Tz(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 Hw(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 Cg(t,e){if(!t)return null;let n=[];for(let r=0;r{let a=Fl.getState(n);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(r){let i=Mz(a,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const I3=P3(!1,!0),R3=P3(!0,!0);Dn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new hn({key:new wn("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 Iz=Dn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pz(this.options)]}});Dn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new hn({key:new wn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:a}=e,i=[];if(!n||!r)return on.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(rs.node(h,h+u.nodeSize,{class:this.options.className}))}),on.create(t,i)}}})]}});var Rz=Dn.create({name:"gapCursor",addProseMirrorPlugins(){return[yz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Jt(st(t,"allowGapCursor",n)))!=null?e:null}}}),Ww="placeholder";function Lz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Oz=Dn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ww,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${Lz(this.options.dataAttribute)}`:`data-${Ww}`;return[new hn({key:new wn("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&&nm(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const x=rs.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}),on.create(e,i)}}})]}});Dn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new hn({key:new wn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||_C(n.selection)||t.view.dragging?null:on.create(n.doc,[rs.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Kw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Dz=Dn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new wn(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 hn({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!Kw({node:o,types:r})},apply:(a,i)=>{if(!a.docChanged||a.getMeta("__uniqueIDTransaction"))return i;const o=a.doc.lastChild;return!Kw({node:o,types:r})}}})]}}),_z=Dn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>I3(t,e),redo:()=>({state:t,dispatch:e})=>R3(t,e)}},addProseMirrorPlugins(){return[Pz(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()}}}),$z=Dn.create({name:"starterKit",addExtensions(){var t,e,n,r;const a=[];return this.options.bold!==!1&&a.push(l$.configure(this.options.bold)),this.options.blockquote!==!1&&a.push(s$.configure(this.options.blockquote)),this.options.bulletList!==!1&&a.push(y3.configure(this.options.bulletList)),this.options.code!==!1&&a.push(u$.configure(this.options.code)),this.options.codeBlock!==!1&&a.push(p$.configure(this.options.codeBlock)),this.options.document!==!1&&a.push(m$.configure(this.options.document)),this.options.dropcursor!==!1&&a.push(Iz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&a.push(Rz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&a.push(x$.configure(this.options.hardBreak)),this.options.heading!==!1&&a.push(g$.configure(this.options.heading)),this.options.undoRedo!==!1&&a.push(_z.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&a.push(y$.configure(this.options.horizontalRule)),this.options.italic!==!1&&a.push(j$.configure(this.options.italic)),this.options.listItem!==!1&&a.push(b3.configure(this.options.listItem)),this.options.listKeymap!==!1&&a.push(S3.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&a.push(G$.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&a.push(E3.configure(this.options.orderedList)),this.options.paragraph!==!1&&a.push(lz.configure(this.options.paragraph)),this.options.strike!==!1&&a.push(uz.configure(this.options.strike)),this.options.text!==!1&&a.push(hz.configure(this.options.text)),this.options.underline!==!1&&a.push(fz.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&a.push(Dz.configure((r=this.options)==null?void 0:r.trailingNode)),a}}),zz=$z,Fz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Bz=Bn.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",Yt(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 U_({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[e3({find:Fz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Vz=Bz;function Hz(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:c}=t,u=r&&!a,h=K_(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),T=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(k);if(i!==null&&!T)return null;const C=w+v.index;let L=C+v[0].length;return u&&f.test(N.slice(L-1,L+1))&&(v[0]+=" ",L+=1),C=c.pos?{range:{from:C,to:L},query:v[0].slice(n.length),text:v[0]}:null}var Uz=new wn("suggestion");function Wz({pluginKey:t=Uz,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=Hz,shouldShow:v}){let k;const T=b==null?void 0:b(),C=()=>{const P=e.state.selection.$anchor.pos,F=e.view.coordsAtPos(P),{top:O,right:Q,bottom:re,left:D}=F;try{return new DOMRect(D,O,Q-D,re-O)}catch{return null}},L=(P,F)=>F?()=>{const O=t.getState(e.state),Q=O==null?void 0:O.decorationId,re=P.dom.querySelector(`[data-decoration-id="${Q}"]`);return(re==null?void 0:re.getBoundingClientRect())||null}:C;function R(P,F){var O;try{const re=t.getState(P.state),D=re!=null&&re.decorationId?P.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`):null,ne={editor:e,range:(re==null?void 0:re.range)||{from:0,to:0},query:(re==null?void 0:re.query)||null,text:(re==null?void 0:re.text)||null,items:[],command:le=>m({editor:e,range:(re==null?void 0:re.range)||{from:0,to:0},props:le}),decorationNode:D,clientRect:L(P,D)};(O=T==null?void 0:T.onExit)==null||O.call(T,ne)}catch{}const Q=P.state.tr.setMeta(F,{exit:!0});P.dispatch(Q)}const U=new hn({key:t,view(){return{update:async(P,F)=>{var O,Q,re,D,ne,le,me;const I=(O=this.key)==null?void 0:O.getState(F),Y=(Q=this.key)==null?void 0:Q.getState(P.state),B=I.active&&Y.active&&I.range.from!==Y.range.from,xe=!I.active&&Y.active,X=I.active&&!Y.active,V=!xe&&!X&&I.query!==Y.query,W=xe||B&&V,fe=V||B,he=X||B&&V;if(!W&&!fe&&!he)return;const de=he&&!W?I:Y,_=P.dom.querySelector(`[data-decoration-id="${de.decorationId}"]`);k={editor:e,range:de.range,query:de.query,text:de.text,items:[],command:J=>m({editor:e,range:de.range,props:J}),decorationNode:_,clientRect:L(P,_)},W&&((re=T==null?void 0:T.onBeforeStart)==null||re.call(T,k)),fe&&((D=T==null?void 0:T.onBeforeUpdate)==null||D.call(T,k)),(fe||W)&&(k.items=await x({editor:e,query:de.query})),he&&((ne=T==null?void 0:T.onExit)==null||ne.call(T,k)),fe&&((le=T==null?void 0:T.onUpdate)==null||le.call(T,k)),W&&((me=T==null?void 0:T.onStart)==null||me.call(T,k))},destroy:()=>{var P;k&&((P=T==null?void 0:T.onExit)==null||P.call(T,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(P,F,O,Q){const{isEditable:re}=e,{composing:D}=e.view,{selection:ne}=P,{empty:le,from:me}=ne,I={...F},Y=P.getMeta(t);if(Y&&Y.exit)return I.active=!1,I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null,I;if(I.composing=D,re&&(le||e.view.composing)){(meF.range.to)&&!D&&!F.composing&&(I.active=!1);const B=w({char:n,allowSpaces:r,allowToIncludeChar:a,allowedPrefixes:i,startOfLine:o,$position:ne.$from}),xe=`id_${Math.floor(Math.random()*4294967295)}`;B&&N({editor:e,state:Q,range:B.range,isActive:F.active})&&(!v||v({editor:e,range:B.range,query:B.query,text:B.text,transaction:P}))?(I.active=!0,I.decorationId=F.decorationId?F.decorationId:xe,I.range=B.range,I.query=B.query,I.text=B.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,F){var O,Q,re,D;const{active:ne,range:le}=U.getState(P.state);if(!ne)return!1;if(F.key==="Escape"||F.key==="Esc"){const I=U.getState(P.state),Y=(O=k==null?void 0:k.decorationNode)!=null?O:null,B=Y??(I!=null&&I.decorationId?P.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null);if(((Q=T==null?void 0:T.onKeyDown)==null?void 0:Q.call(T,{view:P,event:F,range:I.range}))||!1)return!0;const X={editor:e,range:I.range,query:I.query,text:I.text,items:[],command:V=>m({editor:e,range:I.range,props:V}),decorationNode:B,clientRect:B?()=>B.getBoundingClientRect()||null:null};return(re=T==null?void 0:T.onExit)==null||re.call(T,X),R(P,t),!0}return((D=T==null?void 0:T.onKeyDown)==null?void 0:D.call(T,{view:P,event:F,range:le}))||!1},decorations(P){const{active:F,range:O,decorationId:Q,query:re}=U.getState(P);if(!F)return null;const D=!(re!=null&&re.length),ne=[u];return D&&ne.push(f),on.create(P.doc,[rs.inline(O.from,O.to,{nodeName:c,class:ne.join(" "),"data-decoration-id":Q,"data-decoration-content":h})])}}});return U}function Kz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const a=new wn;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 L3(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Kz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function qw(t,e){const n=L3(t),r=n.find(a=>a.char===e);return r||(n.length?n[0]:null)}var qz=Bn.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",Yt(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=qw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Yt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Yt({"data-type":this.name},this.options.HTMLAttributes,e);const a=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof a=="string"?["span",Yt({"data-type":this.name},this.options.HTMLAttributes,e),a]:a},...t3({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:qw(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 $i,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 L3(this).map(Wz)}}),Gz=qz,Jz=Oz;let I0,R0;if(typeof WeakMap<"u"){let t=new WeakMap;I0=e=>t.get(e),R0=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;I0=r=>{for(let a=0;a(n==10&&(n=0),t[n++]=r,t[n++]=a)}var On=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-C});break}const L=a+C*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 Xz(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 eF(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 wa(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 im(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=Yl(e.$head)||tF(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function tF(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 L0(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function nF(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function rb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function O3(t,e,n){const r=t.node(-1),a=On.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 Xl(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 D3(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 SS(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(L0(r)&&L0(a)&&rb(r,a)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ei.rowSelection(r,a):i&&this.isColSelection()?Ei.colSelection(r,a):new Ei(r,a)}return ot.between(r,a)}content(){const e=this.$anchorCell.node(-1),n=On.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=Xl(k,0,w)),v>0&&(k=Xl(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=On.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 Ei&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),a=On.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(rs.node(r,r+n.nodeSize,{class:"selectedCell"}))}),on.create(t.doc,e)}function iF({$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 oF({$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 lF(t,e,n){const r=(e||t).selection,a=(e||t).doc;let i,o;if(r instanceof it&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=un.create(a,r.from);else if(o=="row"){const c=a.resolve(r.from+1);i=un.rowSelection(c,c)}else if(!n){const c=On.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];i=un.create(a,u+1,h)}}else r instanceof ot&&iF(r)?i=ot.create(a,r.from):r instanceof ot&&oF(r)&&(i=ot.create(a,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const cF=new wn("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=dF(t,a,i,n))};return e?e.doc!=t.doc&&$3(e.doc,t.doc,0,r):t.doc.descendants(r),n}function dF(t,e,n,r){const a=On.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;sF(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;mF(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=Gw(h)?u+1:f;i.replaceWith(m+r.tableStart,f+r.tableStart,c)}i.setSelection(new un(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function Qw(t,e){const n=Fs(t.schema);return NF(({node:r})=>n[r.type.spec.tableRole])(t,e)}function NF(t){return(e,n)=>{const r=e.selection;let a,i;if(r instanceof un){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;a=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(a=eF(r.$from),!a)return!1;i=(o=Yl(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=Xa(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 jF(t){return function(e,n){if(!wa(e))return!1;if(n){const r=Fs(e.schema),a=Xa(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}}Hu("row",{useDeprecatedLogic:!0});Hu("column",{useDeprecatedLogic:!0});const kF=Hu("cell",{useDeprecatedLogic:!0});function SF(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 gf(t,e){const n=t.selection;if(!(n instanceof un))return!1;if(e){const r=t.tr,a=Fs(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 ze(a,0,0))}),r.docChanged&&e(r)}return!0}function EF(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(Xl(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 AF(t,e,n,r,a,i,o){const c=t.doc.type.schema,u=Fs(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 un)return Mf(n,r,ft.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=V3(a,t,e);if(o==null)return!1;if(t=="horiz")return Mf(n,r,ft.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),u=O3(c,t,e);let h;return u?h=ft.near(u,1):e<0?h=ft.near(n.doc.resolve(c.before(-1)),-1):h=ft.near(n.doc.resolve(c.after(-1)),1),Mf(n,r,h)}}}function bf(t,e){return(n,r,a)=>{if(!a)return!1;const i=n.selection;let o;if(i instanceof un)o=i;else{const u=V3(a,t,e);if(u==null)return!1;o=new un(n.doc.resolve(u))}const c=O3(o.$headCell,t,e);return c?Mf(n,r,new un(o.$anchorCell,c)):!1}}function IF(t,e){const n=t.state.doc,r=Yl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new un(r))),!0):!1}function RF(t,e,n){if(!wa(t.state))return!1;let r=EF(n);const a=t.state.selection;if(a instanceof un){r||(r={width:1,height:1,rows:[Ce.from(O0(Fs(t.state.schema).cell,n))]});const i=a.$anchorCell.node(-1),o=a.$anchorCell.start(-1),c=On.get(i).rectBetween(a.$anchorCell.pos-o,a.$headCell.pos-o);return r=MF(r,c.right-c.left,c.bottom-c.top),tj(t.state,t.dispatch,o,c,r),!0}else if(r){const i=im(t.state),o=i.start(-1);return tj(t.state,t.dispatch,o,On.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function LF(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=nj(t,e.target);let a;if(e.shiftKey&&t.state.selection instanceof un)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(a=Yl(t.state.selection.$anchor))!=null&&((n=Tg(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=Tg(t,h);const m=Eo.getState(t.state)==null;if(!f||!rb(u,f))if(m)f=u;else return;const x=new un(u,f);if(m||!t.state.selection.eq(x)){const b=t.state.tr.setSelection(x);m&&b.setMeta(Eo,u.pos),t.dispatch(b)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),Eo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Eo,-1))}function c(u){const h=u,f=Eo.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(nj(t,h.target)!=r&&(m=Tg(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 V3(t,e,n){if(!(t.state.selection instanceof ot))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 nj(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Tg(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&&Yl(t.state.doc.resolve(r))||Yl(t.state.doc.resolve(a))}var OF=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")),D0(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,D0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function D0(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 _F(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=Er.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{$F(o,c,t,a)},mouseleave:o=>{zF(o)},mousedown:(o,c)=>{FF(o,c,e,n)}},decorations:o=>{const c=Er.getState(o);if(c&&c.activeHandle>-1)return WF(o,c.activeHandle)},nodeViews:{}}});return i}var _F=class Af{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Er);if(r&&r.setHandle!=null)return new Af(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Af(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let a=e.mapping.map(n.activeHandle,-1);return L0(e.doc.resolve(a))||(a=-1),new Af(a,n.dragging)}return n}};function $F(t,e,n,r){if(!t.editable)return;const a=Er.getState(t.state);if(a&&!a.dragging){const i=VF(e.target);let o=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?o=sj(t,e,"left",n):u-e.clientX<=n&&(o=sj(t,e,"right",n))}if(o!=a.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=On.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}H3(t,o)}}}function zF(t){if(!t.editable)return;const e=Er.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&H3(t,-1)}function FF(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=Er.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=BF(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Er,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){i.removeEventListener("mouseup",h),i.removeEventListener("mousemove",f);const x=Er.getState(t.state);x!=null&&x.dragging&&(HF(t,x.activeHandle,rj(x.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Er,{setDragging:null})))}function f(m){if(!m.which)return h(m);const x=Er.getState(t.state);if(x&&x.dragging){const b=rj(x.dragging,m,n);aj(t,x.activeHandle,b,r)}}return aj(t,o.activeHandle,u,r),i.addEventListener("mouseup",h),i.addEventListener("mousemove",f),e.preventDefault(),!0}function BF(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",Yt(this.options.HTMLAttributes,t),0]}}),W3=Bn.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",Yt(this.options.HTMLAttributes,t),0]}}),K3=Bn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Yt(this.options.HTMLAttributes,t),0]}});function _0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function ij(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 QF(t,e,n,r,a){const i=JF(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!YF(e))return!1;let n=0;const r=MC(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},XF="";function ZF(t){return(t||"").replace(/\s+/g," ").trim()}function eB(t,e,n={}){var r;const a=(r=n.cellLineSeparator)!=null?r:XF;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 T=ZF(k),C=v.type==="tableHeader";w.push({text:T,isHeader:C})}),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]=T),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(" | ")} | @@ -872,11 +872,11 @@ ${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 aB=Bn.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 端全宽播放)"]]}}),iB=Bn.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",Yt(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 cj(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}const oB=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)=>`
@${cj(o.name)} ${cj(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 lB(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(lj(t)),T=g.useCallback((re,D)=>{var I;const ne=x.current;if(!ne||!n)return!1;const le=lB(D);if(le.length>0)return D.preventDefault(),(async()=>{for(const Y of le)try{const F=await n(Y);F&&ne.chain().focus().setImage({src:F}).run()}catch(F){console.error("粘贴图片上传失败",F)}})(),!0;const me=(I=D.clipboardData)==null?void 0:I.getData("text/html");if(me&&/data:image\/[^;"']+;base64,/i.test(me)){D.preventDefault();const{from:Y,to:F}=ne.state.selection;return(async()=>{try{const xe=await uB(me,n);ne.chain().focus().insertContentAt({from:Y,to:F},xe).run()}catch(xe){console.error("粘贴 HTML 内 base64 转换失败",xe)}})(),!0}return!1},[n]),C=X7({extensions:[zz.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),Vz.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"rich-editor-img-thumb"}}),aB,Gz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:oB(a)}),iB,Jz.configure({placeholder:o}),q3.configure({resizable:!0}),K3,U3,W3],content:k.current,onUpdate:({editor:re})=>{e(re.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:T}});g.useEffect(()=>{x.current=C??null},[C]),g.useImperativeHandle(u,()=>({getHTML:()=>(C==null?void 0:C.getHTML())||"",getMarkdown:()=>rB((C==null?void 0:C.getHTML())||"")})),g.useEffect(()=>{if(C&&t!==C.getHTML()){const re=lj(t);re!==C.getHTML()&&C.commands.setContent(re)}},[t]);const L=g.useCallback(async re=>{if(r)return r(re);if(n)return n(re);throw new Error("未配置上传")},[n,r]),R=g.useCallback(async re=>{var ne;const D=(ne=re.target.files)==null?void 0:ne[0];if(!(!D||!C)){if(n){const le=await n(D);le&&C.chain().focus().setImage({src:le}).run()}else{const le=new FileReader;le.onload=()=>{typeof le.result=="string"&&C.chain().focus().setImage({src:le.result}).run()},le.readAsDataURL(D)}re.target.value=""}},[C,n]),U=g.useCallback(async re=>{var ne;const D=(ne=re.target.files)==null?void 0:ne[0];if(!(!D||!C)){try{const le=await L(D);le&&C.chain().focus().insertContent({type:"videoEmbed",attrs:{src:le}}).run()}catch(le){console.error(le)}re.target.value=""}},[C,L]),P=g.useCallback(async re=>{var ne;const D=(ne=re.target.files)==null?void 0:ne[0];if(!(!D||!C)){try{const le=await L(D);if(!le)return;const me=D.name||"附件";C.chain().focus().insertContent(`

附件 ${nB(me)}

`).run()}catch(le){console.error(le)}re.target.value=""}},[C,L]),z=g.useCallback(()=>{C&&C.chain().focus().insertContent("@").run()},[C]),O=g.useCallback(re=>{C&&C.chain().focus().insertContent([{type:"linkTag",attrs:{label:re.label,url:re.url||"",tagType:re.type||"url",tagId:re.id||"",pagePath:re.pagePath||"",appId:re.appId||"",mpKey:re.type==="miniprogram"&&re.appId||""}},{type:"text",text:" "}]).run()},[C]),Q=g.useCallback(()=>{!C||!b||(C.chain().focus().setLink({href:b}).run(),N(""),v(!1))},[C,b]);return C?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:()=>C.chain().focus().toggleBold().run(),className:C.isActive("bold")?"is-active":"",type:"button",children:s.jsx(NT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleItalic().run(),className:C.isActive("italic")?"is-active":"",type:"button",children:s.jsx(kM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleStrike().run(),className:C.isActive("strike")?"is-active":"",type:"button",children:s.jsx(AA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleCode().run(),className:C.isActive("code")?"is-active":"",type:"button",children:s.jsx(VT,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:1}).run(),className:C.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(pM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:2}).run(),className:C.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(xM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:3}).run(),className:C.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(yM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>C.chain().focus().toggleBulletList().run(),className:C.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(LM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleOrderedList().run(),className:C.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(ak,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleBlockquote().run(),className:C.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(oA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(KM,{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:U,className:"hidden"}),s.jsx("input",{ref:m,type:"file",onChange:P,className:"hidden"}),s.jsx("button",{onClick:()=>{var re;return(re=h.current)==null?void 0:re.click()},type:"button",title:"上传图片",children:s.jsx(rk,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var re;return(re=f.current)==null?void 0:re.click()},type:"button",title:"上传视频",disabled:!r&&!n,children:s.jsx(WA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var re;return(re=m.current)==null?void 0:re.click()},type:"button",title:"上传附件(生成下载链接)",disabled:!r&&!n,children:s.jsx(YM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:z,type:"button",title:"插入 @ 并选择人物",className:a.length?"mention-trigger-btn":"",disabled:a.length===0,children:s.jsx(xT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v(!w),className:C.isActive("link")?"is-active":"",type:"button",title:"链接",children:s.jsx(Wg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",title:"表格",children:s.jsx(IA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>C.chain().focus().undo().run(),disabled:!C.can().undo(),type:"button",children:s.jsx(zA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().redo().run(),disabled:!C.can().redo(),type:"button",children:s.jsx(cA,{className:"w-4 h-4"})})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-divider"}),s.jsx("div",{className:"toolbar-group",children:s.jsxs("select",{className:"link-tag-select",onChange:re=>{const D=i.find(ne=>ne.id===re.target.value);D&&O(D),re.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(re=>s.jsx("option",{value:re.id,children:re.label},re.id))]})})]})]}),w&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:b,onChange:re=>N(re.target.value),onKeyDown:re=>re.key==="Enter"&&Q(),className:"link-input"}),s.jsx("button",{onClick:Q,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{C.chain().focus().unsetLink().run(),v(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(r3,{editor:C})]}):null});$0.displayName="RichEditor";const hB=["top","right","bottom","left"],Jo=Math.min,Sr=Math.max,Ap=Math.round,Nf=Math.floor,Ka=t=>({x:t,y:t}),fB={left:"right",right:"left",bottom:"top",top:"bottom"},pB={start:"end",end:"start"};function z0(t,e,n){return Sr(t,Jo(e,n))}function Vi(t,e){return typeof t=="function"?t(e):t}function Hi(t){return t.split("-")[0]}function bd(t){return t.split("-")[1]}function ab(t){return t==="x"?"y":"x"}function ib(t){return t==="y"?"height":"width"}const mB=new Set(["top","bottom"]);function Wa(t){return mB.has(Hi(t))?"y":"x"}function ob(t){return ab(Wa(t))}function xB(t,e,n){n===void 0&&(n=!1);const r=bd(t),a=ob(t),i=ib(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Pp(o)),[o,Pp(o)]}function gB(t){const e=Pp(t);return[F0(t),e,F0(e)]}function F0(t){return t.replace(/start|end/g,e=>pB[e])}const dj=["left","right"],uj=["right","left"],yB=["top","bottom"],bB=["bottom","top"];function vB(t,e,n){switch(t){case"top":case"bottom":return n?e?uj:dj:e?dj:uj;case"left":case"right":return e?yB:bB;default:return[]}}function NB(t,e,n,r){const a=bd(t);let i=vB(Hi(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(F0)))),i}function Pp(t){return t.replace(/left|right|bottom|top/g,e=>fB[e])}function wB(t){return{top:0,right:0,bottom:0,left:0,...t}}function G3(t){return typeof t!="number"?wB(t):{top:t,right:t,bottom:t,left:t}}function Ip(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 hj(t,e,n){let{reference:r,floating:a}=t;const i=Wa(e),o=ob(e),c=ib(o),u=Hi(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(bd(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 jB(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}=Vi(e,t),N=G3(b),v=c[x?m==="floating"?"reference":"floating":m],k=Ip(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})),T=m==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),L=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},R=Ip(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:T,offsetParent:C,strategy:u}):T);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 kB=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}=hj(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}=Vi(t,e)||{};if(h==null)return{};const m=G3(f),x={x:n,y:r},b=ob(a),N=ib(b),w=await o.getDimensions(h),v=b==="y",k=v?"top":"left",T=v?"bottom":"right",C=v?"clientHeight":"clientWidth",L=i.reference[N]+i.reference[b]-x[b]-i.floating[N],R=x[b]-i.reference[b],U=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let P=U?U[C]:0;(!P||!await(o.isElement==null?void 0:o.isElement(U)))&&(P=c.floating[C]||i.floating[N]);const z=L/2-R/2,O=P/2-w[N]/2-1,Q=Jo(m[k],O),re=Jo(m[T],O),D=Q,ne=P-w[N]-re,le=P/2-w[N]/2+z,me=z0(D,le,ne),I=!u.arrow&&bd(a)!=null&&le!==me&&i.reference[N]/2-(lele<=0)){var re,D;const le=(((re=i.flip)==null?void 0:re.index)||0)+1,me=P[le];if(me&&(!(m==="alignment"?T!==Wa(me):!1)||Q.every(F=>Wa(F.placement)===T?F.overflows[0]>0:!0)))return{data:{index:le,overflows:Q},reset:{placement:me}};let I=(D=Q.filter(Y=>Y.overflows[0]<=0).sort((Y,F)=>Y.overflows[1]-F.overflows[1])[0])==null?void 0:D.placement;if(!I)switch(b){case"bestFit":{var ne;const Y=(ne=Q.filter(F=>{if(U){const xe=Wa(F.placement);return xe===T||xe==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(xe=>xe>0).reduce((xe,X)=>xe+X,0)]).sort((F,xe)=>F[1]-xe[1])[0])==null?void 0:ne[0];Y&&(I=Y);break}case"initialPlacement":I=c;break}if(a!==I)return{reset:{placement:I}}}return{}}}};function fj(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function pj(t){return hB.some(e=>t[e]>=0)}const EB=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:a="referenceHidden",...i}=Vi(t,e);switch(a){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),c=fj(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:pj(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),c=fj(o,n.floating);return{data:{escapedOffsets:c,escaped:pj(c)}}}default:return{}}}}},J3=new Set(["left","top"]);async function TB(t,e){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=Hi(n),c=bd(n),u=Wa(n)==="y",h=J3.has(o)?-1:1,f=i&&u?-1:1,m=Vi(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 MB=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 TB(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}}}}},AB=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:T,y:C}=k;return{x:T,y:C}}},...h}=Vi(t,e),f={x:n,y:r},m=await i.detectOverflow(e,h),x=Wa(Hi(a)),b=ab(x);let N=f[b],w=f[x];if(o){const k=b==="y"?"top":"left",T=b==="y"?"bottom":"right",C=N+m[k],L=N-m[T];N=z0(C,N,L)}if(c){const k=x==="y"?"top":"left",T=x==="y"?"bottom":"right",C=w+m[k],L=w-m[T];w=z0(C,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}}}}}},PB=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}=Vi(t,e),f={x:n,y:r},m=Wa(a),x=ab(m);let b=f[x],N=f[m];const w=Vi(c,e),v=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const C=x==="y"?"height":"width",L=i.reference[x]-i.floating[C]+v.mainAxis,R=i.reference[x]+i.reference[C]-v.mainAxis;bR&&(b=R)}if(h){var k,T;const C=x==="y"?"width":"height",L=J3.has(Hi(a)),R=i.reference[m]-i.floating[C]+(L&&((k=o.offset)==null?void 0:k[m])||0)+(L?0:v.crossAxis),U=i.reference[m]+i.reference[C]+(L?0:((T=o.offset)==null?void 0:T[m])||0)-(L?v.crossAxis:0);NU&&(N=U)}return{[x]:b,[m]:N}}}},IB=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}=Vi(t,e),f=await o.detectOverflow(e,h),m=Hi(a),x=bd(a),b=Wa(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 T=w-f.top-f.bottom,C=N-f.left-f.right,L=Jo(w-f[v],T),R=Jo(N-f[k],C),U=!e.middlewareData.shift;let P=L,z=R;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(z=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(P=T),U&&!x){const Q=Sr(f.left,0),re=Sr(f.right,0),D=Sr(f.top,0),ne=Sr(f.bottom,0);b?z=N-2*(Q!==0||re!==0?Q+re:Sr(f.left,f.right)):P=w-2*(D!==0||ne!==0?D+ne:Sr(f.top,f.bottom))}await u({...e,availableWidth:z,availableHeight:P});const O=await o.getDimensions(c.floating);return N!==O.width||w!==O.height?{reset:{rects:!0}}:{}}}};function om(){return typeof window<"u"}function vd(t){return Q3(t)?(t.nodeName||"").toLowerCase():"#document"}function Mr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Za(t){var e;return(e=(Q3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Q3(t){return om()?t instanceof Node||t instanceof Mr(t).Node:!1}function ba(t){return om()?t instanceof Element||t instanceof Mr(t).Element:!1}function Qa(t){return om()?t instanceof HTMLElement||t instanceof Mr(t).HTMLElement:!1}function mj(t){return!om()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Mr(t).ShadowRoot}const RB=new Set(["inline","contents"]);function Zu(t){const{overflow:e,overflowX:n,overflowY:r,display:a}=va(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!RB.has(a)}const LB=new Set(["table","td","th"]);function OB(t){return LB.has(vd(t))}const DB=[":popover-open",":modal"];function lm(t){return DB.some(e=>{try{return t.matches(e)}catch{return!1}})}const _B=["transform","translate","scale","rotate","perspective"],$B=["transform","translate","scale","rotate","perspective","filter"],zB=["paint","layout","strict","content"];function lb(t){const e=cb(),n=ba(t)?va(t):t;return _B.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)||$B.some(r=>(n.willChange||"").includes(r))||zB.some(r=>(n.contain||"").includes(r))}function FB(t){let e=Qo(t);for(;Qa(e)&&!ud(e);){if(lb(e))return e;if(lm(e))return null;e=Qo(e)}return null}function cb(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const BB=new Set(["html","body","#document"]);function ud(t){return BB.has(vd(t))}function va(t){return Mr(t).getComputedStyle(t)}function cm(t){return ba(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Qo(t){if(vd(t)==="html")return t;const e=t.assignedSlot||t.parentNode||mj(t)&&t.host||Za(t);return mj(e)?e.host:e}function Y3(t){const e=Qo(t);return ud(e)?t.ownerDocument?t.ownerDocument.body:t.body:Qa(e)&&Zu(e)?e:Y3(e)}function Uu(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=Y3(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=Mr(a);if(i){const c=B0(o);return e.concat(o,o.visualViewport||[],Zu(a)?a:[],c&&n?Uu(c):[])}return e.concat(a,Uu(a,[],n))}function B0(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function X3(t){const e=va(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const a=Qa(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,c=Ap(n)!==i||Ap(r)!==o;return c&&(n=i,r=o),{width:n,height:r,$:c}}function db(t){return ba(t)?t:t.contextElement}function nd(t){const e=db(t);if(!Qa(e))return Ka(1);const n=e.getBoundingClientRect(),{width:r,height:a,$:i}=X3(e);let o=(i?Ap(n.width):n.width)/r,c=(i?Ap(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const VB=Ka(0);function Z3(t){const e=Mr(t);return!cb()||!e.visualViewport?VB:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function HB(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Mr(t)?!1:e}function Zl(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=db(t);let o=Ka(1);e&&(r?ba(r)&&(o=nd(r)):o=nd(t));const c=HB(i,n,r)?Z3(i):Ka(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=Mr(i),b=r&&ba(r)?Mr(r):r;let N=x,w=B0(N);for(;w&&r&&b!==N;){const v=nd(w),k=w.getBoundingClientRect(),T=va(w),C=k.left+(w.clientLeft+parseFloat(T.paddingLeft))*v.x,L=k.top+(w.clientTop+parseFloat(T.paddingTop))*v.y;u*=v.x,h*=v.y,f*=v.x,m*=v.y,u+=C,h+=L,N=Mr(w),w=B0(N)}}return Ip({width:f,height:m,x:u,y:h})}function dm(t,e){const n=cm(t).scrollLeft;return e?e.left+n:Zl(Za(t)).left+n}function e4(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-dm(t,n),a=n.top+e.scrollTop;return{x:r,y:a}}function UB(t){let{elements:e,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=Za(r),c=e?lm(e.floating):!1;if(r===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Ka(1);const f=Ka(0),m=Qa(r);if((m||!m&&!i)&&((vd(r)!=="body"||Zu(o))&&(u=cm(r)),Qa(r))){const b=Zl(r);h=nd(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const x=o&&!m&&!i?e4(o,u):Ka(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 WB(t){return Array.from(t.getClientRects())}function KB(t){const e=Za(t),n=cm(t),r=t.ownerDocument.body,a=Sr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Sr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+dm(t);const c=-n.scrollTop;return va(r).direction==="rtl"&&(o+=Sr(e.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:c}}const xj=25;function qB(t,e){const n=Mr(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=cb();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=dm(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<=xj&&(i-=N)}else h<=xj&&(i+=h);return{width:i,height:o,x:c,y:u}}const GB=new Set(["absolute","fixed"]);function JB(t,e){const n=Zl(t,!0,e==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=Qa(t)?nd(t):Ka(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 gj(t,e,n){let r;if(e==="viewport")r=qB(t,n);else if(e==="document")r=KB(Za(t));else if(ba(e))r=JB(e,n);else{const a=Z3(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Ip(r)}function t4(t,e){const n=Qo(t);return n===e||!ba(n)||ud(n)?!1:va(n).position==="fixed"||t4(n,e)}function QB(t,e){const n=e.get(t);if(n)return n;let r=Uu(t,[],!1).filter(c=>ba(c)&&vd(c)!=="body"),a=null;const i=va(t).position==="fixed";let o=i?Qo(t):t;for(;ba(o)&&!ud(o);){const c=va(o),u=lb(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&GB.has(a.position)||Zu(o)&&!u&&t4(t,o))?r=r.filter(f=>f!==o):a=c,o=Qo(o)}return e.set(t,r),r}function YB(t){let{element:e,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?lm(e)?[]:QB(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=gj(e,f,a);return h.top=Sr(m.top,h.top),h.right=Jo(m.right,h.right),h.bottom=Jo(m.bottom,h.bottom),h.left=Sr(m.left,h.left),h},gj(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function XB(t){const{width:e,height:n}=X3(t);return{width:e,height:n}}function ZB(t,e,n){const r=Qa(e),a=Za(e),i=n==="fixed",o=Zl(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Ka(0);function h(){u.x=dm(a)}if(r||!r&&!i)if((vd(e)!=="body"||Zu(a))&&(c=cm(e)),r){const b=Zl(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?e4(a,c):Ka(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 Mg(t){return va(t).position==="static"}function yj(t,e){if(!Qa(t)||va(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Za(t)===n&&(n=n.ownerDocument.body),n}function n4(t,e){const n=Mr(t);if(lm(t))return n;if(!Qa(t)){let a=Qo(t);for(;a&&!ud(a);){if(ba(a)&&!Mg(a))return a;a=Qo(a)}return n}let r=yj(t,e);for(;r&&OB(r)&&Mg(r);)r=yj(r,e);return r&&ud(r)&&Mg(r)&&!lb(r)?n:r||FB(t)||n}const e9=async function(t){const e=this.getOffsetParent||n4,n=this.getDimensions,r=await n(t.floating);return{reference:ZB(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function t9(t){return va(t).direction==="rtl"}const n9={convertOffsetParentRelativeRectToViewportRelativeRect:UB,getDocumentElement:Za,getClippingRect:YB,getOffsetParent:n4,getElementRects:e9,getClientRects:WB,getDimensions:XB,getScale:nd,isElement:ba,isRTL:t9};function s4(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function s9(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=Nf(m),w=Nf(a.clientWidth-(f+x)),v=Nf(a.clientHeight-(m+b)),k=Nf(f),C={rootMargin:-N+"px "+-w+"px "+-v+"px "+-k+"px",threshold:Sr(0,Jo(1,u))||1};let L=!0;function R(U){const P=U[0].intersectionRatio;if(P!==u){if(!L)return o();P?o(!1,P):r=setTimeout(()=>{o(!1,1e-7)},1e3)}P===1&&!s4(h,t.getBoundingClientRect())&&o(),L=!1}try{n=new IntersectionObserver(R,{...C,root:a.ownerDocument})}catch{n=new IntersectionObserver(R,C)}n.observe(t)}return o(!0),i}function r9(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=db(t),f=a||i?[...h?Uu(h):[],...Uu(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?s9(h,n):null;let x=-1,b=null;o&&(b=new ResizeObserver(k=>{let[T]=k;T&&T.target===h&&b&&(b.unobserve(e),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var C;(C=b)==null||C.observe(e)})),n()}),h&&!u&&b.observe(h),b.observe(e));let N,w=u?Zl(t):null;u&&v();function v(){const k=Zl(t);w&&!s4(w,k)&&n(),w=k,N=requestAnimationFrame(v)}return n(),()=>{var k;f.forEach(T=>{a&&T.removeEventListener("scroll",n),i&&T.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,u&&cancelAnimationFrame(N)}}const a9=MB,i9=AB,o9=CB,l9=IB,c9=EB,bj=SB,d9=PB,u9=(t,e,n)=>{const r=new Map,a={platform:n9,...n},i={...a.platform,_c:r};return kB(t,e,{...a,platform:i})};var h9=typeof document<"u",f9=function(){},Pf=h9?g.useLayoutEffect:f9;function Rp(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(!Rp(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)&&!Rp(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function r4(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function vj(t,e){const n=r4(t);return Math.round(e*n)/n}function Ag(t){const e=g.useRef(t);return Pf(()=>{e.current=t}),e}function p9(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);Rp(x,r)||b(r);const[N,w]=g.useState(null),[v,k]=g.useState(null),T=g.useCallback(F=>{F!==U.current&&(U.current=F,w(F))},[]),C=g.useCallback(F=>{F!==P.current&&(P.current=F,k(F))},[]),L=i||N,R=o||v,U=g.useRef(null),P=g.useRef(null),z=g.useRef(f),O=u!=null,Q=Ag(u),re=Ag(a),D=Ag(h),ne=g.useCallback(()=>{if(!U.current||!P.current)return;const F={placement:e,strategy:n,middleware:x};re.current&&(F.platform=re.current),u9(U.current,P.current,F).then(xe=>{const X={...xe,isPositioned:D.current!==!1};le.current&&!Rp(z.current,X)&&(z.current=X,hd.flushSync(()=>{m(X)}))})},[x,e,n,re,D]);Pf(()=>{h===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,m(F=>({...F,isPositioned:!1})))},[h]);const le=g.useRef(!1);Pf(()=>(le.current=!0,()=>{le.current=!1}),[]),Pf(()=>{if(L&&(U.current=L),R&&(P.current=R),L&&R){if(Q.current)return Q.current(L,R,ne);ne()}},[L,R,ne,Q,O]);const me=g.useMemo(()=>({reference:U,floating:P,setReference:T,setFloating:C}),[T,C]),I=g.useMemo(()=>({reference:L,floating:R}),[L,R]),Y=g.useMemo(()=>{const F={position:n,left:0,top:0};if(!I.floating)return F;const xe=vj(I.floating,f.x),X=vj(I.floating,f.y);return c?{...F,transform:"translate("+xe+"px, "+X+"px)",...r4(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:xe,top:X}},[n,c,I.floating,f.x,f.y]);return g.useMemo(()=>({...f,update:ne,refs:me,elements:I,floatingStyles:Y}),[f,ne,me,I,Y])}const m9=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?bj({element:r.current,padding:a}).fn(n):{}:r?bj({element:r,padding:a}).fn(n):{}}}},x9=(t,e)=>({...a9(t),options:[t,e]}),g9=(t,e)=>({...i9(t),options:[t,e]}),y9=(t,e)=>({...d9(t),options:[t,e]}),b9=(t,e)=>({...o9(t),options:[t,e]}),v9=(t,e)=>({...l9(t),options:[t,e]}),N9=(t,e)=>({...c9(t),options:[t,e]}),w9=(t,e)=>({...m9(t),options:[t,e]});var j9="Arrow",a4=g.forwardRef((t,e)=>{const{children:n,width:r=10,height:a=5,...i}=t;return s.jsx(Et.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"})})});a4.displayName=j9;var k9=a4,ub="Popper",[i4,o4]=Zo(ub),[S9,l4]=i4(ub),c4=t=>{const{__scopePopper:e,children:n}=t,[r,a]=g.useState(null);return s.jsx(S9,{scope:e,anchor:r,onAnchorChange:a,children:n})};c4.displayName=ub;var d4="PopperAnchor",u4=g.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=l4(d4,n),o=g.useRef(null),c=Xt(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(Et.div,{...a,ref:c})});u4.displayName=d4;var hb="PopperContent",[C9,E9]=i4(hb),h4=g.forwardRef((t,e)=>{var J,$,Z,ae,we,Fe;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=l4(hb,n),[k,T]=g.useState(null),C=Xt(e,Ue=>T(Ue)),[L,R]=g.useState(null),U=fy(L),P=(U==null?void 0:U.width)??0,z=(U==null?void 0:U.height)??0,O=r+(i!=="center"?"-"+i:""),Q=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},re=Array.isArray(h)?h:[h],D=re.length>0,ne={padding:Q,boundary:re.filter(M9),altBoundary:D},{refs:le,floatingStyles:me,placement:I,isPositioned:Y,middlewareData:F}=p9({strategy:"fixed",placement:O,whileElementsMounted:(...Ue)=>r9(...Ue,{animationFrame:b==="always"}),elements:{reference:v.anchor},middleware:[x9({mainAxis:a+z,alignmentAxis:o}),u&&g9({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?y9():void 0,...ne}),u&&b9({...ne}),v9({...ne,apply:({elements:Ue,rects:wt,availableWidth:jn,availableHeight:pt})=>{const{width:At,height:fn}=wt.reference,Vn=Ue.floating.style;Vn.setProperty("--radix-popper-available-width",`${jn}px`),Vn.setProperty("--radix-popper-available-height",`${pt}px`),Vn.setProperty("--radix-popper-anchor-width",`${At}px`),Vn.setProperty("--radix-popper-anchor-height",`${fn}px`)}}),L&&w9({element:L,padding:c}),A9({arrowWidth:P,arrowHeight:z}),x&&N9({strategy:"referenceHidden",...ne})]}),[xe,X]=m4(I),V=Uo(N);$s(()=>{Y&&(V==null||V())},[Y,V]);const W=(J=F.arrow)==null?void 0:J.x,fe=($=F.arrow)==null?void 0:$.y,he=((Z=F.arrow)==null?void 0:Z.centerOffset)!==0,[de,_]=g.useState();return $s(()=>{k&&_(window.getComputedStyle(k).zIndex)},[k]),s.jsx("div",{ref:le.setFloating,"data-radix-popper-content-wrapper":"",style:{...me,transform:Y?me.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(ae=F.transformOrigin)==null?void 0:ae.x,(we=F.transformOrigin)==null?void 0:we.y].join(" "),...((Fe=F.hide)==null?void 0:Fe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(C9,{scope:n,placedSide:xe,onArrowChange:R,arrowX:W,arrowY:fe,shouldHideArrow:he,children:s.jsx(Et.div,{"data-side":xe,"data-align":X,...w,ref:C,style:{...w.style,animation:Y?void 0:"none"}})})})});h4.displayName=hb;var f4="PopperArrow",T9={top:"bottom",right:"left",bottom:"top",left:"right"},p4=g.forwardRef(function(e,n){const{__scopePopper:r,...a}=e,i=E9(f4,r),o=T9[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(k9,{...a,ref:n,style:{...a.style,display:"block"}})})});p4.displayName=f4;function M9(t){return t!==null}var A9=t=>({name:"transformOrigin",options:t,fn(e){var v,k,T;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]=m4(n),m={start:"0%",center:"50%",end:"100%"}[f],x=(((k=a.arrow)==null?void 0:k.x)??0)+c/2,b=(((T=a.arrow)==null?void 0:T.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 m4(t){const[e,n="center"]=t.split("-");return[e,n]}var P9=c4,I9=u4,R9=h4,L9=p4,x4=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"}),O9="VisuallyHidden",D9=g.forwardRef((t,e)=>s.jsx(Et.span,{...t,ref:e,style:{...x4,...t.style}}));D9.displayName=O9;var _9=[" ","Enter","ArrowUp","ArrowDown"],$9=[" ","Enter"],ec="Select",[um,hm,z9]=dy(ec),[Nd]=Zo(ec,[z9,o4]),fm=o4(),[F9,rl]=Nd(ec),[B9,V9]=Nd(ec),g4=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=fm(e),[v,k]=g.useState(null),[T,C]=g.useState(null),[L,R]=g.useState(!1),U=Bp(h),[P,z]=Hl({prop:r,defaultProp:a??!1,onChange:i,caller:ec}),[O,Q]=Hl({prop:o,defaultProp:c,onChange:u,caller:ec}),re=g.useRef(null),D=v?N||!!v.closest("form"):!0,[ne,le]=g.useState(new Set),me=Array.from(ne).map(I=>I.props.value).join(";");return s.jsx(P9,{...w,children:s.jsxs(F9,{required:b,scope:e,trigger:v,onTriggerChange:k,valueNode:T,onValueNodeChange:C,valueNodeHasChildren:L,onValueNodeHasChildrenChange:R,contentId:_o(),value:O,onValueChange:Q,open:P,onOpenChange:z,dir:U,triggerPointerDownPosRef:re,disabled:x,children:[s.jsx(um.Provider,{scope:e,children:s.jsx(B9,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(I=>{le(Y=>new Set(Y).add(I))},[]),onNativeOptionRemove:g.useCallback(I=>{le(Y=>{const F=new Set(Y);return F.delete(I),F})},[]),children:n})}),D?s.jsxs(z4,{"aria-hidden":!0,required:b,tabIndex:-1,name:f,autoComplete:m,value:O,onChange:I=>Q(I.target.value),disabled:x,form:N,children:[O===void 0?s.jsx("option",{value:""}):null,Array.from(ne)]},me):null]})})};g4.displayName=ec;var y4="SelectTrigger",b4=g.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=fm(n),o=rl(y4,n),c=o.disabled||r,u=Xt(e,o.onTriggerChange),h=hm(n),f=g.useRef("touch"),[m,x,b]=B4(w=>{const v=h().filter(C=>!C.disabled),k=v.find(C=>C.value===o.value),T=V4(v,w,k);T!==void 0&&o.onValueChange(T.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(I9,{asChild:!0,...i,children:s.jsx(Et.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":F4(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===" ")&&_9.includes(w.key)&&(N(),w.preventDefault())})})})});b4.displayName=y4;var v4="SelectValue",N4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=t,u=rl(v4,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Xt(e,u.onValueNodeChange);return $s(()=>{h(f)},[h,f]),s.jsx(Et.span,{...c,ref:m,style:{pointerEvents:"none"},children:F4(u.value)?s.jsx(s.Fragment,{children:o}):i})});N4.displayName=v4;var H9="SelectIcon",w4=g.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...a}=t;return s.jsx(Et.span,{"aria-hidden":!0,...a,ref:e,children:r||"▼"})});w4.displayName=H9;var U9="SelectPortal",j4=t=>s.jsx(ay,{asChild:!0,...t});j4.displayName=U9;var tc="SelectContent",k4=g.forwardRef((t,e)=>{const n=rl(tc,t.__scopeSelect),[r,a]=g.useState();if($s(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?hd.createPortal(s.jsx(S4,{scope:t.__scopeSelect,children:s.jsx(um.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),i):null}return s.jsx(C4,{...t,ref:e})});k4.displayName=tc;var pa=10,[S4,al]=Nd(tc),W9="SelectContentImpl",K9=Pu("SelectContent.RemoveScroll"),C4=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,T=rl(tc,n),[C,L]=g.useState(null),[R,U]=g.useState(null),P=Xt(e,J=>L(J)),[z,O]=g.useState(null),[Q,re]=g.useState(null),D=hm(n),[ne,le]=g.useState(!1),me=g.useRef(!1);g.useEffect(()=>{if(C)return zk(C)},[C]),Ak();const I=g.useCallback(J=>{const[$,...Z]=D().map(Fe=>Fe.ref.current),[ae]=Z.slice(-1),we=document.activeElement;for(const Fe of J)if(Fe===we||(Fe==null||Fe.scrollIntoView({block:"nearest"}),Fe===$&&R&&(R.scrollTop=0),Fe===ae&&R&&(R.scrollTop=R.scrollHeight),Fe==null||Fe.focus(),document.activeElement!==we))return},[D,R]),Y=g.useCallback(()=>I([z,C]),[I,z,C]);g.useEffect(()=>{ne&&Y()},[ne,Y]);const{onOpenChange:F,triggerPointerDownPosRef:xe}=T;g.useEffect(()=>{if(C){let J={x:0,y:0};const $=ae=>{var we,Fe;J={x:Math.abs(Math.round(ae.pageX)-(((we=xe.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((Fe=xe.current)==null?void 0:Fe.y)??0))}},Z=ae=>{J.x<=10&&J.y<=10?ae.preventDefault():C.contains(ae.target)||F(!1),document.removeEventListener("pointermove",$),xe.current=null};return xe.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",Z,{capture:!0})}}},[C,F,xe]),g.useEffect(()=>{const J=()=>F(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[F]);const[X,V]=B4(J=>{const $=D().filter(we=>!we.disabled),Z=$.find(we=>we.ref.current===document.activeElement),ae=V4($,J,Z);ae&&setTimeout(()=>ae.ref.current.focus())}),W=g.useCallback((J,$,Z)=>{const ae=!me.current&&!Z;(T.value!==void 0&&T.value===$||ae)&&(O(J),ae&&(me.current=!0))},[T.value]),fe=g.useCallback(()=>C==null?void 0:C.focus(),[C]),he=g.useCallback((J,$,Z)=>{const ae=!me.current&&!Z;(T.value!==void 0&&T.value===$||ae)&&re(J)},[T.value]),de=r==="popper"?V0:E4,_=de===V0?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:x,collisionPadding:b,sticky:N,hideWhenDetached:w,avoidCollisions:v}:{};return s.jsx(S4,{scope:n,content:C,viewport:R,onViewportChange:U,itemRefCallback:W,selectedItem:z,onItemLeave:fe,itemTextRefCallback:he,focusSelectedItem:Y,selectedItemText:Q,position:r,isPositioned:ne,searchRef:X,children:s.jsx(iy,{as:K9,allowPinchZoom:!0,children:s.jsx(ry,{asChild:!0,trapped:T.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:jt(a,J=>{var $;($=T.trigger)==null||$.focus({preventScroll:!0}),J.preventDefault()}),children:s.jsx(sy,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:s.jsx(de,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:J=>J.preventDefault(),...k,..._,onPlaced:()=>le(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:jt(k.onKeyDown,J=>{const $=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!$&&J.key.length===1&&V(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ae=D().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const we=J.target,Fe=ae.indexOf(we);ae=ae.slice(Fe+1)}setTimeout(()=>I(ae)),J.preventDefault()}})})})})})})});C4.displayName=W9;var q9="SelectItemAlignedPosition",E4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=rl(tc,n),o=al(tc,n),[c,u]=g.useState(null),[h,f]=g.useState(null),m=Xt(e,P=>f(P)),x=hm(n),b=g.useRef(!1),N=g.useRef(!0),{viewport:w,selectedItem:v,selectedItemText:k,focusSelectedItem:T}=o,C=g.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&v&&k){const P=i.trigger.getBoundingClientRect(),z=h.getBoundingClientRect(),O=i.valueNode.getBoundingClientRect(),Q=k.getBoundingClientRect();if(i.dir!=="rtl"){const we=Q.left-z.left,Fe=O.left-we,Ue=P.left-Fe,wt=P.width+Ue,jn=Math.max(wt,z.width),pt=window.innerWidth-pa,At=Ff(Fe,[pa,Math.max(pa,pt-jn)]);c.style.minWidth=wt+"px",c.style.left=At+"px"}else{const we=z.right-Q.right,Fe=window.innerWidth-O.right-we,Ue=window.innerWidth-P.right-Fe,wt=P.width+Ue,jn=Math.max(wt,z.width),pt=window.innerWidth-pa,At=Ff(Fe,[pa,Math.max(pa,pt-jn)]);c.style.minWidth=wt+"px",c.style.right=At+"px"}const re=x(),D=window.innerHeight-pa*2,ne=w.scrollHeight,le=window.getComputedStyle(h),me=parseInt(le.borderTopWidth,10),I=parseInt(le.paddingTop,10),Y=parseInt(le.borderBottomWidth,10),F=parseInt(le.paddingBottom,10),xe=me+I+ne+F+Y,X=Math.min(v.offsetHeight*5,xe),V=window.getComputedStyle(w),W=parseInt(V.paddingTop,10),fe=parseInt(V.paddingBottom,10),he=P.top+P.height/2-pa,de=D-he,_=v.offsetHeight/2,J=v.offsetTop+_,$=me+I+J,Z=xe-$;if($<=he){const we=re.length>0&&v===re[re.length-1].ref.current;c.style.bottom="0px";const Fe=h.clientHeight-w.offsetTop-w.offsetHeight,Ue=Math.max(de,_+(we?fe:0)+Fe+Y),wt=$+Ue;c.style.height=wt+"px"}else{const we=re.length>0&&v===re[0].ref.current;c.style.top="0px";const Ue=Math.max(he,me+w.offsetTop+(we?W:0)+_)+Z;c.style.height=Ue+"px",w.scrollTop=$-he+w.offsetTop}c.style.margin=`${pa}px 0`,c.style.minHeight=X+"px",c.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[x,i.trigger,i.valueNode,c,h,w,v,k,i.dir,r]);$s(()=>C(),[C]);const[L,R]=g.useState();$s(()=>{h&&R(window.getComputedStyle(h).zIndex)},[h]);const U=g.useCallback(P=>{P&&N.current===!0&&(C(),T==null||T(),N.current=!1)},[C,T]);return s.jsx(J9,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:b,onScrollButtonChange:U,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:s.jsx(Et.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});E4.displayName=q9;var G9="SelectPopperPosition",V0=g.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=pa,...i}=t,o=fm(n);return s.jsx(R9,{...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)"}})});V0.displayName=G9;var[J9,fb]=Nd(tc,{}),H0="SelectViewport",T4=g.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=al(H0,n),o=fb(H0,n),c=Xt(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(um.Slot,{scope:n,children:s.jsx(Et.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-pa*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})})})]})});T4.displayName=H0;var M4="SelectGroup",[Q9,Y9]=Nd(M4),X9=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=_o();return s.jsx(Q9,{scope:n,id:a,children:s.jsx(Et.div,{role:"group","aria-labelledby":a,...r,ref:e})})});X9.displayName=M4;var A4="SelectLabel",Z9=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Y9(A4,n);return s.jsx(Et.div,{id:a.id,...r,ref:e})});Z9.displayName=A4;var Lp="SelectItem",[eV,P4]=Nd(Lp),I4=g.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,c=rl(Lp,n),u=al(Lp,n),h=c.value===r,[f,m]=g.useState(i??""),[x,b]=g.useState(!1),N=Xt(e,T=>{var C;return(C=u.itemRefCallback)==null?void 0:C.call(u,T,r,a)}),w=_o(),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(eV,{scope:n,value:r,disabled:a,textId:w,isSelected:h,onItemTextChange:g.useCallback(T=>{m(C=>C||((T==null?void 0:T.textContent)??"").trim())},[]),children:s.jsx(um.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:s.jsx(Et.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,T=>{v.current=T.pointerType}),onPointerMove:jt(o.onPointerMove,T=>{var C;v.current=T.pointerType,a?(C=u.onItemLeave)==null||C.call(u):v.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:jt(o.onPointerLeave,T=>{var C;T.currentTarget===document.activeElement&&((C=u.onItemLeave)==null||C.call(u))}),onKeyDown:jt(o.onKeyDown,T=>{var L;((L=u.searchRef)==null?void 0:L.current)!==""&&T.key===" "||($9.includes(T.key)&&k(),T.key===" "&&T.preventDefault())})})})})});I4.displayName=Lp;var fu="SelectItemText",R4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=rl(fu,n),c=al(fu,n),u=P4(fu,n),h=V9(fu,n),[f,m]=g.useState(null),x=Xt(e,k=>m(k),u.onItemTextChange,k=>{var T;return(T=c.itemTextRefCallback)==null?void 0:T.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 $s(()=>(w(N),()=>v(N)),[w,v,N]),s.jsxs(s.Fragment,{children:[s.jsx(Et.span,{id:u.textId,...i,ref:x}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?hd.createPortal(i.children,o.valueNode):null]})});R4.displayName=fu;var L4="SelectItemIndicator",O4=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return P4(L4,n).isSelected?s.jsx(Et.span,{"aria-hidden":!0,...r,ref:e}):null});O4.displayName=L4;var U0="SelectScrollUpButton",D4=g.forwardRef((t,e)=>{const n=al(U0,t.__scopeSelect),r=fb(U0,t.__scopeSelect),[a,i]=g.useState(!1),o=Xt(e,r.onScrollButtonChange);return $s(()=>{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});D4.displayName=U0;var W0="SelectScrollDownButton",_4=g.forwardRef((t,e)=>{const n=al(W0,t.__scopeSelect),r=fb(W0,t.__scopeSelect),[a,i]=g.useState(!1),o=Xt(e,r.onScrollButtonChange);return $s(()=>{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});_4.displayName=W0;var $4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=al("SelectScrollButton",n),o=g.useRef(null),c=hm(n),u=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>u(),[u]),$s(()=>{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(Et.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()})})}),tV="SelectSeparator",nV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(Et.div,{"aria-hidden":!0,...r,ref:e})});nV.displayName=tV;var K0="SelectArrow",sV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=fm(n),i=rl(K0,n),o=al(K0,n);return i.open&&o.position==="popper"?s.jsx(L9,{...a,...r,ref:e}):null});sV.displayName=K0;var rV="SelectBubbleInput",z4=g.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const a=g.useRef(null),i=Xt(r,a),o=hy(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(Et.select,{...n,style:{...x4,...n.style},ref:i,defaultValue:e})});z4.displayName=rV;function F4(t){return t===""||t===void 0}function B4(t){const e=Uo(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 V4(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=aV(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 aV(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var iV=g4,H4=b4,oV=N4,lV=w4,cV=j4,U4=k4,dV=T4,W4=I4,uV=R4,hV=O4,fV=D4,pV=_4;const To=iV,Mo=oV,Ii=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(H4,{ref:r,className:zt("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(lV,{asChild:!0,children:s.jsx(Bi,{className:"h-4 w-4 opacity-50"})})]}));Ii.displayName=H4.displayName;const Ri=g.forwardRef(({className:t,children:e,position:n="popper",...r},a)=>s.jsx(cV,{children:s.jsxs(U4,{ref:a,className:zt("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(fV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Bg,{className:"h-4 w-4"})}),s.jsx(dV,{className:"p-1",children:e}),s.jsx(pV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Bi,{className:"h-4 w-4"})})]})}));Ri.displayName=U4.displayName;const us=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(W4,{ref:r,className:zt("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(hV,{children:s.jsx(_p,{className:"h-4 w-4"})})}),s.jsx(uV,{children:e})]}));us.displayName=W4.displayName;const Nj=["📖","📕","📗","📘","📙","📓","📔","📒","📚","📖"];function mV(t){return t.title==="序言"||t.title.includes("序言")}function wj(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 Pg(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 xV({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),[T,C]=g.useState(null),L=(D,ne)=>(v==null?void 0:v.type)===D&&(v==null?void 0:v.id)===ne,R=(D,ne)=>(T==null?void 0:T.type)===D&&(T==null?void 0:T.id)===ne,U=g.useCallback(()=>{const D=[];for(const ne of t)for(const le of ne.chapters)for(const me of le.sections)D.push({id:me.id,partId:ne.id,partTitle:ne.title,chapterId:le.id,chapterTitle:le.title});return D},[t]),P=g.useCallback(async(D,ne,le,me)=>{var X;D.preventDefault(),D.stopPropagation();const I=D.dataTransfer.getData("text/plain"),Y=Pg(I);if(!Y||Y.type===ne&&Y.id===le)return;const F=U(),xe=new Map(F.map(V=>[V.id,V]));if(Y.type==="part"&&ne==="part"){const V=t.map(_=>_.id),W=V.indexOf(Y.id),fe=V.indexOf(le);if(W===-1||fe===-1)return;const he=[...V];he.splice(W,1),he.splice(W$.id===_);if(J)for(const $ of J.chapters)for(const Z of $.sections){const ae=xe.get(Z.id);ae&&de.push(ae)}}await r(de);return}if(Y.type==="chapter"&&(ne==="chapter"||ne==="section"||ne==="part")){const V=t.find(ae=>ae.chapters.some(we=>we.id===Y.id)),W=V==null?void 0:V.chapters.find(ae=>ae.id===Y.id);if(!V||!W)return;let fe,he,de=null;if(ne==="section"){const ae=xe.get(le);if(!ae)return;fe=ae.partId,he=ae.partTitle,de=le}else if(ne==="chapter"){const ae=t.find(Ue=>Ue.chapters.some(wt=>wt.id===le)),we=ae==null?void 0:ae.chapters.find(Ue=>Ue.id===le);if(!ae||!we)return;fe=ae.id,he=ae.title;const Fe=F.filter(Ue=>Ue.chapterId===le).pop();de=(Fe==null?void 0:Fe.id)??null}else{const ae=t.find(we=>we.id===le);if(!ae)return;if(fe=ae.id,he=ae.title,ae.chapters[0]){const we=F.filter(Fe=>Fe.partId===ae.id&&Fe.chapterId===ae.chapters[0].id);de=((X=we[we.length-1])==null?void 0:X.id)??null}}const _=W.sections.map(ae=>ae.id),J=F.filter(ae=>!_.includes(ae.id));let $=J.length;if(de){const ae=J.findIndex(we=>we.id===de);ae>=0&&($=ae+1)}const Z=_.map(ae=>({...xe.get(ae),partId:fe,partTitle:he,chapterId:W.id,chapterTitle:W.title}));await r([...J.slice(0,$),...Z,...J.slice($)]);return}if(Y.type==="section"&&(ne==="section"||ne==="chapter"||ne==="part")){if(!me)return;const{partId:V,partTitle:W,chapterId:fe,chapterTitle:he}=me,de=F.findIndex(ae=>ae.id===Y.id);if(de===-1)return;const _=F.filter(ae=>ae.id!==Y.id);let J;if(ne==="section"){const ae=_.findIndex(we=>we.id===le);J=ae>=0?ae+1:_.length}else if(ne==="chapter"){const ae=_.filter(we=>we.chapterId===le).pop();J=ae?_.findIndex(we=>we.id===ae.id)+1:_.length}else{const ae=t.find(we=>we.id===le);if(ae!=null&&ae.chapters[0]){const we=_.filter(Ue=>Ue.partId===ae.id&&Ue.chapterId===ae.chapters[0].id),Fe=we[we.length-1];J=Fe?_.findIndex(Ue=>Ue.id===Fe.id)+1:_.length}else J=_.length}const Z={...F[de],partId:V,partTitle:W,chapterId:fe,chapterTitle:he};_.splice(J,0,Z),await r(_)}},[t,U,r]),z=(D,ne,le)=>({onDragEnter:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",C({type:D,id:ne})},onDragOver:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",C({type:D,id:ne})},onDragLeave:()=>C(null),onDrop:me=>{C(null);const I=Pg(me.dataTransfer.getData("text/plain"));I&&(D==="section"&&I.type==="section"&&I.id===ne||(D==="part"?I.type==="part"?P(me,"part",ne):le&&P(me,"part",ne,le):D==="chapter"&&le?(I.type==="section"||I.type==="chapter")&&P(me,"chapter",ne,le):D==="section"&&le&&P(me,"section",ne,le)))}}),O=D=>Nj[D%Nj.length],Q=D=>t.slice(0,D).filter(ne=>!mV(ne)).length,re=D=>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: ${D.id}`,children:D.id}),s.jsx("span",{className:"truncate",children:D.title})]});return s.jsx("div",{className:"space-y-3",children:t.map((D,ne)=>{var W,fe,he,de;const le=D.title==="序言"||D.title.includes("序言"),me=D.title==="尾声"||D.title.includes("尾声"),I=D.title==="附录"||D.title.includes("附录"),Y=R("part",D.id),F=e.includes(D.id),xe=D.chapters.length,X=D.chapters.reduce((_,J)=>_+J.sections.length,0);if(le&&D.chapters.length===1&&D.chapters[0].sections.length===1){const _=D.chapters[0].sections[0],J=R("section",_.id),$={partId:D.id,partTitle:D.title,chapterId:D.chapters[0].id,chapterTitle:D.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+_.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:_.id})},onDragEnd:()=>{k(null),C(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] ${J?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...z("section",_.id,$),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Ni,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.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(ur,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[D.chapters[0].title," | ",_.title]}),w.includes(_.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:Z=>Z.stopPropagation(),onClick:Z=>Z.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(G,{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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]})]},D.id)}if(D.title==="2026每日派对干货"||D.title.includes("2026每日派对干货")){const _=R("part",D.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]"}`,...z("part",D.id,{partId:D.id,partTitle:D.title,chapterId:((W=D.chapters[0])==null?void 0:W.id)??"",chapterTitle:((fe=D.chapters[0])==null?void 0:fe.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:J=>{J.stopPropagation(),J.dataTransfer.setData("text/plain","part:"+D.id),J.dataTransfer.effectAllowed="move",k({type:"part",id:D.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",D.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(Ni,{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:D.badgeText||"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:D.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:wj(D)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:J=>J.stopPropagation(),onClick:J=>J.stopPropagation(),children:[o&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),f&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(D),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(ts,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",X," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:F?"收起":"展开",onMouseDown:J=>J.stopPropagation(),onClick:J=>{J.stopPropagation(),n(D.id)},children:F?s.jsx(Bi,{className:"w-5 h-5"}):s.jsx(Li,{className:"w-5 h-5"})})]})]}),F&&D.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:D.chapters.map(J=>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:J.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:$=>$.stopPropagation(),children:[m&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>m(D,J),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),c&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>u(D,J),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:J.sections.map($=>{const Z=R("section",$.id);return s.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+$.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:$.id})},onDragEnd:()=>{k(null),C(null)},onClick:()=>a($),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${Z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...z("section",$.id,{partId:D.id,partTitle:D.title,chapterId:J.id,chapterTitle:J.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.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("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:re($)}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:ae=>ae.stopPropagation(),children:[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(G,{variant:"ghost",size:"sm",onClick:()=>N($),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]},$.id)})})]},J.id))})]},D.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:D.chapters.map((_,J)=>_.sections.length>0?_.sections.map($=>{const Z=R("section",$.id);return s.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+$.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:$.id})},onDragEnd:()=>{k(null),C(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 ${Z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...z("section",$.id,{partId:D.id,partTitle:D.title,chapterId:_.id,chapterTitle:_.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.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.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",J+1," | ",_.title," | ",$.title]}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:["点击 ",$.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(G,{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 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Li,{className:"w-4 h-4 text-gray-500 shrink-0"})]},$.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:["附录",J+1," | ",_.title,"(空)"]}),s.jsx(Li,{className:"w-4 h-4 text-gray-500 shrink-0"})]},_.id))})]},D.id);if(me&&D.chapters.length===1&&D.chapters[0].sections.length===1){const _=D.chapters[0].sections[0],J=R("section",_.id),$={partId:D.id,partTitle:D.title,chapterId:D.chapters[0].id,chapterTitle:D.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+_.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:_.id})},onDragEnd:()=>{k(null),C(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] ${J?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...z("section",_.id,$),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Ni,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.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(ur,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[D.chapters[0].title," | ",_.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>Z.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(G,{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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]})]},D.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:D.chapters.map(_=>_.sections.map(J=>{const $=R("section",J.id);return s.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+J.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:J.id})},onDragEnd:()=>{k(null),C(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 ${$?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",J.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...z("section",J.id,{partId:D.id,partTitle:D.title,chapterId:_.id,chapterTitle:_.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(J.id),onChange:()=>b(J.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," | ",J.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",J.clickCount??0," · 付款 ",J.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(J.hotScore??0).toFixed(1)," · 第",J.hotRank&&J.hotRank>0?J.hotRank:"-","名"]}),N&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(J),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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(J),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(J),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]})]},J.id)}))})]},D.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${Y?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...z("part",D.id,{partId:D.id,partTitle:D.title,chapterId:((he=D.chapters[0])==null?void 0:he.id)??"",chapterTitle:((de=D.chapters[0])==null?void 0:de.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:_=>{_.stopPropagation(),_.dataTransfer.setData("text/plain","part:"+D.id),_.dataTransfer.effectAllowed="move",k({type:"part",id:D.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",D.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(Ni,{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:D.badgeText||O(Q(ne))}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:D.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:wj(D)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:_=>_.stopPropagation(),onClick:_=>_.stopPropagation(),children:[o&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),f&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(D),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(ts,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",X," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:F?"收起":"展开",onMouseDown:_=>_.stopPropagation(),onClick:_=>{_.stopPropagation(),n(D.id)},children:F?s.jsx(Bi,{className:"w-5 h-5"}):s.jsx(Li,{className:"w-5 h-5"})})]})]}),F&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:D.chapters.map(_=>{const J=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:$=>{$.stopPropagation(),$.dataTransfer.setData("text/plain","chapter:"+_.id),$.dataTransfer.effectAllowed="move",k({type:"chapter",id:_.id})},onDragEnd:()=>{k(null),C(null)},onDragEnter:$=>{$.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="move",C({type:"chapter",id:_.id})},onDragOver:$=>{$.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="move",C({type:"chapter",id:_.id})},onDragLeave:()=>C(null),onDrop:$=>{C(null);const Z=Pg($.dataTransfer.getData("text/plain"));if(!Z)return;const ae={partId:D.id,partTitle:D.title,chapterId:_.id,chapterTitle:_.title};(Z.type==="section"||Z.type==="chapter")&&P($,"chapter",_.id,ae)},className:`flex-1 min-w-0 py-2 px-2 rounded cursor-grab active:cursor-grabbing select-none -mx-2 transition-all duration-200 flex items-center gap-2 ${J?"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(Ni,{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:$=>$.stopPropagation(),children:[m&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>m(D,_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),c&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>u(D,_),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:_.sections.map($=>{const Z=R("section",$.id);return s.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+$.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:$.id})},onDragEnd:()=>{k(null),C(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 ${Z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...z("section",$.id,{partId:D.id,partTitle:D.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:ae=>ae.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(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${$.price===0||$.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:re($)}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:ae=>ae.stopPropagation(),onClick:ae=>ae.stopPropagation(),children:[$.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),$.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",title:"点击次数 · 付款笔数",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(G,{variant:"ghost",size:"sm",onClick:()=>N($),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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(ts,{className:"w-3.5 h-3.5"})})]})]})]},$.id)})})]},_.id)})})]},D.id)})})}function gV(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 Le(r)}function yV(t){return Le(`/api/db/person?personId=${encodeURIComponent(t)}`)}function bV(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 Le(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const vV=10;function K4(t){const e=(t??"").trim();if(!e)return"";if(/^https?:\/\//i.test(e))return ya(e);const n=e.startsWith("/")?e:`/${e}`;return ya(Vl(n))}function NV(t){const{nickname:e,avatar:n}=t,r=K4(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 wV(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 jV({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=qa(w,300),[T,C]=g.useState([]),[L,R]=g.useState(!1),[U,P]=g.useState(!1),[z,O]=g.useState(0),Q=g.useRef(1),re=g.useRef(!1),D=g.useRef(!1),ne=g.useRef(null),le=g.useRef(null),[me,I]=g.useState({top:0,left:0,width:320,maxH:360}),Y=g.useCallback(()=>{const _=le.current;if(!_||typeof window>"u")return;const J=_.getBoundingClientRect(),$=Math.min(400,Math.max(200,window.innerHeight-J.bottom-16)),Z=x==null?void 0:x.current;if(Z){const ae=Z.getBoundingClientRect();I({top:J.bottom-ae.top+6,left:J.left-ae.left,width:Math.max(J.width,300),maxH:$})}else I({top:J.bottom+6,left:J.left,width:Math.max(J.width,300),maxH:$})},[x]);g.useEffect(()=>{c||(N(!1),v(""))},[c]),g.useLayoutEffect(()=>{if(b)return Y(),window.addEventListener("scroll",Y,!0),window.addEventListener("resize",Y),()=>{window.removeEventListener("scroll",Y,!0),window.removeEventListener("resize",Y)}},[b,Y]);const F=g.useCallback(async(_,J,$)=>{if(!re.current){re.current=!0,$?P(!0):R(!0);try{const Z=new URLSearchParams({page:String(_),pageSize:String(vV),search:J.trim()}),ae=await Le(`/api/db/users?${Z}`);if(ae!=null&&ae.success&&Array.isArray(ae.users)){const we=ae.users,Fe=typeof ae.total=="number"?ae.total:0;O(Fe),$?we.length===0?D.current=!0:C(Ue=>{const wt=wV(Ue,we);return wt.length===Ue.length?D.current=!0:Q.current=_,wt}):(C(we),Q.current=_)}else ae!=null&&ae.error&&q.error(ae.error)}catch(Z){q.error(Z instanceof Error?Z.message:"加载用户列表失败")}finally{re.current=!1,R(!1),P(!1)}}},[]);g.useEffect(()=>{b&&(Q.current=1,D.current=!1,F(1,k,!1))},[b,k,F]);const xe=g.useCallback(()=>{L||U||re.current||D.current||z>0&&T.length>=z||F(Q.current+1,k,!0)},[k,F,L,U,z,T.length]);g.useLayoutEffect(()=>{if(!b||L||U||D.current||z>0&&T.length>=z||T.length===0)return;const _=ne.current;_&&(_.scrollHeight>_.clientHeight+12||xe())},[b,T.length,L,U,z,xe]);const X=_=>{(_.id||"").trim()&&(i(_),N(!1),v(""))},V=_=>{_.preventDefault(),_.stopPropagation(),!(u||a)&&o()},W=!!n.trim(),fe=z>0,he=typeof document>"u"?null:(m==null?void 0:m.current)??document.body,de=b&&he&&hd.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(oe,{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:["已加载 ",T.length," / ",z," 条",T.length{const J=_.currentTarget;L||U||D.current||z>0&&T.length>=z||J.scrollHeight-J.scrollTop-J.clientHeight<100&&xe()},children:L&&T.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-gray-400 text-sm",children:"正在加载…"}):T.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:[T.map(_=>{const J=_.id||"",$=n===J,Z=K4(_.avatar),ae=_.nickname&&String(_.nickname).trim()||"(无昵称)";return s.jsxs("button",{type:"button",role:"option","aria-selected":$,className:zt("flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left text-sm transition-colors",$?"border-[#38bdac] bg-[#38bdac]/15 text-white":"border-transparent bg-[#050c18] hover:border-[#38bdac]/40 hover:bg-[#0a1628]"),onMouseDown:we=>we.preventDefault(),onClick:()=>X(_),children:[s.jsx("span",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-gray-800",children:Z?s.jsx("img",{src:Z,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:ae.slice(0,1)})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium truncate",children:ae}),s.jsxs("div",{className:"text-[11px] text-gray-500 font-mono truncate mt-0.5",children:[_.phone?`${_.phone} · `:"",J]})]})]},J)}),U&&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(G,{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:zt("space-y-1.5",f),children:[typeof e=="string"?s.jsx(te,{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:le,id:t,type:"button",disabled:u,"aria-haspopup":"listbox","aria-expanded":b,className:zt("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(""),Y()),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:"正在加载已绑定用户…"}):W?s.jsx(NV,{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(Bi,{className:zt("h-4 w-4 shrink-0 text-gray-400 transition-transform",b&&"rotate-180")})]}),W&&s.jsx(G,{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:V,children:s.jsx(ns,{className:"h-4 w-4"})})]}),h&&s.jsx("div",{className:"text-[11px] text-gray-500",children:h}),de]})}const q4=11,jj={personId:"",name:"",boundUserId:"",aliases:"",label:"",sceneId:q4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"06:00",endTime:"22:00",deviceGroups:""};function kV({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){var J;const a=!!n,i=g.useRef(null),o=g.useRef(null),[c,u]=g.useState(jj),[h,f]=g.useState(!1),[m,x]=g.useState(!1),[b,N]=g.useState([]),[w,v]=g.useState(!1),[k,T]=g.useState(""),[C,L]=g.useState([]),[R,U]=g.useState(!1),[P,z]=g.useState(""),[O,Q]=g.useState(!1),[re,D]=g.useState(null),[ne,le]=g.useState(!1),[me,I]=g.useState({}),[Y,F]=g.useState({loading:!1,messages:[]}),xe=qa(c.name,400),X=qa(c.aliases,400);g.useEffect(()=>{if(!t){F({loading:!1,messages:[]});return}const $=xe.trim(),Z=X.trim();if(!$&&!Z){F({loading:!1,messages:[]});return}let ae=!1;F(Ue=>({...Ue,loading:!0}));const we=a?((n==null?void 0:n.personId)??"").trim():"",Fe=new URLSearchParams;return $&&Fe.set("name",xe.trim()),Fe.set("aliases",X),we&&Fe.set("excludePersonId",we),Le(`/api/db/persons/check-unique?${Fe.toString()}`).then(Ue=>{if(!ae){if((Ue==null?void 0:Ue.success)===!1&&(Ue!=null&&Ue.error)){F({loading:!1,messages:[Ue.error]});return}if((Ue==null?void 0:Ue.ok)===!1&&Array.isArray(Ue.messages)&&Ue.messages.length>0){F({loading:!1,messages:Ue.messages});return}F({loading:!1,messages:[]})}}).catch(()=>{ae||F({loading:!1,messages:[]})}),()=>{ae=!0}},[t,xe,X,a,n==null?void 0:n.personId]),g.useEffect(()=>{if(t){if(T(""),D(null),le(!1),n){u({personId:n.personId??n.name??"",name:n.name??"",boundUserId:n.userId??"",aliases:n.aliases??"",label:n.label??"",sceneId:q4,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 $=(n.userId??"").trim();$&&(le(!0),Le(`/api/db/users?id=${encodeURIComponent($)}`).then(Z=>{const ae=Z==null?void 0:Z.user;ae!=null&&ae.id?D({id:ae.id,nickname:ae.nickname&&String(ae.nickname).trim()||ae.id,phone:ae.phone,avatar:ae.avatar??void 0}):D({id:$,nickname:$,phone:void 0,avatar:void 0})}).catch(()=>{D({id:$,nickname:$,phone:void 0,avatar:void 0})}).finally(()=>le(!1)))}else u({...jj});I({}),b.length===0&&V(""),C.length===0&&W("")}},[t,n]);const V=async $=>{v(!0);try{const Z=await gV({page:1,limit:50,keyword:$});Z!=null&&Z.success&&Array.isArray(Z.devices)?N(Z.devices):Z!=null&&Z.error&&q.error(Z.error)}catch(Z){q.error(Z instanceof Error?Z.message:"加载设备列表失败")}finally{v(!1)}},W=async $=>{U(!0);try{const Z=await bV({page:1,limit:100,keyword:$});Z!=null&&Z.success&&Array.isArray(Z.plans)?L(Z.plans):Z!=null&&Z.error&&q.error(Z.error)}catch{q.error("加载计划列表失败")}finally{U(!1)}},fe=()=>{u($=>{const Z=($.boundUserId||"").trim(),ae={...$,boundUserId:""};return!a&&Z&&($.personId||"").trim()===Z&&(ae.personId=""),ae}),D(null)},he=$=>{const Z=Array.isArray($.deviceGroups)?$.deviceGroups.map(String).join(","):"";u(ae=>({...ae,ckbApiKey:$.apiKey||"",greeting:$.greeting||ae.greeting,tips:$.tips||ae.tips,remarkType:$.remarkType||ae.remarkType,remarkFormat:$.remarkFormat||ae.remarkFormat,addFriendInterval:$.addInterval||ae.addFriendInterval,startTime:$.startTime||ae.startTime,endTime:$.endTime||ae.endTime,deviceGroups:Z||ae.deviceGroups})),Q(!1),q.success(`已选择计划「${$.name}」,参数已覆盖`)},de=P.trim()?C.filter($=>($.name||"").includes(P.trim())||String($.id).includes(P.trim())):C,_=async()=>{var we;const $={};(!c.name||!String(c.name).trim())&&($.name="请填写名称");const Z=c.addFriendInterval;if((typeof Z!="number"||Z<1)&&($.addFriendInterval="添加间隔至少为 1 分钟"),(((we=c.deviceGroups)==null?void 0:we.split(",").map(Fe=>Fe.trim()).filter(Boolean))??[]).length===0&&($.deviceGroups="请至少选择 1 台设备"),I($),Object.keys($).length>0){q.error($.name||$.addFriendInterval||$.deviceGroups||"请完善必填项");return}if(Y.messages.length>0){q.error(Y.messages[0]??"名称或别名与他人重复");return}f(!0);try{await r(c),e(!1)}catch(Fe){q.error(Fe instanceof Error?Fe.message:"保存失败")}finally{f(!1)}};return s.jsx(Lt,{open:t,onOpenChange:e,children:s.jsxs(It,{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(Ot,{children:[s.jsx(Dt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Wo,{className:"text-gray-400 text-sm",children:a?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),s.jsxs("div",{className:"space-y-6 py-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(te,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(oe,{className:`bg-[#0a1628] text-white ${me.name?"border-red-500 focus-visible:ring-red-500":Y.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡若",value:c.name,onChange:$=>{u(Z=>({...Z,name:$.target.value})),me.name&&I(Z=>({...Z,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(te,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:(c.boundUserId||"").trim()?c.boundUserId:c.personId,onChange:$=>u(Z=>({...Z,personId:$.target.value})),disabled:a||!!(c.boundUserId||"").trim()})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:c.label,onChange:$=>u(Z=>({...Z,label:$.target.value}))})]}),s.jsx(jV,{className:"col-span-3",id:"person-bound-member-user",label:"绑定会员用户(可选,与「用户管理」中用户一致)",containerOpen:t,portalMountRef:o,positionContainerRef:i,value:c.boundUserId,preview:re,previewLoading:ne,onSelect:$=>{const Z=($.id||"").trim();Z&&(u(ae=>({...ae,boundUserId:Z,...a?{}:{personId:Z}})),D({id:Z,nickname:$.nickname&&String($.nickname).trim()||Z,phone:$.phone,avatar:$.avatar??void 0}))},onClear:fe,hint:s.jsx("span",{children:"单选;保存时后端校验用户是否存在。同一会员只能绑定一个 @人物;绑定后获客统计可与超级个体对齐。"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),s.jsx(oe,{className:`bg-[#0a1628] text-white ${Y.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡卡, 若若",value:c.aliases,onChange:$=>u(Z=>({...Z,aliases:$.target.value}))})]}),s.jsx("div",{className:"col-span-3 space-y-1",children:Y.loading?s.jsx("p",{className:"text-xs text-gray-500",children:"正在检测名称与别名是否与他人重复…"}):Y.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:Y.messages.map(($,Z)=>s.jsx("p",{children:$},`${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(te,{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:()=>Q(!O),children:c.ckbApiKey?s.jsx("span",{className:"text-white truncate",children:((J=C.find($=>$.apiKey===c.ckbApiKey))==null?void 0:J.name)||`获客计划 (${c.ckbApiKey.slice(0,8)}…)`}):s.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{W(P),Q(!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(oe,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:P,onChange:$=>z($.target.value),onKeyDown:$=>{$.key==="Enter"&&W(P)},autoFocus:!0})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:de.length===0?s.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:R?"加载中...":"暂无计划"}):de.map($=>s.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${c.ckbApiKey===$.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>he($),children:[s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-medium",children:$.name}),s.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String($.id)]})]}),$.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($.id)))}),s.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>Q(!1),children:"关闭"})})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(te,{className:"text-gray-400 text-xs",children:["选择设备 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:`flex gap-2 rounded-md border ${me.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(oe,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:c.deviceGroups?`已选择 ${c.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>x(!0)}),s.jsx(G,{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(te,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(To,{value:c.remarkType,onValueChange:$=>u(Z=>({...Z,remarkType:$})),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{placeholder:"选择备注类型"})}),s.jsxs(Ri,{children:[s.jsx(us,{value:"phone",children:"手机号"}),s.jsx(us,{value:"nickname",children:"昵称"}),s.jsx(us,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"备注格式(手机号+标签,标签不超过6字)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 {手机号}-{来源标签},总长不超过10字",value:c.remarkFormat,onChange:$=>u(Z=>({...Z,remarkFormat:$.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(te,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:c.greeting,onChange:$=>u(Z=>({...Z,greeting:$.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(oe,{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:$=>{u(Z=>({...Z,addFriendInterval:Number($.target.value)||1})),me.addFriendInterval&&I(Z=>({...Z,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(te,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.startTime,onChange:$=>u(Z=>({...Z,startTime:$.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.endTime,onChange:$=>u(Z=>({...Z,endTime:$.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:c.tips,onChange:$=>u(Z=>({...Z,tips:$.target.value}))})]})]})]})]})]})]}),s.jsxs(nn,{className:"gap-3 border-t border-gray-700/40 px-6 py-4 shrink-0",children:[s.jsx(G,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(G,{onClick:_,disabled:h||Y.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(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>{const $=b.map(we=>String(we.id??"")),Z=c.deviceGroups?c.deviceGroups.split(",").map(we=>we.trim()).filter(Boolean):[],ae=$.length>0&&$.every(we=>Z.includes(we));u(we=>({...we,deviceGroups:ae?"":$.join(",")})),!ae&&$.length>0&&I(we=>({...we,deviceGroups:void 0}))},children:(()=>{const $=b.map(ae=>String(ae.id??"")),Z=c.deviceGroups?c.deviceGroups.split(",").map(ae=>ae.trim()).filter(Boolean):[];return $.length>0&&$.every(ae=>Z.includes(ae))?"取消全选":"全选"})()}),s.jsx(oe,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:k,onChange:$=>T($.target.value),onKeyDown:$=>{$.key==="Enter"&&V(k)}}),s.jsx(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>V(k),disabled:w,children:"刷新"}),s.jsx(G,{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($=>{const Z=String($.id??""),ae=c.deviceGroups?c.deviceGroups.split(",").map(Ue=>Ue.trim()).filter(Boolean):[],we=ae.includes(Z),Fe=()=>{let Ue;we?Ue=ae.filter(wt=>wt!==Z):Ue=[...ae,Z],u(wt=>({...wt,deviceGroups:Ue.join(",")})),Ue.length>0&&I(wt=>({...wt,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:Fe}),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:$.memo||$.wechatId||`设备 ${Z}`}),$.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),$.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: ",Z]}),$.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",$.wechatId]}),typeof $.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",$.totalFriend]})]})]})]},Z)})})}),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(G,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>x(!1),children:"取消"}),s.jsx(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>x(!1),children:"确定"})]})]})]})})]})})}const Ig=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 lB(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(lj(t)),T=g.useCallback((re,D)=>{var I;const ne=x.current;if(!ne||!n)return!1;const le=lB(D);if(le.length>0)return D.preventDefault(),(async()=>{for(const Y of le)try{const B=await n(Y);B&&ne.chain().focus().setImage({src:B}).run()}catch(B){console.error("粘贴图片上传失败",B)}})(),!0;const me=(I=D.clipboardData)==null?void 0:I.getData("text/html");if(me&&/data:image\/[^;"']+;base64,/i.test(me)){D.preventDefault();const{from:Y,to:B}=ne.state.selection;return(async()=>{try{const xe=await uB(me,n);ne.chain().focus().insertContentAt({from:Y,to:B},xe).run()}catch(xe){console.error("粘贴 HTML 内 base64 转换失败",xe)}})(),!0}return!1},[n]),C=X7({extensions:[zz.configure({link:{openOnClick:!1,HTMLAttributes:{class:"rich-link"}}}),Vz.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"rich-editor-img-thumb"}}),aB,Gz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:oB(a)}),iB,Jz.configure({placeholder:o}),q3.configure({resizable:!0}),K3,U3,W3],content:k.current,onUpdate:({editor:re})=>{e(re.getHTML())},editorProps:{attributes:{class:"rich-editor-content"},handlePaste:T}});g.useEffect(()=>{x.current=C??null},[C]),g.useImperativeHandle(u,()=>({getHTML:()=>(C==null?void 0:C.getHTML())||"",getMarkdown:()=>rB((C==null?void 0:C.getHTML())||"")})),g.useEffect(()=>{if(C&&t!==C.getHTML()){const re=lj(t);re!==C.getHTML()&&C.commands.setContent(re)}},[t]);const L=g.useCallback(async re=>{if(r)return r(re);if(n)return n(re);throw new Error("未配置上传")},[n,r]),R=g.useCallback(async re=>{var ne;const D=(ne=re.target.files)==null?void 0:ne[0];if(!(!D||!C)){if(n){const le=await n(D);le&&C.chain().focus().setImage({src:le}).run()}else{const le=new FileReader;le.onload=()=>{typeof le.result=="string"&&C.chain().focus().setImage({src:le.result}).run()},le.readAsDataURL(D)}re.target.value=""}},[C,n]),U=g.useCallback(async re=>{var ne;const D=(ne=re.target.files)==null?void 0:ne[0];if(!(!D||!C)){try{const le=await L(D);le&&C.chain().focus().insertContent({type:"videoEmbed",attrs:{src:le}}).run()}catch(le){console.error(le)}re.target.value=""}},[C,L]),P=g.useCallback(async re=>{var ne;const D=(ne=re.target.files)==null?void 0:ne[0];if(!(!D||!C)){try{const le=await L(D);if(!le)return;const me=D.name||"附件";C.chain().focus().insertContent(`

附件 ${nB(me)}

`).run()}catch(le){console.error(le)}re.target.value=""}},[C,L]),F=g.useCallback(()=>{C&&C.chain().focus().insertContent("@").run()},[C]),O=g.useCallback(re=>{C&&C.chain().focus().insertContent([{type:"linkTag",attrs:{label:re.label,url:re.url||"",tagType:re.type||"url",tagId:re.id||"",pagePath:re.pagePath||"",appId:re.appId||"",mpKey:re.type==="miniprogram"&&re.appId||""}},{type:"text",text:" "}]).run()},[C]),Q=g.useCallback(()=>{!C||!b||(C.chain().focus().setLink({href:b}).run(),N(""),v(!1))},[C,b]);return C?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:()=>C.chain().focus().toggleBold().run(),className:C.isActive("bold")?"is-active":"",type:"button",children:s.jsx(NT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleItalic().run(),className:C.isActive("italic")?"is-active":"",type:"button",children:s.jsx(kM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleStrike().run(),className:C.isActive("strike")?"is-active":"",type:"button",children:s.jsx(AA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleCode().run(),className:C.isActive("code")?"is-active":"",type:"button",children:s.jsx(VT,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:1}).run(),className:C.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(pM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:2}).run(),className:C.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(xM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleHeading({level:3}).run(),className:C.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(yM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>C.chain().focus().toggleBulletList().run(),className:C.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(LM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleOrderedList().run(),className:C.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(ak,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().toggleBlockquote().run(),className:C.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(oA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(KM,{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:U,className:"hidden"}),s.jsx("input",{ref:m,type:"file",onChange:P,className:"hidden"}),s.jsx("button",{onClick:()=>{var re;return(re=h.current)==null?void 0:re.click()},type:"button",title:"上传图片",children:s.jsx(rk,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var re;return(re=f.current)==null?void 0:re.click()},type:"button",title:"上传视频",disabled:!r&&!n,children:s.jsx(WA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{var re;return(re=m.current)==null?void 0:re.click()},type:"button",title:"上传附件(生成下载链接)",disabled:!r&&!n,children:s.jsx(YM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:F,type:"button",title:"插入 @ 并选择人物",className:a.length?"mention-trigger-btn":"",disabled:a.length===0,children:s.jsx(xT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v(!w),className:C.isActive("link")?"is-active":"",type:"button",title:"链接",children:s.jsx(Wg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",title:"表格",children:s.jsx(IA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>C.chain().focus().undo().run(),disabled:!C.can().undo(),type:"button",children:s.jsx(zA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>C.chain().focus().redo().run(),disabled:!C.can().redo(),type:"button",children:s.jsx(cA,{className:"w-4 h-4"})})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-divider"}),s.jsx("div",{className:"toolbar-group",children:s.jsxs("select",{className:"link-tag-select",onChange:re=>{const D=i.find(ne=>ne.id===re.target.value);D&&O(D),re.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(re=>s.jsx("option",{value:re.id,children:re.label},re.id))]})})]})]}),w&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:b,onChange:re=>N(re.target.value),onKeyDown:re=>re.key==="Enter"&&Q(),className:"link-input"}),s.jsx("button",{onClick:Q,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{C.chain().focus().unsetLink().run(),v(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(r3,{editor:C})]}):null});$0.displayName="RichEditor";const hB=["top","right","bottom","left"],Jo=Math.min,Sr=Math.max,Ap=Math.round,Nf=Math.floor,Ka=t=>({x:t,y:t}),fB={left:"right",right:"left",bottom:"top",top:"bottom"},pB={start:"end",end:"start"};function z0(t,e,n){return Sr(t,Jo(e,n))}function Vi(t,e){return typeof t=="function"?t(e):t}function Hi(t){return t.split("-")[0]}function bd(t){return t.split("-")[1]}function ab(t){return t==="x"?"y":"x"}function ib(t){return t==="y"?"height":"width"}const mB=new Set(["top","bottom"]);function Wa(t){return mB.has(Hi(t))?"y":"x"}function ob(t){return ab(Wa(t))}function xB(t,e,n){n===void 0&&(n=!1);const r=bd(t),a=ob(t),i=ib(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Pp(o)),[o,Pp(o)]}function gB(t){const e=Pp(t);return[F0(t),e,F0(e)]}function F0(t){return t.replace(/start|end/g,e=>pB[e])}const dj=["left","right"],uj=["right","left"],yB=["top","bottom"],bB=["bottom","top"];function vB(t,e,n){switch(t){case"top":case"bottom":return n?e?uj:dj:e?dj:uj;case"left":case"right":return e?yB:bB;default:return[]}}function NB(t,e,n,r){const a=bd(t);let i=vB(Hi(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),e&&(i=i.concat(i.map(F0)))),i}function Pp(t){return t.replace(/left|right|bottom|top/g,e=>fB[e])}function wB(t){return{top:0,right:0,bottom:0,left:0,...t}}function G3(t){return typeof t!="number"?wB(t):{top:t,right:t,bottom:t,left:t}}function Ip(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 hj(t,e,n){let{reference:r,floating:a}=t;const i=Wa(e),o=ob(e),c=ib(o),u=Hi(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(bd(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 jB(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}=Vi(e,t),N=G3(b),v=c[x?m==="floating"?"reference":"floating":m],k=Ip(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})),T=m==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),L=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},R=Ip(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:T,offsetParent:C,strategy:u}):T);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 kB=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}=hj(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}=Vi(t,e)||{};if(h==null)return{};const m=G3(f),x={x:n,y:r},b=ob(a),N=ib(b),w=await o.getDimensions(h),v=b==="y",k=v?"top":"left",T=v?"bottom":"right",C=v?"clientHeight":"clientWidth",L=i.reference[N]+i.reference[b]-x[b]-i.floating[N],R=x[b]-i.reference[b],U=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let P=U?U[C]:0;(!P||!await(o.isElement==null?void 0:o.isElement(U)))&&(P=c.floating[C]||i.floating[N]);const F=L/2-R/2,O=P/2-w[N]/2-1,Q=Jo(m[k],O),re=Jo(m[T],O),D=Q,ne=P-w[N]-re,le=P/2-w[N]/2+F,me=z0(D,le,ne),I=!u.arrow&&bd(a)!=null&&le!==me&&i.reference[N]/2-(lele<=0)){var re,D;const le=(((re=i.flip)==null?void 0:re.index)||0)+1,me=P[le];if(me&&(!(m==="alignment"?T!==Wa(me):!1)||Q.every(B=>Wa(B.placement)===T?B.overflows[0]>0:!0)))return{data:{index:le,overflows:Q},reset:{placement:me}};let I=(D=Q.filter(Y=>Y.overflows[0]<=0).sort((Y,B)=>Y.overflows[1]-B.overflows[1])[0])==null?void 0:D.placement;if(!I)switch(b){case"bestFit":{var ne;const Y=(ne=Q.filter(B=>{if(U){const xe=Wa(B.placement);return xe===T||xe==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(xe=>xe>0).reduce((xe,X)=>xe+X,0)]).sort((B,xe)=>B[1]-xe[1])[0])==null?void 0:ne[0];Y&&(I=Y);break}case"initialPlacement":I=c;break}if(a!==I)return{reset:{placement:I}}}return{}}}};function fj(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function pj(t){return hB.some(e=>t[e]>=0)}const EB=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:a="referenceHidden",...i}=Vi(t,e);switch(a){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),c=fj(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:pj(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),c=fj(o,n.floating);return{data:{escapedOffsets:c,escaped:pj(c)}}}default:return{}}}}},J3=new Set(["left","top"]);async function TB(t,e){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=Hi(n),c=bd(n),u=Wa(n)==="y",h=J3.has(o)?-1:1,f=i&&u?-1:1,m=Vi(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 MB=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 TB(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}}}}},AB=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:T,y:C}=k;return{x:T,y:C}}},...h}=Vi(t,e),f={x:n,y:r},m=await i.detectOverflow(e,h),x=Wa(Hi(a)),b=ab(x);let N=f[b],w=f[x];if(o){const k=b==="y"?"top":"left",T=b==="y"?"bottom":"right",C=N+m[k],L=N-m[T];N=z0(C,N,L)}if(c){const k=x==="y"?"top":"left",T=x==="y"?"bottom":"right",C=w+m[k],L=w-m[T];w=z0(C,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}}}}}},PB=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}=Vi(t,e),f={x:n,y:r},m=Wa(a),x=ab(m);let b=f[x],N=f[m];const w=Vi(c,e),v=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const C=x==="y"?"height":"width",L=i.reference[x]-i.floating[C]+v.mainAxis,R=i.reference[x]+i.reference[C]-v.mainAxis;bR&&(b=R)}if(h){var k,T;const C=x==="y"?"width":"height",L=J3.has(Hi(a)),R=i.reference[m]-i.floating[C]+(L&&((k=o.offset)==null?void 0:k[m])||0)+(L?0:v.crossAxis),U=i.reference[m]+i.reference[C]+(L?0:((T=o.offset)==null?void 0:T[m])||0)-(L?v.crossAxis:0);NU&&(N=U)}return{[x]:b,[m]:N}}}},IB=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}=Vi(t,e),f=await o.detectOverflow(e,h),m=Hi(a),x=bd(a),b=Wa(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 T=w-f.top-f.bottom,C=N-f.left-f.right,L=Jo(w-f[v],T),R=Jo(N-f[k],C),U=!e.middlewareData.shift;let P=L,F=R;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(F=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(P=T),U&&!x){const Q=Sr(f.left,0),re=Sr(f.right,0),D=Sr(f.top,0),ne=Sr(f.bottom,0);b?F=N-2*(Q!==0||re!==0?Q+re:Sr(f.left,f.right)):P=w-2*(D!==0||ne!==0?D+ne:Sr(f.top,f.bottom))}await u({...e,availableWidth:F,availableHeight:P});const O=await o.getDimensions(c.floating);return N!==O.width||w!==O.height?{reset:{rects:!0}}:{}}}};function om(){return typeof window<"u"}function vd(t){return Q3(t)?(t.nodeName||"").toLowerCase():"#document"}function Mr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Za(t){var e;return(e=(Q3(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Q3(t){return om()?t instanceof Node||t instanceof Mr(t).Node:!1}function ba(t){return om()?t instanceof Element||t instanceof Mr(t).Element:!1}function Qa(t){return om()?t instanceof HTMLElement||t instanceof Mr(t).HTMLElement:!1}function mj(t){return!om()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Mr(t).ShadowRoot}const RB=new Set(["inline","contents"]);function Zu(t){const{overflow:e,overflowX:n,overflowY:r,display:a}=va(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!RB.has(a)}const LB=new Set(["table","td","th"]);function OB(t){return LB.has(vd(t))}const DB=[":popover-open",":modal"];function lm(t){return DB.some(e=>{try{return t.matches(e)}catch{return!1}})}const _B=["transform","translate","scale","rotate","perspective"],$B=["transform","translate","scale","rotate","perspective","filter"],zB=["paint","layout","strict","content"];function lb(t){const e=cb(),n=ba(t)?va(t):t;return _B.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)||$B.some(r=>(n.willChange||"").includes(r))||zB.some(r=>(n.contain||"").includes(r))}function FB(t){let e=Qo(t);for(;Qa(e)&&!ud(e);){if(lb(e))return e;if(lm(e))return null;e=Qo(e)}return null}function cb(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const BB=new Set(["html","body","#document"]);function ud(t){return BB.has(vd(t))}function va(t){return Mr(t).getComputedStyle(t)}function cm(t){return ba(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Qo(t){if(vd(t)==="html")return t;const e=t.assignedSlot||t.parentNode||mj(t)&&t.host||Za(t);return mj(e)?e.host:e}function Y3(t){const e=Qo(t);return ud(e)?t.ownerDocument?t.ownerDocument.body:t.body:Qa(e)&&Zu(e)?e:Y3(e)}function Uu(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=Y3(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=Mr(a);if(i){const c=B0(o);return e.concat(o,o.visualViewport||[],Zu(a)?a:[],c&&n?Uu(c):[])}return e.concat(a,Uu(a,[],n))}function B0(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function X3(t){const e=va(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const a=Qa(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,c=Ap(n)!==i||Ap(r)!==o;return c&&(n=i,r=o),{width:n,height:r,$:c}}function db(t){return ba(t)?t:t.contextElement}function nd(t){const e=db(t);if(!Qa(e))return Ka(1);const n=e.getBoundingClientRect(),{width:r,height:a,$:i}=X3(e);let o=(i?Ap(n.width):n.width)/r,c=(i?Ap(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const VB=Ka(0);function Z3(t){const e=Mr(t);return!cb()||!e.visualViewport?VB:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function HB(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Mr(t)?!1:e}function Zl(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=db(t);let o=Ka(1);e&&(r?ba(r)&&(o=nd(r)):o=nd(t));const c=HB(i,n,r)?Z3(i):Ka(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=Mr(i),b=r&&ba(r)?Mr(r):r;let N=x,w=B0(N);for(;w&&r&&b!==N;){const v=nd(w),k=w.getBoundingClientRect(),T=va(w),C=k.left+(w.clientLeft+parseFloat(T.paddingLeft))*v.x,L=k.top+(w.clientTop+parseFloat(T.paddingTop))*v.y;u*=v.x,h*=v.y,f*=v.x,m*=v.y,u+=C,h+=L,N=Mr(w),w=B0(N)}}return Ip({width:f,height:m,x:u,y:h})}function dm(t,e){const n=cm(t).scrollLeft;return e?e.left+n:Zl(Za(t)).left+n}function e4(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-dm(t,n),a=n.top+e.scrollTop;return{x:r,y:a}}function UB(t){let{elements:e,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=Za(r),c=e?lm(e.floating):!1;if(r===o||c&&i)return n;let u={scrollLeft:0,scrollTop:0},h=Ka(1);const f=Ka(0),m=Qa(r);if((m||!m&&!i)&&((vd(r)!=="body"||Zu(o))&&(u=cm(r)),Qa(r))){const b=Zl(r);h=nd(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const x=o&&!m&&!i?e4(o,u):Ka(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 WB(t){return Array.from(t.getClientRects())}function KB(t){const e=Za(t),n=cm(t),r=t.ownerDocument.body,a=Sr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Sr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+dm(t);const c=-n.scrollTop;return va(r).direction==="rtl"&&(o+=Sr(e.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:c}}const xj=25;function qB(t,e){const n=Mr(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=cb();(!f||f&&e==="fixed")&&(c=a.offsetLeft,u=a.offsetTop)}const h=dm(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<=xj&&(i-=N)}else h<=xj&&(i+=h);return{width:i,height:o,x:c,y:u}}const GB=new Set(["absolute","fixed"]);function JB(t,e){const n=Zl(t,!0,e==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=Qa(t)?nd(t):Ka(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 gj(t,e,n){let r;if(e==="viewport")r=qB(t,n);else if(e==="document")r=KB(Za(t));else if(ba(e))r=JB(e,n);else{const a=Z3(t);r={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Ip(r)}function t4(t,e){const n=Qo(t);return n===e||!ba(n)||ud(n)?!1:va(n).position==="fixed"||t4(n,e)}function QB(t,e){const n=e.get(t);if(n)return n;let r=Uu(t,[],!1).filter(c=>ba(c)&&vd(c)!=="body"),a=null;const i=va(t).position==="fixed";let o=i?Qo(t):t;for(;ba(o)&&!ud(o);){const c=va(o),u=lb(o);!u&&c.position==="fixed"&&(a=null),(i?!u&&!a:!u&&c.position==="static"&&!!a&&GB.has(a.position)||Zu(o)&&!u&&t4(t,o))?r=r.filter(f=>f!==o):a=c,o=Qo(o)}return e.set(t,r),r}function YB(t){let{element:e,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?lm(e)?[]:QB(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=gj(e,f,a);return h.top=Sr(m.top,h.top),h.right=Jo(m.right,h.right),h.bottom=Jo(m.bottom,h.bottom),h.left=Sr(m.left,h.left),h},gj(e,c,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function XB(t){const{width:e,height:n}=X3(t);return{width:e,height:n}}function ZB(t,e,n){const r=Qa(e),a=Za(e),i=n==="fixed",o=Zl(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const u=Ka(0);function h(){u.x=dm(a)}if(r||!r&&!i)if((vd(e)!=="body"||Zu(a))&&(c=cm(e)),r){const b=Zl(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?e4(a,c):Ka(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 Mg(t){return va(t).position==="static"}function yj(t,e){if(!Qa(t)||va(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Za(t)===n&&(n=n.ownerDocument.body),n}function n4(t,e){const n=Mr(t);if(lm(t))return n;if(!Qa(t)){let a=Qo(t);for(;a&&!ud(a);){if(ba(a)&&!Mg(a))return a;a=Qo(a)}return n}let r=yj(t,e);for(;r&&OB(r)&&Mg(r);)r=yj(r,e);return r&&ud(r)&&Mg(r)&&!lb(r)?n:r||FB(t)||n}const e9=async function(t){const e=this.getOffsetParent||n4,n=this.getDimensions,r=await n(t.floating);return{reference:ZB(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function t9(t){return va(t).direction==="rtl"}const n9={convertOffsetParentRelativeRectToViewportRelativeRect:UB,getDocumentElement:Za,getClippingRect:YB,getOffsetParent:n4,getElementRects:e9,getClientRects:WB,getDimensions:XB,getScale:nd,isElement:ba,isRTL:t9};function s4(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function s9(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=Nf(m),w=Nf(a.clientWidth-(f+x)),v=Nf(a.clientHeight-(m+b)),k=Nf(f),C={rootMargin:-N+"px "+-w+"px "+-v+"px "+-k+"px",threshold:Sr(0,Jo(1,u))||1};let L=!0;function R(U){const P=U[0].intersectionRatio;if(P!==u){if(!L)return o();P?o(!1,P):r=setTimeout(()=>{o(!1,1e-7)},1e3)}P===1&&!s4(h,t.getBoundingClientRect())&&o(),L=!1}try{n=new IntersectionObserver(R,{...C,root:a.ownerDocument})}catch{n=new IntersectionObserver(R,C)}n.observe(t)}return o(!0),i}function r9(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=db(t),f=a||i?[...h?Uu(h):[],...Uu(e)]:[];f.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const m=h&&c?s9(h,n):null;let x=-1,b=null;o&&(b=new ResizeObserver(k=>{let[T]=k;T&&T.target===h&&b&&(b.unobserve(e),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var C;(C=b)==null||C.observe(e)})),n()}),h&&!u&&b.observe(h),b.observe(e));let N,w=u?Zl(t):null;u&&v();function v(){const k=Zl(t);w&&!s4(w,k)&&n(),w=k,N=requestAnimationFrame(v)}return n(),()=>{var k;f.forEach(T=>{a&&T.removeEventListener("scroll",n),i&&T.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,u&&cancelAnimationFrame(N)}}const a9=MB,i9=AB,o9=CB,l9=IB,c9=EB,bj=SB,d9=PB,u9=(t,e,n)=>{const r=new Map,a={platform:n9,...n},i={...a.platform,_c:r};return kB(t,e,{...a,platform:i})};var h9=typeof document<"u",f9=function(){},Pf=h9?g.useLayoutEffect:f9;function Rp(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(!Rp(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)&&!Rp(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function r4(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function vj(t,e){const n=r4(t);return Math.round(e*n)/n}function Ag(t){const e=g.useRef(t);return Pf(()=>{e.current=t}),e}function p9(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);Rp(x,r)||b(r);const[N,w]=g.useState(null),[v,k]=g.useState(null),T=g.useCallback(B=>{B!==U.current&&(U.current=B,w(B))},[]),C=g.useCallback(B=>{B!==P.current&&(P.current=B,k(B))},[]),L=i||N,R=o||v,U=g.useRef(null),P=g.useRef(null),F=g.useRef(f),O=u!=null,Q=Ag(u),re=Ag(a),D=Ag(h),ne=g.useCallback(()=>{if(!U.current||!P.current)return;const B={placement:e,strategy:n,middleware:x};re.current&&(B.platform=re.current),u9(U.current,P.current,B).then(xe=>{const X={...xe,isPositioned:D.current!==!1};le.current&&!Rp(F.current,X)&&(F.current=X,hd.flushSync(()=>{m(X)}))})},[x,e,n,re,D]);Pf(()=>{h===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,m(B=>({...B,isPositioned:!1})))},[h]);const le=g.useRef(!1);Pf(()=>(le.current=!0,()=>{le.current=!1}),[]),Pf(()=>{if(L&&(U.current=L),R&&(P.current=R),L&&R){if(Q.current)return Q.current(L,R,ne);ne()}},[L,R,ne,Q,O]);const me=g.useMemo(()=>({reference:U,floating:P,setReference:T,setFloating:C}),[T,C]),I=g.useMemo(()=>({reference:L,floating:R}),[L,R]),Y=g.useMemo(()=>{const B={position:n,left:0,top:0};if(!I.floating)return B;const xe=vj(I.floating,f.x),X=vj(I.floating,f.y);return c?{...B,transform:"translate("+xe+"px, "+X+"px)",...r4(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:xe,top:X}},[n,c,I.floating,f.x,f.y]);return g.useMemo(()=>({...f,update:ne,refs:me,elements:I,floatingStyles:Y}),[f,ne,me,I,Y])}const m9=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?bj({element:r.current,padding:a}).fn(n):{}:r?bj({element:r,padding:a}).fn(n):{}}}},x9=(t,e)=>({...a9(t),options:[t,e]}),g9=(t,e)=>({...i9(t),options:[t,e]}),y9=(t,e)=>({...d9(t),options:[t,e]}),b9=(t,e)=>({...o9(t),options:[t,e]}),v9=(t,e)=>({...l9(t),options:[t,e]}),N9=(t,e)=>({...c9(t),options:[t,e]}),w9=(t,e)=>({...m9(t),options:[t,e]});var j9="Arrow",a4=g.forwardRef((t,e)=>{const{children:n,width:r=10,height:a=5,...i}=t;return s.jsx(Tt.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"})})});a4.displayName=j9;var k9=a4,ub="Popper",[i4,o4]=Zo(ub),[S9,l4]=i4(ub),c4=t=>{const{__scopePopper:e,children:n}=t,[r,a]=g.useState(null);return s.jsx(S9,{scope:e,anchor:r,onAnchorChange:a,children:n})};c4.displayName=ub;var d4="PopperAnchor",u4=g.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=l4(d4,n),o=g.useRef(null),c=Xt(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(Tt.div,{...a,ref:c})});u4.displayName=d4;var hb="PopperContent",[C9,E9]=i4(hb),h4=g.forwardRef((t,e)=>{var J,$,Z,ae,we,Fe;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=l4(hb,n),[k,T]=g.useState(null),C=Xt(e,Ue=>T(Ue)),[L,R]=g.useState(null),U=fy(L),P=(U==null?void 0:U.width)??0,F=(U==null?void 0:U.height)??0,O=r+(i!=="center"?"-"+i:""),Q=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},re=Array.isArray(h)?h:[h],D=re.length>0,ne={padding:Q,boundary:re.filter(M9),altBoundary:D},{refs:le,floatingStyles:me,placement:I,isPositioned:Y,middlewareData:B}=p9({strategy:"fixed",placement:O,whileElementsMounted:(...Ue)=>r9(...Ue,{animationFrame:b==="always"}),elements:{reference:v.anchor},middleware:[x9({mainAxis:a+F,alignmentAxis:o}),u&&g9({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?y9():void 0,...ne}),u&&b9({...ne}),v9({...ne,apply:({elements:Ue,rects:wt,availableWidth:jn,availableHeight:pt})=>{const{width:At,height:fn}=wt.reference,Vn=Ue.floating.style;Vn.setProperty("--radix-popper-available-width",`${jn}px`),Vn.setProperty("--radix-popper-available-height",`${pt}px`),Vn.setProperty("--radix-popper-anchor-width",`${At}px`),Vn.setProperty("--radix-popper-anchor-height",`${fn}px`)}}),L&&w9({element:L,padding:c}),A9({arrowWidth:P,arrowHeight:F}),x&&N9({strategy:"referenceHidden",...ne})]}),[xe,X]=m4(I),V=Uo(N);$s(()=>{Y&&(V==null||V())},[Y,V]);const W=(J=B.arrow)==null?void 0:J.x,fe=($=B.arrow)==null?void 0:$.y,he=((Z=B.arrow)==null?void 0:Z.centerOffset)!==0,[de,_]=g.useState();return $s(()=>{k&&_(window.getComputedStyle(k).zIndex)},[k]),s.jsx("div",{ref:le.setFloating,"data-radix-popper-content-wrapper":"",style:{...me,transform:Y?me.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(ae=B.transformOrigin)==null?void 0:ae.x,(we=B.transformOrigin)==null?void 0:we.y].join(" "),...((Fe=B.hide)==null?void 0:Fe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(C9,{scope:n,placedSide:xe,onArrowChange:R,arrowX:W,arrowY:fe,shouldHideArrow:he,children:s.jsx(Tt.div,{"data-side":xe,"data-align":X,...w,ref:C,style:{...w.style,animation:Y?void 0:"none"}})})})});h4.displayName=hb;var f4="PopperArrow",T9={top:"bottom",right:"left",bottom:"top",left:"right"},p4=g.forwardRef(function(e,n){const{__scopePopper:r,...a}=e,i=E9(f4,r),o=T9[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(k9,{...a,ref:n,style:{...a.style,display:"block"}})})});p4.displayName=f4;function M9(t){return t!==null}var A9=t=>({name:"transformOrigin",options:t,fn(e){var v,k,T;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]=m4(n),m={start:"0%",center:"50%",end:"100%"}[f],x=(((k=a.arrow)==null?void 0:k.x)??0)+c/2,b=(((T=a.arrow)==null?void 0:T.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 m4(t){const[e,n="center"]=t.split("-");return[e,n]}var P9=c4,I9=u4,R9=h4,L9=p4,x4=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"}),O9="VisuallyHidden",D9=g.forwardRef((t,e)=>s.jsx(Tt.span,{...t,ref:e,style:{...x4,...t.style}}));D9.displayName=O9;var _9=[" ","Enter","ArrowUp","ArrowDown"],$9=[" ","Enter"],ec="Select",[um,hm,z9]=dy(ec),[Nd]=Zo(ec,[z9,o4]),fm=o4(),[F9,rl]=Nd(ec),[B9,V9]=Nd(ec),g4=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=fm(e),[v,k]=g.useState(null),[T,C]=g.useState(null),[L,R]=g.useState(!1),U=Bp(h),[P,F]=Hl({prop:r,defaultProp:a??!1,onChange:i,caller:ec}),[O,Q]=Hl({prop:o,defaultProp:c,onChange:u,caller:ec}),re=g.useRef(null),D=v?N||!!v.closest("form"):!0,[ne,le]=g.useState(new Set),me=Array.from(ne).map(I=>I.props.value).join(";");return s.jsx(P9,{...w,children:s.jsxs(F9,{required:b,scope:e,trigger:v,onTriggerChange:k,valueNode:T,onValueNodeChange:C,valueNodeHasChildren:L,onValueNodeHasChildrenChange:R,contentId:_o(),value:O,onValueChange:Q,open:P,onOpenChange:F,dir:U,triggerPointerDownPosRef:re,disabled:x,children:[s.jsx(um.Provider,{scope:e,children:s.jsx(B9,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(I=>{le(Y=>new Set(Y).add(I))},[]),onNativeOptionRemove:g.useCallback(I=>{le(Y=>{const B=new Set(Y);return B.delete(I),B})},[]),children:n})}),D?s.jsxs(z4,{"aria-hidden":!0,required:b,tabIndex:-1,name:f,autoComplete:m,value:O,onChange:I=>Q(I.target.value),disabled:x,form:N,children:[O===void 0?s.jsx("option",{value:""}):null,Array.from(ne)]},me):null]})})};g4.displayName=ec;var y4="SelectTrigger",b4=g.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=fm(n),o=rl(y4,n),c=o.disabled||r,u=Xt(e,o.onTriggerChange),h=hm(n),f=g.useRef("touch"),[m,x,b]=B4(w=>{const v=h().filter(C=>!C.disabled),k=v.find(C=>C.value===o.value),T=V4(v,w,k);T!==void 0&&o.onValueChange(T.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(I9,{asChild:!0,...i,children:s.jsx(Tt.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":F4(o.value)?"":void 0,...a,ref:u,onClick:kt(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&N(w)}),onPointerDown:kt(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:kt(a.onKeyDown,w=>{const v=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&x(w.key),!(v&&w.key===" ")&&_9.includes(w.key)&&(N(),w.preventDefault())})})})});b4.displayName=y4;var v4="SelectValue",N4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=t,u=rl(v4,n),{onValueNodeHasChildrenChange:h}=u,f=i!==void 0,m=Xt(e,u.onValueNodeChange);return $s(()=>{h(f)},[h,f]),s.jsx(Tt.span,{...c,ref:m,style:{pointerEvents:"none"},children:F4(u.value)?s.jsx(s.Fragment,{children:o}):i})});N4.displayName=v4;var H9="SelectIcon",w4=g.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...a}=t;return s.jsx(Tt.span,{"aria-hidden":!0,...a,ref:e,children:r||"▼"})});w4.displayName=H9;var U9="SelectPortal",j4=t=>s.jsx(ay,{asChild:!0,...t});j4.displayName=U9;var tc="SelectContent",k4=g.forwardRef((t,e)=>{const n=rl(tc,t.__scopeSelect),[r,a]=g.useState();if($s(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?hd.createPortal(s.jsx(S4,{scope:t.__scopeSelect,children:s.jsx(um.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),i):null}return s.jsx(C4,{...t,ref:e})});k4.displayName=tc;var pa=10,[S4,al]=Nd(tc),W9="SelectContentImpl",K9=Pu("SelectContent.RemoveScroll"),C4=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,T=rl(tc,n),[C,L]=g.useState(null),[R,U]=g.useState(null),P=Xt(e,J=>L(J)),[F,O]=g.useState(null),[Q,re]=g.useState(null),D=hm(n),[ne,le]=g.useState(!1),me=g.useRef(!1);g.useEffect(()=>{if(C)return zk(C)},[C]),Ak();const I=g.useCallback(J=>{const[$,...Z]=D().map(Fe=>Fe.ref.current),[ae]=Z.slice(-1),we=document.activeElement;for(const Fe of J)if(Fe===we||(Fe==null||Fe.scrollIntoView({block:"nearest"}),Fe===$&&R&&(R.scrollTop=0),Fe===ae&&R&&(R.scrollTop=R.scrollHeight),Fe==null||Fe.focus(),document.activeElement!==we))return},[D,R]),Y=g.useCallback(()=>I([F,C]),[I,F,C]);g.useEffect(()=>{ne&&Y()},[ne,Y]);const{onOpenChange:B,triggerPointerDownPosRef:xe}=T;g.useEffect(()=>{if(C){let J={x:0,y:0};const $=ae=>{var we,Fe;J={x:Math.abs(Math.round(ae.pageX)-(((we=xe.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((Fe=xe.current)==null?void 0:Fe.y)??0))}},Z=ae=>{J.x<=10&&J.y<=10?ae.preventDefault():C.contains(ae.target)||B(!1),document.removeEventListener("pointermove",$),xe.current=null};return xe.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",Z,{capture:!0})}}},[C,B,xe]),g.useEffect(()=>{const J=()=>B(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[B]);const[X,V]=B4(J=>{const $=D().filter(we=>!we.disabled),Z=$.find(we=>we.ref.current===document.activeElement),ae=V4($,J,Z);ae&&setTimeout(()=>ae.ref.current.focus())}),W=g.useCallback((J,$,Z)=>{const ae=!me.current&&!Z;(T.value!==void 0&&T.value===$||ae)&&(O(J),ae&&(me.current=!0))},[T.value]),fe=g.useCallback(()=>C==null?void 0:C.focus(),[C]),he=g.useCallback((J,$,Z)=>{const ae=!me.current&&!Z;(T.value!==void 0&&T.value===$||ae)&&re(J)},[T.value]),de=r==="popper"?V0:E4,_=de===V0?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:x,collisionPadding:b,sticky:N,hideWhenDetached:w,avoidCollisions:v}:{};return s.jsx(S4,{scope:n,content:C,viewport:R,onViewportChange:U,itemRefCallback:W,selectedItem:F,onItemLeave:fe,itemTextRefCallback:he,focusSelectedItem:Y,selectedItemText:Q,position:r,isPositioned:ne,searchRef:X,children:s.jsx(iy,{as:K9,allowPinchZoom:!0,children:s.jsx(ry,{asChild:!0,trapped:T.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:kt(a,J=>{var $;($=T.trigger)==null||$.focus({preventScroll:!0}),J.preventDefault()}),children:s.jsx(sy,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:s.jsx(de,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:J=>J.preventDefault(),...k,..._,onPlaced:()=>le(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:kt(k.onKeyDown,J=>{const $=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!$&&J.key.length===1&&V(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ae=D().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const we=J.target,Fe=ae.indexOf(we);ae=ae.slice(Fe+1)}setTimeout(()=>I(ae)),J.preventDefault()}})})})})})})});C4.displayName=W9;var q9="SelectItemAlignedPosition",E4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=rl(tc,n),o=al(tc,n),[c,u]=g.useState(null),[h,f]=g.useState(null),m=Xt(e,P=>f(P)),x=hm(n),b=g.useRef(!1),N=g.useRef(!0),{viewport:w,selectedItem:v,selectedItemText:k,focusSelectedItem:T}=o,C=g.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&h&&w&&v&&k){const P=i.trigger.getBoundingClientRect(),F=h.getBoundingClientRect(),O=i.valueNode.getBoundingClientRect(),Q=k.getBoundingClientRect();if(i.dir!=="rtl"){const we=Q.left-F.left,Fe=O.left-we,Ue=P.left-Fe,wt=P.width+Ue,jn=Math.max(wt,F.width),pt=window.innerWidth-pa,At=Ff(Fe,[pa,Math.max(pa,pt-jn)]);c.style.minWidth=wt+"px",c.style.left=At+"px"}else{const we=F.right-Q.right,Fe=window.innerWidth-O.right-we,Ue=window.innerWidth-P.right-Fe,wt=P.width+Ue,jn=Math.max(wt,F.width),pt=window.innerWidth-pa,At=Ff(Fe,[pa,Math.max(pa,pt-jn)]);c.style.minWidth=wt+"px",c.style.right=At+"px"}const re=x(),D=window.innerHeight-pa*2,ne=w.scrollHeight,le=window.getComputedStyle(h),me=parseInt(le.borderTopWidth,10),I=parseInt(le.paddingTop,10),Y=parseInt(le.borderBottomWidth,10),B=parseInt(le.paddingBottom,10),xe=me+I+ne+B+Y,X=Math.min(v.offsetHeight*5,xe),V=window.getComputedStyle(w),W=parseInt(V.paddingTop,10),fe=parseInt(V.paddingBottom,10),he=P.top+P.height/2-pa,de=D-he,_=v.offsetHeight/2,J=v.offsetTop+_,$=me+I+J,Z=xe-$;if($<=he){const we=re.length>0&&v===re[re.length-1].ref.current;c.style.bottom="0px";const Fe=h.clientHeight-w.offsetTop-w.offsetHeight,Ue=Math.max(de,_+(we?fe:0)+Fe+Y),wt=$+Ue;c.style.height=wt+"px"}else{const we=re.length>0&&v===re[0].ref.current;c.style.top="0px";const Ue=Math.max(he,me+w.offsetTop+(we?W:0)+_)+Z;c.style.height=Ue+"px",w.scrollTop=$-he+w.offsetTop}c.style.margin=`${pa}px 0`,c.style.minHeight=X+"px",c.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[x,i.trigger,i.valueNode,c,h,w,v,k,i.dir,r]);$s(()=>C(),[C]);const[L,R]=g.useState();$s(()=>{h&&R(window.getComputedStyle(h).zIndex)},[h]);const U=g.useCallback(P=>{P&&N.current===!0&&(C(),T==null||T(),N.current=!1)},[C,T]);return s.jsx(J9,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:b,onScrollButtonChange:U,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:s.jsx(Tt.div,{...a,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});E4.displayName=q9;var G9="SelectPopperPosition",V0=g.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=pa,...i}=t,o=fm(n);return s.jsx(R9,{...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)"}})});V0.displayName=G9;var[J9,fb]=Nd(tc,{}),H0="SelectViewport",T4=g.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=al(H0,n),o=fb(H0,n),c=Xt(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(um.Slot,{scope:n,children:s.jsx(Tt.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:kt(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-pa*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})})})]})});T4.displayName=H0;var M4="SelectGroup",[Q9,Y9]=Nd(M4),X9=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=_o();return s.jsx(Q9,{scope:n,id:a,children:s.jsx(Tt.div,{role:"group","aria-labelledby":a,...r,ref:e})})});X9.displayName=M4;var A4="SelectLabel",Z9=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=Y9(A4,n);return s.jsx(Tt.div,{id:a.id,...r,ref:e})});Z9.displayName=A4;var Lp="SelectItem",[eV,P4]=Nd(Lp),I4=g.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,c=rl(Lp,n),u=al(Lp,n),h=c.value===r,[f,m]=g.useState(i??""),[x,b]=g.useState(!1),N=Xt(e,T=>{var C;return(C=u.itemRefCallback)==null?void 0:C.call(u,T,r,a)}),w=_o(),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(eV,{scope:n,value:r,disabled:a,textId:w,isSelected:h,onItemTextChange:g.useCallback(T=>{m(C=>C||((T==null?void 0:T.textContent)??"").trim())},[]),children:s.jsx(um.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:s.jsx(Tt.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:kt(o.onFocus,()=>b(!0)),onBlur:kt(o.onBlur,()=>b(!1)),onClick:kt(o.onClick,()=>{v.current!=="mouse"&&k()}),onPointerUp:kt(o.onPointerUp,()=>{v.current==="mouse"&&k()}),onPointerDown:kt(o.onPointerDown,T=>{v.current=T.pointerType}),onPointerMove:kt(o.onPointerMove,T=>{var C;v.current=T.pointerType,a?(C=u.onItemLeave)==null||C.call(u):v.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:kt(o.onPointerLeave,T=>{var C;T.currentTarget===document.activeElement&&((C=u.onItemLeave)==null||C.call(u))}),onKeyDown:kt(o.onKeyDown,T=>{var L;((L=u.searchRef)==null?void 0:L.current)!==""&&T.key===" "||($9.includes(T.key)&&k(),T.key===" "&&T.preventDefault())})})})})});I4.displayName=Lp;var fu="SelectItemText",R4=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=rl(fu,n),c=al(fu,n),u=P4(fu,n),h=V9(fu,n),[f,m]=g.useState(null),x=Xt(e,k=>m(k),u.onItemTextChange,k=>{var T;return(T=c.itemTextRefCallback)==null?void 0:T.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 $s(()=>(w(N),()=>v(N)),[w,v,N]),s.jsxs(s.Fragment,{children:[s.jsx(Tt.span,{id:u.textId,...i,ref:x}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?hd.createPortal(i.children,o.valueNode):null]})});R4.displayName=fu;var L4="SelectItemIndicator",O4=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return P4(L4,n).isSelected?s.jsx(Tt.span,{"aria-hidden":!0,...r,ref:e}):null});O4.displayName=L4;var U0="SelectScrollUpButton",D4=g.forwardRef((t,e)=>{const n=al(U0,t.__scopeSelect),r=fb(U0,t.__scopeSelect),[a,i]=g.useState(!1),o=Xt(e,r.onScrollButtonChange);return $s(()=>{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});D4.displayName=U0;var W0="SelectScrollDownButton",_4=g.forwardRef((t,e)=>{const n=al(W0,t.__scopeSelect),r=fb(W0,t.__scopeSelect),[a,i]=g.useState(!1),o=Xt(e,r.onScrollButtonChange);return $s(()=>{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});_4.displayName=W0;var $4=g.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=al("SelectScrollButton",n),o=g.useRef(null),c=hm(n),u=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>u(),[u]),$s(()=>{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(Tt.div,{"aria-hidden":!0,...a,ref:e,style:{flexShrink:0,...a.style},onPointerDown:kt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:kt(a.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:kt(a.onPointerLeave,()=>{u()})})}),tV="SelectSeparator",nV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(Tt.div,{"aria-hidden":!0,...r,ref:e})});nV.displayName=tV;var K0="SelectArrow",sV=g.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,a=fm(n),i=rl(K0,n),o=al(K0,n);return i.open&&o.position==="popper"?s.jsx(L9,{...a,...r,ref:e}):null});sV.displayName=K0;var rV="SelectBubbleInput",z4=g.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const a=g.useRef(null),i=Xt(r,a),o=hy(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(Tt.select,{...n,style:{...x4,...n.style},ref:i,defaultValue:e})});z4.displayName=rV;function F4(t){return t===""||t===void 0}function B4(t){const e=Uo(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 V4(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=aV(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 aV(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var iV=g4,H4=b4,oV=N4,lV=w4,cV=j4,U4=k4,dV=T4,W4=I4,uV=R4,hV=O4,fV=D4,pV=_4;const To=iV,Mo=oV,Ii=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(H4,{ref:r,className:zt("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(lV,{asChild:!0,children:s.jsx(Bi,{className:"h-4 w-4 opacity-50"})})]}));Ii.displayName=H4.displayName;const Ri=g.forwardRef(({className:t,children:e,position:n="popper",...r},a)=>s.jsx(cV,{children:s.jsxs(U4,{ref:a,className:zt("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(fV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Bg,{className:"h-4 w-4"})}),s.jsx(dV,{className:"p-1",children:e}),s.jsx(pV,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Bi,{className:"h-4 w-4"})})]})}));Ri.displayName=U4.displayName;const ts=g.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(W4,{ref:r,className:zt("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(hV,{children:s.jsx(_p,{className:"h-4 w-4"})})}),s.jsx(uV,{children:e})]}));ts.displayName=W4.displayName;const Nj=["📖","📕","📗","📘","📙","📓","📔","📒","📚","📖"];function mV(t){return t.title==="序言"||t.title.includes("序言")}function wj(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 Pg(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 xV({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),[T,C]=g.useState(null),L=(D,ne)=>(v==null?void 0:v.type)===D&&(v==null?void 0:v.id)===ne,R=(D,ne)=>(T==null?void 0:T.type)===D&&(T==null?void 0:T.id)===ne,U=g.useCallback(()=>{const D=[];for(const ne of t)for(const le of ne.chapters)for(const me of le.sections)D.push({id:me.id,partId:ne.id,partTitle:ne.title,chapterId:le.id,chapterTitle:le.title});return D},[t]),P=g.useCallback(async(D,ne,le,me)=>{var X;D.preventDefault(),D.stopPropagation();const I=D.dataTransfer.getData("text/plain"),Y=Pg(I);if(!Y||Y.type===ne&&Y.id===le)return;const B=U(),xe=new Map(B.map(V=>[V.id,V]));if(Y.type==="part"&&ne==="part"){const V=t.map(_=>_.id),W=V.indexOf(Y.id),fe=V.indexOf(le);if(W===-1||fe===-1)return;const he=[...V];he.splice(W,1),he.splice(W$.id===_);if(J)for(const $ of J.chapters)for(const Z of $.sections){const ae=xe.get(Z.id);ae&&de.push(ae)}}await r(de);return}if(Y.type==="chapter"&&(ne==="chapter"||ne==="section"||ne==="part")){const V=t.find(ae=>ae.chapters.some(we=>we.id===Y.id)),W=V==null?void 0:V.chapters.find(ae=>ae.id===Y.id);if(!V||!W)return;let fe,he,de=null;if(ne==="section"){const ae=xe.get(le);if(!ae)return;fe=ae.partId,he=ae.partTitle,de=le}else if(ne==="chapter"){const ae=t.find(Ue=>Ue.chapters.some(wt=>wt.id===le)),we=ae==null?void 0:ae.chapters.find(Ue=>Ue.id===le);if(!ae||!we)return;fe=ae.id,he=ae.title;const Fe=B.filter(Ue=>Ue.chapterId===le).pop();de=(Fe==null?void 0:Fe.id)??null}else{const ae=t.find(we=>we.id===le);if(!ae)return;if(fe=ae.id,he=ae.title,ae.chapters[0]){const we=B.filter(Fe=>Fe.partId===ae.id&&Fe.chapterId===ae.chapters[0].id);de=((X=we[we.length-1])==null?void 0:X.id)??null}}const _=W.sections.map(ae=>ae.id),J=B.filter(ae=>!_.includes(ae.id));let $=J.length;if(de){const ae=J.findIndex(we=>we.id===de);ae>=0&&($=ae+1)}const Z=_.map(ae=>({...xe.get(ae),partId:fe,partTitle:he,chapterId:W.id,chapterTitle:W.title}));await r([...J.slice(0,$),...Z,...J.slice($)]);return}if(Y.type==="section"&&(ne==="section"||ne==="chapter"||ne==="part")){if(!me)return;const{partId:V,partTitle:W,chapterId:fe,chapterTitle:he}=me,de=B.findIndex(ae=>ae.id===Y.id);if(de===-1)return;const _=B.filter(ae=>ae.id!==Y.id);let J;if(ne==="section"){const ae=_.findIndex(we=>we.id===le);J=ae>=0?ae+1:_.length}else if(ne==="chapter"){const ae=_.filter(we=>we.chapterId===le).pop();J=ae?_.findIndex(we=>we.id===ae.id)+1:_.length}else{const ae=t.find(we=>we.id===le);if(ae!=null&&ae.chapters[0]){const we=_.filter(Ue=>Ue.partId===ae.id&&Ue.chapterId===ae.chapters[0].id),Fe=we[we.length-1];J=Fe?_.findIndex(Ue=>Ue.id===Fe.id)+1:_.length}else J=_.length}const Z={...B[de],partId:V,partTitle:W,chapterId:fe,chapterTitle:he};_.splice(J,0,Z),await r(_)}},[t,U,r]),F=(D,ne,le)=>({onDragEnter:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",C({type:D,id:ne})},onDragOver:me=>{me.preventDefault(),me.stopPropagation(),me.dataTransfer.dropEffect="move",C({type:D,id:ne})},onDragLeave:()=>C(null),onDrop:me=>{C(null);const I=Pg(me.dataTransfer.getData("text/plain"));I&&(D==="section"&&I.type==="section"&&I.id===ne||(D==="part"?I.type==="part"?P(me,"part",ne):le&&P(me,"part",ne,le):D==="chapter"&&le?(I.type==="section"||I.type==="chapter")&&P(me,"chapter",ne,le):D==="section"&&le&&P(me,"section",ne,le)))}}),O=D=>Nj[D%Nj.length],Q=D=>t.slice(0,D).filter(ne=>!mV(ne)).length,re=D=>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: ${D.id}`,children:D.id}),s.jsx("span",{className:"truncate",children:D.title})]});return s.jsx("div",{className:"space-y-3",children:t.map((D,ne)=>{var W,fe,he,de;const le=D.title==="序言"||D.title.includes("序言"),me=D.title==="尾声"||D.title.includes("尾声"),I=D.title==="附录"||D.title.includes("附录"),Y=R("part",D.id),B=e.includes(D.id),xe=D.chapters.length,X=D.chapters.reduce((_,J)=>_+J.sections.length,0);if(le&&D.chapters.length===1&&D.chapters[0].sections.length===1){const _=D.chapters[0].sections[0],J=R("section",_.id),$={partId:D.id,partTitle:D.title,chapterId:D.chapters[0].id,chapterTitle:D.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+_.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:_.id})},onDragEnd:()=>{k(null),C(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] ${J?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...F("section",_.id,$),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Ni,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.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(ur,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[D.chapters[0].title," | ",_.title]}),w.includes(_.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:Z=>Z.stopPropagation(),onClick:Z=>Z.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(G,{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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]})]},D.id)}if(D.title==="2026每日派对干货"||D.title.includes("2026每日派对干货")){const _=R("part",D.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]"}`,...F("part",D.id,{partId:D.id,partTitle:D.title,chapterId:((W=D.chapters[0])==null?void 0:W.id)??"",chapterTitle:((fe=D.chapters[0])==null?void 0:fe.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:J=>{J.stopPropagation(),J.dataTransfer.setData("text/plain","part:"+D.id),J.dataTransfer.effectAllowed="move",k({type:"part",id:D.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",D.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(Ni,{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:D.badgeText||"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:D.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:wj(D)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:J=>J.stopPropagation(),onClick:J=>J.stopPropagation(),children:[o&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),f&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(D),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(ns,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",X," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:B?"收起":"展开",onMouseDown:J=>J.stopPropagation(),onClick:J=>{J.stopPropagation(),n(D.id)},children:B?s.jsx(Bi,{className:"w-5 h-5"}):s.jsx(Li,{className:"w-5 h-5"})})]})]}),B&&D.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:D.chapters.map(J=>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:J.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:$=>$.stopPropagation(),children:[m&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>m(D,J),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),c&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>u(D,J),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:J.sections.map($=>{const Z=R("section",$.id);return s.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+$.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:$.id})},onDragEnd:()=>{k(null),C(null)},onClick:()=>a($),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${Z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...F("section",$.id,{partId:D.id,partTitle:D.title,chapterId:J.id,chapterTitle:J.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.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("span",{className:"text-sm text-gray-200 truncate flex items-center min-w-0",children:re($)}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:ae=>ae.stopPropagation(),children:[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(G,{variant:"ghost",size:"sm",onClick:()=>N($),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]},$.id)})})]},J.id))})]},D.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:D.chapters.map((_,J)=>_.sections.length>0?_.sections.map($=>{const Z=R("section",$.id);return s.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+$.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:$.id})},onDragEnd:()=>{k(null),C(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 ${Z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...F("section",$.id,{partId:D.id,partTitle:D.title,chapterId:_.id,chapterTitle:_.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ae=>ae.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.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",J+1," | ",_.title," | ",$.title]}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:["点击 ",$.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(G,{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 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Li,{className:"w-4 h-4 text-gray-500 shrink-0"})]},$.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:["附录",J+1," | ",_.title,"(空)"]}),s.jsx(Li,{className:"w-4 h-4 text-gray-500 shrink-0"})]},_.id))})]},D.id);if(me&&D.chapters.length===1&&D.chapters[0].sections.length===1){const _=D.chapters[0].sections[0],J=R("section",_.id),$={partId:D.id,partTitle:D.title,chapterId:D.chapters[0].id,chapterTitle:D.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+_.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:_.id})},onDragEnd:()=>{k(null),C(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] ${J?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...F("section",_.id,$),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(Ni,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.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(ur,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[D.chapters[0].title," | ",_.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>Z.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(G,{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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]})]},D.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:D.chapters.map(_=>_.sections.map(J=>{const $=R("section",J.id);return s.jsxs("div",{draggable:!0,onDragStart:Z=>{Z.stopPropagation(),Z.dataTransfer.setData("text/plain","section:"+J.id),Z.dataTransfer.effectAllowed="move",k({type:"section",id:J.id})},onDragEnd:()=>{k(null),C(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 ${$?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${L("section",J.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...F("section",J.id,{partId:D.id,partTitle:D.title,chapterId:_.id,chapterTitle:_.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),b&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:Z=>Z.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:x.includes(J.id),onChange:()=>b(J.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," | ",J.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",J.clickCount??0," · 付款 ",J.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(J.hotScore??0).toFixed(1)," · 第",J.hotRank&&J.hotRank>0?J.hotRank:"-","名"]}),N&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>N(J),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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(J),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(J),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]})]},J.id)}))})]},D.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${Y?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...F("part",D.id,{partId:D.id,partTitle:D.title,chapterId:((he=D.chapters[0])==null?void 0:he.id)??"",chapterTitle:((de=D.chapters[0])==null?void 0:de.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:_=>{_.stopPropagation(),_.dataTransfer.setData("text/plain","part:"+D.id),_.dataTransfer.effectAllowed="move",k({type:"part",id:D.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${L("part",D.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(Ni,{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:D.badgeText||O(Q(ne))}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:D.title}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:wj(D)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:_=>_.stopPropagation(),onClick:_=>_.stopPropagation(),children:[o&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),f&&s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(D),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(ns,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",title:"本篇章数与节数",children:[xe," 章 · ",X," 节"]}),s.jsx("button",{type:"button",draggable:!1,className:"p-1 rounded-md hover:bg-white/10 text-gray-500",title:B?"收起":"展开",onMouseDown:_=>_.stopPropagation(),onClick:_=>{_.stopPropagation(),n(D.id)},children:B?s.jsx(Bi,{className:"w-5 h-5"}):s.jsx(Li,{className:"w-5 h-5"})})]})]}),B&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:D.chapters.map(_=>{const J=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:$=>{$.stopPropagation(),$.dataTransfer.setData("text/plain","chapter:"+_.id),$.dataTransfer.effectAllowed="move",k({type:"chapter",id:_.id})},onDragEnd:()=>{k(null),C(null)},onDragEnter:$=>{$.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="move",C({type:"chapter",id:_.id})},onDragOver:$=>{$.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="move",C({type:"chapter",id:_.id})},onDragLeave:()=>C(null),onDrop:$=>{C(null);const Z=Pg($.dataTransfer.getData("text/plain"));if(!Z)return;const ae={partId:D.id,partTitle:D.title,chapterId:_.id,chapterTitle:_.title};(Z.type==="section"||Z.type==="chapter")&&P($,"chapter",_.id,ae)},className:`flex-1 min-w-0 py-2 px-2 rounded cursor-grab active:cursor-grabbing select-none -mx-2 transition-all duration-200 flex items-center gap-2 ${J?"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(Ni,{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:$=>$.stopPropagation(),children:[m&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>m(D,_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),c&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(D),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(Rn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>u(D,_),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:_.sections.map($=>{const Z=R("section",$.id);return s.jsxs("div",{draggable:!0,onDragStart:ae=>{ae.stopPropagation(),ae.dataTransfer.setData("text/plain","section:"+$.id),ae.dataTransfer.effectAllowed="move",k({type:"section",id:$.id})},onDragEnd:()=>{k(null),C(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 ${Z?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${L("section",$.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...F("section",$.id,{partId:D.id,partTitle:D.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:ae=>ae.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(Ni,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${$.price===0||$.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:re($)}),w.includes($.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(Jc,{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:ae=>ae.stopPropagation(),onClick:ae=>ae.stopPropagation(),children:[$.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),$.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",title:"点击次数 · 付款笔数",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(G,{variant:"ghost",size:"sm",onClick:()=>N($),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(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a($),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(an,{className:"w-3.5 h-3.5"})}),s.jsx(G,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i($),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(ns,{className:"w-3.5 h-3.5"})})]})]})]},$.id)})})]},_.id)})})]},D.id)})})}function gV(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 Le(r)}function yV(t){return Le(`/api/db/person?personId=${encodeURIComponent(t)}`)}function bV(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 Le(n?`/api/admin/ckb/plans?${n}`:"/api/admin/ckb/plans")}const vV=10;function K4(t){const e=(t??"").trim();if(!e)return"";if(/^https?:\/\//i.test(e))return ya(e);const n=e.startsWith("/")?e:`/${e}`;return ya(Vl(n))}function NV(t){const{nickname:e,avatar:n}=t,r=K4(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 wV(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 jV({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=qa(w,300),[T,C]=g.useState([]),[L,R]=g.useState(!1),[U,P]=g.useState(!1),[F,O]=g.useState(0),Q=g.useRef(1),re=g.useRef(!1),D=g.useRef(!1),ne=g.useRef(null),le=g.useRef(null),[me,I]=g.useState({top:0,left:0,width:320,maxH:360}),Y=g.useCallback(()=>{const _=le.current;if(!_||typeof window>"u")return;const J=_.getBoundingClientRect(),$=Math.min(400,Math.max(200,window.innerHeight-J.bottom-16)),Z=x==null?void 0:x.current;if(Z){const ae=Z.getBoundingClientRect();I({top:J.bottom-ae.top+6,left:J.left-ae.left,width:Math.max(J.width,300),maxH:$})}else I({top:J.bottom+6,left:J.left,width:Math.max(J.width,300),maxH:$})},[x]);g.useEffect(()=>{c||(N(!1),v(""))},[c]),g.useLayoutEffect(()=>{if(b)return Y(),window.addEventListener("scroll",Y,!0),window.addEventListener("resize",Y),()=>{window.removeEventListener("scroll",Y,!0),window.removeEventListener("resize",Y)}},[b,Y]);const B=g.useCallback(async(_,J,$)=>{if(!re.current){re.current=!0,$?P(!0):R(!0);try{const Z=new URLSearchParams({page:String(_),pageSize:String(vV),search:J.trim()}),ae=await Le(`/api/db/users?${Z}`);if(ae!=null&&ae.success&&Array.isArray(ae.users)){const we=ae.users,Fe=typeof ae.total=="number"?ae.total:0;O(Fe),$?we.length===0?D.current=!0:C(Ue=>{const wt=wV(Ue,we);return wt.length===Ue.length?D.current=!0:Q.current=_,wt}):(C(we),Q.current=_)}else ae!=null&&ae.error&&q.error(ae.error)}catch(Z){q.error(Z instanceof Error?Z.message:"加载用户列表失败")}finally{re.current=!1,R(!1),P(!1)}}},[]);g.useEffect(()=>{b&&(Q.current=1,D.current=!1,B(1,k,!1))},[b,k,B]);const xe=g.useCallback(()=>{L||U||re.current||D.current||F>0&&T.length>=F||B(Q.current+1,k,!0)},[k,B,L,U,F,T.length]);g.useLayoutEffect(()=>{if(!b||L||U||D.current||F>0&&T.length>=F||T.length===0)return;const _=ne.current;_&&(_.scrollHeight>_.clientHeight+12||xe())},[b,T.length,L,U,F,xe]);const X=_=>{(_.id||"").trim()&&(i(_),N(!1),v(""))},V=_=>{_.preventDefault(),_.stopPropagation(),!(u||a)&&o()},W=!!n.trim(),fe=F>0,he=typeof document>"u"?null:(m==null?void 0:m.current)??document.body,de=b&&he&&hd.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(oe,{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:["已加载 ",T.length," / ",F," 条",T.length{const J=_.currentTarget;L||U||D.current||F>0&&T.length>=F||J.scrollHeight-J.scrollTop-J.clientHeight<100&&xe()},children:L&&T.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-gray-400 text-sm",children:"正在加载…"}):T.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:[T.map(_=>{const J=_.id||"",$=n===J,Z=K4(_.avatar),ae=_.nickname&&String(_.nickname).trim()||"(无昵称)";return s.jsxs("button",{type:"button",role:"option","aria-selected":$,className:zt("flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left text-sm transition-colors",$?"border-[#38bdac] bg-[#38bdac]/15 text-white":"border-transparent bg-[#050c18] hover:border-[#38bdac]/40 hover:bg-[#0a1628]"),onMouseDown:we=>we.preventDefault(),onClick:()=>X(_),children:[s.jsx("span",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-gray-800",children:Z?s.jsx("img",{src:Z,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:ae.slice(0,1)})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium truncate",children:ae}),s.jsxs("div",{className:"text-[11px] text-gray-500 font-mono truncate mt-0.5",children:[_.phone?`${_.phone} · `:"",J]})]})]},J)}),U&&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(G,{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:zt("space-y-1.5",f),children:[typeof e=="string"?s.jsx(te,{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:le,id:t,type:"button",disabled:u,"aria-haspopup":"listbox","aria-expanded":b,className:zt("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(""),Y()),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:"正在加载已绑定用户…"}):W?s.jsx(NV,{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(Bi,{className:zt("h-4 w-4 shrink-0 text-gray-400 transition-transform",b&&"rotate-180")})]}),W&&s.jsx(G,{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:V,children:s.jsx(ss,{className:"h-4 w-4"})})]}),h&&s.jsx("div",{className:"text-[11px] text-gray-500",children:h}),de]})}const q4=11,jj={personId:"",name:"",boundUserId:"",aliases:"",label:"",sceneId:q4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"06:00",endTime:"22:00",deviceGroups:""};function kV({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){var J;const a=!!n,i=g.useRef(null),o=g.useRef(null),[c,u]=g.useState(jj),[h,f]=g.useState(!1),[m,x]=g.useState(!1),[b,N]=g.useState([]),[w,v]=g.useState(!1),[k,T]=g.useState(""),[C,L]=g.useState([]),[R,U]=g.useState(!1),[P,F]=g.useState(""),[O,Q]=g.useState(!1),[re,D]=g.useState(null),[ne,le]=g.useState(!1),[me,I]=g.useState({}),[Y,B]=g.useState({loading:!1,messages:[]}),xe=qa(c.name,400),X=qa(c.aliases,400);g.useEffect(()=>{if(!t){B({loading:!1,messages:[]});return}const $=xe.trim(),Z=X.trim();if(!$&&!Z){B({loading:!1,messages:[]});return}let ae=!1;B(Ue=>({...Ue,loading:!0}));const we=a?((n==null?void 0:n.personId)??"").trim():"",Fe=new URLSearchParams;return $&&Fe.set("name",xe.trim()),Fe.set("aliases",X),we&&Fe.set("excludePersonId",we),Le(`/api/db/persons/check-unique?${Fe.toString()}`).then(Ue=>{if(!ae){if((Ue==null?void 0:Ue.success)===!1&&(Ue!=null&&Ue.error)){B({loading:!1,messages:[Ue.error]});return}if((Ue==null?void 0:Ue.ok)===!1&&Array.isArray(Ue.messages)&&Ue.messages.length>0){B({loading:!1,messages:Ue.messages});return}B({loading:!1,messages:[]})}}).catch(()=>{ae||B({loading:!1,messages:[]})}),()=>{ae=!0}},[t,xe,X,a,n==null?void 0:n.personId]),g.useEffect(()=>{if(t){if(T(""),D(null),le(!1),n){u({personId:n.personId??n.name??"",name:n.name??"",boundUserId:n.userId??"",aliases:n.aliases??"",label:n.label??"",sceneId:q4,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 $=(n.userId??"").trim();$&&(le(!0),Le(`/api/db/users?id=${encodeURIComponent($)}`).then(Z=>{const ae=Z==null?void 0:Z.user;ae!=null&&ae.id?D({id:ae.id,nickname:ae.nickname&&String(ae.nickname).trim()||ae.id,phone:ae.phone,avatar:ae.avatar??void 0}):D({id:$,nickname:$,phone:void 0,avatar:void 0})}).catch(()=>{D({id:$,nickname:$,phone:void 0,avatar:void 0})}).finally(()=>le(!1)))}else u({...jj});I({}),b.length===0&&V(""),C.length===0&&W("")}},[t,n]);const V=async $=>{v(!0);try{const Z=await gV({page:1,limit:50,keyword:$});Z!=null&&Z.success&&Array.isArray(Z.devices)?N(Z.devices):Z!=null&&Z.error&&q.error(Z.error)}catch(Z){q.error(Z instanceof Error?Z.message:"加载设备列表失败")}finally{v(!1)}},W=async $=>{U(!0);try{const Z=await bV({page:1,limit:100,keyword:$});Z!=null&&Z.success&&Array.isArray(Z.plans)?L(Z.plans):Z!=null&&Z.error&&q.error(Z.error)}catch{q.error("加载计划列表失败")}finally{U(!1)}},fe=()=>{u($=>{const Z=($.boundUserId||"").trim(),ae={...$,boundUserId:""};return!a&&Z&&($.personId||"").trim()===Z&&(ae.personId=""),ae}),D(null)},he=$=>{const Z=Array.isArray($.deviceGroups)?$.deviceGroups.map(String).join(","):"";u(ae=>({...ae,ckbApiKey:$.apiKey||"",greeting:$.greeting||ae.greeting,tips:$.tips||ae.tips,remarkType:$.remarkType||ae.remarkType,remarkFormat:$.remarkFormat||ae.remarkFormat,addFriendInterval:$.addInterval||ae.addFriendInterval,startTime:$.startTime||ae.startTime,endTime:$.endTime||ae.endTime,deviceGroups:Z||ae.deviceGroups})),Q(!1),q.success(`已选择计划「${$.name}」,参数已覆盖`)},de=P.trim()?C.filter($=>($.name||"").includes(P.trim())||String($.id).includes(P.trim())):C,_=async()=>{var we;const $={};(!c.name||!String(c.name).trim())&&($.name="请填写名称");const Z=c.addFriendInterval;if((typeof Z!="number"||Z<1)&&($.addFriendInterval="添加间隔至少为 1 分钟"),(((we=c.deviceGroups)==null?void 0:we.split(",").map(Fe=>Fe.trim()).filter(Boolean))??[]).length===0&&($.deviceGroups="请至少选择 1 台设备"),I($),Object.keys($).length>0){q.error($.name||$.addFriendInterval||$.deviceGroups||"请完善必填项");return}if(Y.messages.length>0){q.error(Y.messages[0]??"名称或别名与他人重复");return}f(!0);try{await r(c),e(!1)}catch(Fe){q.error(Fe instanceof Error?Fe.message:"保存失败")}finally{f(!1)}};return s.jsx(Lt,{open:t,onOpenChange:e,children:s.jsxs(It,{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(Ot,{children:[s.jsx(Dt,{className:"text-[#38bdac]",children:a?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Wo,{className:"text-gray-400 text-sm",children:a?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),s.jsxs("div",{className:"space-y-6 py-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(te,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(oe,{className:`bg-[#0a1628] text-white ${me.name?"border-red-500 focus-visible:ring-red-500":Y.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡若",value:c.name,onChange:$=>{u(Z=>({...Z,name:$.target.value})),me.name&&I(Z=>({...Z,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(te,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:(c.boundUserId||"").trim()?c.boundUserId:c.personId,onChange:$=>u(Z=>({...Z,personId:$.target.value})),disabled:a||!!(c.boundUserId||"").trim()})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:c.label,onChange:$=>u(Z=>({...Z,label:$.target.value}))})]}),s.jsx(jV,{className:"col-span-3",id:"person-bound-member-user",label:"绑定会员用户(可选,与「用户管理」中用户一致)",containerOpen:t,portalMountRef:o,positionContainerRef:i,value:c.boundUserId,preview:re,previewLoading:ne,onSelect:$=>{const Z=($.id||"").trim();Z&&(u(ae=>({...ae,boundUserId:Z,...a?{}:{personId:Z}})),D({id:Z,nickname:$.nickname&&String($.nickname).trim()||Z,phone:$.phone,avatar:$.avatar??void 0}))},onClear:fe,hint:s.jsx("span",{children:"单选;保存时后端校验用户是否存在。同一会员只能绑定一个 @人物;绑定后获客统计可与超级个体对齐。"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"别名(逗号分隔,@ 可匹配)"}),s.jsx(oe,{className:`bg-[#0a1628] text-white ${Y.messages.length>0?"border-amber-600 focus-visible:ring-amber-600/50":"border-gray-700"}`,placeholder:"如 卡卡, 若若",value:c.aliases,onChange:$=>u(Z=>({...Z,aliases:$.target.value}))})]}),s.jsx("div",{className:"col-span-3 space-y-1",children:Y.loading?s.jsx("p",{className:"text-xs text-gray-500",children:"正在检测名称与别名是否与他人重复…"}):Y.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:Y.messages.map(($,Z)=>s.jsx("p",{children:$},`${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(te,{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:()=>Q(!O),children:c.ckbApiKey?s.jsx("span",{className:"text-white truncate",children:((J=C.find($=>$.apiKey===c.ckbApiKey))==null?void 0:J.name)||`获客计划 (${c.ckbApiKey.slice(0,8)}…)`}):s.jsx("span",{className:"text-gray-500",children:"点击选择已有计划 / 新建时自动创建"})}),s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200 shrink-0",onClick:()=>{W(P),Q(!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(oe,{className:"bg-[#050c18] border-gray-700 text-white h-8 text-xs",placeholder:"搜索计划名称...",value:P,onChange:$=>F($.target.value),onKeyDown:$=>{$.key==="Enter"&&W(P)},autoFocus:!0})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:de.length===0?s.jsx("div",{className:"text-center py-4 text-gray-500 text-xs",children:R?"加载中...":"暂无计划"}):de.map($=>s.jsxs("div",{className:`px-3 py-2 cursor-pointer hover:bg-[#38bdac]/10 text-sm flex items-center justify-between ${c.ckbApiKey===$.apiKey?"bg-[#38bdac]/20 text-[#38bdac]":"text-white"}`,onClick:()=>he($),children:[s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-medium",children:$.name}),s.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["ID:",String($.id)]})]}),$.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($.id)))}),s.jsx("div",{className:"p-2 border-t border-gray-700/60 flex justify-end",children:s.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"text-gray-400 h-7 text-xs",onClick:()=>Q(!1),children:"关闭"})})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"选择计划后自动覆盖下方参数。新建人物时若不选择则自动创建新计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(te,{className:"text-gray-400 text-xs",children:["选择设备 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:`flex gap-2 rounded-md border ${me.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(oe,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:c.deviceGroups?`已选择 ${c.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>x(!0)}),s.jsx(G,{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(te,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(To,{value:c.remarkType,onValueChange:$=>u(Z=>({...Z,remarkType:$})),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{placeholder:"选择备注类型"})}),s.jsxs(Ri,{children:[s.jsx(ts,{value:"phone",children:"手机号"}),s.jsx(ts,{value:"nickname",children:"昵称"}),s.jsx(ts,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"备注格式(手机号+标签,标签不超过6字)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 {手机号}-{来源标签},总长不超过10字",value:c.remarkFormat,onChange:$=>u(Z=>({...Z,remarkFormat:$.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(te,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:c.greeting,onChange:$=>u(Z=>({...Z,greeting:$.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(oe,{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:$=>{u(Z=>({...Z,addFriendInterval:Number($.target.value)||1})),me.addFriendInterval&&I(Z=>({...Z,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(te,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.startTime,onChange:$=>u(Z=>({...Z,startTime:$.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:c.endTime,onChange:$=>u(Z=>({...Z,endTime:$.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:c.tips,onChange:$=>u(Z=>({...Z,tips:$.target.value}))})]})]})]})]})]})]}),s.jsxs(nn,{className:"gap-3 border-t border-gray-700/40 px-6 py-4 shrink-0",children:[s.jsx(G,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(G,{onClick:_,disabled:h||Y.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(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>{const $=b.map(we=>String(we.id??"")),Z=c.deviceGroups?c.deviceGroups.split(",").map(we=>we.trim()).filter(Boolean):[],ae=$.length>0&&$.every(we=>Z.includes(we));u(we=>({...we,deviceGroups:ae?"":$.join(",")})),!ae&&$.length>0&&I(we=>({...we,deviceGroups:void 0}))},children:(()=>{const $=b.map(ae=>String(ae.id??"")),Z=c.deviceGroups?c.deviceGroups.split(",").map(ae=>ae.trim()).filter(Boolean):[];return $.length>0&&$.every(ae=>Z.includes(ae))?"取消全选":"全选"})()}),s.jsx(oe,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:k,onChange:$=>T($.target.value),onKeyDown:$=>{$.key==="Enter"&&V(k)}}),s.jsx(G,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>V(k),disabled:w,children:"刷新"}),s.jsx(G,{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($=>{const Z=String($.id??""),ae=c.deviceGroups?c.deviceGroups.split(",").map(Ue=>Ue.trim()).filter(Boolean):[],we=ae.includes(Z),Fe=()=>{let Ue;we?Ue=ae.filter(wt=>wt!==Z):Ue=[...ae,Z],u(wt=>({...wt,deviceGroups:Ue.join(",")})),Ue.length>0&&I(wt=>({...wt,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:Fe}),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:$.memo||$.wechatId||`设备 ${Z}`}),$.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),$.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: ",Z]}),$.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",$.wechatId]}),typeof $.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",$.totalFriend]})]})]})]},Z)})})}),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(G,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>x(!1),children:"取消"}),s.jsx(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>x(!1),children:"确定"})]})]})]})})]})})}const Ig=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 qc(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 SV(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:qc(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 CV(){var ml,pc,xl;const t=Ya(),[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,T]=g.useState([]),[C,L]=g.useState(!1),[R,U]=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,z]=g.useState(null),[O,Q]=g.useState(!1),[re,D]=g.useState(!1),[ne,le]=g.useState(null),[me,I]=g.useState(!1),[Y,F]=g.useState([]),[xe,X]=g.useState(!1),[V,W]=g.useState(""),[fe,he]=g.useState(""),[de,_]=g.useState(!1),[J,$]=g.useState(""),[Z,ae]=g.useState(!1),[we,Fe]=g.useState(null),[Ue,wt]=g.useState(!1),[jn,pt]=g.useState(!1),[At,fn]=g.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[Vn,pn]=g.useState(!1),[qt,bn]=g.useState(!1),[Mn,Hn]=g.useState(1),[rs,_t]=g.useState([]),[vn,Ne]=g.useState(!1),[Me,We]=g.useState([]),[rt,$t]=g.useState(!1),[kt,$e]=g.useState(20),[H,Qe]=g.useState(!1),[vt,Ft]=g.useState(!1),[yt,ht]=g.useState(Ig),[Pt,Gt]=g.useState(!1),[kn,Ts]=g.useState(!1),[Ms,Ki]=g.useState([]),[ja,ei]=g.useState([]),[ti,Ar]=g.useState([]),[Pr,Ir]=g.useState(!1),[Qr,Vs]=g.useState(1),[Qs,pr]=g.useState(20),[Ys,ka]=g.useState(0),[ce,ve]=g.useState(1),[Rt,Zt]=g.useState(""),[sn,as]=g.useState(!1),[Rr,Yr]=g.useState(null),[Tt,Jn]=g.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),[Xr,Sa]=g.useState(!1),[mn,Zr]=g.useState(!1),[ni,mr]=g.useState(null),[As,Ca]=g.useState(null),[qi,Xs]=g.useState({}),[Zs,Gi]=g.useState(!1),[bs,il]=g.useState(""),[Ji,vs]=g.useState(""),[er,tr]=g.useState([]),[xr,si]=g.useState(0),[ea,ac]=g.useState(1),[ol,ri]=g.useState(!1),[Qi,Ea]=g.useState(""),ll=g.useRef(null),Ta=g.useCallback(async(E,B)=>{var gt;const ue=new FormData;ue.append("file",E),ue.append("folder",B);const Ke=await(await fetch(Vl("/api/upload"),{method:"POST",body:ue,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((gt=Ke==null?void 0:Ke.data)==null?void 0:gt.url)||(Ke==null?void 0:Ke.url)||""},[]),Nt=g.useCallback(E=>Ta(E,"book-images"),[Ta]),Yi=g.useCallback(E=>{const B=E.type.startsWith("video/")?"book-videos":"book-attachments";return Ta(E,B)},[Ta]),[cl,ai]=g.useState({}),ii=E=>String(E||"").trim().slice(0,8),ic=g.useMemo(()=>{const E=new Map;return rs.forEach((B,ue)=>{E.set(B.id,ue+1)}),E},[rs]),Qn=SV(e,ic,cl),Ma=e.length,ta=10,Hs=Math.max(1,Math.ceil(rs.length/ta)),Us=rs.slice((Mn-1)*ta,Mn*ta),cn=async()=>{a(!0);try{const E=await Le("/api/db/book?action=list",{cache:"no-store"});n(Array.isArray(E==null?void 0:E.sections)?E.sections:[])}catch(E){console.error(E),n([])}finally{a(!1)}},nr=async()=>{try{const E=await Le("/api/db/config?key=book_part_badges",{cache:"no-store"});let B={};if(E&&Array.isArray(E.data)){const ke=E.data.find(Ke=>Ke&&Ke.configKey==="book_part_badges");ke&&ke.configValue&&typeof ke.configValue=="object"&&!Array.isArray(ke.configValue)&&(B=ke.configValue)}else E&&E.data&&typeof E.data=="object"&&!Array.isArray(E.data)&&(B=E.data);const ue={};Object.keys(B).forEach(ke=>{const Ke=ii(B[ke]);Ke&&(ue[ke]=Ke)}),ai(ue)}catch(E){console.error(E),ai({})}},gr=async()=>{Ne(!0);try{const E=await Le("/api/db/book?action=ranking",{cache:"no-store"}),B=Array.isArray(E==null?void 0:E.sections)?E.sections:[];_t(B);const ue=B.filter(ke=>ke.isPinned).map(ke=>ke.id);We(ue)}catch(E){console.error(E),_t([])}finally{Ne(!1)}};g.useEffect(()=>{cn(),gr(),nr()},[]);const yr=E=>{o(B=>B.includes(E)?B.filter(ue=>ue!==E):[...B,E])},oc=g.useCallback(E=>{const B=e,ue=E.flatMap(ke=>{const Ke=B.find(gt=>gt.id===ke.id);return Ke?[{...Ke,partId:ke.partId,partTitle:ke.partTitle,chapterId:ke.chapterId,chapterTitle:ke.chapterTitle}]:[]});return n(ue),tn("/api/db/book",{action:"reorder",items:E}).then(ke=>{ke&&ke.success===!1&&(n(B),q.error("排序失败: "+(ke&&typeof ke=="object"&&"error"in ke?ke.error:"未知错误")))}).catch(ke=>{n(B),console.error("排序失败:",ke),q.error("排序失败: "+(ke instanceof Error?ke.message:"网络或服务异常"))}),Promise.resolve()},[e]),lc=async E=>{if(confirm(`确定要删除章节「${E.title}」吗?此操作不可恢复。`))try{const B=await Pi(`/api/db/book?id=${encodeURIComponent(E.id)}`);B&&B.success!==!1?(q.success("已删除"),cn(),gr()):q.error("删除失败: "+(B&&typeof B=="object"&&"error"in B?B.error:"未知错误"))}catch(B){console.error(B),q.error("删除失败")}},Aa=g.useCallback(async()=>{pn(!0);try{const E=await Le("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),B=E&&E.data;B&&typeof B.readWeight=="number"&&typeof B.recencyWeight=="number"&&typeof B.payWeight=="number"&&fn({readWeight:Math.max(0,Math.min(1,B.readWeight)),recencyWeight:Math.max(0,Math.min(1,B.recencyWeight)),payWeight:Math.max(0,Math.min(1,B.payWeight))})}catch{}finally{pn(!1)}},[]);g.useEffect(()=>{jn&&Aa()},[jn,Aa]);const wd=async()=>{const{readWeight:E,recencyWeight:B,payWeight:ue}=At,ke=E+B+ue;if(Math.abs(ke-1)>.001){q.error("三个权重之和必须等于 1");return}bn(!0);try{const Ke=await bt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:E,recencyWeight:B,payWeight:ue},description:"文章排名算法权重"});Ke&&Ke.success!==!1?(q.success("排名权重已保存"),pt(!1),cn(),gr()):q.error("保存失败: "+(Ke&&typeof Ke=="object"&&"error"in Ke?Ke.error:""))}catch(Ke){console.error(Ke),q.error("保存失败")}finally{bn(!1)}},dl=g.useCallback(async()=>{$t(!0);try{const E=await Le("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),B=E&&E.data;Array.isArray(B)&&We(B)}catch{}finally{$t(!1)}},[]),Ns=g.useCallback(async()=>{try{const E=await Le("/api/db/persons");E!=null&&E.success&&E.persons&&Ki(E.persons.map(B=>{const ue=B.deviceGroups,ke=Array.isArray(ue)?ue.join(","):ue??"";return{id:B.token??B.personId??"",personId:B.personId,name:B.name,personSource:B.personSource??"",userId:B.userId,aliases:B.aliases??"",label:B.label??"",ckbApiKey:B.ckbApiKey??"",ckbPlanId:B.ckbPlanId,remarkType:B.remarkType,remarkFormat:B.remarkFormat,addFriendInterval:B.addFriendInterval,startTime:B.startTime,endTime:B.endTime,deviceGroups:ke,isPinned:!!B.isPinned}}))}catch{}},[]),na=g.useCallback(async(E,B)=>{const ue=(E.personId||E.id||"").trim();if(!ue){q.error("缺少 personId");return}B&&!(E.userId||"").trim()&&q.info("未绑定会员时,小程序仍显示 @ 名称,头像可能为默认图");try{const ke=await tn("/api/db/persons/pin",{personId:ue,isPinned:B});if(!(ke!=null&&ke.success)){q.error((ke==null?void 0:ke.error)||"置顶失败");return}q.success(B?"已设为小程序首页置顶(全局仅一条)":"已取消置顶"),await Ns()}catch(ke){q.error(ke instanceof Error?ke.message:"操作失败")}},[Ns]),sa=g.useCallback(async()=>{try{const E=await Le("/api/db/link-tags");E!=null&&E.success&&E.linkTags&&ei(E.linkTags.map(B=>({id:B.tagId,label:B.label,url:B.url,type:B.type||"url",appId:B.appId||"",pagePath:B.pagePath||"",hasAppSecret:!!B.hasAppSecret})))}catch{}},[]),Pa=g.useCallback(async()=>{try{const E=await Le("/api/db/config/full?key=ckb_lead_webhook_url",{cache:"no-store"});E!=null&&E.success&&typeof E.data=="string"&&Ea(E.data)}catch{}},[]),Ia=g.useCallback(async()=>{try{const E=await Le("/api/db/ckb-person-leads");if(E!=null&&E.success&&E.byPerson){const B={};for(const ue of E.byPerson)B[ue.token]=ue.total;Xs(B)}}catch{}},[]),_n=g.useCallback(async(E,B,ue=1)=>{il(E),vs(B),Gi(!0),ac(ue),ri(!0);try{const ke=await Le(`/api/db/ckb-person-leads?token=${encodeURIComponent(E)}&page=${ue}&pageSize=20`);ke!=null&&ke.success?(tr(ke.records||[]),si(ke.total||0)):q.error((ke==null?void 0:ke.error)||"加载获客详情失败")}catch(ke){q.error(ke instanceof Error?ke.message:"加载获客详情失败")}finally{ri(!1)}},[]),Lr=g.useCallback(async()=>{Ir(!0);try{const E=new URLSearchParams({page:String(Qr),pageSize:String(Qs)}),B=Rt.trim();B&&E.set("search",B);const ue=await Le(`/api/db/link-tags?${E.toString()}`);if(ue!=null&&ue.success){const ke=Array.isArray(ue.linkTags)?ue.linkTags:[];Ar(ke.map(Ke=>({id:Ke.tagId,label:Ke.label,aliases:Ke.aliases||"",url:Ke.url,type:Ke.type||"url",appId:Ke.appId||"",pagePath:Ke.pagePath||"",hasAppSecret:!!Ke.hasAppSecret}))),ka(typeof ue.total=="number"?ue.total:0),ve(typeof ue.totalPages=="number"&&ue.totalPages>0?ue.totalPages:1)}}catch(E){console.error(E),q.error("加载链接标签失败")}finally{Ir(!1)}},[Qr,Qs,Rt]),[ra,oi]=g.useState([]),[br,Ps]=g.useState(""),[Ra,vr]=g.useState(!1),Nr=g.useRef(null),Xi=g.useCallback(async()=>{try{const E=await Le("/api/admin/linked-miniprograms");E!=null&&E.success&&Array.isArray(E.data)&&oi(E.data.map(B=>({...B,key:B.key})))}catch{}},[]),Or=ra.filter(E=>!br.trim()||E.name.toLowerCase().includes(br.toLowerCase())||E.key&&E.key.toLowerCase().includes(br.toLowerCase())||E.appId.toLowerCase().includes(br.toLowerCase())),aa=async E=>{const B=Me.includes(E)?Me.filter(ue=>ue!==E):[...Me,E];We(B);try{await bt("/api/db/config",{key:"pinned_section_ids",value:B,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),gr()}catch{We(Me)}},ia=g.useCallback(async()=>{Qe(!0);try{const E=await Le("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),B=E&&E.data;typeof B=="number"&&B>0&&B<=100&&$e(B)}catch{}finally{Qe(!1)}},[]),li=async()=>{if(kt<1||kt>100){q.error("预览比例需在 1~100 之间");return}Ft(!0);try{const E=await bt("/api/db/config",{key:"unpaid_preview_percent",value:kt,description:"小程序未付费内容默认预览比例(%)"});E&&E.success!==!1?q.success("预览比例已保存"):q.error("保存失败: "+(E.error||""))}catch{q.error("保存失败")}finally{Ft(!1)}},ci=g.useCallback(async()=>{Gt(!0);try{const E=await Le("/api/db/config/full?key=read_preview_ui",{cache:"no-store"}),B=E&&E.data;B!=null&&typeof B=="object"&&!Array.isArray(B)&&Object.keys(B).length>0?ht(JSON.stringify(B,null,2)):ht(Ig)}catch{ht(Ig)}finally{Gt(!1)}},[]),is=async()=>{let E;try{E=JSON.parse(yt)}catch{q.error("JSON 格式错误,请检查括号与引号");return}Ts(!0);try{const B=await bt("/api/db/config",{key:"read_preview_ui",value:E,description:"阅读页/朋友圈付费墙与分享文案(占位符 {percent} {price})"});B&&B.success!==!1?q.success("阅读页文案已保存"):q.error("保存失败: "+(B.error||""))}catch{q.error("保存失败")}finally{Ts(!1)}};g.useEffect(()=>{dl(),ia(),ci(),Ns(),sa(),Ia(),Xi(),Pa()},[dl,ia,ci,Ns,sa,Ia,Xi,Pa]),g.useEffect(()=>{Lr()},[Lr]);const Dr=async E=>{Fe({section:E,orders:[]}),wt(!0);try{const B=await Le(`/api/db/book?action=section-orders&id=${encodeURIComponent(E.id)}`),ue=B!=null&&B.success&&Array.isArray(B.orders)?B.orders:[];Fe(ke=>ke?{...ke,orders:ue}:null)}catch(B){console.error(B),Fe(ue=>ue?{...ue,orders:[]}:null)}finally{wt(!1)}},di=async E=>{x(!0);try{const B=E.mid!=null&&E.mid>0?`/api/db/book?action=read&mid=${E.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(E.id)}`,ue=await Le(B);if(ue!=null&&ue.success&&ue.section){const ke=ue.section,Ke=ke.editionPremium===!0,gt=qc(ke.previewPercent)??qc(ke.preview_percent),at=qc(E.previewPercent);u({id:E.id,originalId:E.id,title:ue.section.title??E.title,price:ue.section.price??E.price,content:ue.section.content??"",filePath:E.filePath,isFree:E.isFree||E.price===0,isNew:ke.isNew??E.isNew,isPinned:Me.includes(E.id),hotScore:E.hotScore??0,previewPercent:gt??at??void 0,editionStandard:Ke?!1:ke.editionStandard??!0,editionPremium:Ke})}else u({id:E.id,originalId:E.id,title:E.title,price:E.price,content:"",filePath:E.filePath,isFree:E.isFree,isNew:E.isNew,isPinned:Me.includes(E.id),hotScore:E.hotScore??0,previewPercent:qc(E.previewPercent),editionStandard:!0,editionPremium:!1}),ue&&!ue.success&&q.error("无法读取文件内容: "+(ue.error||"未知错误"))}catch(B){console.error(B),u({id:E.id,title:E.title,price:E.price,content:"",filePath:E.filePath,isFree:E.isFree,previewPercent:qc(E.previewPercent)})}finally{x(!1)}},ui=async()=>{var E;if(c){N(!0);try{let B=c.content||"";const ue=[new RegExp(`^#+\\s*${c.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${c.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(E=c.title)==null?void 0:E.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const Yn of ue)B=B.replace(Yn,"");B=B.replace(/^\s*\n+/,"").trim();const ke=c.originalId||c.id,Ke=c.id!==ke,gt={id:ke,...Ke?{newId:c.id}:{},title:c.title,price:c.isFree?0:c.price,content:B,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?gt.previewPercent=null:typeof c.previewPercent=="number"&&Number.isFinite(c.previewPercent)&&(gt.previewPercent=c.previewPercent);const at=await tn("/api/db/book",gt,{timeout:F1}),$n=Ke?c.id:ke;c.isPinned!==Me.includes($n)&&await aa($n),at&&at.success!==!1?(q.success(`已保存:${c.title}`),u(null),cn(),Ns(),sa()):q.error("保存失败: "+(at&&typeof at=="object"&&"error"in at?at.error:"未知错误"))}catch(B){console.error(B);const ue=B instanceof Error&&B.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";q.error(ue)}finally{N(!1)}}},jd=async()=>{if(!R.id||!R.title){q.error("请填写章节ID和标题");return}N(!0);try{const E=Qn.find(ke=>ke.id===R.partId),B=E==null?void 0:E.chapters.find(ke=>ke.id===R.chapterId),ue=await tn("/api/db/book",{id:R.id,title:R.title,price:R.isFree?0:R.price,content:R.content||"",partId:R.partId,partTitle:(E==null?void 0:E.title)??"",chapterId:R.chapterId,chapterTitle:(B==null?void 0:B.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:F1});if(ue&&ue.success!==!1){if(R.isPinned){const ke=[...Me,R.id];We(ke);try{await bt("/api/db/config",{key:"pinned_section_ids",value:ke,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}q.success(`章节创建成功:${R.title}`),f(!1),U({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),cn(),Ns(),sa()}else q.error("创建失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(E){console.error(E),q.error("创建失败")}finally{N(!1)}},ul=E=>{U(B=>{var ue;return{...B,partId:E.id,chapterId:((ue=E.chapters[0])==null?void 0:ue.id)??"chapter-1"}}),f(!0)},hl=E=>{z({id:E.id,title:E.title,badgeText:ii(E.badgeText)})},hi=async()=>{var E;if((E=P==null?void 0:P.title)!=null&&E.trim()){Q(!0);try{const B=e.map(ke=>({id:ke.id,partId:ke.partId||"part-1",partTitle:ke.partId===P.id?P.title.trim():ke.partTitle||"",chapterId:ke.chapterId||"chapter-1",chapterTitle:ke.chapterTitle||""})),ue=await tn("/api/db/book",{action:"reorder",items:B});if(ue&&ue.success!==!1){const ke=P.title.trim(),Ke={...cl},gt=ii(P.badgeText);gt?Ke[P.id]=gt:delete Ke[P.id];const at=await bt("/api/db/config",{key:"book_part_badges",value:Ke,description:"目录篇名角标(key=part_id, value=角标文案)"});if(at&&at.success===!1){q.error("更新篇名角标失败: "+(at.error||"未知错误"));return}ai(Ke),n($n=>$n.map(Yn=>Yn.partId===P.id?{...Yn,partTitle:ke}:Yn)),z(null),cn()}else q.error("更新篇名失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(B){console.error(B),q.error("更新篇名失败")}finally{Q(!1)}}},oa=E=>{const B=E.chapters.length+1,ue=`chapter-${E.id}-${B}-${Date.now()}`;U({id:`${B}.1`,title:"新章节",price:1,partId:E.id,chapterId:ue,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),f(!0)},La=(E,B)=>{const ue=B.sections;let ke=1,Ke=!1,gt=!1;if(ue.length>0){const at=typeof ue[0].price=="number"?ue[0].price:Number(ue[0].price)||1,$n=!!(ue[0].isFree||at===0);gt=ue.some(Yn=>{const Sn=typeof Yn.price=="number"?Yn.price:Number(Yn.price)||1,sr=!!(Yn.isFree||Sn===0);return Sn!==at||sr!==$n}),ke=$n?0:at,Ke=$n}le({part:E,chapter:B,title:B.title,price:ke,isFree:Ke,priceMixed:gt,initialTitle:B.title,initialPrice:ke,initialIsFree:Ke})},fl=async()=>{var Ke;if(!((Ke=ne==null?void 0:ne.title)!=null&&Ke.trim()))return;const E=ne,B=E.title.trim(),ue=B!==E.initialTitle,ke=E.isFree!==E.initialIsFree||!E.isFree&&Number(E.price)!==Number(E.initialPrice);if(!ue&&!ke){q.info("未修改任何内容"),le(null);return}if(E.priceMixed&&ke){const gt=E.chapter.sections.length,at=E.isFree?"全部设为免费":`全部设为 ¥${E.price}`;if(!confirm(`本章 ${gt} 节当前定价不一致,保存后将${at},确定?`))return}I(!0);try{if(ue){const gt=e.map(Sn=>({id:Sn.id,partId:Sn.partId||E.part.id,partTitle:Sn.partId===E.part.id?E.part.title:Sn.partTitle||"",chapterId:Sn.chapterId||E.chapter.id,chapterTitle:Sn.partId===E.part.id&&Sn.chapterId===E.chapter.id?B:Sn.chapterTitle||""})),at=await tn("/api/db/book",{action:"reorder",items:gt});if(at&&at.success===!1){q.error("保存章节名失败: "+(at&&typeof at=="object"&&"error"in at?at.error:"未知错误"));return}const $n=E.part.id,Yn=E.chapter.id;n(Sn=>Sn.map(sr=>sr.partId===$n&&sr.chapterId===Yn?{...sr,chapterTitle:B}:sr))}if(ke){const gt=await tn("/api/db/book",{action:"update-chapter-pricing",partId:E.part.id,chapterId:E.chapter.id,price:E.isFree?0:Number(E.price)||0,isFree:E.isFree});if(gt&>.success===!1){q.error("保存定价失败: "+(gt&&typeof gt=="object"&&"error"in gt?gt.error:"未知错误")),ue&&cn();return}}le(null),cn(),q.success("已保存")}catch(gt){console.error(gt),q.error("保存失败")}finally{I(!1)}},cc=async(E,B)=>{const ue=B.sections.map(ke=>ke.id);if(ue.length===0){q.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${E.chapters.indexOf(B)+1}章 | ${B.title}」吗?将删除共 ${ue.length} 节,此操作不可恢复。`))try{for(const ke of ue)await Pi(`/api/db/book?id=${encodeURIComponent(ke)}`);cn()}catch(ke){console.error(ke),q.error("删除失败")}},dc=async()=>{if(!J.trim()){q.error("请输入篇名");return}ae(!0);try{const E=`part-new-${Date.now()}`,B="chapter-1",ue=`part-placeholder-${Date.now()}`,ke=await tn("/api/db/book",{id:ue,title:"占位节(可编辑)",price:0,content:"",partId:E,partTitle:J.trim(),chapterId:B,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ke&&ke.success!==!1?(q.success(`篇「${J}」创建成功`),D(!1),$(""),cn()):q.error("创建失败: "+(ke&&typeof ke=="object"&&"error"in ke?ke.error:"未知错误"))}catch(E){console.error(E),q.error("创建失败")}finally{ae(!1)}},Zi=async()=>{if(Y.length===0){q.error("请先勾选要移动的章节");return}const E=Qn.find(ue=>ue.id===V),B=E==null?void 0:E.chapters.find(ue=>ue.id===fe);if(!E||!B||!V||!fe){q.error("请选择目标篇和章");return}_(!0);try{const ue=()=>{const at=new Set(Y),$n=e.map(Un=>({id:Un.id,partId:Un.partId||"",partTitle:Un.partTitle||"",chapterId:Un.chapterId||"",chapterTitle:Un.chapterTitle||""})),Yn=$n.filter(Un=>at.has(Un.id)).map(Un=>({...Un,partId:V,partTitle:E.title||V,chapterId:fe,chapterTitle:B.title||fe})),Sn=$n.filter(Un=>!at.has(Un.id));let sr=Sn.length;for(let Un=Sn.length-1;Un>=0;Un-=1){const mc=Sn[Un];if(mc.partId===V&&mc.chapterId===fe){sr=Un+1;break}}return[...Sn.slice(0,sr),...Yn,...Sn.slice(sr)]},ke=async()=>{const at=ue(),$n=await tn("/api/db/book",{action:"reorder",items:at});return $n&&$n.success!==!1?(q.success(`已移动 ${Y.length} 节到「${E.title}」-「${B.title}」`),X(!1),F([]),await cn(),!0):!1},Ke={action:"move-sections",sectionIds:Y,targetPartId:V,targetChapterId:fe,targetPartTitle:E.title||V,targetChapterTitle:B.title||fe},gt=await tn("/api/db/book",Ke);if(gt&>.success!==!1)q.success(`已移动 ${gt.count??Y.length} 节到「${E.title}」-「${B.title}」`),X(!1),F([]),await cn();else{const at=gt&&typeof gt=="object"&&"error"in gt?gt.error||"":"未知错误";if((at.includes("缺少 id")||at.includes("无效的 action"))&&await ke())return;q.error("移动失败: "+at)}}catch(ue){console.error(ue),q.error("移动失败: "+(ue instanceof Error?ue.message:"网络或服务异常"))}finally{_(!1)}},uc=E=>{F(B=>B.includes(E)?B.filter(ue=>ue!==E):[...B,E])},kd=async E=>{const B=e.filter(ue=>ue.partId===E.id).map(ue=>ue.id);if(B.length===0){q.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${E.title}」整篇吗?将删除共 ${B.length} 节内容,此操作不可恢复。`))try{for(const ue of B)await Pi(`/api/db/book?id=${encodeURIComponent(ue)}`);cn()}catch(ue){console.error(ue),q.error("删除失败")}},hc=async()=>{var E;if(w.trim()){L(!0);try{const B=await Le(`/api/search?q=${encodeURIComponent(w)}`);B!=null&&B.success&&((E=B.data)!=null&&E.results)?T(B.data.results):(T([]),B&&!B.success&&q.error("搜索失败: "+B.error))}catch(B){console.error(B),T([]),q.error("搜索失败")}finally{L(!1)}}},pl=Qn.find(E=>E.id===R.partId),fc=(pl==null?void 0:pl.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:["共 ",Qn.length," 篇 · ",Ma," 节内容"]})]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(G,{onClick:()=>pt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Qh,{className:"w-4 h-4 mr-2"}),"排名算法"]})})]}),s.jsx(Lt,{open:h,onOpenChange:f,children:s.jsxs(It,{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(Ot,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节ID *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:R.id,onChange:E=>U({...R,id:E.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:R.isFree?0:R.price,onChange:E=>U({...R,price:Number(E.target.value),isFree:Number(E.target.value)===0}),disabled:R.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:R.isFree,onChange:E=>U({...R,isFree:E.target.checked,price:E.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:R.isNew,onChange:E=>U({...R,isNew:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:R.isPinned,onChange:E=>U({...R,isPinned:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:R.editionPremium!==!0,onChange:()=>U({...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:()=>U({...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(te,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:R.hotScore??0,onChange:E=>U({...R,hotScore:Math.max(0,parseFloat(E.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:R.title,onChange:E=>U({...R,title:E.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"所属篇"}),s.jsxs(To,{value:R.partId,onValueChange:E=>{var ue;const B=Qn.find(ke=>ke.id===E);U({...R,partId:E,chapterId:((ue=B==null?void 0:B.chapters[0])==null?void 0:ue.id)??"chapter-1"})},children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{})}),s.jsxs(Ri,{className:"bg-[#0f2137] border-gray-700",children:[Qn.map(E=>s.jsx(us,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id)),Qn.length===0&&s.jsx(us,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"所属章"}),s.jsxs(To,{value:R.chapterId,onValueChange:E=>U({...R,chapterId:E}),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{})}),s.jsxs(Ri,{className:"bg-[#0f2137] border-gray-700",children:[fc.map(E=>s.jsx(us,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id)),fc.length===0&&s.jsx(us,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx($0,{content:R.content||"",onChange:E=>U({...R,content:E}),onImageUpload:Nt,onMediaUpload:Yi,persons:Ms,linkTags:ja,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(nn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(G,{variant:"outline",onClick:()=>f(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:jd,disabled:b||!R.id||!R.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Lt,{open:!!P,onOpenChange:E=>!E&&z(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{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(te,{className:"text-gray-300",children:"篇名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.title,onChange:E=>z({...P,title:E.target.value}),placeholder:"输入篇名"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"左侧图标文字(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.badgeText||"",onChange:E=>z({...P,badgeText:ii(E.target.value)}),placeholder:"例如:派 / 新 / 热",maxLength:8}),s.jsx("p",{className:"text-xs text-gray-500",children:"保存后会同步到目录左侧图标文字(小程序与管理端目录树)。"})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>z(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:hi,disabled:O||!((ml=P==null?void 0:P.title)!=null&&ml.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:O?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Lt,{open:!!ne,onOpenChange:E=>!E&&le(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsxs(Ot,{children:[s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),s.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),ne&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:ne.title,onChange:E=>le({...ne,title:E.target.value}),placeholder:"输入章节名称"})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[s.jsxs(te,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",ne.chapter.sections.length," 节)"]}),ne.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(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:ne.isFree?0:ne.price,onChange:E=>le({...ne,price:Number(E.target.value),isFree:Number(E.target.value)===0}),disabled:ne.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:ne.isFree||ne.price===0,onChange:E=>le({...ne,isFree:E.target.checked,price:E.target.checked?0:ne.initialPrice>0?ne.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(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>le(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:fl,disabled:me||!((pc=ne==null?void 0:ne.title)!=null&&pc.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Lt,{open:xe,onOpenChange:E=>{var B;if(X(E),E&&Qn.length>0){const ue=Qn[0];W(ue.id),he(((B=ue.chapters[0])==null?void 0:B.id)??"")}},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsx(Dt,{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:Y.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目标篇"}),s.jsxs(To,{value:V,onValueChange:E=>{var ue;W(E);const B=Qn.find(ke=>ke.id===E);he(((ue=B==null?void 0:B.chapters[0])==null?void 0:ue.id)??"")},children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{placeholder:"选择篇"})}),s.jsx(Ri,{className:"bg-[#0f2137] border-gray-700",children:Qn.map(E=>s.jsx(us,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目标章"}),s.jsxs(To,{value:fe,onValueChange:he,children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{placeholder:"选择章"})}),s.jsx(Ri,{className:"bg-[#0f2137] border-gray-700",children:(((xl=Qn.find(E=>E.id===V))==null?void 0:xl.chapters)??[]).map(E=>s.jsx(us,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id))})]})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>X(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:Zi,disabled:de||Y.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:de?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Lt,{open:!!we,onOpenChange:E=>!E&&Fe(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{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(Ve,{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(E=>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:`查看订单 ${E.orderSn}`,onClick:()=>window.open(`/orders?search=${E.orderSn??E.id??""}`,"_blank"),children:E.orderSn?E.orderSn.length>16?E.orderSn.slice(0,8)+"..."+E.orderSn.slice(-6):E.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:`查看用户 ${E.userId??E.openId??""}`,onClick:()=>window.open(`/users?search=${E.userId??E.openId??""}`,"_blank"),children:(()=>{const B=E.userId??E.openId??"-";return B.length>12?B.slice(0,6)+"..."+B.slice(-4):B})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",E.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:E.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:E.payTime??E.createdAt??"-"})]},E.id??E.orderSn??""))})]}):null})]})}),s.jsx(Lt,{open:jn,onOpenChange:pt,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Qh,{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)"}),Vn?s.jsx("p",{className:"text-gray-500",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.readWeight,onChange:E=>fn(B=>({...B,readWeight:Math.max(0,Math.min(1,parseFloat(E.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.recencyWeight,onChange:E=>fn(B=>({...B,recencyWeight:Math.max(0,Math.min(1,parseFloat(E.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.payWeight,onChange:E=>fn(B=>({...B,payWeight:Math.max(0,Math.min(1,parseFloat(E.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(At.readWeight+At.recencyWeight+At.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(G,{onClick:wd,disabled:qt||Math.abs(At.readWeight+At.recencyWeight+At.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:qt?"保存中...":"保存权重"})]})]})]})}),s.jsx(Lt,{open:re,onOpenChange:D,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:J,onChange:E=>$(E.target.value),placeholder:"输入篇名"})]})}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>{D(!1),$("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:dc,disabled:Z||!J.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:Z?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Lt,{open:!!c,onOpenChange:()=>u(null),children:s.jsxs(It,{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(Ot,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{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(te,{className:"text-gray-300",children:"章节ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.id,onChange:E=>u({...c,id:E.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:c.isFree?0:c.price,onChange:E=>u({...c,price:Number(E.target.value),isFree:Number(E.target.value)===0}),disabled:c.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:c.isFree||c.price===0,onChange:E=>u({...c,isFree:E.target.checked,price:E.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"预览%"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",placeholder:`全局 ${kt}%`,value:c.previewPercent!=null?String(c.previewPercent):"",onChange:E=>{const B=E.target.value.trim();if(B===""){u({...c,previewPercent:null});return}const ue=Number(B);Number.isFinite(ue)&&u({...c,previewPercent:Math.min(100,Math.max(1,Math.round(ue)))})}})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:c.isNew??!1,onChange:E=>u({...c,isNew:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:c.isPinned??!1,onChange:E=>u({...c,isPinned:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"edition-type",checked: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(te,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:c.hotScore??0,onChange:E=>u({...c,hotScore:Math.max(0,parseFloat(E.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.title,onChange:E=>u({...c,title:E.target.value})})]}),c.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文件路径"}),s.jsx(oe,{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(te,{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(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx($0,{ref:ll,content:c.content||"",onChange:E=>u({...c,content:E}),onImageUpload:Nt,onMediaUpload:Yi,persons:Ms,linkTags:ja,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(nn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[c&&s.jsxs(G,{variant:"outline",onClick:()=>Dr({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(ur,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(G,{variant:"outline",onClick:()=>u(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(G,{onClick:ui,disabled:b,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(Wl,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Ko,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Ut,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(ur,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(Ut,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(qg,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(Ut,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(Ut,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),"@列表"]}),s.jsxs(Ut,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(D1,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),s.jsxs(Wt,{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(ur,{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:Ma}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(G,{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(Rn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(G,{onClick:()=>D(!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(Rn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(G,{variant:"outline",onClick:()=>X(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",Y.length," 节)"]})]}),r?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(xV,{parts:Qn,expandedParts:i,onTogglePart:yr,onReorder:oc,onReadSection:di,onDeleteSection:lc,onAddSectionInPart:ul,onAddChapterInPart:oa,onDeleteChapter:cc,onEditPart:hl,onDeletePart:kd,onEditChapter:La,selectedSectionIds:Y,onToggleSectionSelect:uc,onShowSectionOrders:Dr,pinnedSectionIds:Me})]}),s.jsx(Wt,{value:"search",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{children:s.jsx(ut,{className:"text-white",children:"内容搜索"})}),s.jsxs(_e,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:w,onChange:E=>v(E.target.value),onKeyDown:E=>E.key==="Enter"&&hc()}),s.jsx(G,{onClick:hc,disabled:C||!w.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?s.jsx(Ve,{className:"w-4 h-4 animate-spin"}):s.jsx(hr,{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(E=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>{const B=e.find(ue=>ue.id===E.id);di({id:E.id,mid:E.mid,title:E.title,price:E.price??1,filePath:"",previewPercent:B==null?void 0:B.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:E.id}),s.jsx("span",{className:"text-white",children:E.title}),Me.includes(E.id)&&s.jsx(Jc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Be,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:E.matchType==="title"?"标题匹配":"内容匹配"})]}),E.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:E.snippet}),(E.partTitle||E.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[E.partTitle," · ",E.chapterTitle]})]},E.id))]})]})]})}),s.jsxs(Wt,{value:"ranking",className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{className:"pb-3",children:s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Qh,{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(te,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(oe,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:kt,onChange:E=>$e(Math.max(1,Math.min(100,Number(E.target.value)||20))),disabled:H}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(G,{size:"sm",onClick:li,disabled:vt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:vt?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",kt,"% 内容;章节「预览%」可单独覆盖"]})]}),s.jsxs("div",{className:"mt-6 space-y-2",children:[s.jsx(te,{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(el,{className:"bg-[#0a1628] border-gray-700 text-gray-200 font-mono text-xs min-h-[280px]",value:yt,onChange:E=>ht(E.target.value),disabled:Pt,spellCheck:!1}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>ci(),disabled:Pt,children:"重新加载"}),s.jsx(G,{type:"button",size:"sm",onClick:is,disabled:kn||Pt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:kn?"保存中...":"保存文案配置"})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(qg,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",rs.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>gr(),disabled:vn,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Ve,{className:`w-4 h-4 ${vn?"animate-spin":""}`})}),s.jsx(G,{variant:"ghost",size:"sm",disabled:Mn<=1||vn,onClick:()=>Hn(E=>Math.max(1,E-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(TT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[Mn," / ",Hs]}),s.jsx(G,{variant:"ghost",size:"sm",disabled:Mn>=Hs||vn,onClick:()=>Hn(E=>Math.min(Hs,E+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(Li,{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:"编辑"})]}),Us.map((E,B)=>{const ue=(Mn-1)*ta+B+1,ke=E.isPinned??Me.includes(E.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 ${ke?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${ue<=3?"text-amber-400":"text-gray-500"}`,children:ue<=3?["🥇","🥈","🥉"][ue-1]:`#${ue}`}),s.jsx(G,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ke?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>aa(E.id),disabled:rt,title:ke?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ke?s.jsx(Jc,{className:"w-3.5 h-3.5 fill-current"}):s.jsx($1,{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:E.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[E.partTitle," · ",E.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:E.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:E.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(E.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(G,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>di({id:E.id,mid:E.mid,title:E.title,price:E.price,filePath:"",previewPercent:E.previewPercent}),title:"编辑文章",children:s.jsx(an,{className:"w-3 h-3"})})})]},E.id)}),Us.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(Wt,{value:"link-person",className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{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.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(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>{Ns()},title:"刷新",children:s.jsx(Ve,{className:"w-4 h-4"})}),s.jsxs(G,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{mr(null),Zr(!0)},children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),s.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:Ms.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-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:Ms.map(E=>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:E.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:()=>{qi[E.id]&&_n(E.id,E.name)},title:qi[E.id]?"点击查看获客详情":E.name,children:E.name})}),s.jsx("td",{className:"py-2 px-3",children:E.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:E.userId?s.jsxs("div",{className:"flex flex-col gap-0.5 items-start max-w-[100px]",children:[E.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: ${E.userId}`,onClick:()=>t(`/users?search=${encodeURIComponent(E.userId||"")}`),children:E.name})]}):s.jsx("span",{className:"text-gray-600",children:"—"})}),(()=>{const B=qi[E.id]||0;return s.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold cursor-pointer ${B>0?"text-green-400 hover:text-green-300 hover:underline":"text-gray-600"}`,title:B>0?"点击查看获客详情":"暂无获客",onClick:()=>{B>0&&_n(E.id,E.name)},children:B})})(),s.jsx("td",{className:"py-2 px-3 text-white truncate max-w-[220px]",title:`planId: ${E.ckbPlanId??"-"}`,children:s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"truncate",children:E.ckbPlanId?E.personSource==="vip_sync"?"超级个体拉群(统一计划)":`SOUL链接人与事-${E.name}`:"—"})})}),s.jsx("td",{className:"py-2 px-2 text-center",children:s.jsx(G,{type:"button",variant:"ghost",size:"sm",className:E.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:E.isPinned?"取消小程序首页置顶":"设为小程序首页置顶(全局唯一)",onClick:()=>void na(E,!E.isPinned),children:s.jsx($1,{className:`w-3.5 h-3.5 ${E.isPinned?"fill-amber-400":""}`})})}),s.jsx("td",{className:"py-2 px-3 text-center",children:E.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(G,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const B=await yV(E.personId||"");if(B!=null&&B.success&&B.person){const ue=B.person;mr({id:ue.token??ue.personId,personId:ue.personId,name:ue.name,personSource:ue.personSource??"",userId:ue.userId??"",label:ue.label??"",ckbApiKey:ue.ckbApiKey??"",remarkType:ue.remarkType,remarkFormat:ue.remarkFormat,addFriendInterval:ue.addFriendInterval,startTime:ue.startTime,endTime:ue.endTime,deviceGroups:ue.deviceGroups})}else mr(E),B!=null&&B.error&&q.error(B.error)}catch(B){console.error(B),mr(E),q.error(B instanceof Error?B.message:"加载人物详情失败")}Zr(!0)},children:s.jsx(Kg,{className:"w-3 h-3"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>_n(E.id,E.name),children:s.jsx(Kn,{className:"w-3 h-3"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:E.personSource==="vip_sync"?"删除本地 @人物(不删统一获客计划)":"删除(同时删除存客宝对应获客计划)",onClick:()=>Ca(E),children:s.jsx(ns,{className:"w-3 h-3"})})]})})]},E.id))})]}):s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(vA,{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(te,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",s.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Qh,{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(te,{className:"text-gray-400 text-xs",children:"Webhook URL"}),s.jsx(oe,{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:Qi,onChange:E=>Ea(E.target.value)})]}),s.jsxs(G,{size:"sm",className:"bg-blue-500 hover:bg-blue-600 text-white h-8",onClick:async()=>{const E=Qi.trim();try{const B=await bt("/api/db/config",{key:"ckb_lead_webhook_url",value:E,description:"获客线索 Webhook 通知 URL(企微/飞书)"});B!=null&&B.success?q.success(E?"Webhook 已保存":"Webhook 已清除"):q.error((B==null?void 0:B.error)??"保存失败")}catch{q.error("保存失败")}},children:[s.jsx(Tn,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"配置企业微信或飞书群机器人 Webhook URL,获客成功后自动推送通知"})]})]})]}),s.jsxs(Wt,{value:"link-tag",className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(D1,{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(te,{className:"text-gray-400 text-xs",children:"搜索"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:Rt,onChange:E=>{Zt(E.target.value),Vs(1)}})]}),s.jsx(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{sa(),Lr()},title:"刷新",children:s.jsx(Ve,{className:"w-4 h-4"})})]}),s.jsxs(G,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{Yr(null),Jn({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),Ps(""),vr(!1),as(!0)},children:[s.jsx(Rn,{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:Pr?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"加载中..."})}):ti.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):ti.map(E=>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:()=>{Yr(E),Jn({tagId:E.id,label:E.label,aliases:E.aliases??"",url:E.url,type:E.type,appId:E.appId??"",appSecret:"",pagePath:E.pagePath??""}),Ps(E.appId??""),vr(!1),as(!0)},title:"点击编辑标签",children:["#",E.label]})}),s.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs truncate max-w-[120px]",title:E.aliases||"",children:E.aliases||"—"}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Be,{variant:"secondary",className:`text-[10px] ${E.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":E.type==="miniprogram"||E.type==="wxlink"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:E.type==="url"?"网页":E.type==="ckb"?"存客宝":E.type==="wxlink"?"小程序链接":"小程序"})}),s.jsx("td",{className:"px-3 py-2 text-gray-300",children:E.type==="miniprogram"?s.jsxs("div",{className:"space-y-0.5",children:[(()=>{const B=ra.find(ue=>ue.key===E.appId);return s.jsxs(s.Fragment,{children:[B&&s.jsx("div",{className:"text-xs text-white",children:B.name}),s.jsxs("div",{className:"text-xs font-mono text-[#38bdac]",children:["AppID: ",(B==null?void 0:B.appId)||E.appId||"—"]})]})})(),E.pagePath&&s.jsx("div",{className:"text-xs text-gray-500 font-mono",children:E.pagePath}),s.jsxs("div",{className:`text-xs ${E.hasAppSecret?"text-emerald-400/90":"text-amber-500/80"}`,children:["AppSecret:",E.hasAppSecret?"已保存(仅服务端)":"未配置"]})]}):E.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:E.url,children:E.url||"—"}),s.jsx("div",{className:"text-[11px] text-gray-500",children:"小程序内点击 → web-view 打开 → 自动唤起目标小程序"})]}):E.url?s.jsxs("a",{href:E.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[E.url," ",s.jsx(Vo,{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(G,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{Yr(E),Jn({tagId:E.id,label:E.label,aliases:E.aliases??"",url:E.url,type:E.type,appId:E.appId??"",appSecret:"",pagePath:E.pagePath??""}),Ps(E.appId??""),vr(!1),as(!0)},title:"编辑",children:s.jsx(Kg,{className:"w-3 h-3"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${E.label}」吗?`))try{const B=await Pi(`/api/db/link-tags?tagId=${encodeURIComponent(E.id)}`);B!=null&&B.success?(q.success("已删除"),sa(),Lr()):q.error((B==null?void 0:B.error)??"删除失败")}catch(B){console.error(B),q.error("删除失败")}},title:"删除",children:s.jsx(ns,{className:"w-3 h-3"})})]})})]},E.id))})]})}),s.jsx(xs,{page:Qr,pageSize:Qs,total:Ys,totalPages:ce,onPageChange:E=>Vs(E),onPageSizeChange:E=>{pr(E),Vs(1)}})]})]})]}),s.jsx(Lt,{open:sn,onOpenChange:as,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[s.jsxs(Ot,{className:"gap-1",children:[s.jsx(Dt,{className:"text-base",children:Rr?"编辑链接标签":"添加链接标签"}),s.jsx(Wo,{className:"text-gray-400 text-xs",children:"配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转。小程序类型需填 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(te,{className:"text-gray-300 text-sm",children:"标签ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或自定义短 ID(如 kr),最长 50 字符",value:Tt.tagId,disabled:!!Rr,onChange:E=>Jn(B=>({...B,tagId:E.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"显示文字"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:Tt.label,onChange:E=>Jn(B=>({...B,label:E.target.value}))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"别名(多个用逗号分隔,同指向一个目标)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 团队招募, 团队合伙人",value:Tt.aliases,onChange:E=>Jn(B=>({...B,aliases:E.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(te,{className:"text-gray-300 text-sm",children:"类型"}),s.jsxs(To,{value:Tt.type,onValueChange:E=>Jn(B=>({...B,type:E})),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:s.jsx(Mo,{})}),s.jsxs(Ri,{className:"bg-[#0f2137] border-gray-700 text-white",children:[s.jsx(us,{value:"url",children:"网页链接"}),s.jsx(us,{value:"miniprogram",children:"小程序(API跳转)"}),s.jsx(us,{value:"wxlink",children:"小程序链接(右上角复制)"}),s.jsx(us,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:Tt.type==="url"?"URL地址":Tt.type==="ckb"?"存客宝计划URL":Tt.type==="wxlink"?"小程序链接":"小程序 mpKey / 微信 AppID"}),Tt.type==="wxlink"?s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"粘贴小程序右上角 ... → 复制链接 得到的 URL",value:Tt.url,onChange:E=>Jn(B=>({...B,url:E.target.value}))}):Tt.type==="miniprogram"&&ra.length>0?s.jsxs("div",{ref:Nr,className:"relative",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Ra?br:Tt.appId,onChange:E=>{const B=E.target.value;Ps(B),vr(!0),ra.some(ue=>ue.key===B)||Jn(ue=>({...ue,appId:B}))},onFocus:()=>{Ps(Tt.appId),vr(!0)},onBlur:()=>setTimeout(()=>vr(!1),150)}),Ra&&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:Or.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Or.map(E=>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:B=>{B.preventDefault(),Jn(ue=>({...ue,appId:E.key,pagePath:E.path||""})),Ps(""),vr(!1)},children:[s.jsx("span",{children:E.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:E.key})]},E.key))})]}):s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:Tt.type==="url"?"https://...":Tt.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联配置的 key,或直接填 wx 开头的 AppID",value:Tt.type==="url"||Tt.type==="ckb"?Tt.url:Tt.appId,onChange:E=>{Tt.type==="url"||Tt.type==="ckb"?Jn(B=>({...B,url:E.target.value})):Jn(B=>({...B,appId:E.target.value}))}})]})]}),Tt.type==="wxlink"&&s.jsx("p",{className:"text-[11px] text-amber-400/80 leading-snug px-0.5",children:"操作:打开目标小程序 → 右上角「...」→「复制链接」→ 粘贴到上面。小程序内点击此标签会在 web-view 中打开,微信自动唤起目标小程序,无需修改小程序版本。"}),Tt.type==="miniprogram"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:Tt.pagePath,onChange:E=>Jn(B=>({...B,pagePath:E.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"AppSecret(微信公众平台 · 仅服务端存储)"}),s.jsx(oe,{type:"password",autoComplete:"new-password",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:Rr!=null&&Rr.hasAppSecret?"已保存密钥,留空不改;填写则覆盖":"粘贴目标小程序 AppSecret",value:Tt.appSecret,onChange:E=>Jn(B=>({...B,appSecret:E.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-snug",children:"与 AppID 成对落库;接口响应与小程序配置中均不会返回此字段。"})]})]})]}),s.jsxs(nn,{className:"gap-2 pt-1",children:[s.jsx(G,{variant:"outline",onClick:()=>as(!1),className:"border-gray-600",children:"取消"}),s.jsx(G,{onClick:async()=>{const E={tagId:Tt.tagId.trim(),label:Tt.label.trim(),aliases:Tt.aliases.trim(),url:Tt.url.trim(),type:Tt.type,appId:Tt.appId.trim(),appSecret:Tt.appSecret.trim(),pagePath:Tt.pagePath.trim()};if(E.tagId){const B=E.tagId;if([...B].length>50){q.error("标签ID 最长 50 个字符");return}if(/[#,\n\r\t]/.test(B)){q.error("标签ID 不能含 #、逗号或换行");return}}if(!E.label){q.error("显示文字必填");return}E.type==="miniprogram"&&(E.url=""),E.type==="wxlink"&&(E.appId="",E.pagePath=""),Sa(!0);try{const B=await bt("/api/db/link-tags",E);B!=null&&B.success?(q.success(Rr?"已更新":"已添加"),as(!1),sa(),Lr()):q.error((B==null?void 0:B.error)??"保存失败")}catch(B){console.error(B),q.error("保存失败")}finally{Sa(!1)}},disabled:Xr,className:"bg-amber-500 hover:bg-amber-600 text-white",children:Xr?"保存中...":"保存"})]})]})})]})]}),s.jsx(kV,{open:mn,onOpenChange:Zr,editingPerson:ni,onSubmit:async E=>{var ke;const B={personId:E.personId||E.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:E.name,userId:E.boundUserId,aliases:E.aliases||void 0,label:E.label,ckbApiKey:E.ckbApiKey||void 0,greeting:E.greeting||void 0,tips:E.tips||void 0,remarkType:E.remarkType||void 0,remarkFormat:E.remarkFormat||void 0,addFriendInterval:E.addFriendInterval,startTime:E.startTime||void 0,endTime:E.endTime||void 0,deviceGroups:(ke=E.deviceGroups)!=null&&ke.trim()?E.deviceGroups.split(",").map(Ke=>parseInt(Ke.trim(),10)).filter(Ke=>!Number.isNaN(Ke)):void 0},ue=await bt("/api/db/persons",B);if(ue&&ue.success===!1){const Ke=ue;Ke.ckbResponse&&console.log("存客宝返回",Ke.ckbResponse);const gt=Ke.error||"操作失败";throw new Error(gt)}if(Ns(),q.success(ni?"已保存":"已添加"),ue!=null&&ue.ckbCreateResult&&Object.keys(ue.ckbCreateResult).length>0){const Ke=ue.ckbCreateResult;console.log("存客宝创建结果",Ke);const gt=Ke.planId??Ke.id,at=gt!=null?[`planId: ${gt}`]:[];Ke.apiKey!=null&&at.push("apiKey: ***"),q.info(at.length?`存客宝创建结果:${at.join(",")}`:"存客宝创建结果见控制台")}}}),s.jsx(Lt,{open:!!As,onOpenChange:E=>{E||Ca(null)},children:s.jsxs(It,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(Ot,{className:"gap-1",children:[s.jsx(Dt,{className:"text-white text-base",children:"确认删除"}),s.jsx(Wo,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:As&&s.jsxs(s.Fragment,{children:[As.personSource==="vip_sync"?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["确定删除超级个体「",As.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链接人与事-",As.name,"」?将同时删除存客宝对应获客计划。"]})}),s.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",As.name," 将无法正常跳转。"]})]})})]}),s.jsxs(nn,{className:"gap-2 sm:gap-2 pt-1",children:[s.jsx(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>Ca(null),children:"取消"}),s.jsx(G,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{As&&(await Pi(`/api/db/persons?personId=${As.personId}`),Ca(null),Ns(),q.success("已删除"))},children:"确定删除"})]})]})}),s.jsx(Lt,{open:Zs,onOpenChange:Gi,children:s.jsxs(It,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Kn,{className:"w-5 h-5 text-green-400"}),Ji," — 获客详情(共 ",xr," 条)"]})}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:ol?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):er.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:"时间"})]}),er.map((E,B)=>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:(ea-1)*20+B+1}),s.jsx("span",{className:"text-white truncate",children:E.nickname||E.name||E.userId||"-"}),s.jsx("span",{className:"text-gray-300 text-xs",children:E.phone||"-"}),s.jsx("span",{className:"text-gray-300 text-xs truncate",children:E.wechatId||"-"}),s.jsx("span",{className:"text-xs",children:E.source==="article_mention"?s.jsx("span",{className:"text-purple-400",children:"文章@"}):E.source==="index_lead"?s.jsx("span",{className:"text-blue-400",children:"首页"}):s.jsx("span",{className:"text-gray-500",children:E.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:E.createdAt?new Date(E.createdAt).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"})]},E.id))]})}),xr>20&&s.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[s.jsx(G,{size:"sm",variant:"outline",disabled:ea<=1,onClick:()=>_n(bs,Ji,ea-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:[ea," / ",Math.ceil(xr/20)]}),s.jsx(G,{size:"sm",variant:"outline",disabled:ea>=Math.ceil(xr/20),onClick:()=>_n(bs,Ji,ea+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const Mi={name:"卡若",avatar:"K",avatarImg:"",title:"Soul派对房主理人 · 私域运营专家",bio:'每天早上6点到9点,在Soul派对房分享真实的创业故事。专注私域运营与项目变现,用"云阿米巴"模式帮助创业者构建可持续的商业体系。',stats:[{label:"商业案例",value:"62"},{label:"连续直播",value:"365天"},{label:"派对分享",value:"1000+"}],highlights:["5年私域运营经验","帮助100+品牌从0到1增长","连续创业者,擅长商业模式设计"]};function kj(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&"label"in e&&"value"in e?{label:String(e.label),value:String(e.value)}:{label:"",value:""}).filter(e=>e.label||e.value):Mi.stats}function Sj(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):Mi.highlights}function EV(){const[t,e]=g.useState(Mi),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useRef(null);g.useEffect(()=>{Le("/api/admin/author-settings").then(k=>{const T=k==null?void 0:k.data;T&&typeof T=="object"&&e({name:String(T.name??Mi.name),avatar:String(T.avatar??Mi.avatar),avatarImg:String(T.avatarImg??""),title:String(T.title??Mi.title),bio:String(T.bio??Mi.bio),stats:kj(T.stats).length?kj(T.stats):Mi.stats,highlights:Sj(T.highlights).length?Sj(T.highlights):Mi.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)},T=await bt("/api/admin/author-settings",k);if(!T||T.success===!1){q.error("保存失败: "+(T&&typeof T=="object"&&"error"in T?T.error:""));return}i(!1);const C=document.createElement("div");C.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",C.textContent="作者设置已保存",document.body.appendChild(C),setTimeout(()=>C.remove(),2e3)}catch(k){console.error(k),q.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{i(!1)}},f=async k=>{var C;const T=(C=k.target.files)==null?void 0:C[0];if(T){c(!0);try{const L=new FormData;L.append("file",T),L.append("folder","avatars");const R=Ku(),U={};R&&(U.Authorization=`Bearer ${R}`);const z=await(await fetch(Vl("/api/upload"),{method:"POST",body:L,credentials:"include",headers:U})).json();z!=null&&z.success&&(z!=null&&z.url)?e(O=>({...O,avatarImg:z.url})):q.error("上传失败: "+((z==null?void 0:z.error)||"未知错误"))}catch(L){console.error(L),q.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),x=k=>e(T=>({...T,stats:T.stats.filter((C,L)=>L!==k)})),b=(k,T,C)=>e(L=>({...L,stats:L.stats.map((R,U)=>U===k?{...R,[T]:C}:R)})),N=()=>e(k=>({...k,highlights:[...k.highlights,""]})),w=k=>e(T=>({...T,highlights:T.highlights.filter((C,L)=>L!==k)})),v=(k,T)=>e(C=>({...C,highlights:C.highlights.map((L,R)=>R===k?T: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(Ai,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(G,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(Ai,{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(te,{className:"text-gray-300",children:"姓名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(T=>({...T,name:k.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(T=>({...T,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(rk,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(T=>({...T,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(G,{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(Df,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:ya(t.avatarImg.startsWith("http")?t.avatarImg:Vl(t.avatarImg)),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"头衔"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(T=>({...T,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"个人简介"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(T=>({...T,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsx(ut,{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,T)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:C=>b(T,"label",C.target.value),placeholder:"标签"}),s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:C=>b(T,"value",C.target.value),placeholder:"数值"}),s.jsx(G,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>x(T),children:s.jsx(ns,{className:"w-4 h-4"})})]},T)),s.jsxs(G,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsx(ut,{className:"text-white",children:"亮点标签"}),s.jsx(Qt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(_e,{className:"space-y-3",children:[t.highlights.map((k,T)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:C=>v(T,C.target.value),placeholder:"5年私域运营经验"}),s.jsx(G,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(T),children:s.jsx(ns,{className:"w-4 h-4"})})]},T)),s.jsxs(G,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function TV(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function MV(){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=qa(h,300),[x,b]=g.useState(!0),[N,w]=g.useState(null),[v,k]=g.useState(!1),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState(""),[z,O]=g.useState(""),[Q,re]=g.useState("admin"),[D,ne]=g.useState("active"),[le,me]=g.useState(!1);async function I(){var W;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 Le(`/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?"无权限访问":((W=he==null?void 0:he.data)==null?void 0:W.error)||"加载失败"),e([])}finally{b(!1)}}g.useEffect(()=>{I()},[a,o,m]);const Y=()=>{C(null),R(""),P(""),O(""),re("admin"),ne("active"),k(!0)},F=W=>{C(W),R(W.username),P(""),O(W.name||""),re(W.role==="super_admin"?"super_admin":"admin"),ne(W.status==="disabled"?"disabled":"active"),k(!0)},xe=async()=>{var W;if(!L.trim()){w("用户名不能为空");return}if(!T&&!U){w("新建时密码必填,至少 6 位");return}if(U&&U.length<6){w("密码至少 6 位");return}w(null),me(!0);try{if(T){const fe=await tn("/api/admin/users",{id:T.id,password:U||void 0,name:z.trim(),role:Q,status:D});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}else{const fe=await bt("/api/admin/users",{username:L.trim(),password:U,name:z.trim(),role:Q});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}}catch(fe){const he=fe;w(((W=he==null?void 0:he.data)==null?void 0:W.error)||"保存失败")}finally{me(!1)}},X=async W=>{var fe;if(!TV("管理员")){w("已取消删除");return}try{const he=await Pi(`/api/admin/users?id=${W}`);he!=null&&he.success?I():w((he==null?void 0:he.error)||"删除失败")}catch(he){const de=he;w(((fe=de==null?void 0:de.data)==null?void 0:fe.error)||"删除失败")}},V=W=>{if(!W)return"-";try{const fe=new Date(W);return isNaN(fe.getTime())?W:fe.toLocaleString("zh-CN")}catch{return W}};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Gc,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{placeholder:"搜索用户名/昵称",value:h,onChange:W=>f(W.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(G,{variant:"outline",size:"sm",onClick:I,disabled:x,className:"border-gray-600 text-gray-300",children:s.jsx(Ve,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsxs(G,{onClick:Y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{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(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"用户名"}),s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"角色"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"创建时间"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(W=>s.jsxs(xt,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:W.id}),s.jsx(je,{className:"text-white font-medium",children:W.username}),s.jsx(je,{className:"text-gray-400",children:W.name||"-"}),s.jsx(je,{children:s.jsx(Be,{variant:"outline",className:W.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:W.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(je,{children:s.jsx(Be,{variant:"outline",className:W.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:W.status==="active"?"正常":"已禁用"})}),s.jsx(je,{className:"text-gray-500 text-sm",children:V(W.createdAt)}),s.jsxs(je,{className:"text-right",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>F(W),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>X(W.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(ts,{className:"w-4 h-4"})})]})]},W.id)),t.length===0&&!x&&s.jsx(xt,{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(xs,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),s.jsx(Lt,{open:v,onOpenChange:k,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:T?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"用户名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:L,onChange:W=>R(W.target.value),disabled:!!T}),T&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:T?"新密码(留空不改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:T?"留空表示不修改":"至少 6 位",value:U,onChange:W=>P(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:z,onChange:W=>O(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:Q,onChange:W=>re(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"admin",children:"管理员"}),s.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),T&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:D,onChange:W=>ne(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"active",children:"正常"}),s.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:xe,disabled:le,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),le?"保存中...":"保存"]})]})]})})]})}function In({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(` +—— 以上为正文预览约 {percent}% ,搜「卡若创业派对」小程序阅读全文 ——`,timelineTitleSuffix:"(预览{percent}%)"},null,2);function qc(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 SV(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:qc(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 CV(){var ml,pc,xl;const t=Ya(),[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,T]=g.useState([]),[C,L]=g.useState(!1),[R,U]=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,F]=g.useState(null),[O,Q]=g.useState(!1),[re,D]=g.useState(!1),[ne,le]=g.useState(null),[me,I]=g.useState(!1),[Y,B]=g.useState([]),[xe,X]=g.useState(!1),[V,W]=g.useState(""),[fe,he]=g.useState(""),[de,_]=g.useState(!1),[J,$]=g.useState(""),[Z,ae]=g.useState(!1),[we,Fe]=g.useState(null),[Ue,wt]=g.useState(!1),[jn,pt]=g.useState(!1),[At,fn]=g.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[Vn,pn]=g.useState(!1),[qt,bn]=g.useState(!1),[Mn,Hn]=g.useState(1),[as,_t]=g.useState([]),[vn,Ne]=g.useState(!1),[Me,We]=g.useState([]),[rt,$t]=g.useState(!1),[St,$e]=g.useState(20),[H,Qe]=g.useState(!1),[vt,Ft]=g.useState(!1),[yt,ht]=g.useState(Ig),[Pt,Gt]=g.useState(!1),[kn,Ts]=g.useState(!1),[Ms,Ki]=g.useState([]),[ja,ei]=g.useState([]),[ti,Ar]=g.useState([]),[Pr,Ir]=g.useState(!1),[Qr,Vs]=g.useState(1),[Qs,pr]=g.useState(20),[Ys,ka]=g.useState(0),[ce,ve]=g.useState(1),[Rt,Zt]=g.useState(""),[sn,is]=g.useState(!1),[Rr,Yr]=g.useState(null),[jt,Un]=g.useState({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),[Xr,Sa]=g.useState(!1),[mn,Zr]=g.useState(!1),[ni,mr]=g.useState(null),[As,Ca]=g.useState(null),[qi,Xs]=g.useState({}),[Zs,Gi]=g.useState(!1),[bs,il]=g.useState(""),[Ji,vs]=g.useState(""),[er,tr]=g.useState([]),[xr,si]=g.useState(0),[ea,ac]=g.useState(1),[ol,ri]=g.useState(!1),[Qi,Ea]=g.useState(""),ll=g.useRef(null),Ta=g.useCallback(async(E,z)=>{var gt;const ue=new FormData;ue.append("file",E),ue.append("folder",z);const Ke=await(await fetch(Vl("/api/upload"),{method:"POST",body:ue,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((gt=Ke==null?void 0:Ke.data)==null?void 0:gt.url)||(Ke==null?void 0:Ke.url)||""},[]),Nt=g.useCallback(E=>Ta(E,"book-images"),[Ta]),Yi=g.useCallback(E=>{const z=E.type.startsWith("video/")?"book-videos":"book-attachments";return Ta(E,z)},[Ta]),[cl,ai]=g.useState({}),ii=E=>String(E||"").trim().slice(0,8),ic=g.useMemo(()=>{const E=new Map;return as.forEach((z,ue)=>{E.set(z.id,ue+1)}),E},[as]),Qn=SV(e,ic,cl),Ma=e.length,ta=10,Hs=Math.max(1,Math.ceil(as.length/ta)),Us=as.slice((Mn-1)*ta,Mn*ta),cn=async()=>{a(!0);try{const E=await Le("/api/db/book?action=list",{cache:"no-store"});n(Array.isArray(E==null?void 0:E.sections)?E.sections:[])}catch(E){console.error(E),n([])}finally{a(!1)}},nr=async()=>{try{const E=await Le("/api/db/config?key=book_part_badges",{cache:"no-store"});let z={};if(E&&Array.isArray(E.data)){const ke=E.data.find(Ke=>Ke&&Ke.configKey==="book_part_badges");ke&&ke.configValue&&typeof ke.configValue=="object"&&!Array.isArray(ke.configValue)&&(z=ke.configValue)}else E&&E.data&&typeof E.data=="object"&&!Array.isArray(E.data)&&(z=E.data);const ue={};Object.keys(z).forEach(ke=>{const Ke=ii(z[ke]);Ke&&(ue[ke]=Ke)}),ai(ue)}catch(E){console.error(E),ai({})}},gr=async()=>{Ne(!0);try{const E=await Le("/api/db/book?action=ranking",{cache:"no-store"}),z=Array.isArray(E==null?void 0:E.sections)?E.sections:[];_t(z);const ue=z.filter(ke=>ke.isPinned).map(ke=>ke.id);We(ue)}catch(E){console.error(E),_t([])}finally{Ne(!1)}};g.useEffect(()=>{cn(),gr(),nr()},[]);const yr=E=>{o(z=>z.includes(E)?z.filter(ue=>ue!==E):[...z,E])},oc=g.useCallback(E=>{const z=e,ue=E.flatMap(ke=>{const Ke=z.find(gt=>gt.id===ke.id);return Ke?[{...Ke,partId:ke.partId,partTitle:ke.partTitle,chapterId:ke.chapterId,chapterTitle:ke.chapterTitle}]:[]});return n(ue),tn("/api/db/book",{action:"reorder",items:E}).then(ke=>{ke&&ke.success===!1&&(n(z),q.error("排序失败: "+(ke&&typeof ke=="object"&&"error"in ke?ke.error:"未知错误")))}).catch(ke=>{n(z),console.error("排序失败:",ke),q.error("排序失败: "+(ke instanceof Error?ke.message:"网络或服务异常"))}),Promise.resolve()},[e]),lc=async E=>{if(confirm(`确定要删除章节「${E.title}」吗?此操作不可恢复。`))try{const z=await Pi(`/api/db/book?id=${encodeURIComponent(E.id)}`);z&&z.success!==!1?(q.success("已删除"),cn(),gr()):q.error("删除失败: "+(z&&typeof z=="object"&&"error"in z?z.error:"未知错误"))}catch(z){console.error(z),q.error("删除失败")}},Aa=g.useCallback(async()=>{pn(!0);try{const E=await Le("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),z=E&&E.data;z&&typeof z.readWeight=="number"&&typeof z.recencyWeight=="number"&&typeof z.payWeight=="number"&&fn({readWeight:Math.max(0,Math.min(1,z.readWeight)),recencyWeight:Math.max(0,Math.min(1,z.recencyWeight)),payWeight:Math.max(0,Math.min(1,z.payWeight))})}catch{}finally{pn(!1)}},[]);g.useEffect(()=>{jn&&Aa()},[jn,Aa]);const wd=async()=>{const{readWeight:E,recencyWeight:z,payWeight:ue}=At,ke=E+z+ue;if(Math.abs(ke-1)>.001){q.error("三个权重之和必须等于 1");return}bn(!0);try{const Ke=await bt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:E,recencyWeight:z,payWeight:ue},description:"文章排名算法权重"});Ke&&Ke.success!==!1?(q.success("排名权重已保存"),pt(!1),cn(),gr()):q.error("保存失败: "+(Ke&&typeof Ke=="object"&&"error"in Ke?Ke.error:""))}catch(Ke){console.error(Ke),q.error("保存失败")}finally{bn(!1)}},dl=g.useCallback(async()=>{$t(!0);try{const E=await Le("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),z=E&&E.data;Array.isArray(z)&&We(z)}catch{}finally{$t(!1)}},[]),Ns=g.useCallback(async()=>{try{const E=await Le("/api/db/persons");E!=null&&E.success&&E.persons&&Ki(E.persons.map(z=>{const ue=z.deviceGroups,ke=Array.isArray(ue)?ue.join(","):ue??"";return{id:z.token??z.personId??"",personId:z.personId,name:z.name,personSource:z.personSource??"",userId:z.userId,aliases:z.aliases??"",label:z.label??"",ckbApiKey:z.ckbApiKey??"",ckbPlanId:z.ckbPlanId,remarkType:z.remarkType,remarkFormat:z.remarkFormat,addFriendInterval:z.addFriendInterval,startTime:z.startTime,endTime:z.endTime,deviceGroups:ke,isPinned:!!z.isPinned}}))}catch{}},[]),na=g.useCallback(async(E,z)=>{const ue=(E.personId||E.id||"").trim();if(!ue){q.error("缺少 personId");return}z&&!(E.userId||"").trim()&&q.info("未绑定会员时,小程序仍显示 @ 名称,头像可能为默认图");try{const ke=await tn("/api/db/persons/pin",{personId:ue,isPinned:z});if(!(ke!=null&&ke.success)){q.error((ke==null?void 0:ke.error)||"置顶失败");return}q.success(z?"已设为小程序首页置顶(全局仅一条)":"已取消置顶"),await Ns()}catch(ke){q.error(ke instanceof Error?ke.message:"操作失败")}},[Ns]),sa=g.useCallback(async()=>{try{const E=await Le("/api/db/link-tags");E!=null&&E.success&&E.linkTags&&ei(E.linkTags.map(z=>({id:z.tagId,label:z.label,url:z.url,type:z.type||"url",appId:z.appId||"",pagePath:z.pagePath||"",hasAppSecret:!!z.hasAppSecret})))}catch{}},[]),Pa=g.useCallback(async()=>{try{const E=await Le("/api/db/config/full?key=ckb_lead_webhook_url",{cache:"no-store"});E!=null&&E.success&&typeof E.data=="string"&&Ea(E.data)}catch{}},[]),Ia=g.useCallback(async()=>{try{const E=await Le("/api/db/ckb-person-leads");if(E!=null&&E.success&&E.byPerson){const z={};for(const ue of E.byPerson)z[ue.token]=ue.total;Xs(z)}}catch{}},[]),_n=g.useCallback(async(E,z,ue=1)=>{il(E),vs(z),Gi(!0),ac(ue),ri(!0);try{const ke=await Le(`/api/db/ckb-person-leads?token=${encodeURIComponent(E)}&page=${ue}&pageSize=20`);ke!=null&&ke.success?(tr(ke.records||[]),si(ke.total||0)):q.error((ke==null?void 0:ke.error)||"加载获客详情失败")}catch(ke){q.error(ke instanceof Error?ke.message:"加载获客详情失败")}finally{ri(!1)}},[]),Lr=g.useCallback(async()=>{Ir(!0);try{const E=new URLSearchParams({page:String(Qr),pageSize:String(Qs)}),z=Rt.trim();z&&E.set("search",z);const ue=await Le(`/api/db/link-tags?${E.toString()}`);if(ue!=null&&ue.success){const ke=Array.isArray(ue.linkTags)?ue.linkTags:[];Ar(ke.map(Ke=>({id:Ke.tagId,label:Ke.label,aliases:Ke.aliases||"",url:Ke.url,type:Ke.type||"url",appId:Ke.appId||"",pagePath:Ke.pagePath||"",hasAppSecret:!!Ke.hasAppSecret}))),ka(typeof ue.total=="number"?ue.total:0),ve(typeof ue.totalPages=="number"&&ue.totalPages>0?ue.totalPages:1)}}catch(E){console.error(E),q.error("加载链接标签失败")}finally{Ir(!1)}},[Qr,Qs,Rt]),[ra,oi]=g.useState([]),[br,Ps]=g.useState(""),[Ra,vr]=g.useState(!1),Nr=g.useRef(null),Xi=g.useCallback(async()=>{try{const E=await Le("/api/admin/linked-miniprograms");E!=null&&E.success&&Array.isArray(E.data)&&oi(E.data.map(z=>({...z,key:z.key})))}catch{}},[]),Or=ra.filter(E=>!br.trim()||E.name.toLowerCase().includes(br.toLowerCase())||E.key&&E.key.toLowerCase().includes(br.toLowerCase())||E.appId.toLowerCase().includes(br.toLowerCase())),aa=async E=>{const z=Me.includes(E)?Me.filter(ue=>ue!==E):[...Me,E];We(z);try{await bt("/api/db/config",{key:"pinned_section_ids",value:z,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),gr()}catch{We(Me)}},ia=g.useCallback(async()=>{Qe(!0);try{const E=await Le("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),z=E&&E.data;typeof z=="number"&&z>0&&z<=100&&$e(z)}catch{}finally{Qe(!1)}},[]),li=async()=>{if(St<1||St>100){q.error("预览比例需在 1~100 之间");return}Ft(!0);try{const E=await bt("/api/db/config",{key:"unpaid_preview_percent",value:St,description:"小程序未付费内容默认预览比例(%)"});E&&E.success!==!1?q.success("预览比例已保存"):q.error("保存失败: "+(E.error||""))}catch{q.error("保存失败")}finally{Ft(!1)}},ci=g.useCallback(async()=>{Gt(!0);try{const E=await Le("/api/db/config/full?key=read_preview_ui",{cache:"no-store"}),z=E&&E.data;z!=null&&typeof z=="object"&&!Array.isArray(z)&&Object.keys(z).length>0?ht(JSON.stringify(z,null,2)):ht(Ig)}catch{ht(Ig)}finally{Gt(!1)}},[]),ls=async()=>{let E;try{E=JSON.parse(yt)}catch{q.error("JSON 格式错误,请检查括号与引号");return}Ts(!0);try{const z=await bt("/api/db/config",{key:"read_preview_ui",value:E,description:"阅读页/朋友圈付费墙与分享文案(占位符 {percent} {price})"});z&&z.success!==!1?q.success("阅读页文案已保存"):q.error("保存失败: "+(z.error||""))}catch{q.error("保存失败")}finally{Ts(!1)}};g.useEffect(()=>{dl(),ia(),ci(),Ns(),sa(),Ia(),Xi(),Pa()},[dl,ia,ci,Ns,sa,Ia,Xi,Pa]),g.useEffect(()=>{Lr()},[Lr]);const Dr=async E=>{Fe({section:E,orders:[]}),wt(!0);try{const z=await Le(`/api/db/book?action=section-orders&id=${encodeURIComponent(E.id)}`),ue=z!=null&&z.success&&Array.isArray(z.orders)?z.orders:[];Fe(ke=>ke?{...ke,orders:ue}:null)}catch(z){console.error(z),Fe(ue=>ue?{...ue,orders:[]}:null)}finally{wt(!1)}},di=async E=>{x(!0);try{const z=E.mid!=null&&E.mid>0?`/api/db/book?action=read&mid=${E.mid}`:`/api/db/book?action=read&id=${encodeURIComponent(E.id)}`,ue=await Le(z);if(ue!=null&&ue.success&&ue.section){const ke=ue.section,Ke=ke.editionPremium===!0,gt=qc(ke.previewPercent)??qc(ke.preview_percent),at=qc(E.previewPercent);u({id:E.id,originalId:E.id,title:ue.section.title??E.title,price:ue.section.price??E.price,content:ue.section.content??"",filePath:E.filePath,isFree:E.isFree||E.price===0,isNew:ke.isNew??E.isNew,isPinned:Me.includes(E.id),hotScore:E.hotScore??0,previewPercent:gt??at??void 0,editionStandard:Ke?!1:ke.editionStandard??!0,editionPremium:Ke})}else u({id:E.id,originalId:E.id,title:E.title,price:E.price,content:"",filePath:E.filePath,isFree:E.isFree,isNew:E.isNew,isPinned:Me.includes(E.id),hotScore:E.hotScore??0,previewPercent:qc(E.previewPercent),editionStandard:!0,editionPremium:!1}),ue&&!ue.success&&q.error("无法读取文件内容: "+(ue.error||"未知错误"))}catch(z){console.error(z),u({id:E.id,title:E.title,price:E.price,content:"",filePath:E.filePath,isFree:E.isFree,previewPercent:qc(E.previewPercent)})}finally{x(!1)}},ui=async()=>{var E;if(c){N(!0);try{let z=c.content||"";const ue=[new RegExp(`^#+\\s*${c.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${c.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(E=c.title)==null?void 0:E.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const Yn of ue)z=z.replace(Yn,"");z=z.replace(/^\s*\n+/,"").trim();const ke=c.originalId||c.id,Ke=c.id!==ke,gt={id:ke,...Ke?{newId:c.id}:{},title:c.title,price:c.isFree?0:c.price,content:z,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?gt.previewPercent=null:typeof c.previewPercent=="number"&&Number.isFinite(c.previewPercent)&&(gt.previewPercent=c.previewPercent);const at=await tn("/api/db/book",gt,{timeout:F1}),$n=Ke?c.id:ke;c.isPinned!==Me.includes($n)&&await aa($n),at&&at.success!==!1?(q.success(`已保存:${c.title}`),u(null),cn(),Ns(),sa()):q.error("保存失败: "+(at&&typeof at=="object"&&"error"in at?at.error:"未知错误"))}catch(z){console.error(z);const ue=z instanceof Error&&z.name==="AbortError"?"保存超时,请检查网络或稍后重试":"保存失败";q.error(ue)}finally{N(!1)}}},jd=async()=>{if(!R.id||!R.title){q.error("请填写章节ID和标题");return}N(!0);try{const E=Qn.find(ke=>ke.id===R.partId),z=E==null?void 0:E.chapters.find(ke=>ke.id===R.chapterId),ue=await tn("/api/db/book",{id:R.id,title:R.title,price:R.isFree?0:R.price,content:R.content||"",partId:R.partId,partTitle:(E==null?void 0:E.title)??"",chapterId:R.chapterId,chapterTitle:(z==null?void 0:z.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:F1});if(ue&&ue.success!==!1){if(R.isPinned){const ke=[...Me,R.id];We(ke);try{await bt("/api/db/config",{key:"pinned_section_ids",value:ke,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}q.success(`章节创建成功:${R.title}`),f(!1),U({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),cn(),Ns(),sa()}else q.error("创建失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(E){console.error(E),q.error("创建失败")}finally{N(!1)}},ul=E=>{U(z=>{var ue;return{...z,partId:E.id,chapterId:((ue=E.chapters[0])==null?void 0:ue.id)??"chapter-1"}}),f(!0)},hl=E=>{F({id:E.id,title:E.title,badgeText:ii(E.badgeText)})},hi=async()=>{var E;if((E=P==null?void 0:P.title)!=null&&E.trim()){Q(!0);try{const z=e.map(ke=>({id:ke.id,partId:ke.partId||"part-1",partTitle:ke.partId===P.id?P.title.trim():ke.partTitle||"",chapterId:ke.chapterId||"chapter-1",chapterTitle:ke.chapterTitle||""})),ue=await tn("/api/db/book",{action:"reorder",items:z});if(ue&&ue.success!==!1){const ke=P.title.trim(),Ke={...cl},gt=ii(P.badgeText);gt?Ke[P.id]=gt:delete Ke[P.id];const at=await bt("/api/db/config",{key:"book_part_badges",value:Ke,description:"目录篇名角标(key=part_id, value=角标文案)"});if(at&&at.success===!1){q.error("更新篇名角标失败: "+(at.error||"未知错误"));return}ai(Ke),n($n=>$n.map(Yn=>Yn.partId===P.id?{...Yn,partTitle:ke}:Yn)),F(null),cn()}else q.error("更新篇名失败: "+(ue&&typeof ue=="object"&&"error"in ue?ue.error:"未知错误"))}catch(z){console.error(z),q.error("更新篇名失败")}finally{Q(!1)}}},oa=E=>{const z=E.chapters.length+1,ue=`chapter-${E.id}-${z}-${Date.now()}`;U({id:`${z}.1`,title:"新章节",price:1,partId:E.id,chapterId:ue,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),f(!0)},La=(E,z)=>{const ue=z.sections;let ke=1,Ke=!1,gt=!1;if(ue.length>0){const at=typeof ue[0].price=="number"?ue[0].price:Number(ue[0].price)||1,$n=!!(ue[0].isFree||at===0);gt=ue.some(Yn=>{const Sn=typeof Yn.price=="number"?Yn.price:Number(Yn.price)||1,sr=!!(Yn.isFree||Sn===0);return Sn!==at||sr!==$n}),ke=$n?0:at,Ke=$n}le({part:E,chapter:z,title:z.title,price:ke,isFree:Ke,priceMixed:gt,initialTitle:z.title,initialPrice:ke,initialIsFree:Ke})},fl=async()=>{var Ke;if(!((Ke=ne==null?void 0:ne.title)!=null&&Ke.trim()))return;const E=ne,z=E.title.trim(),ue=z!==E.initialTitle,ke=E.isFree!==E.initialIsFree||!E.isFree&&Number(E.price)!==Number(E.initialPrice);if(!ue&&!ke){q.info("未修改任何内容"),le(null);return}if(E.priceMixed&&ke){const gt=E.chapter.sections.length,at=E.isFree?"全部设为免费":`全部设为 ¥${E.price}`;if(!confirm(`本章 ${gt} 节当前定价不一致,保存后将${at},确定?`))return}I(!0);try{if(ue){const gt=e.map(Sn=>({id:Sn.id,partId:Sn.partId||E.part.id,partTitle:Sn.partId===E.part.id?E.part.title:Sn.partTitle||"",chapterId:Sn.chapterId||E.chapter.id,chapterTitle:Sn.partId===E.part.id&&Sn.chapterId===E.chapter.id?z:Sn.chapterTitle||""})),at=await tn("/api/db/book",{action:"reorder",items:gt});if(at&&at.success===!1){q.error("保存章节名失败: "+(at&&typeof at=="object"&&"error"in at?at.error:"未知错误"));return}const $n=E.part.id,Yn=E.chapter.id;n(Sn=>Sn.map(sr=>sr.partId===$n&&sr.chapterId===Yn?{...sr,chapterTitle:z}:sr))}if(ke){const gt=await tn("/api/db/book",{action:"update-chapter-pricing",partId:E.part.id,chapterId:E.chapter.id,price:E.isFree?0:Number(E.price)||0,isFree:E.isFree});if(gt&>.success===!1){q.error("保存定价失败: "+(gt&&typeof gt=="object"&&"error"in gt?gt.error:"未知错误")),ue&&cn();return}}le(null),cn(),q.success("已保存")}catch(gt){console.error(gt),q.error("保存失败")}finally{I(!1)}},cc=async(E,z)=>{const ue=z.sections.map(ke=>ke.id);if(ue.length===0){q.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${E.chapters.indexOf(z)+1}章 | ${z.title}」吗?将删除共 ${ue.length} 节,此操作不可恢复。`))try{for(const ke of ue)await Pi(`/api/db/book?id=${encodeURIComponent(ke)}`);cn()}catch(ke){console.error(ke),q.error("删除失败")}},dc=async()=>{if(!J.trim()){q.error("请输入篇名");return}ae(!0);try{const E=`part-new-${Date.now()}`,z="chapter-1",ue=`part-placeholder-${Date.now()}`,ke=await tn("/api/db/book",{id:ue,title:"占位节(可编辑)",price:0,content:"",partId:E,partTitle:J.trim(),chapterId:z,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ke&&ke.success!==!1?(q.success(`篇「${J}」创建成功`),D(!1),$(""),cn()):q.error("创建失败: "+(ke&&typeof ke=="object"&&"error"in ke?ke.error:"未知错误"))}catch(E){console.error(E),q.error("创建失败")}finally{ae(!1)}},Zi=async()=>{if(Y.length===0){q.error("请先勾选要移动的章节");return}const E=Qn.find(ue=>ue.id===V),z=E==null?void 0:E.chapters.find(ue=>ue.id===fe);if(!E||!z||!V||!fe){q.error("请选择目标篇和章");return}_(!0);try{const ue=()=>{const at=new Set(Y),$n=e.map(Wn=>({id:Wn.id,partId:Wn.partId||"",partTitle:Wn.partTitle||"",chapterId:Wn.chapterId||"",chapterTitle:Wn.chapterTitle||""})),Yn=$n.filter(Wn=>at.has(Wn.id)).map(Wn=>({...Wn,partId:V,partTitle:E.title||V,chapterId:fe,chapterTitle:z.title||fe})),Sn=$n.filter(Wn=>!at.has(Wn.id));let sr=Sn.length;for(let Wn=Sn.length-1;Wn>=0;Wn-=1){const mc=Sn[Wn];if(mc.partId===V&&mc.chapterId===fe){sr=Wn+1;break}}return[...Sn.slice(0,sr),...Yn,...Sn.slice(sr)]},ke=async()=>{const at=ue(),$n=await tn("/api/db/book",{action:"reorder",items:at});return $n&&$n.success!==!1?(q.success(`已移动 ${Y.length} 节到「${E.title}」-「${z.title}」`),X(!1),B([]),await cn(),!0):!1},Ke={action:"move-sections",sectionIds:Y,targetPartId:V,targetChapterId:fe,targetPartTitle:E.title||V,targetChapterTitle:z.title||fe},gt=await tn("/api/db/book",Ke);if(gt&>.success!==!1)q.success(`已移动 ${gt.count??Y.length} 节到「${E.title}」-「${z.title}」`),X(!1),B([]),await cn();else{const at=gt&&typeof gt=="object"&&"error"in gt?gt.error||"":"未知错误";if((at.includes("缺少 id")||at.includes("无效的 action"))&&await ke())return;q.error("移动失败: "+at)}}catch(ue){console.error(ue),q.error("移动失败: "+(ue instanceof Error?ue.message:"网络或服务异常"))}finally{_(!1)}},uc=E=>{B(z=>z.includes(E)?z.filter(ue=>ue!==E):[...z,E])},kd=async E=>{const z=e.filter(ue=>ue.partId===E.id).map(ue=>ue.id);if(z.length===0){q.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${E.title}」整篇吗?将删除共 ${z.length} 节内容,此操作不可恢复。`))try{for(const ue of z)await Pi(`/api/db/book?id=${encodeURIComponent(ue)}`);cn()}catch(ue){console.error(ue),q.error("删除失败")}},hc=async()=>{var E;if(w.trim()){L(!0);try{const z=await Le(`/api/search?q=${encodeURIComponent(w)}`);z!=null&&z.success&&((E=z.data)!=null&&E.results)?T(z.data.results):(T([]),z&&!z.success&&q.error("搜索失败: "+z.error))}catch(z){console.error(z),T([]),q.error("搜索失败")}finally{L(!1)}}},pl=Qn.find(E=>E.id===R.partId),fc=(pl==null?void 0:pl.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:["共 ",Qn.length," 篇 · ",Ma," 节内容"]})]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(G,{onClick:()=>pt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Qh,{className:"w-4 h-4 mr-2"}),"排名算法"]})})]}),s.jsx(Lt,{open:h,onOpenChange:f,children:s.jsxs(It,{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(Ot,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节ID *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:R.id,onChange:E=>U({...R,id:E.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:R.isFree?0:R.price,onChange:E=>U({...R,price:Number(E.target.value),isFree:Number(E.target.value)===0}),disabled:R.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:R.isFree,onChange:E=>U({...R,isFree:E.target.checked,price:E.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:R.isNew,onChange:E=>U({...R,isNew:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:R.isPinned,onChange:E=>U({...R,isPinned:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:R.editionPremium!==!0,onChange:()=>U({...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:()=>U({...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(te,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:R.hotScore??0,onChange:E=>U({...R,hotScore:Math.max(0,parseFloat(E.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:R.title,onChange:E=>U({...R,title:E.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"所属篇"}),s.jsxs(To,{value:R.partId,onValueChange:E=>{var ue;const z=Qn.find(ke=>ke.id===E);U({...R,partId:E,chapterId:((ue=z==null?void 0:z.chapters[0])==null?void 0:ue.id)??"chapter-1"})},children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{})}),s.jsxs(Ri,{className:"bg-[#0f2137] border-gray-700",children:[Qn.map(E=>s.jsx(ts,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id)),Qn.length===0&&s.jsx(ts,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"所属章"}),s.jsxs(To,{value:R.chapterId,onValueChange:E=>U({...R,chapterId:E}),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{})}),s.jsxs(Ri,{className:"bg-[#0f2137] border-gray-700",children:[fc.map(E=>s.jsx(ts,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id)),fc.length===0&&s.jsx(ts,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx($0,{content:R.content||"",onChange:E=>U({...R,content:E}),onImageUpload:Nt,onMediaUpload:Yi,persons:Ms,linkTags:ja,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(nn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(G,{variant:"outline",onClick:()=>f(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:jd,disabled:b||!R.id||!R.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Lt,{open:!!P,onOpenChange:E=>!E&&F(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{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(te,{className:"text-gray-300",children:"篇名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.title,onChange:E=>F({...P,title:E.target.value}),placeholder:"输入篇名"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"左侧图标文字(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:P.badgeText||"",onChange:E=>F({...P,badgeText:ii(E.target.value)}),placeholder:"例如:派 / 新 / 热",maxLength:8}),s.jsx("p",{className:"text-xs text-gray-500",children:"保存后会同步到目录左侧图标文字(小程序与管理端目录树)。"})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>F(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:hi,disabled:O||!((ml=P==null?void 0:P.title)!=null&&ml.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:O?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Lt,{open:!!ne,onOpenChange:E=>!E&&le(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsxs(Ot,{children:[s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}),"章节设置"]}),s.jsx("p",{className:"text-gray-400 text-sm font-normal pt-1",children:"修改本章显示名称,或为本章下全部节设置统一金额(仍可在单节编辑里单独改某一节)。"})]}),ne&&s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:ne.title,onChange:E=>le({...ne,title:E.target.value}),placeholder:"输入章节名称"})]}),s.jsxs("div",{className:"space-y-2 border-t border-gray-700/60 pt-4",children:[s.jsxs(te,{className:"text-gray-300",children:["本章统一定价(应用于本章全部 ",ne.chapter.sections.length," 节)"]}),ne.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(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:ne.isFree?0:ne.price,onChange:E=>le({...ne,price:Number(E.target.value),isFree:Number(E.target.value)===0}),disabled:ne.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:ne.isFree||ne.price===0,onChange:E=>le({...ne,isFree:E.target.checked,price:E.target.checked?0:ne.initialPrice>0?ne.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(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>le(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:fl,disabled:me||!((pc=ne==null?void 0:ne.title)!=null&&pc.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:me?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Lt,{open:xe,onOpenChange:E=>{var z;if(X(E),E&&Qn.length>0){const ue=Qn[0];W(ue.id),he(((z=ue.chapters[0])==null?void 0:z.id)??"")}},children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsx(Dt,{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:Y.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目标篇"}),s.jsxs(To,{value:V,onValueChange:E=>{var ue;W(E);const z=Qn.find(ke=>ke.id===E);he(((ue=z==null?void 0:z.chapters[0])==null?void 0:ue.id)??"")},children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{placeholder:"选择篇"})}),s.jsx(Ri,{className:"bg-[#0f2137] border-gray-700",children:Qn.map(E=>s.jsx(ts,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目标章"}),s.jsxs(To,{value:fe,onValueChange:he,children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(Mo,{placeholder:"选择章"})}),s.jsx(Ri,{className:"bg-[#0f2137] border-gray-700",children:(((xl=Qn.find(E=>E.id===V))==null?void 0:xl.chapters)??[]).map(E=>s.jsx(ts,{value:E.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:E.title},E.id))})]})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>X(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:Zi,disabled:de||Y.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:de?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Lt,{open:!!we,onOpenChange:E=>!E&&Fe(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{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(Ve,{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(E=>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:`查看订单 ${E.orderSn}`,onClick:()=>window.open(`/orders?search=${E.orderSn??E.id??""}`,"_blank"),children:E.orderSn?E.orderSn.length>16?E.orderSn.slice(0,8)+"..."+E.orderSn.slice(-6):E.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:`查看用户 ${E.userId??E.openId??""}`,onClick:()=>window.open(`/users?search=${E.userId??E.openId??""}`,"_blank"),children:(()=>{const z=E.userId??E.openId??"-";return z.length>12?z.slice(0,6)+"..."+z.slice(-4):z})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",E.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:E.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:E.payTime??E.createdAt??"-"})]},E.id??E.orderSn??""))})]}):null})]})}),s.jsx(Lt,{open:jn,onOpenChange:pt,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Qh,{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)"}),Vn?s.jsx("p",{className:"text-gray-500",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.readWeight,onChange:E=>fn(z=>({...z,readWeight:Math.max(0,Math.min(1,parseFloat(E.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.recencyWeight,onChange:E=>fn(z=>({...z,recencyWeight:Math.max(0,Math.min(1,parseFloat(E.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:At.payWeight,onChange:E=>fn(z=>({...z,payWeight:Math.max(0,Math.min(1,parseFloat(E.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(At.readWeight+At.recencyWeight+At.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(G,{onClick:wd,disabled:qt||Math.abs(At.readWeight+At.recencyWeight+At.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:qt?"保存中...":"保存权重"})]})]})]})}),s.jsx(Lt,{open:re,onOpenChange:D,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:J,onChange:E=>$(E.target.value),placeholder:"输入篇名"})]})}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>{D(!1),$("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(G,{onClick:dc,disabled:Z||!J.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:Z?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Lt,{open:!!c,onOpenChange:()=>u(null),children:s.jsxs(It,{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(Ot,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(an,{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(te,{className:"text-gray-300",children:"章节ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.id,onChange:E=>u({...c,id:E.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:c.isFree?0:c.price,onChange:E=>u({...c,price:Number(E.target.value),isFree:Number(E.target.value)===0}),disabled:c.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:c.isFree||c.price===0,onChange:E=>u({...c,isFree:E.target.checked,price:E.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"预览%"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",placeholder:`全局 ${St}%`,value:c.previewPercent!=null?String(c.previewPercent):"",onChange:E=>{const z=E.target.value.trim();if(z===""){u({...c,previewPercent:null});return}const ue=Number(z);Number.isFinite(ue)&&u({...c,previewPercent:Math.min(100,Math.max(1,Math.round(ue)))})}})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:c.isNew??!1,onChange:E=>u({...c,isNew:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:c.isPinned??!1,onChange:E=>u({...c,isPinned:E.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"edition-type",checked: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(te,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:c.hotScore??0,onChange:E=>u({...c,hotScore:Math.max(0,parseFloat(E.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"章节标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:c.title,onChange:E=>u({...c,title:E.target.value})})]}),c.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文件路径"}),s.jsx(oe,{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(te,{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(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx($0,{ref:ll,content:c.content||"",onChange:E=>u({...c,content:E}),onImageUpload:Nt,onMediaUpload:Yi,persons:Ms,linkTags:ja,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(nn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[c&&s.jsxs(G,{variant:"outline",onClick:()=>Dr({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(ur,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(G,{variant:"outline",onClick:()=>u(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(G,{onClick:ui,disabled:b,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:b?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(Wl,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Ko,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Ut,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(ur,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(Ut,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(qg,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(Ut,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(Ut,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),"@列表"]}),s.jsxs(Ut,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(D1,{className:"w-4 h-4 mr-2"}),"链接标签"]})]}),s.jsxs(Wt,{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(ur,{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:Ma}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(G,{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(Rn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(G,{onClick:()=>D(!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(Rn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(G,{variant:"outline",onClick:()=>X(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",Y.length," 节)"]})]}),r?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ve,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(xV,{parts:Qn,expandedParts:i,onTogglePart:yr,onReorder:oc,onReadSection:di,onDeleteSection:lc,onAddSectionInPart:ul,onAddChapterInPart:oa,onDeleteChapter:cc,onEditPart:hl,onDeletePart:kd,onEditChapter:La,selectedSectionIds:Y,onToggleSectionSelect:uc,onShowSectionOrders:Dr,pinnedSectionIds:Me})]}),s.jsx(Wt,{value:"search",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{children:s.jsx(ut,{className:"text-white",children:"内容搜索"})}),s.jsxs(_e,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:w,onChange:E=>v(E.target.value),onKeyDown:E=>E.key==="Enter"&&hc()}),s.jsx(G,{onClick:hc,disabled:C||!w.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?s.jsx(Ve,{className:"w-4 h-4 animate-spin"}):s.jsx(hr,{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(E=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>{const z=e.find(ue=>ue.id===E.id);di({id:E.id,mid:E.mid,title:E.title,price:E.price??1,filePath:"",previewPercent:z==null?void 0:z.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:E.id}),s.jsx("span",{className:"text-white",children:E.title}),Me.includes(E.id)&&s.jsx(Jc,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Be,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:E.matchType==="title"?"标题匹配":"内容匹配"})]}),E.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:E.snippet}),(E.partTitle||E.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[E.partTitle," · ",E.chapterTitle]})]},E.id))]})]})]})}),s.jsxs(Wt,{value:"ranking",className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{className:"pb-3",children:s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Qh,{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(te,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(oe,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:St,onChange:E=>$e(Math.max(1,Math.min(100,Number(E.target.value)||20))),disabled:H}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(G,{size:"sm",onClick:li,disabled:vt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:vt?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",St,"% 内容;章节「预览%」可单独覆盖"]})]}),s.jsxs("div",{className:"mt-6 space-y-2",children:[s.jsx(te,{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(el,{className:"bg-[#0a1628] border-gray-700 text-gray-200 font-mono text-xs min-h-[280px]",value:yt,onChange:E=>ht(E.target.value),disabled:Pt,spellCheck:!1}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(G,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>ci(),disabled:Pt,children:"重新加载"}),s.jsx(G,{type:"button",size:"sm",onClick:ls,disabled:kn||Pt,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:kn?"保存中...":"保存文案配置"})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(dt,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(qg,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",as.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>gr(),disabled:vn,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Ve,{className:`w-4 h-4 ${vn?"animate-spin":""}`})}),s.jsx(G,{variant:"ghost",size:"sm",disabled:Mn<=1||vn,onClick:()=>Hn(E=>Math.max(1,E-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(TT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[Mn," / ",Hs]}),s.jsx(G,{variant:"ghost",size:"sm",disabled:Mn>=Hs||vn,onClick:()=>Hn(E=>Math.min(Hs,E+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(Li,{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:"编辑"})]}),Us.map((E,z)=>{const ue=(Mn-1)*ta+z+1,ke=E.isPinned??Me.includes(E.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 ${ke?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${ue<=3?"text-amber-400":"text-gray-500"}`,children:ue<=3?["🥇","🥈","🥉"][ue-1]:`#${ue}`}),s.jsx(G,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ke?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>aa(E.id),disabled:rt,title:ke?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ke?s.jsx(Jc,{className:"w-3.5 h-3.5 fill-current"}):s.jsx($1,{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:E.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[E.partTitle," · ",E.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:E.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:E.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(E.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(G,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>di({id:E.id,mid:E.mid,title:E.title,price:E.price,filePath:"",previewPercent:E.previewPercent}),title:"编辑文章",children:s.jsx(an,{className:"w-3 h-3"})})})]},E.id)}),Us.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(Wt,{value:"link-person",className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{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.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(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50",onClick:()=>{Ns()},title:"刷新",children:s.jsx(Ve,{className:"w-4 h-4"})}),s.jsxs(G,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{mr(null),Zr(!0)},children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"添加"]})]})]}),s.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:Ms.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-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:Ms.map(E=>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:E.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:()=>{qi[E.id]&&_n(E.id,E.name)},title:qi[E.id]?"点击查看获客详情":E.name,children:E.name})}),s.jsx("td",{className:"py-2 px-3",children:E.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:E.userId?s.jsxs("div",{className:"flex flex-col gap-0.5 items-start max-w-[100px]",children:[E.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: ${E.userId}`,onClick:()=>t(`/users?search=${encodeURIComponent(E.userId||"")}`),children:E.name})]}):s.jsx("span",{className:"text-gray-600",children:"—"})}),(()=>{const z=qi[E.id]||0;return s.jsx("td",{className:`py-2 px-3 shrink-0 w-16 text-center text-xs font-bold cursor-pointer ${z>0?"text-green-400 hover:text-green-300 hover:underline":"text-gray-600"}`,title:z>0?"点击查看获客详情":"暂无获客",onClick:()=>{z>0&&_n(E.id,E.name)},children:z})})(),s.jsx("td",{className:"py-2 px-3 text-white truncate max-w-[220px]",title:`planId: ${E.ckbPlanId??"-"}`,children:s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"truncate",children:E.ckbPlanId?E.personSource==="vip_sync"?"超级个体拉群(统一计划)":`SOUL链接人与事-${E.name}`:"—"})})}),s.jsx("td",{className:"py-2 px-2 text-center",children:s.jsx(G,{type:"button",variant:"ghost",size:"sm",className:E.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:E.isPinned?"取消小程序首页置顶":"设为小程序首页置顶(全局唯一)",onClick:()=>void na(E,!E.isPinned),children:s.jsx($1,{className:`w-3.5 h-3.5 ${E.isPinned?"fill-amber-400":""}`})})}),s.jsx("td",{className:"py-2 px-3 text-center",children:E.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(G,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const z=await yV(E.personId||"");if(z!=null&&z.success&&z.person){const ue=z.person;mr({id:ue.token??ue.personId,personId:ue.personId,name:ue.name,personSource:ue.personSource??"",userId:ue.userId??"",label:ue.label??"",ckbApiKey:ue.ckbApiKey??"",remarkType:ue.remarkType,remarkFormat:ue.remarkFormat,addFriendInterval:ue.addFriendInterval,startTime:ue.startTime,endTime:ue.endTime,deviceGroups:ue.deviceGroups})}else mr(E),z!=null&&z.error&&q.error(z.error)}catch(z){console.error(z),mr(E),q.error(z instanceof Error?z.message:"加载人物详情失败")}Zr(!0)},children:s.jsx(Kg,{className:"w-3 h-3"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-green-400 h-6 px-2",title:"查看新客户",onClick:()=>_n(E.id,E.name),children:s.jsx(qn,{className:"w-3 h-3"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:E.personSource==="vip_sync"?"删除本地 @人物(不删统一获客计划)":"删除(同时删除存客宝对应获客计划)",onClick:()=>Ca(E),children:s.jsx(ss,{className:"w-3 h-3"})})]})})]},E.id))})]}):s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(vA,{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(te,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",s.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Qh,{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(te,{className:"text-gray-400 text-xs",children:"Webhook URL"}),s.jsx(oe,{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:Qi,onChange:E=>Ea(E.target.value)})]}),s.jsxs(G,{size:"sm",className:"bg-blue-500 hover:bg-blue-600 text-white h-8",onClick:async()=>{const E=Qi.trim();try{const z=await bt("/api/db/config",{key:"ckb_lead_webhook_url",value:E,description:"获客线索 Webhook 通知 URL(企微/飞书)"});z!=null&&z.success?q.success(E?"Webhook 已保存":"Webhook 已清除"):q.error((z==null?void 0:z.error)??"保存失败")}catch{q.error("保存失败")}},children:[s.jsx(Tn,{className:"w-3.5 h-3.5 mr-1"}),"保存"]})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"配置企业微信或飞书群机器人 Webhook URL,获客成功后自动推送通知"})]})]})]}),s.jsxs(Wt,{value:"link-tag",className:"space-y-4",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsxs(ut,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(D1,{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(te,{className:"text-gray-400 text-xs",children:"搜索"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-48",placeholder:"按标签ID/显示文字搜索",value:Rt,onChange:E=>{Zt(E.target.value),Vs(1)}})]}),s.jsx(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 hover:bg-gray-700/50 h-8",onClick:()=>{sa(),Lr()},title:"刷新",children:s.jsx(Ve,{className:"w-4 h-4"})})]}),s.jsxs(G,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:()=>{Yr(null),Un({tagId:"",label:"",aliases:"",url:"",type:"url",appId:"",appSecret:"",pagePath:""}),Ps(""),vr(!1),is(!0)},children:[s.jsx(Rn,{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:Pr?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"加载中..."})}):ti.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})}):ti.map(E=>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:()=>{Yr(E),Un({tagId:E.id,label:E.label,aliases:E.aliases??"",url:E.url,type:E.type,appId:E.appId??"",appSecret:"",pagePath:E.pagePath??""}),Ps(E.appId??""),vr(!1),is(!0)},title:"点击编辑标签",children:["#",E.label]})}),s.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs truncate max-w-[120px]",title:E.aliases||"",children:E.aliases||"—"}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Be,{variant:"secondary",className:`text-[10px] ${E.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":E.type==="internal"?"bg-sky-500/20 text-sky-200 border-sky-500/30":E.type==="miniprogram"||E.type==="wxlink"?"bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30":"bg-gray-700 text-gray-300"}`,children:E.type==="url"?"网页":E.type==="internal"?"本小程序":E.type==="ckb"?"存客宝":E.type==="wxlink"?"小程序链接":"小程序"})}),s.jsx("td",{className:"px-3 py-2 text-gray-300",children:E.type==="internal"?s.jsx("div",{className:"text-xs font-mono text-sky-300 truncate max-w-[420px]",title:E.pagePath||"",children:E.pagePath||"—"}):E.type==="miniprogram"?s.jsxs("div",{className:"space-y-0.5",children:[(()=>{const z=ra.find(ue=>ue.key===E.appId);return s.jsxs(s.Fragment,{children:[z&&s.jsx("div",{className:"text-xs text-white",children:z.name}),s.jsxs("div",{className:"text-xs font-mono text-[#38bdac]",children:["AppID: ",(z==null?void 0:z.appId)||E.appId||"—"]})]})})(),E.pagePath&&s.jsx("div",{className:"text-xs text-gray-500 font-mono",children:E.pagePath}),s.jsxs("div",{className:`text-xs ${E.hasAppSecret?"text-emerald-400/90":"text-amber-500/80"}`,children:["AppSecret:",E.hasAppSecret?"已保存(仅服务端)":"未配置"]})]}):E.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:E.url,children:E.url||"—"}),s.jsx("div",{className:"text-[11px] text-gray-500",children:"小程序内点击 → web-view 打开 → 自动唤起目标小程序"})]}):E.url?s.jsxs("a",{href:E.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[420px] hover:underline inline-flex items-center gap-1",children:[E.url," ",s.jsx(Vo,{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(G,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-7 px-2",onClick:()=>{Yr(E),Un({tagId:E.id,label:E.label,aliases:E.aliases??"",url:E.url,type:E.type,appId:E.appId??"",appSecret:"",pagePath:E.pagePath??""}),Ps(E.appId??""),vr(!1),is(!0)},title:"编辑",children:s.jsx(Kg,{className:"w-3 h-3"})}),s.jsx(G,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-7 px-2",onClick:async()=>{if(confirm(`确定要删除「#${E.label}」吗?`))try{const z=await Pi(`/api/db/link-tags?tagId=${encodeURIComponent(E.id)}`);z!=null&&z.success?(q.success("已删除"),sa(),Lr()):q.error((z==null?void 0:z.error)??"删除失败")}catch(z){console.error(z),q.error("删除失败")}},title:"删除",children:s.jsx(ss,{className:"w-3 h-3"})})]})})]},E.id))})]})}),s.jsx(xs,{page:Qr,pageSize:Qs,total:Ys,totalPages:ce,onPageChange:E=>Vs(E),onPageSizeChange:E=>{pr(E),Vs(1)}})]})]})]}),s.jsx(Lt,{open:sn,onOpenChange:is,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg p-4 gap-3",children:[s.jsxs(Ot,{className:"gap-1",children:[s.jsx(Dt,{className:"text-base",children:Rr?"编辑链接标签":"添加链接标签"}),s.jsx(Wo,{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(te,{className:"text-gray-300 text-sm",children:"标签ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"留空自动生成;或自定义短 ID(如 kr),最长 50 字符",value:jt.tagId,disabled:!!Rr,onChange:E=>Un(z=>({...z,tagId:E.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"显示文字"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 神仙团队",value:jt.label,onChange:E=>Un(z=>({...z,label:E.target.value}))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"别名(多个用逗号分隔,同指向一个目标)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"如 团队招募, 团队合伙人",value:jt.aliases,onChange:E=>Un(z=>({...z,aliases:E.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(te,{className:"text-gray-300 text-sm",children:"类型"}),s.jsxs(To,{value:jt.type,onValueChange:E=>Un(z=>({...z,type:E})),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-700 text-white h-8",children:s.jsx(Mo,{})}),s.jsxs(Ri,{className:"bg-[#0f2137] border-gray-700 text-white",children:[s.jsx(ts,{value:"url",children:"网页链接"}),s.jsx(ts,{value:"internal",children:"本小程序页面"}),s.jsx(ts,{value:"miniprogram",children:"小程序(API跳转)"}),s.jsx(ts,{value:"wxlink",children:"小程序链接(右上角复制)"}),s.jsx(ts,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:jt.type==="url"?"URL地址":jt.type==="ckb"?"存客宝计划URL":jt.type==="wxlink"?"小程序链接":jt.type==="internal"?"页面路径":"小程序 mpKey / 微信 AppID"}),jt.type==="internal"?s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"/pages/index/index 或带参数 ?id=1",value:jt.pagePath,onChange:E=>Un(z=>({...z,pagePath:E.target.value}))}):jt.type==="wxlink"?s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"粘贴小程序右上角 ... → 复制链接 得到的 URL",value:jt.url,onChange:E=>Un(z=>({...z,url:E.target.value}))}):jt.type==="miniprogram"&&ra.length>0?s.jsxs("div",{ref:Nr,className:"relative",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"搜索名称或密钥",value:Ra?br:jt.appId,onChange:E=>{const z=E.target.value;Ps(z),vr(!0),ra.some(ue=>ue.key===z)||Un(ue=>({...ue,appId:z}))},onFocus:()=>{Ps(jt.appId),vr(!0)},onBlur:()=>setTimeout(()=>vr(!1),150)}),Ra&&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:Or.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Or.map(E=>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:z=>{z.preventDefault(),Un(ue=>({...ue,appId:E.key,pagePath:E.path||""})),Ps(""),vr(!1)},children:[s.jsx("span",{children:E.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:E.key})]},E.key))})]}):s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:jt.type==="url"?"https://...":jt.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联配置的 key,或直接填 wx 开头的 AppID",value:jt.type==="url"||jt.type==="ckb"?jt.url:jt.appId,onChange:E=>{jt.type==="url"||jt.type==="ckb"?Un(z=>({...z,url:E.target.value})):Un(z=>({...z,appId:E.target.value}))}})]})]}),jt.type==="wxlink"&&s.jsx("p",{className:"text-[11px] text-amber-400/80 leading-snug px-0.5",children:"操作:打开目标小程序 → 右上角「...」→「复制链接」→ 粘贴到上面。小程序内点击此标签会在 web-view 中打开,微信自动唤起目标小程序,无需修改小程序版本。"}),jt.type==="miniprogram"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"页面路径(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:"pages/index/index",value:jt.pagePath,onChange:E=>Un(z=>({...z,pagePath:E.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-300 text-sm",children:"AppSecret(微信公众平台 · 仅服务端存储)"}),s.jsx(oe,{type:"password",autoComplete:"new-password",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm font-mono",placeholder:Rr!=null&&Rr.hasAppSecret?"已保存密钥,留空不改;填写则覆盖":"粘贴目标小程序 AppSecret",value:jt.appSecret,onChange:E=>Un(z=>({...z,appSecret:E.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-snug",children:"与 AppID 成对落库;接口响应与小程序配置中均不会返回此字段。"})]})]})]}),s.jsxs(nn,{className:"gap-2 pt-1",children:[s.jsx(G,{variant:"outline",onClick:()=>is(!1),className:"border-gray-600",children:"取消"}),s.jsx(G,{onClick:async()=>{const E={tagId:jt.tagId.trim(),label:jt.label.trim(),aliases:jt.aliases.trim(),url:jt.url.trim(),type:jt.type,appId:jt.appId.trim(),appSecret:jt.appSecret.trim(),pagePath:jt.pagePath.trim()};if(E.tagId){const z=E.tagId;if([...z].length>50){q.error("标签ID 最长 50 个字符");return}if(/[#,\n\r\t]/.test(z)){q.error("标签ID 不能含 #、逗号或换行");return}}if(!E.label){q.error("显示文字必填");return}if(E.type==="miniprogram"&&(E.url=""),E.type==="internal"){E.url="",E.appId="",E.appSecret="";let z=E.pagePath.trim();if(!z){q.error("请填写本小程序页面路径");return}if(z.startsWith("/")||(z="/"+z.replace(/^\/+/,"")),!/^\/pages\//.test(z)){q.error("路径需以 /pages/ 开头");return}E.pagePath=z}E.type==="wxlink"&&(E.appId="",E.pagePath=""),Sa(!0);try{const z=await bt("/api/db/link-tags",E);z!=null&&z.success?(q.success(Rr?"已更新":"已添加"),is(!1),sa(),Lr()):q.error((z==null?void 0:z.error)??"保存失败")}catch(z){console.error(z),q.error("保存失败")}finally{Sa(!1)}},disabled:Xr,className:"bg-amber-500 hover:bg-amber-600 text-white",children:Xr?"保存中...":"保存"})]})]})})]})]}),s.jsx(kV,{open:mn,onOpenChange:Zr,editingPerson:ni,onSubmit:async E=>{var ke;const z={personId:E.personId||E.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:E.name,userId:E.boundUserId,aliases:E.aliases||void 0,label:E.label,ckbApiKey:E.ckbApiKey||void 0,greeting:E.greeting||void 0,tips:E.tips||void 0,remarkType:E.remarkType||void 0,remarkFormat:E.remarkFormat||void 0,addFriendInterval:E.addFriendInterval,startTime:E.startTime||void 0,endTime:E.endTime||void 0,deviceGroups:(ke=E.deviceGroups)!=null&&ke.trim()?E.deviceGroups.split(",").map(Ke=>parseInt(Ke.trim(),10)).filter(Ke=>!Number.isNaN(Ke)):void 0},ue=await bt("/api/db/persons",z);if(ue&&ue.success===!1){const Ke=ue;Ke.ckbResponse&&console.log("存客宝返回",Ke.ckbResponse);const gt=Ke.error||"操作失败";throw new Error(gt)}if(Ns(),q.success(ni?"已保存":"已添加"),ue!=null&&ue.ckbCreateResult&&Object.keys(ue.ckbCreateResult).length>0){const Ke=ue.ckbCreateResult;console.log("存客宝创建结果",Ke);const gt=Ke.planId??Ke.id,at=gt!=null?[`planId: ${gt}`]:[];Ke.apiKey!=null&&at.push("apiKey: ***"),q.info(at.length?`存客宝创建结果:${at.join(",")}`:"存客宝创建结果见控制台")}}}),s.jsx(Lt,{open:!!As,onOpenChange:E=>{E||Ca(null)},children:s.jsxs(It,{showCloseButton:!0,className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(Ot,{className:"gap-1",children:[s.jsx(Dt,{className:"text-white text-base",children:"确认删除"}),s.jsx(Wo,{className:"text-gray-400 text-sm leading-relaxed wrap-break-word",children:As&&s.jsxs(s.Fragment,{children:[As.personSource==="vip_sync"?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["确定删除超级个体「",As.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链接人与事-",As.name,"」?将同时删除存客宝对应获客计划。"]})}),s.jsxs("p",{className:"mt-1.5",children:["二次确认:删除后无法恢复,文章中的 @",As.name," 将无法正常跳转。"]})]})})]}),s.jsxs(nn,{className:"gap-2 sm:gap-2 pt-1",children:[s.jsx(G,{variant:"outline",size:"sm",className:"border-gray-600 text-gray-300",onClick:()=>Ca(null),children:"取消"}),s.jsx(G,{variant:"destructive",size:"sm",className:"bg-red-600 hover:bg-red-700",onClick:async()=>{As&&(await Pi(`/api/db/persons?personId=${As.personId}`),Ca(null),Ns(),q.success("已删除"))},children:"确定删除"})]})]})}),s.jsx(Lt,{open:Zs,onOpenChange:Gi,children:s.jsxs(It,{className:"max-w-2xl bg-[#0f2137] border-gray-700",children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[s.jsx(qn,{className:"w-5 h-5 text-green-400"}),Ji," — 获客详情(共 ",xr," 条)"]})}),s.jsx("div",{className:"max-h-[450px] overflow-y-auto space-y-2",children:ol?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ve,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):er.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:"时间"})]}),er.map((E,z)=>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:(ea-1)*20+z+1}),s.jsx("span",{className:"text-white truncate",children:E.nickname||E.name||E.userId||"-"}),s.jsx("span",{className:"text-gray-300 text-xs",children:E.phone||"-"}),s.jsx("span",{className:"text-gray-300 text-xs truncate",children:E.wechatId||"-"}),s.jsx("span",{className:"text-xs",children:E.source==="article_mention"?s.jsx("span",{className:"text-purple-400",children:"文章@"}):E.source==="index_lead"?s.jsx("span",{className:"text-blue-400",children:"首页"}):s.jsx("span",{className:"text-gray-500",children:E.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:E.createdAt?new Date(E.createdAt).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"})]},E.id))]})}),xr>20&&s.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2",children:[s.jsx(G,{size:"sm",variant:"outline",disabled:ea<=1,onClick:()=>_n(bs,Ji,ea-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:[ea," / ",Math.ceil(xr/20)]}),s.jsx(G,{size:"sm",variant:"outline",disabled:ea>=Math.ceil(xr/20),onClick:()=>_n(bs,Ji,ea+1),className:"border-gray-600 text-gray-300 bg-transparent h-7 px-3",children:"下一页"})]})]})})]})}const Mi={name:"卡若",avatar:"K",avatarImg:"",title:"Soul派对房主理人 · 私域运营专家",bio:'每天早上6点到9点,在Soul派对房分享真实的创业故事。专注私域运营与项目变现,用"云阿米巴"模式帮助创业者构建可持续的商业体系。',stats:[{label:"商业案例",value:"62"},{label:"连续直播",value:"365天"},{label:"派对分享",value:"1000+"}],highlights:["5年私域运营经验","帮助100+品牌从0到1增长","连续创业者,擅长商业模式设计"]};function kj(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&"label"in e&&"value"in e?{label:String(e.label),value:String(e.value)}:{label:"",value:""}).filter(e=>e.label||e.value):Mi.stats}function Sj(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):Mi.highlights}function EV(){const[t,e]=g.useState(Mi),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,c]=g.useState(!1),u=g.useRef(null);g.useEffect(()=>{Le("/api/admin/author-settings").then(k=>{const T=k==null?void 0:k.data;T&&typeof T=="object"&&e({name:String(T.name??Mi.name),avatar:String(T.avatar??Mi.avatar),avatarImg:String(T.avatarImg??""),title:String(T.title??Mi.title),bio:String(T.bio??Mi.bio),stats:kj(T.stats).length?kj(T.stats):Mi.stats,highlights:Sj(T.highlights).length?Sj(T.highlights):Mi.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)},T=await bt("/api/admin/author-settings",k);if(!T||T.success===!1){q.error("保存失败: "+(T&&typeof T=="object"&&"error"in T?T.error:""));return}i(!1);const C=document.createElement("div");C.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",C.textContent="作者设置已保存",document.body.appendChild(C),setTimeout(()=>C.remove(),2e3)}catch(k){console.error(k),q.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{i(!1)}},f=async k=>{var C;const T=(C=k.target.files)==null?void 0:C[0];if(T){c(!0);try{const L=new FormData;L.append("file",T),L.append("folder","avatars");const R=Ku(),U={};R&&(U.Authorization=`Bearer ${R}`);const F=await(await fetch(Vl("/api/upload"),{method:"POST",body:L,credentials:"include",headers:U})).json();F!=null&&F.success&&(F!=null&&F.url)?e(O=>({...O,avatarImg:F.url})):q.error("上传失败: "+((F==null?void 0:F.error)||"未知错误"))}catch(L){console.error(L),q.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),x=k=>e(T=>({...T,stats:T.stats.filter((C,L)=>L!==k)})),b=(k,T,C)=>e(L=>({...L,stats:L.stats.map((R,U)=>U===k?{...R,[T]:C}:R)})),N=()=>e(k=>({...k,highlights:[...k.highlights,""]})),w=k=>e(T=>({...T,highlights:T.highlights.filter((C,L)=>L!==k)})),v=(k,T)=>e(C=>({...C,highlights:C.highlights.map((L,R)=>R===k?T: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(Ai,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(G,{onClick:h,disabled:a||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"flex items-center gap-2 text-white",children:[s.jsx(Ai,{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(te,{className:"text-gray-300",children:"姓名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(T=>({...T,name:k.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(T=>({...T,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(rk,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(T=>({...T,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(G,{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(Df,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:ya(t.avatarImg.startsWith("http")?t.avatarImg:Vl(t.avatarImg)),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"头衔"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(T=>({...T,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"个人简介"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(T=>({...T,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsx(ut,{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,T)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:C=>b(T,"label",C.target.value),placeholder:"标签"}),s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:C=>b(T,"value",C.target.value),placeholder:"数值"}),s.jsx(G,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>x(T),children:s.jsx(ss,{className:"w-4 h-4"})})]},T)),s.jsxs(G,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsx(ut,{className:"text-white",children:"亮点标签"}),s.jsx(Qt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(_e,{className:"space-y-3",children:[t.highlights.map((k,T)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:C=>v(T,C.target.value),placeholder:"5年私域运营经验"}),s.jsx(G,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(T),children:s.jsx(ss,{className:"w-4 h-4"})})]},T)),s.jsxs(G,{variant:"outline",size:"sm",onClick:N,className:"border-gray-600 text-gray-400",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function TV(t){return confirm(`确定删除该${t}?此操作不可恢复。`)?window.prompt(`请输入「删除」以确认删除${t}`)==="删除":!1}function MV(){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=qa(h,300),[x,b]=g.useState(!0),[N,w]=g.useState(null),[v,k]=g.useState(!1),[T,C]=g.useState(null),[L,R]=g.useState(""),[U,P]=g.useState(""),[F,O]=g.useState(""),[Q,re]=g.useState("admin"),[D,ne]=g.useState("active"),[le,me]=g.useState(!1);async function I(){var W;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 Le(`/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?"无权限访问":((W=he==null?void 0:he.data)==null?void 0:W.error)||"加载失败"),e([])}finally{b(!1)}}g.useEffect(()=>{I()},[a,o,m]);const Y=()=>{C(null),R(""),P(""),O(""),re("admin"),ne("active"),k(!0)},B=W=>{C(W),R(W.username),P(""),O(W.name||""),re(W.role==="super_admin"?"super_admin":"admin"),ne(W.status==="disabled"?"disabled":"active"),k(!0)},xe=async()=>{var W;if(!L.trim()){w("用户名不能为空");return}if(!T&&!U){w("新建时密码必填,至少 6 位");return}if(U&&U.length<6){w("密码至少 6 位");return}w(null),me(!0);try{if(T){const fe=await tn("/api/admin/users",{id:T.id,password:U||void 0,name:F.trim(),role:Q,status:D});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}else{const fe=await bt("/api/admin/users",{username:L.trim(),password:U,name:F.trim(),role:Q});fe!=null&&fe.success?(k(!1),I()):w((fe==null?void 0:fe.error)||"保存失败")}}catch(fe){const he=fe;w(((W=he==null?void 0:he.data)==null?void 0:W.error)||"保存失败")}finally{me(!1)}},X=async W=>{var fe;if(!TV("管理员")){w("已取消删除");return}try{const he=await Pi(`/api/admin/users?id=${W}`);he!=null&&he.success?I():w((he==null?void 0:he.error)||"删除失败")}catch(he){const de=he;w(((fe=de==null?void 0:de.data)==null?void 0:fe.error)||"删除失败")}},V=W=>{if(!W)return"-";try{const fe=new Date(W);return isNaN(fe.getTime())?W:fe.toLocaleString("zh-CN")}catch{return W}};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Gc,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{placeholder:"搜索用户名/昵称",value:h,onChange:W=>f(W.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(G,{variant:"outline",size:"sm",onClick:I,disabled:x,className:"border-gray-600 text-gray-300",children:s.jsx(Ve,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsxs(G,{onClick:Y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{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(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"用户名"}),s.jsx(Se,{className:"text-gray-400",children:"昵称"}),s.jsx(Se,{className:"text-gray-400",children:"角色"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"创建时间"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(W=>s.jsxs(xt,{className:"border-gray-700/50",children:[s.jsx(je,{className:"text-gray-300",children:W.id}),s.jsx(je,{className:"text-white font-medium",children:W.username}),s.jsx(je,{className:"text-gray-400",children:W.name||"-"}),s.jsx(je,{children:s.jsx(Be,{variant:"outline",className:W.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:W.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(je,{children:s.jsx(Be,{variant:"outline",className:W.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:W.status==="active"?"正常":"已禁用"})}),s.jsx(je,{className:"text-gray-500 text-sm",children:V(W.createdAt)}),s.jsxs(je,{className:"text-right",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>B(W),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>X(W.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(ns,{className:"w-4 h-4"})})]})]},W.id)),t.length===0&&!x&&s.jsx(xt,{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(xs,{page:a,pageSize:o,total:n,totalPages:c,onPageChange:i})})]})})}),s.jsx(Lt,{open:v,onOpenChange:k,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(Ot,{children:s.jsx(Dt,{className:"text-white",children:T?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"用户名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:L,onChange:W=>R(W.target.value),disabled:!!T}),T&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:T?"新密码(留空不改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:T?"留空表示不修改":"至少 6 位",value:U,onChange:W=>P(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:F,onChange:W=>O(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:Q,onChange:W=>re(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"admin",children:"管理员"}),s.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),T&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:D,onChange:W=>ne(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"active",children:"正常"}),s.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:xe,disabled:le,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),le?"保存中...":"保存"]})]})]})})]})}function In({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 G4(){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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(dt,{className:"pb-3",children:s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Au,{className:"w-5 h-5 text-[#38bdac]"}),"1. Authentication"]})}),s.jsx(_e,{className:"space-y-4",children:s.jsx(In,{method:"POST",url:"/api/admin",desc:"登录,返回 JWT token",headers:["Content-Type: application/json"],body:`{ "username": "admin", "password": "your_password" @@ -1029,14 +1029,14 @@ ${b.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content: "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 Di="/pages/member-detail/member-detail",Ba="/pages/read/read",Ha={[Di]:"成员详情",[Ba]:"文章详情 / 阅读"},Rg=[{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:"开发登录"}],AV=Ba;function Cj(t){const e=String(t.pageName??"").trim();return e||Ha[t.pagePath]||"—"}function PV(t){const e=String(t??"").trim();return e==="singlePage"||e==="single_page"?"singlePage":"fullApp"}function Ej(t){return t==="singlePage"?"单页面":"多页面"}function Oo(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`pp-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function pb(t){return/^[a-zA-Z][a-zA-Z0-9_]*$/.test(t.trim())}function IV(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(!pb(i))return;const o=String(a.pagePath??"").trim();o.startsWith("/")&&n.push({id:typeof a.id=="string"&&a.id.trim()?a.id.trim():Oo(),pageName:String(a.pageName??"").trim(),pagePath:o,scope:PV(a.scope),key:i,behavior:String(a.behavior??"").trim()||"—",content:String(a.content??"")})}),n}function RV(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:Oo(),pageName:Ha[Di],pagePath:Di,scope:"fullApp",key:"unlockIntroTitle",behavior:"解锁前说明弹窗 · 标题(wx.showModal title)",content:o.unlockIntroTitle}),typeof o.unlockIntroBody=="string"&&o.unlockIntroBody.trim()&&n.push({id:Oo(),pageName:Ha[Di],pagePath:Di,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:Oo(),pageName:Ha[Ba],pagePath:Ba,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}`;pb(v)&&n.push({id:Oo(),pageName:f||Ha[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 LV=new Set(["memberDetailPage","readPage","customPagePopups","pagePopupItems"]);function OV(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const n=t;for(const r of Object.keys(n))LV.has(r)||(e[r]=n[r]);return e}function DV(t){let e=IV(t);return e.length===0&&(e=RV(t)),{extra:OV(t),pagePopupItems:_V(e)}}function _V(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 $V(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 zV(t){const e=String(t.content||"").replace(/\s+/g," ").trim();return e.length>56?`${e.slice(0,56)}…`:e||"—"}const FV=[{pageName:Ha[Di],pagePath:Di,scope:"fullApp",key:"unlockIntroTitle",behavior:"解锁前说明弹窗 · 标题(wx.showModal title)",content:"解锁与链接说明"},{pageName:Ha[Di],pagePath:Di,scope:"fullApp",key:"unlockIntroBody",behavior:"解锁前说明弹窗 · 正文(wx.showModal content)",content:`「链接」用于提交留资,由对方通过获客计划跟进;「解锁」用于复制手机/微信号后自行添加好友。 -请确认已了解后再登录。`},{pageName:Ha[Ba],pagePath:Ba,scope:"fullApp",key:"beforeLoginHint",behavior:"未登录时付费墙上方说明",content:"试读进度与下方百分比以后台配置为准;登录后可购买解锁全文。"},{pageName:Ha[Ba],pagePath:Ba,scope:"singlePage",key:"singlePageTitle",behavior:"朋友圈单页 · 付费区标题",content:"解锁全文"},{pageName:Ha[Ba],pagePath:Ba,scope:"singlePage",key:"singlePagePaywallHint",behavior:"朋友圈单页 · 付费墙说明",content:"当前为朋友圈单页预览,无法在此登录或付款。请点击底部「前往小程序」进入完整版后再解锁本章。"}];function BV(){return FV.map(t=>({...t,id:Oo()}))}const Hc=10,Tj=()=>({id:Oo(),pageName:"",pagePath:AV,scope:"fullApp",key:"",behavior:"",content:""});function VV({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 Rg.some(z=>z.value===P)?P:"__other__"},[h.pagePath]),v=g.useMemo(()=>{const P=r.trim().toLowerCase();return P?t.filter(z=>`${z.pageName} ${z.pagePath} ${Ej(z.scope)} ${z.key} ${z.behavior} ${z.content} ${Cj(z)}`.toLowerCase().includes(P)):t},[r,t]),k=g.useMemo(()=>Math.max(1,Math.ceil(v.length/Hc)),[v.length]),T=g.useMemo(()=>{const P=(b-1)*Hc;return v.slice(P,P+Hc)},[v,b]);g.useEffect(()=>{N(1)},[r]),g.useEffect(()=>{N(P=>Math.min(P,k))},[k]);const C=()=>{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(),z=h.key.trim();if(!P.startsWith("/")){q.error("页面路径须以 / 开头");return}if(!pb(z)){q.error("键名须为英文:字母开头,仅字母、数字、下划线");return}if(!h.behavior.trim()){q.error("请填写行为说明");return}if(t.some(Q=>Q.pagePath===P&&Q.key===z&&Q.id!==h.id)){q.error("同一页面下键名不能重复");return}c==="add"?(e(Q=>[...Q,{...h,id:h.id||Oo()}]),q.success("已添加,请点击右上角「保存设置」提交")):(e(Q=>Q.map(re=>re.id===h.id?{...h}:re)),q.success("已更新,请点击「保存设置」提交")),o(!1)},U=()=>{m&&(e(P=>P.filter(z=>z.id!==m)),q.success("已删除,请点击「保存设置」提交"),x(null))};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(ok,{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)。下方表格每页展示 ",Hc," 条;全部条目随右上角「保存设置」写入数据库,与分页无关。"]})]}),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(G,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200",title:"用与小程序对齐的 5 条标准文案替换当前列表,再点「保存设置」写入数据库。迁移完成后可移除此按钮。",onClick:()=>{e(BV()),q.info("已填入标准 5 条,请点击「保存设置」写入数据库")},children:[s.jsx(hA,{className:"w-3.5 h-3.5 mr-1.5"}),"填入默认种子"]}),s.jsxs(G,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:C,children:[s.jsx(OT,{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(te,{className:"text-gray-400 text-xs flex items-center gap-1.5",children:[s.jsx(hr,{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(oe,{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(fs,{className:"w-full min-w-[1320px] table-fixed",children:[s.jsx(ps,{children:s.jsxs(xt,{className:"border-gray-700 hover:bg-[#0a1628]/80 bg-[#0a1628]",children:[s.jsx(Se,{className:"text-gray-300 w-[11%] min-w-[108px]",children:"页面名称"}),s.jsx(Se,{className:"text-gray-300 w-[8%] min-w-[88px]",children:"类型"}),s.jsx(Se,{className:"text-gray-300 w-[19%] min-w-[200px]",children:"页面路径"}),s.jsx(Se,{className:"text-gray-300 w-[10%] min-w-[108px]",children:"键名(英文)"}),s.jsx(Se,{className:"text-gray-300 w-[13%] min-w-[108px]",children:"行为"}),s.jsx(Se,{className:"text-gray-300 w-[25%] min-w-[220px]",children:"文案摘要"}),s.jsx(Se,{className:"text-gray-300 text-right w-[14%] min-w-[200px] whitespace-nowrap",children:"操作"})]})}),s.jsx(ms,{children:T.map(P=>s.jsxs(xt,{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(Be,{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:zV(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(G,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 px-2.5 text-[#38bdac]",onClick:()=>L(P),children:[s.jsx(Kg,{className:"w-3.5 h-3.5 mr-1"}),"编辑"]}),s.jsxs(G,{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(ts,{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(xs,{page:b,totalPages:k,total:v.length,pageSize:Hc,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," 条,每页 ",Hc," 条"]})]})]})]}),s.jsx(Lt,{open:i,onOpenChange:o,children:s.jsxs(It,{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(Ot,{children:[s.jsx(Dt,{children:c==="add"?"新增弹窗文案":"编辑弹窗文案"}),s.jsxs(Wo,{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(te,{className:"text-gray-300",children:"页面名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:文章详情 / 阅读",value:h.pageName,onChange:P=>f(z=>({...z,pageName:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"便于表格识别;可与路径列对照,留空时对常见路径会自动显示默认名称。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"页面路径"}),s.jsxs(To,{value:w,onValueChange:P=>{f(P==="__other__"?z=>{const O=z.pagePath.trim(),Q=Rg.some(re=>re.value===O);return{...z,pagePath:Q?"/pages/":z.pagePath}}:z=>({...z,pagePath:P}))},children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm w-full",children:s.jsx(Mo,{placeholder:"选择页面路径"})}),s.jsxs(Ri,{className:"max-h-[min(60vh,320px)]",children:[Rg.map(P=>s.jsxs(us,{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(us,{value:"__other__",className:"focus:bg-[#1a3a4a] focus:text-white",children:"自定义路径…"})]})]}),w==="__other__"&&s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"/pages/xxx/xxx",value:h.pagePath,onChange:P=>f(z=>({...z,pagePath:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"从列表选择常用页面;若路径未收录(如分包页),选「自定义路径」后手动填写。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型"}),s.jsxs(To,{value:h.scope,onValueChange:P=>f(z=>({...z,scope:P==="singlePage"?"singlePage":"fullApp"})),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-600 text-white",children:s.jsx(Mo,{placeholder:"选择类型"})}),s.jsxs(Ri,{children:[s.jsx(us,{value:"fullApp",className:"focus:bg-[#1a3a4a] focus:text-white",children:"多页面(完整小程序)"}),s.jsx(us,{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(te,{className:"text-gray-300",children:"键名(英文,自定义)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"beforeLoginHint",value:h.key,disabled:c==="edit",onChange:P=>f(z=>({...z,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(te,{className:"text-gray-300",children:"行为说明"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:未登录时付费墙上方展示",value:h.behavior,onChange:P=>f(z=>({...z,behavior:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文案内容"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-600 text-white min-h-[140px]",placeholder:"弹窗正文、提示语等",value:h.content,onChange:P=>f(z=>({...z,content:P.target.value}))})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>o(!1),children:"取消"}),s.jsx(G,{className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:R,children:"确定"})]})]})}),s.jsx(Lt,{open:!!m,onOpenChange:P=>!P&&x(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsxs(Ot,{children:[s.jsx(Dt,{children:"删除该条文案?"}),s.jsx(Wo,{className:"text-gray-400",children:"删除后需保存设置才会同步到小程序;若键名已被代码引用,删除后对应位置将走默认兜底。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>x(null),children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700",onClick:U,children:"删除"})]})]})})]})}const HV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},UV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},WV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...UV},ckbLeadApiKey:""},KV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},qV=["system","author","admin","api-docs"],Mj=["basic","mp","mp-copy","oss","features"];function GV(){const[t,e]=X0(),n=t.get("tab")??"system",r=qV.includes(n)?n:"system",a=t.get("section")??"basic",i=Mj.includes(a)?a:"basic",[o,c]=g.useState(WV),[u,h]=g.useState(KV),[f,m]=g.useState(HV),[x,b]=g.useState({}),[N,w]=g.useState([]),[v,k]=g.useState({}),[T,C]=g.useState(!1),[L,R]=g.useState(!0),[U,P]=g.useState(!1),[z,O]=g.useState(""),[Q,re]=g.useState(""),[D,ne]=g.useState(!1),[le,me]=g.useState(!1),I=(de,_,J=!1)=>{O(de),re(_),ne(J),P(!0)};g.useEffect(()=>{(async()=>{try{const _=await Le("/api/admin/settings");if(!_||_.success===!1)return;if(_.featureConfig&&Object.keys(_.featureConfig).length&&h(J=>({...J,..._.featureConfig})),_.mpConfig&&typeof _.mpConfig=="object"){const J={..._.mpConfig};m(ae=>({...ae,...J}));const{extra:$,pagePopupItems:Z}=DV(J.mpUi);b($),w(Z)}if(_.ossConfig&&typeof _.ossConfig=="object"&&k(J=>({...J,..._.ossConfig})),_.siteSettings&&typeof _.siteSettings=="object"){const J=_.siteSettings;c($=>({...$,...typeof J.sectionPrice=="number"&&{sectionPrice:J.sectionPrice},...typeof J.baseBookPrice=="number"&&{baseBookPrice:J.baseBookPrice},...typeof J.distributorShare=="number"&&{distributorShare:J.distributorShare},...J.authorInfo&&typeof J.authorInfo=="object"&&{authorInfo:{...$.authorInfo,...J.authorInfo}},...typeof J.ckbLeadApiKey=="string"&&{ckbLeadApiKey:J.ckbLeadApiKey}}))}}catch(_){console.error("Load settings error:",_)}finally{R(!1)}})()},[]);const Y=async(de,_)=>{me(!0);try{const J=await bt("/api/admin/settings",{featureConfig:de});if(!J||J.success===!1){_(),I("保存失败",(J==null?void 0:J.error)??"未知错误",!0);return}I("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(J){console.error("Save feature config error:",J),_(),I("保存失败",J instanceof Error?J.message:String(J),!0)}finally{me(!1)}},F=(de,_)=>{const J=u,$={...J,[de]:_};h($),Y($,()=>h(J))},[xe,X]=g.useState(!1),V=async de=>{const _=f,J={..._,auditMode:de};m(J),X(!0);try{const $=await bt("/api/admin/settings",{mpConfig:J});if(!$||$.success===!1){m(_),I("保存失败",($==null?void 0:$.error)??"未知错误",!0);return}I("已保存",de?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch($){m(_),I("保存失败",$ instanceof Error?$.message:String($),!0)}finally{X(!1)}},W=async()=>{C(!0);try{const de=$V(N,x),_=await bt("/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:de},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(de){console.error("Save settings error:",de),I("保存失败",de instanceof Error?de.message:String(de),!0)}finally{C(!1)}},fe=de=>{if(de==="system"){const _=new URLSearchParams(t);_.delete("tab"),Mj.includes(_.get("section")||"basic")||_.set("section","basic"),e(_);return}e({tab:de})},he=de=>{const _=new URLSearchParams(t);_.delete("tab"),_.set("section",de),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(G,{onClick:W,disabled:T,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),T?"保存中...":"保存设置"]})]}),s.jsxs(Wl,{value:r,onValueChange:fe,className:"w-full",children:[s.jsxs(Ko,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Ut,{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(Po,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(Ut,{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(Gh,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(Ut,{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(Gc,{className:"w-4 h-4 mr-2"}),"管理员"]}),s.jsxs(Ut,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",onClick:de=>{de.preventDefault(),window.open("/api-docs","_blank")},children:[s.jsx(Z0,{className:"w-4 h-4 mr-2"}),"API 文档 ↗"]})]}),s.jsxs(Wt,{value:"system",className:"mt-0",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["MBTI 默认头像已迁至"," ",s.jsx(_i,{to:"/users",className:"text-[#38bdac] underline",children:"用户管理(用户列表点头像打开)"})]}),s.jsxs(Wl,{value:i,onValueChange:he,className:"w-full",children:[s.jsxs(Ko,{className:"mb-4 bg-[#0a1628] border border-gray-700/50 p-1 flex-wrap h-auto gap-1",children:[s.jsxs(Ut,{value:"basic",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(MM,{className:"w-3.5 h-3.5 mr-1"}),"基础与价格"]}),s.jsxs(Ut,{value:"mp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(Bl,{className:"w-3.5 h-3.5 mr-1"}),"小程序与审核"]}),s.jsxs(Ut,{value:"mp-copy",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(ok,{className:"w-3.5 h-3.5 mr-1"}),"弹窗文案"]}),s.jsxs(Ut,{value:"oss",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(L1,{className:"w-3.5 h-3.5 mr-1"}),"OSS"]}),s.jsxs(Ut,{value:"features",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(Po,{className:"w-3.5 h-3.5 mr-1"}),"功能开关"]})]}),s.jsxs(Wt,{value:"basic",className:"space-y-6 mt-0",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Gh,{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(te,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Gh,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(oe,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.name??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,name:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Fg,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(oe,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:o.authorInfo.startDate??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,startDate:de.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Fg,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(oe,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:o.authorInfo.liveTime??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,liveTime:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ik,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(oe,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:o.authorInfo.platform??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,platform:de.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ur,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(oe,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.description??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,description:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(el,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:o.authorInfo.bio??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,bio:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Ua,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(oe,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:o.ckbLeadApiKey??"",onChange:de=>c(_=>({..._,ckbLeadApiKey:de.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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Rf,{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(te,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.sectionPrice,onChange:de=>c(_=>({..._,sectionPrice:Number.parseFloat(de.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.baseBookPrice,onChange:de=>c(_=>({..._,baseBookPrice:Number.parseFloat(de.target.value)||9.9}))})]})]})})]})]}),s.jsxs(Wt,{value:"mp",className:"space-y-6 mt-0",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Bl,{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(te,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:f.appId??"",onChange:de=>m(_=>({..._,appId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:f.withdrawSubscribeTmplId??"",onChange:de=>m(_=>({..._,withdrawSubscribeTmplId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:f.mchId??"",onChange:de=>m(_=>({..._,mchId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.minWithdraw??10,onChange:de=>m(_=>({..._,minWithdraw:Number.parseFloat(de.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(De,{className:`bg-[#0f2137] shadow-xl ${f.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Gc,{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(Gc,{className:`w-4 h-4 ${f.auditMode?"text-amber-400":"text-gray-400"}`}),s.jsx(te,{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(Kt,{id:"audit-mode",checked:f.auditMode??!1,disabled:xe,onCheckedChange:V})]})})]})]}),s.jsx(Wt,{value:"mp-copy",className:"space-y-6 mt-0",children:s.jsx(VV,{pagePopupItems:N,setPagePopupItems:w,extraKeysCount:Object.keys(x).length})}),s.jsx(Wt,{value:"oss",className:"space-y-6 mt-0",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(L1,{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(te,{className:"text-gray-300",children:"Endpoint"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:v.endpoint??"",onChange:de=>k(_=>({..._,endpoint:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"Bucket"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:v.bucket??"",onChange:de=>k(_=>({..._,bucket:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"Region"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:v.region??"",onChange:de=>k(_=>({..._,region:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"AccessKey ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:v.accessKeyId??"",onChange:de=>k(_=>({..._,accessKeyId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"AccessKey Secret"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:v.accessKeySecret??"",onChange:de=>k(_=>({..._,accessKeySecret:de.target.value}))})]})]})})]})}),s.jsxs(Wt,{value:"features",className:"space-y-6 mt-0",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Po,{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(Kn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),s.jsx(Kt,{id:"match-enabled",checked:u.matchEnabled,disabled:le,onCheckedChange:de=>F("matchEnabled",de)})]}),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(Hg,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"}),s.jsxs("p",{className:"text-xs text-amber-400/80 ml-6 mt-1",children:["佣金比例、绑定期、提现规则等与",s.jsx(_i,{to:"/distribution?tab=settings",className:"underline mx-1 text-[#38bdac]",children:"推广中心 → 推广设置"}),"为同一套接口,在此仅控制是否展示入口。"]})]}),s.jsx(Kt,{id:"referral-enabled",checked:u.referralEnabled,disabled:le,onCheckedChange:de=>F("referralEnabled",de)})]}),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(ur,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页、目录页搜索栏的显示"})]}),s.jsx(Kt,{id:"search-enabled",checked:u.searchEnabled,disabled:le,onCheckedChange:de=>F("searchEnabled",de)})]}),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(Po,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),s.jsx(Kt,{id:"about-enabled",checked:u.aboutEnabled,disabled:le,onCheckedChange:de=>F("aboutEnabled",de)})]})]}),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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Lf,{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(Kn,{className:"w-3 h-3"})},{mod:"推广中心 / 推荐好友",ctrl:"推广功能开关",icon:s.jsx(Hg,{className:"w-3 h-3"})},{mod:"搜索",ctrl:"搜索功能开关",icon:s.jsx(ur,{className:"w-3 h-3"})},{mod:"关于页面",ctrl:"关于页面开关",icon:s.jsx(Gh,{className:"w-3 h-3"})},{mod:"支付 / VIP / 充值 / 收益",ctrl:"审核模式",icon:s.jsx(Gc,{className:"w-3 h-3"})},{mod:"超级个体名片",ctrl:"审核模式",icon:s.jsx(EA,{className:"w-3 h-3"})},{mod:"首页获客入口",ctrl:"已移除",icon:s.jsx(ZT,{className:"w-3 h-3"})}].map(de=>s.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#0a1628] border border-gray-700/30",children:[de.icon,s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:de.mod}),s.jsxs("span",{className:"text-gray-500 ml-1",children:["← ",de.ctrl]})]})]},de.mod))})})]})]})]})]}),s.jsx(Wt,{value:"author",className:"mt-0",children:s.jsx(EV,{})}),s.jsx(Wt,{value:"admin",className:"mt-0",children:s.jsx(MV,{})}),s.jsx(Wt,{value:"api-docs",className:"mt-0",children:s.jsx(G4,{})})]}),s.jsx(Lt,{open:U,onOpenChange:P,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(Ot,{children:[s.jsx(Dt,{className:D?"text-red-400":"text-[#38bdac]",children:z}),s.jsx(Wo,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:Q})]}),s.jsx(nn,{className:"mt-4",children:s.jsx(G,{onClick:()=>P(!1),className:D?"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 JV(){const[t,e]=g.useState(!1),[n,r]=g.useState(Aj),[a,i]=g.useState(""),o=async()=>{e(!0);try{const k=await Le("/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 bt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),q.success("配置已保存!")}catch(k){console.error("保存失败:",k),q.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,T)=>{navigator.clipboard.writeText(k),i(T),setTimeout(()=>i(""),2e3)},h=(k,T)=>{r(C=>({...C,wechat:{...C.wechat,[k]:T}}))},f=(k,T)=>{r(C=>({...C,alipay:{...C.alipay,[k]:T}}))},m=(k,T)=>{r(C=>({...C,usdt:{...C.usdt,[k]:T}}))},x=(k,T)=>{r(C=>({...C,paypal:{...C.paypal,[k]:T}}))},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(G,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(G,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{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(ek,{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(Wl,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Ko,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(Ut,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(Bl,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(Ut,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(O1,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(Ut,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(R1,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(Ut,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(Ug,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(Wt,{value:"wechat",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(Bl,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"网站AppID"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"商户号"}),s.jsx(oe,{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(Vo,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(oe,{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(te,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(oe,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(b.groupQrCode??""),onChange:k=>h("groupQrCode",k.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(Wt,{value:"alipay",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(O1,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),s.jsx(G,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?s.jsx(_p,{className:"w-4 h-4 text-green-500"}):s.jsx(nk,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(oe,{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(Vo,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(oe,{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(Wt,{value:"usdt",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(R1,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"网络类型"}),s.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(w.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[s.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),s.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),s.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"收款地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(w.address??""),onChange:k=>m("address",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{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(Wt,{value:"paypal",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(Ug,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{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 QV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},YV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},XV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function ZV(){const[t,e]=g.useState({siteConfig:{...QV},menuConfig:{...YV},pageConfig:{...XV}}),[n,r]=g.useState(!1),[a,i]=g.useState(!1);g.useEffect(()=>{Le("/api/config").then(f=>{f!=null&&f.siteConfig&&e(m=>({...m,siteConfig:{...m.siteConfig,...f.siteConfig}})),f!=null&&f.menuConfig&&e(m=>({...m,menuConfig:{...m.menuConfig,...f.menuConfig}})),f!=null&&f.pageConfig&&e(m=>({...m,pageConfig:{...m.pageConfig,...f.pageConfig}}))}).catch(console.error)},[]);const o=async()=>{i(!0);try{await bt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await bt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await bt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),q.success("配置已保存")}catch(f){console.error(f),q.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(G,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Ug,{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(te,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(oe,{id:"site-name",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteName??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteName:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(oe,{id:"site-title",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteTitle??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(oe,{id:"site-desc",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteDescription??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteDescription:f.target.value}}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(oe,{id:"logo",className:"bg-[#0a1628] border-gray-700 text-white",value:c.logo??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,logo:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(oe,{id:"favicon",className:"bg-[#0a1628] border-gray-700 text-white",value:c.favicon??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,favicon:f.target.value}}))})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(JM,{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(te,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(oe,{id:"primary-color",type:"color",className:"w-16 h-10 bg-[#0a1628] border-gray-700 cursor-pointer p-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white flex-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))})]})]}),s.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(BM,{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(Kt,{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(oe,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Z0,{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(te,{className:"text-gray-300",children:"首页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"首页副标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目录页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"我的页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function eH(){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 Le("/api/config"),T=(N=(b=k==null?void 0:k.liveQRCodes)==null?void 0:b[0])==null?void 0:N.urls;Array.isArray(T)&&e(T.join(` +请确认已了解后再登录。`},{pageName:Ha[Ba],pagePath:Ba,scope:"fullApp",key:"beforeLoginHint",behavior:"未登录时付费墙上方说明",content:"试读进度与下方百分比以后台配置为准;登录后可购买解锁全文。"},{pageName:Ha[Ba],pagePath:Ba,scope:"singlePage",key:"singlePageTitle",behavior:"朋友圈单页 · 付费区标题",content:"解锁全文"},{pageName:Ha[Ba],pagePath:Ba,scope:"singlePage",key:"singlePagePaywallHint",behavior:"朋友圈单页 · 付费墙说明",content:"当前为朋友圈单页预览,无法在此登录或付款。请点击底部「前往小程序」进入完整版后再解锁本章。"}];function BV(){return FV.map(t=>({...t,id:Oo()}))}const Hc=10,Tj=()=>({id:Oo(),pageName:"",pagePath:AV,scope:"fullApp",key:"",behavior:"",content:""});function VV({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 Rg.some(F=>F.value===P)?P:"__other__"},[h.pagePath]),v=g.useMemo(()=>{const P=r.trim().toLowerCase();return P?t.filter(F=>`${F.pageName} ${F.pagePath} ${Ej(F.scope)} ${F.key} ${F.behavior} ${F.content} ${Cj(F)}`.toLowerCase().includes(P)):t},[r,t]),k=g.useMemo(()=>Math.max(1,Math.ceil(v.length/Hc)),[v.length]),T=g.useMemo(()=>{const P=(b-1)*Hc;return v.slice(P,P+Hc)},[v,b]);g.useEffect(()=>{N(1)},[r]),g.useEffect(()=>{N(P=>Math.min(P,k))},[k]);const C=()=>{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(),F=h.key.trim();if(!P.startsWith("/")){q.error("页面路径须以 / 开头");return}if(!pb(F)){q.error("键名须为英文:字母开头,仅字母、数字、下划线");return}if(!h.behavior.trim()){q.error("请填写行为说明");return}if(t.some(Q=>Q.pagePath===P&&Q.key===F&&Q.id!==h.id)){q.error("同一页面下键名不能重复");return}c==="add"?(e(Q=>[...Q,{...h,id:h.id||Oo()}]),q.success("已添加,请点击右上角「保存设置」提交")):(e(Q=>Q.map(re=>re.id===h.id?{...h}:re)),q.success("已更新,请点击「保存设置」提交")),o(!1)},U=()=>{m&&(e(P=>P.filter(F=>F.id!==m)),q.success("已删除,请点击「保存设置」提交"),x(null))};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(ok,{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)。下方表格每页展示 ",Hc," 条;全部条目随右上角「保存设置」写入数据库,与分页无关。"]})]}),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(G,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-200",title:"用与小程序对齐的 5 条标准文案替换当前列表,再点「保存设置」写入数据库。迁移完成后可移除此按钮。",onClick:()=>{e(BV()),q.info("已填入标准 5 条,请点击「保存设置」写入数据库")},children:[s.jsx(hA,{className:"w-3.5 h-3.5 mr-1.5"}),"填入默认种子"]}),s.jsxs(G,{type:"button",size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:C,children:[s.jsx(OT,{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(te,{className:"text-gray-400 text-xs flex items-center gap-1.5",children:[s.jsx(hr,{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(oe,{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(fs,{className:"w-full min-w-[1320px] table-fixed",children:[s.jsx(ps,{children:s.jsxs(xt,{className:"border-gray-700 hover:bg-[#0a1628]/80 bg-[#0a1628]",children:[s.jsx(Se,{className:"text-gray-300 w-[11%] min-w-[108px]",children:"页面名称"}),s.jsx(Se,{className:"text-gray-300 w-[8%] min-w-[88px]",children:"类型"}),s.jsx(Se,{className:"text-gray-300 w-[19%] min-w-[200px]",children:"页面路径"}),s.jsx(Se,{className:"text-gray-300 w-[10%] min-w-[108px]",children:"键名(英文)"}),s.jsx(Se,{className:"text-gray-300 w-[13%] min-w-[108px]",children:"行为"}),s.jsx(Se,{className:"text-gray-300 w-[25%] min-w-[220px]",children:"文案摘要"}),s.jsx(Se,{className:"text-gray-300 text-right w-[14%] min-w-[200px] whitespace-nowrap",children:"操作"})]})}),s.jsx(ms,{children:T.map(P=>s.jsxs(xt,{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(Be,{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:zV(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(G,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 px-2.5 text-[#38bdac]",onClick:()=>L(P),children:[s.jsx(Kg,{className:"w-3.5 h-3.5 mr-1"}),"编辑"]}),s.jsxs(G,{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(ns,{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(xs,{page:b,totalPages:k,total:v.length,pageSize:Hc,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," 条,每页 ",Hc," 条"]})]})]})]}),s.jsx(Lt,{open:i,onOpenChange:o,children:s.jsxs(It,{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(Ot,{children:[s.jsx(Dt,{children:c==="add"?"新增弹窗文案":"编辑弹窗文案"}),s.jsxs(Wo,{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(te,{className:"text-gray-300",children:"页面名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:文章详情 / 阅读",value:h.pageName,onChange:P=>f(F=>({...F,pageName:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"便于表格识别;可与路径列对照,留空时对常见路径会自动显示默认名称。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"页面路径"}),s.jsxs(To,{value:w,onValueChange:P=>{f(P==="__other__"?F=>{const O=F.pagePath.trim(),Q=Rg.some(re=>re.value===O);return{...F,pagePath:Q?"/pages/":F.pagePath}}:F=>({...F,pagePath:P}))},children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm w-full",children:s.jsx(Mo,{placeholder:"选择页面路径"})}),s.jsxs(Ri,{className:"max-h-[min(60vh,320px)]",children:[Rg.map(P=>s.jsxs(ts,{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(ts,{value:"__other__",className:"focus:bg-[#1a3a4a] focus:text-white",children:"自定义路径…"})]})]}),w==="__other__"&&s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"/pages/xxx/xxx",value:h.pagePath,onChange:P=>f(F=>({...F,pagePath:P.target.value}))}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"从列表选择常用页面;若路径未收录(如分包页),选「自定义路径」后手动填写。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型"}),s.jsxs(To,{value:h.scope,onValueChange:P=>f(F=>({...F,scope:P==="singlePage"?"singlePage":"fullApp"})),children:[s.jsx(Ii,{className:"bg-[#0a1628] border-gray-600 text-white",children:s.jsx(Mo,{placeholder:"选择类型"})}),s.jsxs(Ri,{children:[s.jsx(ts,{value:"fullApp",className:"focus:bg-[#1a3a4a] focus:text-white",children:"多页面(完整小程序)"}),s.jsx(ts,{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(te,{className:"text-gray-300",children:"键名(英文,自定义)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white font-mono text-sm",placeholder:"beforeLoginHint",value:h.key,disabled:c==="edit",onChange:P=>f(F=>({...F,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(te,{className:"text-gray-300",children:"行为说明"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-600 text-white",placeholder:"如:未登录时付费墙上方展示",value:h.behavior,onChange:P=>f(F=>({...F,behavior:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"文案内容"}),s.jsx(el,{className:"bg-[#0a1628] border-gray-600 text-white min-h-[140px]",placeholder:"弹窗正文、提示语等",value:h.content,onChange:P=>f(F=>({...F,content:P.target.value}))})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>o(!1),children:"取消"}),s.jsx(G,{className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:R,children:"确定"})]})]})}),s.jsx(Lt,{open:!!m,onOpenChange:P=>!P&&x(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsxs(Ot,{children:[s.jsx(Dt,{children:"删除该条文案?"}),s.jsx(Wo,{className:"text-gray-400",children:"删除后需保存设置才会同步到小程序;若键名已被代码引用,删除后对应位置将走默认兜底。"})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>x(null),children:"取消"}),s.jsx(G,{className:"bg-red-600 hover:bg-red-700",onClick:U,children:"删除"})]})]})})]})}const HV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},UV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},WV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...UV},ckbLeadApiKey:""},KV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},qV=["system","author","admin","api-docs"],Mj=["basic","mp","mp-copy","oss","features"];function GV(){const[t,e]=X0(),n=t.get("tab")??"system",r=qV.includes(n)?n:"system",a=t.get("section")??"basic",i=Mj.includes(a)?a:"basic",[o,c]=g.useState(WV),[u,h]=g.useState(KV),[f,m]=g.useState(HV),[x,b]=g.useState({}),[N,w]=g.useState([]),[v,k]=g.useState({}),[T,C]=g.useState(!1),[L,R]=g.useState(!0),[U,P]=g.useState(!1),[F,O]=g.useState(""),[Q,re]=g.useState(""),[D,ne]=g.useState(!1),[le,me]=g.useState(!1),I=(de,_,J=!1)=>{O(de),re(_),ne(J),P(!0)};g.useEffect(()=>{(async()=>{try{const _=await Le("/api/admin/settings");if(!_||_.success===!1)return;if(_.featureConfig&&Object.keys(_.featureConfig).length&&h(J=>({...J,..._.featureConfig})),_.mpConfig&&typeof _.mpConfig=="object"){const J={..._.mpConfig};m(ae=>({...ae,...J}));const{extra:$,pagePopupItems:Z}=DV(J.mpUi);b($),w(Z)}if(_.ossConfig&&typeof _.ossConfig=="object"&&k(J=>({...J,..._.ossConfig})),_.siteSettings&&typeof _.siteSettings=="object"){const J=_.siteSettings;c($=>({...$,...typeof J.sectionPrice=="number"&&{sectionPrice:J.sectionPrice},...typeof J.baseBookPrice=="number"&&{baseBookPrice:J.baseBookPrice},...typeof J.distributorShare=="number"&&{distributorShare:J.distributorShare},...J.authorInfo&&typeof J.authorInfo=="object"&&{authorInfo:{...$.authorInfo,...J.authorInfo}},...typeof J.ckbLeadApiKey=="string"&&{ckbLeadApiKey:J.ckbLeadApiKey}}))}}catch(_){console.error("Load settings error:",_)}finally{R(!1)}})()},[]);const Y=async(de,_)=>{me(!0);try{const J=await bt("/api/admin/settings",{featureConfig:de});if(!J||J.success===!1){_(),I("保存失败",(J==null?void 0:J.error)??"未知错误",!0);return}I("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(J){console.error("Save feature config error:",J),_(),I("保存失败",J instanceof Error?J.message:String(J),!0)}finally{me(!1)}},B=(de,_)=>{const J=u,$={...J,[de]:_};h($),Y($,()=>h(J))},[xe,X]=g.useState(!1),V=async de=>{const _=f,J={..._,auditMode:de};m(J),X(!0);try{const $=await bt("/api/admin/settings",{mpConfig:J});if(!$||$.success===!1){m(_),I("保存失败",($==null?void 0:$.error)??"未知错误",!0);return}I("已保存",de?"审核模式已开启,小程序将隐藏所有支付入口。":"审核模式已关闭,支付功能已恢复。")}catch($){m(_),I("保存失败",$ instanceof Error?$.message:String($),!0)}finally{X(!1)}},W=async()=>{C(!0);try{const de=$V(N,x),_=await bt("/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:de},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(de){console.error("Save settings error:",de),I("保存失败",de instanceof Error?de.message:String(de),!0)}finally{C(!1)}},fe=de=>{if(de==="system"){const _=new URLSearchParams(t);_.delete("tab"),Mj.includes(_.get("section")||"basic")||_.set("section","basic"),e(_);return}e({tab:de})},he=de=>{const _=new URLSearchParams(t);_.delete("tab"),_.set("section",de),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(G,{onClick:W,disabled:T,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),T?"保存中...":"保存设置"]})]}),s.jsxs(Wl,{value:r,onValueChange:fe,className:"w-full",children:[s.jsxs(Ko,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Ut,{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(Po,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(Ut,{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(Gh,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(Ut,{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(Gc,{className:"w-4 h-4 mr-2"}),"管理员"]}),s.jsxs(Ut,{value:"api-docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",onClick:de=>{de.preventDefault(),window.open("/api-docs","_blank")},children:[s.jsx(Z0,{className:"w-4 h-4 mr-2"}),"API 文档 ↗"]})]}),s.jsxs(Wt,{value:"system",className:"mt-0",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["MBTI 默认头像已迁至"," ",s.jsx(_i,{to:"/users",className:"text-[#38bdac] underline",children:"用户管理(用户列表点头像打开)"})]}),s.jsxs(Wl,{value:i,onValueChange:he,className:"w-full",children:[s.jsxs(Ko,{className:"mb-4 bg-[#0a1628] border border-gray-700/50 p-1 flex-wrap h-auto gap-1",children:[s.jsxs(Ut,{value:"basic",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(MM,{className:"w-3.5 h-3.5 mr-1"}),"基础与价格"]}),s.jsxs(Ut,{value:"mp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(Bl,{className:"w-3.5 h-3.5 mr-1"}),"小程序与审核"]}),s.jsxs(Ut,{value:"mp-copy",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(ok,{className:"w-3.5 h-3.5 mr-1"}),"弹窗文案"]}),s.jsxs(Ut,{value:"oss",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(L1,{className:"w-3.5 h-3.5 mr-1"}),"OSS"]}),s.jsxs(Ut,{value:"features",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 text-xs",children:[s.jsx(Po,{className:"w-3.5 h-3.5 mr-1"}),"功能开关"]})]}),s.jsxs(Wt,{value:"basic",className:"space-y-6 mt-0",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Gh,{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(te,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Gh,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(oe,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.name??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,name:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Fg,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(oe,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:o.authorInfo.startDate??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,startDate:de.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Fg,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(oe,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:o.authorInfo.liveTime??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,liveTime:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ik,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(oe,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:o.authorInfo.platform??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,platform:de.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ur,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(oe,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:o.authorInfo.description??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,description:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(el,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:o.authorInfo.bio??"",onChange:de=>c(_=>({..._,authorInfo:{..._.authorInfo,bio:de.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(te,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Ua,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(oe,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:o.ckbLeadApiKey??"",onChange:de=>c(_=>({..._,ckbLeadApiKey:de.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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Rf,{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(te,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.sectionPrice,onChange:de=>c(_=>({..._,sectionPrice:Number.parseFloat(de.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.baseBookPrice,onChange:de=>c(_=>({..._,baseBookPrice:Number.parseFloat(de.target.value)||9.9}))})]})]})})]})]}),s.jsxs(Wt,{value:"mp",className:"space-y-6 mt-0",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Bl,{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(te,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:f.appId??"",onChange:de=>m(_=>({..._,appId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:f.withdrawSubscribeTmplId??"",onChange:de=>m(_=>({..._,withdrawSubscribeTmplId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:f.mchId??"",onChange:de=>m(_=>({..._,mchId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.minWithdraw??10,onChange:de=>m(_=>({..._,minWithdraw:Number.parseFloat(de.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(De,{className:`bg-[#0f2137] shadow-xl ${f.auditMode?"border-amber-500/50 border-2":"border-gray-700/50"}`,children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Gc,{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(Gc,{className:`w-4 h-4 ${f.auditMode?"text-amber-400":"text-gray-400"}`}),s.jsx(te,{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(Kt,{id:"audit-mode",checked:f.auditMode??!1,disabled:xe,onCheckedChange:V})]})})]})]}),s.jsx(Wt,{value:"mp-copy",className:"space-y-6 mt-0",children:s.jsx(VV,{pagePopupItems:N,setPagePopupItems:w,extraKeysCount:Object.keys(x).length})}),s.jsx(Wt,{value:"oss",className:"space-y-6 mt-0",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(L1,{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(te,{className:"text-gray-300",children:"Endpoint"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou.aliyuncs.com",value:v.endpoint??"",onChange:de=>k(_=>({..._,endpoint:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"Bucket"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"bucket 名称",value:v.bucket??"",onChange:de=>k(_=>({..._,bucket:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"Region"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"oss-cn-hangzhou",value:v.region??"",onChange:de=>k(_=>({..._,region:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"AccessKey ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey ID",value:v.accessKeyId??"",onChange:de=>k(_=>({..._,accessKeyId:de.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"AccessKey Secret"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"AccessKey Secret",value:v.accessKeySecret??"",onChange:de=>k(_=>({..._,accessKeySecret:de.target.value}))})]})]})})]})}),s.jsxs(Wt,{value:"features",className:"space-y-6 mt-0",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Po,{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(qn,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),s.jsx(Kt,{id:"match-enabled",checked:u.matchEnabled,disabled:le,onCheckedChange:de=>B("matchEnabled",de)})]}),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(Hg,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"}),s.jsxs("p",{className:"text-xs text-amber-400/80 ml-6 mt-1",children:["佣金比例、绑定期、提现规则等与",s.jsx(_i,{to:"/distribution?tab=settings",className:"underline mx-1 text-[#38bdac]",children:"推广中心 → 推广设置"}),"为同一套接口,在此仅控制是否展示入口。"]})]}),s.jsx(Kt,{id:"referral-enabled",checked:u.referralEnabled,disabled:le,onCheckedChange:de=>B("referralEnabled",de)})]}),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(ur,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页、目录页搜索栏的显示"})]}),s.jsx(Kt,{id:"search-enabled",checked:u.searchEnabled,disabled:le,onCheckedChange:de=>B("searchEnabled",de)})]}),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(Po,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(te,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),s.jsx(Kt,{id:"about-enabled",checked:u.aboutEnabled,disabled:le,onCheckedChange:de=>B("aboutEnabled",de)})]})]}),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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Lf,{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(qn,{className:"w-3 h-3"})},{mod:"推广中心 / 推荐好友",ctrl:"推广功能开关",icon:s.jsx(Hg,{className:"w-3 h-3"})},{mod:"搜索",ctrl:"搜索功能开关",icon:s.jsx(ur,{className:"w-3 h-3"})},{mod:"关于页面",ctrl:"关于页面开关",icon:s.jsx(Gh,{className:"w-3 h-3"})},{mod:"支付 / VIP / 充值 / 收益",ctrl:"审核模式",icon:s.jsx(Gc,{className:"w-3 h-3"})},{mod:"超级个体名片",ctrl:"审核模式",icon:s.jsx(EA,{className:"w-3 h-3"})},{mod:"首页获客入口",ctrl:"已移除",icon:s.jsx(ZT,{className:"w-3 h-3"})}].map(de=>s.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#0a1628] border border-gray-700/30",children:[de.icon,s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:de.mod}),s.jsxs("span",{className:"text-gray-500 ml-1",children:["← ",de.ctrl]})]})]},de.mod))})})]})]})]})]}),s.jsx(Wt,{value:"author",className:"mt-0",children:s.jsx(EV,{})}),s.jsx(Wt,{value:"admin",className:"mt-0",children:s.jsx(MV,{})}),s.jsx(Wt,{value:"api-docs",className:"mt-0",children:s.jsx(G4,{})})]}),s.jsx(Lt,{open:U,onOpenChange:P,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(Ot,{children:[s.jsx(Dt,{className:D?"text-red-400":"text-[#38bdac]",children:F}),s.jsx(Wo,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:Q})]}),s.jsx(nn,{className:"mt-4",children:s.jsx(G,{onClick:()=>P(!1),className:D?"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 JV(){const[t,e]=g.useState(!1),[n,r]=g.useState(Aj),[a,i]=g.useState(""),o=async()=>{e(!0);try{const k=await Le("/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 bt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),q.success("配置已保存!")}catch(k){console.error("保存失败:",k),q.error("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,T)=>{navigator.clipboard.writeText(k),i(T),setTimeout(()=>i(""),2e3)},h=(k,T)=>{r(C=>({...C,wechat:{...C.wechat,[k]:T}}))},f=(k,T)=>{r(C=>({...C,alipay:{...C.alipay,[k]:T}}))},m=(k,T)=>{r(C=>({...C,usdt:{...C.usdt,[k]:T}}))},x=(k,T)=>{r(C=>({...C,paypal:{...C.paypal,[k]:T}}))},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(G,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(G,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{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(ek,{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(Wl,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Ko,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(Ut,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(Bl,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(Ut,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(O1,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(Ut,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(R1,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(Ut,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(Ug,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(Wt,{value:"wechat",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(Bl,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"网站AppID"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"商户号"}),s.jsx(oe,{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(Vo,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(oe,{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(te,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(oe,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(b.groupQrCode??""),onChange:k=>h("groupQrCode",k.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(Wt,{value:"alipay",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(O1,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(N.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),s.jsx(G,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(N.partnerId??""),"pid"),children:a==="pid"?s.jsx(_p,{className:"w-4 h-4 text-green-500"}):s.jsx(nk,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(oe,{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(Vo,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(oe,{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(Wt,{value:"usdt",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(R1,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"网络类型"}),s.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(w.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[s.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),s.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),s.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"收款地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(w.address??""),onChange:k=>m("address",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{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(Wt,{value:"paypal",className:"space-y-4",children:s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(ut,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(Ug,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(Kt,{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(te,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{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 QV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},YV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},XV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function ZV(){const[t,e]=g.useState({siteConfig:{...QV},menuConfig:{...YV},pageConfig:{...XV}}),[n,r]=g.useState(!1),[a,i]=g.useState(!1);g.useEffect(()=>{Le("/api/config").then(f=>{f!=null&&f.siteConfig&&e(m=>({...m,siteConfig:{...m.siteConfig,...f.siteConfig}})),f!=null&&f.menuConfig&&e(m=>({...m,menuConfig:{...m.menuConfig,...f.menuConfig}})),f!=null&&f.pageConfig&&e(m=>({...m,pageConfig:{...m.pageConfig,...f.pageConfig}}))}).catch(console.error)},[]);const o=async()=>{i(!0);try{await bt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await bt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await bt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),q.success("配置已保存")}catch(f){console.error(f),q.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(G,{onClick:o,disabled:a,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),a?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Ug,{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(te,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(oe,{id:"site-name",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteName??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteName:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(oe,{id:"site-title",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteTitle??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(oe,{id:"site-desc",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteDescription??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteDescription:f.target.value}}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(oe,{id:"logo",className:"bg-[#0a1628] border-gray-700 text-white",value:c.logo??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,logo:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(oe,{id:"favicon",className:"bg-[#0a1628] border-gray-700 text-white",value:c.favicon??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,favicon:f.target.value}}))})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(JM,{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(te,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(oe,{id:"primary-color",type:"color",className:"w-16 h-10 bg-[#0a1628] border-gray-700 cursor-pointer p-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white flex-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))})]})]}),s.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(BM,{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(Kt,{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(oe,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Z0,{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(te,{className:"text-gray-300",children:"首页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"首页副标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"目录页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"我的页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function eH(){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 Le("/api/config"),T=(N=(b=k==null?void 0:k.liveQRCodes)==null?void 0:b[0])==null?void 0:N.urls;Array.isArray(T)&&e(T.join(` `));const C=(v=(w=k==null?void 0:k.paymentMethods)==null?void 0:w.wechat)==null?void 0:v.groupQrCode;C&&r(C),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 bt("/api/db/config",{key:"live_qr_codes",value:N,description:"群活码配置"}),q.success("群活码配置已保存!"),await u()}catch(b){console.error(b),q.error("保存失败: "+(b instanceof Error?b.message:String(b)))}},m=async()=>{var b;try{await bt("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((b=o.paymentMethods)==null?void 0:b.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),q.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(N){console.error(N),q.error("保存失败: "+(N instanceof Error?N.message:String(N)))}},x=()=>{n?window.open(n,"_blank"):q.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(ek,{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(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(z1,{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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Wg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{placeholder:"https://cli.im/xxxxx 或 https://weixin.qq.com/g/...",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",value:n,onChange:b=>r(b.target.value)}),s.jsx(G,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:a==="group"?s.jsx(_p,{className:"w-4 h-4 text-green-500"}):s.jsx(nk,{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(Vo,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(G,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(Df,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(G,{onClick:x,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(Vo,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(z1,{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(te,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Wg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(el,{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(G,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Df,{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}},tH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function nH(){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 C=await Le("/api/db/config/full?key=match_config"),L=(C==null?void 0:C.data)??(C==null?void 0:C.config);L&&e({...Pj,...L})}catch(C){console.error("加载匹配配置失败:",C)}finally{r(!1)}};g.useEffect(()=>{x()},[]);const b=async()=>{i(!0);try{const C=await bt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});C&&C.success!==!1?q.success("配置保存成功!"):q.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:"未知错误"))}catch(C){console.error("保存配置失败:",C),q.error("保存失败")}finally{i(!1)}},N=C=>{h(C),m({id:C.id,label:C.label,matchLabel:C.matchLabel,icon:C.icon,matchFromDB:C.matchFromDB,showJoinAfterMatch:C.showJoinAfterMatch,price:C.price,enabled:C.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){q.error("请填写类型ID和名称");return}const C=[...t.matchTypes];if(u){const L=C.findIndex(R=>R.id===u.id);L!==-1&&(C[L]={...f})}else{if(C.some(L=>L.id===f.id)){q.error("类型ID已存在");return}C.push({...f})}e({...t,matchTypes:C}),c(!1)},k=C=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(L=>L.id!==C)})},T=C=>{e({...t,matchTypes:t.matchTypes.map(L=>L.id===C?{...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(Po,{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(G,{variant:"outline",onClick:x,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(G,{onClick:b,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Ho,{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(te,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:C=>e({...t,freeMatchLimit:parseInt(C.target.value,10)||0})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:C=>e({...t,matchPrice:parseFloat(C.target.value)||1})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:C=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(C.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(Kt,{checked:t.settings.enableFreeMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enableFreeMatches:C}})}),s.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:t.settings.enablePaidMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enablePaidMatches:C}})}),s.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Kn,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(G,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(_e,{children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"图标"}),s.jsx(Se,{className:"text-gray-400",children:"类型ID"}),s.jsx(Se,{className:"text-gray-400",children:"显示名称"}),s.jsx(Se,{className:"text-gray-400",children:"匹配标签"}),s.jsx(Se,{className:"text-gray-400",children:"价格"}),s.jsx(Se,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ms,{children:t.matchTypes.map(C=>s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx("span",{className:"text-2xl",children:C.icon})}),s.jsx(je,{className:"font-mono text-gray-300",children:C.id}),s.jsx(je,{className:"text-white font-medium",children:C.label}),s.jsx(je,{className:"text-gray-300",children:C.matchLabel}),s.jsx(je,{children:s.jsxs(Be,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",C.price]})}),s.jsx(je,{children:C.matchFromDB?s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Kt,{checked:C.enabled,onCheckedChange:()=>T(C.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>N(C),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>k(C.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(ts,{className:"w-4 h-4"})})]})})]},C.id))})]})})]}),s.jsx(Lt,{open:o,onOpenChange:c,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Rn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:C=>m({...f,id:C.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:tH.map(C=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===C?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:C}),children:C},C))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:C=>m({...f,label:C.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:C=>m({...f,matchLabel:C.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:C=>m({...f,price:parseFloat(C.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(Kt,{checked:f.matchFromDB,onCheckedChange:C=>m({...f,matchFromDB:C})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:f.showJoinAfterMatch,onCheckedChange:C=>m({...f,showJoinAfterMatch:C})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:f.enabled,onCheckedChange:C=>m({...f,enabled:C})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(G,{onClick:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const Ij={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function sH(){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 Le(`/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(Ve,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ms,{children:[t.map(v=>s.jsxs(xt,{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:ya(v.userAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const T=k.currentTarget.nextElementSibling;T&&T.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:ya(v.matchedUserAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const T=k.currentTarget.nextElementSibling;T&&T.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(Be,{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(xt,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(xs,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:v=>{c(v),i(1)}})]})})})]})}function rH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0);async function a(){r(!0);try{const i=await Le("/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),q.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(Xc,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(Se,{className:"text-gray-400",children:"成员"}),s.jsx(Se,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(Se,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(ms,{children:[t.map((i,o)=>{var c;return s.jsxs(xt,{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:ya(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(xt,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function J4(t){const e=Ya(),[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 re;const Q=(re=O.target.files)==null?void 0:re[0];if(Q){w(!0);try{const D=new FormData;D.append("file",Q),D.append("folder","mentors");const ne=Ku(),le={};ne&&(le.Authorization=`Bearer ${ne}`);const I=await(await fetch(Vl("/api/upload"),{method:"POST",body:D,credentials:"include",headers:le})).json();I!=null&&I.success&&(I!=null&&I.url)?m(Y=>({...Y,avatar:I.url})):q.error("上传失败: "+((I==null?void 0:I.error)||"未知错误"))}catch(D){console.error(D),q.error("上传失败")}finally{w(!1),v.current&&(v.current.value="")}}};async function T(){i(!0);try{const O=await Le("/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(()=>{T()},[]);const C=()=>{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),C(),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)},U=async()=>{if(!f.name.trim()){q.error("导师姓名不能为空");return}b(!0);try{const O=D=>D===""?void 0:parseFloat(D),Q=f.userId.trim(),re={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 D=await tn("/api/db/mentors",{id:u.id,...re,userId:Q});D!=null&&D.success?(c(!1),T()):q.error("更新失败: "+(D==null?void 0:D.error))}else{const D=await bt("/api/db/mentors",{...re,userId:Q||void 0});D!=null&&D.success?(c(!1),T()):q.error("新增失败: "+(D==null?void 0:D.error))}}catch(O){console.error("Save error:",O),q.error("保存失败")}finally{b(!1)}},P=async O=>{if(confirm("确定删除该导师?"))try{const Q=await Pi(`/api/db/mentors?id=${O}`);Q!=null&&Q.success?T():q.error("删除失败: "+(Q==null?void 0:Q.error))}catch(Q){console.error("Delete error:",Q),q.error("删除失败")}},z=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(Kn,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表;填写「绑定用户 ID」后,小程序导师详情可跳转「派对会员名片」(与超级个体同页)"})]}),s.jsxs(G,{onClick:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"姓名"}),s.jsx(Se,{className:"text-gray-400",children:"简介"}),s.jsx(Se,{className:"text-gray-400",children:"单次"}),s.jsx(Se,{className:"text-gray-400",children:"半年"}),s.jsx(Se,{className:"text-gray-400",children:"年度"}),s.jsx(Se,{className:"text-gray-400",children:"绑定用户"}),s.jsx(Se,{className:"text-gray-400",children:"排序"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[n.map(O=>s.jsxs(xt,{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(Vo,{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:z(O.priceSingle)}),s.jsx(je,{className:"text-gray-400",children:z(O.priceHalfYear)}),s.jsx(je,{className:"text-gray-400",children:z(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(G,{variant:"ghost",size:"sm",onClick:()=>R(O),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(ts,{className:"w-4 h-4"})})]})]},O.id)),n.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:9,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Lt,{open:o,onOpenChange:c,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsx(Dt,{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(te,{className:"text-gray-300",children:"姓名 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:f.name,onChange:O=>m(Q=>({...Q,name:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"排序"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.sort,onChange:O=>m(Q=>({...Q,sort:parseInt(O.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:f.avatar,onChange:O=>m(Q=>({...Q,avatar:O.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:v,type:"file",accept:"image/*",className:"hidden",onChange:k}),s.jsxs(G,{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(Df,{className:"w-4 h-4 mr-2"}),N?"上传中...":"上传"]})]}),f.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:ya(f.avatar.startsWith("http")?f.avatar:Vl(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(te,{className:"text-gray-300",children:"绑定用户 ID(可选,与名片页一致)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"小程序用户 id,填后导师详情显示「查看派对会员名片」",value:f.userId,onChange:O=>m(Q=>({...Q,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(te,{className:"text-gray-300",children:"简介"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:f.intro,onChange:O=>m(Q=>({...Q,intro:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:f.tags,onChange:O=>m(Q=>({...Q,tags:O.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(te,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:f.priceSingle,onChange:O=>m(Q=>({...Q,priceSingle:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:f.priceHalfYear,onChange:O=>m(Q=>({...Q,priceHalfYear:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:f.priceYear,onChange:O=>m(Q=>({...Q,priceYear:O.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"引言"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:f.quote,onChange:O=>m(Q=>({...Q,quote:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.whyFind,onChange:O=>m(Q=>({...Q,whyFind:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.offering,onChange:O=>m(Q=>({...Q,offering:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:f.judgmentStyle,onChange:O=>m(Q=>({...Q,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(Q=>({...Q,enabled:O.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(te,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(ns,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:U,disabled:x,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),x?"保存中...":"保存"]})]})]})})]})}function aH(){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 Le(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(Fg,{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(G,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"用户ID"}),s.jsx(Se,{className:"text-gray-400",children:"导师ID"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ms,{children:[t.map(h=>s.jsxs(xt,{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(xt,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const pu={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:pu},iH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function oH(){const t=Ya(),[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 Le("/api/db/match-pool-counts");O!=null&&O.success&&O.data&&N(O.data)}catch(O){console.error("加载池子人数失败:",O)}finally{v(!1)}},T=async()=>{a(!0);try{const O=await Le("/api/db/config/full?key=match_config"),Q=(O==null?void 0:O.data)??(O==null?void 0:O.config);if(Q){let re=Q.poolSettings??pu;re.poolSource&&!Array.isArray(re.poolSource)&&(re={...re,poolSource:[re.poolSource]}),n({...Rj,...Q,poolSettings:re})}}catch(O){console.error("加载匹配配置失败:",O)}finally{a(!1)}};g.useEffect(()=>{T(),k()},[]);const C=async()=>{o(!0);try{const O=await bt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});q.error((O==null?void 0:O.success)!==!1?"配置保存成功!":"保存失败: "+((O==null?void 0:O.error)||"未知错误"))}catch(O){console.error(O),q.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)},U=()=>{if(!m.id||!m.label){q.error("请填写类型ID和名称");return}const O=[...e.matchTypes];if(h){const Q=O.findIndex(re=>re.id===h.id);Q!==-1&&(O[Q]={...m})}else{if(O.some(Q=>Q.id===m.id)){q.error("类型ID已存在");return}O.push({...m})}n({...e,matchTypes:O}),u(!1)},P=O=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(Q=>Q.id!==O)})},z=O=>{n({...e,matchTypes:e.matchTypes.map(Q=>Q.id===O?{...Q,enabled:!Q.enabled}:Q)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(G,{variant:"outline",onClick:T,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:C,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(sk,{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(te,{className:"text-gray-300",children:"匹配来源池"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{value:"vip",label:"超级个体(VIP会员)",desc:"付费 ¥1980 的VIP会员",icon:"👑",countKey:"vip"},{value:"complete",label:"完善资料用户",desc:"符合下方完善度要求的用户",icon:"✅",countKey:"complete"},{value:"all",label:"全部用户",desc:"所有已注册用户",icon:"👥",countKey:"all"}].map(O=>{const Q=e.poolSettings??pu,D=(Array.isArray(Q.poolSource)?Q.poolSource:[Q.poolSource]).includes(O.value),ne=b==null?void 0:b[O.countKey],le=()=>{const me=Array.isArray(Q.poolSource)?[...Q.poolSource]:[Q.poolSource],I=D?me.filter(Y=>Y!==O.value):[...me,O.value];I.length===0&&I.push(O.value),n({...e,poolSettings:{...Q,poolSource:I}})};return s.jsxs("button",{type:"button",onClick:le,className:`p-4 rounded-lg border text-left transition-all ${D?"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 ${D?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:D&&"✓"}),s.jsx("span",{className:"text-xl",children:O.icon}),s.jsx("span",{className:`text-sm font-medium ${D?"text-[#38bdac]":"text-gray-300"}`,children:O.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":ne??"-",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(te,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{key:"requirePhone",label:"有手机号",icon:"📱"},{key:"requireNickname",label:"有昵称",icon:"👤"},{key:"requireAvatar",label:"有头像",icon:"🖼️"},{key:"requireBusiness",label:"有业务需求",icon:"💼"}].map(O=>{const re=(e.poolSettings??pu)[O.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(Kt,{checked:re,onCheckedChange:D=>n({...e,poolSettings:{...e.poolSettings??pu,[O.key]:D}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:O.icon}),s.jsx(te,{className:"text-gray-300 text-sm",children:O.label})]})]},O.key)})})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Ho,{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(te,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:O=>n({...e,freeMatchLimit:parseInt(O.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:O=>n({...e,matchPrice:parseFloat(O.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange: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(Kt,{checked:e.settings.enableFreeMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enableFreeMatches:O}})}),s.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:e.settings.enablePaidMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enablePaidMatches:O}})}),s.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Kn,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(G,{onClick:R,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(_e,{children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"图标"}),s.jsx(Se,{className:"text-gray-400",children:"类型ID"}),s.jsx(Se,{className:"text-gray-400",children:"显示名称"}),s.jsx(Se,{className:"text-gray-400",children:"匹配标签"}),s.jsx(Se,{className:"text-gray-400",children:"价格"}),s.jsx(Se,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ms,{children:e.matchTypes.map(O=>s.jsxs(xt,{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(Be,{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(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Kt,{checked:O.enabled,onCheckedChange:()=>z(O.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>L(O),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(ts,{className:"w-4 h-4"})})]})})]},O.id))})]})})]}),s.jsx(Lt,{open:c,onOpenChange:u,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Rn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:iH.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(te,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange: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(Kt,{checked:m.matchFromDB,onCheckedChange:O=>x({...m,matchFromDB:O})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:m.showJoinAfterMatch,onCheckedChange:O=>x({...m,showJoinAfterMatch:O})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:m.enabled,onCheckedChange:O=>x({...m,enabled:O})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(G,{onClick:U,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const Lj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function lH(){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 C=new URLSearchParams({page:String(a),pageSize:String(o)});u&&C.set("matchType",u);const L=await Le(`/api/db/match-records?${C}`);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,T=({userId:C,nickname:L,avatar:R})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>w(C),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:ya(R),alt:"",className:"w-full h-full object-cover",onError:U=>{U.currentTarget.style.display="none"}}):null,s.jsx("span",{className:R?"hidden":"",children:(L||C||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:L||C}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[C==null?void 0:C.slice(0,16),(C==null?void 0:C.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:C=>{h(C.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(([C,L])=>s.jsx("option",{value:C,children:L},C))]}),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(Ve,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ms,{children:[t.map(C=>s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx(T,{userId:C.userId,nickname:C.userNickname,avatar:C.userAvatar})}),s.jsx(je,{children:C.matchedUserId?s.jsx(T,{userId:C.matchedUserId,nickname:C.matchedNickname,avatar:C.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(je,{children:s.jsx(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Lj[C.matchType]||C.matchType})}),s.jsxs(je,{className:"text-sm",children:[C.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&s.jsx("span",{className:"text-gray-600",children:"-"})]}),s.jsx(je,{className:"text-gray-400",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"})]},C.id)),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(xs,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:C=>{c(C),i(1)}})]})})}),s.jsx(py,{open:!!N,onClose:()=>w(null),userId:N,onUserUpdated:v})]})}function cH(){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(lH,{}),t==="pool"&&s.jsx(oH,{})]})}const Oj={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(!0),[f,m]=g.useState("investor"),[x,b]=g.useState(null);async function N(){h(!0);try{const T=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),C=await Le(`/api/db/match-records?${T}`);C!=null&&C.success&&(e(C.records||[]),r(C.total??0))}catch(T){console.error(T)}finally{h(!1)}}g.useEffect(()=>{N()},[a,f]);const w=async T=>{if(!T.phone&&!T.wechatId){q.info("该记录无联系方式,无法推送到存客宝");return}b(T.id);try{const C=await bt("/api/ckb/join",{type:T.matchType||"investor",phone:T.phone||"",wechat:T.wechatId||"",userId:T.userId,name:T.userNickname||""});q.error((C==null?void 0:C.message)||(C!=null&&C.success?"推送成功":"推送失败"))}catch(C){q.error("推送失败: "+(C instanceof Error?C.message:"网络错误"))}finally{b(null)}},v=Math.ceil(n/o)||1,k=T=>!!(T.phone||T.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:T=>{m(T.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(([T,C])=>s.jsx("option",{value:T,children:C},T))}),s.jsxs(G,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"时间"}),s.jsx(Se,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(T=>{var C,L;return s.jsxs(xt,{className:`border-gray-700/50 ${k(T)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(je,{className:"text-white",children:T.userNickname||((C=T.userId)==null?void 0:C.slice(0,12))}),s.jsx(je,{className:"text-white",children:T.matchedNickname||((L=T.matchedUserId)==null?void 0:L.slice(0,12))}),s.jsx(je,{children:s.jsx(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Oj[T.matchType]||T.matchType})}),s.jsxs(je,{className:"text-sm",children:[T.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",T.phone]}),T.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",T.wechatId]}),!T.phone&&!T.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(je,{className:"text-gray-400 text-sm",children:T.createdAt?new Date(T.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-right",children:k(T)?s.jsxs(G,{size:"sm",onClick:()=>w(T),disabled:x===T.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(xA,{className:"w-3 h-3 mr-1"}),x===T.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},T.id)}),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(xs,{page:a,totalPages:v,total:n,pageSize:o,onPageChange:i,onPageSizeChange:T=>{c(T),i(1)}})]})})})]})}const Dj={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},uH={single:"单次",half_year:"半年",year:"年度"};function hH(){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 Le(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(G,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"用户ID"}),s.jsx(Se,{className:"text-gray-400",children:"导师ID"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ms,{children:[t.map(c=>s.jsxs(xt,{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:uH[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(xt,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function fH(){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(hH,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(J4,{embedded:!0})})]})}function pH(){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 Le(`/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(Ve,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(ms,{children:[t.map(x=>s.jsxs(xt,{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(xt,{children:s.jsx(je,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(xs,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:x=>{c(x),i(1)}})]})})})]})}const mH=["partner","investor","mentor","team"],Lg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],_j=`# 场景获客接口摘要 +`).filter(Boolean).length," 个"]})]}),s.jsxs(G,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Df,{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}},tH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function nH(){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 C=await Le("/api/db/config/full?key=match_config"),L=(C==null?void 0:C.data)??(C==null?void 0:C.config);L&&e({...Pj,...L})}catch(C){console.error("加载匹配配置失败:",C)}finally{r(!1)}};g.useEffect(()=>{x()},[]);const b=async()=>{i(!0);try{const C=await bt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});C&&C.success!==!1?q.success("配置保存成功!"):q.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:"未知错误"))}catch(C){console.error("保存配置失败:",C),q.error("保存失败")}finally{i(!1)}},N=C=>{h(C),m({id:C.id,label:C.label,matchLabel:C.matchLabel,icon:C.icon,matchFromDB:C.matchFromDB,showJoinAfterMatch:C.showJoinAfterMatch,price:C.price,enabled:C.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){q.error("请填写类型ID和名称");return}const C=[...t.matchTypes];if(u){const L=C.findIndex(R=>R.id===u.id);L!==-1&&(C[L]={...f})}else{if(C.some(L=>L.id===f.id)){q.error("类型ID已存在");return}C.push({...f})}e({...t,matchTypes:C}),c(!1)},k=C=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(L=>L.id!==C)})},T=C=>{e({...t,matchTypes:t.matchTypes.map(L=>L.id===C?{...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(Po,{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(G,{variant:"outline",onClick:x,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(G,{onClick:b,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Ho,{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(te,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:C=>e({...t,freeMatchLimit:parseInt(C.target.value,10)||0})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:C=>e({...t,matchPrice:parseFloat(C.target.value)||1})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:C=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(C.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(Kt,{checked:t.settings.enableFreeMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enableFreeMatches:C}})}),s.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:t.settings.enablePaidMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enablePaidMatches:C}})}),s.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(qn,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(G,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(_e,{children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"图标"}),s.jsx(Se,{className:"text-gray-400",children:"类型ID"}),s.jsx(Se,{className:"text-gray-400",children:"显示名称"}),s.jsx(Se,{className:"text-gray-400",children:"匹配标签"}),s.jsx(Se,{className:"text-gray-400",children:"价格"}),s.jsx(Se,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ms,{children:t.matchTypes.map(C=>s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx("span",{className:"text-2xl",children:C.icon})}),s.jsx(je,{className:"font-mono text-gray-300",children:C.id}),s.jsx(je,{className:"text-white font-medium",children:C.label}),s.jsx(je,{className:"text-gray-300",children:C.matchLabel}),s.jsx(je,{children:s.jsxs(Be,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",C.price]})}),s.jsx(je,{children:C.matchFromDB?s.jsx(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Kt,{checked:C.enabled,onCheckedChange:()=>T(C.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>N(C),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>k(C.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(ns,{className:"w-4 h-4"})})]})})]},C.id))})]})})]}),s.jsx(Lt,{open:o,onOpenChange:c,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Rn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:C=>m({...f,id:C.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:tH.map(C=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===C?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:C}),children:C},C))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:C=>m({...f,label:C.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:C=>m({...f,matchLabel:C.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:C=>m({...f,price:parseFloat(C.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(Kt,{checked:f.matchFromDB,onCheckedChange:C=>m({...f,matchFromDB:C})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:f.showJoinAfterMatch,onCheckedChange:C=>m({...f,showJoinAfterMatch:C})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:f.enabled,onCheckedChange:C=>m({...f,enabled:C})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(G,{onClick:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const Ij={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function sH(){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 Le(`/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(Ve,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ms,{children:[t.map(v=>s.jsxs(xt,{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:ya(v.userAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const T=k.currentTarget.nextElementSibling;T&&T.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:ya(v.matchedUserAvatar),alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const T=k.currentTarget.nextElementSibling;T&&T.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(Be,{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(xt,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(xs,{page:a,totalPages:w,total:n,pageSize:o,onPageChange:i,onPageSizeChange:v=>{c(v),i(1)}})]})})})]})}function rH(){const[t,e]=g.useState([]),[n,r]=g.useState(!0);async function a(){r(!0);try{const i=await Le("/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),q.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(Xc,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(Se,{className:"text-gray-400",children:"成员"}),s.jsx(Se,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(Se,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(ms,{children:[t.map((i,o)=>{var c;return s.jsxs(xt,{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:ya(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(xt,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function J4(t){const e=Ya(),[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 re;const Q=(re=O.target.files)==null?void 0:re[0];if(Q){w(!0);try{const D=new FormData;D.append("file",Q),D.append("folder","mentors");const ne=Ku(),le={};ne&&(le.Authorization=`Bearer ${ne}`);const I=await(await fetch(Vl("/api/upload"),{method:"POST",body:D,credentials:"include",headers:le})).json();I!=null&&I.success&&(I!=null&&I.url)?m(Y=>({...Y,avatar:I.url})):q.error("上传失败: "+((I==null?void 0:I.error)||"未知错误"))}catch(D){console.error(D),q.error("上传失败")}finally{w(!1),v.current&&(v.current.value="")}}};async function T(){i(!0);try{const O=await Le("/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(()=>{T()},[]);const C=()=>{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),C(),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)},U=async()=>{if(!f.name.trim()){q.error("导师姓名不能为空");return}b(!0);try{const O=D=>D===""?void 0:parseFloat(D),Q=f.userId.trim(),re={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 D=await tn("/api/db/mentors",{id:u.id,...re,userId:Q});D!=null&&D.success?(c(!1),T()):q.error("更新失败: "+(D==null?void 0:D.error))}else{const D=await bt("/api/db/mentors",{...re,userId:Q||void 0});D!=null&&D.success?(c(!1),T()):q.error("新增失败: "+(D==null?void 0:D.error))}}catch(O){console.error("Save error:",O),q.error("保存失败")}finally{b(!1)}},P=async O=>{if(confirm("确定删除该导师?"))try{const Q=await Pi(`/api/db/mentors?id=${O}`);Q!=null&&Q.success?T():q.error("删除失败: "+(Q==null?void 0:Q.error))}catch(Q){console.error("Delete error:",Q),q.error("删除失败")}},F=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(qn,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表;填写「绑定用户 ID」后,小程序导师详情可跳转「派对会员名片」(与超级个体同页)"})]}),s.jsxs(G,{onClick:L,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"姓名"}),s.jsx(Se,{className:"text-gray-400",children:"简介"}),s.jsx(Se,{className:"text-gray-400",children:"单次"}),s.jsx(Se,{className:"text-gray-400",children:"半年"}),s.jsx(Se,{className:"text-gray-400",children:"年度"}),s.jsx(Se,{className:"text-gray-400",children:"绑定用户"}),s.jsx(Se,{className:"text-gray-400",children:"排序"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(ms,{children:[n.map(O=>s.jsxs(xt,{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(Vo,{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:F(O.priceSingle)}),s.jsx(je,{className:"text-gray-400",children:F(O.priceHalfYear)}),s.jsx(je,{className:"text-gray-400",children:F(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(G,{variant:"ghost",size:"sm",onClick:()=>R(O),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(ns,{className:"w-4 h-4"})})]})]},O.id)),n.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:9,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Lt,{open:o,onOpenChange:c,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(Ot,{children:s.jsx(Dt,{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(te,{className:"text-gray-300",children:"姓名 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:f.name,onChange:O=>m(Q=>({...Q,name:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"排序"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f.sort,onChange:O=>m(Q=>({...Q,sort:parseInt(O.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:f.avatar,onChange:O=>m(Q=>({...Q,avatar:O.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:v,type:"file",accept:"image/*",className:"hidden",onChange:k}),s.jsxs(G,{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(Df,{className:"w-4 h-4 mr-2"}),N?"上传中...":"上传"]})]}),f.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:ya(f.avatar.startsWith("http")?f.avatar:Vl(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(te,{className:"text-gray-300",children:"绑定用户 ID(可选,与名片页一致)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"小程序用户 id,填后导师详情显示「查看派对会员名片」",value:f.userId,onChange:O=>m(Q=>({...Q,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(te,{className:"text-gray-300",children:"简介"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:f.intro,onChange:O=>m(Q=>({...Q,intro:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:f.tags,onChange:O=>m(Q=>({...Q,tags:O.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(te,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:f.priceSingle,onChange:O=>m(Q=>({...Q,priceSingle:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:f.priceHalfYear,onChange:O=>m(Q=>({...Q,priceHalfYear:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:f.priceYear,onChange:O=>m(Q=>({...Q,priceYear:O.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"引言"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:f.quote,onChange:O=>m(Q=>({...Q,quote:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.whyFind,onChange:O=>m(Q=>({...Q,whyFind:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:f.offering,onChange:O=>m(Q=>({...Q,offering:O.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:f.judgmentStyle,onChange:O=>m(Q=>({...Q,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(Q=>({...Q,enabled:O.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(te,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(nn,{children:[s.jsxs(G,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(ss,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(G,{onClick:U,disabled:x,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"}),x?"保存中...":"保存"]})]})]})})]})}function aH(){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 Le(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(Fg,{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(G,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"用户ID"}),s.jsx(Se,{className:"text-gray-400",children:"导师ID"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ms,{children:[t.map(h=>s.jsxs(xt,{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(xt,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const pu={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:pu},iH=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function oH(){const t=Ya(),[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 Le("/api/db/match-pool-counts");O!=null&&O.success&&O.data&&N(O.data)}catch(O){console.error("加载池子人数失败:",O)}finally{v(!1)}},T=async()=>{a(!0);try{const O=await Le("/api/db/config/full?key=match_config"),Q=(O==null?void 0:O.data)??(O==null?void 0:O.config);if(Q){let re=Q.poolSettings??pu;re.poolSource&&!Array.isArray(re.poolSource)&&(re={...re,poolSource:[re.poolSource]}),n({...Rj,...Q,poolSettings:re})}}catch(O){console.error("加载匹配配置失败:",O)}finally{a(!1)}};g.useEffect(()=>{T(),k()},[]);const C=async()=>{o(!0);try{const O=await bt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});q.error((O==null?void 0:O.success)!==!1?"配置保存成功!":"保存失败: "+((O==null?void 0:O.error)||"未知错误"))}catch(O){console.error(O),q.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)},U=()=>{if(!m.id||!m.label){q.error("请填写类型ID和名称");return}const O=[...e.matchTypes];if(h){const Q=O.findIndex(re=>re.id===h.id);Q!==-1&&(O[Q]={...m})}else{if(O.some(Q=>Q.id===m.id)){q.error("类型ID已存在");return}O.push({...m})}n({...e,matchTypes:O}),u(!1)},P=O=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(Q=>Q.id!==O)})},F=O=>{n({...e,matchTypes:e.matchTypes.map(Q=>Q.id===O?{...Q,enabled:!Q.enabled}:Q)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(G,{variant:"outline",onClick:T,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:C,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"})," ",i?"保存中...":"保存配置"]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(sk,{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(te,{className:"text-gray-300",children:"匹配来源池"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{value:"vip",label:"超级个体(VIP会员)",desc:"付费 ¥1980 的VIP会员",icon:"👑",countKey:"vip"},{value:"complete",label:"完善资料用户",desc:"符合下方完善度要求的用户",icon:"✅",countKey:"complete"},{value:"all",label:"全部用户",desc:"所有已注册用户",icon:"👥",countKey:"all"}].map(O=>{const Q=e.poolSettings??pu,D=(Array.isArray(Q.poolSource)?Q.poolSource:[Q.poolSource]).includes(O.value),ne=b==null?void 0:b[O.countKey],le=()=>{const me=Array.isArray(Q.poolSource)?[...Q.poolSource]:[Q.poolSource],I=D?me.filter(Y=>Y!==O.value):[...me,O.value];I.length===0&&I.push(O.value),n({...e,poolSettings:{...Q,poolSource:I}})};return s.jsxs("button",{type:"button",onClick:le,className:`p-4 rounded-lg border text-left transition-all ${D?"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 ${D?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:D&&"✓"}),s.jsx("span",{className:"text-xl",children:O.icon}),s.jsx("span",{className:`text-sm font-medium ${D?"text-[#38bdac]":"text-gray-300"}`,children:O.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":ne??"-",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(te,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{key:"requirePhone",label:"有手机号",icon:"📱"},{key:"requireNickname",label:"有昵称",icon:"👤"},{key:"requireAvatar",label:"有头像",icon:"🖼️"},{key:"requireBusiness",label:"有业务需求",icon:"💼"}].map(O=>{const re=(e.poolSettings??pu)[O.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(Kt,{checked:re,onCheckedChange:D=>n({...e,poolSettings:{...e.poolSettings??pu,[O.key]:D}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:O.icon}),s.jsx(te,{className:"text-gray-300 text-sm",children:O.label})]})]},O.key)})})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(Ho,{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(te,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:O=>n({...e,freeMatchLimit:parseInt(O.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:O=>n({...e,matchPrice:parseFloat(O.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange: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(Kt,{checked:e.settings.enableFreeMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enableFreeMatches:O}})}),s.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:e.settings.enablePaidMatches,onCheckedChange:O=>n({...e,settings:{...e.settings,enablePaidMatches:O}})}),s.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(De,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(ut,{className:"text-white flex items-center gap-2",children:[s.jsx(qn,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(Qt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(G,{onClick:R,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Rn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(_e,{children:s.jsxs(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"图标"}),s.jsx(Se,{className:"text-gray-400",children:"类型ID"}),s.jsx(Se,{className:"text-gray-400",children:"显示名称"}),s.jsx(Se,{className:"text-gray-400",children:"匹配标签"}),s.jsx(Se,{className:"text-gray-400",children:"价格"}),s.jsx(Se,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(ms,{children:e.matchTypes.map(O=>s.jsxs(xt,{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(Be,{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(Be,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Be,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(je,{children:s.jsx(Kt,{checked:O.enabled,onCheckedChange:()=>F(O.id)})}),s.jsx(je,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>L(O),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>P(O.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(ns,{className:"w-4 h-4"})})]})})]},O.id))})]})})]}),s.jsx(Lt,{open:c,onOpenChange:u,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(Ot,{children:s.jsxs(Dt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(an,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Rn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:iH.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(te,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{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(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange: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(Kt,{checked:m.matchFromDB,onCheckedChange:O=>x({...m,matchFromDB:O})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:m.showJoinAfterMatch,onCheckedChange:O=>x({...m,showJoinAfterMatch:O})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Kt,{checked:m.enabled,onCheckedChange:O=>x({...m,enabled:O})}),s.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(G,{onClick:U,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const Lj={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function lH(){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 C=new URLSearchParams({page:String(a),pageSize:String(o)});u&&C.set("matchType",u);const L=await Le(`/api/db/match-records?${C}`);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,T=({userId:C,nickname:L,avatar:R})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>w(C),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:ya(R),alt:"",className:"w-full h-full object-cover",onError:U=>{U.currentTarget.style.display="none"}}):null,s.jsx("span",{className:R?"hidden":"",children:(L||C||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:L||C}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[C==null?void 0:C.slice(0,16),(C==null?void 0:C.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:C=>{h(C.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(([C,L])=>s.jsx("option",{value:C,children:L},C))]}),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(Ve,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(ms,{children:[t.map(C=>s.jsxs(xt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(je,{children:s.jsx(T,{userId:C.userId,nickname:C.userNickname,avatar:C.userAvatar})}),s.jsx(je,{children:C.matchedUserId?s.jsx(T,{userId:C.matchedUserId,nickname:C.matchedNickname,avatar:C.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(je,{children:s.jsx(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Lj[C.matchType]||C.matchType})}),s.jsxs(je,{className:"text-sm",children:[C.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&s.jsx("span",{className:"text-gray-600",children:"-"})]}),s.jsx(je,{className:"text-gray-400",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"})]},C.id)),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(xs,{page:a,totalPages:k,total:n,pageSize:o,onPageChange:i,onPageSizeChange:C=>{c(C),i(1)}})]})})}),s.jsx(py,{open:!!N,onClose:()=>w(null),userId:N,onUserUpdated:v})]})}function cH(){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(lH,{}),t==="pool"&&s.jsx(oH,{})]})}const Oj={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(!0),[f,m]=g.useState("investor"),[x,b]=g.useState(null);async function N(){h(!0);try{const T=new URLSearchParams({page:String(a),pageSize:String(o),matchType:f}),C=await Le(`/api/db/match-records?${T}`);C!=null&&C.success&&(e(C.records||[]),r(C.total??0))}catch(T){console.error(T)}finally{h(!1)}}g.useEffect(()=>{N()},[a,f]);const w=async T=>{if(!T.phone&&!T.wechatId){q.info("该记录无联系方式,无法推送到存客宝");return}b(T.id);try{const C=await bt("/api/ckb/join",{type:T.matchType||"investor",phone:T.phone||"",wechat:T.wechatId||"",userId:T.userId,name:T.userNickname||""});q.error((C==null?void 0:C.message)||(C!=null&&C.success?"推送成功":"推送失败"))}catch(C){q.error("推送失败: "+(C instanceof Error?C.message:"网络错误"))}finally{b(null)}},v=Math.ceil(n/o)||1,k=T=>!!(T.phone||T.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:T=>{m(T.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(([T,C])=>s.jsx("option",{value:T,children:C},T))}),s.jsxs(G,{onClick:N,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"时间"}),s.jsx(Se,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(ms,{children:[t.map(T=>{var C,L;return s.jsxs(xt,{className:`border-gray-700/50 ${k(T)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(je,{className:"text-white",children:T.userNickname||((C=T.userId)==null?void 0:C.slice(0,12))}),s.jsx(je,{className:"text-white",children:T.matchedNickname||((L=T.matchedUserId)==null?void 0:L.slice(0,12))}),s.jsx(je,{children:s.jsx(Be,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Oj[T.matchType]||T.matchType})}),s.jsxs(je,{className:"text-sm",children:[T.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",T.phone]}),T.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",T.wechatId]}),!T.phone&&!T.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(je,{className:"text-gray-400 text-sm",children:T.createdAt?new Date(T.createdAt).toLocaleString():"-"}),s.jsx(je,{className:"text-right",children:k(T)?s.jsxs(G,{size:"sm",onClick:()=>w(T),disabled:x===T.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(xA,{className:"w-3 h-3 mr-1"}),x===T.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},T.id)}),t.length===0&&s.jsx(xt,{children:s.jsx(je,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(xs,{page:a,totalPages:v,total:n,pageSize:o,onPageChange:i,onPageSizeChange:T=>{c(T),i(1)}})]})})})]})}const Dj={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},uH={single:"单次",half_year:"半年",year:"年度"};function hH(){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 Le(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(G,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(De,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"ID"}),s.jsx(Se,{className:"text-gray-400",children:"用户ID"}),s.jsx(Se,{className:"text-gray-400",children:"导师ID"}),s.jsx(Se,{className:"text-gray-400",children:"类型"}),s.jsx(Se,{className:"text-gray-400",children:"金额"}),s.jsx(Se,{className:"text-gray-400",children:"状态"}),s.jsx(Se,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(ms,{children:[t.map(c=>s.jsxs(xt,{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:uH[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(xt,{children:s.jsx(je,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function fH(){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(hH,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(J4,{embedded:!0})})]})}function pH(){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 Le(`/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(Ve,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(De,{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(Ve,{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(fs,{children:[s.jsx(ps,{children:s.jsxs(xt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(Se,{className:"text-gray-400",children:"发起人"}),s.jsx(Se,{className:"text-gray-400",children:"匹配到"}),s.jsx(Se,{className:"text-gray-400",children:"联系方式"}),s.jsx(Se,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(ms,{children:[t.map(x=>s.jsxs(xt,{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(xt,{children:s.jsx(je,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(xs,{page:a,totalPages:m,total:n,pageSize:o,onPageChange:i,onPageSizeChange:x=>{c(x),i(1)}})]})})})]})}const mH=["partner","investor","mentor","team"],Lg=[{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 xH({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,T]=g.useState([]),[C,L]=g.useState({}),[R,U]=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 Lg.forEach(Y=>{I[Y.key]=C[Y.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),I},[C]),z=I=>{const Y=r.trim(),F=i.trim();return I<=3?{type:mH[I],phone:Y||void 0,wechat:F||void 0,userId:"admin_test",name:"后台测试"}:I===4?{matchType:"partner",phone:Y||void 0,wechat:F||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:I===5?{phone:Y||void 0,wechatId:F||void 0,userId:"admin_test",name:"后台测试"}:{}};async function O(){N(!0);try{const[I,Y,F]=await Promise.all([Le("/api/db/config/full?key=ckb_config"),Le("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Le("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),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),Y!=null&&Y.success&&v(Y.records||[]),F!=null&&F.success&&T(F.records||[])}finally{N(!1)}}g.useEffect(()=>{n(t)},[t]),g.useEffect(()=>{O()},[]);const Q=g.useMemo(()=>{const I=V=>(V||"").replace(/\D/g,"")||"",Y=V=>{const W=I(V.phone);if(W)return`phone:${W}`;const fe=(V.userId||"").trim();if(fe)return`user:${fe}`;const he=(V.wechatId||"").trim();return he?`wechat:${he}`:`row:${V.id}`},F=[...k].sort((V,W)=>{const fe=V.createdAt?new Date(V.createdAt).getTime():0;return(W.createdAt?new Date(W.createdAt).getTime():0)-fe}),xe=new Set,X=[];for(const V of F){const W=Y(V);xe.has(W)||(xe.add(W),X.push(V))}return X},[k]);async function re(){x(!0);try{const I=await bt("/api/db/config",{key:"ckb_config",value:{routes:P,docNotes:c,docContent:h},description:"存客宝接口配置"});q.error((I==null?void 0:I.success)!==!1?"存客宝配置已保存":`保存失败: ${(I==null?void 0:I.error)||"未知错误"}`)}catch(I){q.error(`保存失败: ${I instanceof Error?I.message:"网络错误"}`)}finally{x(!1)}}const D=(I,Y)=>{L(F=>({...F,[I]:{...P[I],...Y}}))},ne=async I=>{const Y=R[I];if(Y.method==="POST"&&!r.trim()&&!i.trim()){q.error("请填写测试手机号");return}const F=[...R];F[I]={...Y,status:"testing",message:void 0,responseTime:void 0},U(F);const xe=performance.now();try{const X=Y.method==="GET"?await Le(Y.endpoint):await bt(Y.endpoint,z(I)),V=Math.round(performance.now()-xe),W=(X==null?void 0:X.message)||"",fe=(X==null?void 0:X.success)===!0||W.includes("已存在")||W.includes("已加入")||W.includes("已提交"),he=[...R];he[I]={...Y,status:fe?"success":"error",message:W||(fe?"正常":"异常"),responseTime:V},U(he),await O()}catch(X){const V=Math.round(performance.now()-xe),W=[...R];W[I]={...Y,status:"error",message:X instanceof Error?X.message:"失败",responseTime:V},U(W)}},le=async()=>{if(!r.trim()&&!i.trim()){q.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(Bl,{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:Y}),F?s.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto leading-relaxed",children:F}):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(De,{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(Be,{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(Vo,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(G,{onClick:()=>O(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${b?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:re,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{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,Y])=>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:Y},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:Q.length}),k.length!==Q.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:Lg.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>Q.length&&s.jsxs("p",{className:"text-xs text-gray-500",children:["已合并 ",k.length-Q.length," 条重复(同手机号或同用户 ID 仅保留最近一条)"]}),me(Q,"暂无有联系方式线索","存客宝留资同步后显示;完整列表与筛选请前往「用户管理 → 获客列表」。")]}),e==="config"&&s.jsx("div",{className:"space-y-4",children:Lg.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(Be,{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(te,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiUrl,onChange:Y=>D(I.key,{apiUrl:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiKey,onChange:Y=>D(I.key,{apiKey:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].source,onChange:Y=>D(I.key,{source:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].tags,onChange:Y=>D(I.key,{tags:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].siteTags,onChange:Y=>D(I.key,{siteTags:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].notes,onChange:Y=>D(I.key,{notes:Y.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(Bl,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(oe,{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(te,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:I=>o(I.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(G,{onClick:le,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(Ho,{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,Y)=>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(Ve,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),I.status==="success"&&s.jsx(Zj,{className:"w-3 h-3 text-green-400 shrink-0"}),I.status==="error"&&s.jsx(tk,{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:()=>ne(Y),disabled:I.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${I.endpoint}-${Y}`))})]}),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(Vo,{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 gH=[{id:"partner",label:"找伙伴",icon:Kn,desc:"匹配池与记录"},{id:"resource",label:"资源对接",icon:uM,desc:"人脉资源"},{id:"mentor",label:"导师预约",icon:lM,desc:"预约与管理"},{id:"team",label:"团队招募",icon:Qc,desc:"团队协作"}];function yH(){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(Kn,{className:"w-5 h-5 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"匹配、获客、导师与团队管理 · 汇总数据见「仪表盘」与「推广中心」"})]}),s.jsxs(G,{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(Ua,{className:"w-3.5 h-3.5 mr-1.5"}),"存客宝",s.jsx(Li,{className:`w-3 h-3 ml-1 transition-transform ${n?"rotate-90":""}`})]})]}),n&&s.jsx(xH,{initialTab:"overview"}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:gH.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(cH,{}),t==="resource"&&s.jsx(dH,{}),t==="mentor"&&s.jsx(fH,{}),t==="team"&&s.jsx(pH,{})]})}function bH(){const[t,e]=g.useState(""),n=qa(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,T]=g.useState(!1),[C,L]=g.useState(""),[R,U]=g.useState(!1),[P,z]=g.useState(null),O=g.useCallback(async()=>{N(!0),v(null);try{const D=new URLSearchParams;D.set("page",String(r)),D.set("pageSize",String(i)),n.trim()&&D.set("search",n.trim());const ne=await Le(`/api/admin/open-platform/keys?${D.toString()}`);if(!ne.success){v(ne.error||"加载失败"),x([]);return}x(ne.records||[]),u(ne.total??0),f(ne.totalPages??1)}catch(D){v(D instanceof Error?D.message:"网络错误"),x([])}finally{N(!1)}},[r,i,n]);g.useEffect(()=>{O()},[O]);const Q=async()=>{var D;U(!0);try{const ne=await bt("/api/admin/open-platform/keys",{name:C.trim()||"未命名密钥"});if(!ne.success||!((D=ne.data)!=null&&D.secret)){q.error(ne.error||"创建失败");return}T(!1),L(""),z({secret:ne.data.secret,name:ne.data.name||""}),q.success("密钥已创建,请立即复制保存"),O()}catch(ne){q.error(ne instanceof Error?ne.message:"创建失败")}finally{U(!1)}},re=async D=>{if(window.confirm("确定吊销该密钥?吊销后无法恢复。"))try{const ne=await bt(`/api/admin/open-platform/keys/${D}/revoke`,{});if(!ne.success){q.error(ne.error||"操作失败");return}q.success("已吊销"),O()}catch(ne){q.error(ne instanceof Error?ne.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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{placeholder:"搜索名称、密钥前缀…",value:t,onChange:D=>{e(D.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(G,{type:"button",variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>O(),disabled:b,children:[s.jsx(Ve,{className:`w-4 h-4 mr-1 ${b?"animate-spin":""}`}),"刷新"]}),s.jsxs(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>T(!0),children:[s.jsx(Rn,{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(D=>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:D.id}),s.jsx("td",{className:"px-4 py-3",children:D.name}),s.jsxs("td",{className:"px-4 py-3 font-mono text-[#38bdac]",children:[D.keyPrefix,"••••••••"]}),s.jsx("td",{className:"px-4 py-3 text-gray-400 text-xs",children:D.createdAt?new Date(D.createdAt).toLocaleString():"—"}),s.jsx("td",{className:"px-4 py-3",children:D.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:!D.revokedAt&&s.jsxs("button",{type:"button",onClick:()=>re(D.id),className:"inline-flex items-center gap-1 text-amber-400 hover:text-amber-300 text-xs",children:[s.jsx(yT,{className:"w-3.5 h-3.5"}),"吊销"]})})]},D.id))})]})}),s.jsx(xs,{page:r,totalPages:Math.max(1,h),total:c,pageSize:i,onPageChange:a,onPageSizeChange:D=>{o(D),a(1)}})]}),s.jsx(Lt,{open:k,onOpenChange:T,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-600 text-white max-w-md",children:[s.jsxs(Ot,{children:[s.jsxs(Dt,{className:"flex items-center gap-2",children:[s.jsx(Au,{className:"w-5 h-5 text-[#38bdac]"}),"新建 API Key"]}),s.jsx(Wo,{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:C,onChange:D=>L(D.target.value)})})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>T(!1),children:"取消"}),s.jsx(G,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:Q,disabled:R,children:R?"创建中…":"创建"})]})]})}),s.jsx(Lt,{open:!!P,onOpenChange:D=>!D&&z(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-600 text-white max-w-lg",children:[s.jsxs(Ot,{children:[s.jsx(Dt,{children:"请保存密钥"}),s.jsxs(Wo,{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(nn,{className:"gap-2",children:[s.jsx(G,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>{P!=null&&P.secret&&(navigator.clipboard.writeText(P.secret),q.success("已复制到剪贴板"))},children:"复制密钥"}),s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>z(null),children:"已保存"})]})]})})]})}const vH=[{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=vH.filter(t=>t.path.startsWith("/api/open"));function Og({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 NH({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(Bi,{className:"w-4 h-4 text-gray-500 shrink-0"}):s.jsx(Li,{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(` +- 成功:code=200,message=新增成功 或 已存在`;function xH({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,T]=g.useState([]),[C,L]=g.useState({}),[R,U]=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 Lg.forEach(Y=>{I[Y.key]=C[Y.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),I},[C]),F=I=>{const Y=r.trim(),B=i.trim();return I<=3?{type:mH[I],phone:Y||void 0,wechat:B||void 0,userId:"admin_test",name:"后台测试"}:I===4?{matchType:"partner",phone:Y||void 0,wechat:B||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:I===5?{phone:Y||void 0,wechatId:B||void 0,userId:"admin_test",name:"后台测试"}:{}};async function O(){N(!0);try{const[I,Y,B]=await Promise.all([Le("/api/db/config/full?key=ckb_config"),Le("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Le("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),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),Y!=null&&Y.success&&v(Y.records||[]),B!=null&&B.success&&T(B.records||[])}finally{N(!1)}}g.useEffect(()=>{n(t)},[t]),g.useEffect(()=>{O()},[]);const Q=g.useMemo(()=>{const I=V=>(V||"").replace(/\D/g,"")||"",Y=V=>{const W=I(V.phone);if(W)return`phone:${W}`;const fe=(V.userId||"").trim();if(fe)return`user:${fe}`;const he=(V.wechatId||"").trim();return he?`wechat:${he}`:`row:${V.id}`},B=[...k].sort((V,W)=>{const fe=V.createdAt?new Date(V.createdAt).getTime():0;return(W.createdAt?new Date(W.createdAt).getTime():0)-fe}),xe=new Set,X=[];for(const V of B){const W=Y(V);xe.has(W)||(xe.add(W),X.push(V))}return X},[k]);async function re(){x(!0);try{const I=await bt("/api/db/config",{key:"ckb_config",value:{routes:P,docNotes:c,docContent:h},description:"存客宝接口配置"});q.error((I==null?void 0:I.success)!==!1?"存客宝配置已保存":`保存失败: ${(I==null?void 0:I.error)||"未知错误"}`)}catch(I){q.error(`保存失败: ${I instanceof Error?I.message:"网络错误"}`)}finally{x(!1)}}const D=(I,Y)=>{L(B=>({...B,[I]:{...P[I],...Y}}))},ne=async I=>{const Y=R[I];if(Y.method==="POST"&&!r.trim()&&!i.trim()){q.error("请填写测试手机号");return}const B=[...R];B[I]={...Y,status:"testing",message:void 0,responseTime:void 0},U(B);const xe=performance.now();try{const X=Y.method==="GET"?await Le(Y.endpoint):await bt(Y.endpoint,F(I)),V=Math.round(performance.now()-xe),W=(X==null?void 0:X.message)||"",fe=(X==null?void 0:X.success)===!0||W.includes("已存在")||W.includes("已加入")||W.includes("已提交"),he=[...R];he[I]={...Y,status:fe?"success":"error",message:W||(fe?"正常":"异常"),responseTime:V},U(he),await O()}catch(X){const V=Math.round(performance.now()-xe),W=[...R];W[I]={...Y,status:"error",message:X instanceof Error?X.message:"失败",responseTime:V},U(W)}},le=async()=>{if(!r.trim()&&!i.trim()){q.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(Bl,{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:Y}),B?s.jsx("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto leading-relaxed",children:B}):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(De,{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(Be,{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(Vo,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(G,{onClick:()=>O(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ve,{className:`w-3.5 h-3.5 mr-1 ${b?"animate-spin":""}`})," 刷新"]}),s.jsxs(G,{onClick:re,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Tn,{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,Y])=>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:Y},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:Q.length}),k.length!==Q.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:Lg.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>Q.length&&s.jsxs("p",{className:"text-xs text-gray-500",children:["已合并 ",k.length-Q.length," 条重复(同手机号或同用户 ID 仅保留最近一条)"]}),me(Q,"暂无有联系方式线索","存客宝留资同步后显示;完整列表与筛选请前往「用户管理 → 获客列表」。")]}),e==="config"&&s.jsx("div",{className:"space-y-4",children:Lg.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(Be,{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(te,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiUrl,onChange:Y=>D(I.key,{apiUrl:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].apiKey,onChange:Y=>D(I.key,{apiKey:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].source,onChange:Y=>D(I.key,{source:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].tags,onChange:Y=>D(I.key,{tags:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].siteTags,onChange:Y=>D(I.key,{siteTags:Y.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:P[I.key].notes,onChange:Y=>D(I.key,{notes:Y.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(Bl,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(te,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(oe,{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(te,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:i,onChange:I=>o(I.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(G,{onClick:le,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(Ho,{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,Y)=>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(Ve,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),I.status==="success"&&s.jsx(Zj,{className:"w-3 h-3 text-green-400 shrink-0"}),I.status==="error"&&s.jsx(tk,{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:()=>ne(Y),disabled:I.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${I.endpoint}-${Y}`))})]}),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(Vo,{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 gH=[{id:"partner",label:"找伙伴",icon:qn,desc:"匹配池与记录"},{id:"resource",label:"资源对接",icon:uM,desc:"人脉资源"},{id:"mentor",label:"导师预约",icon:lM,desc:"预约与管理"},{id:"team",label:"团队招募",icon:Qc,desc:"团队协作"}];function yH(){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(qn,{className:"w-5 h-5 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:"匹配、获客、导师与团队管理 · 汇总数据见「仪表盘」与「推广中心」"})]}),s.jsxs(G,{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(Ua,{className:"w-3.5 h-3.5 mr-1.5"}),"存客宝",s.jsx(Li,{className:`w-3 h-3 ml-1 transition-transform ${n?"rotate-90":""}`})]})]}),n&&s.jsx(xH,{initialTab:"overview"}),s.jsx("div",{className:"flex gap-1 mb-6 bg-[#0a1628] rounded-lg p-1 border border-gray-700/40",children:gH.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(cH,{}),t==="resource"&&s.jsx(dH,{}),t==="mentor"&&s.jsx(fH,{}),t==="team"&&s.jsx(pH,{})]})}function bH(){const[t,e]=g.useState(""),n=qa(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,T]=g.useState(!1),[C,L]=g.useState(""),[R,U]=g.useState(!1),[P,F]=g.useState(null),O=g.useCallback(async()=>{N(!0),v(null);try{const D=new URLSearchParams;D.set("page",String(r)),D.set("pageSize",String(i)),n.trim()&&D.set("search",n.trim());const ne=await Le(`/api/admin/open-platform/keys?${D.toString()}`);if(!ne.success){v(ne.error||"加载失败"),x([]);return}x(ne.records||[]),u(ne.total??0),f(ne.totalPages??1)}catch(D){v(D instanceof Error?D.message:"网络错误"),x([])}finally{N(!1)}},[r,i,n]);g.useEffect(()=>{O()},[O]);const Q=async()=>{var D;U(!0);try{const ne=await bt("/api/admin/open-platform/keys",{name:C.trim()||"未命名密钥"});if(!ne.success||!((D=ne.data)!=null&&D.secret)){q.error(ne.error||"创建失败");return}T(!1),L(""),F({secret:ne.data.secret,name:ne.data.name||""}),q.success("密钥已创建,请立即复制保存"),O()}catch(ne){q.error(ne instanceof Error?ne.message:"创建失败")}finally{U(!1)}},re=async D=>{if(window.confirm("确定吊销该密钥?吊销后无法恢复。"))try{const ne=await bt(`/api/admin/open-platform/keys/${D}/revoke`,{});if(!ne.success){q.error(ne.error||"操作失败");return}q.success("已吊销"),O()}catch(ne){q.error(ne instanceof Error?ne.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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{placeholder:"搜索名称、密钥前缀…",value:t,onChange:D=>{e(D.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(G,{type:"button",variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>O(),disabled:b,children:[s.jsx(Ve,{className:`w-4 h-4 mr-1 ${b?"animate-spin":""}`}),"刷新"]}),s.jsxs(G,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>T(!0),children:[s.jsx(Rn,{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(D=>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:D.id}),s.jsx("td",{className:"px-4 py-3",children:D.name}),s.jsxs("td",{className:"px-4 py-3 font-mono text-[#38bdac]",children:[D.keyPrefix,"••••••••"]}),s.jsx("td",{className:"px-4 py-3 text-gray-400 text-xs",children:D.createdAt?new Date(D.createdAt).toLocaleString():"—"}),s.jsx("td",{className:"px-4 py-3",children:D.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:!D.revokedAt&&s.jsxs("button",{type:"button",onClick:()=>re(D.id),className:"inline-flex items-center gap-1 text-amber-400 hover:text-amber-300 text-xs",children:[s.jsx(yT,{className:"w-3.5 h-3.5"}),"吊销"]})})]},D.id))})]})}),s.jsx(xs,{page:r,totalPages:Math.max(1,h),total:c,pageSize:i,onPageChange:a,onPageSizeChange:D=>{o(D),a(1)}})]}),s.jsx(Lt,{open:k,onOpenChange:T,children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-600 text-white max-w-md",children:[s.jsxs(Ot,{children:[s.jsxs(Dt,{className:"flex items-center gap-2",children:[s.jsx(Au,{className:"w-5 h-5 text-[#38bdac]"}),"新建 API Key"]}),s.jsx(Wo,{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:C,onChange:D=>L(D.target.value)})})]}),s.jsxs(nn,{children:[s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>T(!1),children:"取消"}),s.jsx(G,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:Q,disabled:R,children:R?"创建中…":"创建"})]})]})}),s.jsx(Lt,{open:!!P,onOpenChange:D=>!D&&F(null),children:s.jsxs(It,{className:"bg-[#0f2137] border-gray-600 text-white max-w-lg",children:[s.jsxs(Ot,{children:[s.jsx(Dt,{children:"请保存密钥"}),s.jsxs(Wo,{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(nn,{className:"gap-2",children:[s.jsx(G,{className:"bg-[#38bdac] hover:bg-[#2da898] text-[#0a1628]",onClick:()=>{P!=null&&P.secret&&(navigator.clipboard.writeText(P.secret),q.success("已复制到剪贴板"))},children:"复制密钥"}),s.jsx(G,{variant:"outline",className:"border-gray-600",onClick:()=>F(null),children:"已保存"})]})]})})]})}const vH=[{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=vH.filter(t=>t.path.startsWith("/api/open"));function Og({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 NH({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(Bi,{className:"w-4 h-4 text-gray-500 shrink-0"}):s.jsx(Li,{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(Og,{title:"Query 参数",rows:t.queryParams||[]}),s.jsx(Og,{title:"请求体字段",rows:t.requestBody||[]}),s.jsx(Og,{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 wH(){const[t,e]=g.useState(""),n=qa(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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{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(NH,{item:w,open:!!c[w.id],onToggle:()=>N(w.id)},w.id))}),s.jsx(xs,{page:r,totalPages:m,total:f,pageSize:i,onPageChange:a,onPageSizeChange:w=>{o(w),a(1)}})]})}function jH(){const[t,e]=g.useState(""),n=qa(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,T]=g.useState({}),C=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 U=await Le(`/api/admin/open-platform/logs?${R.toString()}`);if(!U.success){v(U.error||"加载失败"),x([]);return}x(U.records||[]),u(U.total??0),f(U.totalPages??1)}catch(R){v(R instanceof Error?R.message:"网络错误"),x([])}finally{N(!1)}},[r,i,n]);g.useEffect(()=>{C()},[C]);const L=R=>{T(U=>({...U,[R]:!U[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(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{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:()=>C(),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(Ve,{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(Bi,{className:"w-4 h-4"}):s.jsx(Li,{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(xs,{page:r,totalPages:Math.max(1,h),total:c,pageSize:i,onPageChange:a,onPageSizeChange:R=>{o(R),a(1)}})]})]})}function kH(){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(_i,{to:"/api-docs",className:"text-sm text-[#38bdac] hover:underline inline-flex items-center gap-1 shrink-0",children:[s.jsx(Ua,{className:"w-4 h-4"}),"管理端内部 API 文档"]})]}),s.jsxs(Wl,{defaultValue:"keys",className:"w-full",children:[s.jsxs(Ko,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1 flex flex-wrap h-auto gap-1",children:[s.jsxs(Ut,{value:"keys",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(Au,{className:"w-4 h-4 mr-1.5 inline"}),"API Key"]}),s.jsxs(Ut,{value:"docs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(Z0,{className:"w-4 h-4 mr-1.5 inline"}),"接口文档"]}),s.jsxs(Ut,{value:"logs",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(ak,{className:"w-4 h-4 mr-1.5 inline"}),"请求明细"]})]}),s.jsx(Wt,{value:"keys",className:"mt-0 outline-none",children:s.jsx(bH,{})}),s.jsx(Wt,{value:"docs",className:"mt-0 outline-none",children:s.jsx(wH,{})}),s.jsx(Wt,{value:"logs",className:"mt-0 outline-none",children:s.jsx(jH,{})})]})]})}function SH(){const t=Xo();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(Xj,{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(G,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(_i,{to:"/",children:[s.jsx(vM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function CH(){return s.jsxs(YE,{children:[s.jsx(rn,{path:"/login",element:s.jsx(eI,{})}),s.jsxs(rn,{path:"/",element:s.jsx(sP,{}),children:[s.jsx(rn,{index:!0,element:s.jsx(qh,{to:"/dashboard",replace:!0})}),s.jsx(rn,{path:"dashboard",element:s.jsx(f8,{})}),s.jsx(rn,{path:"orders",element:s.jsx(p8,{})}),s.jsx(rn,{path:"users",element:s.jsx(j8,{})}),s.jsx(rn,{path:"distribution",element:s.jsx(W8,{})}),s.jsx(rn,{path:"withdrawals",element:s.jsx(K8,{})}),s.jsx(rn,{path:"content",element:s.jsx(CV,{})}),s.jsx(rn,{path:"referral-settings",element:s.jsx(W2,{})}),s.jsx(rn,{path:"author-settings",element:s.jsx(qh,{to:"/settings?tab=author",replace:!0})}),s.jsx(rn,{path:"vip-roles",element:s.jsx(rH,{})}),s.jsx(rn,{path:"mentors",element:s.jsx(J4,{})}),s.jsx(rn,{path:"mentor-consultations",element:s.jsx(aH,{})}),s.jsx(rn,{path:"admin-users",element:s.jsx(qh,{to:"/settings?tab=admin",replace:!0})}),s.jsx(rn,{path:"settings",element:s.jsx(GV,{})}),s.jsx(rn,{path:"payment",element:s.jsx(JV,{})}),s.jsx(rn,{path:"site",element:s.jsx(ZV,{})}),s.jsx(rn,{path:"qrcodes",element:s.jsx(eH,{})}),s.jsx(rn,{path:"find-partner",element:s.jsx(yH,{})}),s.jsx(rn,{path:"match",element:s.jsx(nH,{})}),s.jsx(rn,{path:"match-records",element:s.jsx(sH,{})}),s.jsx(rn,{path:"api-doc",element:s.jsx(qh,{to:"/api-docs",replace:!0})}),s.jsx(rn,{path:"api-docs",element:s.jsx(G4,{})}),s.jsx(rn,{path:"open-platform",element:s.jsx(kH,{})})]}),s.jsx(rn,{path:"*",element:s.jsx(SH,{})})]})}nE.createRoot(document.getElementById("root")).render(s.jsx(g.StrictMode,{children:s.jsx(aT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(CH,{})})})); diff --git a/soul-admin/dist/assets/index-CLoQZZ8i.css b/soul-admin/dist/assets/index-CLoQZZ8i.css deleted file mode 100644 index 0bfe83ca..00000000 --- a/soul-admin/dist/assets/index-CLoQZZ8i.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-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-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-CuUAjfcM.css b/soul-admin/dist/assets/index-CuUAjfcM.css new file mode 100644 index 00000000..70994702 --- /dev/null +++ b/soul-admin/dist/assets/index-CuUAjfcM.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-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/index.html b/soul-admin/dist/index.html index f31597aa..c55e4ada 100644 --- a/soul-admin/dist/index.html +++ b/soul-admin/dist/index.html @@ -4,8 +4,8 @@ 管理后台 - Soul创业派对 - - + +
diff --git a/soul-admin/src/components/RichEditor.tsx b/soul-admin/src/components/RichEditor.tsx index 7e2d0480..b5409a83 100644 --- a/soul-admin/src/components/RichEditor.tsx +++ b/soul-admin/src/components/RichEditor.tsx @@ -37,7 +37,7 @@ export interface LinkTagItem { label: string aliases?: string url: string - type: 'url' | 'miniprogram' | 'ckb' | 'wxlink' + type: 'url' | 'miniprogram' | 'ckb' | 'wxlink' | 'internal' appId?: string pagePath?: string /** 管理端列表用:库内是否已存目标小程序 AppSecret(接口不下发明文) */ diff --git a/soul-admin/src/pages/content/ContentPage.tsx b/soul-admin/src/pages/content/ContentPage.tsx index 6a4acf40..5ea6afd2 100644 --- a/soul-admin/src/pages/content/ContentPage.tsx +++ b/soul-admin/src/pages/content/ContentPage.tsx @@ -308,7 +308,7 @@ export function ContentPage() { label: '', aliases: '', url: '', - type: 'url' as 'url' | 'miniprogram' | 'ckb' | 'wxlink', + type: 'url' as 'url' | 'miniprogram' | 'ckb' | 'wxlink' | 'internal', appId: '', appSecret: '', pagePath: '', @@ -663,7 +663,7 @@ export function ContentPage() { id: t.tagId, label: t.label, url: t.url, - type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb' | 'wxlink', + type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb' | 'wxlink' | 'internal', appId: t.appId || '', pagePath: t.pagePath || '', hasAppSecret: !!t.hasAppSecret, @@ -750,7 +750,7 @@ export function ContentPage() { label: t.label, aliases: t.aliases || '', url: t.url, - type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb' | 'wxlink', + type: (t.type || 'url') as 'url' | 'miniprogram' | 'ckb' | 'wxlink' | 'internal', appId: t.appId || '', pagePath: t.pagePath || '', hasAppSecret: !!t.hasAppSecret, @@ -3063,9 +3063,9 @@ export function ContentPage() { - 链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝) + 链接标签 — 链接事与物(编辑器内 #标签 可跳转网页/本小程序页/其他小程序/存客宝) -

小程序端点击 #标签 可直接跳转对应链接,进入流量池

+

小程序端点击 #标签 可跳转外链、当前小程序指定页面、或进入流量池

@@ -3174,16 +3174,30 @@ export function ContentPage() { className={`text-[10px] ${ t.type === 'ckb' ? 'bg-green-500/20 text-green-300 border-green-500/30' - : t.type === 'miniprogram' || t.type === 'wxlink' - ? 'bg-[#38bdac]/20 text-[#38bdac] border-[#38bdac]/30' - : 'bg-gray-700 text-gray-300' + : 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' }`} > - {t.type === 'url' ? '网页' : t.type === 'ckb' ? '存客宝' : t.type === 'wxlink' ? '小程序链接' : '小程序'} + {t.type === 'url' + ? '网页' + : t.type === 'internal' + ? '本小程序' + : t.type === 'ckb' + ? '存客宝' + : t.type === 'wxlink' + ? '小程序链接' + : '小程序'} - {t.type === 'miniprogram' ? ( + {t.type === 'internal' ? ( +
+ {t.pagePath || '—'} +
+ ) : t.type === 'miniprogram' ? (
{(() => { const mp = linkedMps.find(m => m.key === t.appId) @@ -3301,7 +3315,7 @@ export function ContentPage() { {linkTagEditing ? '编辑链接标签' : '添加链接标签'} - 配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转。小程序类型需填 mpKey 或微信 AppID;AppSecret 仅存服务端(不下发小程序),供后续开放接口与台账使用。 + 配置后可在富文本编辑器中通过 #标签 插入,并在小程序端点击跳转。「本小程序页面」仅跳转当前小程序内路径;API 跳转小程序类型需填 mpKey 或微信 AppID;AppSecret 仅存服务端(不下发小程序),供后续开放接口与台账使用。 @@ -3343,7 +3357,7 @@ export function ContentPage() { setLinkTagForm((p) => ({ ...p, pagePath: e.target.value }))} + /> + ) : linkTagForm.type === 'wxlink' ? ( 说明:`/app/uploads`、`/app/log` 是容器内目录;本方案已挂载到服务器目录: +> - `/www/wwwroot/self/soul-dev/uploads -> /app/uploads` +> - `/www/wwwroot/self/soul-dev/log -> /app/log` -- **soul-api**:Go 1.25,alpine 3.19 -- **Redis**:7-alpine(与 soul-api 一并打包上传,服务器无需拉取) -- **MySQL**:外部服务,不打包 +## 2) 本地/服务器快速启动 -## 用法 +在 `soul-api/deploy` 目录下执行: -```bash -# 一键部署(蓝绿) -python deploy.py --mode docker +1. 复制环境文件: + - `cp app.env.example app.env` + - 按实际环境填写 `DB_DSN`、微信和管理端密钥 +2. 启动: + - `docker compose up -d --build` +3. 查看状态: + - `docker compose ps` + - `docker compose logs -f app` +4. 健康检查: + - `http://服务器IP:APP_PORT/health` -# 使用本地 Go 编译 -python deploy.py --mode docker --local-go +## 3) 给宝塔的推荐方式 -# 本地启动 Redis -docker compose -f deploy/docker-compose.yml up -d -``` +- 方式 A(推荐):在宝塔 Docker/Compose 项目里直接使用 `deploy/docker-compose.yml` +- 方式 B:先 `docker build -f deploy/Dockerfile -t soul-api:latest ..`,再在宝塔按镜像创建容器 + +## 4) 目录结构(deploy) + +- `deploy/Dockerfile`:多阶段构建 Go 应用镜像 +- `deploy/docker-compose.yml`:单容器运行与数据卷持久化 +- `deploy/app.env.example`:环境变量模板 + +## 5) 离线镜像部署(不走远端拉取) + +你可以把本地导出的 `deploy/soul-api_latest.tar` 上传到服务器,然后: + +1. 导入镜像: + - `docker load -i soul-api_latest.tar` +2. 准备配置: + - 把 `deploy/app.env` 放到服务器同目录(或按需改 `env_file`) +3. 启动: + - `docker compose up -d --no-build` + +> 这种方式不会再从 Docker Hub 拉取 `soul-api` 业务镜像;直接使用你导入的本地镜像运行。 diff --git a/soul-api/deploy/deploy-runner-remote.sh b/soul-api/deploy/deploy-runner-remote.sh deleted file mode 100644 index e02e1aac..00000000 --- a/soul-api/deploy/deploy-runner-remote.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# soul-api Runner 部署脚本(在宿主机执行) -# 用法:./deploy-runner-remote.sh [path-to-deploy.tar.gz] -# 默认 tar 路径:${DEPLOY_DOCKER_PATH:-/www/wwwroot/self/soul-dev}/soul_api_deploy.tar.gz -# 仅负责:将 tar 拷入容器并触发容器内 deploy.sh,不涉及宝塔/Nginx 配置 - -set -e -CONTAINER="${DEPLOY_RUNNER_CONTAINER:-soul-api-runner}" -DEPLOY_PATH="${DEPLOY_DOCKER_PATH:-/www/wwwroot/self/soul-dev}" -TAR="${1:-$DEPLOY_PATH/soul_api_deploy.tar.gz}" - -if [ -z "$TAR" ] || [ ! -f "$TAR" ]; then - echo "[ERROR] 用法: $0 [path-to-deploy.tar.gz]" - echo " 默认: $DEPLOY_PATH/soul_api_deploy.tar.gz" - exit 1 -fi - -echo "[1/2] 拷贝部署包到容器 ..." -docker cp "$TAR" "$CONTAINER:/tmp/incoming.tar.gz" - -echo "[2/2] 执行容器内红蓝切换 ..." -docker exec "$CONTAINER" /app/deploy.sh /tmp/incoming.tar.gz - -rm -f "$TAR" -echo "" -echo "[SUCCESS] 部署完成,宝塔代理 9001 无需修改" diff --git a/soul-api/deploy/docker-compose.bluegreen.yml b/soul-api/deploy/docker-compose.bluegreen.yml deleted file mode 100644 index 1f210d53..00000000 --- a/soul-api/deploy/docker-compose.bluegreen.yml +++ /dev/null @@ -1,62 +0,0 @@ -# soul-api 蓝绿部署 - 支持无缝切换 -# blue=9001, green=9002,部署时先启新实例,健康检查通过后切换 Nginx,再停旧实例 -# 用法:见 deploy.py --mode docker - -services: - soul-api-blue: - image: soul-api:latest - container_name: soul-api-blue - restart: "no" - environment: - - REDIS_URL=redis://:soul-docker-redis@redis:6379/0 - - GIN_MODE=release - - APP_ENV=production - # 测试/预发布环境可设 SKIP_PROD_SECRET_CHECK=staging,正式生产请使用真实密钥并移除此项 - - SKIP_PROD_SECRET_CHECK=staging - ports: - - "9001:8080" - volumes: - - soul_uploads:/app/uploads - depends_on: - - redis - healthcheck: - test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8080/health"] - interval: 5s - timeout: 5s - retries: 10 - start_period: 15s - - soul-api-green: - image: soul-api:latest - container_name: soul-api-green - restart: "no" - environment: - - REDIS_URL=redis://:soul-docker-redis@redis:6379/0 - - GIN_MODE=release - - APP_ENV=production - - SKIP_PROD_SECRET_CHECK=staging - ports: - - "9002:8080" - volumes: - - soul_uploads:/app/uploads - depends_on: - - redis - healthcheck: - test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8080/health"] - interval: 5s - timeout: 5s - retries: 10 - start_period: 15s - - redis: - # 与 soul-api 一并打包上传,使用本地 DaoCloud 镜像名(与 pack 中 docker save 一致) - image: docker.m.daocloud.io/library/redis:7-alpine - container_name: soul-redis - command: redis-server --appendonly yes --requirepass "soul-docker-redis" - volumes: - - redis_data:/data - restart: unless-stopped - -volumes: - redis_data: - soul_uploads: diff --git a/soul-api/deploy/docker-compose.production.yml b/soul-api/deploy/docker-compose.production.yml deleted file mode 100644 index e772f308..00000000 --- a/soul-api/deploy/docker-compose.production.yml +++ /dev/null @@ -1,42 +0,0 @@ -# soul-api 生产环境 Docker 部署 -# 用法:在 soul-api 根目录执行 -# docker compose -f deploy/docker-compose.production.yml up -d -# -# Redis 7-alpine:与宝塔已有 Redis 隔离,仅容器内网使用 - -services: - soul-api: - build: - context: .. - dockerfile: deploy/Dockerfile - image: soul-api:latest - container_name: soul-api - restart: unless-stopped - environment: - - REDIS_URL=redis://:soul-docker-redis@redis:6379/0 - - GIN_MODE=release - - APP_ENV=production - ports: - - "8080:8080" - volumes: - - soul_uploads:/app/uploads - depends_on: - - redis - healthcheck: - test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8080/health"] - interval: 30s - timeout: 10s - retries: 3 - start_period: 10s - - redis: - image: redis:7-alpine - container_name: soul-redis - command: redis-server --appendonly yes --requirepass "soul-docker-redis" - volumes: - - redis_data:/data - restart: unless-stopped - -volumes: - redis_data: - soul_uploads: diff --git a/soul-api/deploy/docker-compose.runner.standalone.yml b/soul-api/deploy/docker-compose.runner.standalone.yml deleted file mode 100644 index ba73ac54..00000000 --- a/soul-api/deploy/docker-compose.runner.standalone.yml +++ /dev/null @@ -1,14 +0,0 @@ -# soul-api Runner 部署(仅用已加载镜像,无 build) -# 用于 devloy.py --init-runner 推送镜像后启动 - -services: - soul-api-runner: - image: soul-api-runner:latest - container_name: soul-api-runner - network_mode: host - volumes: - - soul_runner_data:/app - restart: unless-stopped - -volumes: - soul_runner_data: diff --git a/soul-api/deploy/docker-compose.runner.yml b/soul-api/deploy/docker-compose.runner.yml deleted file mode 100644 index d27b3882..00000000 --- a/soul-api/deploy/docker-compose.runner.yml +++ /dev/null @@ -1,21 +0,0 @@ -# soul-api Runner 部署 -# 红蓝切换在容器内完成,宝塔固定 proxy_pass 到 127.0.0.1:9001 -# 使用 network_mode: host,无需端口映射,避免 iptables DOCKER 链问题 -# -# 首次启动:docker compose -f docker-compose.runner.yml up -d -# 部署新版本:上传 tar 后执行 deploy-runner-remote.sh - -services: - soul-api-runner: - build: - context: .. - dockerfile: deploy/Dockerfile.runner - image: soul-api-runner:latest - container_name: soul-api-runner - network_mode: host - volumes: - - soul_runner_data:/app - restart: unless-stopped - -volumes: - soul_runner_data: diff --git a/soul-api/deploy/docker-compose.yml b/soul-api/deploy/docker-compose.yml index ee17045c..b87a8d68 100644 --- a/soul-api/deploy/docker-compose.yml +++ b/soul-api/deploy/docker-compose.yml @@ -1,16 +1,23 @@ -# soul-api 本地开发用 Redis -# 用法:docker compose -f deploy/docker-compose.yml up -d +version: "3.8" services: - redis: - image: redis:7-alpine - container_name: soul-redis - ports: - - "6379:6379" - volumes: - - redis_data:/data - command: redis-server --appendonly yes + app: + build: + context: .. + dockerfile: deploy/Dockerfile + image: soul-api:latest + container_name: soul-api restart: unless-stopped - -volumes: - redis_data: + env_file: + - ./app.env + ports: + - "${APP_PORT:-8080}:${PORT:-8080}" + volumes: + - "${HOST_UPLOAD_DIR:-./data/uploads}:/app/uploads" + - "${HOST_LOG_DIR:-./data/log}:/app/log" + healthcheck: + test: ["CMD", "sh", "-lc", "wget -qO- http://127.0.0.1:${PORT:-8080}/health"] + interval: 15s + timeout: 5s + retries: 5 + start_period: 20s diff --git a/soul-api/deploy/docker-deploy-remote.sh b/soul-api/deploy/docker-deploy-remote.sh deleted file mode 100644 index 3613d0ab..00000000 --- a/soul-api/deploy/docker-deploy-remote.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash -# soul-api Docker 蓝绿部署脚本(在服务器上执行) -# 用法:./docker-deploy-remote.sh /tmp/soul_api_image.tar.gz [--skip-nginx] -# --skip-nginx:跳过 Nginx 切换,由宝塔 API 在本地执行 - -set -e -PROJECT_ROOT="${DEPLOY_DOCKER_PATH:-/www/wwwroot/self/soul-dev}" -ACTIVE_FILE="$PROJECT_ROOT/.active" -NGINX_CONF="${DEPLOY_NGINX_CONF:-}" -IMAGE_TAR="${1:-}" -SKIP_NGINX="" -if [ "${2:-}" = "--skip-nginx" ]; then - SKIP_NGINX=1 -fi - -if [ -z "$IMAGE_TAR" ] || [ ! -f "$IMAGE_TAR" ]; then - echo "[ERROR] usage: $0 [--skip-nginx]" - exit 1 -fi - -cd "$PROJECT_ROOT" - -# 兼容 docker-compose / docker compose(不同系统安装不一致) -dc() { - if command -v docker-compose >/dev/null 2>&1; then - docker-compose "$@" - else - docker compose "$@" - fi -} - -# 兼容 curl / wget(健康检查工具不一定都有) -health_ok() { - url="$1" - if command -v curl >/dev/null 2>&1; then - curl -sf "$url" >/dev/null 2>&1 - else - wget -qO- "$url" >/dev/null 2>&1 - fi -} - -# 加载新镜像 -echo "[1/5] 加载 Docker 镜像 ..." -gunzip -c "$IMAGE_TAR" | docker load -rm -f "$IMAGE_TAR" - -# 确定当前活跃实例与待启动实例 -CURRENT="blue" -if [ -f "$ACTIVE_FILE" ]; then - CURRENT=$(cat "$ACTIVE_FILE") -fi -if [ "$CURRENT" = "blue" ]; then - NEW="green" - OLD_PORT=9001 - NEW_PORT=9002 -else - NEW="blue" - OLD_PORT=9002 - NEW_PORT=9001 -fi - -echo "[2/5] 当前活跃: $CURRENT ($OLD_PORT),将启动: $NEW ($NEW_PORT)" - -# 启动新实例 -echo "[3/5] 启动 soul-api-$NEW ..." -# --no-deps:线上 Redis 已在跑,不再让 compose 拉起/重建依赖 -dc -f docker-compose.bluegreen.yml up -d --no-deps "soul-api-$NEW" - -# 等待健康检查(镜像已从 tar.gz 加载,无需联网拉取,最多 120 秒) -echo "[4/5] 等待健康检查 ..." -sleep 5 -for i in $(seq 1 58); do - if health_ok "http://127.0.0.1:$NEW_PORT/health"; then - echo " 健康检查通过 ($((5 + i * 2))s)" - break - fi - sleep 2 - if [ $i -eq 58 ]; then - echo "[ERROR] 健康检查超时(120s),新实例未就绪。可查看: docker-compose -f docker-compose.bluegreen.yml logs soul-api-$NEW" - dc -f docker-compose.bluegreen.yml stop "soul-api-$NEW" - exit 1 - fi -done - -# 切换 Nginx(若配置了 NGINX_CONF):将 proxy_pass 中的端口改为 NEW_PORT -if [ -z "$SKIP_NGINX" ]; then - CONF_TO_EDIT="$NGINX_CONF" - # 自动兜底:如果未传入 DEPLOY_NGINX_CONF,则尝试在宝塔默认目录中定位 vhost 配置文件 - if [ -z "$CONF_TO_EDIT" ] || [ ! -f "$CONF_TO_EDIT" ]; then - CONF_DIR="${DEPLOY_NGINX_CONF_DIR:-/www/server/panel/vhost/nginx}" - if [ -d "$CONF_DIR" ]; then - # 优先匹配旧/新端口对应的 proxy_pass,尽量减少误命中 - for p in "$OLD_PORT" "$NEW_PORT"; do - # proxy_pass 前可能带空格;用正则增强匹配容错 - match="$(grep -rlE "proxy_pass[[:space:]]+http://(127\\.0\\.0\\.1|localhost|0\\.0\\.0\\.0):${p}" "$CONF_DIR" 2>/dev/null | sed -n '1p')" - if [ -n "$match" ]; then - CONF_TO_EDIT="$match" - break - fi - done - # 如果仍未匹配,尝试按域名关键字(可选:DEPLOY_DOMAIN) - if [ -z "$CONF_TO_EDIT" ] && [ -n "${DEPLOY_DOMAIN:-}" ]; then - match="$(grep -rl "${DEPLOY_DOMAIN}" "$CONF_DIR" 2>/dev/null | head -n 1)" - if [ -n "$match" ]; then - CONF_TO_EDIT="$match" - fi - fi - fi - fi - - if [ -n "$CONF_TO_EDIT" ] && [ -f "$CONF_TO_EDIT" ]; then - echo "[5/5] 切换 Nginx 到 $NEW_PORT ...(编辑: $CONF_TO_EDIT)" - # 只在同一个 vhost 配置里替换 proxy_pass 上游端口 - sed -i.bak "s|proxy_pass http://127.0.0.1:[0-9]*|proxy_pass http://127.0.0.1:$NEW_PORT|g" "$CONF_TO_EDIT" - sed -i.bak "s|proxy_pass http://localhost:[0-9]*|proxy_pass http://127.0.0.1:$NEW_PORT|g" "$CONF_TO_EDIT" - sed -i.bak "s|proxy_pass http://0.0.0.0:[0-9]*|proxy_pass http://127.0.0.1:$NEW_PORT|g" "$CONF_TO_EDIT" - nginx -t && nginx -s reload - echo " Nginx 已重载" - else - echo "[5/5] 未找到可编辑的 nginx 配置文件,跳过 Nginx 切换。请手动将 proxy_pass 改为 127.0.0.1:$NEW_PORT" - fi -else - echo "[5/5] 已跳过 Nginx 切换(--skip-nginx)" -fi - -# 停止旧实例(首次部署时可能不存在,忽略错误) -dc -f docker-compose.bluegreen.yml stop "soul-api-$CURRENT" 2>/dev/null || true -echo "$NEW" > "$ACTIVE_FILE" -echo "" -echo "[SUCCESS] 部署完成,当前活跃: $NEW (端口 $NEW_PORT)" diff --git a/soul-api/deploy/runner-init.sh b/soul-api/deploy/runner-init.sh deleted file mode 100644 index d6ef22da..00000000 --- a/soul-api/deploy/runner-init.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# soul-api Runner 首次初始化(在宿主机执行) -# 构建并启动 Runner 容器,之后用 devloy.py --mode runner 部署 -# -# 用法:在 soul-api 根目录执行 -# cd /path/to/soul-api -# bash deploy/runner-init.sh - -set -e -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -cd "$ROOT" - -echo "=== soul-api Runner 初始化 ===" -echo " 项目目录: $ROOT" -echo "" - -# 兼容 docker-compose / docker compose -dc() { - if command -v docker-compose >/dev/null 2>&1; then - docker-compose "$@" - else - docker compose "$@" - fi -} - -echo "[1/2] 构建 Runner 镜像 ..." -docker build -f deploy/Dockerfile.runner -t soul-api-runner:latest . - -echo "[2/2] 启动 Runner 容器 ..." -dc -f deploy/docker-compose.runner.yml up -d - -echo "" -echo "[SUCCESS] Runner 已启动" -echo " 宝塔反向代理保持 proxy_pass http://127.0.0.1:9001" -echo " 首次部署: python devloy.py --mode runner" -echo "" diff --git a/soul-api/deploy/runner/deploy.sh b/soul-api/deploy/runner/deploy.sh deleted file mode 100644 index 75041dbb..00000000 --- a/soul-api/deploy/runner/deploy.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -# soul-api Runner 容器内红蓝切换脚本 -# 用法: /app/deploy.sh /tmp/incoming.tar.gz -# 将新版本解压到非活跃目录,健康检查通过后切换 nginx 并停旧实例 - -set -e -INCOMING="${1:-}" -APP_ROOT="/app" -BLUE="$APP_ROOT/blue" -GREEN="$APP_ROOT/green" -ACTIVE_FILE="$APP_ROOT/.active" -NGINX_CONF="$APP_ROOT/nginx.conf" -NGINX_PID="/tmp/nginx.pid" -REDIS_PASS="soul-docker-redis" - -health_ok() { - local url="$1" - if command -v wget >/dev/null 2>&1; then - wget -qO- "$url" >/dev/null 2>&1 - else - [ -x /usr/bin/wget ] && /usr/bin/wget -qO- "$url" >/dev/null 2>&1 - fi -} - -if [ -z "$INCOMING" ] || [ ! -f "$INCOMING" ]; then - echo "[ERROR] 用法: $0 " - exit 1 -fi - -# 确定当前活跃与待部署目录 -CURRENT="blue" -[ -f "$ACTIVE_FILE" ] && CURRENT=$(cat "$ACTIVE_FILE") -[ "$CURRENT" != "blue" ] && [ "$CURRENT" != "green" ] && CURRENT="blue" - -if [ "$CURRENT" = "blue" ]; then - NEW="green" - NEW_PORT=18082 - OLD_PORT=18081 -else - NEW="blue" - NEW_PORT=18081 - OLD_PORT=18082 -fi - -NEW_DIR="$APP_ROOT/$NEW" -echo "[1/5] 当前活跃: $CURRENT ($OLD_PORT),将部署到: $NEW ($NEW_PORT)" - -# 解压到新目录 -echo "[2/5] 解压到 $NEW_DIR ..." -rm -rf "$NEW_DIR" -mkdir -p "$NEW_DIR" -tar -xzf "$INCOMING" -C "$NEW_DIR" -rm -f "$INCOMING" - -# 设置 PORT 和 REDIS_URL -ENV_FILE="$NEW_DIR/.env" -if [ -f "$ENV_FILE" ]; then - sed -i "s/^PORT=.*/PORT=$NEW_PORT/" "$ENV_FILE" - grep -q "^REDIS_URL=" "$ENV_FILE" || echo "REDIS_URL=redis://:${REDIS_PASS}@127.0.0.1:6379/0" >> "$ENV_FILE" - sed -i "s|^REDIS_URL=.*|REDIS_URL=redis://:${REDIS_PASS}@127.0.0.1:6379/0|" "$ENV_FILE" -fi -chmod +x "$NEW_DIR/soul-api" 2>/dev/null || true - -# 启动新实例 -echo "[3/5] 启动 soul-api-$NEW (端口 $NEW_PORT) ..." -cd "$NEW_DIR" -export PORT=$NEW_PORT -export REDIS_URL="redis://:${REDIS_PASS}@127.0.0.1:6379/0" -nohup ./soul-api >> soul-api.log 2>&1 & -NEW_PID=$! -echo $NEW_PID > "$APP_ROOT/.pid.$NEW" -cd - >/dev/null - -# 等待健康检查(最多 120 秒) -echo "[4/5] 等待健康检查 ..." -sleep 5 -for i in $(seq 1 58); do - if health_ok "http://127.0.0.1:$NEW_PORT/health"; then - echo " 健康检查通过" - break - fi - sleep 2 - if [ $i -eq 58 ]; then - echo "[ERROR] 健康检查超时,新实例未就绪" - kill $NEW_PID 2>/dev/null || true - exit 1 - fi -done - -# 更新 nginx 配置并重载 -echo "[5/5] 切换 nginx 到 $NEW_PORT ..." -sed "s/__BACKEND_PORT__/$NEW_PORT/g" "$APP_ROOT/nginx.conf.template" > "$NGINX_CONF" -nginx -s reload 2>/dev/null || nginx -c "$NGINX_CONF" 2>/dev/null || true - -# 停止旧实例(通过 PID 文件或端口) -OLD_PID_FILE="$APP_ROOT/.pid.$CURRENT" -if [ -f "$OLD_PID_FILE" ]; then - OLD_PID=$(cat "$OLD_PID_FILE") - if kill -0 "$OLD_PID" 2>/dev/null; then - echo " 停止旧实例 (PID $OLD_PID)" - kill "$OLD_PID" 2>/dev/null || true - sleep 2 - fi - rm -f "$OLD_PID_FILE" -fi -# 兜底:通过端口杀进程(Alpine 可用 fuser 或 ss) -if command -v fuser >/dev/null 2>&1; then - fuser -k "$OLD_PORT/tcp" 2>/dev/null || true -fi - -echo "$NEW" > "$ACTIVE_FILE" -echo "" -echo "[SUCCESS] 部署完成,当前活跃: $NEW (端口 $NEW_PORT)" diff --git a/soul-api/deploy/runner/entrypoint.sh b/soul-api/deploy/runner/entrypoint.sh deleted file mode 100644 index d1e91290..00000000 --- a/soul-api/deploy/runner/entrypoint.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# soul-api Runner 容器入口 -# 启动 Redis、Nginx,首次部署时需外部调用 deploy.sh - -set -e -APP_ROOT="/app" -REDIS_PASS="soul-docker-redis" - -# 启动 Redis(后台) -if ! pgrep -x redis-server >/dev/null 2>&1; then - redis-server --requirepass "$REDIS_PASS" --daemonize yes -fi - -# 生成初始 nginx 配置(默认指向 blue 18081,若 blue 未部署则 18082) -BACKEND=18081 -[ -f "$APP_ROOT/.active" ] && [ "$(cat $APP_ROOT/.active)" = "green" ] && BACKEND=18082 -sed "s/__BACKEND_PORT__/$BACKEND/g" "$APP_ROOT/nginx.conf.template" > "$APP_ROOT/nginx.conf" - -# 若已有活跃实例,启动它 -if [ -f "$APP_ROOT/.active" ]; then - ACTIVE=$(cat "$APP_ROOT/.active") - ACTIVE_DIR="$APP_ROOT/$ACTIVE" - if [ -d "$ACTIVE_DIR" ] && [ -x "$ACTIVE_DIR/soul-api" ]; then - PORT=18081 - [ "$ACTIVE" = "green" ] && PORT=18082 - cd "$ACTIVE_DIR" - export PORT=$PORT - export REDIS_URL="redis://:${REDIS_PASS}@127.0.0.1:6379/0" - nohup ./soul-api >> soul-api.log 2>&1 & - echo $! > "$APP_ROOT/.pid.$ACTIVE" - cd - >/dev/null - fi -fi - -# 启动 Nginx(前台,保持容器运行) -exec nginx -c "$APP_ROOT/nginx.conf" -g "daemon off;" diff --git a/soul-api/deploy/runner/nginx.conf.template b/soul-api/deploy/runner/nginx.conf.template deleted file mode 100644 index aec815d3..00000000 --- a/soul-api/deploy/runner/nginx.conf.template +++ /dev/null @@ -1,31 +0,0 @@ -# soul-api Runner - Nginx 反向代理 -# 监听 9001,代理到当前活跃实例(blue=18081, green=18082) -# 宝塔固定 proxy_pass 到 127.0.0.1:9001,无需改配置 - -worker_processes 1; -error_log /dev/stderr warn; -pid /tmp/nginx.pid; - -events { worker_connections 64; } - -http { - access_log /dev/stdout; - include /etc/nginx/mime.types; - default_type application/octet-stream; - - server { - listen 9001; - server_name _; - - location / { - proxy_pass http://127.0.0.1:__BACKEND_PORT__; - proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_connect_timeout 5s; - proxy_read_timeout 60s; - } - } -} diff --git a/soul-api/internal/handler/match.go b/soul-api/internal/handler/match.go index e302b7ac..be6e80c4 100644 --- a/soul-api/internal/handler/match.go +++ b/soul-api/internal/handler/match.go @@ -14,18 +14,30 @@ import ( "gorm.io/gorm" ) -const defaultFreeMatchLimit = 3 +const defaultFreeMatchLimit = 1 const completeProfileSQL = "((phone IS NOT NULL AND phone != '') AND (nickname IS NOT NULL AND nickname != '' AND nickname != '微信用户') AND (avatar IS NOT NULL AND avatar != ''))" // MatchQuota 匹配次数配额(纯计算:订单 + match_records) +// 免费次数为「终身」额度,不按自然日重置;RemainToday JSON 字段名历史遗留,语义为「当前剩余可匹配次数」。 type MatchQuota struct { PurchasedTotal int64 `json:"purchasedTotal"` PurchasedUsed int64 `json:"purchasedUsed"` - MatchesUsedToday int64 `json:"matchesUsedToday"` - FreeRemainToday int64 `json:"freeRemainToday"` + MatchesUsedToday int64 `json:"matchesUsedToday"` // 今日已匹配次数(统计用) + FreeRemainToday int64 `json:"freeRemainToday"` // 终身免费剩余次数(字段名保留) PurchasedRemain int64 `json:"purchasedRemain"` - RemainToday int64 `json:"remainToday"` // 今日剩余可匹配次数 + RemainToday int64 `json:"remainToday"` // 当前剩余可匹配次数(免费剩余 + 已购剩余) +} + +// normalizeFreeMatchLimit 产品规则:终身免费匹配仅 1 次(不按日重置);配置大于 1 时按 1 生效 +func normalizeFreeMatchLimit(n int) int { + if n <= 0 { + return defaultFreeMatchLimit + } + if n > 1 { + return 1 + } + return n } func getFreeMatchLimit(db *gorm.DB) int { @@ -38,35 +50,31 @@ func getFreeMatchLimit(db *gorm.DB) int { return defaultFreeMatchLimit } if v, ok := config["freeMatchLimit"].(float64); ok && v > 0 { - return int(v) + return normalizeFreeMatchLimit(int(v)) } return defaultFreeMatchLimit } -// GetMatchQuota 根据订单和 match_records 纯计算用户匹配配额 +// GetMatchQuota 根据订单和 match_records 纯计算用户匹配配额(免费次数为终身额度,不按日重置) func GetMatchQuota(db *gorm.DB, userID string, freeLimit int) MatchQuota { - if freeLimit <= 0 { - freeLimit = defaultFreeMatchLimit - } + freeLimit = normalizeFreeMatchLimit(freeLimit) var purchasedTotal int64 db.Model(&model.Order{}).Where("user_id = ? AND product_type = ? AND status = ?", userID, "match", "paid").Count(&purchasedTotal) var matchesToday int64 db.Model(&model.MatchRecord{}).Where("user_id = ? AND created_at >= CURDATE()", userID).Count(&matchesToday) - // 历史每日超出免费部分之和 = 已消耗的购买次数 - var purchasedUsed int64 - db.Raw(` - SELECT COALESCE(SUM(cnt - ?), 0) FROM ( - SELECT DATE(created_at) AS d, COUNT(*) AS cnt - FROM match_records WHERE user_id = ? - GROUP BY DATE(created_at) - HAVING cnt > ? - ) t - `, freeLimit, userID, freeLimit).Scan(&purchasedUsed) - freeUsed := matchesToday - if freeUsed > int64(freeLimit) { - freeUsed = int64(freeLimit) + var lifetimeMatches int64 + db.Model(&model.MatchRecord{}).Where("user_id = ?", userID).Count(&lifetimeMatches) + + fl := int64(freeLimit) + beyondFree := lifetimeMatches - fl + if beyondFree < 0 { + beyondFree = 0 } - freeRemain := int64(freeLimit) - freeUsed + purchasedUsed := beyondFree + if purchasedUsed > purchasedTotal { + purchasedUsed = purchasedTotal + } + freeRemain := fl - lifetimeMatches if freeRemain < 0 { freeRemain = 0 } @@ -74,14 +82,17 @@ func GetMatchQuota(db *gorm.DB, userID string, freeLimit int) MatchQuota { if purchasedRemain < 0 { purchasedRemain = 0 } - remainToday := freeRemain + purchasedRemain + remainTotal := freeRemain + purchasedRemain + if remainTotal < 0 { + remainTotal = 0 + } return MatchQuota{ PurchasedTotal: purchasedTotal, PurchasedUsed: purchasedUsed, MatchesUsedToday: matchesToday, FreeRemainToday: freeRemain, PurchasedRemain: purchasedRemain, - RemainToday: remainToday, + RemainToday: remainTotal, } } @@ -100,10 +111,11 @@ func MatchConfigGet(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "success": true, "data": gin.H{ - "matchTypes": defaultMatchTypes, - "freeMatchLimit": 3, - "matchPrice": 1, - "settings": gin.H{"enableFreeMatches": true, "enablePaidMatches": true, "maxMatchesPerDay": 10}, + "matchTypes": defaultMatchTypes, + "freeMatchLimit": 1, + "matchPrice": 1, + "matchPriceOriginal": 9.9, + "settings": gin.H{"enableFreeMatches": true, "enablePaidMatches": true, "maxMatchesPerDay": 10}, }, "source": "default", }) @@ -129,14 +141,18 @@ func MatchConfigGet(c *gin.Context) { matchTypes = defaultMatchTypes } } - freeMatchLimit := 3 - if v, ok := config["freeMatchLimit"].(float64); ok { - freeMatchLimit = int(v) + freeMatchLimit := defaultFreeMatchLimit + if v, ok := config["freeMatchLimit"].(float64); ok && int(v) > 0 { + freeMatchLimit = normalizeFreeMatchLimit(int(v)) } matchPrice := 1 if v, ok := config["matchPrice"].(float64); ok { matchPrice = int(v) } + matchPriceOriginal := 9.9 + if v, ok := config["matchPriceOriginal"].(float64); ok && v > 0 { + matchPriceOriginal = v + } settings := gin.H{"enableFreeMatches": true, "enablePaidMatches": true, "maxMatchesPerDay": 10} if s, ok := config["settings"].(map[string]interface{}); ok { for k, v := range s { @@ -144,7 +160,11 @@ func MatchConfigGet(c *gin.Context) { } } c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{ - "matchTypes": matchTypes, "freeMatchLimit": freeMatchLimit, "matchPrice": matchPrice, "settings": settings, + "matchTypes": matchTypes, + "freeMatchLimit": freeMatchLimit, + "matchPrice": matchPrice, + "matchPriceOriginal": matchPriceOriginal, + "settings": settings, }, "source": "database"}) } @@ -188,7 +208,7 @@ func MatchUsers(c *gin.Context) { if quota.RemainToday <= 0 { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "今日匹配次数已用完,请购买更多次数", + "message": "免费次数已用完,请购买匹配次数后再试", "code": "QUOTA_EXCEEDED", }) return